Skip to content

Commit 1a46712

Browse files
committed
Merge tag 'gpio-v4.6-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 kernel v4.6. There is quite a lot of interesting stuff going on. The patches to other subsystems and arch-wide are ACKed as far as possible, though I consider things like per-arch <asm/gpio.h> as essentially a part of the GPIO subsystem so it should not be needed. Core changes: - The gpio_chip is now a *real device*. Until now the gpio chips were just piggybacking the parent device or (gasp) floating in space outside of the device model. We now finally make GPIO chips devices. The gpio_chip will create a gpio_device which contains a struct device, and this gpio_device struct is kept private. Anything that needs to be kept private from the rest of the kernel will gradually be moved over to the gpio_device. - As a result of making the gpio_device a real device, we have added resource management, so devm_gpiochip_add_data() will cut down on overhead and reduce code lines. A huge slew of patches convert almost all drivers in the subsystem to use this. - Building on making the GPIO a real device, we add the first step of a new userspace ABI: the GPIO character device. We take small steps here, so we first add a pure *information* ABI and the tool "lsgpio" that will list all GPIO devices on the system and all lines on these devices. We can now discover GPIOs properly from userspace. We still have not come up with a way to actually *use* GPIOs from userspace. - To encourage people to use the character device for the future, we have it always-enabled when using GPIO. The old sysfs ABI is still opt-in (and can be used in parallel), but is marked as deprecated. We will keep it around for the foreseeable future, but it will not be extended to cover ever more use cases. Cleanup: - Bjorn Helgaas removed a whole slew of per-architecture <asm/gpio.h> includes. This dates back to when GPIO was an opt-in feature and no shared library even existed: just a header file with proper prototypes was provided and all semantics were up to the arch to implement. These patches make the GPIO chip even more a proper device and cleans out leftovers of the old in-kernel API here and there. Still some cruft is left but it's very little now. - There is still some clamping of return values for .get() going on, but we now return sane values in the vast majority of drivers and the errorpath is sanitized. Some patches for powerpc, blackfin and unicore still drop in. - We continue to switch the ARM, MIPS, blackfin, m68k local GPIO implementations to use gpiochip_add_data() and cut down on code lines. - MPC8xxx is converted to use the generic GPIO helpers. - ATH79 is converted to use the generic GPIO helpers. New drivers: - WinSystems WS16C48 - Acces 104-DIO-48E - F81866 (a F7188x variant) - Qoric (a MPC8xxx variant) - TS-4800 - SPI serializers (pisosr): simple 74xx shift registers connected to SPI to obtain a dirt-cheap output-only GPIO expander. - Texas Instruments TPIC2810 - Texas Instruments TPS65218 - Texas Instruments TPS65912 - X-Gene (ARM64) standby GPIO controller" * tag 'gpio-v4.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (194 commits) Revert "Share upstreaming patches" gpio: mcp23s08: Fix clearing of interrupt. gpiolib: Fix comment referring to gpio_*() in gpiod_*() gpio: pca953x: Fix pca953x_gpio_set_multiple() on 64-bit gpio: xgene: Fix kconfig for standby GIPO contoller gpio: Add generic serializer DT binding gpio: uapi: use 0xB4 as ioctl() major gpio: tps65912: fix bad merge Revert "gpio: lp3943: Drop pin_used and lp3943_gpio_request/lp3943_gpio_free" gpio: omap: drop dev field from gpio_bank structure gpio: mpc8xxx: Slightly update the code for better readability gpio: mpc8xxx: Remove *read_reg and *write_reg from struct mpc8xxx_gpio_chip gpio: mpc8xxx: Fixup setting gpio direction output gpio: mcp23s08: Add support for mcp23s18 dt-bindings: gpio: altera: Fix altr,interrupt-type property gpio: add driver for MEN 16Z127 GPIO controller gpio: lp3943: Drop pin_used and lp3943_gpio_request/lp3943_gpio_free gpio: timberdale: Switch to devm_ioremap_resource() gpio: ts4800: Add IMX51 dependency gpiolib: rewrite gpiodev_add_to_list ...
2 parents 82b666e + ccbd805 commit 1a46712

File tree

169 files changed

+4405
-2663
lines changed

Some content is hidden

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

169 files changed

+4405
-2663
lines changed

