Skip to content

Commit 1334d2a

Browse files
committed
Merge tag 'gpio-updates-for-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio updates from Bartosz Golaszewski: "For this merge window we have two new drivers: support for GPIO-signalled ACPI events on Intel platforms and a generic GPIO-over-pinctrl driver using the ARM SCMI protocol for controlling pins. Several things have been reworked in GPIO core: we unduplicated GPIO hog handling, reduced the number of SRCU locks and dereferences, improved support for software-node-based lookup and removed more legacy code after converting remaining users to modern alternatives. There's also a number of driver reworks and refactoring, documentation updates, some bug-fixes and new tests. GPIO core: - defer probe on software node lookups when the remote software node exists but has not been registered as a firmware node yet - unify GPIO hog handling by moving code duplicated in OF and ACPI modules into GPIO core and allow setting up hogs with software nodes - allow matching GPIO controllers by secondary firmware node if matching by primary does not succeed - demote deferral warnings to debug level as they are quite normal when using software nodes which don't support fw_devlink yet - disable the legacy GPIO character device uAPI v1 supprt in Kconfig by default - rework several core functions in preparation for the upcoming Revocable helper library for protecting resources against sudden removal, this reduces the number of SRCU dereferences in GPIO core - simplify file descriptor logic in GPIO character device code by using FD_PREPARE() - introduce a header defining symbols used by both GPIO consumers and providers to avoid having to include provider-specific headers from drivers which only consume GPIOs - replace snprintf() with strscpy() where formatting is not required New drivers: - add the gpio-by-pinctrl generic driver using the ARM SCMI protocol to control GPIOs (along with SCMI changes pulled from the pinctrl tree) - add a driver providing support for handling of platform events via GPIO-signalled ACPI events (used on Intel Nova Lake and later platforms) Driver changes: - extend the gpio-kempld driver with support for more recent models, interrupts and setting/getting multiple values at once - improve interrupt handling in gpio-brcmstb - add support for multi-SoC systems in gpio-tegra186 - make sure we return correct values from the .get() callbacks in several GPIO drivers by normalizing any values other than 0, 1 or negative error numbers - use flexible arrays in several drivers to reduce the number of required memory allocations - simplify synchronous waiting for virtual drivers to probe and remove the dedicated, a bit overengineered helper library dev-sync-probe - remove unneeded Kconfig dependencies on OF_GPIO in several drivers and subsystems - convert the two remaining users of of_get_named_gpio() to using GPIO descriptors and remove the (no longer used) function along with the header that declares it - add missing includes in gpio-mmio - shrink and simplify code in gpio-max732x by using guard(mutex) - remove duplicated code handling the 'ngpios' property from gpio-ts4800, it's already handled in GPIO core - use correct variable type in gpio-aspeed - add support for a new model in gpio-realtek-otto - allow to specify the active-low setting of simulated hogs over the configfs interface (in addition to existing devicetree support) in gpio-sim Bug fixes: - clear the OF_POPULATED flag on hog nodes in GPIO chip remove path on OF systems - fix resource leaks in error path in gpiochip_add_data_with_key() - drop redundant device reference in gpio-mpsse Tests: - add selftests for use-after-free cases in GPIO character device code DT bindings: - add a DT binding document for SCMI based, gpio-over-pinctrl devices - fix interrupt description in microchip,mpfs-gpio - add new compatible for gpio-realtek-otto - describe the resets of the mpfs-gpio controller - fix maintainer's email in gpio-delay bindings - remove the binding document for cavium,thunder-8890 as the corresponding device is bound over PCI and not firmware nodes Documentation: - update the recommended way of converting legacy boards to using software nodes for GPIO description - describe GPIO line value semantics - misc updates to kerneldocs Misc: - convert OMAP1 ams-delta board to using GPIO hogs described with software nodes" * tag 'gpio-updates-for-v7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (79 commits) gpio: swnode: defer probe on references to unregistered software nodes dt-bindings: gpio: cavium,thunder-8890: Remove DT binding Documentation: gpio: update the preferred method for using software node lookup gpio: gpio-by-pinctrl: s/used to do/is used to do/ gpio: aspeed: fix unsigned long int declaration gpio: rockchip: convert to dynamic GPIO base allocation gpio: remove dev-sync-probe gpio: virtuser: stop using dev-sync-probe gpio: aggregator: stop using dev-sync-probe gpio: sim: stop using dev-sync-probe gpio: Add Intel Nova Lake ACPI GPIO events driver gpiolib: Make deferral warnings debug messages gpiolib: fix hogs with multiple lines gpio: fix up CONFIG_OF dependencies gpio: gpio-by-pinctrl: add pinctrl based generic GPIO driver gpio: dt-bindings: Add GPIO on top of generic pin control firmware: arm_scmi: Allow PINCTRL_REQUEST to return EOPNOTSUPP pinctrl: scmi: ignore PIN_CONFIG_PERSIST_STATE pinctrl: scmi: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE ...
2 parents fbfb6bd + ca13ab6 commit 1334d2a

