Skip to content

Commit 8e50966

Browse files
committed
Merge tag 'gpio-v3.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO tree bulk changes from Linus Walleij: "A big set this merge window, as we have much going on in this subsystem. The changes to other subsystems (notably a slew of ARM machines as I am doing away with their custom APIs) have all been ACKed to the extent possible. Major changes this time: - Some core improvements and cleanups to the new GPIO descriptor API. This seems to be working now so we can start the exodus to this API, moving gradually away from the global GPIO numberspace. - Incremental improvements to the ACPI GPIO core, and move the few GPIO ACPI clients we have to the GPIO descriptor API right *now* before we go any further. We actually managed to contain this *before* we started to litter the kernel with yet another hackish global numberspace for the ACPI GPIOs, which is a big win. - The RFkill GPIO driver and all platforms using it have been migrated to use the GPIO descriptors rather than fixed number assignments. Tegra machine has been migrated as part of this. - New drivers for MOXA ART, Xtensa GPIO32 and SMSC SCH311x. Those should be really good examples of how I expect a nice GPIO driver to look these days. - Do away with custom GPIO implementations on a major part of the ARM machines: ks8695, lpc32xx, mv78xx0. Make a first step towards the same in the horribly convoluted Samsung S3C include forest. We expect to continue to clean this up as we move forward. - Flag GPIO lines used for IRQ on adnp, bcm-kona, em, intel-mid and lynxpoint. This makes the GPIOlib core aware that a certain GPIO line is used for IRQs and can then enforce some semantics such as disallowing a GPIO line marked as in use for IRQ to be switched to output mode. - Drop all use of irq_set_chip_and_handler_name(). The name provided in these cases were just unhelpful tags like "mux" or "demux". - Extend the MCP23s08 driver to handle interrupts. - Minor incremental improvements for rcar, lynxpoint, em 74x164 and msm drivers. - Some non-urgent bug fixes here and there, duplicate #includes and that usual kind of cleanups" Fix up broken Kconfig file manually to make this all compile. * tag 'gpio-v3.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (71 commits) gpio: mcp23s08: fix casting caused build warning gpio: mcp23s08: depend on OF_GPIO gpio: mcp23s08: Add irq functionality for i2c chips ARM: S5P[v210|c100|64x0]: Fix build error gpio: pxa: clamp gpio get value to [0,1] ARM: s3c24xx: explicit dependency on <plat/gpio-cfg.h> ARM: S3C[24|64]xx: move includes back under <mach/> scope Documentation / ACPI: update to GPIO descriptor API gpio / ACPI: get rid of acpi_gpio.h gpio / ACPI: register to ACPI events automatically mmc: sdhci-acpi: convert to use GPIO descriptor API ARM: s3c24xx: fix build error gpio: f7188x: set can_sleep attribute gpio: samsung: Update documentation gpio: samsung: Remove hardware.h inclusion gpio: xtensa: depend on HAVE_XTENSA_GPIO32 gpio: clps711x: Enable driver compilation with COMPILE_TEST gpio: clps711x: Use of_match_ptr() net: rfkill: gpio: convert to descriptor-based GPIO interface leds: s3c24xx: Fix build failure ...
2 parents 02d0a75 + de755c3 commit 8e50966

155 files changed

Lines changed: 1859 additions & 676 deletions

File tree

Some content is hidden

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

‎Documentation/acpi/enumeration.txt‎

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -293,36 +293,13 @@ the device to the driver. For example:
293293

294294
These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
295295
specifies the path to the controller. In order to use these GPIOs in Linux
296-
we need to translate them to the Linux GPIO numbers.
296+
we need to translate them to the corresponding Linux GPIO descriptors.
297297

298-
In a simple case of just getting the Linux GPIO number from device
299-
resources one can use acpi_get_gpio_by_index() helper function. It takes
300-
pointer to the device and index of the GpioIo/GpioInt descriptor in the
301-
device resources list. For example:
298+
There is a standard GPIO API for that and is documented in
299+
Documentation/gpio.txt.
302300

303-
int gpio_irq, gpio_power;
304-
int ret;
305-
306-
gpio_irq = acpi_get_gpio_by_index(dev, 1, NULL);
307-
if (gpio_irq < 0)
308-
/* handle error */
309-
310-
gpio_power = acpi_get_gpio_by_index(dev, 0, NULL);
311-
if (gpio_power < 0)
312-
/* handle error */
313-
314-
/* Now we can use the GPIO numbers */
315-
316-
Other GpioIo parameters must be converted first by the driver to be
317-
suitable to the gpiolib before passing them.
318-
319-
In case of GpioInt resource an additional call to gpio_to_irq() must be
320-
done before calling request_irq().
321-
322-
Note that the above API is ACPI specific and not recommended for drivers
323-
that need to support non-ACPI systems. The recommended way is to use
324-
the descriptor based GPIO interfaces. The above example looks like this
325-
when converted to the GPIO desc:
301+
In the above example we can get the corresponding two GPIO descriptors with
302+
a code like this:
326303

