Skip to content

Commit 5143840

Browse files
committed
Merge tag 'gpio-updates-for-v6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio updates from Bartosz Golaszewski: "There are no new drivers this time but several changes to the core GPIO framework and various driver updates. This release cycle, we're starting a relatively straightforward but tedious rework of the GPIO consumer API: for historical reasons, the gpiod_set_value() variants would return void. Not only that but the GPIO provider interface does not even allow drivers to return a value to GPIO core. This is because initial GPIO controllers would be MMIO based and could not fail. We've had I2C, SPI and USB controllers for years too but no way of indicating failures to callers. This changes the consumer interface, adds new provider callbacks and starts converting the drivers under drivers/gpio/ to using them. Once this gets upstream, we'll keep on converting GPIO drivers that live elsewhere and once there are no more users of the old callbacks, we'll remove them and rename the new ones to the previous name. I imagine the last step would happen in one sweeping change like what you did for the remove_new() -> remove() renaming. We've also addressed an issue where invalid return values from GPIO drivers would get propagated to user-space by adding some GPIO-core-level sanitization. Again: not a complex change but way overdue. Other than that: lots of driver and core refactoring, DT-bindings changes and some other minor changes like coding style fixes or header reordering. GPIO core: - add sanitization of return values of GPIO provider callbacks so that invalid ones don't get propagated to user-space - add new variants of the line setter callbacks for GPIO providers that return an integer and allow to indicate driver errors to the GPIO core - change the interface of all gpiod_set_value() variants to return an integer thus becoming able to indicate failures in the underlying layer to callers - drop unneeded ERR_CAST in gpiolib-acpi - use for_each_if() where applicable - provide gpiod_multi_set_value_cansleep() as a new, simpler interface to gpiod_set_array_value_cansleep() and use it across several drivers treewide - reduce the number of atomic reads of the descriptor flags in gpiolib debugfs code - simplify for_each_hwgpio_in_range() and for_each_requested_gpio_in_range() - add support for three-cell GPIO specifiers in GPIO OF code - don't build HTE (hardware timestamp engine) GPIO code with the HTE subsystem disabled in Kconfig - unduplicate calls to gpiod_direction_input_nonotify() - rework the handling of the valid_mask property of GPIO chips: don't allow drivers to set it as it should only be handled by GPIO core and start actually enforcing it in GPIO core for *all* drivers, not only the ones implementing a custom request() callback - get the `ngpios` property from the fwnode of the GPIO chip, not its device in order to handle multi-bank GPIO chips Driver improvements: - convert a part of the GPIO drivers under drivers/gpio/ to using the new value setter callbacks - convert several drivers to using automatic lock guards from cleanup.h - allow building gpio-bt8xx with COMPILE_TEST=y - refactor gpio-74x164 (use devres, cleanup helpers, __counted_by() and bits.h macros) - refactor gpio-latch (use generic device properties, lock guards and some local variables for better readability) - refactor gpio-xilinx (improve the usage of the bitmap API) - support multiple virtual GPIO controller instances in gpio-virtio - allow gpio-regmap to use the standard `ngpios` property from GPIOLIB - factor out the common code for synchronous probing of virtual GPIO devices into its own library - use str_enable_disable(), str_high_low() and other string helpers where applicable - extend the gpio-mmio abstraction layer to allow calling into the pinctrl back-end when setting direction - convert gpio-vf610 to using the gpio-mmio library - use more devres in gpio-adnp - add support for reset-gpios in gpio-pcf857x - add support for more models to gpio-loongson-64bit DT bindings: - add new compatibles to gpio-vf610 and gpio-loongson - add missing gpio-ranges property to gpio-mvebu - add reset-gpios to nxp,pcf8575 - enable gpio-hog parsing in ast2400-gpio Misc: - coding style improvements - kerneldoc fixes - includes reordering - updates to the TODO list" * tag 'gpio-updates-for-v6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (119 commits) gpio: TODO: add an item to track reworking the sysfs interface gpio: TODO: add an item to track the conversion to the new value setters gpio: TODO: add delimiters between tasks for better readability gpio: TODO: remove the pinctrl integration task gpio: TODO: remove task duplication gpio: TODO: remove the item about the new debugfs interface gpio: da9055: use new line value setter callbacks gpio: da9052: use new line value setter callbacks gpio: cs5535: use new line value setter callbacks gpio: crystalcove: use new line value setter callbacks gpio: cros-ec: use new line value setter callbacks gpio: creg-snps: use new line value setter callbacks gpio: cgbc: use new line value setter callbacks gpio: bt8xx: use new line value setter callbacks gpio: bt8xx: use lock guards gpio: bt8xx: allow to build the module with COMPILE_TEST=y gpio: bd9571mwv: use new line value setter callbacks gpio: bd71828: use new line value setter callbacks gpio: bd71815: use new line value setter callbacks gpio: bcm-kona: use new line value setter callbacks ...
2 parents c07666e + af54a2f commit 5143840

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1456
-1169
lines changed