77 files changed

Lines changed: 2078 additions & 1278 deletions

Some content is hidden

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
77
title: GPIO delay controller
88

99
maintainers:
10-
- Alexander Stein <linux@ew.tq-group.com>
10+
- Alexander Stein <alexander.stein@ew.tq-group.com>
1111

1212
description: |
1313
This binding describes an electrical setup where setting an GPIO output

Documentation/devicetree/bindings/gpio/gpio-thunderx.txt

Lines changed: 0 additions & 27 deletions
This file was deleted.

Documentation/devicetree/bindings/gpio/microchip,mpfs-gpio.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ properties:
3333
clocks:
3434
maxItems: 1
3535

36+
resets:
37+
maxItems: 1
38+
3639
"#gpio-cells":
3740
const: 2
3841

@@ -62,6 +65,11 @@ allOf:
6265
contains:
6366
const: microchip,mpfs-gpio
6467
then:
68+
properties:
69+
ngpios:
70+
enum: [14, 24, 32]
71+
interrupts:
72+
minItems: 14
6573
required:
6674
- interrupts
6775
- "#interrupt-cells"
@@ -82,18 +90,19 @@ examples:
8290
compatible = "microchip,mpfs-gpio";
8391
reg = <0x20122000 0x1000>;
8492
clocks = <&clkcfg 25>;
85-
interrupt-parent = <&plic>;
93+
interrupt-parent = <&irqmux>;
8694
gpio-controller;
8795
#gpio-cells = <2>;
96+
ngpios = <32>;
8897
interrupt-controller;
8998
#interrupt-cells = <2>;
90-
interrupts = <53>, <53>, <53>, <53>,
91-
<53>, <53>, <53>, <53>,
92-
<53>, <53>, <53>, <53>,
93-
<53>, <53>, <53>, <53>,
94-
<53>, <53>, <53>, <53>,
95-
<53>, <53>, <53>, <53>,
96-
<53>, <53>, <53>, <53>,
97-
<53>, <53>, <53>, <53>;
99+
interrupts = <64>, <65>, <66>, <67>,
100+
<68>, <69>, <70>, <71>,
101+
<72>, <73>, <74>, <75>,
102+
<76>, <77>, <78>, <79>,
103+
<80>, <81>, <82>, <83>,
104+
<84>, <85>, <86>, <87>,
105+
<88>, <89>, <90>, <91>,
106+
<92>, <93>, <94>, <95>;
98107
};
99108
...
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/gpio/pin-control-gpio.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Pin control based generic GPIO controller
8+
9+
description:
10+
The pin control-based GPIO will facilitate a pin controller's ability
11+
to drive electric lines high/low and other generic properties of a
12+
pin controller to perform general-purpose one-bit binary I/O.
13+
14+
maintainers:
15+
- Dan Carpenter <dan.carpenter@linaro.org>
16+
17+
properties:
18+
compatible:
19+
const: scmi-pinctrl-gpio
20+
21+
gpio-controller: true
22+
23+
"#gpio-cells":
24+
const: 2
25+
26+
gpio-line-names: true
27+
28+
gpio-ranges: true
29+
30+
ngpios: true
31+
32+
patternProperties:
33+
"^.+-hog(-[0-9]+)?$":
34+
type: object
35+
36+
required:
37+
- gpio-hog
38+
39+
required:
40+
- compatible
41+
- gpio-controller
42+
- "#gpio-cells"
43+
- gpio-ranges
44+
- ngpios
45+
46+
additionalProperties: false
47+
48+
examples:
49+
- |
50+
gpio {
51+
compatible = "scmi-pinctrl-gpio";
52+
gpio-controller;
53+
#gpio-cells = <2>;
54+
ngpios = <4>;
55+
gpio-line-names = "gpio_5_17", "gpio_5_20", "gpio_5_22", "gpio_2_1";
56+
gpio-ranges = <&scmi_pinctrl 0 30 4>;
57+
pinctrl-names = "default";
58+
pinctrl-0 = <&keys_pins>;
59+
};

Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ properties:
3030
- realtek,rtl8390-gpio
3131
- realtek,rtl9300-gpio
3232
- realtek,rtl9310-gpio
33+
- realtek,rtl9607-gpio
3334
- const: realtek,otto-gpio
3435