327304
#include <linux/gpio/consumer.h>
328305
...
@@ -339,4 +316,5 @@ when converted to the GPIO desc:
339316

340317
/* Now we can use the GPIO descriptors */
341318

342-
See also Documentation/gpio.txt.
319+
There are also devm_* versions of these functions which release the
320+
descriptors once the device is released.

‎Documentation/arm/Samsung-S3C24XX/GPIO.txt‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,10 @@ between the calls.
8585
Headers
8686
-------
8787

88-
See arch/arm/mach-s3c2410/include/mach/regs-gpio.h for the list
88+
See arch/arm/mach-s3c24xx/include/mach/regs-gpio.h for the list
8989
of GPIO pins, and the configuration values for them. This
9090
is included by using #include <mach/regs-gpio.h>
9191

92-
The GPIO management functions are defined in the hardware
93-
header arch/arm/mach-s3c2410/include/mach/hardware.h which can be
94-
included by #include <mach/hardware.h>
95-
96-
A useful amount of documentation can be found in the hardware
97-
header on how the GPIO functions (and others) work.
98-
99-
Whilst a number of these functions do make some checks on what
100-
is passed to them, for speed of use, they may not always ensure
101-
that the user supplied data to them is correct.
102-
10392

10493
PIN Numbers
10594
-----------

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,38 @@ Required device specific properties (only for SPI chips):
3838
removed.
3939
- spi-max-frequency = The maximum frequency this chip is able to handle
4040

41-
Example I2C:
41+
Optional properties:
42+
- #interrupt-cells : Should be two.
43+
- first cell is the pin number
44+
- second cell is used to specify flags.
45+
- 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.
49+
50+
Optional device specific properties:
51+
- microchip,irq-mirror: Sets the mirror flag in the IOCON register. Devices
52+
with two interrupt outputs (these are the devices ending with 17 and
53+
those that have 16 IOs) have two IO banks: IO 0-7 form bank 1 and
54+
IO 8-15 are bank 2. These chips have two different interrupt outputs:
55+
One for bank 1 and another for bank 2. If irq-mirror is set, both
56+
interrupts are generated regardless of the bank that an input change
57+
occured on. If it is not set, the interrupt are only generated for the
58+
bank they belong to.
59+
On devices with only one interrupt output this property is useless.
60+
61+
Example I2C (with interrupt):
4262
gpiom1: gpio@20 {
4363
compatible = "microchip,mcp23017";
4464
gpio-controller;
4565
#gpio-cells = <2>;
4666
reg = <0x20>;
67+
68+
interrupt-parent = <&gpio1>;
69+
interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
70+
interrupt-controller;
71+
#interrupt-cells=<2>;
72+
microchip,irq-mirror;
4773
};
4874

4975
Example SPI:
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
MOXA ART GPIO Controller
2+
3+
Required properties:
4+
5+
- #gpio-cells : Should be 2, The first cell is the pin number,
6+
the second cell is used to specify polarity:
7+
0 = active high
8+
1 = active low
9+
- compatible : Must be "moxa,moxart-gpio"
10+
- reg : Should contain registers location and length
11+
12+
Example:
13+
14+
gpio: gpio@98700000 {
15+
gpio-controller;
16+
#gpio-cells = <2>;
17+
compatible = "moxa,moxart-gpio";
18+
reg = <0x98700000 0xC>;
19+
};

‎Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
Required Properties:
44

5-
- compatible: should be one of the following.
5+
- compatible: should contain one of the following.
66
- "renesas,gpio-r8a7778": for R8A7778 (R-Mobile M1) compatible GPIO controller.
77
- "renesas,gpio-r8a7779": for R8A7779 (R-Car H1) compatible GPIO controller.
88
- "renesas,gpio-r8a7790": for R8A7790 (R-Car H2) compatible GPIO controller.
9+
- "renesas,gpio-r8a7791": for R8A7791 (R-Car M2) compatible GPIO controller.
910
- "renesas,gpio-rcar": for generic R-Car GPIO controller.
1011

1112
- reg: Base address and length of each memory resource used by the GPIO

‎Documentation/gpio/board.txt‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ where
7272

