Skip to content

Commit 1d8ce0e

Browse files
committed
Merge tag 'gpio-v5.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO changes for the v5.9 kernel cycle. There is nothing too exciting in it, but a new macro that fixes a build failure on a minor ARM32 platform that appeared yesterday is part of it so we better merge it. Core changes: - Introduce the for_each_requested_gpio() macro to help in dependent code all over the place. Also patch a few locations to use it while we are at it. - Split out the sysfs code into its own file. - Split out the character device code into its own file, then make a set of refactorings and improvements to this code. We are setting the stage to revamp the userspace API a bit in the next cycle. - Fix a whole slew of kerneldoc that was wrong or missing. New drivers: - The PCA953x driver now supports the PCAL9535. Driver improvements: - A host of incremental modernizations and improvements to the PCA953x driver. - Incremental improvements to the Xilinx Zynq driver. - Some improvements to the GPIO aggregator driver. - I ran all over the place switching all threaded and other drivers requesting their own IRQ while using the core GPIO IRQ helpers to pass the GPIO irq chip as a template instead of calling the explicit set-up functions. Next merge window we may retire the old code altogether" * tag 'gpio-v5.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (97 commits) gpio: wcove: Request IRQ after all initialisation done gpio: crystalcove: Free IRQ on error path gpio: pca953x: Request IRQ after all initialisation done gpio: don't use same lockdep class for all devm_gpiochip_add_data users gpio: max732x: Use irqchip template gpio: stmpe: Move chip registration gpio: rcar: Use irqchip template gpio: regmap: fix type clash gpio: Correct kernel-doc inconsistency gpio: pci-idio-16: Use irqchip template gpio: pcie-idio-24: Use irqchip template gpio: 104-idio-16: Use irqchip template gpio: 104-idi-48: Use irqchip template gpio: 104-dio-48e: Use irqchip template gpio: ws16c48: Use irqchip template gpio: omap: improve coding style for pin config flags gpio: dln2: Use irqchip template gpio: sch: Add a blank line between declaration and code gpio: sch: changed every 'unsigned' to 'unsigned int' gpio: ich: changed every 'unsigned' to 'unsigned int' ...
2 parents 5855240 + 22cc422 commit 1d8ce0e

Some content is hidden

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

59 files changed