3536
reg: true

Documentation/driver-api/gpio/board.rst

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ macro, which ties a software node representing the GPIO controller with
108108
consumer device. It allows consumers to use regular gpiolib APIs, such as
109109
gpiod_get(), gpiod_get_optional().
110110

111-
The software node representing a GPIO controller need not be attached to the
112-
GPIO controller device. The only requirement is that the node must be
113-
registered and its name must match the GPIO controller's label.
111+
The software node representing a GPIO controller must be attached to the
112+
GPIO controller device - either as the primary or the secondary firmware node.
114113

115114
For example, here is how to describe a single GPIO-connected LED. This is an
116115
alternative to using platform_data on legacy systems.
@@ -122,8 +121,7 @@ alternative to using platform_data on legacy systems.
122121
#include <linux/gpio/property.h>
123122
124123
/*
125-
* 1. Define a node for the GPIO controller. Its .name must match the
126-
* controller's label.
124+
* 1. Define a node for the GPIO controller.
127125
*/
128126
static const struct software_node gpio_controller_node = {
129127
.name = "gpio-foo",
@@ -153,6 +151,21 @@ alternative to using platform_data on legacy systems.
153151
};
154152
software_node_register_node_group(swnodes);
155153
154+
/*
155+
* 5. Attach the GPIO controller's software node to the device and
156+
* register it.
157+
*/
158+
static void gpio_foo_register(void)
159+
{
160+
struct platform_device_info pdev_info = {
161+
.name = "gpio-foo",
162+
.id = PLATFORM_DEVID_NONE,
163+
.swnode = &gpio_controller_node
164+
};
165+
166+
platform_device_register_full(&pdev_info);
167+
}
168+
156169
// Then register a platform_device for "leds-gpio" and associate
157170
// it with &led_device_swnode via .fwnode.
158171
@@ -239,22 +252,6 @@ mapping and is thus transparent to GPIO consumers.
239252
A set of functions such as gpiod_set_value() is available to work with
240253
the new descriptor-oriented interface.
241254

242-
Boards using platform data can also hog GPIO lines by defining GPIO hog tables.
243-
244-
.. code-block:: c
245-
246-
struct gpiod_hog gpio_hog_table[] = {
247-
GPIO_HOG("gpio.0", 10, "foo", GPIO_ACTIVE_LOW, GPIOD_OUT_HIGH),
248-
{ }
249-
};
250-
251-
And the table can be added to the board code as follows::
252-
253-
gpiod_add_hogs(gpio_hog_table);
254-
255-
The line will be hogged as soon as the gpiochip is created or - in case the
256-
chip was created earlier - when the hog table is registered.
257-
258255
Arrays of pins
259256
--------------
260257
In addition to requesting pins belonging to a function one by one, a device may

