diff options
42 files changed, 1165 insertions, 161 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio-74xx-mmio.txt b/Documentation/devicetree/bindings/gpio/gpio-74xx-mmio.txt new file mode 100644 index 000000000000..7bb1a9d60133 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/gpio-74xx-mmio.txt | |||
@@ -0,0 +1,30 @@ | |||
1 | * 74XX MMIO GPIO driver | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: Should contain one of the following: | ||
5 | "ti,741g125": for 741G125 (1-bit Input), | ||
6 | "ti,741g174": for 741G74 (1-bit Output), | ||
7 | "ti,742g125": for 742G125 (2-bit Input), | ||
8 | "ti,7474" : for 7474 (2-bit Output), | ||
9 | "ti,74125" : for 74125 (4-bit Input), | ||
10 | "ti,74175" : for 74175 (4-bit Output), | ||
11 | "ti,74365" : for 74365 (6-bit Input), | ||
12 | "ti,74174" : for 74174 (6-bit Output), | ||
13 | "ti,74244" : for 74244 (8-bit Input), | ||
14 | "ti,74273" : for 74273 (8-bit Output), | ||
15 | "ti,741624" : for 741624 (16-bit Input), | ||
16 | "ti,7416374": for 7416374 (16-bit Output). | ||
17 | - reg: Physical base address and length where IC resides. | ||
18 | - gpio-controller: Marks the device node as a gpio controller. | ||
19 | - #gpio-cells: Should be two. The first cell is the pin number and | ||
20 | the second cell is used to specify the GPIO polarity: | ||
21 | 0 = Active High, | ||
22 | 1 = Active Low. | ||
23 | |||
24 | Example: | ||
25 | ctrl: gpio@30008004 { | ||
26 | compatible = "ti,74174"; | ||
27 | reg = <0x30008004 0x1>; | ||
28 | gpio-controller; | ||
29 | #gpio-cells = <2>; | ||
30 | }; | ||
diff --git a/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt b/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt index c306a2d0f2b1..f3332b9a8ed4 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt | |||
@@ -57,6 +57,8 @@ Optional device specific properties: | |||
57 | occurred on. If it is not set, the interrupt are only generated for the | 57 | occurred on. If it is not set, the interrupt are only generated for the |
58 | bank they belong to. | 58 | bank they belong to. |
59 | On devices with only one interrupt output this property is useless. | 59 | On devices with only one interrupt output this property is useless. |
60 | - microchip,irq-active-high: Sets the INTPOL flag in the IOCON register. This | ||
61 | configures the IRQ output polarity as active high. | ||
60 | 62 | ||
61 | Example I2C (with interrupt): | 63 | Example I2C (with interrupt): |
62 | gpiom1: gpio@20 { | 64 | gpiom1: gpio@20 { |
diff --git a/Documentation/devicetree/bindings/gpio/gpio-vf610.txt b/Documentation/devicetree/bindings/gpio/gpio-vf610.txt new file mode 100644 index 000000000000..436cc99c6598 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/gpio-vf610.txt | |||
@@ -0,0 +1,55 @@ | |||
1 | * Freescale VF610 PORT/GPIO module | ||
2 | |||
3 | The Freescale PORT/GPIO modules are two adjacent modules providing GPIO | ||
4 | functionality. Each pair serves 32 GPIOs. The VF610 has 5 instances of | ||
5 | each, and each PORT module has its own interrupt. | ||
6 | |||
7 | Required properties for GPIO node: | ||
8 | - compatible : Should be "fsl,<soc>-gpio", currently "fsl,vf610-gpio" | ||
9 | - reg : The first reg tuple represents the PORT module, the second tuple | ||
10 | the GPIO module. | ||
11 | - interrupts : Should be the port interrupt shared by all 32 pins. | ||
12 | - gpio-controller : Marks the device node as a gpio controller. | ||
13 | - #gpio-cells : Should be two. The first cell is the pin number and | ||
14 | the second cell is used to specify the gpio polarity: | ||
15 | 0 = active high | ||
16 | 1 = active low | ||
17 | - interrupt-controller: Marks the device node as an interrupt controller. | ||
18 | - #interrupt-cells : Should be 2. The first cell is the GPIO number. | ||
19 | The second cell bits[3:0] is used to specify trigger type and level flags: | ||
20 | 1 = low-to-high edge triggered. | ||
21 | 2 = high-to-low edge triggered. | ||
22 | 4 = active high level-sensitive. | ||
23 | 8 = active low level-sensitive. | ||
24 | |||
25 | Note: Each GPIO port should have an alias correctly numbered in "aliases" | ||
26 | node. | ||
27 | |||
28 | Examples: | ||
29 | |||
30 | aliases { | ||
31 | gpio0 = &gpio1; | ||
32 | gpio1 = &gpio2; | ||
33 | }; | ||
34 | |||
35 | gpio1: gpio@40049000 { | ||
36 | compatible = "fsl,vf610-gpio"; | ||
37 | reg = <0x40049000 0x1000 0x400ff000 0x40>; | ||
38 | interrupts = <0 107 IRQ_TYPE_LEVEL_HIGH>; | ||
39 | gpio-controller; | ||
40 | #gpio-cells = <2>; | ||
41 | interrupt-controller; | ||
42 | #interrupt-cells = <2>; | ||
43 | gpio-ranges = <&iomuxc 0 0 32>; | ||
44 | }; | ||
45 | |||
46 | gpio2: gpio@4004a000 { | ||
47 | compatible = "fsl,vf610-gpio"; | ||
48 | reg = <0x4004a000 0x1000 0x400ff040 0x40>; | ||
49 | interrupts = <0 108 IRQ_TYPE_LEVEL_HIGH>; | ||
50 | gpio-controller; | ||
51 | #gpio-cells = <2>; | ||
52 | interrupt-controller; | ||
53 | #interrupt-cells = <2>; | ||
54 | gpio-ranges = <&iomuxc 0 32 32>; | ||
55 | }; | ||
diff --git a/Documentation/devicetree/bindings/gpio/gpio.txt b/Documentation/devicetree/bindings/gpio/gpio.txt index 3fb8f53071b8..b9bd1d64cfa6 100644 --- a/Documentation/devicetree/bindings/gpio/gpio.txt +++ b/Documentation/devicetree/bindings/gpio/gpio.txt | |||
@@ -13,13 +13,22 @@ properties, each containing a 'gpio-list': | |||
13 | gpio-specifier : Array of #gpio-cells specifying specific gpio | 13 | gpio-specifier : Array of #gpio-cells specifying specific gpio |
14 | (controller specific) | 14 | (controller specific) |
15 | 15 | ||
16 | GPIO properties should be named "[<name>-]gpios". The exact | 16 | GPIO properties should be named "[<name>-]gpios", with <name> being the purpose |
17 | meaning of each gpios property must be documented in the device tree | 17 | of this GPIO for the device. While a non-existent <name> is considered valid |
18 | binding for each device. | 18 | for compatibility reasons (resolving to the "gpios" property), it is not allowed |
19 | for new bindings. | ||
19 | 20 | ||
20 | For example, the following could be used to describe GPIO pins used | 21 | GPIO properties can contain one or more GPIO phandles, but only in exceptional |
21 | as chip select lines; with chip selects 0, 1 and 3 populated, and chip | 22 | cases should they contain more than one. If your device uses several GPIOs with |
22 | select 2 left empty: | 23 | distinct functions, reference each of them under its own property, giving it a |
24 | meaningful name. The only case where an array of GPIOs is accepted is when | ||
25 | several GPIOs serve the same function (e.g. a parallel data line). | ||
26 | |||
27 | The exact purpose of each gpios property must be documented in the device tree | ||
28 | binding of the device. | ||
29 | |||
30 | The following example could be used to describe GPIO pins used as device enable | ||
31 | and bit-banged data signals: | ||
23 | 32 | ||
24 | gpio1: gpio1 { | 33 | gpio1: gpio1 { |
25 | gpio-controller | 34 | gpio-controller |
@@ -30,10 +39,12 @@ select 2 left empty: | |||
30 | #gpio-cells = <1>; | 39 | #gpio-cells = <1>; |
31 | }; | 40 | }; |
32 | [...] | 41 | [...] |
33 | chipsel-gpios = <&gpio1 12 0>, | 42 | |
34 | <&gpio1 13 0>, | 43 | enable-gpios = <&gpio2 2>; |
35 | <0>, /* holes are permitted, means no GPIO 2 */ | 44 | data-gpios = <&gpio1 12 0>, |
36 | <&gpio2 2>; | 45 | <&gpio1 13 0>, |
46 | <&gpio1 14 0>, | ||
47 | <&gpio1 15 0>; | ||
37 | 48 | ||
38 | Note that gpio-specifier length is controller dependent. In the | 49 | Note that gpio-specifier length is controller dependent. In the |
39 | above example, &gpio1 uses 2 cells to specify a gpio, while &gpio2 | 50 | above example, &gpio1 uses 2 cells to specify a gpio, while &gpio2 |
@@ -42,16 +53,17 @@ only uses one. | |||
42 | gpio-specifier may encode: bank, pin position inside the bank, | 53 | gpio-specifier may encode: bank, pin position inside the bank, |
43 | whether pin is open-drain and whether pin is logically inverted. | 54 | whether pin is open-drain and whether pin is logically inverted. |
44 | Exact meaning of each specifier cell is controller specific, and must | 55 | Exact meaning of each specifier cell is controller specific, and must |
45 | be documented in the device tree binding for the device. | 56 | be documented in the device tree binding for the device. Use the macros |
57 | defined in include/dt-bindings/gpio/gpio.h whenever possible: | ||
46 | 58 | ||
47 | Example of a node using GPIOs: | 59 | Example of a node using GPIOs: |
48 | 60 | ||
49 | node { | 61 | node { |
50 | gpios = <&qe_pio_e 18 0>; | 62 | enable-gpios = <&qe_pio_e 18 GPIO_ACTIVE_HIGH>; |
51 | }; | 63 | }; |
52 | 64 | ||
53 | In this example gpio-specifier is "18 0" and encodes GPIO pin number, | 65 | GPIO_ACTIVE_HIGH is 0, so in this example gpio-specifier is "18 0" and encodes |
54 | and GPIO flags as accepted by the "qe_pio_e" gpio-controller. | 66 | GPIO pin number, and GPIO flags as accepted by the "qe_pio_e" gpio-controller. |
55 | 67 | ||
56 | 1.1) GPIO specifier best practices | 68 | 1.1) GPIO specifier best practices |
57 | ---------------------------------- | 69 | ---------------------------------- |
diff --git a/Documentation/devicetree/bindings/gpio/pl061-gpio.txt b/Documentation/devicetree/bindings/gpio/pl061-gpio.txt index a2c416bcbccc..89058d375b7c 100644 --- a/Documentation/devicetree/bindings/gpio/pl061-gpio.txt +++ b/Documentation/devicetree/bindings/gpio/pl061-gpio.txt | |||
@@ -7,4 +7,4 @@ Required properties: | |||
7 | - bit 0 specifies polarity (0 for normal, 1 for inverted) | 7 | - bit 0 specifies polarity (0 for normal, 1 for inverted) |
8 | - gpio-controller : Marks the device node as a GPIO controller. | 8 | - gpio-controller : Marks the device node as a GPIO controller. |
9 | - interrupts : Interrupt mapping for GPIO IRQ. | 9 | - interrupts : Interrupt mapping for GPIO IRQ. |
10 | 10 | - gpio-ranges : Interaction with the PINCTRL subsystem. | |
diff --git a/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt b/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt index 941a26aa4322..38fb86f28ba2 100644 --- a/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt +++ b/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt | |||
@@ -6,7 +6,9 @@ Required Properties: | |||
6 | - "renesas,gpio-r8a7778": for R8A7778 (R-Mobile M1) compatible GPIO controller. | 6 | - "renesas,gpio-r8a7778": for R8A7778 (R-Mobile M1) compatible GPIO controller. |
7 | - "renesas,gpio-r8a7779": for R8A7779 (R-Car H1) compatible GPIO controller. | 7 | - "renesas,gpio-r8a7779": for R8A7779 (R-Car H1) compatible GPIO controller. |
8 | - "renesas,gpio-r8a7790": for R8A7790 (R-Car H2) compatible GPIO controller. | 8 | - "renesas,gpio-r8a7790": for R8A7790 (R-Car H2) compatible GPIO controller. |
9 | - "renesas,gpio-r8a7791": for R8A7791 (R-Car M2) compatible GPIO controller. | 9 | - "renesas,gpio-r8a7791": for R8A7791 (R-Car M2-W) compatible GPIO controller. |
10 | - "renesas,gpio-r8a7793": for R8A7793 (R-Car M2-N) compatible GPIO controller. | ||
11 | - "renesas,gpio-r8a7794": for R8A7794 (R-Car E2) compatible GPIO controller. | ||
10 | - "renesas,gpio-rcar": for generic R-Car GPIO controller. | 12 | - "renesas,gpio-rcar": for generic R-Car GPIO controller. |
11 | 13 | ||
12 | - reg: Base address and length of each memory resource used by the GPIO | 14 | - reg: Base address and length of each memory resource used by the GPIO |
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt index 859918db36b8..d85fbae451ea 100644 --- a/Documentation/gpio/consumer.txt +++ b/Documentation/gpio/consumer.txt | |||
@@ -199,6 +199,33 @@ The active-low state of a GPIO can also be queried using the following call: | |||
199 | Note that these functions should only be used with great moderation ; a driver | 199 | Note that these functions should only be used with great moderation ; a driver |
200 | should not have to care about the physical line level. | 200 | should not have to care about the physical line level. |
201 | 201 | ||
202 | |||
203 | Set multiple GPIO outputs with a single function call | ||
204 | ----------------------------------------------------- | ||
205 | The following functions set the output values of an array of GPIOs: | ||
206 | |||
207 | void gpiod_set_array(unsigned int array_size, | ||
208 | struct gpio_desc **desc_array, | ||
209 | int *value_array) | ||
210 | void gpiod_set_raw_array(unsigned int array_size, | ||
211 | struct gpio_desc **desc_array, | ||
212 | int *value_array) | ||
213 | void gpiod_set_array_cansleep(unsigned int array_size, | ||
214 | struct gpio_desc **desc_array, | ||
215 | int *value_array) | ||
216 | void gpiod_set_raw_array_cansleep(unsigned int array_size, | ||
217 | struct gpio_desc **desc_array, | ||
218 | int *value_array) | ||
219 | |||
220 | The array can be an arbitrary set of GPIOs. The functions will try to set | ||
221 | GPIOs belonging to the same bank or chip simultaneously if supported by the | ||
222 | corresponding chip driver. In that case a significantly improved performance | ||
223 | can be expected. If simultaneous setting is not possible the GPIOs will be set | ||
224 | sequentially. | ||
225 | Note that for optimal performance GPIOs belonging to the same chip should be | ||
226 | contiguous within the array of descriptors. | ||
227 | |||
228 | |||
202 | GPIOs mapped to IRQs | 229 | GPIOs mapped to IRQs |
203 | -------------------- | 230 | -------------------- |
204 | GPIO lines can quite often be used as IRQs. You can get the IRQ number | 231 | GPIO lines can quite often be used as IRQs. You can get the IRQ number |
diff --git a/Documentation/gpio/driver.txt b/Documentation/gpio/driver.txt index 31e0b5db55d8..90d0f6aba7a6 100644 --- a/Documentation/gpio/driver.txt +++ b/Documentation/gpio/driver.txt | |||
@@ -158,12 +158,12 @@ Locking IRQ usage | |||
158 | Input GPIOs can be used as IRQ signals. When this happens, a driver is requested | 158 | Input GPIOs can be used as IRQ signals. When this happens, a driver is requested |
159 | to mark the GPIO as being used as an IRQ: | 159 | to mark the GPIO as being used as an IRQ: |
160 | 160 | ||
161 | int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset) | 161 | int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset) |
162 | 162 | ||
163 | This will prevent the use of non-irq related GPIO APIs until the GPIO IRQ lock | 163 | This will prevent the use of non-irq related GPIO APIs until the GPIO IRQ lock |
164 | is released: | 164 | is released: |
165 | 165 | ||
166 | void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) | 166 | void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) |
167 | 167 | ||
168 | When implementing an irqchip inside a GPIO driver, these two functions should | 168 | When implementing an irqchip inside a GPIO driver, these two functions should |
169 | typically be called in the .startup() and .shutdown() callbacks from the | 169 | typically be called in the .startup() and .shutdown() callbacks from the |
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 23dfd5f59b39..633ec216e185 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -112,6 +112,20 @@ config GPIO_MAX730X | |||
112 | 112 | ||
113 | comment "Memory mapped GPIO drivers:" | 113 | comment "Memory mapped GPIO drivers:" |
114 | 114 | ||
115 | config GPIO_74XX_MMIO | ||
116 | tristate "GPIO driver for 74xx-ICs with MMIO access" | ||
117 | depends on OF_GPIO | ||
118 | select GPIO_GENERIC | ||
119 | help | ||
120 | Say yes here to support GPIO functionality for 74xx-compatible ICs | ||
121 | with MMIO access. Compatible models include: | ||
122 | 1 bit: 741G125 (Input), 741G74 (Output) | ||
123 | 2 bits: 742G125 (Input), 7474 (Output) | ||
124 | 4 bits: 74125 (Input), 74175 (Output) | ||
125 | 6 bits: 74365 (Input), 74174 (Output) | ||
126 | 8 bits: 74244 (Input), 74273 (Output) | ||
127 | 16 bits: 741624 (Input), 7416374 (Output) | ||
128 | |||
115 | config GPIO_CLPS711X | 129 | config GPIO_CLPS711X |
116 | tristate "CLPS711X GPIO support" | 130 | tristate "CLPS711X GPIO support" |
117 | depends on ARCH_CLPS711X || COMPILE_TEST | 131 | depends on ARCH_CLPS711X || COMPILE_TEST |
@@ -134,6 +148,8 @@ config GPIO_GENERIC_PLATFORM | |||
134 | 148 | ||
135 | config GPIO_DWAPB | 149 | config GPIO_DWAPB |
136 | tristate "Synopsys DesignWare APB GPIO driver" | 150 | tristate "Synopsys DesignWare APB GPIO driver" |
151 | depends on ARM | ||
152 | depends on OF_GPIO | ||
137 | select GPIO_GENERIC | 153 | select GPIO_GENERIC |
138 | select GENERIC_IRQ_CHIP | 154 | select GENERIC_IRQ_CHIP |
139 | help | 155 | help |
@@ -333,6 +349,13 @@ config GPIO_TZ1090_PDC | |||
333 | help | 349 | help |
334 | Say yes here to support Toumaz Xenif TZ1090 PDC GPIOs. | 350 | Say yes here to support Toumaz Xenif TZ1090 PDC GPIOs. |
335 | 351 | ||
352 | config GPIO_VF610 | ||
353 | def_bool y | ||
354 | depends on ARCH_MXC && SOC_VF610 | ||
355 | select GPIOLIB_IRQCHIP | ||
356 | help | ||
357 | Say yes here to support Vybrid vf610 GPIOs. | ||
358 | |||
336 | config GPIO_XGENE | 359 | config GPIO_XGENE |
337 | bool "APM X-Gene GPIO controller support" | 360 | bool "APM X-Gene GPIO controller support" |
338 | depends on ARM64 && OF_GPIO | 361 | depends on ARM64 && OF_GPIO |
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index e60677b8ccb4..81755f1305e6 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile | |||
@@ -13,6 +13,7 @@ obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o | |||
13 | obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o | 13 | obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o |
14 | 14 | ||
15 | obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o | 15 | obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o |
16 | obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o | ||
16 | obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o | 17 | obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o |
17 | obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o | 18 | obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o |
18 | obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o | 19 | obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o |
@@ -96,6 +97,7 @@ obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o | |||
96 | obj-$(CONFIG_GPIO_TZ1090) += gpio-tz1090.o | 97 | obj-$(CONFIG_GPIO_TZ1090) += gpio-tz1090.o |
97 | obj-$(CONFIG_GPIO_TZ1090_PDC) += gpio-tz1090-pdc.o | 98 | obj-$(CONFIG_GPIO_TZ1090_PDC) += gpio-tz1090-pdc.o |
98 | obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o | 99 | obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o |
100 | obj-$(CONFIG_GPIO_VF610) += gpio-vf610.o | ||
99 | obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o | 101 | obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o |
100 | obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o | 102 | obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o |
101 | obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o | 103 | obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o |
diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c new file mode 100644 index 000000000000..0763655cca6c --- /dev/null +++ b/drivers/gpio/gpio-74xx-mmio.c | |||
@@ -0,0 +1,170 @@ | |||
1 | /* | ||
2 | * 74xx MMIO GPIO driver | ||
3 | * | ||
4 | * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/err.h> | ||
13 | #include <linux/gpio.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/of_device.h> | ||
16 | #include <linux/basic_mmio_gpio.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | |||
19 | #define MMIO_74XX_DIR_IN (0 << 8) | ||
20 | #define MMIO_74XX_DIR_OUT (1 << 8) | ||
21 | #define MMIO_74XX_BIT_CNT(x) ((x) & 0xff) | ||
22 | |||
23 | struct mmio_74xx_gpio_priv { | ||
24 | struct bgpio_chip bgc; | ||
25 | unsigned flags; | ||
26 | }; | ||
27 | |||
28 | static const struct of_device_id mmio_74xx_gpio_ids[] = { | ||
29 | { | ||
30 | .compatible = "ti,741g125", | ||
31 | .data = (const void *)(MMIO_74XX_DIR_IN | 1), | ||
32 | }, | ||
33 | { | ||
34 | .compatible = "ti,742g125", | ||
35 | .data = (const void *)(MMIO_74XX_DIR_IN | 2), | ||
36 | }, | ||
37 | { | ||
38 | .compatible = "ti,74125", | ||
39 | .data = (const void *)(MMIO_74XX_DIR_IN | 4), | ||
40 | }, | ||
41 | { | ||
42 | .compatible = "ti,74365", | ||
43 | .data = (const void *)(MMIO_74XX_DIR_IN | 6), | ||
44 | }, | ||
45 | { | ||
46 | .compatible = "ti,74244", | ||
47 | .data = (const void *)(MMIO_74XX_DIR_IN | 8), | ||
48 | }, | ||
49 | { | ||
50 | .compatible = "ti,741624", | ||
51 | .data = (const void *)(MMIO_74XX_DIR_IN | 16), | ||
52 | }, | ||
53 | { | ||
54 | .compatible = "ti,741g74", | ||
55 | .data = (const void *)(MMIO_74XX_DIR_OUT | 1), | ||
56 | }, | ||
57 | { | ||
58 | .compatible = "ti,7474", | ||
59 | .data = (const void *)(MMIO_74XX_DIR_OUT | 2), | ||
60 | }, | ||
61 | { | ||
62 | .compatible = "ti,74175", | ||
63 | .data = (const void *)(MMIO_74XX_DIR_OUT | 4), | ||
64 | }, | ||
65 | { | ||
66 | .compatible = "ti,74174", | ||
67 | .data = (const void *)(MMIO_74XX_DIR_OUT | 6), | ||
68 | }, | ||
69 | { | ||
70 | .compatible = "ti,74273", | ||
71 | .data = (const void *)(MMIO_74XX_DIR_OUT | 8), | ||
72 | }, | ||
73 | { | ||
74 | .compatible = "ti,7416374", | ||
75 | .data = (const void *)(MMIO_74XX_DIR_OUT | 16), | ||
76 | }, | ||
77 | { } | ||
78 | }; | ||
79 | MODULE_DEVICE_TABLE(of, mmio_74xx_gpio_ids); | ||
80 | |||
81 | static inline struct mmio_74xx_gpio_priv *to_74xx_gpio(struct gpio_chip *gc) | ||
82 | { | ||
83 | struct bgpio_chip *bgc = to_bgpio_chip(gc); | ||
84 | |||
85 | return container_of(bgc, struct mmio_74xx_gpio_priv, bgc); | ||
86 | } | ||
87 | |||
88 | static int mmio_74xx_get_direction(struct gpio_chip *gc, unsigned offset) | ||
89 | { | ||
90 | struct mmio_74xx_gpio_priv *priv = to_74xx_gpio(gc); | ||
91 | |||
92 | return (priv->flags & MMIO_74XX_DIR_OUT) ? GPIOF_DIR_OUT : GPIOF_DIR_IN; | ||
93 | } | ||
94 | |||
95 | static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio) | ||
96 | { | ||
97 | struct mmio_74xx_gpio_priv *priv = to_74xx_gpio(gc); | ||
98 | |||
99 | return (priv->flags & MMIO_74XX_DIR_OUT) ? -ENOTSUPP : 0; | ||
100 | } | ||
101 | |||
102 | static int mmio_74xx_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | ||
103 | { | ||
104 | struct mmio_74xx_gpio_priv *priv = to_74xx_gpio(gc); | ||
105 | |||
106 | if (priv->flags & MMIO_74XX_DIR_OUT) { | ||
107 | gc->set(gc, gpio, val); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | return -ENOTSUPP; | ||
112 | } | ||
113 | |||
114 | static int mmio_74xx_gpio_probe(struct platform_device *pdev) | ||
115 | { | ||
116 | const struct of_device_id *of_id = | ||
117 | of_match_device(mmio_74xx_gpio_ids, &pdev->dev); | ||
118 | struct mmio_74xx_gpio_priv *priv; | ||
119 | struct resource *res; | ||
120 | void __iomem *dat; | ||
121 | int err; | ||
122 | |||
123 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); | ||
124 | if (!priv) | ||
125 | return -ENOMEM; | ||
126 | |||
127 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
128 | dat = devm_ioremap_resource(&pdev->dev, res); | ||
129 | if (IS_ERR(dat)) | ||
130 | return PTR_ERR(dat); | ||
131 | |||
132 | priv->flags = (unsigned)of_id->data; | ||
133 | |||
134 | err = bgpio_init(&priv->bgc, &pdev->dev, | ||
135 | DIV_ROUND_UP(MMIO_74XX_BIT_CNT(priv->flags), 8), | ||
136 | dat, NULL, NULL, NULL, NULL, 0); | ||
137 | if (err) | ||
138 | return err; | ||
139 | |||
140 | priv->bgc.gc.direction_input = mmio_74xx_dir_in; | ||
141 | priv->bgc.gc.direction_output = mmio_74xx_dir_out; | ||
142 | priv->bgc.gc.get_direction = mmio_74xx_get_direction; | ||
143 | priv->bgc.gc.ngpio = MMIO_74XX_BIT_CNT(priv->flags); | ||
144 | priv->bgc.gc.owner = THIS_MODULE; | ||
145 | |||
146 | platform_set_drvdata(pdev, priv); | ||
147 | |||
148 | return gpiochip_add(&priv->bgc.gc); | ||
149 | } | ||
150 | |||
151 | static int mmio_74xx_gpio_remove(struct platform_device *pdev) | ||
152 | { | ||
153 | struct mmio_74xx_gpio_priv *priv = platform_get_drvdata(pdev); | ||
154 | |||
155 | return bgpio_remove(&priv->bgc); | ||
156 | } | ||
157 | |||
158 | static struct platform_driver mmio_74xx_gpio_driver = { | ||
159 | .driver = { | ||
160 | .name = "74xx-mmio-gpio", | ||
161 | .of_match_table = mmio_74xx_gpio_ids, | ||
162 | }, | ||
163 | .probe = mmio_74xx_gpio_probe, | ||
164 | .remove = mmio_74xx_gpio_remove, | ||
165 | }; | ||
166 | module_platform_driver(mmio_74xx_gpio_driver); | ||
167 | |||
168 | MODULE_LICENSE("GPL"); | ||
169 | MODULE_AUTHOR("Alexander Shiyan <shc_work@mail.ru>"); | ||
170 | MODULE_DESCRIPTION("74xx MMIO GPIO driver"); | ||
diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c index 3c09f1a6872a..d3d2d1099f64 100644 --- a/drivers/gpio/gpio-amd8111.c +++ b/drivers/gpio/gpio-amd8111.c | |||
@@ -223,6 +223,7 @@ found: | |||
223 | if (err) { | 223 | if (err) { |
224 | printk(KERN_ERR "GPIO registering failed (%d)\n", | 224 | printk(KERN_ERR "GPIO registering failed (%d)\n", |
225 | err); | 225 | err); |
226 | ioport_unmap(gp.pm); | ||
226 | release_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE); | 227 | release_region(gp.pmbase + PMBASE_OFFSET, PMBASE_SIZE); |
227 | goto out; | 228 | goto out; |
228 | } | 229 | } |
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index de0801e9767a..56fb5ce47aa1 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c | |||
@@ -470,7 +470,7 @@ static int bcm_kona_gpio_irq_reqres(struct irq_data *d) | |||
470 | { | 470 | { |
471 | struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); | 471 | struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); |
472 | 472 | ||
473 | if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq)) { | 473 | if (gpiochip_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq)) { |
474 | dev_err(kona_gpio->gpio_chip.dev, | 474 | dev_err(kona_gpio->gpio_chip.dev, |
475 | "unable to lock HW IRQ %lu for IRQ\n", | 475 | "unable to lock HW IRQ %lu for IRQ\n", |
476 | d->hwirq); | 476 | d->hwirq); |
@@ -483,7 +483,7 @@ static void bcm_kona_gpio_irq_relres(struct irq_data *d) | |||
483 | { | 483 | { |
484 | struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); | 484 | struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d); |
485 | 485 | ||
486 | gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq); | 486 | gpiochip_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq); |
487 | } | 487 | } |
488 | 488 | ||
489 | static struct irq_chip bcm_gpio_irq_chip = { | 489 | static struct irq_chip bcm_gpio_irq_chip = { |
diff --git a/drivers/gpio/gpio-cs5535.c b/drivers/gpio/gpio-cs5535.c index 668127fe90ef..71484eeb4ac2 100644 --- a/drivers/gpio/gpio-cs5535.c +++ b/drivers/gpio/gpio-cs5535.c | |||
@@ -322,7 +322,8 @@ static int cs5535_gpio_probe(struct platform_device *pdev) | |||
322 | goto done; | 322 | goto done; |
323 | } | 323 | } |
324 | 324 | ||
325 | if (!request_region(res->start, resource_size(res), pdev->name)) { | 325 | if (!devm_request_region(&pdev->dev, res->start, resource_size(res), |
326 | pdev->name)) { | ||
326 | dev_err(&pdev->dev, "can't request region\n"); | 327 | dev_err(&pdev->dev, "can't request region\n"); |
327 | goto done; | 328 | goto done; |
328 | } | 329 | } |
@@ -348,24 +349,18 @@ static int cs5535_gpio_probe(struct platform_device *pdev) | |||
348 | /* finally, register with the generic GPIO API */ | 349 | /* finally, register with the generic GPIO API */ |
349 | err = gpiochip_add(&cs5535_gpio_chip.chip); | 350 | err = gpiochip_add(&cs5535_gpio_chip.chip); |
350 | if (err) | 351 | if (err) |
351 | goto release_region; | 352 | goto done; |
352 | 353 | ||
353 | return 0; | 354 | return 0; |
354 | 355 | ||
355 | release_region: | ||
356 | release_region(res->start, resource_size(res)); | ||
357 | done: | 356 | done: |
358 | return err; | 357 | return err; |
359 | } | 358 | } |
360 | 359 | ||
361 | static int cs5535_gpio_remove(struct platform_device *pdev) | 360 | static int cs5535_gpio_remove(struct platform_device *pdev) |
362 | { | 361 | { |
363 | struct resource *r; | ||
364 | |||
365 | gpiochip_remove(&cs5535_gpio_chip.chip); | 362 | gpiochip_remove(&cs5535_gpio_chip.chip); |
366 | 363 | ||
367 | r = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
368 | release_region(r->start, resource_size(r)); | ||
369 | return 0; | 364 | return 0; |
370 | } | 365 | } |
371 | 366 | ||
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 9f0682534e2f..3faf5f944ccc 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c | |||
@@ -234,11 +234,6 @@ static int davinci_gpio_probe(struct platform_device *pdev) | |||
234 | return -ENOMEM; | 234 | return -ENOMEM; |
235 | 235 | ||
236 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 236 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
237 | if (!res) { | ||
238 | dev_err(dev, "Invalid memory resource\n"); | ||
239 | return -EBUSY; | ||
240 | } | ||
241 | |||
242 | gpio_base = devm_ioremap_resource(dev, res); | 237 | gpio_base = devm_ioremap_resource(dev, res); |
243 | if (IS_ERR(gpio_base)) | 238 | if (IS_ERR(gpio_base)) |
244 | return PTR_ERR(gpio_base); | 239 | return PTR_ERR(gpio_base); |
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index b43cd84b61f1..4beb37839392 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c | |||
@@ -194,7 +194,7 @@ static int dwapb_irq_reqres(struct irq_data *d) | |||
194 | struct dwapb_gpio *gpio = igc->private; | 194 | struct dwapb_gpio *gpio = igc->private; |
195 | struct bgpio_chip *bgc = &gpio->ports[0].bgc; | 195 | struct bgpio_chip *bgc = &gpio->ports[0].bgc; |
196 | 196 | ||
197 | if (gpio_lock_as_irq(&bgc->gc, irqd_to_hwirq(d))) { | 197 | if (gpiochip_lock_as_irq(&bgc->gc, irqd_to_hwirq(d))) { |
198 | dev_err(gpio->dev, "unable to lock HW IRQ %lu for IRQ\n", | 198 | dev_err(gpio->dev, "unable to lock HW IRQ %lu for IRQ\n", |
199 | irqd_to_hwirq(d)); | 199 | irqd_to_hwirq(d)); |
200 | return -EINVAL; | 200 | return -EINVAL; |
@@ -208,7 +208,7 @@ static void dwapb_irq_relres(struct irq_data *d) | |||
208 | struct dwapb_gpio *gpio = igc->private; | 208 | struct dwapb_gpio *gpio = igc->private; |
209 | struct bgpio_chip *bgc = &gpio->ports[0].bgc; | 209 | struct bgpio_chip *bgc = &gpio->ports[0].bgc; |
210 | 210 | ||
211 | gpio_unlock_as_irq(&bgc->gc, irqd_to_hwirq(d)); | 211 | gpiochip_unlock_as_irq(&bgc->gc, irqd_to_hwirq(d)); |
212 | } | 212 | } |
213 | 213 | ||
214 | static int dwapb_irq_set_type(struct irq_data *d, u32 type) | 214 | static int dwapb_irq_set_type(struct irq_data *d, u32 type) |
diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index fe49ec3cdb7d..c3434146f605 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c | |||
@@ -103,7 +103,7 @@ static int em_gio_irq_reqres(struct irq_data *d) | |||
103 | { | 103 | { |
104 | struct em_gio_priv *p = irq_data_get_irq_chip_data(d); | 104 | struct em_gio_priv *p = irq_data_get_irq_chip_data(d); |
105 | 105 | ||
106 | if (gpio_lock_as_irq(&p->gpio_chip, irqd_to_hwirq(d))) { | 106 | if (gpiochip_lock_as_irq(&p->gpio_chip, irqd_to_hwirq(d))) { |
107 | dev_err(p->gpio_chip.dev, | 107 | dev_err(p->gpio_chip.dev, |
108 | "unable to lock HW IRQ %lu for IRQ\n", | 108 | "unable to lock HW IRQ %lu for IRQ\n", |
109 | irqd_to_hwirq(d)); | 109 | irqd_to_hwirq(d)); |
@@ -116,7 +116,7 @@ static void em_gio_irq_relres(struct irq_data *d) | |||
116 | { | 116 | { |
117 | struct em_gio_priv *p = irq_data_get_irq_chip_data(d); | 117 | struct em_gio_priv *p = irq_data_get_irq_chip_data(d); |
118 | 118 | ||
119 | gpio_unlock_as_irq(&p->gpio_chip, irqd_to_hwirq(d)); | 119 | gpiochip_unlock_as_irq(&p->gpio_chip, irqd_to_hwirq(d)); |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
@@ -330,12 +330,7 @@ static int em_gio_probe(struct platform_device *pdev) | |||
330 | goto err0; | 330 | goto err0; |
331 | } | 331 | } |
332 | 332 | ||
333 | ret = of_alias_get_id(pdev->dev.of_node, "gpio"); | 333 | pdata->gpio_base = -1; |
334 | if (ret < 0) { | ||
335 | dev_err(&pdev->dev, "Couldn't get OF id\n"); | ||
336 | goto err0; | ||
337 | } | ||
338 | pdata->gpio_base = ret * 32; /* 32 GPIOs per instance */ | ||
339 | } | 334 | } |
340 | 335 | ||
341 | gpio_chip = &p->gpio_chip; | 336 | gpio_chip = &p->gpio_chip; |
diff --git a/drivers/gpio/gpio-grgpio.c b/drivers/gpio/gpio-grgpio.c index 66ad3df9d9cf..38acdcea9799 100644 --- a/drivers/gpio/gpio-grgpio.c +++ b/drivers/gpio/gpio-grgpio.c | |||
@@ -441,6 +441,7 @@ static int grgpio_probe(struct platform_device *ofdev) | |||
441 | err = gpiochip_add(gc); | 441 | err = gpiochip_add(gc); |
442 | if (err) { | 442 | if (err) { |
443 | dev_err(&ofdev->dev, "Could not add gpiochip\n"); | 443 | dev_err(&ofdev->dev, "Could not add gpiochip\n"); |
444 | irq_domain_remove(priv->domain); | ||
444 | return err; | 445 | return err; |
445 | } | 446 | } |
446 | 447 | ||
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c index 8488e2fd307c..da9c316059bc 100644 --- a/drivers/gpio/gpio-mcp23s08.c +++ b/drivers/gpio/gpio-mcp23s08.c | |||
@@ -65,6 +65,7 @@ struct mcp23s08_ops { | |||
65 | 65 | ||
66 | struct mcp23s08 { | 66 | struct mcp23s08 { |
67 | u8 addr; | 67 | u8 addr; |
68 | bool irq_active_high; | ||
68 | 69 | ||
69 | u16 cache[11]; | 70 | u16 cache[11]; |
70 | u16 irq_rise; | 71 | u16 irq_rise; |
@@ -444,7 +445,7 @@ static int mcp23s08_irq_reqres(struct irq_data *data) | |||
444 | { | 445 | { |
445 | struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); | 446 | struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); |
446 | 447 | ||
447 | if (gpio_lock_as_irq(&mcp->chip, data->hwirq)) { | 448 | if (gpiochip_lock_as_irq(&mcp->chip, data->hwirq)) { |
448 | dev_err(mcp->chip.dev, | 449 | dev_err(mcp->chip.dev, |
449 | "unable to lock HW IRQ %lu for IRQ usage\n", | 450 | "unable to lock HW IRQ %lu for IRQ usage\n", |
450 | data->hwirq); | 451 | data->hwirq); |
@@ -458,7 +459,7 @@ static void mcp23s08_irq_relres(struct irq_data *data) | |||
458 | { | 459 | { |
459 | struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); | 460 | struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); |
460 | 461 | ||
461 | gpio_unlock_as_irq(&mcp->chip, data->hwirq); | 462 | gpiochip_unlock_as_irq(&mcp->chip, data->hwirq); |
462 | } | 463 | } |
463 | 464 | ||
464 | static struct irq_chip mcp23s08_irq_chip = { | 465 | static struct irq_chip mcp23s08_irq_chip = { |
@@ -476,6 +477,7 @@ static int mcp23s08_irq_setup(struct mcp23s08 *mcp) | |||
476 | { | 477 | { |
477 | struct gpio_chip *chip = &mcp->chip; | 478 | struct gpio_chip *chip = &mcp->chip; |
478 | int err, irq, j; | 479 | int err, irq, j; |
480 | unsigned long irqflags = IRQF_ONESHOT | IRQF_SHARED; | ||
479 | 481 | ||
480 | mutex_init(&mcp->irq_lock); | 482 | mutex_init(&mcp->irq_lock); |
481 | 483 | ||
@@ -484,9 +486,13 @@ static int mcp23s08_irq_setup(struct mcp23s08 *mcp) | |||
484 | if (!mcp->irq_domain) | 486 | if (!mcp->irq_domain) |
485 | return -ENODEV; | 487 | return -ENODEV; |
486 | 488 | ||
489 | if (mcp->irq_active_high) | ||
490 | irqflags |= IRQF_TRIGGER_HIGH; | ||
491 | else | ||
492 | irqflags |= IRQF_TRIGGER_LOW; | ||
493 | |||
487 | err = devm_request_threaded_irq(chip->dev, mcp->irq, NULL, mcp23s08_irq, | 494 | err = devm_request_threaded_irq(chip->dev, mcp->irq, NULL, mcp23s08_irq, |
488 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | 495 | irqflags, dev_name(chip->dev), mcp); |
489 | dev_name(chip->dev), mcp); | ||
490 | if (err != 0) { | 496 | if (err != 0) { |
491 | dev_err(chip->dev, "unable to request IRQ#%d: %d\n", | 497 | dev_err(chip->dev, "unable to request IRQ#%d: %d\n", |
492 | mcp->irq, err); | 498 | mcp->irq, err); |
@@ -514,8 +520,6 @@ static void mcp23s08_irq_teardown(struct mcp23s08 *mcp) | |||
514 | { | 520 | { |
515 | unsigned int irq, i; | 521 | unsigned int irq, i; |
516 | 522 | ||
517 | free_irq(mcp->irq, mcp); | ||
518 | |||
519 | for (i = 0; i < mcp->chip.ngpio; i++) { | 523 | for (i = 0; i < mcp->chip.ngpio; i++) { |
520 | irq = irq_find_mapping(mcp->irq_domain, i); | 524 | irq = irq_find_mapping(mcp->irq_domain, i); |
521 | if (irq > 0) | 525 | if (irq > 0) |
@@ -590,6 +594,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, | |||
590 | 594 | ||
591 | mcp->data = data; | 595 | mcp->data = data; |
592 | mcp->addr = addr; | 596 | mcp->addr = addr; |
597 | mcp->irq_active_high = false; | ||
593 | 598 | ||
594 | mcp->chip.direction_input = mcp23s08_direction_input; | 599 | mcp->chip.direction_input = mcp23s08_direction_input; |
595 | mcp->chip.get = mcp23s08_get; | 600 | mcp->chip.get = mcp23s08_get; |
@@ -649,14 +654,25 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, | |||
649 | goto fail; | 654 | goto fail; |
650 | 655 | ||
651 | mcp->irq_controller = pdata->irq_controller; | 656 | mcp->irq_controller = pdata->irq_controller; |
652 | if (mcp->irq && mcp->irq_controller && (type == MCP_TYPE_017)) | 657 | if (mcp->irq && mcp->irq_controller) { |
653 | mirror = pdata->mirror; | 658 | mcp->irq_active_high = |
659 | of_property_read_bool(mcp->chip.dev->of_node, | ||
660 | "microchip,irq-active-high"); | ||
654 | 661 | ||
655 | if ((status & IOCON_SEQOP) || !(status & IOCON_HAEN) || mirror) { | 662 | if (type == MCP_TYPE_017) |
663 | mirror = pdata->mirror; | ||
664 | } | ||
665 | |||
666 | if ((status & IOCON_SEQOP) || !(status & IOCON_HAEN) || mirror || | ||
667 | mcp->irq_active_high) { | ||
656 | /* mcp23s17 has IOCON twice, make sure they are in sync */ | 668 | /* mcp23s17 has IOCON twice, make sure they are in sync */ |
657 | status &= ~(IOCON_SEQOP | (IOCON_SEQOP << 8)); | 669 | status &= ~(IOCON_SEQOP | (IOCON_SEQOP << 8)); |
658 | status |= IOCON_HAEN | (IOCON_HAEN << 8); | 670 | status |= IOCON_HAEN | (IOCON_HAEN << 8); |
659 | status &= ~(IOCON_INTPOL | (IOCON_INTPOL << 8)); | 671 | if (mcp->irq_active_high) |
672 | status |= IOCON_INTPOL | (IOCON_INTPOL << 8); | ||
673 | else | ||
674 | status &= ~(IOCON_INTPOL | (IOCON_INTPOL << 8)); | ||
675 | |||
660 | if (mirror) | 676 | if (mirror) |
661 | status |= IOCON_MIRROR | (IOCON_MIRROR << 8); | 677 | status |= IOCON_MIRROR | (IOCON_MIRROR << 8); |
662 | 678 | ||
@@ -936,11 +952,14 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
936 | return -ENOMEM; | 952 | return -ENOMEM; |
937 | spi_set_drvdata(spi, data); | 953 | spi_set_drvdata(spi, data); |
938 | 954 | ||
955 | spi->irq = irq_of_parse_and_map(spi->dev.of_node, 0); | ||
956 | |||
939 | for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) { | 957 | for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) { |
940 | if (!(spi_present_mask & (1 << addr))) | 958 | if (!(spi_present_mask & (1 << addr))) |
941 | continue; | 959 | continue; |
942 | chips--; | 960 | chips--; |
943 | data->mcp[addr] = &data->chip[chips]; | 961 | data->mcp[addr] = &data->chip[chips]; |
962 | data->mcp[addr]->irq = spi->irq; | ||
944 | status = mcp23s08_probe_one(data->mcp[addr], &spi->dev, spi, | 963 | status = mcp23s08_probe_one(data->mcp[addr], &spi->dev, spi, |
945 | 0x40 | (addr << 1), type, pdata, | 964 | 0x40 | (addr << 1), type, pdata, |
946 | addr); | 965 | addr); |
@@ -981,6 +1000,8 @@ static int mcp23s08_remove(struct spi_device *spi) | |||
981 | if (!data->mcp[addr]) | 1000 | if (!data->mcp[addr]) |
982 | continue; | 1001 | continue; |
983 | 1002 | ||
1003 | if (spi->irq && data->mcp[addr]->irq_controller) | ||
1004 | mcp23s08_irq_teardown(data->mcp[addr]); | ||
984 | gpiochip_remove(&data->mcp[addr]->chip); | 1005 | gpiochip_remove(&data->mcp[addr]->chip); |
985 | } | 1006 | } |
986 | kfree(data); | 1007 | kfree(data); |
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c index d7d6d72eba33..d1ff879e6ff2 100644 --- a/drivers/gpio/gpio-mpc8xxx.c +++ b/drivers/gpio/gpio-mpc8xxx.c | |||
@@ -105,6 +105,32 @@ static void mpc8xxx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | |||
105 | spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); | 105 | spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); |
106 | } | 106 | } |
107 | 107 | ||
108 | static void mpc8xxx_gpio_set_multiple(struct gpio_chip *gc, | ||
109 | unsigned long *mask, unsigned long *bits) | ||
110 | { | ||
111 | struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); | ||
112 | struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm); | ||
113 | unsigned long flags; | ||
114 | int i; | ||
115 | |||
116 | spin_lock_irqsave(&mpc8xxx_gc->lock, flags); | ||
117 | |||
118 | for (i = 0; i < gc->ngpio; i++) { | ||
119 | if (*mask == 0) | ||
120 | break; | ||
121 | if (__test_and_clear_bit(i, mask)) { | ||
122 | if (test_bit(i, bits)) | ||
123 | mpc8xxx_gc->data |= mpc8xxx_gpio2mask(i); | ||
124 | else | ||
125 | mpc8xxx_gc->data &= ~mpc8xxx_gpio2mask(i); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | out_be32(mm->regs + GPIO_DAT, mpc8xxx_gc->data); | ||
130 | |||
131 | spin_unlock_irqrestore(&mpc8xxx_gc->lock, flags); | ||
132 | } | ||
133 | |||
108 | static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) | 134 | static int mpc8xxx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) |
109 | { | 135 | { |
110 | struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); | 136 | struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); |
@@ -344,6 +370,7 @@ static void __init mpc8xxx_add_controller(struct device_node *np) | |||
344 | gc->get = of_device_is_compatible(np, "fsl,mpc8572-gpio") ? | 370 | gc->get = of_device_is_compatible(np, "fsl,mpc8572-gpio") ? |
345 | mpc8572_gpio_get : mpc8xxx_gpio_get; | 371 | mpc8572_gpio_get : mpc8xxx_gpio_get; |
346 | gc->set = mpc8xxx_gpio_set; | 372 | gc->set = mpc8xxx_gpio_set; |
373 | gc->set_multiple = mpc8xxx_gpio_set_multiple; | ||
347 | gc->to_irq = mpc8xxx_gpio_to_irq; | 374 | gc->to_irq = mpc8xxx_gpio_to_irq; |
348 | 375 | ||
349 | ret = of_mm_gpiochip_add(np, mm_gc); | 376 | ret = of_mm_gpiochip_add(np, mm_gc); |
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index 418e38650363..dd5545c293d4 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c | |||
@@ -83,6 +83,14 @@ struct mvebu_gpio_chip { | |||
83 | int irqbase; | 83 | int irqbase; |
84 | struct irq_domain *domain; | 84 | struct irq_domain *domain; |
85 | int soc_variant; | 85 | int soc_variant; |
86 | |||
87 | /* Used to preserve GPIO registers accross suspend/resume */ | ||
88 | u32 out_reg; | ||
89 | u32 io_conf_reg; | ||
90 | u32 blink_en_reg; | ||
91 | u32 in_pol_reg; | ||
92 | u32 edge_mask_regs[4]; | ||
93 | u32 level_mask_regs[4]; | ||
86 | }; | 94 | }; |
87 | 95 | ||
88 | /* | 96 | /* |
@@ -554,6 +562,93 @@ static const struct of_device_id mvebu_gpio_of_match[] = { | |||
554 | }; | 562 | }; |
555 | MODULE_DEVICE_TABLE(of, mvebu_gpio_of_match); | 563 | MODULE_DEVICE_TABLE(of, mvebu_gpio_of_match); |
556 | 564 | ||
565 | static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state) | ||
566 | { | ||
567 | struct mvebu_gpio_chip *mvchip = platform_get_drvdata(pdev); | ||
568 | int i; | ||
569 | |||
570 | mvchip->out_reg = readl(mvebu_gpioreg_out(mvchip)); | ||
571 | mvchip->io_conf_reg = readl(mvebu_gpioreg_io_conf(mvchip)); | ||
572 | mvchip->blink_en_reg = readl(mvebu_gpioreg_blink(mvchip)); | ||
573 | mvchip->in_pol_reg = readl(mvebu_gpioreg_in_pol(mvchip)); | ||
574 | |||
575 | switch (mvchip->soc_variant) { | ||
576 | case MVEBU_GPIO_SOC_VARIANT_ORION: | ||
577 | mvchip->edge_mask_regs[0] = | ||
578 | readl(mvchip->membase + GPIO_EDGE_MASK_OFF); | ||
579 | mvchip->level_mask_regs[0] = | ||
580 | readl(mvchip->membase + GPIO_LEVEL_MASK_OFF); | ||
581 | break; | ||
582 | case MVEBU_GPIO_SOC_VARIANT_MV78200: | ||
583 | for (i = 0; i < 2; i++) { | ||
584 | mvchip->edge_mask_regs[i] = | ||
585 | readl(mvchip->membase + | ||
586 | GPIO_EDGE_MASK_MV78200_OFF(i)); | ||
587 | mvchip->level_mask_regs[i] = | ||
588 | readl(mvchip->membase + | ||
589 | GPIO_LEVEL_MASK_MV78200_OFF(i)); | ||
590 | } | ||
591 | break; | ||
592 | case MVEBU_GPIO_SOC_VARIANT_ARMADAXP: | ||
593 | for (i = 0; i < 4; i++) { | ||
594 | mvchip->edge_mask_regs[i] = | ||
595 | readl(mvchip->membase + | ||
596 | GPIO_EDGE_MASK_ARMADAXP_OFF(i)); | ||
597 | mvchip->level_mask_regs[i] = | ||
598 | readl(mvchip->membase + | ||
599 | GPIO_LEVEL_MASK_ARMADAXP_OFF(i)); | ||
600 | } | ||
601 | break; | ||
602 | default: | ||
603 | BUG(); | ||
604 | } | ||
605 | |||
606 | return 0; | ||
607 | } | ||
608 | |||
609 | static int mvebu_gpio_resume(struct platform_device *pdev) | ||
610 | { | ||
611 | struct mvebu_gpio_chip *mvchip = platform_get_drvdata(pdev); | ||
612 | int i; | ||
613 | |||
614 | writel(mvchip->out_reg, mvebu_gpioreg_out(mvchip)); | ||
615 | writel(mvchip->io_conf_reg, mvebu_gpioreg_io_conf(mvchip)); | ||
616 | writel(mvchip->blink_en_reg, mvebu_gpioreg_blink(mvchip)); | ||
617 | writel(mvchip->in_pol_reg, mvebu_gpioreg_in_pol(mvchip)); | ||
618 | |||
619 | switch (mvchip->soc_variant) { | ||
620 | case MVEBU_GPIO_SOC_VARIANT_ORION: | ||
621 | writel(mvchip->edge_mask_regs[0], | ||
622 | mvchip->membase + GPIO_EDGE_MASK_OFF); | ||
623 | writel(mvchip->level_mask_regs[0], | ||
624 | mvchip->membase + GPIO_LEVEL_MASK_OFF); | ||
625 | break; | ||
626 | case MVEBU_GPIO_SOC_VARIANT_MV78200: | ||
627 | for (i = 0; i < 2; i++) { | ||
628 | writel(mvchip->edge_mask_regs[i], | ||
629 | mvchip->membase + GPIO_EDGE_MASK_MV78200_OFF(i)); | ||
630 | writel(mvchip->level_mask_regs[i], | ||
631 | mvchip->membase + | ||
632 | GPIO_LEVEL_MASK_MV78200_OFF(i)); | ||
633 | } | ||
634 | break; | ||
635 | case MVEBU_GPIO_SOC_VARIANT_ARMADAXP: | ||
636 | for (i = 0; i < 4; i++) { | ||
637 | writel(mvchip->edge_mask_regs[i], | ||
638 | mvchip->membase + | ||
639 | GPIO_EDGE_MASK_ARMADAXP_OFF(i)); | ||
640 | writel(mvchip->level_mask_regs[i], | ||
641 | mvchip->membase + | ||
642 | GPIO_LEVEL_MASK_ARMADAXP_OFF(i)); | ||
643 | } | ||
644 | break; | ||
645 | default: | ||
646 | BUG(); | ||
647 | } | ||
648 | |||
649 | return 0; | ||
650 | } | ||
651 | |||
557 | static int mvebu_gpio_probe(struct platform_device *pdev) | 652 | static int mvebu_gpio_probe(struct platform_device *pdev) |
558 | { | 653 | { |
559 | struct mvebu_gpio_chip *mvchip; | 654 | struct mvebu_gpio_chip *mvchip; |
@@ -577,6 +672,8 @@ static int mvebu_gpio_probe(struct platform_device *pdev) | |||
577 | if (!mvchip) | 672 | if (!mvchip) |
578 | return -ENOMEM; | 673 | return -ENOMEM; |
579 | 674 | ||
675 | platform_set_drvdata(pdev, mvchip); | ||
676 | |||
580 | if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) { | 677 | if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) { |
581 | dev_err(&pdev->dev, "Missing ngpios OF property\n"); | 678 | dev_err(&pdev->dev, "Missing ngpios OF property\n"); |
582 | return -ENODEV; | 679 | return -ENODEV; |
@@ -735,5 +832,7 @@ static struct platform_driver mvebu_gpio_driver = { | |||
735 | .of_match_table = mvebu_gpio_of_match, | 832 | .of_match_table = mvebu_gpio_of_match, |
736 | }, | 833 | }, |
737 | .probe = mvebu_gpio_probe, | 834 | .probe = mvebu_gpio_probe, |
835 | .suspend = mvebu_gpio_suspend, | ||
836 | .resume = mvebu_gpio_resume, | ||
738 | }; | 837 | }; |
739 | module_platform_driver(mvebu_gpio_driver); | 838 | module_platform_driver(mvebu_gpio_driver); |
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c index 8ffdd7d2bade..56052c285714 100644 --- a/drivers/gpio/gpio-mxs.c +++ b/drivers/gpio/gpio-mxs.c | |||
@@ -227,6 +227,18 @@ static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset) | |||
227 | return irq_find_mapping(port->domain, offset); | 227 | return irq_find_mapping(port->domain, offset); |
228 | } | 228 | } |
229 | 229 | ||
230 | static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset) | ||
231 | { | ||
232 | struct bgpio_chip *bgc = to_bgpio_chip(gc); | ||
233 | struct mxs_gpio_port *port = | ||
234 | container_of(bgc, struct mxs_gpio_port, bgc); | ||
235 | u32 mask = 1 << offset; | ||
236 | u32 dir; | ||
237 | |||
238 | dir = readl(port->base + PINCTRL_DOE(port)); | ||
239 | return !(dir & mask); | ||
240 | } | ||
241 | |||
230 | static struct platform_device_id mxs_gpio_ids[] = { | 242 | static struct platform_device_id mxs_gpio_ids[] = { |
231 | { | 243 | { |
232 | .name = "imx23-gpio", | 244 | .name = "imx23-gpio", |
@@ -320,6 +332,7 @@ static int mxs_gpio_probe(struct platform_device *pdev) | |||
320 | goto out_irqdesc_free; | 332 | goto out_irqdesc_free; |
321 | 333 | ||
322 | port->bgc.gc.to_irq = mxs_gpio_to_irq; | 334 | port->bgc.gc.to_irq = mxs_gpio_to_irq; |
335 | port->bgc.gc.get_direction = mxs_gpio_get_direction; | ||
323 | port->bgc.gc.base = port->id * 32; | 336 | port->bgc.gc.base = port->id * 32; |
324 | 337 | ||
325 | err = gpiochip_add(&port->bgc.gc); | 338 | err = gpiochip_add(&port->bgc.gc); |
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 3d6b445665ad..30646cfe0efa 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -800,7 +800,7 @@ static void omap_gpio_irq_shutdown(struct irq_data *d) | |||
800 | unsigned offset = GPIO_INDEX(bank, gpio); | 800 | unsigned offset = GPIO_INDEX(bank, gpio); |
801 | 801 | ||
802 | spin_lock_irqsave(&bank->lock, flags); | 802 | spin_lock_irqsave(&bank->lock, flags); |
803 | gpio_unlock_as_irq(&bank->chip, offset); | 803 | gpiochip_unlock_as_irq(&bank->chip, offset); |
804 | bank->irq_usage &= ~(BIT(offset)); | 804 | bank->irq_usage &= ~(BIT(offset)); |
805 | omap_disable_gpio_module(bank, offset); | 805 | omap_disable_gpio_module(bank, offset); |
806 | omap_reset_gpio(bank, gpio); | 806 | omap_reset_gpio(bank, gpio); |
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 84b49cfb81a8..04756130437f 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
@@ -52,28 +52,34 @@ struct pl061_gpio { | |||
52 | 52 | ||
53 | void __iomem *base; | 53 | void __iomem *base; |
54 | struct gpio_chip gc; | 54 | struct gpio_chip gc; |
55 | bool uses_pinctrl; | ||
55 | 56 | ||
56 | #ifdef CONFIG_PM | 57 | #ifdef CONFIG_PM |
57 | struct pl061_context_save_regs csave_regs; | 58 | struct pl061_context_save_regs csave_regs; |
58 | #endif | 59 | #endif |
59 | }; | 60 | }; |
60 | 61 | ||
61 | static int pl061_gpio_request(struct gpio_chip *chip, unsigned offset) | 62 | static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset) |
62 | { | 63 | { |
63 | /* | 64 | /* |
64 | * Map back to global GPIO space and request muxing, the direction | 65 | * Map back to global GPIO space and request muxing, the direction |
65 | * parameter does not matter for this controller. | 66 | * parameter does not matter for this controller. |
66 | */ | 67 | */ |
67 | int gpio = chip->base + offset; | 68 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); |
69 | int gpio = gc->base + offset; | ||
68 | 70 | ||
69 | return pinctrl_request_gpio(gpio); | 71 | if (chip->uses_pinctrl) |
72 | return pinctrl_request_gpio(gpio); | ||
73 | return 0; | ||
70 | } | 74 | } |
71 | 75 | ||
72 | static void pl061_gpio_free(struct gpio_chip *chip, unsigned offset) | 76 | static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset) |
73 | { | 77 | { |
74 | int gpio = chip->base + offset; | 78 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); |
79 | int gpio = gc->base + offset; | ||
75 | 80 | ||
76 | pinctrl_free_gpio(gpio); | 81 | if (chip->uses_pinctrl) |
82 | pinctrl_free_gpio(gpio); | ||
77 | } | 83 | } |
78 | 84 | ||
79 | static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) | 85 | static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) |
@@ -263,6 +269,8 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | |||
263 | return PTR_ERR(chip->base); | 269 | return PTR_ERR(chip->base); |
264 | 270 | ||
265 | spin_lock_init(&chip->lock); | 271 | spin_lock_init(&chip->lock); |
272 | if (of_property_read_bool(dev->of_node, "gpio-ranges")) | ||
273 | chip->uses_pinctrl = true; | ||
266 | 274 | ||
267 | chip->gc.request = pl061_gpio_request; | 275 | chip->gc.request = pl061_gpio_request; |
268 | chip->gc.free = pl061_gpio_free; | 276 | chip->gc.free = pl061_gpio_free; |
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index bf6c09450fee..584484e3f1e3 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c | |||
@@ -1,6 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Renesas R-Car GPIO Support | 2 | * Renesas R-Car GPIO Support |
3 | * | 3 | * |
4 | * Copyright (C) 2014 Renesas Electronics Corporation | ||
4 | * Copyright (C) 2013 Magnus Damm | 5 | * Copyright (C) 2013 Magnus Damm |
5 | * | 6 | * |
6 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -291,22 +292,30 @@ struct gpio_rcar_info { | |||
291 | bool has_both_edge_trigger; | 292 | bool has_both_edge_trigger; |
292 | }; | 293 | }; |
293 | 294 | ||
295 | static const struct gpio_rcar_info gpio_rcar_info_gen1 = { | ||
296 | .has_both_edge_trigger = false, | ||
297 | }; | ||
298 | |||
299 | static const struct gpio_rcar_info gpio_rcar_info_gen2 = { | ||
300 | .has_both_edge_trigger = true, | ||
301 | }; | ||
302 | |||
294 | static const struct of_device_id gpio_rcar_of_table[] = { | 303 | static const struct of_device_id gpio_rcar_of_table[] = { |
295 | { | 304 | { |
296 | .compatible = "renesas,gpio-r8a7790", | 305 | .compatible = "renesas,gpio-r8a7790", |
297 | .data = (void *)&(const struct gpio_rcar_info) { | 306 | .data = &gpio_rcar_info_gen2, |
298 | .has_both_edge_trigger = true, | ||
299 | }, | ||
300 | }, { | 307 | }, { |
301 | .compatible = "renesas,gpio-r8a7791", | 308 | .compatible = "renesas,gpio-r8a7791", |
302 | .data = (void *)&(const struct gpio_rcar_info) { | 309 | .data = &gpio_rcar_info_gen2, |
303 | .has_both_edge_trigger = true, | 310 | }, { |
304 | }, | 311 | .compatible = "renesas,gpio-r8a7793", |
312 | .data = &gpio_rcar_info_gen2, | ||
313 | }, { | ||
314 | .compatible = "renesas,gpio-r8a7794", | ||
315 | .data = &gpio_rcar_info_gen2, | ||
305 | }, { | 316 | }, { |
306 | .compatible = "renesas,gpio-rcar", | 317 | .compatible = "renesas,gpio-rcar", |
307 | .data = (void *)&(const struct gpio_rcar_info) { | 318 | .data = &gpio_rcar_info_gen1, |
308 | .has_both_edge_trigger = false, | ||
309 | }, | ||
310 | }, { | 319 | }, { |
311 | /* Terminator */ | 320 | /* Terminator */ |
312 | }, | 321 | }, |
diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c index 7e359b7cce1b..7892e0fa8ba7 100644 --- a/drivers/gpio/gpio-stp-xway.c +++ b/drivers/gpio/gpio-stp-xway.c | |||
@@ -199,21 +199,17 @@ static int xway_stp_hw_init(struct xway_stp *chip) | |||
199 | 199 | ||
200 | static int xway_stp_probe(struct platform_device *pdev) | 200 | static int xway_stp_probe(struct platform_device *pdev) |
201 | { | 201 | { |
202 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 202 | struct resource *res; |
203 | const __be32 *shadow, *groups, *dsl, *phy; | 203 | const __be32 *shadow, *groups, *dsl, *phy; |
204 | struct xway_stp *chip; | 204 | struct xway_stp *chip; |
205 | struct clk *clk; | 205 | struct clk *clk; |
206 | int ret = 0; | 206 | int ret = 0; |
207 | 207 | ||
208 | if (!res) { | ||
209 | dev_err(&pdev->dev, "failed to request STP resource\n"); | ||
210 | return -ENOENT; | ||
211 | } | ||
212 | |||
213 | chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); | 208 | chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); |
214 | if (!chip) | 209 | if (!chip) |
215 | return -ENOMEM; | 210 | return -ENOMEM; |
216 | 211 | ||
212 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
217 | chip->virt = devm_ioremap_resource(&pdev->dev, res); | 213 | chip->virt = devm_ioremap_resource(&pdev->dev, res); |
218 | if (IS_ERR(chip->virt)) | 214 | if (IS_ERR(chip->virt)) |
219 | return PTR_ERR(chip->virt); | 215 | return PTR_ERR(chip->virt); |
diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c index 9e615be8032c..8b1e8c0dd2fb 100644 --- a/drivers/gpio/gpio-tb10x.c +++ b/drivers/gpio/gpio-tb10x.c | |||
@@ -195,18 +195,13 @@ static int tb10x_gpio_probe(struct platform_device *pdev) | |||
195 | if (of_property_read_u32(dn, "abilis,ngpio", &ngpio)) | 195 | if (of_property_read_u32(dn, "abilis,ngpio", &ngpio)) |
196 | return -EINVAL; | 196 | return -EINVAL; |
197 | 197 | ||
198 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
199 | if (!mem) { | ||
200 | dev_err(&pdev->dev, "No memory resource defined.\n"); | ||
201 | return -EINVAL; | ||
202 | } | ||
203 | |||
204 | tb10x_gpio = devm_kzalloc(&pdev->dev, sizeof(*tb10x_gpio), GFP_KERNEL); | 198 | tb10x_gpio = devm_kzalloc(&pdev->dev, sizeof(*tb10x_gpio), GFP_KERNEL); |
205 | if (tb10x_gpio == NULL) | 199 | if (tb10x_gpio == NULL) |
206 | return -ENOMEM; | 200 | return -ENOMEM; |
207 | 201 | ||
208 | spin_lock_init(&tb10x_gpio->spinlock); | 202 | spin_lock_init(&tb10x_gpio->spinlock); |
209 | 203 | ||
204 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
210 | tb10x_gpio->base = devm_ioremap_resource(&pdev->dev, mem); | 205 | tb10x_gpio->base = devm_ioremap_resource(&pdev->dev, mem); |
211 | if (IS_ERR(tb10x_gpio->base)) | 206 | if (IS_ERR(tb10x_gpio->base)) |
212 | return PTR_ERR(tb10x_gpio->base); | 207 | return PTR_ERR(tb10x_gpio->base); |
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 4e8fb8261a87..61bcfa93606d 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c | |||
@@ -233,7 +233,7 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type) | |||
233 | return -EINVAL; | 233 | return -EINVAL; |
234 | } | 234 | } |
235 | 235 | ||
236 | ret = gpio_lock_as_irq(&tegra_gpio_chip, gpio); | 236 | ret = gpiochip_lock_as_irq(&tegra_gpio_chip, gpio); |
237 | if (ret) { | 237 | if (ret) { |
238 | dev_err(dev, "unable to lock Tegra GPIO %d as IRQ\n", gpio); | 238 | dev_err(dev, "unable to lock Tegra GPIO %d as IRQ\n", gpio); |
239 | return ret; | 239 | return ret; |
@@ -263,7 +263,7 @@ static void tegra_gpio_irq_shutdown(struct irq_data *d) | |||
263 | { | 263 | { |
264 | int gpio = d->hwirq; | 264 | int gpio = d->hwirq; |
265 | 265 | ||
266 | gpio_unlock_as_irq(&tegra_gpio_chip, gpio); | 266 | gpiochip_unlock_as_irq(&tegra_gpio_chip, gpio); |
267 | } | 267 | } |
268 | 268 | ||
269 | static void tegra_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | 269 | static void tegra_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) |
diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c new file mode 100644 index 000000000000..4ee4cee832ec --- /dev/null +++ b/drivers/gpio/gpio-vf610.c | |||
@@ -0,0 +1,295 @@ | |||
1 | /* | ||
2 | * vf610 GPIO support through PORT and GPIO module | ||
3 | * | ||
4 | * Copyright (c) 2014 Toradex AG. | ||
5 | * | ||
6 | * Author: Stefan Agner <stefan@agner.ch>. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version 2 | ||
11 | * of the License, or (at your option) any later version. | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | ||
17 | |||
18 | #include <linux/bitops.h> | ||
19 | #include <linux/err.h> | ||
20 | #include <linux/gpio.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/ioport.h> | ||
25 | #include <linux/irq.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/of.h> | ||
29 | #include <linux/of_device.h> | ||
30 | #include <linux/of_irq.h> | ||
31 | |||
32 | #define VF610_GPIO_PER_PORT 32 | ||
33 | |||
34 | struct vf610_gpio_port { | ||
35 | struct gpio_chip gc; | ||
36 | void __iomem *base; | ||
37 | void __iomem *gpio_base; | ||
38 | u8 irqc[VF610_GPIO_PER_PORT]; | ||
39 | int irq; | ||
40 | }; | ||
41 | |||
42 | #define GPIO_PDOR 0x00 | ||
43 | #define GPIO_PSOR 0x04 | ||
44 | #define GPIO_PCOR 0x08 | ||
45 | #define GPIO_PTOR 0x0c | ||
46 | #define GPIO_PDIR 0x10 | ||
47 | |||
48 | #define PORT_PCR(n) ((n) * 0x4) | ||
49 | #define PORT_PCR_IRQC_OFFSET 16 | ||
50 | |||
51 | #define PORT_ISFR 0xa0 | ||
52 | #define PORT_DFER 0xc0 | ||
53 | #define PORT_DFCR 0xc4 | ||
54 | #define PORT_DFWR 0xc8 | ||
55 | |||
56 | #define PORT_INT_OFF 0x0 | ||
57 | #define PORT_INT_LOGIC_ZERO 0x8 | ||
58 | #define PORT_INT_RISING_EDGE 0x9 | ||
59 | #define PORT_INT_FALLING_EDGE 0xa | ||
60 | #define PORT_INT_EITHER_EDGE 0xb | ||
61 | #define PORT_INT_LOGIC_ONE 0xc | ||
62 | |||
63 | static const struct of_device_id vf610_gpio_dt_ids[] = { | ||
64 | { .compatible = "fsl,vf610-gpio" }, | ||
65 | { /* sentinel */ } | ||
66 | }; | ||
67 | |||
68 | static inline void vf610_gpio_writel(u32 val, void __iomem *reg) | ||
69 | { | ||
70 | writel_relaxed(val, reg); | ||
71 | } | ||
72 | |||
73 | static inline u32 vf610_gpio_readl(void __iomem *reg) | ||
74 | { | ||
75 | return readl_relaxed(reg); | ||
76 | } | ||
77 | |||
78 | static int vf610_gpio_request(struct gpio_chip *chip, unsigned offset) | ||
79 | { | ||
80 | return pinctrl_request_gpio(chip->base + offset); | ||
81 | } | ||
82 | |||
83 | static void vf610_gpio_free(struct gpio_chip *chip, unsigned offset) | ||
84 | { | ||
85 | pinctrl_free_gpio(chip->base + offset); | ||
86 | } | ||
87 | |||
88 | static int vf610_gpio_get(struct gpio_chip *gc, unsigned int gpio) | ||
89 | { | ||
90 | struct vf610_gpio_port *port = | ||
91 | container_of(gc, struct vf610_gpio_port, gc); | ||
92 | |||
93 | return !!(vf610_gpio_readl(port->gpio_base + GPIO_PDIR) & BIT(gpio)); | ||
94 | } | ||
95 | |||
96 | static void vf610_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | ||
97 | { | ||
98 | struct vf610_gpio_port *port = | ||
99 | container_of(gc, struct vf610_gpio_port, gc); | ||
100 | unsigned long mask = BIT(gpio); | ||
101 | |||
102 | if (val) | ||
103 | vf610_gpio_writel(mask, port->gpio_base + GPIO_PSOR); | ||
104 | else | ||
105 | vf610_gpio_writel(mask, port->gpio_base + GPIO_PCOR); | ||
106 | } | ||
107 | |||
108 | static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | ||
109 | { | ||
110 | return pinctrl_gpio_direction_input(chip->base + gpio); | ||
111 | } | ||
112 | |||
113 | static int vf610_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, | ||
114 | int value) | ||
115 | { | ||
116 | vf610_gpio_set(chip, gpio, value); | ||
117 | |||
118 | return pinctrl_gpio_direction_output(chip->base + gpio); | ||
119 | } | ||
120 | |||
121 | static void vf610_gpio_irq_handler(u32 irq, struct irq_desc *desc) | ||
122 | { | ||
123 | struct vf610_gpio_port *port = irq_get_handler_data(irq); | ||
124 | struct irq_chip *chip = irq_desc_get_chip(desc); | ||
125 | int pin; | ||
126 | unsigned long irq_isfr; | ||
127 | |||
128 | chained_irq_enter(chip, desc); | ||
129 | |||
130 | irq_isfr = vf610_gpio_readl(port->base + PORT_ISFR); | ||
131 | |||
132 | for_each_set_bit(pin, &irq_isfr, VF610_GPIO_PER_PORT) { | ||
133 | vf610_gpio_writel(BIT(pin), port->base + PORT_ISFR); | ||
134 | |||
135 | generic_handle_irq(irq_find_mapping(port->gc.irqdomain, pin)); | ||
136 | } | ||
137 | |||
138 | chained_irq_exit(chip, desc); | ||
139 | } | ||
140 | |||
141 | static void vf610_gpio_irq_ack(struct irq_data *d) | ||
142 | { | ||
143 | struct vf610_gpio_port *port = irq_data_get_irq_chip_data(d); | ||
144 | int gpio = d->hwirq; | ||
145 | |||
146 | vf610_gpio_writel(BIT(gpio), port->base + PORT_ISFR); | ||
147 | } | ||
148 | |||
149 | static int vf610_gpio_irq_set_type(struct irq_data *d, u32 type) | ||
150 | { | ||
151 | struct vf610_gpio_port *port = irq_data_get_irq_chip_data(d); | ||
152 | u8 irqc; | ||
153 | |||
154 | switch (type) { | ||
155 | case IRQ_TYPE_EDGE_RISING: | ||
156 | irqc = PORT_INT_RISING_EDGE; | ||
157 | break; | ||
158 | case IRQ_TYPE_EDGE_FALLING: | ||
159 | irqc = PORT_INT_FALLING_EDGE; | ||
160 | break; | ||
161 | case IRQ_TYPE_EDGE_BOTH: | ||
162 | irqc = PORT_INT_EITHER_EDGE; | ||
163 | break; | ||
164 | case IRQ_TYPE_LEVEL_LOW: | ||
165 | irqc = PORT_INT_LOGIC_ZERO; | ||
166 | break; | ||
167 | case IRQ_TYPE_LEVEL_HIGH: | ||
168 | irqc = PORT_INT_LOGIC_ONE; | ||
169 | break; | ||
170 | default: | ||
171 | return -EINVAL; | ||
172 | } | ||
173 | |||
174 | port->irqc[d->hwirq] = irqc; | ||
175 | |||
176 | return 0; | ||
177 | } | ||
178 | |||
179 | static void vf610_gpio_irq_mask(struct irq_data *d) | ||
180 | { | ||
181 | struct vf610_gpio_port *port = irq_data_get_irq_chip_data(d); | ||
182 | void __iomem *pcr_base = port->base + PORT_PCR(d->hwirq); | ||
183 | |||
184 | vf610_gpio_writel(0, pcr_base); | ||
185 | } | ||
186 | |||
187 | static void vf610_gpio_irq_unmask(struct irq_data *d) | ||
188 | { | ||
189 | struct vf610_gpio_port *port = irq_data_get_irq_chip_data(d); | ||
190 | void __iomem *pcr_base = port->base + PORT_PCR(d->hwirq); | ||
191 | |||
192 | vf610_gpio_writel(port->irqc[d->hwirq] << PORT_PCR_IRQC_OFFSET, | ||
193 | pcr_base); | ||
194 | } | ||
195 | |||
196 | static int vf610_gpio_irq_set_wake(struct irq_data *d, u32 enable) | ||
197 | { | ||
198 | struct vf610_gpio_port *port = irq_data_get_irq_chip_data(d); | ||
199 | |||
200 | if (enable) | ||
201 | enable_irq_wake(port->irq); | ||
202 | else | ||
203 | disable_irq_wake(port->irq); | ||
204 | |||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | static struct irq_chip vf610_gpio_irq_chip = { | ||
209 | .name = "gpio-vf610", | ||
210 | .irq_ack = vf610_gpio_irq_ack, | ||
211 | .irq_mask = vf610_gpio_irq_mask, | ||
212 | .irq_unmask = vf610_gpio_irq_unmask, | ||
213 | .irq_set_type = vf610_gpio_irq_set_type, | ||
214 | .irq_set_wake = vf610_gpio_irq_set_wake, | ||
215 | }; | ||
216 | |||
217 | static int vf610_gpio_probe(struct platform_device *pdev) | ||
218 | { | ||
219 | struct device *dev = &pdev->dev; | ||
220 | struct device_node *np = dev->of_node; | ||
221 | struct vf610_gpio_port *port; | ||
222 | struct resource *iores; | ||
223 | struct gpio_chip *gc; | ||
224 | int ret; | ||
225 | |||
226 | port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL); | ||
227 | if (!port) | ||
228 | return -ENOMEM; | ||
229 | |||
230 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
231 | port->base = devm_ioremap_resource(dev, iores); | ||
232 | if (IS_ERR(port->base)) | ||
233 | return PTR_ERR(port->base); | ||
234 | |||
235 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
236 | port->gpio_base = devm_ioremap_resource(dev, iores); | ||
237 | if (IS_ERR(port->gpio_base)) | ||
238 | return PTR_ERR(port->gpio_base); | ||
239 | |||
240 | port->irq = platform_get_irq(pdev, 0); | ||
241 | if (port->irq < 0) | ||
242 | return port->irq; | ||
243 | |||
244 | gc = &port->gc; | ||
245 | gc->of_node = np; | ||
246 | gc->dev = dev; | ||
247 | gc->label = "vf610-gpio", | ||
248 | gc->ngpio = VF610_GPIO_PER_PORT, | ||
249 | gc->base = of_alias_get_id(np, "gpio") * VF610_GPIO_PER_PORT; | ||
250 | |||
251 | gc->request = vf610_gpio_request, | ||
252 | gc->free = vf610_gpio_free, | ||
253 | gc->direction_input = vf610_gpio_direction_input, | ||
254 | gc->get = vf610_gpio_get, | ||
255 | gc->direction_output = vf610_gpio_direction_output, | ||
256 | gc->set = vf610_gpio_set, | ||
257 | |||
258 | ret = gpiochip_add(gc); | ||
259 | if (ret < 0) | ||
260 | return ret; | ||
261 | |||
262 | /* Clear the interrupt status register for all GPIO's */ | ||
263 | vf610_gpio_writel(~0, port->base + PORT_ISFR); | ||
264 | |||
265 | ret = gpiochip_irqchip_add(gc, &vf610_gpio_irq_chip, 0, | ||
266 | handle_simple_irq, IRQ_TYPE_NONE); | ||
267 | if (ret) { | ||
268 | dev_err(dev, "failed to add irqchip\n"); | ||
269 | gpiochip_remove(gc); | ||
270 | return ret; | ||
271 | } | ||
272 | gpiochip_set_chained_irqchip(gc, &vf610_gpio_irq_chip, port->irq, | ||
273 | vf610_gpio_irq_handler); | ||
274 | |||
275 | return 0; | ||
276 | } | ||
277 | |||
278 | static struct platform_driver vf610_gpio_driver = { | ||
279 | .driver = { | ||
280 | .name = "gpio-vf610", | ||
281 | .owner = THIS_MODULE, | ||
282 | .of_match_table = vf610_gpio_dt_ids, | ||
283 | }, | ||
284 | .probe = vf610_gpio_probe, | ||
285 | }; | ||
286 | |||
287 | static int __init gpio_vf610_init(void) | ||
288 | { | ||
289 | return platform_driver_register(&vf610_gpio_driver); | ||
290 | } | ||
291 | device_initcall(gpio_vf610_init); | ||
292 | |||
293 | MODULE_AUTHOR("Stefan Agner <stefan@agner.ch>"); | ||
294 | MODULE_DESCRIPTION("Freescale VF610 GPIO"); | ||
295 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c index dbf28fa03f67..cec55226143d 100644 --- a/drivers/gpio/gpio-vr41xx.c +++ b/drivers/gpio/gpio-vr41xx.c | |||
@@ -138,7 +138,7 @@ static void unmask_giuint_low(struct irq_data *d) | |||
138 | 138 | ||
139 | static unsigned int startup_giuint(struct irq_data *data) | 139 | static unsigned int startup_giuint(struct irq_data *data) |
140 | { | 140 | { |
141 | if (gpio_lock_as_irq(&vr41xx_gpio_chip, data->hwirq)) | 141 | if (gpiochip_lock_as_irq(&vr41xx_gpio_chip, data->hwirq)) |
142 | dev_err(vr41xx_gpio_chip.dev, | 142 | dev_err(vr41xx_gpio_chip.dev, |
143 | "unable to lock HW IRQ %lu for IRQ\n", | 143 | "unable to lock HW IRQ %lu for IRQ\n", |
144 | data->hwirq); | 144 | data->hwirq); |
@@ -150,7 +150,7 @@ static unsigned int startup_giuint(struct irq_data *data) | |||
150 | static void shutdown_giuint(struct irq_data *data) | 150 | static void shutdown_giuint(struct irq_data *data) |
151 | { | 151 | { |
152 | mask_giuint_low(data); | 152 | mask_giuint_low(data); |
153 | gpio_unlock_as_irq(&vr41xx_gpio_chip, data->hwirq); | 153 | gpiochip_unlock_as_irq(&vr41xx_gpio_chip, data->hwirq); |
154 | } | 154 | } |
155 | 155 | ||
156 | static struct irq_chip giuint_low_irq_chip = { | 156 | static struct irq_chip giuint_low_irq_chip = { |
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index c3bdaff71c25..c0929d938ced 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -209,7 +209,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, | |||
209 | 209 | ||
210 | gpiod_direction_input(desc); | 210 | gpiod_direction_input(desc); |
211 | 211 | ||
212 | ret = gpio_lock_as_irq(chip, pin); | 212 | ret = gpiochip_lock_as_irq(chip, pin); |
213 | if (ret) { | 213 | if (ret) { |
214 | dev_err(chip->dev, "Failed to lock GPIO as interrupt\n"); | 214 | dev_err(chip->dev, "Failed to lock GPIO as interrupt\n"); |
215 | goto fail_free_desc; | 215 | goto fail_free_desc; |
@@ -265,7 +265,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, | |||
265 | fail_free_event: | 265 | fail_free_event: |
266 | kfree(event); | 266 | kfree(event); |
267 | fail_unlock_irq: | 267 | fail_unlock_irq: |
268 | gpio_unlock_as_irq(chip, pin); | 268 | gpiochip_unlock_as_irq(chip, pin); |
269 | fail_free_desc: | 269 | fail_free_desc: |
270 | gpiochip_free_own_desc(desc); | 270 | gpiochip_free_own_desc(desc); |
271 | 271 | ||
@@ -336,7 +336,7 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) | |||
336 | desc = event->desc; | 336 | desc = event->desc; |
337 | if (WARN_ON(IS_ERR(desc))) | 337 | if (WARN_ON(IS_ERR(desc))) |
338 | continue; | 338 | continue; |
339 | gpio_unlock_as_irq(chip, event->pin); | 339 | gpiochip_unlock_as_irq(chip, event->pin); |
340 | gpiochip_free_own_desc(desc); | 340 | gpiochip_free_own_desc(desc); |
341 | list_del(&event->node); | 341 | list_del(&event->node); |
342 | kfree(event); | 342 | kfree(event); |
diff --git a/drivers/gpio/gpiolib-legacy.c b/drivers/gpio/gpiolib-legacy.c index 078ae6c2df79..8b830996fe02 100644 --- a/drivers/gpio/gpiolib-legacy.c +++ b/drivers/gpio/gpiolib-legacy.c | |||
@@ -24,6 +24,10 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label) | |||
24 | 24 | ||
25 | desc = gpio_to_desc(gpio); | 25 | desc = gpio_to_desc(gpio); |
26 | 26 | ||
27 | /* Compatibility: assume unavailable "valid" GPIOs will appear later */ | ||
28 | if (!desc && gpio_is_valid(gpio)) | ||
29 | return -EPROBE_DEFER; | ||
30 | |||
27 | err = gpiod_request(desc, label); | 31 | err = gpiod_request(desc, label); |
28 | if (err) | 32 | if (err) |
29 | return err; | 33 | return err; |
@@ -62,7 +66,13 @@ EXPORT_SYMBOL_GPL(gpio_request_one); | |||
62 | 66 | ||
63 | int gpio_request(unsigned gpio, const char *label) | 67 | int gpio_request(unsigned gpio, const char *label) |
64 | { | 68 | { |
65 | return gpiod_request(gpio_to_desc(gpio), label); | 69 | struct gpio_desc *desc = gpio_to_desc(gpio); |
70 | |||
71 | /* Compatibility: assume unavailable "valid" GPIOs will appear later */ | ||
72 | if (!desc && gpio_is_valid(gpio)) | ||
73 | return -EPROBE_DEFER; | ||
74 | |||
75 | return gpiod_request(desc, label); | ||
66 | } | 76 | } |
67 | EXPORT_SYMBOL_GPL(gpio_request); | 77 | EXPORT_SYMBOL_GPL(gpio_request); |
68 | 78 | ||
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 5f2150b619a7..2ac1800b58bb 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c | |||
@@ -41,7 +41,7 @@ static DEFINE_MUTEX(sysfs_lock); | |||
41 | static ssize_t gpio_direction_show(struct device *dev, | 41 | static ssize_t gpio_direction_show(struct device *dev, |
42 | struct device_attribute *attr, char *buf) | 42 | struct device_attribute *attr, char *buf) |
43 | { | 43 | { |
44 | const struct gpio_desc *desc = dev_get_drvdata(dev); | 44 | struct gpio_desc *desc = dev_get_drvdata(dev); |
45 | ssize_t status; | 45 | ssize_t status; |
46 | 46 | ||
47 | mutex_lock(&sysfs_lock); | 47 | mutex_lock(&sysfs_lock); |
@@ -161,7 +161,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev, | |||
161 | desc->flags &= ~GPIO_TRIGGER_MASK; | 161 | desc->flags &= ~GPIO_TRIGGER_MASK; |
162 | 162 | ||
163 | if (!gpio_flags) { | 163 | if (!gpio_flags) { |
164 | gpio_unlock_as_irq(desc->chip, gpio_chip_hwgpio(desc)); | 164 | gpiochip_unlock_as_irq(desc->chip, gpio_chip_hwgpio(desc)); |
165 | ret = 0; | 165 | ret = 0; |
166 | goto free_id; | 166 | goto free_id; |
167 | } | 167 | } |
@@ -200,7 +200,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev, | |||
200 | if (ret < 0) | 200 | if (ret < 0) |
201 | goto free_id; | 201 | goto free_id; |
202 | 202 | ||
203 | ret = gpio_lock_as_irq(desc->chip, gpio_chip_hwgpio(desc)); | 203 | ret = gpiochip_lock_as_irq(desc->chip, gpio_chip_hwgpio(desc)); |
204 | if (ret < 0) { | 204 | if (ret < 0) { |
205 | gpiod_warn(desc, "failed to flag the GPIO for IRQ\n"); | 205 | gpiod_warn(desc, "failed to flag the GPIO for IRQ\n"); |
206 | goto free_id; | 206 | goto free_id; |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 58659dbe702a..487afe6f22fc 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -47,8 +47,6 @@ | |||
47 | */ | 47 | */ |
48 | DEFINE_SPINLOCK(gpio_lock); | 48 | DEFINE_SPINLOCK(gpio_lock); |
49 | 49 | ||
50 | static struct gpio_desc gpio_desc[ARCH_NR_GPIOS]; | ||
51 | |||
52 | #define GPIO_OFFSET_VALID(chip, offset) (offset >= 0 && offset < chip->ngpio) | 50 | #define GPIO_OFFSET_VALID(chip, offset) (offset >= 0 && offset < chip->ngpio) |
53 | 51 | ||
54 | static DEFINE_MUTEX(gpio_lookup_lock); | 52 | static DEFINE_MUTEX(gpio_lookup_lock); |
@@ -65,10 +63,24 @@ static inline void desc_set_label(struct gpio_desc *d, const char *label) | |||
65 | */ | 63 | */ |
66 | struct gpio_desc *gpio_to_desc(unsigned gpio) | 64 | struct gpio_desc *gpio_to_desc(unsigned gpio) |
67 | { | 65 | { |
68 | if (WARN(!gpio_is_valid(gpio), "invalid GPIO %d\n", gpio)) | 66 | struct gpio_chip *chip; |
69 | return NULL; | 67 | unsigned long flags; |
70 | else | 68 | |
71 | return &gpio_desc[gpio]; | 69 | spin_lock_irqsave(&gpio_lock, flags); |
70 | |||
71 | list_for_each_entry(chip, &gpio_chips, list) { | ||
72 | if (chip->base <= gpio && chip->base + chip->ngpio > gpio) { | ||
73 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
74 | return &chip->desc[gpio - chip->base]; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
79 | |||
80 | if (!gpio_is_valid(gpio)) | ||
81 | WARN(1, "invalid GPIO %d\n", gpio); | ||
82 | |||
83 | return NULL; | ||
72 | } | 84 | } |
73 | EXPORT_SYMBOL_GPL(gpio_to_desc); | 85 | EXPORT_SYMBOL_GPL(gpio_to_desc); |
74 | 86 | ||
@@ -91,7 +103,7 @@ struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, | |||
91 | */ | 103 | */ |
92 | int desc_to_gpio(const struct gpio_desc *desc) | 104 | int desc_to_gpio(const struct gpio_desc *desc) |
93 | { | 105 | { |
94 | return desc - &gpio_desc[0]; | 106 | return desc->chip->base + (desc - &desc->chip->desc[0]); |
95 | } | 107 | } |
96 | EXPORT_SYMBOL_GPL(desc_to_gpio); | 108 | EXPORT_SYMBOL_GPL(desc_to_gpio); |
97 | 109 | ||
@@ -138,7 +150,7 @@ static int gpiochip_find_base(int ngpio) | |||
138 | * | 150 | * |
139 | * This function may sleep if gpiod_cansleep() is true. | 151 | * This function may sleep if gpiod_cansleep() is true. |
140 | */ | 152 | */ |
141 | int gpiod_get_direction(const struct gpio_desc *desc) | 153 | int gpiod_get_direction(struct gpio_desc *desc) |
142 | { | 154 | { |
143 | struct gpio_chip *chip; | 155 | struct gpio_chip *chip; |
144 | unsigned offset; | 156 | unsigned offset; |
@@ -154,13 +166,11 @@ int gpiod_get_direction(const struct gpio_desc *desc) | |||
154 | if (status > 0) { | 166 | if (status > 0) { |
155 | /* GPIOF_DIR_IN, or other positive */ | 167 | /* GPIOF_DIR_IN, or other positive */ |
156 | status = 1; | 168 | status = 1; |
157 | /* FLAG_IS_OUT is just a cache of the result of get_direction(), | 169 | clear_bit(FLAG_IS_OUT, &desc->flags); |
158 | * so it does not affect constness per se */ | ||
159 | clear_bit(FLAG_IS_OUT, &((struct gpio_desc *)desc)->flags); | ||
160 | } | 170 | } |
161 | if (status == 0) { | 171 | if (status == 0) { |
162 | /* GPIOF_DIR_OUT */ | 172 | /* GPIOF_DIR_OUT */ |
163 | set_bit(FLAG_IS_OUT, &((struct gpio_desc *)desc)->flags); | 173 | set_bit(FLAG_IS_OUT, &desc->flags); |
164 | } | 174 | } |
165 | return status; | 175 | return status; |
166 | } | 176 | } |
@@ -206,7 +216,7 @@ static int gpiochip_add_to_list(struct gpio_chip *chip) | |||
206 | /** | 216 | /** |
207 | * gpiochip_add() - register a gpio_chip | 217 | * gpiochip_add() - register a gpio_chip |
208 | * @chip: the chip to register, with chip->base initialized | 218 | * @chip: the chip to register, with chip->base initialized |
209 | * Context: potentially before irqs or kmalloc will work | 219 | * Context: potentially before irqs will work |
210 | * | 220 | * |
211 | * Returns a negative errno if the chip can't be registered, such as | 221 | * Returns a negative errno if the chip can't be registered, such as |
212 | * because the chip->base is invalid or already associated with a | 222 | * because the chip->base is invalid or already associated with a |
@@ -226,12 +236,11 @@ int gpiochip_add(struct gpio_chip *chip) | |||
226 | int status = 0; | 236 | int status = 0; |
227 | unsigned id; | 237 | unsigned id; |
228 | int base = chip->base; | 238 | int base = chip->base; |
239 | struct gpio_desc *descs; | ||
229 | 240 | ||
230 | if ((!gpio_is_valid(base) || !gpio_is_valid(base + chip->ngpio - 1)) | 241 | descs = kcalloc(chip->ngpio, sizeof(descs[0]), GFP_KERNEL); |
231 | && base >= 0) { | 242 | if (!descs) |
232 | status = -EINVAL; | 243 | return -ENOMEM; |
233 | goto fail; | ||
234 | } | ||
235 | 244 | ||
236 | spin_lock_irqsave(&gpio_lock, flags); | 245 | spin_lock_irqsave(&gpio_lock, flags); |
237 | 246 | ||
@@ -247,10 +256,8 @@ int gpiochip_add(struct gpio_chip *chip) | |||
247 | status = gpiochip_add_to_list(chip); | 256 | status = gpiochip_add_to_list(chip); |
248 | 257 | ||
249 | if (status == 0) { | 258 | if (status == 0) { |
250 | chip->desc = &gpio_desc[chip->base]; | ||
251 | |||
252 | for (id = 0; id < chip->ngpio; id++) { | 259 | for (id = 0; id < chip->ngpio; id++) { |
253 | struct gpio_desc *desc = &chip->desc[id]; | 260 | struct gpio_desc *desc = &descs[id]; |
254 | desc->chip = chip; | 261 | desc->chip = chip; |
255 | 262 | ||
256 | /* REVISIT: most hardware initializes GPIOs as | 263 | /* REVISIT: most hardware initializes GPIOs as |
@@ -266,6 +273,8 @@ int gpiochip_add(struct gpio_chip *chip) | |||
266 | } | 273 | } |
267 | } | 274 | } |
268 | 275 | ||
276 | chip->desc = descs; | ||
277 | |||
269 | spin_unlock_irqrestore(&gpio_lock, flags); | 278 | spin_unlock_irqrestore(&gpio_lock, flags); |
270 | 279 | ||
271 | #ifdef CONFIG_PINCTRL | 280 | #ifdef CONFIG_PINCTRL |
@@ -291,6 +300,9 @@ int gpiochip_add(struct gpio_chip *chip) | |||
291 | unlock: | 300 | unlock: |
292 | spin_unlock_irqrestore(&gpio_lock, flags); | 301 | spin_unlock_irqrestore(&gpio_lock, flags); |
293 | fail: | 302 | fail: |
303 | kfree(descs); | ||
304 | chip->desc = NULL; | ||
305 | |||
294 | /* failures here can mean systems won't boot... */ | 306 | /* failures here can mean systems won't boot... */ |
295 | pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__, | 307 | pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__, |
296 | chip->base, chip->base + chip->ngpio - 1, | 308 | chip->base, chip->base + chip->ngpio - 1, |
@@ -331,6 +343,9 @@ void gpiochip_remove(struct gpio_chip *chip) | |||
331 | list_del(&chip->list); | 343 | list_del(&chip->list); |
332 | spin_unlock_irqrestore(&gpio_lock, flags); | 344 | spin_unlock_irqrestore(&gpio_lock, flags); |
333 | gpiochip_unexport(chip); | 345 | gpiochip_unexport(chip); |
346 | |||
347 | kfree(chip->desc); | ||
348 | chip->desc = NULL; | ||
334 | } | 349 | } |
335 | EXPORT_SYMBOL_GPL(gpiochip_remove); | 350 | EXPORT_SYMBOL_GPL(gpiochip_remove); |
336 | 351 | ||
@@ -495,7 +510,7 @@ static int gpiochip_irq_reqres(struct irq_data *d) | |||
495 | { | 510 | { |
496 | struct gpio_chip *chip = irq_data_get_irq_chip_data(d); | 511 | struct gpio_chip *chip = irq_data_get_irq_chip_data(d); |
497 | 512 | ||
498 | if (gpio_lock_as_irq(chip, d->hwirq)) { | 513 | if (gpiochip_lock_as_irq(chip, d->hwirq)) { |
499 | chip_err(chip, | 514 | chip_err(chip, |
500 | "unable to lock HW IRQ %lu for IRQ\n", | 515 | "unable to lock HW IRQ %lu for IRQ\n", |
501 | d->hwirq); | 516 | d->hwirq); |
@@ -508,7 +523,7 @@ static void gpiochip_irq_relres(struct irq_data *d) | |||
508 | { | 523 | { |
509 | struct gpio_chip *chip = irq_data_get_irq_chip_data(d); | 524 | struct gpio_chip *chip = irq_data_get_irq_chip_data(d); |
510 | 525 | ||
511 | gpio_unlock_as_irq(chip, d->hwirq); | 526 | gpiochip_unlock_as_irq(chip, d->hwirq); |
512 | } | 527 | } |
513 | 528 | ||
514 | static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) | 529 | static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) |
@@ -1254,6 +1269,88 @@ static void _gpiod_set_raw_value(struct gpio_desc *desc, bool value) | |||
1254 | chip->set(chip, gpio_chip_hwgpio(desc), value); | 1269 | chip->set(chip, gpio_chip_hwgpio(desc), value); |
1255 | } | 1270 | } |
1256 | 1271 | ||
1272 | /* | ||
1273 | * set multiple outputs on the same chip; | ||
1274 | * use the chip's set_multiple function if available; | ||
1275 | * otherwise set the outputs sequentially; | ||
1276 | * @mask: bit mask array; one bit per output; BITS_PER_LONG bits per word | ||
1277 | * defines which outputs are to be changed | ||
1278 | * @bits: bit value array; one bit per output; BITS_PER_LONG bits per word | ||
1279 | * defines the values the outputs specified by mask are to be set to | ||
1280 | */ | ||
1281 | static void gpio_chip_set_multiple(struct gpio_chip *chip, | ||
1282 | unsigned long *mask, unsigned long *bits) | ||
1283 | { | ||
1284 | if (chip->set_multiple) { | ||
1285 | chip->set_multiple(chip, mask, bits); | ||
1286 | } else { | ||
1287 | int i; | ||
1288 | for (i = 0; i < chip->ngpio; i++) { | ||
1289 | if (mask[BIT_WORD(i)] == 0) { | ||
1290 | /* no more set bits in this mask word; | ||
1291 | * skip ahead to the next word */ | ||
1292 | i = (BIT_WORD(i) + 1) * BITS_PER_LONG - 1; | ||
1293 | continue; | ||
1294 | } | ||
1295 | /* set outputs if the corresponding mask bit is set */ | ||
1296 | if (__test_and_clear_bit(i, mask)) { | ||
1297 | chip->set(chip, i, test_bit(i, bits)); | ||
1298 | } | ||
1299 | } | ||
1300 | } | ||
1301 | } | ||
1302 | |||
1303 | static void gpiod_set_array_priv(bool raw, bool can_sleep, | ||
1304 | unsigned int array_size, | ||
1305 | struct gpio_desc **desc_array, | ||
1306 | int *value_array) | ||
1307 | { | ||
1308 | int i = 0; | ||
1309 | |||
1310 | while (i < array_size) { | ||
1311 | struct gpio_chip *chip = desc_array[i]->chip; | ||
1312 | unsigned long mask[BITS_TO_LONGS(chip->ngpio)]; | ||
1313 | unsigned long bits[BITS_TO_LONGS(chip->ngpio)]; | ||
1314 | int count = 0; | ||
1315 | |||
1316 | if (!can_sleep) { | ||
1317 | WARN_ON(chip->can_sleep); | ||
1318 | } | ||
1319 | memset(mask, 0, sizeof(mask)); | ||
1320 | do { | ||
1321 | struct gpio_desc *desc = desc_array[i]; | ||
1322 | int hwgpio = gpio_chip_hwgpio(desc); | ||
1323 | int value = value_array[i]; | ||
1324 | |||
1325 | if (!raw && test_bit(FLAG_ACTIVE_LOW, &desc->flags)) | ||
1326 | value = !value; | ||
1327 | trace_gpio_value(desc_to_gpio(desc), 0, value); | ||
1328 | /* | ||
1329 | * collect all normal outputs belonging to the same chip | ||
1330 | * open drain and open source outputs are set individually | ||
1331 | */ | ||
1332 | if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { | ||
1333 | _gpio_set_open_drain_value(desc,value); | ||
1334 | } else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) { | ||
1335 | _gpio_set_open_source_value(desc, value); | ||
1336 | } else { | ||
1337 | __set_bit(hwgpio, mask); | ||
1338 | if (value) { | ||
1339 | __set_bit(hwgpio, bits); | ||
1340 | } else { | ||
1341 | __clear_bit(hwgpio, bits); | ||
1342 | } | ||
1343 | count++; | ||
1344 | } | ||
1345 | i++; | ||
1346 | } while ((i < array_size) && (desc_array[i]->chip == chip)); | ||
1347 | /* push collected bits to outputs */ | ||
1348 | if (count != 0) { | ||
1349 | gpio_chip_set_multiple(chip, mask, bits); | ||
1350 | } | ||
1351 | } | ||
1352 | } | ||
1353 | |||
1257 | /** | 1354 | /** |
1258 | * gpiod_set_raw_value() - assign a gpio's raw value | 1355 | * gpiod_set_raw_value() - assign a gpio's raw value |
1259 | * @desc: gpio whose value will be assigned | 1356 | * @desc: gpio whose value will be assigned |
@@ -1299,6 +1396,48 @@ void gpiod_set_value(struct gpio_desc *desc, int value) | |||
1299 | EXPORT_SYMBOL_GPL(gpiod_set_value); | 1396 | EXPORT_SYMBOL_GPL(gpiod_set_value); |
1300 | 1397 | ||
1301 | /** | 1398 | /** |
1399 | * gpiod_set_raw_array() - assign values to an array of GPIOs | ||
1400 | * @array_size: number of elements in the descriptor / value arrays | ||
1401 | * @desc_array: array of GPIO descriptors whose values will be assigned | ||
1402 | * @value_array: array of values to assign | ||
1403 | * | ||
1404 | * Set the raw values of the GPIOs, i.e. the values of the physical lines | ||
1405 | * without regard for their ACTIVE_LOW status. | ||
1406 | * | ||
1407 | * This function should be called from contexts where we cannot sleep, and will | ||
1408 | * complain if the GPIO chip functions potentially sleep. | ||
1409 | */ | ||
1410 | void gpiod_set_raw_array(unsigned int array_size, | ||
1411 | struct gpio_desc **desc_array, int *value_array) | ||
1412 | { | ||
1413 | if (!desc_array) | ||
1414 | return; | ||
1415 | gpiod_set_array_priv(true, false, array_size, desc_array, value_array); | ||
1416 | } | ||
1417 | EXPORT_SYMBOL_GPL(gpiod_set_raw_array); | ||
1418 | |||
1419 | /** | ||
1420 | * gpiod_set_array() - assign values to an array of GPIOs | ||
1421 | * @array_size: number of elements in the descriptor / value arrays | ||
1422 | * @desc_array: array of GPIO descriptors whose values will be assigned | ||
1423 | * @value_array: array of values to assign | ||
1424 | * | ||
1425 | * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | ||
1426 | * into account. | ||
1427 | * | ||
1428 | * This function should be called from contexts where we cannot sleep, and will | ||
1429 | * complain if the GPIO chip functions potentially sleep. | ||
1430 | */ | ||
1431 | void gpiod_set_array(unsigned int array_size, | ||
1432 | struct gpio_desc **desc_array, int *value_array) | ||
1433 | { | ||
1434 | if (!desc_array) | ||
1435 | return; | ||
1436 | gpiod_set_array_priv(false, false, array_size, desc_array, value_array); | ||
1437 | } | ||
1438 | EXPORT_SYMBOL_GPL(gpiod_set_array); | ||
1439 | |||
1440 | /** | ||
1302 | * gpiod_cansleep() - report whether gpio value access may sleep | 1441 | * gpiod_cansleep() - report whether gpio value access may sleep |
1303 | * @desc: gpio to check | 1442 | * @desc: gpio to check |
1304 | * | 1443 | * |
@@ -1332,14 +1471,14 @@ int gpiod_to_irq(const struct gpio_desc *desc) | |||
1332 | EXPORT_SYMBOL_GPL(gpiod_to_irq); | 1471 | EXPORT_SYMBOL_GPL(gpiod_to_irq); |
1333 | 1472 | ||
1334 | /** | 1473 | /** |
1335 | * gpio_lock_as_irq() - lock a GPIO to be used as IRQ | 1474 | * gpiochip_lock_as_irq() - lock a GPIO to be used as IRQ |
1336 | * @chip: the chip the GPIO to lock belongs to | 1475 | * @chip: the chip the GPIO to lock belongs to |
1337 | * @offset: the offset of the GPIO to lock as IRQ | 1476 | * @offset: the offset of the GPIO to lock as IRQ |
1338 | * | 1477 | * |
1339 | * This is used directly by GPIO drivers that want to lock down | 1478 | * This is used directly by GPIO drivers that want to lock down |
1340 | * a certain GPIO line to be used for IRQs. | 1479 | * a certain GPIO line to be used for IRQs. |
1341 | */ | 1480 | */ |
1342 | int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset) | 1481 | int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset) |
1343 | { | 1482 | { |
1344 | if (offset >= chip->ngpio) | 1483 | if (offset >= chip->ngpio) |
1345 | return -EINVAL; | 1484 | return -EINVAL; |
@@ -1354,24 +1493,24 @@ int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset) | |||
1354 | set_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags); | 1493 | set_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags); |
1355 | return 0; | 1494 | return 0; |
1356 | } | 1495 | } |
1357 | EXPORT_SYMBOL_GPL(gpio_lock_as_irq); | 1496 | EXPORT_SYMBOL_GPL(gpiochip_lock_as_irq); |
1358 | 1497 | ||
1359 | /** | 1498 | /** |
1360 | * gpio_unlock_as_irq() - unlock a GPIO used as IRQ | 1499 | * gpiochip_unlock_as_irq() - unlock a GPIO used as IRQ |
1361 | * @chip: the chip the GPIO to lock belongs to | 1500 | * @chip: the chip the GPIO to lock belongs to |
1362 | * @offset: the offset of the GPIO to lock as IRQ | 1501 | * @offset: the offset of the GPIO to lock as IRQ |
1363 | * | 1502 | * |
1364 | * This is used directly by GPIO drivers that want to indicate | 1503 | * This is used directly by GPIO drivers that want to indicate |
1365 | * that a certain GPIO is no longer used exclusively for IRQ. | 1504 | * that a certain GPIO is no longer used exclusively for IRQ. |
1366 | */ | 1505 | */ |
1367 | void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) | 1506 | void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) |
1368 | { | 1507 | { |
1369 | if (offset >= chip->ngpio) | 1508 | if (offset >= chip->ngpio) |
1370 | return; | 1509 | return; |
1371 | 1510 | ||
1372 | clear_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags); | 1511 | clear_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags); |
1373 | } | 1512 | } |
1374 | EXPORT_SYMBOL_GPL(gpio_unlock_as_irq); | 1513 | EXPORT_SYMBOL_GPL(gpiochip_unlock_as_irq); |
1375 | 1514 | ||
1376 | /** | 1515 | /** |
1377 | * gpiod_get_raw_value_cansleep() - return a gpio's raw value | 1516 | * gpiod_get_raw_value_cansleep() - return a gpio's raw value |
@@ -1458,6 +1597,50 @@ void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) | |||
1458 | EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep); | 1597 | EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep); |
1459 | 1598 | ||
1460 | /** | 1599 | /** |
1600 | * gpiod_set_raw_array_cansleep() - assign values to an array of GPIOs | ||
1601 | * @array_size: number of elements in the descriptor / value arrays | ||
1602 | * @desc_array: array of GPIO descriptors whose values will be assigned | ||
1603 | * @value_array: array of values to assign | ||
1604 | * | ||
1605 | * Set the raw values of the GPIOs, i.e. the values of the physical lines | ||
1606 | * without regard for their ACTIVE_LOW status. | ||
1607 | * | ||
1608 | * This function is to be called from contexts that can sleep. | ||
1609 | */ | ||
1610 | void gpiod_set_raw_array_cansleep(unsigned int array_size, | ||
1611 | struct gpio_desc **desc_array, | ||
1612 | int *value_array) | ||
1613 | { | ||
1614 | might_sleep_if(extra_checks); | ||
1615 | if (!desc_array) | ||
1616 | return; | ||
1617 | gpiod_set_array_priv(true, true, array_size, desc_array, value_array); | ||
1618 | } | ||
1619 | EXPORT_SYMBOL_GPL(gpiod_set_raw_array_cansleep); | ||
1620 | |||
1621 | /** | ||
1622 | * gpiod_set_array_cansleep() - assign values to an array of GPIOs | ||
1623 | * @array_size: number of elements in the descriptor / value arrays | ||
1624 | * @desc_array: array of GPIO descriptors whose values will be assigned | ||
1625 | * @value_array: array of values to assign | ||
1626 | * | ||
1627 | * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | ||
1628 | * into account. | ||
1629 | * | ||
1630 | * This function is to be called from contexts that can sleep. | ||
1631 | */ | ||
1632 | void gpiod_set_array_cansleep(unsigned int array_size, | ||
1633 | struct gpio_desc **desc_array, | ||
1634 | int *value_array) | ||
1635 | { | ||
1636 | might_sleep_if(extra_checks); | ||
1637 | if (!desc_array) | ||
1638 | return; | ||
1639 | gpiod_set_array_priv(false, true, array_size, desc_array, value_array); | ||
1640 | } | ||
1641 | EXPORT_SYMBOL_GPL(gpiod_set_array_cansleep); | ||
1642 | |||
1643 | /** | ||
1461 | * gpiod_add_lookup_table() - register GPIO device consumers | 1644 | * gpiod_add_lookup_table() - register GPIO device consumers |
1462 | * @table: table of consumers to register | 1645 | * @table: table of consumers to register |
1463 | */ | 1646 | */ |
diff --git a/drivers/net/phy/mdio-mux-gpio.c b/drivers/net/phy/mdio-mux-gpio.c index 096695163491..1eaf81efde24 100644 --- a/drivers/net/phy/mdio-mux-gpio.c +++ b/drivers/net/phy/mdio-mux-gpio.c | |||
@@ -14,13 +14,13 @@ | |||
14 | #include <linux/mdio-mux.h> | 14 | #include <linux/mdio-mux.h> |
15 | #include <linux/of_gpio.h> | 15 | #include <linux/of_gpio.h> |
16 | 16 | ||
17 | #define DRV_VERSION "1.0" | 17 | #define DRV_VERSION "1.1" |
18 | #define DRV_DESCRIPTION "GPIO controlled MDIO bus multiplexer driver" | 18 | #define DRV_DESCRIPTION "GPIO controlled MDIO bus multiplexer driver" |
19 | 19 | ||
20 | #define MDIO_MUX_GPIO_MAX_BITS 8 | 20 | #define MDIO_MUX_GPIO_MAX_BITS 8 |
21 | 21 | ||
22 | struct mdio_mux_gpio_state { | 22 | struct mdio_mux_gpio_state { |
23 | int gpio[MDIO_MUX_GPIO_MAX_BITS]; | 23 | struct gpio_desc *gpio[MDIO_MUX_GPIO_MAX_BITS]; |
24 | unsigned int num_gpios; | 24 | unsigned int num_gpios; |
25 | void *mux_handle; | 25 | void *mux_handle; |
26 | }; | 26 | }; |
@@ -28,29 +28,23 @@ struct mdio_mux_gpio_state { | |||
28 | static int mdio_mux_gpio_switch_fn(int current_child, int desired_child, | 28 | static int mdio_mux_gpio_switch_fn(int current_child, int desired_child, |
29 | void *data) | 29 | void *data) |
30 | { | 30 | { |
31 | int change; | 31 | int values[MDIO_MUX_GPIO_MAX_BITS]; |
32 | unsigned int n; | 32 | unsigned int n; |
33 | struct mdio_mux_gpio_state *s = data; | 33 | struct mdio_mux_gpio_state *s = data; |
34 | 34 | ||
35 | if (current_child == desired_child) | 35 | if (current_child == desired_child) |
36 | return 0; | 36 | return 0; |
37 | 37 | ||
38 | change = current_child == -1 ? -1 : current_child ^ desired_child; | ||
39 | |||
40 | for (n = 0; n < s->num_gpios; n++) { | 38 | for (n = 0; n < s->num_gpios; n++) { |
41 | if (change & 1) | 39 | values[n] = (desired_child >> n) & 1; |
42 | gpio_set_value_cansleep(s->gpio[n], | ||
43 | (desired_child & 1) != 0); | ||
44 | change >>= 1; | ||
45 | desired_child >>= 1; | ||
46 | } | 40 | } |
41 | gpiod_set_array_cansleep(s->num_gpios, s->gpio, values); | ||
47 | 42 | ||
48 | return 0; | 43 | return 0; |
49 | } | 44 | } |
50 | 45 | ||
51 | static int mdio_mux_gpio_probe(struct platform_device *pdev) | 46 | static int mdio_mux_gpio_probe(struct platform_device *pdev) |
52 | { | 47 | { |
53 | enum of_gpio_flags f; | ||
54 | struct mdio_mux_gpio_state *s; | 48 | struct mdio_mux_gpio_state *s; |
55 | int num_gpios; | 49 | int num_gpios; |
56 | unsigned int n; | 50 | unsigned int n; |
@@ -70,22 +64,14 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) | |||
70 | s->num_gpios = num_gpios; | 64 | s->num_gpios = num_gpios; |
71 | 65 | ||
72 | for (n = 0; n < num_gpios; ) { | 66 | for (n = 0; n < num_gpios; ) { |
73 | int gpio = of_get_gpio_flags(pdev->dev.of_node, n, &f); | 67 | struct gpio_desc *gpio = gpiod_get_index(&pdev->dev, NULL, n, |
74 | if (gpio < 0) { | 68 | GPIOD_OUT_LOW); |
75 | r = (gpio == -ENODEV) ? -EPROBE_DEFER : gpio; | 69 | if (IS_ERR(gpio)) { |
70 | r = PTR_ERR(gpio); | ||
76 | goto err; | 71 | goto err; |
77 | } | 72 | } |
78 | s->gpio[n] = gpio; | 73 | s->gpio[n] = gpio; |
79 | |||
80 | n++; | 74 | n++; |
81 | |||
82 | r = gpio_request(gpio, "mdio_mux_gpio"); | ||
83 | if (r) | ||
84 | goto err; | ||
85 | |||
86 | r = gpio_direction_output(gpio, 0); | ||
87 | if (r) | ||
88 | goto err; | ||
89 | } | 75 | } |
90 | 76 | ||
91 | r = mdio_mux_init(&pdev->dev, | 77 | r = mdio_mux_init(&pdev->dev, |
@@ -98,15 +84,18 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) | |||
98 | err: | 84 | err: |
99 | while (n) { | 85 | while (n) { |
100 | n--; | 86 | n--; |
101 | gpio_free(s->gpio[n]); | 87 | gpiod_put(s->gpio[n]); |
102 | } | 88 | } |
103 | return r; | 89 | return r; |
104 | } | 90 | } |
105 | 91 | ||
106 | static int mdio_mux_gpio_remove(struct platform_device *pdev) | 92 | static int mdio_mux_gpio_remove(struct platform_device *pdev) |
107 | { | 93 | { |
94 | unsigned int n; | ||
108 | struct mdio_mux_gpio_state *s = dev_get_platdata(&pdev->dev); | 95 | struct mdio_mux_gpio_state *s = dev_get_platdata(&pdev->dev); |
109 | mdio_mux_uninit(s->mux_handle); | 96 | mdio_mux_uninit(s->mux_handle); |
97 | for (n = 0; n < s->num_gpios; n++) | ||
98 | gpiod_put(s->gpio[n]); | ||
110 | return 0; | 99 | return 0; |
111 | } | 100 | } |
112 | 101 | ||
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 66db9849aca8..2867730100e4 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c | |||
@@ -1471,7 +1471,7 @@ static unsigned int gpio_irq_startup(struct irq_data *d) | |||
1471 | unsigned pin = d->hwirq; | 1471 | unsigned pin = d->hwirq; |
1472 | int ret; | 1472 | int ret; |
1473 | 1473 | ||
1474 | ret = gpio_lock_as_irq(&at91_gpio->chip, pin); | 1474 | ret = gpiochip_lock_as_irq(&at91_gpio->chip, pin); |
1475 | if (ret) { | 1475 | if (ret) { |
1476 | dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n", | 1476 | dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n", |
1477 | d->hwirq); | 1477 | d->hwirq); |
@@ -1487,7 +1487,7 @@ static void gpio_irq_shutdown(struct irq_data *d) | |||
1487 | unsigned pin = d->hwirq; | 1487 | unsigned pin = d->hwirq; |
1488 | 1488 | ||
1489 | gpio_irq_mask(d); | 1489 | gpio_irq_mask(d); |
1490 | gpio_unlock_as_irq(&at91_gpio->chip, pin); | 1490 | gpiochip_unlock_as_irq(&at91_gpio->chip, pin); |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | #ifdef CONFIG_PM | 1493 | #ifdef CONFIG_PM |
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c index d5d4cfc55873..becb3792977b 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c | |||
@@ -174,7 +174,7 @@ static int exynos_irq_request_resources(struct irq_data *irqd) | |||
174 | unsigned int con; | 174 | unsigned int con; |
175 | int ret; | 175 | int ret; |
176 | 176 | ||
177 | ret = gpio_lock_as_irq(&bank->gpio_chip, irqd->hwirq); | 177 | ret = gpiochip_lock_as_irq(&bank->gpio_chip, irqd->hwirq); |
178 | if (ret) { | 178 | if (ret) { |
179 | dev_err(bank->gpio_chip.dev, "unable to lock pin %s-%lu IRQ\n", | 179 | dev_err(bank->gpio_chip.dev, "unable to lock pin %s-%lu IRQ\n", |
180 | bank->name, irqd->hwirq); | 180 | bank->name, irqd->hwirq); |
@@ -227,7 +227,7 @@ static void exynos_irq_release_resources(struct irq_data *irqd) | |||
227 | 227 | ||
228 | spin_unlock_irqrestore(&bank->slock, flags); | 228 | spin_unlock_irqrestore(&bank->slock, flags); |
229 | 229 | ||
230 | gpio_unlock_as_irq(&bank->gpio_chip, irqd->hwirq); | 230 | gpiochip_unlock_as_irq(&bank->gpio_chip, irqd->hwirq); |
231 | } | 231 | } |
232 | 232 | ||
233 | /* | 233 | /* |
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index ef9d804e55de..3d0744337736 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c | |||
@@ -553,7 +553,7 @@ static int sunxi_pinctrl_irq_request_resources(struct irq_data *d) | |||
553 | if (!func) | 553 | if (!func) |
554 | return -EINVAL; | 554 | return -EINVAL; |
555 | 555 | ||
556 | ret = gpio_lock_as_irq(pctl->chip, | 556 | ret = gpiochip_lock_as_irq(pctl->chip, |
557 | pctl->irq_array[d->hwirq] - pctl->desc->pin_base); | 557 | pctl->irq_array[d->hwirq] - pctl->desc->pin_base); |
558 | if (ret) { | 558 | if (ret) { |
559 | dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n", | 559 | dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n", |
@@ -571,8 +571,8 @@ static void sunxi_pinctrl_irq_release_resources(struct irq_data *d) | |||
571 | { | 571 | { |
572 | struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); | 572 | struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); |
573 | 573 | ||
574 | gpio_unlock_as_irq(pctl->chip, | 574 | gpiochip_unlock_as_irq(pctl->chip, |
575 | pctl->irq_array[d->hwirq] - pctl->desc->pin_base); | 575 | pctl->irq_array[d->hwirq] - pctl->desc->pin_base); |
576 | } | 576 | } |
577 | 577 | ||
578 | static int sunxi_pinctrl_irq_set_type(struct irq_data *d, unsigned int type) | 578 | static int sunxi_pinctrl_irq_set_type(struct irq_data *d, unsigned int type) |
diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c index a3035f997b98..a38596c5194e 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.c +++ b/drivers/tty/serial/serial_mctrl_gpio.c | |||
@@ -44,15 +44,21 @@ static const struct { | |||
44 | void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl) | 44 | void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl) |
45 | { | 45 | { |
46 | enum mctrl_gpio_idx i; | 46 | enum mctrl_gpio_idx i; |
47 | struct gpio_desc *desc_array[UART_GPIO_MAX]; | ||
48 | int value_array[UART_GPIO_MAX]; | ||
49 | unsigned int count = 0; | ||
47 | 50 | ||
48 | if (IS_ERR_OR_NULL(gpios)) | 51 | if (IS_ERR_OR_NULL(gpios)) |
49 | return; | 52 | return; |
50 | 53 | ||
51 | for (i = 0; i < UART_GPIO_MAX; i++) | 54 | for (i = 0; i < UART_GPIO_MAX; i++) |
52 | if (!IS_ERR_OR_NULL(gpios->gpio[i]) && | 55 | if (!IS_ERR_OR_NULL(gpios->gpio[i]) && |
53 | mctrl_gpios_desc[i].dir_out) | 56 | mctrl_gpios_desc[i].dir_out) { |
54 | gpiod_set_value(gpios->gpio[i], | 57 | desc_array[count] = gpios->gpio[i]; |
55 | !!(mctrl & mctrl_gpios_desc[i].mctrl)); | 58 | value_array[count] = !!(mctrl & mctrl_gpios_desc[i].mctrl); |
59 | count++; | ||
60 | } | ||
61 | gpiod_set_array(count, desc_array, value_array); | ||
56 | } | 62 | } |
57 | EXPORT_SYMBOL_GPL(mctrl_gpio_set); | 63 | EXPORT_SYMBOL_GPL(mctrl_gpio_set); |
58 | 64 | ||
diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 85aa5d0b9357..ab81339a8590 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h | |||
@@ -216,14 +216,15 @@ static inline int gpio_to_irq(unsigned gpio) | |||
216 | return -EINVAL; | 216 | return -EINVAL; |
217 | } | 217 | } |
218 | 218 | ||
219 | static inline int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset) | 219 | static inline int gpiochip_lock_as_irq(struct gpio_chip *chip, |
220 | unsigned int offset) | ||
220 | { | 221 | { |
221 | WARN_ON(1); | 222 | WARN_ON(1); |
222 | return -EINVAL; | 223 | return -EINVAL; |
223 | } | 224 | } |
224 | 225 | ||
225 | static inline void gpio_unlock_as_irq(struct gpio_chip *chip, | 226 | static inline void gpiochip_unlock_as_irq(struct gpio_chip *chip, |
226 | unsigned int offset) | 227 | unsigned int offset) |
227 | { | 228 | { |
228 | WARN_ON(1); | 229 | WARN_ON(1); |
229 | } | 230 | } |
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 00b1b70d68ba..fd85cb120ee0 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h | |||
@@ -66,7 +66,7 @@ __devm_gpiod_get_index_optional(struct device *dev, const char *con_id, | |||
66 | unsigned int index, enum gpiod_flags flags); | 66 | unsigned int index, enum gpiod_flags flags); |
67 | void devm_gpiod_put(struct device *dev, struct gpio_desc *desc); | 67 | void devm_gpiod_put(struct device *dev, struct gpio_desc *desc); |
68 | 68 | ||
69 | int gpiod_get_direction(const struct gpio_desc *desc); | 69 | int gpiod_get_direction(struct gpio_desc *desc); |
70 | int gpiod_direction_input(struct gpio_desc *desc); | 70 | int gpiod_direction_input(struct gpio_desc *desc); |
71 | int gpiod_direction_output(struct gpio_desc *desc, int value); | 71 | int gpiod_direction_output(struct gpio_desc *desc, int value); |
72 | int gpiod_direction_output_raw(struct gpio_desc *desc, int value); | 72 | int gpiod_direction_output_raw(struct gpio_desc *desc, int value); |
@@ -74,14 +74,24 @@ int gpiod_direction_output_raw(struct gpio_desc *desc, int value); | |||
74 | /* Value get/set from non-sleeping context */ | 74 | /* Value get/set from non-sleeping context */ |
75 | int gpiod_get_value(const struct gpio_desc *desc); | 75 | int gpiod_get_value(const struct gpio_desc *desc); |
76 | void gpiod_set_value(struct gpio_desc *desc, int value); | 76 | void gpiod_set_value(struct gpio_desc *desc, int value); |
77 | void gpiod_set_array(unsigned int array_size, | ||
78 | struct gpio_desc **desc_array, int *value_array); | ||
77 | int gpiod_get_raw_value(const struct gpio_desc *desc); | 79 | int gpiod_get_raw_value(const struct gpio_desc *desc); |
78 | void gpiod_set_raw_value(struct gpio_desc *desc, int value); | 80 | void gpiod_set_raw_value(struct gpio_desc *desc, int value); |
81 | void gpiod_set_raw_array(unsigned int array_size, | ||
82 | struct gpio_desc **desc_array, int *value_array); | ||
79 | 83 | ||
80 | /* Value get/set from sleeping context */ | 84 | /* Value get/set from sleeping context */ |
81 | int gpiod_get_value_cansleep(const struct gpio_desc *desc); | 85 | int gpiod_get_value_cansleep(const struct gpio_desc *desc); |
82 | void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); | 86 | void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); |
87 | void gpiod_set_array_cansleep(unsigned int array_size, | ||
88 | struct gpio_desc **desc_array, | ||
89 | int *value_array); | ||
83 | int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); | 90 | int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); |
84 | void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); | 91 | void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); |
92 | void gpiod_set_raw_array_cansleep(unsigned int array_size, | ||
93 | struct gpio_desc **desc_array, | ||
94 | int *value_array); | ||
85 | 95 | ||
86 | int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); | 96 | int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); |
87 | 97 | ||
@@ -217,6 +227,13 @@ static inline void gpiod_set_value(struct gpio_desc *desc, int value) | |||
217 | /* GPIO can never have been requested */ | 227 | /* GPIO can never have been requested */ |
218 | WARN_ON(1); | 228 | WARN_ON(1); |
219 | } | 229 | } |
230 | static inline void gpiod_set_array(unsigned int array_size, | ||
231 | struct gpio_desc **desc_array, | ||
232 | int *value_array) | ||
233 | { | ||
234 | /* GPIO can never have been requested */ | ||
235 | WARN_ON(1); | ||
236 | } | ||
220 | static inline int gpiod_get_raw_value(const struct gpio_desc *desc) | 237 | static inline int gpiod_get_raw_value(const struct gpio_desc *desc) |
221 | { | 238 | { |
222 | /* GPIO can never have been requested */ | 239 | /* GPIO can never have been requested */ |
@@ -228,6 +245,13 @@ static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value) | |||
228 | /* GPIO can never have been requested */ | 245 | /* GPIO can never have been requested */ |
229 | WARN_ON(1); | 246 | WARN_ON(1); |
230 | } | 247 | } |
248 | static inline void gpiod_set_raw_array(unsigned int array_size, | ||
249 | struct gpio_desc **desc_array, | ||
250 | int *value_array) | ||
251 | { | ||
252 | /* GPIO can never have been requested */ | ||
253 | WARN_ON(1); | ||
254 | } | ||
231 | 255 | ||
232 | static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc) | 256 | static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc) |
233 | { | 257 | { |
@@ -240,6 +264,13 @@ static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) | |||
240 | /* GPIO can never have been requested */ | 264 | /* GPIO can never have been requested */ |
241 | WARN_ON(1); | 265 | WARN_ON(1); |
242 | } | 266 | } |
267 | static inline void gpiod_set_array_cansleep(unsigned int array_size, | ||
268 | struct gpio_desc **desc_array, | ||
269 | int *value_array) | ||
270 | { | ||
271 | /* GPIO can never have been requested */ | ||
272 | WARN_ON(1); | ||
273 | } | ||
243 | static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) | 274 | static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) |
244 | { | 275 | { |
245 | /* GPIO can never have been requested */ | 276 | /* GPIO can never have been requested */ |
@@ -252,6 +283,13 @@ static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, | |||
252 | /* GPIO can never have been requested */ | 283 | /* GPIO can never have been requested */ |
253 | WARN_ON(1); | 284 | WARN_ON(1); |
254 | } | 285 | } |
286 | static inline void gpiod_set_raw_array_cansleep(unsigned int array_size, | ||
287 | struct gpio_desc **desc_array, | ||
288 | int *value_array) | ||
289 | { | ||
290 | /* GPIO can never have been requested */ | ||
291 | WARN_ON(1); | ||
292 | } | ||
255 | 293 | ||
256 | static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) | 294 | static inline int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) |
257 | { | 295 | { |
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 249db3057e4d..c497c62889d1 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h | |||
@@ -32,6 +32,7 @@ struct seq_file; | |||
32 | * @get: returns value for signal "offset"; for output signals this | 32 | * @get: returns value for signal "offset"; for output signals this |
33 | * returns either the value actually sensed, or zero | 33 | * returns either the value actually sensed, or zero |
34 | * @set: assigns output value for signal "offset" | 34 | * @set: assigns output value for signal "offset" |
35 | * @set_multiple: assigns output values for multiple signals defined by "mask" | ||
35 | * @set_debounce: optional hook for setting debounce time for specified gpio in | 36 | * @set_debounce: optional hook for setting debounce time for specified gpio in |
36 | * interrupt triggered gpio chips | 37 | * interrupt triggered gpio chips |
37 | * @to_irq: optional hook supporting non-static gpio_to_irq() mappings; | 38 | * @to_irq: optional hook supporting non-static gpio_to_irq() mappings; |
@@ -89,6 +90,9 @@ struct gpio_chip { | |||
89 | unsigned offset); | 90 | unsigned offset); |
90 | void (*set)(struct gpio_chip *chip, | 91 | void (*set)(struct gpio_chip *chip, |
91 | unsigned offset, int value); | 92 | unsigned offset, int value); |
93 | void (*set_multiple)(struct gpio_chip *chip, | ||
94 | unsigned long *mask, | ||
95 | unsigned long *bits); | ||
92 | int (*set_debounce)(struct gpio_chip *chip, | 96 | int (*set_debounce)(struct gpio_chip *chip, |
93 | unsigned offset, | 97 | unsigned offset, |
94 | unsigned debounce); | 98 | unsigned debounce); |
@@ -149,8 +153,8 @@ extern struct gpio_chip *gpiochip_find(void *data, | |||
149 | int (*match)(struct gpio_chip *chip, void *data)); | 153 | int (*match)(struct gpio_chip *chip, void *data)); |
150 | 154 | ||
151 | /* lock/unlock as IRQ */ | 155 | /* lock/unlock as IRQ */ |
152 | int gpio_lock_as_irq(struct gpio_chip *chip, unsigned int offset); | 156 | int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset); |
153 | void gpio_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); | 157 | void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset); |
154 | 158 | ||
155 | struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); | 159 | struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); |
156 | 160 | ||