+2048
-1597
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Required properties:
1919
nxp,pca9698
2020
nxp,pcal6416
2121
nxp,pcal6524
22+
nxp,pcal9535
2223
nxp,pcal9555a
2324
maxim,max7310
2425
maxim,max7312
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/gpio/gpio-pca9570.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: PCA9570 I2C GPO expander
8+
9+
maintainers:
10+
- Sungbo Eo <[email protected]>
11+
12+
properties:
13+
compatible:
14+
enum:
15+
- nxp,pca9570
16+
17+
reg:
18+
maxItems: 1
19+
20+
gpio-controller: true
21+
22+
'#gpio-cells':
23+
const: 2
24+
25+
required:
26+
- compatible
27+
- reg
28+
- gpio-controller
29+
- "#gpio-cells"
30+
31+
additionalProperties: false
32+
33+
examples:
34+
- |
35+
i2c0 {
36+
#address-cells = <1>;
37+
#size-cells = <0>;
38+
39+
gpio@24 {
40+
compatible = "nxp,pca9570";
41+
reg = <0x24>;
42+
gpio-controller;
43+
#gpio-cells = <2>;
44+
};
45+
};
46+
47+
...

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Required properties:
66
- First cell is the GPIO line number
77
- Second cell is used to specify optional
88
parameters (unused)
9-
- compatible : Should be "xlnx,zynq-gpio-1.0" or "xlnx,zynqmp-gpio-1.0"
9+
- compatible : Should be "xlnx,zynq-gpio-1.0" or
10+
"xlnx,zynqmp-gpio-1.0" or "xlnx,versal-gpio-1.0
11+
or "xlnx,pmc-gpio-1.0
1012
- clocks : Clock specifier (see clock bindings for details)
1113
- gpio-controller : Marks the device node as a GPIO controller.
1214
- interrupts : Interrupt specifier (see interrupt bindings for

Documentation/driver-api/gpio/drivers-on-gpio.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ hardware descriptions such as device tree or ACPI:
8989
Consumer Electronics Control bus using only GPIO. It is used to communicate
9090
with devices on the HDMI bus.
9191

92+
- gpio-charger: drivers/power/supply/gpio-charger.c is used if you need to do
93+
battery charging and all you have to go by to check the presence of the
94+
AC charger or more complex tasks such as indicating charging status using
95+
nothing but GPIO lines, this driver provides that and also a clearly defined
96+
way to pass the charging parameters from hardware descriptions such as the
97+
device tree.
98+
9299
Apart from this there are special GPIO drivers in subsystems like MMC/SD to
93100
read card detect and write protect GPIO lines, and in the TTY serial subsystem
94101
to emulate MCTRL (modem control) signals CTS/RTS by using two GPIO lines. The

drivers/gpio/Kconfig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ config GPIO_MXS
410410

411411
config GPIO_OCTEON
412412
tristate "Cavium OCTEON GPIO"
413-
depends on GPIOLIB && CAVIUM_OCTEON_SOC
413+
depends on CAVIUM_OCTEON_SOC
414414
default y
415415
help
416416
Say yes here to support the on-chip GPIO lines on the OCTEON
@@ -962,6 +962,14 @@ config GPIO_PCA953X_IRQ
962962
Say yes here to enable the pca953x to be used as an interrupt
963963
controller. It requires the driver to be built in the kernel.
964964

965+
config GPIO_PCA9570
966+
tristate "PCA9570 4-Bit I2C GPO expander"
967+
help
968+
Say yes here to enable the GPO driver for the NXP PCA9570 chip.
969+
970+
To compile this driver as a module, choose M here: the module will
971+
be called gpio-pca9570.
972+
965973
config GPIO_PCF857X
966974
tristate "PCF857x, PCA{85,96}7x, and MAX732[89] I2C GPIO expanders"
967975
select GPIOLIB_IRQCHIP
@@ -1117,7 +1125,7 @@ config GPIO_DLN2
11171125

11181126
config HTC_EGPIO
11191127
bool "HTC EGPIO support"
1120-
depends on GPIOLIB && ARM
1128+
depends on ARM
11211129
help
11221130
This driver supports the CPLD egpio chip present on
11231131
several HTC phones. It provides basic support for input

drivers/gpio/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ obj-$(CONFIG_GPIOLIB) += gpiolib.o
77
obj-$(CONFIG_GPIOLIB) += gpiolib-devres.o
88
obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o
99
obj-$(CONFIG_GPIOLIB) += gpiolib-devprop.o
10+
obj-$(CONFIG_GPIOLIB) += gpiolib-cdev.o
1011
obj-$(CONFIG_OF_GPIO) += gpiolib-of.o
1112
obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o
1213
obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o
@@ -110,6 +111,7 @@ obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o
110111
obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o
111112
obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o
112113
obj-$(CONFIG_GPIO_PCA953X) += gpio-pca953x.o
114+
obj-$(CONFIG_GPIO_PCA9570) += gpio-pca9570.o
113115
obj-$(CONFIG_GPIO_PCF857X) += gpio-pcf857x.o
114116
obj-$(CONFIG_GPIO_PCH) += gpio-pch.o
115117
obj-$(CONFIG_GPIO_PCIE_IDIO_24) += gpio-pcie-idio-24.o

drivers/gpio/TODO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subsystem.
55
GPIO descriptors
66

77
Starting with commit 79a9becda894 the GPIO subsystem embarked on a journey
8-
to move away from the global GPIO numberspace and toward a decriptor-based
8+
to move away from the global GPIO numberspace and toward a descriptor-based
99
approach. This means that GPIO consumers, drivers and machine descriptions
1010
ideally have no use or idea of the global GPIO numberspace that has/was
1111
used in the inception of the GPIO subsystem.

drivers/gpio/gpio-104-dio-48e.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,21 @@ static const char *dio48e_names[DIO48E_NGPIO] = {
368368
"PPI Group 1 Port C 5", "PPI Group 1 Port C 6", "PPI Group 1 Port C 7"
369369
};
370370

371+
static int dio48e_irq_init_hw(struct gpio_chip *gc)
372+
{
373+
struct dio48e_gpio *const dio48egpio = gpiochip_get_data(gc);
374+
375+
/* Disable IRQ by default */
376+
inb(dio48egpio->base + 0xB);
377+
378+
return 0;
379+
}
380+
371381
static int dio48e_probe(struct device *dev, unsigned int id)
372382
{
373383
struct dio48e_gpio *dio48egpio;
374384
const char *const name = dev_name(dev);
385+
struct gpio_irq_chip *girq;
375386
int err;
376387

377388
dio48egpio = devm_kzalloc(dev, sizeof(*dio48egpio), GFP_KERNEL);
@@ -399,13 +410,17 @@ static int dio48e_probe(struct device *dev, unsigned int id)
399410
dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple;
400411
dio48egpio->base = base[id];
401412

402-
raw_spin_lock_init(&dio48egpio->lock);
413+
girq = &dio48egpio->chip.irq;
414+
girq->chip = &dio48e_irqchip;
415+
/* This will let us handle the parent IRQ in the driver */
416+
girq->parent_handler = NULL;
417+
girq->num_parents = 0;
418+
girq->parents = NULL;
419+
girq->default_type = IRQ_TYPE_NONE;
420+
girq->handler = handle_edge_irq;
421+
girq->init_hw = dio48e_irq_init_hw;
403422

404-
err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio);
405-
if (err) {
406-
dev_err(dev, "GPIO registering failed (%d)\n", err);
407-
return err;
408-
}
423+
raw_spin_lock_init(&dio48egpio->lock);
409424

410425
/* initialize all GPIO as output */
411426
outb(0x80, base[id] + 3);
@@ -419,13 +434,9 @@ static int dio48e_probe(struct device *dev, unsigned int id)
419434
outb(0x00, base[id] + 6);
420435
outb(0x00, base[id] + 7);
421436

422-
/* disable IRQ by default */
423-
inb(base[id] + 0xB);
424-
425-
err = gpiochip_irqchip_add(&dio48egpio->chip, &dio48e_irqchip, 0,
426-
handle_edge_irq, IRQ_TYPE_NONE);
437+
err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio);
427438
if (err) {
428-
dev_err(dev, "Could not add irqchip (%d)\n", err);
439+
dev_err(dev, "GPIO registering failed (%d)\n", err);
429440
return err;
430441
}
431442