7373
- chip_label is the label of the gpiod_chip instance providing the GPIO
7474
- chip_hwnum is the hardware number of the GPIO within the chip
75-
- dev_id is the identifier of the device that will make use of this GPIO. If
76-
NULL, the GPIO will be available to all devices.
75+
- dev_id is the identifier of the device that will make use of this GPIO. It
76+
can be NULL, in which case it will be matched for calls to gpiod_get()
77+
with a NULL device.
7778
- con_id is the name of the GPIO function from the device point of view. It
78-
can be NULL.
79+
can be NULL, in which case it will match any function.
7980
- idx is the index of the GPIO within the function.
8081
- flags is defined to specify the following properties:
8182
* GPIOF_ACTIVE_LOW - to configure the GPIO as active-low
@@ -86,18 +87,23 @@ In the future, these flags might be extended to support more properties.
8687

8788
Note that GPIO_LOOKUP() is just a shortcut to GPIO_LOOKUP_IDX() where idx = 0.
8889

89-
A lookup table can then be defined as follows:
90+
A lookup table can then be defined as follows, with an empty entry defining its
91+
end:
9092

91-
struct gpiod_lookup gpios_table[] = {
92-
GPIO_LOOKUP_IDX("gpio.0", 15, "foo.0", "led", 0, GPIO_ACTIVE_HIGH),
93-
GPIO_LOOKUP_IDX("gpio.0", 16, "foo.0", "led", 1, GPIO_ACTIVE_HIGH),
94-
GPIO_LOOKUP_IDX("gpio.0", 17, "foo.0", "led", 2, GPIO_ACTIVE_HIGH),
95-
GPIO_LOOKUP("gpio.0", 1, "foo.0", "power", GPIO_ACTIVE_LOW),
96-
};
93+
struct gpiod_lookup_table gpios_table = {
94+
.dev_id = "foo.0",
95+
.table = {
96+
GPIO_LOOKUP_IDX("gpio.0", 15, "led", 0, GPIO_ACTIVE_HIGH),
97+
GPIO_LOOKUP_IDX("gpio.0", 16, "led", 1, GPIO_ACTIVE_HIGH),
98+
GPIO_LOOKUP_IDX("gpio.0", 17, "led", 2, GPIO_ACTIVE_HIGH),
99+
GPIO_LOOKUP("gpio.0", 1, "power", GPIO_ACTIVE_LOW),
100+
{ },
101+
},
102+
};
97103

98104
And the table can be added by the board code as follows:
99105

100-
gpiod_add_table(gpios_table, ARRAY_SIZE(gpios_table));
106+
gpiod_add_lookup_table(&gpios_table);
101107

102108
The driver controlling "foo.0" will then be able to obtain its GPIOs as follows:
103109

‎Documentation/gpio/consumer.txt‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ device that displays digits), an additional index argument can be specified:
3838
const char *con_id, unsigned int idx)
3939

4040
Both functions return either a valid GPIO descriptor, or an error code checkable
41-
with IS_ERR(). They will never return a NULL pointer.
41+
with IS_ERR() (they will never return a NULL pointer). -ENOENT will be returned
42+
if and only if no GPIO has been assigned to the device/function/index triplet,
43+
other error codes are used for cases where a GPIO has been assigned but an error
44+
occured while trying to acquire it. This is useful to discriminate between mere
45+
errors and an absence of GPIO for optional GPIO parameters.
4246

4347
Device-managed variants of these functions are also defined:
4448

‎arch/arm/Kconfig‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,6 @@ config ARCH_S3C24XX
711711
select HAVE_S3C2410_WATCHDOG if WATCHDOG
712712
select HAVE_S3C_RTC if RTC_CLASS
713713
select MULTI_IRQ_HANDLER
714-
select NEED_MACH_GPIO_H
715714
select NEED_MACH_IO_H
716715
select SAMSUNG_ATAGS
717716
help
@@ -734,7 +733,6 @@ config ARCH_S3C64XX
734733
select HAVE_S3C2410_I2C if I2C
735734
select HAVE_S3C2410_WATCHDOG if WATCHDOG
736735
select HAVE_TCM
737-
select NEED_MACH_GPIO_H
738736
select NO_IOPORT
739737
select PLAT_SAMSUNG
740738
select PM_GENERIC_DOMAINS
@@ -1594,7 +1592,7 @@ config ARM_PSCI
15941592
config ARCH_NR_GPIO
15951593
int
15961594
default 1024 if ARCH_SHMOBILE || ARCH_TEGRA
1597-
default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5 || SOC_DRA7XX
1595+
default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5 || SOC_DRA7XX || ARCH_S3C24XX || ARCH_S3C64XX
15981596
default 392 if ARCH_U8500
15991597
default 352 if ARCH_VT8500
16001598
default 288 if ARCH_SUNXI

‎arch/arm/mach-ks8695/include/mach/gpio.h‎

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

‎arch/arm/mach-lpc32xx/include/mach/gpio.h‎

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

0 commit comments

Comments
 (0)