Documentation/devicetree/bindings/gpio/aspeed,ast2400-gpio.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ properties:
4646
minimum: 12
4747
maximum: 232
4848

49+
patternProperties:
50+
"-hog(-[0-9]+)?$":
51+
type: object
52+
required:
53+
- gpio-hog
54+
4955
required:
5056
- compatible
5157
- reg

Documentation/devicetree/bindings/gpio/gpio-mvebu.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ properties:
7272
"#gpio-cells":
7373
const: 2
7474

75+
gpio-ranges:
76+
maxItems: 1
77+
7578
marvell,pwm-offset:
7679
$ref: /schemas/types.yaml#/definitions/uint32
7780
description: Offset in the register map for the pwm registers (in bytes)
@@ -96,6 +99,13 @@ properties:
9699
- const: axi
97100
minItems: 1
98101

102+
patternProperties:
103+
"^(.+-hog(-[0-9]+)?)$":
104+
type: object
105+
106+
required:
107+
- gpio-hog
108+
99109
required:
100110
- compatible
101111
- gpio-controller

Documentation/devicetree/bindings/gpio/gpio-vf610.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ properties:
2828
- items:
2929
- enum:
3030
- fsl,imx93-gpio
31+
- fsl,imx94-gpio
3132
- fsl,imx95-gpio
3233
- const: fsl,imx8ulp-gpio
3334

Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ properties:
2020
- loongson,ls2k2000-gpio1
2121
- loongson,ls2k2000-gpio2
2222
- loongson,ls3a5000-gpio
23+
- loongson,ls3a6000-gpio # Loongson-3A6000 node GPIO
2324
- loongson,ls7a-gpio
25+
- loongson,ls7a2000-gpio1 # LS7A2000 chipset GPIO
26+
- loongson,ls7a2000-gpio2 # LS7A2000 ACPI GPIO
2427
- items:
2528
- const: loongson,ls2k1000-gpio
2629
- const: loongson,ls2k-gpio

Documentation/devicetree/bindings/gpio/nxp,pcf8575.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,43 @@ properties:
7373

7474
wakeup-source: true
7575

76+
reset-gpios:
77+
maxItems: 1
78+
description:
79+
GPIO controlling the (reset active LOW) RESET# pin.
80+
81+
The active polarity of the GPIO must translate to the low state of the
82+
RESET# pin on the IC, i.e. if a GPIO is directly routed to the RESET# pin
83+
without any inverter, GPIO_ACTIVE_LOW is expected.
84+
85+
Performing a reset makes all lines initialized to their input (pulled-up)
86+
state.
87+
88+
allOf:
89+
- if:
90+
properties:
91+
compatible:
92+
not:
93+
contains:
94+
enum:
95+
- nxp,pca9670
96+
- nxp,pca9671
97+
- nxp,pca9672
98+
- nxp,pca9673
99+
then:
100+
properties:
101+
reset-gpios: false
102+
103+
# lines-initial-states XOR reset-gpios
104+
# Performing a reset reinitializes all lines to a known state which
105+
# may not match passed lines-initial-states
106+
- if:
107+
required:
108+
- lines-initial-states
109+
then:
110+
properties:
111+
reset-gpios: false
112+
76113
patternProperties:
77114
"^(.+-hog(-[0-9]+)?)$":
78115
type: object

drivers/gpio/Kconfig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ config GPIO_VF610
757757
default y if SOC_VF610
758758
depends on ARCH_MXC || COMPILE_TEST
759759
select GPIOLIB_IRQCHIP
760+
select GPIO_GENERIC
760761
help
761762
Say yes here to support i.MX or Vybrid vf610 GPIOs.
762763