drivers/gpio/gpio-104-idi-48.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,22 @@ static const char *idi48_names[IDI48_NGPIO] = {
247247
"Bit 18 B", "Bit 19 B", "Bit 20 B", "Bit 21 B", "Bit 22 B", "Bit 23 B"
248248
};
249249

250+
static int idi_48_irq_init_hw(struct gpio_chip *gc)
251+
{
252+
struct idi_48_gpio *const idi48gpio = gpiochip_get_data(gc);
253+
254+
/* Disable IRQ by default */
255+
outb(0, idi48gpio->base + 7);
256+
inb(idi48gpio->base + 7);
257+
258+
return 0;
259+
}
260+
250261
static int idi_48_probe(struct device *dev, unsigned int id)
251262
{
252263
struct idi_48_gpio *idi48gpio;
253264
const char *const name = dev_name(dev);
265+
struct gpio_irq_chip *girq;
254266
int err;
255267

256268
idi48gpio = devm_kzalloc(dev, sizeof(*idi48gpio), GFP_KERNEL);
@@ -275,6 +287,16 @@ static int idi_48_probe(struct device *dev, unsigned int id)
275287
idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple;
276288
idi48gpio->base = base[id];
277289

290+
girq = &idi48gpio->chip.irq;
291+
girq->chip = &idi_48_irqchip;
292+
/* This will let us handle the parent IRQ in the driver */
293+
girq->parent_handler = NULL;
294+
girq->num_parents = 0;
295+
girq->parents = NULL;
296+
girq->default_type = IRQ_TYPE_NONE;
297+
girq->handler = handle_edge_irq;
298+
girq->init_hw = idi_48_irq_init_hw;
299+
278300
raw_spin_lock_init(&idi48gpio->lock);
279301
spin_lock_init(&idi48gpio->ack_lock);
280302

@@ -284,17 +306,6 @@ static int idi_48_probe(struct device *dev, unsigned int id)
284306
return err;
285307
}
286308