Documentation/ABI/testing/sysfs-gpio renamed to Documentation/ABI/obsolete/sysfs-gpio

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
What: /sys/class/gpio/
22
Date: July 2008
33
KernelVersion: 2.6.27
4-
Contact: David Brownell <[email protected]>
4+
Contact: Linus Walleij <[email protected]>
55
Description:
66

77
As a Kconfig option, individual GPIO signals may be accessed from
@@ -26,3 +26,5 @@ Description:
2626
/label ... (r/o) descriptive, not necessarily unique
2727
/ngpio ... (r/o) number of GPIOs; numbered N to N + (ngpio - 1)
2828

29+
This ABI is deprecated and will be removed after 2020. It is
30+
replaced with the GPIO character device.

Documentation/ABI/testing/gpio-cdev

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
What: /dev/gpiochip[0-9]+
2+
Date: November 2015
3+
KernelVersion: 4.4
4+
5+
Description:
6+
The character device files /dev/gpiochip* are the interface
7+
between GPIO chips and userspace.
8+
9+
The ioctl(2)-based ABI is defined and documented in
10+
[include/uapi]<linux/gpio.h>.
11+
12+
The following file operations are supported:
13+
14+
open(2)
15+
Currently the only useful flags are O_RDWR.
16+
17+
ioctl(2)
18+
Initiate various actions.
19+
See the inline documentation in [include/uapi]<linux/gpio.h>
20+
for descriptions of all ioctls.
21+
22+
close(2)
23+
Stops and free up the I/O contexts that was associated
24+
with the file descriptor.
25+
26+
Users: TBD

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Required properties:
1212
- #interrupt-cells : Should be 1. The interrupt type is fixed in the hardware.
1313
- The first cell is the GPIO offset number within the GPIO controller.
1414
- interrupts: Specify the interrupt.
15-
- altr,interrupt-trigger: Specifies the interrupt trigger type the GPIO
15+
- altr,interrupt-type: Specifies the interrupt trigger type the GPIO
1616
hardware is synthesized. This field is required if the Altera GPIO controller
1717
used has IRQ enabled as the interrupt type is not software controlled,
1818
but hardware synthesized. Required if GPIO is used as an interrupt
@@ -35,7 +35,7 @@ gpio_altr: gpio@0xff200000 {
3535
reg = <0xff200000 0x10>;
3636
interrupts = <0 45 4>;
3737
altr,ngpio = <32>;
38-
altr,interrupt-trigger = <IRQ_TYPE_EDGE_RISING>;
38+
altr,interrupt-type = <IRQ_TYPE_EDGE_RISING>;
3939
#gpio-cells = <2>;
4040
gpio-controller;
4141
#interrupt-cells = <1>;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Required properties:
1010

1111
- "microchip,mcp23s08" for 8 GPIO SPI version
1212
- "microchip,mcp23s17" for 16 GPIO SPI version
13+
- "microchip,mcp23s18" for 16 GPIO SPI version
1314
- "microchip,mcp23008" for 8 GPIO I2C version or
1415
- "microchip,mcp23017" for 16 GPIO I2C version of the chip
1516
NOTE: Do not use the old mcp prefix any more. It is deprecated and will be
@@ -43,9 +44,6 @@ Optional properties:
4344
- first cell is the pin number
4445
- second cell is used to specify flags.
4546
- interrupt-controller: Marks the device node as a interrupt controller.
46-
NOTE: The interrupt functionality is only supported for i2c versions of the
47-
chips. The spi chips can also do the interrupts, but this is not supported by
48-
the linux driver yet.
4947

5048
Optional device specific properties:
5149
- microchip,irq-mirror: Sets the mirror flag in the IOCON register. Devices
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Generic Parallel-in/Serial-out Shift Register GPIO Driver
2+
3+
This binding describes generic parallel-in/serial-out shift register
4+
devices that can be used for GPI (General Purpose Input). This includes
5+
SN74165 serial-out shift registers and the SN65HVS88x series of
6+
industrial serializers.
7+
8+
Required properties:
9+
- compatible : Should be "pisosr-gpio".
10+
- gpio-controller : Marks the device node as a GPIO controller.
11+
- #gpio-cells : Should be two. For consumer use see gpio.txt.
12+
13+
Optional properties:
14+
- ngpios : Number of used GPIO lines (0..n-1), default is 8.
15+
- load-gpios : GPIO pin specifier attached to load enable, this
16+
pin is pulsed before reading from the device to
17+
load input pin values into the the device.
18+
19+
For other required and optional properties of SPI slave
20+
nodes please refer to ../spi/spi-bus.txt.
21+
22+
Example:
23+
24+
gpio@0 {
25+
compatible = "ti,sn65hvs882", "pisosr-gpio";
26+
gpio-controller;
27+
#gpio-cells = <2>;
28+
29+
load-gpios = <&gpio2 23 GPIO_ACTIVE_LOW>;
30+
31+
reg = <0>;
32+
spi-max-frequency = <1000000>;
33+
spi-cpol;
34+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
* TS-4800 FPGA's GPIO controller bindings
2+
3+
Required properties:
4+
- compatible: Must be "technologic,ts4800-gpio".
5+
- #gpio-cells: Should be two. The first cell is the pin number.
6+
- reg: Physical base address of the controller and length
7+
of memory mapped region.
8+
9+
Optional property:
10+
- ngpios: See "gpio.txt"
11+
12+
Example:
13+
14+
gpio1: gpio {
15+
compatible = "technologic,ts4800-gpio";
16+
reg = <0x10020 0x6>;
17+
ngpios = <8>;
18+
gpio-controller;
19+
#gpio-cells = <2>;
20+
};
Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
APM X-Gene Standby GPIO controller bindings
22

3-
This is a gpio controller in the standby domain.
4-
5-
There are 20 GPIO pins from 0..21. There is no GPIO_DS14 or GPIO_DS15,
6-
only GPIO_DS8..GPIO_DS13 support interrupts. The IRQ mapping
7-
is currently 1-to-1 on interrupts 0x28 thru 0x2d.
3+
This is a gpio controller in the standby domain. It also supports interrupt in
4+
some particular pins which are sourced to its parent interrupt controller
5+
as diagram below:
6+
+-----------------+
7+
| X-Gene standby |
8+
| GPIO controller +------ GPIO_0
9+
+------------+ | | ...
10+
| Parent IRQ | EXT_INT_0 | +------ GPIO_8/EXT_INT_0
11+
| controller | (SPI40) | | ...
12+
| (GICv2) +--------------+ +------ GPIO_[N+8]/EXT_INT_N
13+
| | ... | |
14+
| | EXT_INT_N | +------ GPIO_[N+9]
15+
| | (SPI[40 + N])| | ...
16+
| +--------------+ +------ GPIO_MAX
17+
+------------+ +-----------------+
818

919
Required properties:
1020
- compatible: "apm,xgene-gpio-sb" for the X-Gene Standby GPIO controller
@@ -15,10 +25,18 @@ Required properties:
1525
0 = active high
1626
1 = active low
1727
- gpio-controller: Marks the device node as a GPIO controller.
18-
- interrupts: Shall contain exactly 6 interrupts.
28+
- interrupts: The EXT_INT_0 parent interrupt resource must be listed first.
29+
- interrupt-parent: Phandle of the parent interrupt controller.
30+
- interrupt-cells: Should be two.
31+
- first cell is 0-N coresponding for EXT_INT_0 to EXT_INT_N.
32+
- second cell is used to specify flags.
33+
- interrupt-controller: Marks the device node as an interrupt controller.
34+
- apm,nr-gpios: Optional, specify number of gpios pin.
35+
- apm,nr-irqs: Optional, specify number of interrupt pins.
36+
- apm,irq-start: Optional, specify lowest gpio pin support interrupt.
1937

2038
Example:
21-
sbgpio: sbgpio@17001000 {
39+
sbgpio: gpio@17001000{
2240
compatible = "apm,xgene-gpio-sb";
2341
reg = <0x0 0x17001000 0x0 0x400>;
2442
#gpio-cells = <2>;
@@ -29,4 +47,19 @@ Example:
2947
<0x0 0x2b 0x1>,
3048
<0x0 0x2c 0x1>,
3149
<0x0 0x2d 0x1>;
50+
interrupt-parent = <&gic>;
51+
#interrupt-cells = <2>;
52+
interrupt-controller;
53+
apm,nr-gpios = <22>;
54+
apm,nr-irqs = <6>;
55+
apm,irq-start = <8>;
56+
};
57+
58+
testuser {
59+
compatible = "example,testuser";
60+
/* Use the GPIO_13/EXT_INT_5 line as an active high triggered
61+
* level interrupt
62+
*/
63+
interrupts = <5 4>;
64+
interrupt-parent = <&sbgpio>;
3265
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
* TPS65912 Power Management Integrated Circuit bindings
2+
3+
Required properties:
4+
- compatible : Should be "ti,tps65912".
5+
- reg : Slave address or chip select number (I2C / SPI).
6+
- interrupt-parent : The parent interrupt controller.
7+
- interrupts : The interrupt line the device is connected to.
8+
- interrupt-controller : Marks the device node as an interrupt controller.
9+
- #interrupt-cells : The number of cells to describe an IRQ, should be 2.
10+
The first cell is the IRQ number.
11+
The second cell is the flags, encoded as trigger
12+
masks from ../interrupt-controller/interrupts.txt.
13+
- gpio-controller : Marks the device node as a GPIO Controller.
14+
- #gpio-cells : Should be two. The first cell is the pin number and
15+
the second cell is used to specify flags.
16+
See ../gpio/gpio.txt for more information.
17+
- regulators: : List of child nodes that specify the regulator
18+
initialization data. Child nodes must be named
19+
after their hardware counterparts: dcdc[1-4] and
20+
ldo[1-10]. Each child nodes is defined using the
21+
standard binding for regulators.
22+
23+
Example:
24+
25+
pmic: tps65912@2d {
26+
compatible = "ti,tps65912";
27+
reg = <0x2d>;
28+
interrupt-parent = <&gpio1>;
29+
interrupts = <28 IRQ_TYPE_LEVEL_LOW>;
30+
interrupt-controller;
31+
#interrupt-cells = <2>;
32+
gpio-controller;
33+
#gpio-cells = <2>;
34+
35+
regulators {
36+
dcdc1 {
37+
regulator-name = "vdd_core";
38+
regulator-min-microvolt = <912000>;
39+
regulator-max-microvolt = <1144000>;
40+
regulator-boot-on;
41+
regulator-always-on;
42+
};
43+
44+
ldo1 {
45+
regulator-name = "ldo1";
46+
regulator-min-microvolt = <1900000>;
47+
regulator-max-microvolt = <1900000>;
48+
};
49+
};
50+
};

Documentation/driver-model/devres.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ GPIO
252252
devm_gpiod_get_index_optional()
253253
devm_gpiod_get_optional()
254254
devm_gpiod_put()
255+
devm_gpiochip_add_data()
256+
devm_gpiochip_remove()
257+
devm_gpio_request()
258+
devm_gpio_request_one()
259+
devm_gpio_free()
255260

256261
IIO
257262
devm_iio_device_alloc()

Documentation/gpio/board.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,13 @@ files that desire to do so need to include the following header:
111111
GPIOs are mapped by the means of tables of lookups, containing instances of the
112112
gpiod_lookup structure. Two macros are defined to help declaring such mappings:
113113

114-
GPIO_LOOKUP(chip_label, chip_hwnum, dev_id, con_id, flags)
115-
GPIO_LOOKUP_IDX(chip_label, chip_hwnum, dev_id, con_id, idx, flags)
114+
GPIO_LOOKUP(chip_label, chip_hwnum, con_id, flags)
115+
GPIO_LOOKUP_IDX(chip_label, chip_hwnum, con_id, idx, flags)
116116

117117
where
118118

119119
- chip_label is the label of the gpiod_chip instance providing the GPIO
120120
- chip_hwnum is the hardware number of the GPIO within the chip
121-
- dev_id is the identifier of the device that will make use of this GPIO. It
122-
can be NULL, in which case it will be matched for calls to gpiod_get()
123-
with a NULL device.
124121
- con_id is the name of the GPIO function from the device point of view. It
125122
can be NULL, in which case it will match any function.
126123
- idx is the index of the GPIO within the function.
@@ -134,7 +131,9 @@ In the future, these flags might be extended to support more properties.
134131
Note that GPIO_LOOKUP() is just a shortcut to GPIO_LOOKUP_IDX() where idx = 0.
135132

136133
A lookup table can then be defined as follows, with an empty entry defining its
137-
end:
134+
end. The 'dev_id' field of the table is the identifier of the device that will
135+
make use of these GPIOs. It can be NULL, in which case it will be matched for
136+
calls to gpiod_get() with a NULL device.
138137

139138
struct gpiod_lookup_table gpios_table = {
140139
.dev_id = "foo.0",

Documentation/ioctl/ioctl-number.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ Code Seq#(hex) Include File Comments
319319
320320
0xB1 00-1F PPPoX <mailto:[email protected]>
321321
0xB3 00 linux/mmc/ioctl.h
322+
0xB4 00-0F linux/gpio.h <mailto:[email protected]>
322323
0xC0 00-0F linux/usb/iowarrior.h
323324
0xCA 00-0F uapi/misc/cxl.h
324325
0xCA 80-8F uapi/scsi/cxlflash_ioctl.h

MAINTAINERS

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ L: [email protected]
238238
S: Maintained
239239
F: drivers/hwmon/abituguru3.c
240240

241+
ACCES 104-DIO-48E GPIO DRIVER
242+
M: William Breathitt Gray <[email protected]>
243+
244+
S: Maintained
245+
F: drivers/gpio/gpio-104-dio-48e.c
246+
241247
ACCES 104-IDI-48 GPIO DRIVER
242248
M: "William Breathitt Gray" <[email protected]>
243249
@@ -4827,10 +4833,14 @@ L: [email protected]
48274833
T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git
48284834
S: Maintained
48294835
F: Documentation/gpio/
4836+
F: Documentation/ABI/testing/gpio-cdev
4837+
F: Documentation/ABI/obsolete/sysfs-gpio
48304838
F: drivers/gpio/
48314839
F: include/linux/gpio/
48324840
F: include/linux/gpio.h
48334841
F: include/asm-generic/gpio.h
4842+
F: include/uapi/linux/gpio.h
4843+
F: tools/gpio/
48344844

48354845
GRE DEMULTIPLEXER DRIVER
48364846
M: Dmitry Kozlov <[email protected]>
@@ -11931,6 +11941,12 @@ M: David Härdeman <[email protected]>
1193111941
S: Maintained
1193211942
F: drivers/media/rc/winbond-cir.c
1193311943

11944+
WINSYSTEMS WS16C48 GPIO DRIVER
11945+
M: William Breathitt Gray <[email protected]>
11946+
11947+
S: Maintained
11948+
F: drivers/gpio/gpio-ws16c48.c
11949+
1193411950
WIMAX STACK
1193511951
M: Inaky Perez-Gonzalez <[email protected]>
1193611952

arch/alpha/include/asm/gpio.h

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

arch/arm/common/scoop.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void __scoop_gpio_set(struct scoop_dev *sdev,
6969

7070
static void scoop_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
7171
{
72-
struct scoop_dev *sdev = container_of(chip, struct scoop_dev, gpio);
72+
struct scoop_dev *sdev = gpiochip_get_data(chip);
7373
unsigned long flags;
7474

7575
spin_lock_irqsave(&sdev->scoop_lock, flags);
@@ -81,7 +81,7 @@ static void scoop_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
8181

8282
static int scoop_gpio_get(struct gpio_chip *chip, unsigned offset)
8383
{
84-
struct scoop_dev *sdev = container_of(chip, struct scoop_dev, gpio);
84+
struct scoop_dev *sdev = gpiochip_get_data(chip);
8585

8686
/* XXX: I'm unsure, but it seems so */
8787
return !!(ioread16(sdev->base + SCOOP_GPRR) & (1 << (offset + 1)));
@@ -90,7 +90,7 @@ static int scoop_gpio_get(struct gpio_chip *chip, unsigned offset)
9090
static int scoop_gpio_direction_input(struct gpio_chip *chip,
9191
unsigned offset)
9292
{
93-
struct scoop_dev *sdev = container_of(chip, struct scoop_dev, gpio);
93+
struct scoop_dev *sdev = gpiochip_get_data(chip);
9494
unsigned long flags;
9595
unsigned short gpcr;
9696

@@ -108,7 +108,7 @@ static int scoop_gpio_direction_input(struct gpio_chip *chip,
108108
static int scoop_gpio_direction_output(struct gpio_chip *chip,
109109
unsigned offset, int value)
110110
{
111-
struct scoop_dev *sdev = container_of(chip, struct scoop_dev, gpio);
111+
struct scoop_dev *sdev = gpiochip_get_data(chip);
112112
unsigned long flags;
113113
unsigned short gpcr;
114114

@@ -224,7 +224,7 @@ static int scoop_probe(struct platform_device *pdev)
224224
devptr->gpio.direction_input = scoop_gpio_direction_input;
225225
devptr->gpio.direction_output = scoop_gpio_direction_output;
226226

227-
ret = gpiochip_add(&devptr->gpio);
227+
ret = gpiochip_add_data(&devptr->gpio, devptr);
228228
if (ret)
229229
goto err_gpio;
230230
}

0 commit comments

Comments
 (0)