@@ -1670,7 +1671,7 @@ config GPIO_AMD8111
16701671

16711672
config GPIO_BT8XX
16721673
tristate "BT8XX GPIO abuser"
1673-
depends on VIDEO_BT848=n
1674+
depends on VIDEO_BT848=n || COMPILE_TEST
16741675
help
16751676
The BT8xx frame grabber chip has 24 GPIO pins that can be abused
16761677
as a cheap PCI GPIO card.
@@ -1791,7 +1792,6 @@ menu "SPI GPIO expanders"
17911792

17921793
config GPIO_74X164
17931794
tristate "74x164 serial-in/parallel-out 8-bits shift register"
1794-
depends on OF_GPIO
17951795
help
17961796
Driver for 74x164 compatible serial-in/parallel-out 8-outputs
17971797
shift registers. This driver can be used to provide access
@@ -1911,6 +1911,7 @@ config GPIO_SIM
19111911
tristate "GPIO Simulator Module"
19121912
select IRQ_SIM
19131913
select CONFIGFS_FS
1914+
select DEV_SYNC_PROBE
19141915
help
19151916
This enables the GPIO simulator - a configfs-based GPIO testing
19161917
driver.
@@ -1939,6 +1940,7 @@ config GPIO_VIRTUSER
19391940
select DEBUG_FS
19401941
select CONFIGFS_FS
19411942
select IRQ_WORK
1943+
select DEV_SYNC_PROBE
19421944
help
19431945
Say Y here to enable the configurable, configfs-based virtual GPIO
19441946
consumer testing driver.
@@ -1949,3 +1951,6 @@ config GPIO_VIRTUSER
19491951
endmenu
19501952

19511953
endif
1954+
1955+
config DEV_SYNC_PROBE
1956+
tristate

drivers/gpio/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o
1919
# directly supported by gpio-generic
2020
gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o
2121

22+
# Utilities for drivers that need synchronous fake device creation
23+
obj-$(CONFIG_DEV_SYNC_PROBE) += dev-sync-probe.o
24+
2225
obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o
2326
obj-$(CONFIG_GPIO_104_IDI_48) += gpio-104-idi-48.o
2427
obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o

drivers/gpio/TODO

Lines changed: 33 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
This is a place for planning the ongoing long-term work in the GPIO
22
subsystem.
33

4+
===============================================================================
45

56
GPIO descriptors
67

@@ -48,6 +49,7 @@ Work items:
4849
numberspace accessors from <linux/gpio.h> and eventually delete
4950
<linux/gpio.h> altogether.
5051

52+
-------------------------------------------------------------------------------
5153

5254
Get rid of <linux/of_gpio.h>
5355

@@ -75,6 +77,7 @@ Work items:
7577
- Delete <linux/of_gpio.h> when all the above is complete and everything
7678
uses <linux/gpio/consumer.h> or <linux/gpio/driver.h> instead.
7779

80+
-------------------------------------------------------------------------------
7881

7982
Get rid of <linux/gpio/legacy-of-mm-gpiochip.h>
8083

@@ -85,15 +88,7 @@ Work items:
8588
to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove(),
8689
CONFIG_OF_GPIO_MM_GPIOCHIP from the kernel.
8790