287-
/* Disable IRQ by default */
288-
outb(0, base[id] + 7);
289-
inb(base[id] + 7);
290-
291-
err = gpiochip_irqchip_add(&idi48gpio->chip, &idi_48_irqchip, 0,
292-
handle_edge_irq, IRQ_TYPE_NONE);
293-
if (err) {
294-
dev_err(dev, "Could not add irqchip (%d)\n", err);
295-
return err;
296-
}
297-
298309
err = devm_request_irq(dev, irq[id], idi_48_irq_handler, IRQF_SHARED,
299310
name, idi48gpio);
300311
if (err) {

drivers/gpio/gpio-104-idio-16.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,22 @@ static const char *idio_16_names[IDIO_16_NGPIO] = {
224224
"IIN8", "IIN9", "IIN10", "IIN11", "IIN12", "IIN13", "IIN14", "IIN15"
225225
};
226226

227+
static int idio_16_irq_init_hw(struct gpio_chip *gc)
228+
{
229+
struct idio_16_gpio *const idio16gpio = gpiochip_get_data(gc);
230+
231+
/* Disable IRQ by default */
232+
outb(0, idio16gpio->base + 2);
233+
outb(0, idio16gpio->base + 1);
234+
235+
return 0;
236+
}
237+
227238
static int idio_16_probe(struct device *dev, unsigned int id)
228239
{
229240
struct idio_16_gpio *idio16gpio;
230241
const char *const name = dev_name(dev);
242+
struct gpio_irq_chip *girq;
231243
int err;
232244

233245
idio16gpio = devm_kzalloc(dev, sizeof(*idio16gpio), GFP_KERNEL);
@@ -256,6 +268,16 @@ static int idio_16_probe(struct device *dev, unsigned int id)
256268
idio16gpio->base = base[id];
257269
idio16gpio->out_state = 0xFFFF;
258270

271+
girq = &idio16gpio->chip.irq;
272+
girq->chip = &idio_16_irqchip;
273+
/* This will let us handle the parent IRQ in the driver */
274+
girq->parent_handler = NULL;
275+
girq->num_parents = 0;
276+
girq->parents = NULL;
277+
girq->default_type = IRQ_TYPE_NONE;
278+
girq->handler = handle_edge_irq;
279+
girq->init_hw = idio_16_irq_init_hw;
280+
259281
raw_spin_lock_init(&idio16gpio->lock);
260282

261283
err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio);
@@ -264,17 +286,6 @@ static int idio_16_probe(struct device *dev, unsigned int id)
264286
return err;
265287
}
266288

267-
/* Disable IRQ by default */
268-
outb(0, base[id] + 2);
269-
outb(0, base[id] + 1);
270-
271-
err = gpiochip_irqchip_add(&idio16gpio->chip, &idio_16_irqchip, 0,
272-
handle_edge_irq, IRQ_TYPE_NONE);
273-
if (err) {
274-
dev_err(dev, "Could not add irqchip (%d)\n", err);
275-
return err;
276-
}
277-
278289
err = devm_request_irq(dev, irq[id], idio_16_irq_handler, 0, name,
279290
idio16gpio);
280291
if (err) {

0 commit comments

Comments
 (0)