Documentation/driver-api/gpio/driver.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,33 @@ atomic context on realtime kernels (inside hard IRQ handlers and similar
8787
contexts). Normally this should not be required.
8888

8989

90+
GPIO level semantics
91+
--------------------
92+
93+
The gpip_chip .get/set[_multiple]() line values are clamped to the boolean
94+
space [0, 1], low level or high level.
95+
96+
Low and high values are defined as physical low on the line in/out to the
97+
connector such as a physical pad, pin or rail.
98+
99+
The GPIO library has internal logic to handle lines that are active low, such
100+
as indicated by overstrike or #name in a schematic, and the driver should not
101+
try to second-guess the logic value of a line.
102+
103+
The way GPIO values are handled by the consumers is that the library present
104+
the *logical* value to the consumer. A line is *asserted* if its *logical*
105+
value is 1, and *de-asserted* if its logical value is 0. If inversion is
106+
required, this is handled by gpiolib and configured using hardware descriptions
107+
such as device tree or ACPI that can clearly indicate if a line is active
108+
high or low.
109+
110+
Since electronics commonly insert inverters as driving stages or protection
111+
buffers in front of a GPIO line it is necessary that this semantic is part
112+
of the hardware description, so that consumers such as kernel drivers need
113+
not worry about this, and can for example assert a RESET line tied to a GPIO
114+
pin by setting it to logic 1 even if it is physically active low.
115+
116+
90117
GPIO electrical configuration
91118
-----------------------------
92119

Documentation/driver-api/gpio/legacy-boards.rst

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ Requirements for GPIO Properties
3636
When using software nodes to describe GPIO connections, the following
3737
requirements must be met for the GPIO core to correctly resolve the reference:
3838

39-
1. **The GPIO controller's software node "name" must match the controller's
40-
"label".** The gpiolib core uses this name to find the corresponding
41-
struct gpio_chip at runtime.
42-
This software node has to be registered, but need not be attached to the
43-
device representing the GPIO controller that is providing the GPIO in
44-
question. It may be left as a "free floating" node.
39+
1. **The GPIO controller's software node must be registered and attached to
40+
the controller's ``struct device`` either as its primary or secondary
41+
firmware node.** The gpiolib core uses the address of the firmware node to
42+
find the corresponding ``struct gpio_chip`` at runtime.
4543

4644
2. **The GPIO property must be a reference.** The ``PROPERTY_ENTRY_GPIO()``
4745
macro handles this as it is an alias for ``PROPERTY_ENTRY_REF()``.
@@ -121,13 +119,21 @@ A typical legacy board file might look like this:
121119
/* Device registration */
122120
static int __init myboard_init(void)
123121
{
122+
struct platform_device_info pdev_info = {
123+
.name = MYBOARD_GPIO_CONTROLLER,
124+
.id = PLATFORM_DEVID_NONE,
125+
.swnode = &gpio_controller_node
126+
};
127+
124128
gpiod_add_lookup_table(&myboard_leds_gpios);
125129
gpiod_add_lookup_table(&myboard_buttons_gpios);
126130
131+
platform_device_register_full(&pdev_info);
127132
platform_device_register_data(NULL, "leds-gpio", -1,
128133
&myboard_leds_pdata, sizeof(myboard_leds_pdata));
129134
platform_device_register_data(NULL, "gpio-keys", -1,
130-
&myboard_buttons_pdata, sizeof(myboard_buttons_pdata));
135+
&myboard_buttons_pdata,
136+
sizeof(myboard_buttons_pdata));
131137
132138
return 0;
133139
}
@@ -141,8 +147,7 @@ Step 1: Define the GPIO Controller Node
141147
***************************************
142148