88-
89-
Get rid of <linux/gpio.h>
90-
91-
This legacy header is a one stop shop for anything GPIO is closely tied
92-
to the global GPIO numberspace. The endgame of the above refactorings will
93-
be the removal of <linux/gpio.h> and from that point only the specialized
94-
headers under <linux/gpio/*.h> will be used. This requires all the above to
95-
be completed and is expected to take a long time.
96-
91+
-------------------------------------------------------------------------------
9792

9893
Collect drivers
9994

@@ -108,6 +103,7 @@ At the same time it makes sense to get rid of code duplication in existing or
108103
new coming drivers. For example, gpio-ml-ioh should be incorporated into
109104
gpio-pch.
110105

106+
-------------------------------------------------------------------------------
111107

112108
Generic MMIO GPIO
113109

@@ -128,13 +124,15 @@ Work items:
128124
helpers (x86 inb()/outb()) and convert port-mapped I/O drivers to use
129125
this with dry-coding and sending to maintainers to test
130126

127+
-------------------------------------------------------------------------------
131128

132129
Generic regmap GPIO
133130

134131
In the very similar way to Generic MMIO GPIO convert the users which can
135132
take advantage of using regmap over direct IO accessors. Note, even in
136133
MMIO case the regmap MMIO with gpio-regmap.c is preferable over gpio-mmio.c.
137134

135+
-------------------------------------------------------------------------------
138136

139137
GPIOLIB irqchip
140138

@@ -144,53 +142,7 @@ try to cover any generic kind of irqchip cascaded from a GPIO.
144142
- Look over and identify any remaining easily converted drivers and
145143
dry-code conversions to gpiolib irqchip for maintainers to test
146144

147-
148-
Increase integration with pin control
149-
150-
There are already ways to use pin control as back-end for GPIO and
151-
it may make sense to bring these subsystems closer. One reason for
152-
creating pin control as its own subsystem was that we could avoid any
153-
use of the global GPIO numbers. Once the above is complete, it may
154-
make sense to simply join the subsystems into one and make pin
155-
multiplexing, pin configuration, GPIO, etc selectable options in one
156-
and the same pin control and GPIO subsystem.
157-
158-
159-
Debugfs in place of sysfs
160-
161-
The old sysfs code that enables simple uses of GPIOs from the
162-
command line is still popular despite the existance of the proper
163-
character device. The reason is that it is simple to use on
164-
root filesystems where you only have a minimal set of tools such
165-
as "cat", "echo" etc.
166-
167-
The old sysfs still need to be strongly deprecated and removed
168-
as it relies on the global GPIO numberspace that assume a strict
169-
order of global GPIO numbers that do not change between boots
170-
and is independent of probe order.
171-
172-
To solve this and provide an ABI that people can use for hacks
173-
and development, implement a debugfs interface to manipulate
174-
GPIO lines that can do everything that sysfs can do today: one
175-
directory per gpiochip and one file entry per line:
176-
177-
/sys/kernel/debug/gpiochip/gpiochip0
178-
/sys/kernel/debug/gpiochip/gpiochip0/gpio0
179-
/sys/kernel/debug/gpiochip/gpiochip0/gpio1
180-
/sys/kernel/debug/gpiochip/gpiochip0/gpio2
181-
/sys/kernel/debug/gpiochip/gpiochip0/gpio3
182-
...
183-
/sys/kernel/debug/gpiochip/gpiochip1
184-
/sys/kernel/debug/gpiochip/gpiochip1/gpio0
185-
/sys/kernel/debug/gpiochip/gpiochip1/gpio1
186-
...
187-
188-
The exact files and design of the debugfs interface can be
189-
discussed but the idea is to provide a low-level access point
190-
for debugging and hacking and to expose all lines without the
191-
need of any exporting. Also provide ample ammunition to shoot
192-
oneself in the foot, because this is debugfs after all.
193-
145+
-------------------------------------------------------------------------------
194146

195147
Moving over to immutable irq_chip structures
196148

@@ -209,3 +161,28 @@ A small number of drivers have been converted (pl061, tegra186, msm,
209161
amd, apple), and can be used as examples of how to proceed with this
210162
conversion. Note that drivers using the generic irqchip framework
211163
cannot be converted yet, but watch this space!
164+
165+
-------------------------------------------------------------------------------
166+
167+
Convert all GPIO chips to using the new, value returning line setters
168+
169+
struct gpio_chip's set() and set_multiple() callbacks are now deprecated. They
170+
return void and thus do not allow drivers to indicate failure to set the line
171+
value back to the caller.
172+
173+
We've now added new variants - set_rv() and set_multiple_rv() that return an
174+
integer. Let's convert all GPIO drivers treewide to use the new callbacks,
175+
remove the old ones and finally rename the new ones back to the old names.
176+
177+
-------------------------------------------------------------------------------
178+
179+
Extend the sysfs ABI to allow exporting lines by their HW offsets
180+
181+
The need to support the sysfs GPIO class is one of the main obstacles to
182+
removing the global GPIO numberspace from the kernel. In order to wean users
183+
off using global numbers from user-space, extend the existing interface with
184+
new per-gpiochip export/unexport attributes that allow to refer to GPIOs using
185+
their hardware offsets within the chip.
186+
187+
Encourage users to switch to using them and eventually remove the existing
188+
global export/unexport attribues.

0 commit comments

Comments
 (0)