143149
First, define a software node that represents the GPIO controller that the
144-
LEDs and buttons are connected to. The ``name`` of this node must match the
145-
name of the driver for the GPIO controller (e.g., "gpio-foo").
150+
LEDs and buttons are connected to. The ``name`` of this node is optional.
146151

147152
.. code-block:: c
148153
@@ -257,13 +262,24 @@ software nodes using the ``fwnode`` field in struct platform_device_info.
257262
if (error)
258263
return error;
259264
265+
memset(&pdev_info, 0, sizeof(pdev_info));
266+
pdev_info.name = MYBOARD_GPIO_CONTROLLER;
267+
pdev_info.id = PLATFORM_DEVID_NONE;
268+
pdev_info.swnode = &myboard_gpio_controller_node;
269+
gpio_pdev = platform_device_register_full(&pdev_info);
270+
if (IS_ERR(gpio_pdev)) {
271+
error = PTR_ERR(gpio_pdev);
272+
goto err_unregister_nodes;
273+
}
274+
260275
memset(&pdev_info, 0, sizeof(pdev_info));
261276
pdev_info.name = "leds-gpio";
262277
pdev_info.id = PLATFORM_DEVID_NONE;
263278
pdev_info.fwnode = software_node_fwnode(&myboard_leds_node);
264279
leds_pdev = platform_device_register_full(&pdev_info);
265280
if (IS_ERR(leds_pdev)) {
266281
error = PTR_ERR(leds_pdev);
282+
platform_device_unregister(gpio_pdev);
267283
goto err_unregister_nodes;
268284
}
269285
@@ -274,6 +290,7 @@ software nodes using the ``fwnode`` field in struct platform_device_info.
274290
keys_pdev = platform_device_register_full(&pdev_info);
275291
if (IS_ERR(keys_pdev)) {
276292
error = PTR_ERR(keys_pdev);
293+
platform_device_unregister(gpio_pdev);
277294
platform_device_unregister(leds_pdev);
278295
goto err_unregister_nodes;
279296
}
@@ -289,6 +306,7 @@ software nodes using the ``fwnode`` field in struct platform_device_info.
289306
{
290307
platform_device_unregister(keys_pdev);
291308
platform_device_unregister(leds_pdev);
309+
platform_device_unregister(gpio_pdev);
292310
software_node_unregister_node_group(myboard_swnodes);
293311
}
294312

MAINTAINERS

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10982,7 +10982,6 @@ F: drivers/gpio/
1098210982
F: include/dt-bindings/gpio/
1098310983
F: include/linux/gpio.h
1098410984
F: include/linux/gpio/
10985-
F: include/linux/of_gpio.h
1098610985
K: (devm_)?gpio_(request|free|direction|get|set)
1098710986
K: GPIOD_FLAGS_BIT_NONEXCLUSIVE
1098810987
K: devm_gpiod_unhinge
@@ -12872,6 +12871,13 @@ F: drivers/gpio/gpio-sodaville.c
1287212871
F: drivers/gpio/gpio-tangier.c
1287312872
F: drivers/gpio/gpio-tangier.h
1287412873

12874+
INTEL GPIO GPE DRIVER
12875+
M: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
12876+
R: Mika Westerberg <westeri@kernel.org>
12877+
L: linux-gpio@vger.kernel.org
12878+
S: Supported
12879+
F: drivers/gpio/gpio-novalake-events.c
12880+
1287512881
INTEL GVT-g DRIVERS (Intel GPU Virtualization)
1287612882
R: Zhenyu Wang <zhenyuw.linux@gmail.com>
1287712883
R: Zhi Wang <zhi.wang.linux@gmail.com>

arch/arc/plat-axs10x/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ menuconfig ARC_PLAT_AXS10X
77
bool "Synopsys ARC AXS10x Software Development Platforms"
88
select DW_APB_ICTL
99
select GPIO_DWAPB
10-
select OF_GPIO
1110
select HAVE_PCI
1211
select GENERIC_IRQ_CHIP
1312
select GPIOLIB

0 commit comments

Comments
 (0)