aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/acpi/enumeration.txt36
-rw-r--r--Documentation/arm/Samsung-S3C24XX/GPIO.txt13
-rw-r--r--Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt28
-rw-r--r--Documentation/devicetree/bindings/gpio/moxa,moxart-gpio.txt19
-rw-r--r--Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt3
-rw-r--r--Documentation/gpio/board.txt28
-rw-r--r--Documentation/gpio/consumer.txt6
-rw-r--r--arch/arm/Kconfig4
-rw-r--r--arch/arm/mach-ks8695/include/mach/gpio.h19
-rw-r--r--arch/arm/mach-lpc32xx/include/mach/gpio.h6
-rw-r--r--arch/arm/mach-lpc32xx/phy3250.c2
-rw-r--r--arch/arm/mach-mv78xx0/include/mach/gpio.h9
-rw-r--r--arch/arm/mach-s3c24xx/Kconfig21
-rw-r--r--arch/arm/mach-s3c24xx/common-smdk.c2
-rw-r--r--arch/arm/mach-s3c24xx/h1940-bluetooth.c2
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/gpio-samsung.h (renamed from arch/arm/mach-s3c24xx/include/mach/gpio.h)26
-rw-r--r--arch/arm/mach-s3c24xx/mach-amlm5900.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-anubis.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-at2440evb.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-bast.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-gta02.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-h1940.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-jive.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-mini2440.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-n30.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-nexcoder.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-osiris-dvs.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-osiris.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-qt2410.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-rx1950.c2
-rw-r--r--arch/arm/mach-s3c24xx/mach-rx3715.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-smdk2413.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-smdk2416.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-vr1000.c1
-rw-r--r--arch/arm/mach-s3c24xx/pm-s3c2410.c2
-rw-r--r--arch/arm/mach-s3c24xx/pm.c1
-rw-r--r--arch/arm/mach-s3c24xx/s3c2410.c1
-rw-r--r--arch/arm/mach-s3c24xx/s3c2416.c1
-rw-r--r--arch/arm/mach-s3c24xx/s3c2440.c1
-rw-r--r--arch/arm/mach-s3c24xx/s3c2442.c1
-rw-r--r--arch/arm/mach-s3c24xx/s3c2443.c1
-rw-r--r--arch/arm/mach-s3c24xx/setup-i2c.c1
-rw-r--r--arch/arm/mach-s3c24xx/setup-sdhci-gpio.c1
-rw-r--r--arch/arm/mach-s3c24xx/setup-ts.c2
-rw-r--r--arch/arm/mach-s3c24xx/simtec-usb.c1
-rw-r--r--arch/arm/mach-s3c64xx/Kconfig3
-rw-r--r--arch/arm/mach-s3c64xx/common.c1
-rw-r--r--arch/arm/mach-s3c64xx/crag6410.h2
-rw-r--r--arch/arm/mach-s3c64xx/dev-audio.c1
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/gpio-samsung.h (renamed from arch/arm/mach-s3c64xx/include/mach/gpio.h)9
-rw-r--r--arch/arm/mach-s3c64xx/mach-anw6410.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-crag6410.c2
-rw-r--r--arch/arm/mach-s3c64xx/mach-hmt.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-mini6410.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-real6410.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-smartq.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-smartq5.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-smartq7.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-smdk6400.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-smdk6410.c1
-rw-r--r--arch/arm/mach-s3c64xx/pm.c1
-rw-r--r--arch/arm/mach-s3c64xx/setup-fb-24bpp.c1
-rw-r--r--arch/arm/mach-s3c64xx/setup-i2c0.c1
-rw-r--r--arch/arm/mach-s3c64xx/setup-i2c1.c1
-rw-r--r--arch/arm/mach-s3c64xx/setup-ide.c1
-rw-r--r--arch/arm/mach-s3c64xx/setup-keypad.c1
-rw-r--r--arch/arm/mach-s3c64xx/setup-sdhci-gpio.c1
-rw-r--r--arch/arm/mach-s3c64xx/setup-spi.c1
-rw-r--r--arch/arm/mach-tegra/board-paz00.c11
-rw-r--r--arch/arm/plat-samsung/pm-gpio.c4
-rw-r--r--arch/arm/plat-samsung/setup-camif.c1
-rw-r--r--arch/xtensa/Kconfig6
-rw-r--r--drivers/gpio/Kconfig37
-rw-r--r--drivers/gpio/Makefile3
-rw-r--r--drivers/gpio/gpio-74x164.c59
-rw-r--r--drivers/gpio/gpio-adnp.c25
-rw-r--r--drivers/gpio/gpio-adp5520.c2
-rw-r--r--drivers/gpio/gpio-adp5588.c2
-rw-r--r--drivers/gpio/gpio-amd8111.c2
-rw-r--r--drivers/gpio/gpio-arizona.c2
-rw-r--r--drivers/gpio/gpio-bcm-kona.c22
-rw-r--r--drivers/gpio/gpio-bt8xx.c4
-rw-r--r--drivers/gpio/gpio-clps711x.c4
-rw-r--r--drivers/gpio/gpio-da9052.c2
-rw-r--r--drivers/gpio/gpio-da9055.c2
-rw-r--r--drivers/gpio/gpio-em.c28
-rw-r--r--drivers/gpio/gpio-f7188x.c1
-rw-r--r--drivers/gpio/gpio-ich.c2
-rw-r--r--drivers/gpio/gpio-intel-mid.c30
-rw-r--r--drivers/gpio/gpio-kempld.c2
-rw-r--r--drivers/gpio/gpio-ks8695.c2
-rw-r--r--drivers/gpio/gpio-lpc32xx.c14
-rw-r--r--drivers/gpio/gpio-lynxpoint.c39
-rw-r--r--drivers/gpio/gpio-max730x.c5
-rw-r--r--drivers/gpio/gpio-max732x.c2
-rw-r--r--drivers/gpio/gpio-mc33880.c2
-rw-r--r--drivers/gpio/gpio-mc9s08dz60.c2
-rw-r--r--drivers/gpio/gpio-mcp23s08.c252
-rw-r--r--drivers/gpio/gpio-ml-ioh.c4
-rw-r--r--drivers/gpio/gpio-moxart.c156
-rw-r--r--drivers/gpio/gpio-msic.c9
-rw-r--r--drivers/gpio/gpio-msm-v2.c3
-rw-r--r--drivers/gpio/gpio-mvebu.c4
-rw-r--r--drivers/gpio/gpio-mxc.c2
-rw-r--r--drivers/gpio/gpio-octeon.c2
-rw-r--r--drivers/gpio/gpio-omap.c188
-rw-r--r--drivers/gpio/gpio-palmas.c2
-rw-r--r--drivers/gpio/gpio-pca953x.c2
-rw-r--r--drivers/gpio/gpio-pcf857x.c2
-rw-r--r--drivers/gpio/gpio-pch.c4
-rw-r--r--drivers/gpio/gpio-pxa.c3
-rw-r--r--drivers/gpio/gpio-rc5t583.c2
-rw-r--r--drivers/gpio/gpio-rcar.c61
-rw-r--r--drivers/gpio/gpio-samsung.c11
-rw-r--r--drivers/gpio/gpio-sch311x.c432
-rw-r--r--drivers/gpio/gpio-sodaville.c10
-rw-r--r--drivers/gpio/gpio-sta2x11.c2
-rw-r--r--drivers/gpio/gpio-stmpe.c2
-rw-r--r--drivers/gpio/gpio-sx150x.c2
-rw-r--r--drivers/gpio/gpio-tb10x.c4
-rw-r--r--drivers/gpio/gpio-tc3589x.c2
-rw-r--r--drivers/gpio/gpio-tegra.c7
-rw-r--r--drivers/gpio/gpio-timberdale.c6
-rw-r--r--drivers/gpio/gpio-tnetv107x.c2
-rw-r--r--drivers/gpio/gpio-tps6586x.c2
-rw-r--r--drivers/gpio/gpio-tps65910.c2
-rw-r--r--drivers/gpio/gpio-tps65912.c2
-rw-r--r--drivers/gpio/gpio-twl4030.c2
-rw-r--r--drivers/gpio/gpio-twl6040.c2
-rw-r--r--drivers/gpio/gpio-ucb1400.c2
-rw-r--r--drivers/gpio/gpio-viperboard.c4
-rw-r--r--drivers/gpio/gpio-vx855.c2
-rw-r--r--drivers/gpio/gpio-wm831x.c2
-rw-r--r--drivers/gpio/gpio-wm8350.c2
-rw-r--r--drivers/gpio/gpio-wm8994.c2
-rw-r--r--drivers/gpio/gpio-xtensa.c163
-rw-r--r--drivers/gpio/gpiolib-acpi.c23
-rw-r--r--drivers/gpio/gpiolib.c251
-rw-r--r--drivers/gpio/gpiolib.h46
-rw-r--r--drivers/leds/leds-s3c24xx.c1
-rw-r--r--drivers/mmc/host/s3cmci.c2
-rw-r--r--drivers/mmc/host/sdhci-acpi.c29
-rw-r--r--drivers/pinctrl/pinctrl-as3722.c2
-rw-r--r--drivers/pinctrl/pinctrl-at91.c2
-rw-r--r--drivers/pinctrl/pinctrl-baytrail.c6
-rw-r--r--drivers/pinctrl/pinctrl-bcm2835.c2
-rw-r--r--drivers/pinctrl/pinctrl-nomadik.c2
-rw-r--r--drivers/pinctrl/pinctrl-sunxi.c2
-rw-r--r--drivers/pinctrl/vt8500/pinctrl-wmt.c2
-rw-r--r--include/linux/acpi_gpio.h51
-rw-r--r--include/linux/gpio.h1
-rw-r--r--include/linux/gpio/driver.h56
-rw-r--r--include/linux/platform_data/gpio-lpc32xx.h (renamed from arch/arm/mach-lpc32xx/include/mach/gpio-lpc32xx.h)0
-rw-r--r--include/linux/spi/74x164.h9
-rw-r--r--net/rfkill/rfkill-gpio.c77
155 files changed, 1859 insertions, 676 deletions
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt
index b994bcb32b92..2a1519b87177 100644
--- a/Documentation/acpi/enumeration.txt
+++ b/Documentation/acpi/enumeration.txt
@@ -293,36 +293,13 @@ the device to the driver. For example:
293 293
294These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" 294These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
295specifies the path to the controller. In order to use these GPIOs in Linux 295specifies the path to the controller. In order to use these GPIOs in Linux
296we need to translate them to the Linux GPIO numbers. 296we need to translate them to the corresponding Linux GPIO descriptors.
297 297
298In a simple case of just getting the Linux GPIO number from device 298There is a standard GPIO API for that and is documented in
299resources one can use acpi_get_gpio_by_index() helper function. It takes 299Documentation/gpio.txt.
300pointer to the device and index of the GpioIo/GpioInt descriptor in the
301device resources list. For example:
302 300
303 int gpio_irq, gpio_power; 301In the above example we can get the corresponding two GPIO descriptors with
304 int ret; 302a code like this:
305
306 gpio_irq = acpi_get_gpio_by_index(dev, 1, NULL);
307 if (gpio_irq < 0)
308 /* handle error */
309
310 gpio_power = acpi_get_gpio_by_index(dev, 0, NULL);
311 if (gpio_power < 0)
312 /* handle error */
313
314 /* Now we can use the GPIO numbers */
315
316Other GpioIo parameters must be converted first by the driver to be
317suitable to the gpiolib before passing them.
318
319In case of GpioInt resource an additional call to gpio_to_irq() must be
320done before calling request_irq().
321
322Note that the above API is ACPI specific and not recommended for drivers
323that need to support non-ACPI systems. The recommended way is to use
324the descriptor based GPIO interfaces. The above example looks like this
325when converted to the GPIO desc:
326 303
327 #include <linux/gpio/consumer.h> 304 #include <linux/gpio/consumer.h>
328 ... 305 ...
@@ -339,4 +316,5 @@ when converted to the GPIO desc:
339 316
340 /* Now we can use the GPIO descriptors */ 317 /* Now we can use the GPIO descriptors */
341 318
342See also Documentation/gpio.txt. 319There are also devm_* versions of these functions which release the
320descriptors once the device is released.
diff --git a/Documentation/arm/Samsung-S3C24XX/GPIO.txt b/Documentation/arm/Samsung-S3C24XX/GPIO.txt
index 8b46c79679c4..0ebd7e2244d0 100644
--- a/Documentation/arm/Samsung-S3C24XX/GPIO.txt
+++ b/Documentation/arm/Samsung-S3C24XX/GPIO.txt
@@ -85,21 +85,10 @@ between the calls.
85Headers 85Headers
86------- 86-------
87 87
88 See arch/arm/mach-s3c2410/include/mach/regs-gpio.h for the list 88 See arch/arm/mach-s3c24xx/include/mach/regs-gpio.h for the list
89 of GPIO pins, and the configuration values for them. This 89 of GPIO pins, and the configuration values for them. This
90 is included by using #include <mach/regs-gpio.h> 90 is included by using #include <mach/regs-gpio.h>
91 91
92 The GPIO management functions are defined in the hardware
93 header arch/arm/mach-s3c2410/include/mach/hardware.h which can be
94 included by #include <mach/hardware.h>
95
96 A useful amount of documentation can be found in the hardware
97 header on how the GPIO functions (and others) work.
98
99 Whilst a number of these functions do make some checks on what
100 is passed to them, for speed of use, they may not always ensure
101 that the user supplied data to them is correct.
102
103 92
104PIN Numbers 93PIN Numbers
105----------- 94-----------
diff --git a/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt b/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
index daa30174bcc1..3ddc7ccfe5f3 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
@@ -38,12 +38,38 @@ Required device specific properties (only for SPI chips):
38 removed. 38 removed.
39- spi-max-frequency = The maximum frequency this chip is able to handle 39- spi-max-frequency = The maximum frequency this chip is able to handle
40 40
41Example I2C: 41Optional properties:
42- #interrupt-cells : Should be two.
43 - first cell is the pin number
44 - second cell is used to specify flags.
45- interrupt-controller: Marks the device node as a interrupt controller.
46NOTE: The interrupt functionality is only supported for i2c versions of the
47chips. The spi chips can also do the interrupts, but this is not supported by
48the linux driver yet.
49
50Optional device specific properties:
51- microchip,irq-mirror: Sets the mirror flag in the IOCON register. Devices
52 with two interrupt outputs (these are the devices ending with 17 and
53 those that have 16 IOs) have two IO banks: IO 0-7 form bank 1 and
54 IO 8-15 are bank 2. These chips have two different interrupt outputs:
55 One for bank 1 and another for bank 2. If irq-mirror is set, both
56 interrupts are generated regardless of the bank that an input change
57 occured on. If it is not set, the interrupt are only generated for the
58 bank they belong to.
59 On devices with only one interrupt output this property is useless.
60
61Example I2C (with interrupt):
42gpiom1: gpio@20 { 62gpiom1: gpio@20 {
43 compatible = "microchip,mcp23017"; 63 compatible = "microchip,mcp23017";
44 gpio-controller; 64 gpio-controller;
45 #gpio-cells = <2>; 65 #gpio-cells = <2>;
46 reg = <0x20>; 66 reg = <0x20>;
67
68 interrupt-parent = <&gpio1>;
69 interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
70 interrupt-controller;
71 #interrupt-cells=<2>;
72 microchip,irq-mirror;
47}; 73};
48 74
49Example SPI: 75Example SPI:
diff --git a/Documentation/devicetree/bindings/gpio/moxa,moxart-gpio.txt b/Documentation/devicetree/bindings/gpio/moxa,moxart-gpio.txt
new file mode 100644
index 000000000000..f8e8f185a3db
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/moxa,moxart-gpio.txt
@@ -0,0 +1,19 @@
1MOXA ART GPIO Controller
2
3Required properties:
4
5- #gpio-cells : Should be 2, The first cell is the pin number,
6 the second cell is used to specify polarity:
7 0 = active high
8 1 = active low
9- compatible : Must be "moxa,moxart-gpio"
10- reg : Should contain registers location and length
11
12Example:
13
14 gpio: gpio@98700000 {
15 gpio-controller;
16 #gpio-cells = <2>;
17 compatible = "moxa,moxart-gpio";
18 reg = <0x98700000 0xC>;
19 };
diff --git a/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt b/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
index 8655df9440d5..f61cef74a212 100644
--- a/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
+++ b/Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
@@ -2,10 +2,11 @@
2 2
3Required Properties: 3Required Properties:
4 4
5 - compatible: should be one of the following. 5 - compatible: should contain one of the following.
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-rcar": for generic R-Car GPIO controller. 10 - "renesas,gpio-rcar": for generic R-Car GPIO controller.
10 11
11 - reg: Base address and length of each memory resource used by the GPIO 12 - reg: Base address and length of each memory resource used by the GPIO
diff --git a/Documentation/gpio/board.txt b/Documentation/gpio/board.txt
index 0d03506f2cc5..ba169faad5c6 100644
--- a/Documentation/gpio/board.txt
+++ b/Documentation/gpio/board.txt
@@ -72,10 +72,11 @@ where
72 72
73 - chip_label is the label of the gpiod_chip instance providing the GPIO 73 - chip_label is the label of the gpiod_chip instance providing the GPIO
74 - chip_hwnum is the hardware number of the GPIO within the chip 74 - chip_hwnum is the hardware number of the GPIO within the chip
75 - dev_id is the identifier of the device that will make use of this GPIO. If 75 - dev_id is the identifier of the device that will make use of this GPIO. It
76 NULL, the GPIO will be available to all devices. 76 can be NULL, in which case it will be matched for calls to gpiod_get()
77 with a NULL device.
77 - con_id is the name of the GPIO function from the device point of view. It 78 - con_id is the name of the GPIO function from the device point of view. It
78 can be NULL. 79 can be NULL, in which case it will match any function.
79 - idx is the index of the GPIO within the function. 80 - idx is the index of the GPIO within the function.
80 - flags is defined to specify the following properties: 81 - flags is defined to specify the following properties:
81 * GPIOF_ACTIVE_LOW - to configure the GPIO as active-low 82 * GPIOF_ACTIVE_LOW - to configure the GPIO as active-low
@@ -86,18 +87,23 @@ In the future, these flags might be extended to support more properties.
86 87
87Note that GPIO_LOOKUP() is just a shortcut to GPIO_LOOKUP_IDX() where idx = 0. 88Note that GPIO_LOOKUP() is just a shortcut to GPIO_LOOKUP_IDX() where idx = 0.
88 89
89A lookup table can then be defined as follows: 90A lookup table can then be defined as follows, with an empty entry defining its
91end:
90 92
91 struct gpiod_lookup gpios_table[] = { 93struct gpiod_lookup_table gpios_table = {
92 GPIO_LOOKUP_IDX("gpio.0", 15, "foo.0", "led", 0, GPIO_ACTIVE_HIGH), 94 .dev_id = "foo.0",
93 GPIO_LOOKUP_IDX("gpio.0", 16, "foo.0", "led", 1, GPIO_ACTIVE_HIGH), 95 .table = {
94 GPIO_LOOKUP_IDX("gpio.0", 17, "foo.0", "led", 2, GPIO_ACTIVE_HIGH), 96 GPIO_LOOKUP_IDX("gpio.0", 15, "led", 0, GPIO_ACTIVE_HIGH),
95 GPIO_LOOKUP("gpio.0", 1, "foo.0", "power", GPIO_ACTIVE_LOW), 97 GPIO_LOOKUP_IDX("gpio.0", 16, "led", 1, GPIO_ACTIVE_HIGH),
96 }; 98 GPIO_LOOKUP_IDX("gpio.0", 17, "led", 2, GPIO_ACTIVE_HIGH),
99 GPIO_LOOKUP("gpio.0", 1, "power", GPIO_ACTIVE_LOW),
100 { },
101 },
102};
97 103
98And the table can be added by the board code as follows: 104And the table can be added by the board code as follows:
99 105
100 gpiod_add_table(gpios_table, ARRAY_SIZE(gpios_table)); 106 gpiod_add_lookup_table(&gpios_table);
101 107
102The driver controlling "foo.0" will then be able to obtain its GPIOs as follows: 108The driver controlling "foo.0" will then be able to obtain its GPIOs as follows:
103 109
diff --git a/Documentation/gpio/consumer.txt b/Documentation/gpio/consumer.txt
index 07c74a3765a0..e42f77d8d4ca 100644
--- a/Documentation/gpio/consumer.txt
+++ b/Documentation/gpio/consumer.txt
@@ -38,7 +38,11 @@ device that displays digits), an additional index argument can be specified:
38 const char *con_id, unsigned int idx) 38 const char *con_id, unsigned int idx)
39 39
40Both functions return either a valid GPIO descriptor, or an error code checkable 40Both functions return either a valid GPIO descriptor, or an error code checkable
41with IS_ERR(). They will never return a NULL pointer. 41with IS_ERR() (they will never return a NULL pointer). -ENOENT will be returned
42if and only if no GPIO has been assigned to the device/function/index triplet,
43other error codes are used for cases where a GPIO has been assigned but an error
44occured while trying to acquire it. This is useful to discriminate between mere
45errors and an absence of GPIO for optional GPIO parameters.
42 46
43Device-managed variants of these functions are also defined: 47Device-managed variants of these functions are also defined:
44 48
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9c909fc29272..b9df6224609c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -711,7 +711,6 @@ config ARCH_S3C24XX
711 select HAVE_S3C2410_WATCHDOG if WATCHDOG 711 select HAVE_S3C2410_WATCHDOG if WATCHDOG
712 select HAVE_S3C_RTC if RTC_CLASS 712 select HAVE_S3C_RTC if RTC_CLASS
713 select MULTI_IRQ_HANDLER 713 select MULTI_IRQ_HANDLER
714 select NEED_MACH_GPIO_H
715 select NEED_MACH_IO_H 714 select NEED_MACH_IO_H
716 select SAMSUNG_ATAGS 715 select SAMSUNG_ATAGS
717 help 716 help
@@ -734,7 +733,6 @@ config ARCH_S3C64XX
734 select HAVE_S3C2410_I2C if I2C 733 select HAVE_S3C2410_I2C if I2C
735 select HAVE_S3C2410_WATCHDOG if WATCHDOG 734 select HAVE_S3C2410_WATCHDOG if WATCHDOG
736 select HAVE_TCM 735 select HAVE_TCM
737 select NEED_MACH_GPIO_H
738 select NO_IOPORT 736 select NO_IOPORT
739 select PLAT_SAMSUNG 737 select PLAT_SAMSUNG
740 select PM_GENERIC_DOMAINS 738 select PM_GENERIC_DOMAINS
@@ -1594,7 +1592,7 @@ config ARM_PSCI
1594config ARCH_NR_GPIO 1592config ARCH_NR_GPIO
1595 int 1593 int
1596 default 1024 if ARCH_SHMOBILE || ARCH_TEGRA 1594 default 1024 if ARCH_SHMOBILE || ARCH_TEGRA
1597 default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5 || SOC_DRA7XX 1595 default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5 || SOC_DRA7XX || ARCH_S3C24XX || ARCH_S3C64XX
1598 default 392 if ARCH_U8500 1596 default 392 if ARCH_U8500
1599 default 352 if ARCH_VT8500 1597 default 352 if ARCH_VT8500
1600 default 288 if ARCH_SUNXI 1598 default 288 if ARCH_SUNXI
diff --git a/arch/arm/mach-ks8695/include/mach/gpio.h b/arch/arm/mach-ks8695/include/mach/gpio.h
deleted file mode 100644
index f5fda36e4512..000000000000
--- a/arch/arm/mach-ks8695/include/mach/gpio.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * arch/arm/mach-ks8695/include/mach/gpio.h
3 *
4 * Copyright (C) 2006 Andrew Victor
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 version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_GPIO_H_
12#define __ASM_ARCH_GPIO_H_
13
14/*
15 * Map IRQ number to GPIO line.
16 */
17extern int irq_to_gpio(unsigned int irq);
18
19#endif
diff --git a/arch/arm/mach-lpc32xx/include/mach/gpio.h b/arch/arm/mach-lpc32xx/include/mach/gpio.h
deleted file mode 100644
index 0052e7a76179..000000000000
--- a/arch/arm/mach-lpc32xx/include/mach/gpio.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __MACH_GPIO_H
2#define __MACH_GPIO_H
3
4#include "gpio-lpc32xx.h"
5
6#endif /* __MACH_GPIO_H */
diff --git a/arch/arm/mach-lpc32xx/phy3250.c b/arch/arm/mach-lpc32xx/phy3250.c
index e54f87ec2e4a..34932e0e31fa 100644
--- a/arch/arm/mach-lpc32xx/phy3250.c
+++ b/arch/arm/mach-lpc32xx/phy3250.c
@@ -36,6 +36,7 @@
36#include <linux/clk.h> 36#include <linux/clk.h>
37#include <linux/mtd/lpc32xx_slc.h> 37#include <linux/mtd/lpc32xx_slc.h>
38#include <linux/mtd/lpc32xx_mlc.h> 38#include <linux/mtd/lpc32xx_mlc.h>
39#include <linux/platform_data/gpio-lpc32xx.h>
39 40
40#include <asm/setup.h> 41#include <asm/setup.h>
41#include <asm/mach-types.h> 42#include <asm/mach-types.h>
@@ -44,7 +45,6 @@
44#include <mach/hardware.h> 45#include <mach/hardware.h>
45#include <mach/platform.h> 46#include <mach/platform.h>
46#include <mach/board.h> 47#include <mach/board.h>
47#include <mach/gpio-lpc32xx.h>
48#include "common.h" 48#include "common.h"
49 49
50/* 50/*
diff --git a/arch/arm/mach-mv78xx0/include/mach/gpio.h b/arch/arm/mach-mv78xx0/include/mach/gpio.h
deleted file mode 100644
index 77e1b843e768..000000000000
--- a/arch/arm/mach-mv78xx0/include/mach/gpio.h
+++ /dev/null
@@ -1,9 +0,0 @@
1/*
2 * arch/asm-arm/mach-mv78xx0/include/mach/gpio.h
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9#include <plat/gpio.h>
diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig
index 8f1d327e0cd1..d876431d64c0 100644
--- a/arch/arm/mach-s3c24xx/Kconfig
+++ b/arch/arm/mach-s3c24xx/Kconfig
@@ -180,27 +180,6 @@ config CPU_LLSERIAL_S3C2440
180 Selected if there is an S3C2440 (or register compatible) serial 180 Selected if there is an S3C2440 (or register compatible) serial
181 low-level implementation needed 181 low-level implementation needed
182 182
183# gpio configurations
184
185config S3C24XX_GPIO_EXTRA
186 int
187 default 128 if S3C24XX_GPIO_EXTRA128
188 default 64 if S3C24XX_GPIO_EXTRA64
189 default 16 if ARCH_H1940
190 default 0
191
192config S3C24XX_GPIO_EXTRA64
193 bool
194 help
195 Add an extra 64 gpio numbers to the available GPIO pool. This is
196 available for boards that need extra gpios for external devices.
197
198config S3C24XX_GPIO_EXTRA128
199 bool
200 help
201 Add an extra 128 gpio numbers to the available GPIO pool. This is
202 available for boards that need extra gpios for external devices.
203
204config S3C24XX_PLL 183config S3C24XX_PLL
205 bool "Support CPUfreq changing of PLL frequency (EXPERIMENTAL)" 184 bool "Support CPUfreq changing of PLL frequency (EXPERIMENTAL)"
206 depends on ARM_S3C24XX_CPUFREQ 185 depends on ARM_S3C24XX_CPUFREQ
diff --git a/arch/arm/mach-s3c24xx/common-smdk.c b/arch/arm/mach-s3c24xx/common-smdk.c
index 404444dd3840..e9fbcc91c5c0 100644
--- a/arch/arm/mach-s3c24xx/common-smdk.c
+++ b/arch/arm/mach-s3c24xx/common-smdk.c
@@ -37,8 +37,8 @@
37#include <asm/irq.h> 37#include <asm/irq.h>
38 38
39#include <mach/regs-gpio.h> 39#include <mach/regs-gpio.h>
40#include <mach/gpio-samsung.h>
40#include <linux/platform_data/leds-s3c24xx.h> 41#include <linux/platform_data/leds-s3c24xx.h>
41
42#include <linux/platform_data/mtd-nand-s3c2410.h> 42#include <linux/platform_data/mtd-nand-s3c2410.h>
43 43
44#include <plat/gpio-cfg.h> 44#include <plat/gpio-cfg.h>
diff --git a/arch/arm/mach-s3c24xx/h1940-bluetooth.c b/arch/arm/mach-s3c24xx/h1940-bluetooth.c
index 5b98bfd1df43..b4d14b864367 100644
--- a/arch/arm/mach-s3c24xx/h1940-bluetooth.c
+++ b/arch/arm/mach-s3c24xx/h1940-bluetooth.c
@@ -19,8 +19,10 @@
19#include <linux/gpio.h> 19#include <linux/gpio.h>
20#include <linux/rfkill.h> 20#include <linux/rfkill.h>
21 21
22#include <plat/gpio-cfg.h>
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <mach/regs-gpio.h> 24#include <mach/regs-gpio.h>
25#include <mach/gpio-samsung.h>
24 26
25#include "h1940.h" 27#include "h1940.h"
26 28
diff --git a/arch/arm/mach-s3c24xx/include/mach/gpio.h b/arch/arm/mach-s3c24xx/include/mach/gpio-samsung.h
index 14591563ca70..528fcdc4f63e 100644
--- a/arch/arm/mach-s3c24xx/include/mach/gpio.h
+++ b/arch/arm/mach-s3c24xx/include/mach/gpio-samsung.h
@@ -14,16 +14,8 @@
14 * devices that need GPIO. 14 * devices that need GPIO.
15 */ 15 */
16 16
17#ifndef __MACH_GPIO_H 17#ifndef GPIO_SAMSUNG_S3C24XX_H
18#define __MACH_GPIO_H __FILE__ 18#define GPIO_SAMSUNG_S3C24XX_H
19
20#ifdef CONFIG_CPU_S3C244X
21#define ARCH_NR_GPIOS (32 * 9 + CONFIG_S3C24XX_GPIO_EXTRA)
22#elif defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2416)
23#define ARCH_NR_GPIOS (32 * 12 + CONFIG_S3C24XX_GPIO_EXTRA)
24#else
25#define ARCH_NR_GPIOS (256 + CONFIG_S3C24XX_GPIO_EXTRA)
26#endif
27 19
28/* 20/*
29 * GPIO sizes for various SoCs: 21 * GPIO sizes for various SoCs:
@@ -31,17 +23,17 @@
31 * 2410 2412 2440 2443 2416 23 * 2410 2412 2440 2443 2416
32 * 2442 24 * 2442
33 * ---- ---- ---- ---- ---- 25 * ---- ---- ---- ---- ----
34 * A 23 22 25 16 25 26 * A 23 22 25 16 27
35 * B 11 11 11 11 9 27 * B 11 11 11 11 11
36 * C 16 15 16 16 16 28 * C 16 16 16 16 16
37 * D 16 16 16 16 16 29 * D 16 16 16 16 16
38 * E 16 16 16 16 16 30 * E 16 16 16 16 16
39 * F 8 8 8 8 8 31 * F 8 8 8 8 8
40 * G 16 16 16 16 8 32 * G 16 16 16 16 8
41 * H 11 11 9 15 15 33 * H 11 11 11 15 15
42 * J -- -- 13 16 -- 34 * J -- -- 13 16 --
43 * K -- -- -- -- 16 35 * K -- -- -- -- 16
44 * L -- -- -- 15 7 36 * L -- -- -- 15 14
45 * M -- -- -- 2 2 37 * M -- -- -- 2 2
46 */ 38 */
47 39
@@ -101,8 +93,6 @@ enum s3c_gpio_number {
101#define S3C2410_GPL(_nr) (S3C2410_GPIO_L_START + (_nr)) 93#define S3C2410_GPL(_nr) (S3C2410_GPIO_L_START + (_nr))
102#define S3C2410_GPM(_nr) (S3C2410_GPIO_M_START + (_nr)) 94#define S3C2410_GPM(_nr) (S3C2410_GPIO_M_START + (_nr))
103 95
104#include <plat/gpio-cfg.h>
105
106#ifdef CONFIG_CPU_S3C244X 96#ifdef CONFIG_CPU_S3C244X
107#define S3C_GPIO_END (S3C2410_GPJ(0) + 32) 97#define S3C_GPIO_END (S3C2410_GPJ(0) + 32)
108#elif defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2416) 98#elif defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2416)
@@ -111,4 +101,4 @@ enum s3c_gpio_number {
111#define S3C_GPIO_END (S3C2410_GPH(0) + 32) 101#define S3C_GPIO_END (S3C2410_GPH(0) + 32)
112#endif 102#endif
113 103
114#endif /* __MACH_GPIO_H */ 104#endif /* GPIO_SAMSUNG_S3C24XX_H */
diff --git a/arch/arm/mach-s3c24xx/mach-amlm5900.c b/arch/arm/mach-s3c24xx/mach-amlm5900.c
index e27b5c91b3db..284ea1f44205 100644
--- a/arch/arm/mach-s3c24xx/mach-amlm5900.c
+++ b/arch/arm/mach-s3c24xx/mach-amlm5900.c
@@ -52,6 +52,7 @@
52#include <plat/regs-serial.h> 52#include <plat/regs-serial.h>
53#include <mach/regs-lcd.h> 53#include <mach/regs-lcd.h>
54#include <mach/regs-gpio.h> 54#include <mach/regs-gpio.h>
55#include <mach/gpio-samsung.h>
55 56
56#include <linux/platform_data/i2c-s3c2410.h> 57#include <linux/platform_data/i2c-s3c2410.h>
57#include <plat/devs.h> 58#include <plat/devs.h>
diff --git a/arch/arm/mach-s3c24xx/mach-anubis.c b/arch/arm/mach-s3c24xx/mach-anubis.c
index c1fb6c37867f..2a16f8fb3584 100644
--- a/arch/arm/mach-s3c24xx/mach-anubis.c
+++ b/arch/arm/mach-s3c24xx/mach-anubis.c
@@ -35,6 +35,7 @@
35#include <plat/regs-serial.h> 35#include <plat/regs-serial.h>
36#include <mach/regs-gpio.h> 36#include <mach/regs-gpio.h>
37#include <mach/regs-lcd.h> 37#include <mach/regs-lcd.h>
38#include <mach/gpio-samsung.h>
38#include <linux/platform_data/mtd-nand-s3c2410.h> 39#include <linux/platform_data/mtd-nand-s3c2410.h>
39#include <linux/platform_data/i2c-s3c2410.h> 40#include <linux/platform_data/i2c-s3c2410.h>
40 41
diff --git a/arch/arm/mach-s3c24xx/mach-at2440evb.c b/arch/arm/mach-s3c24xx/mach-at2440evb.c
index 6dfeeb7ef469..6beab674c147 100644
--- a/arch/arm/mach-s3c24xx/mach-at2440evb.c
+++ b/arch/arm/mach-s3c24xx/mach-at2440evb.c
@@ -36,6 +36,7 @@
36#include <plat/regs-serial.h> 36#include <plat/regs-serial.h>
37#include <mach/regs-gpio.h> 37#include <mach/regs-gpio.h>
38#include <mach/regs-lcd.h> 38#include <mach/regs-lcd.h>
39#include <mach/gpio-samsung.h>
39#include <linux/platform_data/mtd-nand-s3c2410.h> 40#include <linux/platform_data/mtd-nand-s3c2410.h>
40#include <linux/platform_data/i2c-s3c2410.h> 41#include <linux/platform_data/i2c-s3c2410.h>
41 42
diff --git a/arch/arm/mach-s3c24xx/mach-bast.c b/arch/arm/mach-s3c24xx/mach-bast.c
index 22d6ae926d91..981ba1eb9fdc 100644
--- a/arch/arm/mach-s3c24xx/mach-bast.c
+++ b/arch/arm/mach-s3c24xx/mach-bast.c
@@ -48,6 +48,7 @@
48#include <mach/hardware.h> 48#include <mach/hardware.h>
49#include <mach/regs-gpio.h> 49#include <mach/regs-gpio.h>
50#include <mach/regs-lcd.h> 50#include <mach/regs-lcd.h>
51#include <mach/gpio-samsung.h>
51 52
52#include <plat/clock.h> 53#include <plat/clock.h>
53#include <plat/cpu.h> 54#include <plat/cpu.h>
diff --git a/arch/arm/mach-s3c24xx/mach-gta02.c b/arch/arm/mach-s3c24xx/mach-gta02.c
index 13d8d073675a..d9170e9f8ccd 100644
--- a/arch/arm/mach-s3c24xx/mach-gta02.c
+++ b/arch/arm/mach-s3c24xx/mach-gta02.c
@@ -75,6 +75,7 @@
75#include <mach/hardware.h> 75#include <mach/hardware.h>
76#include <mach/regs-gpio.h> 76#include <mach/regs-gpio.h>
77#include <mach/regs-irq.h> 77#include <mach/regs-irq.h>
78#include <mach/gpio-samsung.h>
78 79
79#include <plat/cpu.h> 80#include <plat/cpu.h>
80#include <plat/devs.h> 81#include <plat/devs.h>
diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-s3c24xx/mach-h1940.c
index 952b6a040d1f..de0832181d8c 100644
--- a/arch/arm/mach-s3c24xx/mach-h1940.c
+++ b/arch/arm/mach-s3c24xx/mach-h1940.c
@@ -54,6 +54,7 @@
54#include <mach/regs-clock.h> 54#include <mach/regs-clock.h>
55#include <mach/regs-gpio.h> 55#include <mach/regs-gpio.h>
56#include <mach/regs-lcd.h> 56#include <mach/regs-lcd.h>
57#include <mach/gpio-samsung.h>
57 58
58#include <plat/clock.h> 59#include <plat/clock.h>
59#include <plat/cpu.h> 60#include <plat/cpu.h>
diff --git a/arch/arm/mach-s3c24xx/mach-jive.c b/arch/arm/mach-s3c24xx/mach-jive.c
index 43c23e220f5b..67cb8e948b7e 100644
--- a/arch/arm/mach-s3c24xx/mach-jive.c
+++ b/arch/arm/mach-s3c24xx/mach-jive.c
@@ -38,6 +38,7 @@
38#include <mach/regs-gpio.h> 38#include <mach/regs-gpio.h>
39#include <mach/regs-lcd.h> 39#include <mach/regs-lcd.h>
40#include <mach/fb.h> 40#include <mach/fb.h>
41#include <mach/gpio-samsung.h>
41 42
42#include <asm/mach-types.h> 43#include <asm/mach-types.h>
43 44
diff --git a/arch/arm/mach-s3c24xx/mach-mini2440.c b/arch/arm/mach-s3c24xx/mach-mini2440.c
index 4a18d49a63e0..1f1559713d8b 100644
--- a/arch/arm/mach-s3c24xx/mach-mini2440.c
+++ b/arch/arm/mach-s3c24xx/mach-mini2440.c
@@ -42,6 +42,7 @@
42#include <linux/platform_data/leds-s3c24xx.h> 42#include <linux/platform_data/leds-s3c24xx.h>
43#include <mach/regs-lcd.h> 43#include <mach/regs-lcd.h>
44#include <mach/irqs.h> 44#include <mach/irqs.h>
45#include <mach/gpio-samsung.h>
45#include <linux/platform_data/mtd-nand-s3c2410.h> 46#include <linux/platform_data/mtd-nand-s3c2410.h>
46#include <linux/platform_data/i2c-s3c2410.h> 47#include <linux/platform_data/i2c-s3c2410.h>
47#include <linux/platform_data/mmc-s3cmci.h> 48#include <linux/platform_data/mmc-s3cmci.h>
diff --git a/arch/arm/mach-s3c24xx/mach-n30.c b/arch/arm/mach-s3c24xx/mach-n30.c
index 2cb46c37c920..997684f17930 100644
--- a/arch/arm/mach-s3c24xx/mach-n30.c
+++ b/arch/arm/mach-s3c24xx/mach-n30.c
@@ -36,6 +36,7 @@
36#include <linux/platform_data/leds-s3c24xx.h> 36#include <linux/platform_data/leds-s3c24xx.h>
37#include <mach/regs-gpio.h> 37#include <mach/regs-gpio.h>
38#include <mach/regs-lcd.h> 38#include <mach/regs-lcd.h>
39#include <mach/gpio-samsung.h>
39 40
40#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
41#include <asm/mach/irq.h> 42#include <asm/mach/irq.h>
diff --git a/arch/arm/mach-s3c24xx/mach-nexcoder.c b/arch/arm/mach-s3c24xx/mach-nexcoder.c
index 01f4354206f9..575d28c9e6c6 100644
--- a/arch/arm/mach-s3c24xx/mach-nexcoder.c
+++ b/arch/arm/mach-s3c24xx/mach-nexcoder.c
@@ -37,6 +37,7 @@
37 37
38//#include <asm/debug-ll.h> 38//#include <asm/debug-ll.h>
39#include <mach/regs-gpio.h> 39#include <mach/regs-gpio.h>
40#include <mach/gpio-samsung.h>
40#include <plat/regs-serial.h> 41#include <plat/regs-serial.h>
41#include <linux/platform_data/i2c-s3c2410.h> 42#include <linux/platform_data/i2c-s3c2410.h>
42 43
diff --git a/arch/arm/mach-s3c24xx/mach-osiris-dvs.c b/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
index 45e74363aaa9..33afb9190091 100644
--- a/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
+++ b/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
@@ -20,6 +20,7 @@
20#include <linux/i2c/tps65010.h> 20#include <linux/i2c/tps65010.h>
21 21
22#include <plat/cpu-freq.h> 22#include <plat/cpu-freq.h>
23#include <mach/gpio-samsung.h>
23 24
24#define OSIRIS_GPIO_DVS S3C2410_GPB(5) 25#define OSIRIS_GPIO_DVS S3C2410_GPB(5)
25 26
diff --git a/arch/arm/mach-s3c24xx/mach-osiris.c b/arch/arm/mach-s3c24xx/mach-osiris.c
index 58d6fbe5bf1f..f84f2a4c0c6d 100644
--- a/arch/arm/mach-s3c24xx/mach-osiris.c
+++ b/arch/arm/mach-s3c24xx/mach-osiris.c
@@ -50,6 +50,7 @@
50#include <mach/hardware.h> 50#include <mach/hardware.h>
51#include <mach/regs-gpio.h> 51#include <mach/regs-gpio.h>
52#include <mach/regs-lcd.h> 52#include <mach/regs-lcd.h>
53#include <mach/gpio-samsung.h>
53 54
54#include "common.h" 55#include "common.h"
55#include "osiris.h" 56#include "osiris.h"
diff --git a/arch/arm/mach-s3c24xx/mach-qt2410.c b/arch/arm/mach-s3c24xx/mach-qt2410.c
index f8feaeadb55a..b534b76812e3 100644
--- a/arch/arm/mach-s3c24xx/mach-qt2410.c
+++ b/arch/arm/mach-s3c24xx/mach-qt2410.c
@@ -54,6 +54,7 @@
54#include <linux/platform_data/mtd-nand-s3c2410.h> 54#include <linux/platform_data/mtd-nand-s3c2410.h>
55#include <linux/platform_data/usb-s3c2410_udc.h> 55#include <linux/platform_data/usb-s3c2410_udc.h>
56#include <linux/platform_data/i2c-s3c2410.h> 56#include <linux/platform_data/i2c-s3c2410.h>
57#include <mach/gpio-samsung.h>
57 58
58#include <plat/gpio-cfg.h> 59#include <plat/gpio-cfg.h>
59#include <plat/devs.h> 60#include <plat/devs.h>
diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
index 034b7fe45c49..0a5456cda1bc 100644
--- a/arch/arm/mach-s3c24xx/mach-rx1950.c
+++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
@@ -51,6 +51,7 @@
51#include <mach/fb.h> 51#include <mach/fb.h>
52#include <mach/regs-gpio.h> 52#include <mach/regs-gpio.h>
53#include <mach/regs-lcd.h> 53#include <mach/regs-lcd.h>
54#include <mach/gpio-samsung.h>
54 55
55#include <plat/clock.h> 56#include <plat/clock.h>
56#include <plat/cpu.h> 57#include <plat/cpu.h>
@@ -58,6 +59,7 @@
58#include <plat/pm.h> 59#include <plat/pm.h>
59#include <plat/regs-serial.h> 60#include <plat/regs-serial.h>
60#include <plat/samsung-time.h> 61#include <plat/samsung-time.h>
62#include <plat/gpio-cfg.h>
61 63
62#include "common.h" 64#include "common.h"
63#include "h1940.h" 65#include "h1940.h"
diff --git a/arch/arm/mach-s3c24xx/mach-rx3715.c b/arch/arm/mach-s3c24xx/mach-rx3715.c
index 3bc6231d0a1f..b36edce8b2b8 100644
--- a/arch/arm/mach-s3c24xx/mach-rx3715.c
+++ b/arch/arm/mach-s3c24xx/mach-rx3715.c
@@ -43,6 +43,7 @@
43#include <mach/hardware.h> 43#include <mach/hardware.h>
44#include <mach/regs-gpio.h> 44#include <mach/regs-gpio.h>
45#include <mach/regs-lcd.h> 45#include <mach/regs-lcd.h>
46#include <mach/gpio-samsung.h>
46 47
47#include <plat/clock.h> 48#include <plat/clock.h>
48#include <plat/cpu.h> 49#include <plat/cpu.h>
diff --git a/arch/arm/mach-s3c24xx/mach-smdk2413.c b/arch/arm/mach-s3c24xx/mach-smdk2413.c
index c9d31ef28dd1..f5bc721217e3 100644
--- a/arch/arm/mach-s3c24xx/mach-smdk2413.c
+++ b/arch/arm/mach-s3c24xx/mach-smdk2413.c
@@ -39,6 +39,7 @@
39 39
40#include <linux/platform_data/usb-s3c2410_udc.h> 40#include <linux/platform_data/usb-s3c2410_udc.h>
41#include <linux/platform_data/i2c-s3c2410.h> 41#include <linux/platform_data/i2c-s3c2410.h>
42#include <mach/gpio-samsung.h>
42#include <mach/fb.h> 43#include <mach/fb.h>
43 44
44#include <plat/clock.h> 45#include <plat/clock.h>
diff --git a/arch/arm/mach-s3c24xx/mach-smdk2416.c b/arch/arm/mach-s3c24xx/mach-smdk2416.c
index f88e672ad1e4..12023cae4378 100644
--- a/arch/arm/mach-s3c24xx/mach-smdk2416.c
+++ b/arch/arm/mach-s3c24xx/mach-smdk2416.c
@@ -38,6 +38,7 @@
38#include <mach/regs-gpio.h> 38#include <mach/regs-gpio.h>
39#include <mach/regs-lcd.h> 39#include <mach/regs-lcd.h>
40#include <mach/regs-s3c2443-clock.h> 40#include <mach/regs-s3c2443-clock.h>
41#include <mach/gpio-samsung.h>
41 42
42#include <linux/platform_data/leds-s3c24xx.h> 43#include <linux/platform_data/leds-s3c24xx.h>
43#include <linux/platform_data/i2c-s3c2410.h> 44#include <linux/platform_data/i2c-s3c2410.h>
diff --git a/arch/arm/mach-s3c24xx/mach-vr1000.c b/arch/arm/mach-s3c24xx/mach-vr1000.c
index 42e7187fed60..755df489a45f 100644
--- a/arch/arm/mach-s3c24xx/mach-vr1000.c
+++ b/arch/arm/mach-s3c24xx/mach-vr1000.c
@@ -40,6 +40,7 @@
40 40
41#include <mach/hardware.h> 41#include <mach/hardware.h>
42#include <mach/regs-gpio.h> 42#include <mach/regs-gpio.h>
43#include <mach/gpio-samsung.h>
43 44
44#include <plat/clock.h> 45#include <plat/clock.h>
45#include <plat/cpu.h> 46#include <plat/cpu.h>
diff --git a/arch/arm/mach-s3c24xx/pm-s3c2410.c b/arch/arm/mach-s3c24xx/pm-s3c2410.c
index 2d82c4f116cd..20e481d8a33a 100644
--- a/arch/arm/mach-s3c24xx/pm-s3c2410.c
+++ b/arch/arm/mach-s3c24xx/pm-s3c2410.c
@@ -33,7 +33,9 @@
33 33
34#include <mach/hardware.h> 34#include <mach/hardware.h>
35#include <mach/regs-gpio.h> 35#include <mach/regs-gpio.h>
36#include <mach/gpio-samsung.h>
36 37
38#include <plat/gpio-cfg.h>
37#include <plat/cpu.h> 39#include <plat/cpu.h>
38#include <plat/pm.h> 40#include <plat/pm.h>
39 41
diff --git a/arch/arm/mach-s3c24xx/pm.c b/arch/arm/mach-s3c24xx/pm.c
index caa5b7211380..052ca23393a7 100644
--- a/arch/arm/mach-s3c24xx/pm.c
+++ b/arch/arm/mach-s3c24xx/pm.c
@@ -39,6 +39,7 @@
39#include <mach/regs-clock.h> 39#include <mach/regs-clock.h>
40#include <mach/regs-gpio.h> 40#include <mach/regs-gpio.h>
41#include <mach/regs-irq.h> 41#include <mach/regs-irq.h>
42#include <mach/gpio-samsung.h>
42 43
43#include <asm/mach/time.h> 44#include <asm/mach/time.h>
44 45
diff --git a/arch/arm/mach-s3c24xx/s3c2410.c b/arch/arm/mach-s3c24xx/s3c2410.c
index 34676d1d5fec..ffb92cbca08c 100644
--- a/arch/arm/mach-s3c24xx/s3c2410.c
+++ b/arch/arm/mach-s3c24xx/s3c2410.c
@@ -30,6 +30,7 @@
30#include <asm/mach/irq.h> 30#include <asm/mach/irq.h>
31 31
32#include <mach/hardware.h> 32#include <mach/hardware.h>
33#include <mach/gpio-samsung.h>
33#include <asm/irq.h> 34#include <asm/irq.h>
34#include <asm/system_misc.h> 35#include <asm/system_misc.h>
35 36
diff --git a/arch/arm/mach-s3c24xx/s3c2416.c b/arch/arm/mach-s3c24xx/s3c2416.c
index 9ef3ccfbe196..8e01b4f2df35 100644
--- a/arch/arm/mach-s3c24xx/s3c2416.c
+++ b/arch/arm/mach-s3c24xx/s3c2416.c
@@ -42,6 +42,7 @@
42#include <asm/mach/irq.h> 42#include <asm/mach/irq.h>
43 43
44#include <mach/hardware.h> 44#include <mach/hardware.h>
45#include <mach/gpio-samsung.h>
45#include <asm/proc-fns.h> 46#include <asm/proc-fns.h>
46#include <asm/irq.h> 47#include <asm/irq.h>
47#include <asm/system_misc.h> 48#include <asm/system_misc.h>
diff --git a/arch/arm/mach-s3c24xx/s3c2440.c b/arch/arm/mach-s3c24xx/s3c2440.c
index 5f9d6569475d..03d379f1fc52 100644
--- a/arch/arm/mach-s3c24xx/s3c2440.c
+++ b/arch/arm/mach-s3c24xx/s3c2440.c
@@ -29,6 +29,7 @@
29#include <asm/mach/irq.h> 29#include <asm/mach/irq.h>
30 30
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/gpio-samsung.h>
32#include <asm/irq.h> 33#include <asm/irq.h>
33 34
34#include <plat/devs.h> 35#include <plat/devs.h>
diff --git a/arch/arm/mach-s3c24xx/s3c2442.c b/arch/arm/mach-s3c24xx/s3c2442.c
index 6819961f6b19..2c8adc028538 100644
--- a/arch/arm/mach-s3c24xx/s3c2442.c
+++ b/arch/arm/mach-s3c24xx/s3c2442.c
@@ -37,6 +37,7 @@
37#include <linux/io.h> 37#include <linux/io.h>
38 38
39#include <mach/hardware.h> 39#include <mach/hardware.h>
40#include <mach/gpio-samsung.h>
40#include <linux/atomic.h> 41#include <linux/atomic.h>
41#include <asm/irq.h> 42#include <asm/irq.h>
42 43
diff --git a/arch/arm/mach-s3c24xx/s3c2443.c b/arch/arm/mach-s3c24xx/s3c2443.c
index b6c71918b25c..886c2147062b 100644
--- a/arch/arm/mach-s3c24xx/s3c2443.c
+++ b/arch/arm/mach-s3c24xx/s3c2443.c
@@ -29,6 +29,7 @@
29#include <asm/mach/irq.h> 29#include <asm/mach/irq.h>
30 30
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/gpio-samsung.h>
32#include <asm/irq.h> 33#include <asm/irq.h>
33#include <asm/system_misc.h> 34#include <asm/system_misc.h>
34 35
diff --git a/arch/arm/mach-s3c24xx/setup-i2c.c b/arch/arm/mach-s3c24xx/setup-i2c.c
index 7b4f33332d19..1852696ca16e 100644
--- a/arch/arm/mach-s3c24xx/setup-i2c.c
+++ b/arch/arm/mach-s3c24xx/setup-i2c.c
@@ -19,6 +19,7 @@ struct platform_device;
19#include <linux/platform_data/i2c-s3c2410.h> 19#include <linux/platform_data/i2c-s3c2410.h>
20#include <mach/hardware.h> 20#include <mach/hardware.h>
21#include <mach/regs-gpio.h> 21#include <mach/regs-gpio.h>
22#include <mach/gpio-samsung.h>
22 23
23void s3c_i2c0_cfg_gpio(struct platform_device *dev) 24void s3c_i2c0_cfg_gpio(struct platform_device *dev)
24{ 25{
diff --git a/arch/arm/mach-s3c24xx/setup-sdhci-gpio.c b/arch/arm/mach-s3c24xx/setup-sdhci-gpio.c
index f65cb3ef16ce..c99b0f664db7 100644
--- a/arch/arm/mach-s3c24xx/setup-sdhci-gpio.c
+++ b/arch/arm/mach-s3c24xx/setup-sdhci-gpio.c
@@ -20,6 +20,7 @@
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21 21
22#include <mach/regs-gpio.h> 22#include <mach/regs-gpio.h>
23#include <mach/gpio-samsung.h>
23#include <plat/gpio-cfg.h> 24#include <plat/gpio-cfg.h>
24 25
25void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) 26void s3c2416_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
diff --git a/arch/arm/mach-s3c24xx/setup-ts.c b/arch/arm/mach-s3c24xx/setup-ts.c
index 4e11affce3a8..46466d20257e 100644
--- a/arch/arm/mach-s3c24xx/setup-ts.c
+++ b/arch/arm/mach-s3c24xx/setup-ts.c
@@ -15,7 +15,9 @@
15 15
16struct platform_device; /* don't need the contents */ 16struct platform_device; /* don't need the contents */
17 17
18#include <plat/gpio-cfg.h>
18#include <mach/hardware.h> 19#include <mach/hardware.h>
20#include <mach/gpio-samsung.h>
19 21
20/** 22/**
21 * s3c24xx_ts_cfg_gpio - configure gpio for s3c2410 systems 23 * s3c24xx_ts_cfg_gpio - configure gpio for s3c2410 systems
diff --git a/arch/arm/mach-s3c24xx/simtec-usb.c b/arch/arm/mach-s3c24xx/simtec-usb.c
index 2ed2e32430dc..8dea917e954b 100644
--- a/arch/arm/mach-s3c24xx/simtec-usb.c
+++ b/arch/arm/mach-s3c24xx/simtec-usb.c
@@ -29,6 +29,7 @@
29#include <asm/mach/irq.h> 29#include <asm/mach/irq.h>
30 30
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/gpio-samsung.h>
32#include <asm/irq.h> 33#include <asm/irq.h>
33 34
34#include <linux/platform_data/usb-ohci-s3c2410.h> 35#include <linux/platform_data/usb-ohci-s3c2410.h>
diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig
index 2cb8dc55b50e..175f01501129 100644
--- a/arch/arm/mach-s3c64xx/Kconfig
+++ b/arch/arm/mach-s3c64xx/Kconfig
@@ -192,7 +192,6 @@ config SMDK6410_WM1190_EV1
192 select MFD_WM8350_I2C 192 select MFD_WM8350_I2C
193 select REGULATOR 193 select REGULATOR
194 select REGULATOR_WM8350 194 select REGULATOR_WM8350
195 select SAMSUNG_GPIO_EXTRA64
196 help 195 help
197 The Wolfson Microelectronics 1190-EV1 is a WM835x based PMIC 196 The Wolfson Microelectronics 1190-EV1 is a WM835x based PMIC
198 and audio daughtercard for the Samsung SMDK6410 reference 197 and audio daughtercard for the Samsung SMDK6410 reference
@@ -208,7 +207,6 @@ config SMDK6410_WM1192_EV1
208 select MFD_WM831X_I2C 207 select MFD_WM831X_I2C
209 select REGULATOR 208 select REGULATOR
210 select REGULATOR_WM831X 209 select REGULATOR_WM831X
211 select SAMSUNG_GPIO_EXTRA64
212 help 210 help
213 The Wolfson Microelectronics 1192-EV1 is a WM831x based PMIC 211 The Wolfson Microelectronics 1192-EV1 is a WM831x based PMIC
214 daughtercard for the Samsung SMDK6410 reference platform. 212 daughtercard for the Samsung SMDK6410 reference platform.
@@ -294,7 +292,6 @@ config MACH_WLF_CRAGG_6410
294 select SAMSUNG_DEV_ADC 292 select SAMSUNG_DEV_ADC
295 select SAMSUNG_DEV_KEYPAD 293 select SAMSUNG_DEV_KEYPAD
296 select SAMSUNG_DEV_PWM 294 select SAMSUNG_DEV_PWM
297 select SAMSUNG_GPIO_EXTRA128
298 help 295 help
299 Machine support for the Wolfson Cragganmore S3C6410 variant. 296 Machine support for the Wolfson Cragganmore S3C6410 variant.
300 297
diff --git a/arch/arm/mach-s3c64xx/common.c b/arch/arm/mach-s3c64xx/common.c
index 7a3ce4c39e5f..76ab595d849b 100644
--- a/arch/arm/mach-s3c64xx/common.c
+++ b/arch/arm/mach-s3c64xx/common.c
@@ -41,6 +41,7 @@
41#include <mach/map.h> 41#include <mach/map.h>
42#include <mach/hardware.h> 42#include <mach/hardware.h>
43#include <mach/regs-gpio.h> 43#include <mach/regs-gpio.h>
44#include <mach/gpio-samsung.h>
44 45
45#include <plat/cpu.h> 46#include <plat/cpu.h>
46#include <plat/devs.h> 47#include <plat/devs.h>
diff --git a/arch/arm/mach-s3c64xx/crag6410.h b/arch/arm/mach-s3c64xx/crag6410.h
index 4c3c9994fc2c..7bc66682687e 100644
--- a/arch/arm/mach-s3c64xx/crag6410.h
+++ b/arch/arm/mach-s3c64xx/crag6410.h
@@ -11,7 +11,7 @@
11#ifndef MACH_CRAG6410_H 11#ifndef MACH_CRAG6410_H
12#define MACH_CRAG6410_H 12#define MACH_CRAG6410_H
13 13
14#include <linux/gpio.h> 14#include <mach/gpio-samsung.h>
15 15
16#define GLENFARCLAS_PMIC_IRQ_BASE IRQ_BOARD_START 16#define GLENFARCLAS_PMIC_IRQ_BASE IRQ_BOARD_START
17 17
diff --git a/arch/arm/mach-s3c64xx/dev-audio.c b/arch/arm/mach-s3c64xx/dev-audio.c
index e367e87bbc29..ff780a8d8366 100644
--- a/arch/arm/mach-s3c64xx/dev-audio.c
+++ b/arch/arm/mach-s3c64xx/dev-audio.c
@@ -22,6 +22,7 @@
22#include <plat/devs.h> 22#include <plat/devs.h>
23#include <linux/platform_data/asoc-s3c.h> 23#include <linux/platform_data/asoc-s3c.h>
24#include <plat/gpio-cfg.h> 24#include <plat/gpio-cfg.h>
25#include <mach/gpio-samsung.h>
25 26
26static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev) 27static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev)
27{ 28{
diff --git a/arch/arm/mach-s3c64xx/include/mach/gpio.h b/arch/arm/mach-s3c64xx/include/mach/gpio-samsung.h
index 8b540c42d5dd..9c81fac3b2d5 100644
--- a/arch/arm/mach-s3c64xx/include/mach/gpio.h
+++ b/arch/arm/mach-s3c64xx/include/mach/gpio-samsung.h
@@ -1,5 +1,4 @@
1/* arch/arm/mach-s3c6400/include/mach/gpio.h 1/*
2 *
3 * Copyright 2008 Openmoko, Inc. 2 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics 3 * Copyright 2008 Simtec Electronics
5 * http://armlinux.simtec.co.uk/ 4 * http://armlinux.simtec.co.uk/
@@ -12,6 +11,9 @@
12 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
13*/ 12*/
14 13
14#ifndef GPIO_SAMSUNG_S3C64XX_H
15#define GPIO_SAMSUNG_S3C64XX_H
16
15/* GPIO bank sizes */ 17/* GPIO bank sizes */
16#define S3C64XX_GPIO_A_NR (8) 18#define S3C64XX_GPIO_A_NR (8)
17#define S3C64XX_GPIO_B_NR (7) 19#define S3C64XX_GPIO_B_NR (7)
@@ -88,6 +90,5 @@ enum s3c_gpio_number {
88/* define the number of gpios we need to the one after the GPQ() range */ 90/* define the number of gpios we need to the one after the GPQ() range */
89#define GPIO_BOARD_START (S3C64XX_GPQ(S3C64XX_GPIO_Q_NR) + 1) 91#define GPIO_BOARD_START (S3C64XX_GPQ(S3C64XX_GPIO_Q_NR) + 1)
90 92
91#define BOARD_NR_GPIOS (16 + CONFIG_SAMSUNG_GPIO_EXTRA) 93#endif /* GPIO_SAMSUNG_S3C64XX_H */
92 94
93#define ARCH_NR_GPIOS (GPIO_BOARD_START + BOARD_NR_GPIOS)
diff --git a/arch/arm/mach-s3c64xx/mach-anw6410.c b/arch/arm/mach-s3c64xx/mach-anw6410.c
index d266dd5f7060..ddeb0e51a962 100644
--- a/arch/arm/mach-s3c64xx/mach-anw6410.c
+++ b/arch/arm/mach-s3c64xx/mach-anw6410.c
@@ -49,6 +49,7 @@
49#include <plat/devs.h> 49#include <plat/devs.h>
50#include <plat/cpu.h> 50#include <plat/cpu.h>
51#include <mach/regs-gpio.h> 51#include <mach/regs-gpio.h>
52#include <mach/gpio-samsung.h>
52#include <plat/samsung-time.h> 53#include <plat/samsung-time.h>
53 54
54#include "common.h" 55#include "common.h"
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 758e31b26550..3df3c372ee1f 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -48,8 +48,8 @@
48#include <video/samsung_fimd.h> 48#include <video/samsung_fimd.h>
49#include <mach/hardware.h> 49#include <mach/hardware.h>
50#include <mach/map.h> 50#include <mach/map.h>
51
52#include <mach/regs-gpio.h> 51#include <mach/regs-gpio.h>
52#include <mach/gpio-samsung.h>
53 53
54#include <plat/regs-serial.h> 54#include <plat/regs-serial.h>
55#include <plat/fb.h> 55#include <plat/fb.h>
diff --git a/arch/arm/mach-s3c64xx/mach-hmt.c b/arch/arm/mach-s3c64xx/mach-hmt.c
index 614a03a92cf7..0431016925b9 100644
--- a/arch/arm/mach-s3c64xx/mach-hmt.c
+++ b/arch/arm/mach-s3c64xx/mach-hmt.c
@@ -35,6 +35,7 @@
35 35
36#include <plat/regs-serial.h> 36#include <plat/regs-serial.h>
37#include <linux/platform_data/i2c-s3c2410.h> 37#include <linux/platform_data/i2c-s3c2410.h>
38#include <mach/gpio-samsung.h>
38#include <plat/fb.h> 39#include <plat/fb.h>
39#include <linux/platform_data/mtd-nand-s3c2410.h> 40#include <linux/platform_data/mtd-nand-s3c2410.h>
40 41
diff --git a/arch/arm/mach-s3c64xx/mach-mini6410.c b/arch/arm/mach-s3c64xx/mach-mini6410.c
index 58d46a3d7b78..8c84d3448dac 100644
--- a/arch/arm/mach-s3c64xx/mach-mini6410.c
+++ b/arch/arm/mach-s3c64xx/mach-mini6410.c
@@ -30,6 +30,7 @@
30 30
31#include <mach/map.h> 31#include <mach/map.h>
32#include <mach/regs-gpio.h> 32#include <mach/regs-gpio.h>
33#include <mach/gpio-samsung.h>
33 34
34#include <plat/adc.h> 35#include <plat/adc.h>
35#include <plat/cpu.h> 36#include <plat/cpu.h>
diff --git a/arch/arm/mach-s3c64xx/mach-real6410.c b/arch/arm/mach-s3c64xx/mach-real6410.c
index 8bed37b3d5ac..5152026f0e19 100644
--- a/arch/arm/mach-s3c64xx/mach-real6410.c
+++ b/arch/arm/mach-s3c64xx/mach-real6410.c
@@ -31,6 +31,7 @@
31 31
32#include <mach/map.h> 32#include <mach/map.h>
33#include <mach/regs-gpio.h> 33#include <mach/regs-gpio.h>
34#include <mach/gpio-samsung.h>
34 35
35#include <plat/adc.h> 36#include <plat/adc.h>
36#include <plat/cpu.h> 37#include <plat/cpu.h>
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c b/arch/arm/mach-s3c64xx/mach-smartq.c
index a6b338fd0470..5629df905fcd 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -25,6 +25,7 @@
25 25
26#include <mach/map.h> 26#include <mach/map.h>
27#include <mach/regs-gpio.h> 27#include <mach/regs-gpio.h>
28#include <mach/gpio-samsung.h>
28 29
29#include <plat/clock.h> 30#include <plat/clock.h>
30#include <plat/cpu.h> 31#include <plat/cpu.h>
diff --git a/arch/arm/mach-s3c64xx/mach-smartq5.c b/arch/arm/mach-s3c64xx/mach-smartq5.c
index 8aca5daf3d05..dec4c08e834f 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq5.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq5.c
@@ -23,6 +23,7 @@
23#include <video/samsung_fimd.h> 23#include <video/samsung_fimd.h>
24#include <mach/map.h> 24#include <mach/map.h>
25#include <mach/regs-gpio.h> 25#include <mach/regs-gpio.h>
26#include <mach/gpio-samsung.h>
26 27
27#include <plat/cpu.h> 28#include <plat/cpu.h>
28#include <plat/devs.h> 29#include <plat/devs.h>
diff --git a/arch/arm/mach-s3c64xx/mach-smartq7.c b/arch/arm/mach-s3c64xx/mach-smartq7.c
index a052e107c0b4..27b322069c7d 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq7.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq7.c
@@ -23,6 +23,7 @@
23#include <video/samsung_fimd.h> 23#include <video/samsung_fimd.h>
24#include <mach/map.h> 24#include <mach/map.h>
25#include <mach/regs-gpio.h> 25#include <mach/regs-gpio.h>
26#include <mach/gpio-samsung.h>
26 27
27#include <plat/cpu.h> 28#include <plat/cpu.h>
28#include <plat/devs.h> 29#include <plat/devs.h>
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6400.c b/arch/arm/mach-s3c64xx/mach-smdk6400.c
index 27381cfcabbe..150f55fb9e33 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6400.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6400.c
@@ -35,6 +35,7 @@
35#include <plat/devs.h> 35#include <plat/devs.h>
36#include <plat/cpu.h> 36#include <plat/cpu.h>
37#include <linux/platform_data/i2c-s3c2410.h> 37#include <linux/platform_data/i2c-s3c2410.h>
38#include <mach/gpio-samsung.h>
38#include <plat/samsung-time.h> 39#include <plat/samsung-time.h>
39 40
40#include "common.h" 41#include "common.h"
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index d5ea938cc9a1..43261d24a0a5 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -57,6 +57,7 @@
57 57
58#include <plat/regs-serial.h> 58#include <plat/regs-serial.h>
59#include <mach/regs-gpio.h> 59#include <mach/regs-gpio.h>
60#include <mach/gpio-samsung.h>
60#include <linux/platform_data/ata-samsung_cf.h> 61#include <linux/platform_data/ata-samsung_cf.h>
61#include <linux/platform_data/i2c-s3c2410.h> 62#include <linux/platform_data/i2c-s3c2410.h>
62#include <plat/fb.h> 63#include <plat/fb.h>
diff --git a/arch/arm/mach-s3c64xx/pm.c b/arch/arm/mach-s3c64xx/pm.c
index 8cdb824a3b43..b5a66986a529 100644
--- a/arch/arm/mach-s3c64xx/pm.c
+++ b/arch/arm/mach-s3c64xx/pm.c
@@ -28,6 +28,7 @@
28 28
29#include <mach/regs-gpio.h> 29#include <mach/regs-gpio.h>
30#include <mach/regs-clock.h> 30#include <mach/regs-clock.h>
31#include <mach/gpio-samsung.h>
31 32
32#include "regs-gpio-memport.h" 33#include "regs-gpio-memport.h"
33#include "regs-modem.h" 34#include "regs-modem.h"
diff --git a/arch/arm/mach-s3c64xx/setup-fb-24bpp.c b/arch/arm/mach-s3c64xx/setup-fb-24bpp.c
index 2cf80026c58d..9d17bff12d4d 100644
--- a/arch/arm/mach-s3c64xx/setup-fb-24bpp.c
+++ b/arch/arm/mach-s3c64xx/setup-fb-24bpp.c
@@ -19,6 +19,7 @@
19 19
20#include <plat/fb.h> 20#include <plat/fb.h>
21#include <plat/gpio-cfg.h> 21#include <plat/gpio-cfg.h>
22#include <mach/gpio-samsung.h>
22 23
23void s3c64xx_fb_gpio_setup_24bpp(void) 24void s3c64xx_fb_gpio_setup_24bpp(void)
24{ 25{
diff --git a/arch/arm/mach-s3c64xx/setup-i2c0.c b/arch/arm/mach-s3c64xx/setup-i2c0.c
index 40666ba8d607..4b8c1cfdd1fc 100644
--- a/arch/arm/mach-s3c64xx/setup-i2c0.c
+++ b/arch/arm/mach-s3c64xx/setup-i2c0.c
@@ -20,6 +20,7 @@ struct platform_device; /* don't need the contents */
20 20
21#include <linux/platform_data/i2c-s3c2410.h> 21#include <linux/platform_data/i2c-s3c2410.h>
22#include <plat/gpio-cfg.h> 22#include <plat/gpio-cfg.h>
23#include <mach/gpio-samsung.h>
23 24
24void s3c_i2c0_cfg_gpio(struct platform_device *dev) 25void s3c_i2c0_cfg_gpio(struct platform_device *dev)
25{ 26{
diff --git a/arch/arm/mach-s3c64xx/setup-i2c1.c b/arch/arm/mach-s3c64xx/setup-i2c1.c
index 3fdb24c4e62a..cd1df71ee13b 100644
--- a/arch/arm/mach-s3c64xx/setup-i2c1.c
+++ b/arch/arm/mach-s3c64xx/setup-i2c1.c
@@ -20,6 +20,7 @@ struct platform_device; /* don't need the contents */
20 20
21#include <linux/platform_data/i2c-s3c2410.h> 21#include <linux/platform_data/i2c-s3c2410.h>
22#include <plat/gpio-cfg.h> 22#include <plat/gpio-cfg.h>
23#include <mach/gpio-samsung.h>
23 24
24void s3c_i2c1_cfg_gpio(struct platform_device *dev) 25void s3c_i2c1_cfg_gpio(struct platform_device *dev)
25{ 26{
diff --git a/arch/arm/mach-s3c64xx/setup-ide.c b/arch/arm/mach-s3c64xx/setup-ide.c
index 648d8b85bf6b..689fb72e715c 100644
--- a/arch/arm/mach-s3c64xx/setup-ide.c
+++ b/arch/arm/mach-s3c64xx/setup-ide.c
@@ -17,6 +17,7 @@
17#include <mach/map.h> 17#include <mach/map.h>
18#include <mach/regs-clock.h> 18#include <mach/regs-clock.h>
19#include <plat/gpio-cfg.h> 19#include <plat/gpio-cfg.h>
20#include <mach/gpio-samsung.h>
20#include <linux/platform_data/ata-samsung_cf.h> 21#include <linux/platform_data/ata-samsung_cf.h>
21 22
22void s3c64xx_ide_setup_gpio(void) 23void s3c64xx_ide_setup_gpio(void)
diff --git a/arch/arm/mach-s3c64xx/setup-keypad.c b/arch/arm/mach-s3c64xx/setup-keypad.c
index 1d4d0ee9e870..6ad9a89dfddf 100644
--- a/arch/arm/mach-s3c64xx/setup-keypad.c
+++ b/arch/arm/mach-s3c64xx/setup-keypad.c
@@ -13,6 +13,7 @@
13#include <linux/gpio.h> 13#include <linux/gpio.h>
14#include <plat/gpio-cfg.h> 14#include <plat/gpio-cfg.h>
15#include <plat/keypad.h> 15#include <plat/keypad.h>
16#include <mach/gpio-samsung.h>
16 17
17void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols) 18void samsung_keypad_cfg_gpio(unsigned int rows, unsigned int cols)
18{ 19{
diff --git a/arch/arm/mach-s3c64xx/setup-sdhci-gpio.c b/arch/arm/mach-s3c64xx/setup-sdhci-gpio.c
index 6eac071afae2..f426b7a16c16 100644
--- a/arch/arm/mach-s3c64xx/setup-sdhci-gpio.c
+++ b/arch/arm/mach-s3c64xx/setup-sdhci-gpio.c
@@ -20,6 +20,7 @@
20 20
21#include <plat/gpio-cfg.h> 21#include <plat/gpio-cfg.h>
22#include <plat/sdhci.h> 22#include <plat/sdhci.h>
23#include <mach/gpio-samsung.h>
23 24
24void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width) 25void s3c64xx_setup_sdhci0_cfg_gpio(struct platform_device *dev, int width)
25{ 26{
diff --git a/arch/arm/mach-s3c64xx/setup-spi.c b/arch/arm/mach-s3c64xx/setup-spi.c
index 4dc53450d715..5fd1a315c901 100644
--- a/arch/arm/mach-s3c64xx/setup-spi.c
+++ b/arch/arm/mach-s3c64xx/setup-spi.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/gpio.h> 11#include <linux/gpio.h>
12#include <plat/gpio-cfg.h> 12#include <plat/gpio-cfg.h>
13#include <mach/gpio-samsung.h>
13 14
14#ifdef CONFIG_S3C64XX_DEV_SPI0 15#ifdef CONFIG_S3C64XX_DEV_SPI0
15int s3c64xx_spi0_cfg_gpio(void) 16int s3c64xx_spi0_cfg_gpio(void)
diff --git a/arch/arm/mach-tegra/board-paz00.c b/arch/arm/mach-tegra/board-paz00.c
index 06f024070dab..e4dec9fcb084 100644
--- a/arch/arm/mach-tegra/board-paz00.c
+++ b/arch/arm/mach-tegra/board-paz00.c
@@ -18,6 +18,7 @@
18 */ 18 */
19 19
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/gpio/driver.h>
21#include <linux/rfkill-gpio.h> 22#include <linux/rfkill-gpio.h>
22#include "board.h" 23#include "board.h"
23 24
@@ -36,7 +37,17 @@ static struct platform_device wifi_rfkill_device = {
36 }, 37 },
37}; 38};
38 39
40static struct gpiod_lookup_table wifi_gpio_lookup = {
41 .dev_id = "rfkill_gpio",
42 .table = {
43 GPIO_LOOKUP_IDX("tegra-gpio", 25, NULL, 0, 0),
44 GPIO_LOOKUP_IDX("tegra-gpio", 85, NULL, 1, 0),
45 { },
46 },
47};
48
39void __init tegra_paz00_wifikill_init(void) 49void __init tegra_paz00_wifikill_init(void)
40{ 50{
51 gpiod_add_lookup_table(&wifi_gpio_lookup);
41 platform_device_register(&wifi_rfkill_device); 52 platform_device_register(&wifi_rfkill_device);
42} 53}
diff --git a/arch/arm/plat-samsung/pm-gpio.c b/arch/arm/plat-samsung/pm-gpio.c
index a8de3cfe2ee1..dd4c15d0d68f 100644
--- a/arch/arm/plat-samsung/pm-gpio.c
+++ b/arch/arm/plat-samsung/pm-gpio.c
@@ -19,6 +19,10 @@
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21 21
22#if defined(CONFIG_ARCH_S3C24XX) || defined(CONFIG_ARCH_S3C64XX)
23#include <mach/gpio-samsung.h>
24#endif
25
22#include <plat/gpio-core.h> 26#include <plat/gpio-core.h>
23#include <plat/pm.h> 27#include <plat/pm.h>
24 28
diff --git a/arch/arm/plat-samsung/setup-camif.c b/arch/arm/plat-samsung/setup-camif.c
index e01bf760af2c..72d8edb8927a 100644
--- a/arch/arm/plat-samsung/setup-camif.c
+++ b/arch/arm/plat-samsung/setup-camif.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/gpio.h> 11#include <linux/gpio.h>
12#include <plat/gpio-cfg.h> 12#include <plat/gpio-cfg.h>
13#include <mach/gpio-samsung.h>
13 14
14/* Number of camera port pins, without FIELD */ 15/* Number of camera port pins, without FIELD */
15#define S3C_CAMIF_NUM_GPIOS 13 16#define S3C_CAMIF_NUM_GPIOS 13
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 8d24dcb7cdac..f8df0cc70cb6 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -64,6 +64,9 @@ config MMU
64config VARIANT_IRQ_SWITCH 64config VARIANT_IRQ_SWITCH
65 def_bool n 65 def_bool n
66 66
67config HAVE_XTENSA_GPIO32
68 def_bool n
69
67menu "Processor type and features" 70menu "Processor type and features"
68 71
69choice 72choice
@@ -73,16 +76,19 @@ choice
73config XTENSA_VARIANT_FSF 76config XTENSA_VARIANT_FSF
74 bool "fsf - default (not generic) configuration" 77 bool "fsf - default (not generic) configuration"
75 select MMU 78 select MMU
79 select HAVE_XTENSA_GPIO32
76 80
77config XTENSA_VARIANT_DC232B 81config XTENSA_VARIANT_DC232B
78 bool "dc232b - Diamond 232L Standard Core Rev.B (LE)" 82 bool "dc232b - Diamond 232L Standard Core Rev.B (LE)"
79 select MMU 83 select MMU
84 select HAVE_XTENSA_GPIO32
80 help 85 help
81 This variant refers to Tensilica's Diamond 232L Standard core Rev.B (LE). 86 This variant refers to Tensilica's Diamond 232L Standard core Rev.B (LE).
82 87
83config XTENSA_VARIANT_DC233C 88config XTENSA_VARIANT_DC233C
84 bool "dc233c - Diamond 233L Standard Core Rev.C (LE)" 89 bool "dc233c - Diamond 233L Standard Core Rev.C (LE)"
85 select MMU 90 select MMU
91 select HAVE_XTENSA_GPIO32
86 help 92 help
87 This variant refers to Tensilica's Diamond 233L Standard core Rev.C (LE). 93 This variant refers to Tensilica's Diamond 233L Standard core Rev.C (LE).
88 94
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 0f0444475bf0..25ce03eff6ab 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -110,7 +110,7 @@ comment "Memory mapped GPIO drivers:"
110 110
111config GPIO_CLPS711X 111config GPIO_CLPS711X
112 tristate "CLPS711X GPIO support" 112 tristate "CLPS711X GPIO support"
113 depends on ARCH_CLPS711X 113 depends on ARCH_CLPS711X || COMPILE_TEST
114 select GPIO_GENERIC 114 select GPIO_GENERIC
115 help 115 help
116 Say yes here to support GPIO on CLPS711X SoCs. 116 Say yes here to support GPIO on CLPS711X SoCs.
@@ -156,6 +156,13 @@ config GPIO_F7188X
156 To compile this driver as a module, choose M here: the module will 156 To compile this driver as a module, choose M here: the module will
157 be called f7188x-gpio. 157 be called f7188x-gpio.
158 158
159config GPIO_MOXART
160 bool "MOXART GPIO support"
161 depends on ARCH_MOXART
162 help
163 Select this option to enable GPIO driver for
164 MOXA ART SoC devices.
165
159config GPIO_MPC5200 166config GPIO_MPC5200
160 def_bool y 167 def_bool y
161 depends on PPC_MPC52xx 168 depends on PPC_MPC52xx
@@ -237,6 +244,15 @@ config GPIO_SAMSUNG
237 Legacy GPIO support. Use only for platforms without support for 244 Legacy GPIO support. Use only for platforms without support for
238 pinctrl. 245 pinctrl.
239 246
247config GPIO_SCH311X
248 tristate "SMSC SCH311x SuperI/O GPIO"
249 help
250 Driver to enable the GPIOs found on SMSC SMSC SCH3112, SCH3114 and
251 SCH3116 "Super I/O" chipsets.
252
253 To compile this driver as a module, choose M here: the module will
254 be called gpio-sch311x.
255
240config GPIO_SPEAR_SPICS 256config GPIO_SPEAR_SPICS
241 bool "ST SPEAr13xx SPI Chip Select as GPIO support" 257 bool "ST SPEAr13xx SPI Chip Select as GPIO support"
242 depends on PLAT_SPEAR 258 depends on PLAT_SPEAR
@@ -281,6 +297,15 @@ config GPIO_XILINX
281 help 297 help
282 Say yes here to support the Xilinx FPGA GPIO device 298 Say yes here to support the Xilinx FPGA GPIO device
283 299
300config GPIO_XTENSA
301 bool "Xtensa GPIO32 support"
302 depends on XTENSA
303 depends on HAVE_XTENSA_GPIO32
304 depends on !SMP
305 help
306 Say yes here to support the Xtensa internal GPIO32 IMPWIRE (input)
307 and EXPSTATE (output) ports
308
284config GPIO_VR41XX 309config GPIO_VR41XX
285 tristate "NEC VR4100 series General-purpose I/O Uint support" 310 tristate "NEC VR4100 series General-purpose I/O Uint support"
286 depends on CPU_VR41XX 311 depends on CPU_VR41XX
@@ -353,7 +378,7 @@ config GPIO_GE_FPGA
353 board computers. 378 board computers.
354 379
355config GPIO_LYNXPOINT 380config GPIO_LYNXPOINT
356 bool "Intel Lynxpoint GPIO support" 381 tristate "Intel Lynxpoint GPIO support"
357 depends on ACPI && X86 382 depends on ACPI && X86
358 select IRQ_DOMAIN 383 select IRQ_DOMAIN
359 help 384 help
@@ -692,11 +717,13 @@ config GPIO_MAX7301
692 717
693config GPIO_MCP23S08 718config GPIO_MCP23S08
694 tristate "Microchip MCP23xxx I/O expander" 719 tristate "Microchip MCP23xxx I/O expander"
720 depends on OF_GPIO
695 depends on (SPI_MASTER && !I2C) || I2C 721 depends on (SPI_MASTER && !I2C) || I2C
696 help 722 help
697 SPI/I2C driver for Microchip MCP23S08/MCP23S17/MCP23008/MCP23017 723 SPI/I2C driver for Microchip MCP23S08/MCP23S17/MCP23008/MCP23017
698 I/O expanders. 724 I/O expanders.
699 This provides a GPIO interface supporting inputs and outputs. 725 This provides a GPIO interface supporting inputs and outputs.
726 The I2C versions of the chips can be used as interrupt-controller.
700 727
701config GPIO_MC33880 728config GPIO_MC33880
702 tristate "Freescale MC33880 high-side/low-side switch" 729 tristate "Freescale MC33880 high-side/low-side switch"
@@ -707,10 +734,10 @@ config GPIO_MC33880
707 734
708config GPIO_74X164 735config GPIO_74X164
709 tristate "74x164 serial-in/parallel-out 8-bits shift register" 736 tristate "74x164 serial-in/parallel-out 8-bits shift register"
710 depends on SPI_MASTER 737 depends on SPI_MASTER && OF
711 help 738 help
712 Platform driver for 74x164 compatible serial-in/parallel-out 739 Driver for 74x164 compatible serial-in/parallel-out 8-outputs
713 8-outputs shift registers. This driver can be used to provide access 740 shift registers. This driver can be used to provide access
714 to more gpio outputs. 741 to more gpio outputs.
715 742
716comment "AC97 GPIO expanders:" 743comment "AC97 GPIO expanders:"
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 7971e36b8b12..c44fffac9519 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o
46obj-$(CONFIG_GPIO_MCP23S08) += gpio-mcp23s08.o 46obj-$(CONFIG_GPIO_MCP23S08) += gpio-mcp23s08.o
47obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o 47obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o
48obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o 48obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o
49obj-$(CONFIG_GPIO_MOXART) += gpio-moxart.o
49obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o 50obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o
50obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o 51obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o
51obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o 52obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o
@@ -67,6 +68,7 @@ obj-$(CONFIG_GPIO_RCAR) += gpio-rcar.o
67obj-$(CONFIG_GPIO_SAMSUNG) += gpio-samsung.o 68obj-$(CONFIG_GPIO_SAMSUNG) += gpio-samsung.o
68obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o 69obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o
69obj-$(CONFIG_GPIO_SCH) += gpio-sch.o 70obj-$(CONFIG_GPIO_SCH) += gpio-sch.o
71obj-$(CONFIG_GPIO_SCH311X) += gpio-sch311x.o
70obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o 72obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o
71obj-$(CONFIG_GPIO_SPEAR_SPICS) += gpio-spear-spics.o 73obj-$(CONFIG_GPIO_SPEAR_SPICS) += gpio-spear-spics.o
72obj-$(CONFIG_GPIO_STA2X11) += gpio-sta2x11.o 74obj-$(CONFIG_GPIO_STA2X11) += gpio-sta2x11.o
@@ -95,3 +97,4 @@ obj-$(CONFIG_GPIO_WM831X) += gpio-wm831x.o
95obj-$(CONFIG_GPIO_WM8350) += gpio-wm8350.o 97obj-$(CONFIG_GPIO_WM8350) += gpio-wm8350.o
96obj-$(CONFIG_GPIO_WM8994) += gpio-wm8994.o 98obj-$(CONFIG_GPIO_WM8994) += gpio-wm8994.o
97obj-$(CONFIG_GPIO_XILINX) += gpio-xilinx.o 99obj-$(CONFIG_GPIO_XILINX) += gpio-xilinx.o
100obj-$(CONFIG_GPIO_XTENSA) += gpio-xtensa.o
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index 1e04bf91328d..e4ae29824c32 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -12,7 +12,6 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/mutex.h> 13#include <linux/mutex.h>
14#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
15#include <linux/spi/74x164.h>
16#include <linux/gpio.h> 15#include <linux/gpio.h>
17#include <linux/of_gpio.h> 16#include <linux/of_gpio.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
@@ -21,7 +20,6 @@
21#define GEN_74X164_NUMBER_GPIOS 8 20#define GEN_74X164_NUMBER_GPIOS 8
22 21
23struct gen_74x164_chip { 22struct gen_74x164_chip {
24 struct spi_device *spi;
25 u8 *buffer; 23 u8 *buffer;
26 struct gpio_chip gpio_chip; 24 struct gpio_chip gpio_chip;
27 struct mutex lock; 25 struct mutex lock;
@@ -35,6 +33,7 @@ static struct gen_74x164_chip *gpio_to_74x164_chip(struct gpio_chip *gc)
35 33
36static int __gen_74x164_write_config(struct gen_74x164_chip *chip) 34static int __gen_74x164_write_config(struct gen_74x164_chip *chip)
37{ 35{
36 struct spi_device *spi = to_spi_device(chip->gpio_chip.dev);
38 struct spi_message message; 37 struct spi_message message;
39 struct spi_transfer *msg_buf; 38 struct spi_transfer *msg_buf;
40 int i, ret = 0; 39 int i, ret = 0;
@@ -55,12 +54,12 @@ static int __gen_74x164_write_config(struct gen_74x164_chip *chip)
55 * byte of the buffer will end up in the last register. 54 * byte of the buffer will end up in the last register.
56 */ 55 */
57 for (i = chip->registers - 1; i >= 0; i--) { 56 for (i = chip->registers - 1; i >= 0; i--) {
58 msg_buf[i].tx_buf = chip->buffer +i; 57 msg_buf[i].tx_buf = chip->buffer + i;
59 msg_buf[i].len = sizeof(u8); 58 msg_buf[i].len = sizeof(u8);
60 spi_message_add_tail(msg_buf + i, &message); 59 spi_message_add_tail(msg_buf + i, &message);
61 } 60 }
62 61
63 ret = spi_sync(chip->spi, &message); 62 ret = spi_sync(spi, &message);
64 63
65 kfree(msg_buf); 64 kfree(msg_buf);
66 65
@@ -108,14 +107,8 @@ static int gen_74x164_direction_output(struct gpio_chip *gc,
108static int gen_74x164_probe(struct spi_device *spi) 107static int gen_74x164_probe(struct spi_device *spi)
109{ 108{
110 struct gen_74x164_chip *chip; 109 struct gen_74x164_chip *chip;
111 struct gen_74x164_chip_platform_data *pdata;
112 int ret; 110 int ret;
113 111
114 if (!spi->dev.of_node) {
115 dev_err(&spi->dev, "No device tree data available.\n");
116 return -EINVAL;
117 }
118
119 /* 112 /*
120 * bits_per_word cannot be configured in platform data 113 * bits_per_word cannot be configured in platform data
121 */ 114 */
@@ -129,40 +122,32 @@ static int gen_74x164_probe(struct spi_device *spi)
129 if (!chip) 122 if (!chip)
130 return -ENOMEM; 123 return -ENOMEM;
131 124
132 pdata = dev_get_platdata(&spi->dev);
133 if (pdata && pdata->base)
134 chip->gpio_chip.base = pdata->base;
135 else
136 chip->gpio_chip.base = -1;
137
138 mutex_init(&chip->lock);
139
140 spi_set_drvdata(spi, chip); 125 spi_set_drvdata(spi, chip);
141 126
142 chip->spi = spi;
143
144 chip->gpio_chip.label = spi->modalias; 127 chip->gpio_chip.label = spi->modalias;
145 chip->gpio_chip.direction_output = gen_74x164_direction_output; 128 chip->gpio_chip.direction_output = gen_74x164_direction_output;
146 chip->gpio_chip.get = gen_74x164_get_value; 129 chip->gpio_chip.get = gen_74x164_get_value;
147 chip->gpio_chip.set = gen_74x164_set_value; 130 chip->gpio_chip.set = gen_74x164_set_value;
131 chip->gpio_chip.base = -1;
148 132
149 if (of_property_read_u32(spi->dev.of_node, "registers-number", &chip->registers)) { 133 if (of_property_read_u32(spi->dev.of_node, "registers-number",
150 dev_err(&spi->dev, "Missing registers-number property in the DT.\n"); 134 &chip->registers)) {
151 ret = -EINVAL; 135 dev_err(&spi->dev,
152 goto exit_destroy; 136 "Missing registers-number property in the DT.\n");
137 return -EINVAL;
153 } 138 }
154 139
155 chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers; 140 chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers;
156 chip->buffer = devm_kzalloc(&spi->dev, chip->registers, GFP_KERNEL); 141 chip->buffer = devm_kzalloc(&spi->dev, chip->registers, GFP_KERNEL);
157 if (!chip->buffer) { 142 if (!chip->buffer)
158 ret = -ENOMEM; 143 return -ENOMEM;
159 goto exit_destroy;
160 }
161 144
162 chip->gpio_chip.can_sleep = 1; 145 chip->gpio_chip.can_sleep = true;
163 chip->gpio_chip.dev = &spi->dev; 146 chip->gpio_chip.dev = &spi->dev;
164 chip->gpio_chip.owner = THIS_MODULE; 147 chip->gpio_chip.owner = THIS_MODULE;
165 148
149 mutex_init(&chip->lock);
150
166 ret = __gen_74x164_write_config(chip); 151 ret = __gen_74x164_write_config(chip);
167 if (ret) { 152 if (ret) {
168 dev_err(&spi->dev, "Failed writing: %d\n", ret); 153 dev_err(&spi->dev, "Failed writing: %d\n", ret);
@@ -170,31 +155,23 @@ static int gen_74x164_probe(struct spi_device *spi)
170 } 155 }
171 156
172 ret = gpiochip_add(&chip->gpio_chip); 157 ret = gpiochip_add(&chip->gpio_chip);
173 if (ret) 158 if (!ret)
174 goto exit_destroy; 159 return 0;
175
176 return ret;
177 160
178exit_destroy: 161exit_destroy:
179 mutex_destroy(&chip->lock); 162 mutex_destroy(&chip->lock);
163
180 return ret; 164 return ret;
181} 165}
182 166
183static int gen_74x164_remove(struct spi_device *spi) 167static int gen_74x164_remove(struct spi_device *spi)
184{ 168{
185 struct gen_74x164_chip *chip; 169 struct gen_74x164_chip *chip = spi_get_drvdata(spi);
186 int ret; 170 int ret;
187 171
188 chip = spi_get_drvdata(spi);
189 if (chip == NULL)
190 return -ENODEV;
191
192 ret = gpiochip_remove(&chip->gpio_chip); 172 ret = gpiochip_remove(&chip->gpio_chip);
193 if (!ret) 173 if (!ret)
194 mutex_destroy(&chip->lock); 174 mutex_destroy(&chip->lock);
195 else
196 dev_err(&spi->dev, "Failed to remove the GPIO controller: %d\n",
197 ret);
198 175
199 return ret; 176 return ret;
200} 177}
diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
index b204033acaeb..6fc6206b38bd 100644
--- a/drivers/gpio/gpio-adnp.c
+++ b/drivers/gpio/gpio-adnp.c
@@ -260,7 +260,7 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios)
260 chip->direction_output = adnp_gpio_direction_output; 260 chip->direction_output = adnp_gpio_direction_output;
261 chip->get = adnp_gpio_get; 261 chip->get = adnp_gpio_get;
262 chip->set = adnp_gpio_set; 262 chip->set = adnp_gpio_set;
263 chip->can_sleep = 1; 263 chip->can_sleep = true;
264 264
265 if (IS_ENABLED(CONFIG_DEBUG_FS)) 265 if (IS_ENABLED(CONFIG_DEBUG_FS))
266 chip->dbg_show = adnp_gpio_dbg_show; 266 chip->dbg_show = adnp_gpio_dbg_show;
@@ -408,6 +408,27 @@ static void adnp_irq_bus_unlock(struct irq_data *data)
408 mutex_unlock(&adnp->irq_lock); 408 mutex_unlock(&adnp->irq_lock);
409} 409}
410 410
411static unsigned int adnp_irq_startup(struct irq_data *data)
412{
413 struct adnp *adnp = irq_data_get_irq_chip_data(data);
414
415 if (gpio_lock_as_irq(&adnp->gpio, data->hwirq))
416 dev_err(adnp->gpio.dev,
417 "unable to lock HW IRQ %lu for IRQ\n",
418 data->hwirq);
419 /* Satisfy the .enable semantics by unmasking the line */
420 adnp_irq_unmask(data);
421 return 0;
422}
423
424static void adnp_irq_shutdown(struct irq_data *data)
425{
426 struct adnp *adnp = irq_data_get_irq_chip_data(data);
427
428 adnp_irq_mask(data);
429 gpio_unlock_as_irq(&adnp->gpio, data->hwirq);
430}
431
411static struct irq_chip adnp_irq_chip = { 432static struct irq_chip adnp_irq_chip = {
412 .name = "gpio-adnp", 433 .name = "gpio-adnp",
413 .irq_mask = adnp_irq_mask, 434 .irq_mask = adnp_irq_mask,
@@ -415,6 +436,8 @@ static struct irq_chip adnp_irq_chip = {
415 .irq_set_type = adnp_irq_set_type, 436 .irq_set_type = adnp_irq_set_type,
416 .irq_bus_lock = adnp_irq_bus_lock, 437 .irq_bus_lock = adnp_irq_bus_lock,
417 .irq_bus_sync_unlock = adnp_irq_bus_unlock, 438 .irq_bus_sync_unlock = adnp_irq_bus_unlock,
439 .irq_startup = adnp_irq_startup,
440 .irq_shutdown = adnp_irq_shutdown,
418}; 441};
419 442
420static int adnp_irq_map(struct irq_domain *domain, unsigned int irq, 443static int adnp_irq_map(struct irq_domain *domain, unsigned int irq,
diff --git a/drivers/gpio/gpio-adp5520.c b/drivers/gpio/gpio-adp5520.c
index 084337d5514d..613265944e2e 100644
--- a/drivers/gpio/gpio-adp5520.c
+++ b/drivers/gpio/gpio-adp5520.c
@@ -127,7 +127,7 @@ static int adp5520_gpio_probe(struct platform_device *pdev)
127 gc->direction_output = adp5520_gpio_direction_output; 127 gc->direction_output = adp5520_gpio_direction_output;
128 gc->get = adp5520_gpio_get_value; 128 gc->get = adp5520_gpio_get_value;
129 gc->set = adp5520_gpio_set_value; 129 gc->set = adp5520_gpio_set_value;
130 gc->can_sleep = 1; 130 gc->can_sleep = true;
131 131
132 gc->base = pdata->gpio_start; 132 gc->base = pdata->gpio_start;
133 gc->ngpio = gpios; 133 gc->ngpio = gpios;
diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c
index 90fc4c99c024..3f190e68f973 100644
--- a/drivers/gpio/gpio-adp5588.c
+++ b/drivers/gpio/gpio-adp5588.c
@@ -380,7 +380,7 @@ static int adp5588_gpio_probe(struct i2c_client *client,
380 gc->direction_output = adp5588_gpio_direction_output; 380 gc->direction_output = adp5588_gpio_direction_output;
381 gc->get = adp5588_gpio_get_value; 381 gc->get = adp5588_gpio_get_value;
382 gc->set = adp5588_gpio_set_value; 382 gc->set = adp5588_gpio_set_value;
383 gc->can_sleep = 1; 383 gc->can_sleep = true;
384 384
385 gc->base = pdata->gpio_start; 385 gc->base = pdata->gpio_start;
386 gc->ngpio = ADP5588_MAXGPIO; 386 gc->ngpio = ADP5588_MAXGPIO;
diff --git a/drivers/gpio/gpio-amd8111.c b/drivers/gpio/gpio-amd8111.c
index 710fafcdd1b1..94e9992f8904 100644
--- a/drivers/gpio/gpio-amd8111.c
+++ b/drivers/gpio/gpio-amd8111.c
@@ -60,7 +60,7 @@
60 * register a pci_driver, because someone else might one day 60 * register a pci_driver, because someone else might one day
61 * want to register another driver on the same PCI id. 61 * want to register another driver on the same PCI id.
62 */ 62 */
63static DEFINE_PCI_DEVICE_TABLE(pci_tbl) = { 63static const struct pci_device_id pci_tbl[] = {
64 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS), 0 }, 64 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS), 0 },
65 { 0, }, /* terminate list */ 65 { 0, }, /* terminate list */
66}; 66};
diff --git a/drivers/gpio/gpio-arizona.c b/drivers/gpio/gpio-arizona.c
index dceb5dcf9d16..29bdff558981 100644
--- a/drivers/gpio/gpio-arizona.c
+++ b/drivers/gpio/gpio-arizona.c
@@ -91,7 +91,7 @@ static struct gpio_chip template_chip = {
91 .get = arizona_gpio_get, 91 .get = arizona_gpio_get,
92 .direction_output = arizona_gpio_direction_out, 92 .direction_output = arizona_gpio_direction_out,
93 .set = arizona_gpio_set, 93 .set = arizona_gpio_set,
94 .can_sleep = 1, 94 .can_sleep = true,
95}; 95};
96 96
97static int arizona_gpio_probe(struct platform_device *pdev) 97static int arizona_gpio_probe(struct platform_device *pdev)
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
index 54c18c220a60..233d088ac59f 100644
--- a/drivers/gpio/gpio-bcm-kona.c
+++ b/drivers/gpio/gpio-bcm-kona.c
@@ -449,12 +449,34 @@ static void bcm_kona_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
449 chained_irq_exit(chip, desc); 449 chained_irq_exit(chip, desc);
450} 450}
451 451
452static unsigned int bcm_kona_gpio_irq_startup(struct irq_data *d)
453{
454 struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
455
456 if (gpio_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq))
457 dev_err(kona_gpio->gpio_chip.dev,
458 "unable to lock HW IRQ %lu for IRQ\n",
459 d->hwirq);
460 bcm_kona_gpio_irq_unmask(d);
461 return 0;
462}
463
464static void bcm_kona_gpio_irq_shutdown(struct irq_data *d)
465{
466 struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
467
468 bcm_kona_gpio_irq_mask(d);
469 gpio_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq);
470}
471
452static struct irq_chip bcm_gpio_irq_chip = { 472static struct irq_chip bcm_gpio_irq_chip = {
453 .name = "bcm-kona-gpio", 473 .name = "bcm-kona-gpio",
454 .irq_ack = bcm_kona_gpio_irq_ack, 474 .irq_ack = bcm_kona_gpio_irq_ack,
455 .irq_mask = bcm_kona_gpio_irq_mask, 475 .irq_mask = bcm_kona_gpio_irq_mask,
456 .irq_unmask = bcm_kona_gpio_irq_unmask, 476 .irq_unmask = bcm_kona_gpio_irq_unmask,
457 .irq_set_type = bcm_kona_gpio_irq_set_type, 477 .irq_set_type = bcm_kona_gpio_irq_set_type,
478 .irq_startup = bcm_kona_gpio_irq_startup,
479 .irq_shutdown = bcm_kona_gpio_irq_shutdown,
458}; 480};
459 481
460static struct __initconst of_device_id bcm_kona_gpio_of_match[] = { 482static struct __initconst of_device_id bcm_kona_gpio_of_match[] = {
diff --git a/drivers/gpio/gpio-bt8xx.c b/drivers/gpio/gpio-bt8xx.c
index 9dfe36fd8baf..ecb3ca2d1d10 100644
--- a/drivers/gpio/gpio-bt8xx.c
+++ b/drivers/gpio/gpio-bt8xx.c
@@ -169,7 +169,7 @@ static void bt8xxgpio_gpio_setup(struct bt8xxgpio *bg)
169 c->dbg_show = NULL; 169 c->dbg_show = NULL;
170 c->base = modparam_gpiobase; 170 c->base = modparam_gpiobase;
171 c->ngpio = BT8XXGPIO_NR_GPIOS; 171 c->ngpio = BT8XXGPIO_NR_GPIOS;
172 c->can_sleep = 0; 172 c->can_sleep = false;
173} 173}
174 174
175static int bt8xxgpio_probe(struct pci_dev *dev, 175static int bt8xxgpio_probe(struct pci_dev *dev,
@@ -308,7 +308,7 @@ static int bt8xxgpio_resume(struct pci_dev *pdev)
308#define bt8xxgpio_resume NULL 308#define bt8xxgpio_resume NULL
309#endif /* CONFIG_PM */ 309#endif /* CONFIG_PM */
310 310
311static DEFINE_PCI_DEVICE_TABLE(bt8xxgpio_pci_tbl) = { 311static const struct pci_device_id bt8xxgpio_pci_tbl[] = {
312 { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848) }, 312 { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT848) },
313 { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT849) }, 313 { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT849) },
314 { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT878) }, 314 { PCI_DEVICE(PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BT878) },
diff --git a/drivers/gpio/gpio-clps711x.c b/drivers/gpio/gpio-clps711x.c
index 0924f20fa47f..d3550274b8f7 100644
--- a/drivers/gpio/gpio-clps711x.c
+++ b/drivers/gpio/gpio-clps711x.c
@@ -77,7 +77,7 @@ static int clps711x_gpio_remove(struct platform_device *pdev)
77 return bgpio_remove(bgc); 77 return bgpio_remove(bgc);
78} 78}
79 79
80static const struct of_device_id clps711x_gpio_ids[] = { 80static const struct of_device_id __maybe_unused clps711x_gpio_ids[] = {
81 { .compatible = "cirrus,clps711x-gpio" }, 81 { .compatible = "cirrus,clps711x-gpio" },
82 { } 82 { }
83}; 83};
@@ -87,7 +87,7 @@ static struct platform_driver clps711x_gpio_driver = {
87 .driver = { 87 .driver = {
88 .name = "clps711x-gpio", 88 .name = "clps711x-gpio",
89 .owner = THIS_MODULE, 89 .owner = THIS_MODULE,
90 .of_match_table = clps711x_gpio_ids, 90 .of_match_table = of_match_ptr(clps711x_gpio_ids),
91 }, 91 },
92 .probe = clps711x_gpio_probe, 92 .probe = clps711x_gpio_probe,
93 .remove = clps711x_gpio_remove, 93 .remove = clps711x_gpio_remove,
diff --git a/drivers/gpio/gpio-da9052.c b/drivers/gpio/gpio-da9052.c
index 9b77dc05d4ad..416cdf786b05 100644
--- a/drivers/gpio/gpio-da9052.c
+++ b/drivers/gpio/gpio-da9052.c
@@ -200,7 +200,7 @@ static struct gpio_chip reference_gp = {
200 .direction_input = da9052_gpio_direction_input, 200 .direction_input = da9052_gpio_direction_input,
201 .direction_output = da9052_gpio_direction_output, 201 .direction_output = da9052_gpio_direction_output,
202 .to_irq = da9052_gpio_to_irq, 202 .to_irq = da9052_gpio_to_irq,
203 .can_sleep = 1, 203 .can_sleep = true,
204 .ngpio = 16, 204 .ngpio = 16,
205 .base = -1, 205 .base = -1,
206}; 206};
diff --git a/drivers/gpio/gpio-da9055.c b/drivers/gpio/gpio-da9055.c
index 7ef0820032bd..f992997bc301 100644
--- a/drivers/gpio/gpio-da9055.c
+++ b/drivers/gpio/gpio-da9055.c
@@ -134,7 +134,7 @@ static struct gpio_chip reference_gp = {
134 .direction_input = da9055_gpio_direction_input, 134 .direction_input = da9055_gpio_direction_input,
135 .direction_output = da9055_gpio_direction_output, 135 .direction_output = da9055_gpio_direction_output,
136 .to_irq = da9055_gpio_to_irq, 136 .to_irq = da9055_gpio_to_irq,
137 .can_sleep = 1, 137 .can_sleep = true,
138 .ngpio = 3, 138 .ngpio = 3,
139 .base = -1, 139 .base = -1,
140}; 140};
diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c
index ec190361bf2e..1e98a9873967 100644
--- a/drivers/gpio/gpio-em.c
+++ b/drivers/gpio/gpio-em.c
@@ -99,6 +99,27 @@ static void em_gio_irq_enable(struct irq_data *d)
99 em_gio_write(p, GIO_IEN, BIT(irqd_to_hwirq(d))); 99 em_gio_write(p, GIO_IEN, BIT(irqd_to_hwirq(d)));
100} 100}
101 101
102static unsigned int em_gio_irq_startup(struct irq_data *d)
103{
104 struct em_gio_priv *p = irq_data_get_irq_chip_data(d);
105
106 if (gpio_lock_as_irq(&p->gpio_chip, irqd_to_hwirq(d)))
107 dev_err(p->gpio_chip.dev,
108 "unable to lock HW IRQ %lu for IRQ\n",
109 irqd_to_hwirq(d));
110 em_gio_irq_enable(d);
111 return 0;
112}
113
114static void em_gio_irq_shutdown(struct irq_data *d)
115{
116 struct em_gio_priv *p = irq_data_get_irq_chip_data(d);
117
118 em_gio_irq_disable(d);
119 gpio_unlock_as_irq(&p->gpio_chip, irqd_to_hwirq(d));
120}
121
122
102#define GIO_ASYNC(x) (x + 8) 123#define GIO_ASYNC(x) (x + 8)
103 124
104static unsigned char em_gio_sense_table[IRQ_TYPE_SENSE_MASK + 1] = { 125static unsigned char em_gio_sense_table[IRQ_TYPE_SENSE_MASK + 1] = {
@@ -328,6 +349,7 @@ static int em_gio_probe(struct platform_device *pdev)
328 gpio_chip->request = em_gio_request; 349 gpio_chip->request = em_gio_request;
329 gpio_chip->free = em_gio_free; 350 gpio_chip->free = em_gio_free;
330 gpio_chip->label = name; 351 gpio_chip->label = name;
352 gpio_chip->dev = &pdev->dev;
331 gpio_chip->owner = THIS_MODULE; 353 gpio_chip->owner = THIS_MODULE;
332 gpio_chip->base = pdata->gpio_base; 354 gpio_chip->base = pdata->gpio_base;
333 gpio_chip->ngpio = pdata->number_of_pins; 355 gpio_chip->ngpio = pdata->number_of_pins;
@@ -336,10 +358,10 @@ static int em_gio_probe(struct platform_device *pdev)
336 irq_chip->name = name; 358 irq_chip->name = name;
337 irq_chip->irq_mask = em_gio_irq_disable; 359 irq_chip->irq_mask = em_gio_irq_disable;
338 irq_chip->irq_unmask = em_gio_irq_enable; 360 irq_chip->irq_unmask = em_gio_irq_enable;
339 irq_chip->irq_enable = em_gio_irq_enable;
340 irq_chip->irq_disable = em_gio_irq_disable;
341 irq_chip->irq_set_type = em_gio_irq_set_type; 361 irq_chip->irq_set_type = em_gio_irq_set_type;
342 irq_chip->flags = IRQCHIP_SKIP_SET_WAKE; 362 irq_chip->irq_startup = em_gio_irq_startup;
363 irq_chip->irq_shutdown = em_gio_irq_shutdown;
364 irq_chip->flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MASK_ON_SUSPEND;
343 365
344 p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, 366 p->irq_domain = irq_domain_add_simple(pdev->dev.of_node,
345 pdata->number_of_pins, 367 pdata->number_of_pins,
diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c
index 9cb8320e1181..8f73ee093739 100644
--- a/drivers/gpio/gpio-f7188x.c
+++ b/drivers/gpio/gpio-f7188x.c
@@ -135,6 +135,7 @@ static void f7188x_gpio_set(struct gpio_chip *chip, unsigned offset, int value);
135 .set = f7188x_gpio_set, \ 135 .set = f7188x_gpio_set, \
136 .base = _base, \ 136 .base = _base, \
137 .ngpio = _ngpio, \ 137 .ngpio = _ngpio, \
138 .can_sleep = true, \
138 }, \ 139 }, \
139 .regbase = _regbase, \ 140 .regbase = _regbase, \
140 } 141 }
diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
index 814addb62d2c..f5bf3c38bca6 100644
--- a/drivers/gpio/gpio-ich.c
+++ b/drivers/gpio/gpio-ich.c
@@ -252,7 +252,7 @@ static void ichx_gpiolib_setup(struct gpio_chip *chip)
252 chip->direction_output = ichx_gpio_direction_output; 252 chip->direction_output = ichx_gpio_direction_output;
253 chip->base = modparam_gpiobase; 253 chip->base = modparam_gpiobase;
254 chip->ngpio = ichx_priv.desc->ngpio; 254 chip->ngpio = ichx_priv.desc->ngpio;
255 chip->can_sleep = 0; 255 chip->can_sleep = false;
256 chip->dbg_show = NULL; 256 chip->dbg_show = NULL;
257} 257}
258 258
diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
index be803af658ac..d1b50ef5fab8 100644
--- a/drivers/gpio/gpio-intel-mid.c
+++ b/drivers/gpio/gpio-intel-mid.c
@@ -235,11 +235,33 @@ static void intel_mid_irq_mask(struct irq_data *d)
235{ 235{
236} 236}
237 237
238static unsigned int intel_mid_irq_startup(struct irq_data *d)
239{
240 struct intel_mid_gpio *priv = irq_data_get_irq_chip_data(d);
241
242 if (gpio_lock_as_irq(&priv->chip, irqd_to_hwirq(d)))
243 dev_err(priv->chip.dev,
244 "unable to lock HW IRQ %lu for IRQ\n",
245 irqd_to_hwirq(d));
246 intel_mid_irq_unmask(d);
247 return 0;
248}
249
250static void intel_mid_irq_shutdown(struct irq_data *d)
251{
252 struct intel_mid_gpio *priv = irq_data_get_irq_chip_data(d);
253
254 intel_mid_irq_mask(d);
255 gpio_unlock_as_irq(&priv->chip, irqd_to_hwirq(d));
256}
257
238static struct irq_chip intel_mid_irqchip = { 258static struct irq_chip intel_mid_irqchip = {
239 .name = "INTEL_MID-GPIO", 259 .name = "INTEL_MID-GPIO",
240 .irq_mask = intel_mid_irq_mask, 260 .irq_mask = intel_mid_irq_mask,
241 .irq_unmask = intel_mid_irq_unmask, 261 .irq_unmask = intel_mid_irq_unmask,
242 .irq_set_type = intel_mid_irq_type, 262 .irq_set_type = intel_mid_irq_type,
263 .irq_startup = intel_mid_irq_startup,
264 .irq_shutdown = intel_mid_irq_shutdown,
243}; 265};
244 266
245static const struct intel_mid_gpio_ddata gpio_lincroft = { 267static const struct intel_mid_gpio_ddata gpio_lincroft = {
@@ -275,7 +297,7 @@ static const struct intel_mid_gpio_ddata gpio_tangier = {
275 .chip_irq_type = INTEL_MID_IRQ_TYPE_EDGE, 297 .chip_irq_type = INTEL_MID_IRQ_TYPE_EDGE,
276}; 298};
277 299
278static DEFINE_PCI_DEVICE_TABLE(intel_gpio_ids) = { 300static const struct pci_device_id intel_gpio_ids[] = {
279 { 301 {
280 /* Lincroft */ 302 /* Lincroft */
281 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080f), 303 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080f),
@@ -358,8 +380,7 @@ static int intel_gpio_irq_map(struct irq_domain *d, unsigned int irq,
358{ 380{
359 struct intel_mid_gpio *priv = d->host_data; 381 struct intel_mid_gpio *priv = d->host_data;
360 382
361 irq_set_chip_and_handler_name(irq, &intel_mid_irqchip, 383 irq_set_chip_and_handler(irq, &intel_mid_irqchip, handle_simple_irq);
362 handle_simple_irq, "demux");
363 irq_set_chip_data(irq, priv); 384 irq_set_chip_data(irq, priv);
364 irq_set_irq_type(irq, IRQ_TYPE_NONE); 385 irq_set_irq_type(irq, IRQ_TYPE_NONE);
365 386
@@ -418,6 +439,7 @@ static int intel_gpio_probe(struct pci_dev *pdev,
418 439
419 priv->reg_base = pcim_iomap_table(pdev)[0]; 440 priv->reg_base = pcim_iomap_table(pdev)[0];
420 priv->chip.label = dev_name(&pdev->dev); 441 priv->chip.label = dev_name(&pdev->dev);
442 priv->chip.dev = &pdev->dev;
421 priv->chip.request = intel_gpio_request; 443 priv->chip.request = intel_gpio_request;
422 priv->chip.direction_input = intel_gpio_direction_input; 444 priv->chip.direction_input = intel_gpio_direction_input;
423 priv->chip.direction_output = intel_gpio_direction_output; 445 priv->chip.direction_output = intel_gpio_direction_output;
@@ -426,7 +448,7 @@ static int intel_gpio_probe(struct pci_dev *pdev,
426 priv->chip.to_irq = intel_gpio_to_irq; 448 priv->chip.to_irq = intel_gpio_to_irq;
427 priv->chip.base = gpio_base; 449 priv->chip.base = gpio_base;
428 priv->chip.ngpio = ddata->ngpio; 450 priv->chip.ngpio = ddata->ngpio;
429 priv->chip.can_sleep = 0; 451 priv->chip.can_sleep = false;
430 priv->pdev = pdev; 452 priv->pdev = pdev;
431 453
432 spin_lock_init(&priv->lock); 454 spin_lock_init(&priv->lock);
diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c
index efdc3924d7df..c6d88173f5a2 100644
--- a/drivers/gpio/gpio-kempld.c
+++ b/drivers/gpio/gpio-kempld.c
@@ -167,7 +167,7 @@ static int kempld_gpio_probe(struct platform_device *pdev)
167 chip->label = "gpio-kempld"; 167 chip->label = "gpio-kempld";
168 chip->owner = THIS_MODULE; 168 chip->owner = THIS_MODULE;
169 chip->dev = dev; 169 chip->dev = dev;
170 chip->can_sleep = 1; 170 chip->can_sleep = true;
171 if (pdata && pdata->gpio_base) 171 if (pdata && pdata->gpio_base)
172 chip->base = pdata->gpio_base; 172 chip->base = pdata->gpio_base;
173 else 173 else
diff --git a/drivers/gpio/gpio-ks8695.c b/drivers/gpio/gpio-ks8695.c
index a3ac66ea364b..464a83de0d6a 100644
--- a/drivers/gpio/gpio-ks8695.c
+++ b/drivers/gpio/gpio-ks8695.c
@@ -228,7 +228,7 @@ static struct gpio_chip ks8695_gpio_chip = {
228 .to_irq = ks8695_gpio_to_irq, 228 .to_irq = ks8695_gpio_to_irq,
229 .base = 0, 229 .base = 0,
230 .ngpio = 16, 230 .ngpio = 16,
231 .can_sleep = 0, 231 .can_sleep = false,
232}; 232};
233 233
234/* Register the GPIOs */ 234/* Register the GPIOs */
diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
index 2d5555decf0c..225344d66404 100644
--- a/drivers/gpio/gpio-lpc32xx.c
+++ b/drivers/gpio/gpio-lpc32xx.c
@@ -25,10 +25,10 @@
25#include <linux/of_gpio.h> 25#include <linux/of_gpio.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/platform_data/gpio-lpc32xx.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <mach/platform.h> 31#include <mach/platform.h>
31#include <mach/gpio-lpc32xx.h>
32#include <mach/irqs.h> 32#include <mach/irqs.h>
33 33
34#define LPC32XX_GPIO_P3_INP_STATE _GPREG(0x000) 34#define LPC32XX_GPIO_P3_INP_STATE _GPREG(0x000)
@@ -448,7 +448,7 @@ static struct lpc32xx_gpio_chip lpc32xx_gpiochip[] = {
448 .base = LPC32XX_GPIO_P0_GRP, 448 .base = LPC32XX_GPIO_P0_GRP,
449 .ngpio = LPC32XX_GPIO_P0_MAX, 449 .ngpio = LPC32XX_GPIO_P0_MAX,
450 .names = gpio_p0_names, 450 .names = gpio_p0_names,
451 .can_sleep = 0, 451 .can_sleep = false,
452 }, 452 },
453 .gpio_grp = &gpio_grp_regs_p0, 453 .gpio_grp = &gpio_grp_regs_p0,
454 }, 454 },
@@ -464,7 +464,7 @@ static struct lpc32xx_gpio_chip lpc32xx_gpiochip[] = {
464 .base = LPC32XX_GPIO_P1_GRP, 464 .base = LPC32XX_GPIO_P1_GRP,
465 .ngpio = LPC32XX_GPIO_P1_MAX, 465 .ngpio = LPC32XX_GPIO_P1_MAX,
466 .names = gpio_p1_names, 466 .names = gpio_p1_names,
467 .can_sleep = 0, 467 .can_sleep = false,
468 }, 468 },
469 .gpio_grp = &gpio_grp_regs_p1, 469 .gpio_grp = &gpio_grp_regs_p1,
470 }, 470 },
@@ -479,7 +479,7 @@ static struct lpc32xx_gpio_chip lpc32xx_gpiochip[] = {
479 .base = LPC32XX_GPIO_P2_GRP, 479 .base = LPC32XX_GPIO_P2_GRP,
480 .ngpio = LPC32XX_GPIO_P2_MAX, 480 .ngpio = LPC32XX_GPIO_P2_MAX,
481 .names = gpio_p2_names, 481 .names = gpio_p2_names,
482 .can_sleep = 0, 482 .can_sleep = false,
483 }, 483 },
484 .gpio_grp = &gpio_grp_regs_p2, 484 .gpio_grp = &gpio_grp_regs_p2,
485 }, 485 },
@@ -495,7 +495,7 @@ static struct lpc32xx_gpio_chip lpc32xx_gpiochip[] = {
495 .base = LPC32XX_GPIO_P3_GRP, 495 .base = LPC32XX_GPIO_P3_GRP,
496 .ngpio = LPC32XX_GPIO_P3_MAX, 496 .ngpio = LPC32XX_GPIO_P3_MAX,
497 .names = gpio_p3_names, 497 .names = gpio_p3_names,
498 .can_sleep = 0, 498 .can_sleep = false,
499 }, 499 },
500 .gpio_grp = &gpio_grp_regs_p3, 500 .gpio_grp = &gpio_grp_regs_p3,
501 }, 501 },
@@ -509,7 +509,7 @@ static struct lpc32xx_gpio_chip lpc32xx_gpiochip[] = {
509 .base = LPC32XX_GPI_P3_GRP, 509 .base = LPC32XX_GPI_P3_GRP,
510 .ngpio = LPC32XX_GPI_P3_MAX, 510 .ngpio = LPC32XX_GPI_P3_MAX,
511 .names = gpi_p3_names, 511 .names = gpi_p3_names,
512 .can_sleep = 0, 512 .can_sleep = false,
513 }, 513 },
514 .gpio_grp = &gpio_grp_regs_p3, 514 .gpio_grp = &gpio_grp_regs_p3,
515 }, 515 },
@@ -523,7 +523,7 @@ static struct lpc32xx_gpio_chip lpc32xx_gpiochip[] = {
523 .base = LPC32XX_GPO_P3_GRP, 523 .base = LPC32XX_GPO_P3_GRP,
524 .ngpio = LPC32XX_GPO_P3_MAX, 524 .ngpio = LPC32XX_GPO_P3_MAX,
525 .names = gpo_p3_names, 525 .names = gpo_p3_names,
526 .can_sleep = 0, 526 .can_sleep = false,
527 }, 527 },
528 .gpio_grp = &gpio_grp_regs_p3, 528 .gpio_grp = &gpio_grp_regs_p3,
529 }, 529 },
diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c
index a0804740a0b7..66b18535b5ae 100644
--- a/drivers/gpio/gpio-lynxpoint.c
+++ b/drivers/gpio/gpio-lynxpoint.c
@@ -301,6 +301,26 @@ static void lp_irq_disable(struct irq_data *d)
301 spin_unlock_irqrestore(&lg->lock, flags); 301 spin_unlock_irqrestore(&lg->lock, flags);
302} 302}
303 303
304static unsigned int lp_irq_startup(struct irq_data *d)
305{
306 struct lp_gpio *lg = irq_data_get_irq_chip_data(d);
307
308 if (gpio_lock_as_irq(&lg->chip, irqd_to_hwirq(d)))
309 dev_err(lg->chip.dev,
310 "unable to lock HW IRQ %lu for IRQ\n",
311 irqd_to_hwirq(d));
312 lp_irq_enable(d);
313 return 0;
314}
315
316static void lp_irq_shutdown(struct irq_data *d)
317{
318 struct lp_gpio *lg = irq_data_get_irq_chip_data(d);
319
320 lp_irq_disable(d);
321 gpio_unlock_as_irq(&lg->chip, irqd_to_hwirq(d));
322}
323
304static struct irq_chip lp_irqchip = { 324static struct irq_chip lp_irqchip = {
305 .name = "LP-GPIO", 325 .name = "LP-GPIO",
306 .irq_mask = lp_irq_mask, 326 .irq_mask = lp_irq_mask,
@@ -308,6 +328,8 @@ static struct irq_chip lp_irqchip = {
308 .irq_enable = lp_irq_enable, 328 .irq_enable = lp_irq_enable,
309 .irq_disable = lp_irq_disable, 329 .irq_disable = lp_irq_disable,
310 .irq_set_type = lp_irq_type, 330 .irq_set_type = lp_irq_type,
331 .irq_startup = lp_irq_startup,
332 .irq_shutdown = lp_irq_shutdown,
311 .flags = IRQCHIP_SKIP_SET_WAKE, 333 .flags = IRQCHIP_SKIP_SET_WAKE,
312}; 334};
313 335
@@ -331,8 +353,7 @@ static int lp_gpio_irq_map(struct irq_domain *d, unsigned int irq,
331{ 353{
332 struct lp_gpio *lg = d->host_data; 354 struct lp_gpio *lg = d->host_data;
333 355
334 irq_set_chip_and_handler_name(irq, &lp_irqchip, handle_simple_irq, 356 irq_set_chip_and_handler(irq, &lp_irqchip, handle_simple_irq);
335 "demux");
336 irq_set_chip_data(irq, lg); 357 irq_set_chip_data(irq, lg);
337 irq_set_irq_type(irq, IRQ_TYPE_NONE); 358 irq_set_irq_type(irq, IRQ_TYPE_NONE);
338 359
@@ -392,7 +413,7 @@ static int lp_gpio_probe(struct platform_device *pdev)
392 gc->set = lp_gpio_set; 413 gc->set = lp_gpio_set;
393 gc->base = -1; 414 gc->base = -1;
394 gc->ngpio = LP_NUM_GPIO; 415 gc->ngpio = LP_NUM_GPIO;
395 gc->can_sleep = 0; 416 gc->can_sleep = false;
396 gc->dev = dev; 417 gc->dev = dev;
397 418
398 /* set up interrupts */ 419 /* set up interrupts */
@@ -438,6 +459,7 @@ static const struct dev_pm_ops lp_gpio_pm_ops = {
438 459
439static const struct acpi_device_id lynxpoint_gpio_acpi_match[] = { 460static const struct acpi_device_id lynxpoint_gpio_acpi_match[] = {
440 { "INT33C7", 0 }, 461 { "INT33C7", 0 },
462 { "INT3437", 0 },
441 { } 463 { }
442}; 464};
443MODULE_DEVICE_TABLE(acpi, lynxpoint_gpio_acpi_match); 465MODULE_DEVICE_TABLE(acpi, lynxpoint_gpio_acpi_match);
@@ -469,4 +491,15 @@ static int __init lp_gpio_init(void)
469 return platform_driver_register(&lp_gpio_driver); 491 return platform_driver_register(&lp_gpio_driver);
470} 492}
471 493
494static void __exit lp_gpio_exit(void)
495{
496 platform_driver_unregister(&lp_gpio_driver);
497}
498
472subsys_initcall(lp_gpio_init); 499subsys_initcall(lp_gpio_init);
500module_exit(lp_gpio_exit);
501
502MODULE_AUTHOR("Mathias Nyman (Intel)");
503MODULE_DESCRIPTION("GPIO interface for Intel Lynxpoint");
504MODULE_LICENSE("GPL");
505MODULE_ALIAS("platform:lp_gpio");
diff --git a/drivers/gpio/gpio-max730x.c b/drivers/gpio/gpio-max730x.c
index f4f4ed19bdc1..8672755f95c9 100644
--- a/drivers/gpio/gpio-max730x.c
+++ b/drivers/gpio/gpio-max730x.c
@@ -188,7 +188,7 @@ int __max730x_probe(struct max7301 *ts)
188 ts->chip.set = max7301_set; 188 ts->chip.set = max7301_set;
189 189
190 ts->chip.ngpio = PIN_NUMBER; 190 ts->chip.ngpio = PIN_NUMBER;
191 ts->chip.can_sleep = 1; 191 ts->chip.can_sleep = true;
192 ts->chip.dev = dev; 192 ts->chip.dev = dev;
193 ts->chip.owner = THIS_MODULE; 193 ts->chip.owner = THIS_MODULE;
194 194
@@ -220,7 +220,6 @@ int __max730x_probe(struct max7301 *ts)
220 return ret; 220 return ret;
221 221
222exit_destroy: 222exit_destroy:
223 dev_set_drvdata(dev, NULL);
224 mutex_destroy(&ts->lock); 223 mutex_destroy(&ts->lock);
225 return ret; 224 return ret;
226} 225}
@@ -234,8 +233,6 @@ int __max730x_remove(struct device *dev)
234 if (ts == NULL) 233 if (ts == NULL)
235 return -ENODEV; 234 return -ENODEV;
236 235
237 dev_set_drvdata(dev, NULL);
238
239 /* Power down the chip and disable IRQ output */ 236 /* Power down the chip and disable IRQ output */
240 ts->write(dev, 0x04, 0x00); 237 ts->write(dev, 0x04, 0x00);
241 238
diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c
index 91ad74dea8ce..36cb290764b6 100644
--- a/drivers/gpio/gpio-max732x.c
+++ b/drivers/gpio/gpio-max732x.c
@@ -564,7 +564,7 @@ static int max732x_setup_gpio(struct max732x_chip *chip,
564 gc->set = max732x_gpio_set_value; 564 gc->set = max732x_gpio_set_value;
565 } 565 }
566 gc->get = max732x_gpio_get_value; 566 gc->get = max732x_gpio_get_value;
567 gc->can_sleep = 1; 567 gc->can_sleep = true;
568 568
569 gc->base = gpio_start; 569 gc->base = gpio_start;
570 gc->ngpio = port; 570 gc->ngpio = port;
diff --git a/drivers/gpio/gpio-mc33880.c b/drivers/gpio/gpio-mc33880.c
index c0b7835f5136..553a80a5eaf3 100644
--- a/drivers/gpio/gpio-mc33880.c
+++ b/drivers/gpio/gpio-mc33880.c
@@ -115,7 +115,7 @@ static int mc33880_probe(struct spi_device *spi)
115 mc->chip.set = mc33880_set; 115 mc->chip.set = mc33880_set;
116 mc->chip.base = pdata->base; 116 mc->chip.base = pdata->base;
117 mc->chip.ngpio = PIN_NUMBER; 117 mc->chip.ngpio = PIN_NUMBER;
118 mc->chip.can_sleep = 1; 118 mc->chip.can_sleep = true;
119 mc->chip.dev = &spi->dev; 119 mc->chip.dev = &spi->dev;
120 mc->chip.owner = THIS_MODULE; 120 mc->chip.owner = THIS_MODULE;
121 121
diff --git a/drivers/gpio/gpio-mc9s08dz60.c b/drivers/gpio/gpio-mc9s08dz60.c
index 0ab700046a23..dce35ff00db7 100644
--- a/drivers/gpio/gpio-mc9s08dz60.c
+++ b/drivers/gpio/gpio-mc9s08dz60.c
@@ -102,7 +102,7 @@ static int mc9s08dz60_probe(struct i2c_client *client,
102 mc9s->chip.dev = &client->dev; 102 mc9s->chip.dev = &client->dev;
103 mc9s->chip.owner = THIS_MODULE; 103 mc9s->chip.owner = THIS_MODULE;
104 mc9s->chip.ngpio = GPIO_NUM; 104 mc9s->chip.ngpio = GPIO_NUM;
105 mc9s->chip.can_sleep = 1; 105 mc9s->chip.can_sleep = true;
106 mc9s->chip.get = mc9s08dz60_get_value; 106 mc9s->chip.get = mc9s08dz60_get_value;
107 mc9s->chip.set = mc9s08dz60_set_value; 107 mc9s->chip.set = mc9s08dz60_set_value;
108 mc9s->chip.direction_output = mc9s08dz60_direction_output; 108 mc9s->chip.direction_output = mc9s08dz60_direction_output;
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index 2deb0c5e54a4..1ac288ea810d 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -1,5 +1,13 @@
1/* 1/*
2 * MCP23S08 SPI/GPIO gpio expander driver 2 * MCP23S08 SPI/I2C GPIO gpio expander driver
3 *
4 * The inputs and outputs of the mcp23s08, mcp23s17, mcp23008 and mcp23017 are
5 * supported.
6 * For the I2C versions of the chips (mcp23008 and mcp23017) generation of
7 * interrupts is also supported.
8 * The hardware of the SPI versions of the chips (mcp23s08 and mcp23s17) is
9 * also capable of generating interrupts, but the linux driver does not
10 * support that yet.
3 */ 11 */
4 12
5#include <linux/kernel.h> 13#include <linux/kernel.h>
@@ -12,7 +20,8 @@
12#include <linux/spi/mcp23s08.h> 20#include <linux/spi/mcp23s08.h>
13#include <linux/slab.h> 21#include <linux/slab.h>
14#include <asm/byteorder.h> 22#include <asm/byteorder.h>
15#include <linux/of.h> 23#include <linux/interrupt.h>
24#include <linux/of_irq.h>
16#include <linux/of_device.h> 25#include <linux/of_device.h>
17 26
18/** 27/**
@@ -34,6 +43,7 @@
34#define MCP_DEFVAL 0x03 43#define MCP_DEFVAL 0x03
35#define MCP_INTCON 0x04 44#define MCP_INTCON 0x04
36#define MCP_IOCON 0x05 45#define MCP_IOCON 0x05
46# define IOCON_MIRROR (1 << 6)
37# define IOCON_SEQOP (1 << 5) 47# define IOCON_SEQOP (1 << 5)
38# define IOCON_HAEN (1 << 3) 48# define IOCON_HAEN (1 << 3)
39# define IOCON_ODR (1 << 2) 49# define IOCON_ODR (1 << 2)
@@ -57,8 +67,14 @@ struct mcp23s08 {
57 u8 addr; 67 u8 addr;
58 68
59 u16 cache[11]; 69 u16 cache[11];
70 u16 irq_rise;
71 u16 irq_fall;
72 int irq;
73 bool irq_controller;
60 /* lock protects the cached values */ 74 /* lock protects the cached values */
61 struct mutex lock; 75 struct mutex lock;
76 struct mutex irq_lock;
77 struct irq_domain *irq_domain;
62 78
63 struct gpio_chip chip; 79 struct gpio_chip chip;
64 80
@@ -77,6 +93,11 @@ struct mcp23s08_driver_data {
77 struct mcp23s08 chip[]; 93 struct mcp23s08 chip[];
78}; 94};
79 95
96/* This lock class tells lockdep that GPIO irqs are in a different
97 * category than their parents, so it won't report false recursion.
98 */
99static struct lock_class_key gpio_lock_class;
100
80/*----------------------------------------------------------------------*/ 101/*----------------------------------------------------------------------*/
81 102
82#if IS_ENABLED(CONFIG_I2C) 103#if IS_ENABLED(CONFIG_I2C)
@@ -316,6 +337,195 @@ mcp23s08_direction_output(struct gpio_chip *chip, unsigned offset, int value)
316} 337}
317 338
318/*----------------------------------------------------------------------*/ 339/*----------------------------------------------------------------------*/
340static irqreturn_t mcp23s08_irq(int irq, void *data)
341{
342 struct mcp23s08 *mcp = data;
343 int intcap, intf, i;
344 unsigned int child_irq;
345
346 mutex_lock(&mcp->lock);
347 intf = mcp->ops->read(mcp, MCP_INTF);
348 if (intf < 0) {
349 mutex_unlock(&mcp->lock);
350 return IRQ_HANDLED;
351 }
352
353 mcp->cache[MCP_INTF] = intf;
354
355 intcap = mcp->ops->read(mcp, MCP_INTCAP);
356 if (intcap < 0) {
357 mutex_unlock(&mcp->lock);
358 return IRQ_HANDLED;
359 }
360
361 mcp->cache[MCP_INTCAP] = intcap;
362 mutex_unlock(&mcp->lock);
363
364
365 for (i = 0; i < mcp->chip.ngpio; i++) {
366 if ((BIT(i) & mcp->cache[MCP_INTF]) &&
367 ((BIT(i) & intcap & mcp->irq_rise) ||
368 (mcp->irq_fall & ~intcap & BIT(i)))) {
369 child_irq = irq_find_mapping(mcp->irq_domain, i);
370 handle_nested_irq(child_irq);
371 }
372 }
373
374 return IRQ_HANDLED;
375}
376
377static int mcp23s08_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
378{
379 struct mcp23s08 *mcp = container_of(chip, struct mcp23s08, chip);
380
381 return irq_find_mapping(mcp->irq_domain, offset);
382}
383
384static void mcp23s08_irq_mask(struct irq_data *data)
385{
386 struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data);
387 unsigned int pos = data->hwirq;
388
389 mcp->cache[MCP_GPINTEN] &= ~BIT(pos);
390}
391
392static void mcp23s08_irq_unmask(struct irq_data *data)
393{
394 struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data);
395 unsigned int pos = data->hwirq;
396
397 mcp->cache[MCP_GPINTEN] |= BIT(pos);
398}
399
400static int mcp23s08_irq_set_type(struct irq_data *data, unsigned int type)
401{
402 struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data);
403 unsigned int pos = data->hwirq;
404 int status = 0;
405
406 if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
407 mcp->cache[MCP_INTCON] &= ~BIT(pos);
408 mcp->irq_rise |= BIT(pos);
409 mcp->irq_fall |= BIT(pos);
410 } else if (type & IRQ_TYPE_EDGE_RISING) {
411 mcp->cache[MCP_INTCON] &= ~BIT(pos);
412 mcp->irq_rise |= BIT(pos);
413 mcp->irq_fall &= ~BIT(pos);
414 } else if (type & IRQ_TYPE_EDGE_FALLING) {
415 mcp->cache[MCP_INTCON] &= ~BIT(pos);
416 mcp->irq_rise &= ~BIT(pos);
417 mcp->irq_fall |= BIT(pos);
418 } else
419 return -EINVAL;
420
421 return status;
422}
423
424static void mcp23s08_irq_bus_lock(struct irq_data *data)
425{
426 struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data);
427
428 mutex_lock(&mcp->irq_lock);
429}
430
431static void mcp23s08_irq_bus_unlock(struct irq_data *data)
432{
433 struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data);
434
435 mutex_lock(&mcp->lock);
436 mcp->ops->write(mcp, MCP_GPINTEN, mcp->cache[MCP_GPINTEN]);
437 mcp->ops->write(mcp, MCP_DEFVAL, mcp->cache[MCP_DEFVAL]);
438 mcp->ops->write(mcp, MCP_INTCON, mcp->cache[MCP_INTCON]);
439 mutex_unlock(&mcp->lock);
440 mutex_unlock(&mcp->irq_lock);
441}
442
443static unsigned int mcp23s08_irq_startup(struct irq_data *data)
444{
445 struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data);
446
447 if (gpio_lock_as_irq(&mcp->chip, data->hwirq))
448 dev_err(mcp->chip.dev,
449 "unable to lock HW IRQ %lu for IRQ usage\n",
450 data->hwirq);
451
452 mcp23s08_irq_unmask(data);
453 return 0;
454}
455
456static void mcp23s08_irq_shutdown(struct irq_data *data)
457{
458 struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data);
459
460 mcp23s08_irq_mask(data);
461 gpio_unlock_as_irq(&mcp->chip, data->hwirq);
462}
463
464static struct irq_chip mcp23s08_irq_chip = {
465 .name = "gpio-mcp23xxx",
466 .irq_mask = mcp23s08_irq_mask,
467 .irq_unmask = mcp23s08_irq_unmask,
468 .irq_set_type = mcp23s08_irq_set_type,
469 .irq_bus_lock = mcp23s08_irq_bus_lock,
470 .irq_bus_sync_unlock = mcp23s08_irq_bus_unlock,
471 .irq_startup = mcp23s08_irq_startup,
472 .irq_shutdown = mcp23s08_irq_shutdown,
473};
474
475static int mcp23s08_irq_setup(struct mcp23s08 *mcp)
476{
477 struct gpio_chip *chip = &mcp->chip;
478 int err, irq, j;
479
480 mutex_init(&mcp->irq_lock);
481
482 mcp->irq_domain = irq_domain_add_linear(chip->of_node, chip->ngpio,
483 &irq_domain_simple_ops, mcp);
484 if (!mcp->irq_domain)
485 return -ENODEV;
486
487 err = devm_request_threaded_irq(chip->dev, mcp->irq, NULL, mcp23s08_irq,
488 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
489 dev_name(chip->dev), mcp);
490 if (err != 0) {
491 dev_err(chip->dev, "unable to request IRQ#%d: %d\n",
492 mcp->irq, err);
493 return err;
494 }
495
496 chip->to_irq = mcp23s08_gpio_to_irq;
497
498 for (j = 0; j < mcp->chip.ngpio; j++) {
499 irq = irq_create_mapping(mcp->irq_domain, j);
500 irq_set_lockdep_class(irq, &gpio_lock_class);
501 irq_set_chip_data(irq, mcp);
502 irq_set_chip(irq, &mcp23s08_irq_chip);
503 irq_set_nested_thread(irq, true);
504#ifdef CONFIG_ARM
505 set_irq_flags(irq, IRQF_VALID);
506#else
507 irq_set_noprobe(irq);
508#endif
509 }
510 return 0;
511}
512
513static void mcp23s08_irq_teardown(struct mcp23s08 *mcp)
514{
515 unsigned int irq, i;
516
517 free_irq(mcp->irq, mcp);
518
519 for (i = 0; i < mcp->chip.ngpio; i++) {
520 irq = irq_find_mapping(mcp->irq_domain, i);
521 if (irq > 0)
522 irq_dispose_mapping(irq);
523 }
524
525 irq_domain_remove(mcp->irq_domain);
526}
527
528/*----------------------------------------------------------------------*/
319 529
320#ifdef CONFIG_DEBUG_FS 530#ifdef CONFIG_DEBUG_FS
321 531
@@ -370,10 +580,11 @@ done:
370/*----------------------------------------------------------------------*/ 580/*----------------------------------------------------------------------*/
371 581
372static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, 582static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
373 void *data, unsigned addr, 583 void *data, unsigned addr, unsigned type,
374 unsigned type, unsigned base, unsigned pullups) 584 unsigned base, unsigned pullups)
375{ 585{
376 int status; 586 int status;
587 bool mirror = false;
377 588
378 mutex_init(&mcp->lock); 589 mutex_init(&mcp->lock);
379 590
@@ -425,20 +636,32 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
425 } 636 }
426 637
427 mcp->chip.base = base; 638 mcp->chip.base = base;
428 mcp->chip.can_sleep = 1; 639 mcp->chip.can_sleep = true;
429 mcp->chip.dev = dev; 640 mcp->chip.dev = dev;
430 mcp->chip.owner = THIS_MODULE; 641 mcp->chip.owner = THIS_MODULE;
431 642
432 /* verify MCP_IOCON.SEQOP = 0, so sequential reads work, 643 /* verify MCP_IOCON.SEQOP = 0, so sequential reads work,
433 * and MCP_IOCON.HAEN = 1, so we work with all chips. 644 * and MCP_IOCON.HAEN = 1, so we work with all chips.
434 */ 645 */
646
435 status = mcp->ops->read(mcp, MCP_IOCON); 647 status = mcp->ops->read(mcp, MCP_IOCON);
436 if (status < 0) 648 if (status < 0)
437 goto fail; 649 goto fail;
438 if ((status & IOCON_SEQOP) || !(status & IOCON_HAEN)) { 650
651 mcp->irq_controller = of_property_read_bool(mcp->chip.of_node,
652 "interrupt-controller");
653 if (mcp->irq && mcp->irq_controller && (type == MCP_TYPE_017))
654 mirror = of_property_read_bool(mcp->chip.of_node,
655 "microchip,irq-mirror");
656
657 if ((status & IOCON_SEQOP) || !(status & IOCON_HAEN) || mirror) {
439 /* mcp23s17 has IOCON twice, make sure they are in sync */ 658 /* mcp23s17 has IOCON twice, make sure they are in sync */
440 status &= ~(IOCON_SEQOP | (IOCON_SEQOP << 8)); 659 status &= ~(IOCON_SEQOP | (IOCON_SEQOP << 8));
441 status |= IOCON_HAEN | (IOCON_HAEN << 8); 660 status |= IOCON_HAEN | (IOCON_HAEN << 8);
661 status &= ~(IOCON_INTPOL | (IOCON_INTPOL << 8));
662 if (mirror)
663 status |= IOCON_MIRROR | (IOCON_MIRROR << 8);
664
442 status = mcp->ops->write(mcp, MCP_IOCON, status); 665 status = mcp->ops->write(mcp, MCP_IOCON, status);
443 if (status < 0) 666 if (status < 0)
444 goto fail; 667 goto fail;
@@ -470,6 +693,16 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
470 } 693 }
471 694
472 status = gpiochip_add(&mcp->chip); 695 status = gpiochip_add(&mcp->chip);
696 if (status < 0)
697 goto fail;
698
699 if (mcp->irq && mcp->irq_controller) {
700 status = mcp23s08_irq_setup(mcp);
701 if (status) {
702 mcp23s08_irq_teardown(mcp);
703 goto fail;
704 }
705 }
473fail: 706fail:
474 if (status < 0) 707 if (status < 0)
475 dev_dbg(dev, "can't setup chip %d, --> %d\n", 708 dev_dbg(dev, "can't setup chip %d, --> %d\n",
@@ -546,6 +779,7 @@ static int mcp230xx_probe(struct i2c_client *client,
546 if (match || !pdata) { 779 if (match || !pdata) {
547 base = -1; 780 base = -1;
548 pullups = 0; 781 pullups = 0;
782 client->irq = irq_of_parse_and_map(client->dev.of_node, 0);
549 } else { 783 } else {
550 if (!gpio_is_valid(pdata->base)) { 784 if (!gpio_is_valid(pdata->base)) {
551 dev_dbg(&client->dev, "invalid platform data\n"); 785 dev_dbg(&client->dev, "invalid platform data\n");
@@ -559,6 +793,7 @@ static int mcp230xx_probe(struct i2c_client *client,
559 if (!mcp) 793 if (!mcp)
560 return -ENOMEM; 794 return -ENOMEM;
561 795
796 mcp->irq = client->irq;
562 status = mcp23s08_probe_one(mcp, &client->dev, client, client->addr, 797 status = mcp23s08_probe_one(mcp, &client->dev, client, client->addr,
563 id->driver_data, base, pullups); 798 id->driver_data, base, pullups);
564 if (status) 799 if (status)
@@ -579,6 +814,9 @@ static int mcp230xx_remove(struct i2c_client *client)
579 struct mcp23s08 *mcp = i2c_get_clientdata(client); 814 struct mcp23s08 *mcp = i2c_get_clientdata(client);
580 int status; 815 int status;
581 816
817 if (client->irq && mcp->irq_controller)
818 mcp23s08_irq_teardown(mcp);
819
582 status = gpiochip_remove(&mcp->chip); 820 status = gpiochip_remove(&mcp->chip);
583 if (status == 0) 821 if (status == 0)
584 kfree(mcp); 822 kfree(mcp);
@@ -640,7 +878,7 @@ static int mcp23s08_probe(struct spi_device *spi)
640 878
641 match = of_match_device(of_match_ptr(mcp23s08_spi_of_match), &spi->dev); 879 match = of_match_device(of_match_ptr(mcp23s08_spi_of_match), &spi->dev);
642 if (match) { 880 if (match) {
643 type = (int)match->data; 881 type = (int)(uintptr_t)match->data;
644 status = of_property_read_u32(spi->dev.of_node, 882 status = of_property_read_u32(spi->dev.of_node,
645 "microchip,spi-present-mask", &spi_present_mask); 883 "microchip,spi-present-mask", &spi_present_mask);
646 if (status) { 884 if (status) {
diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c
index 6da6d7667c6d..d51329d23d38 100644
--- a/drivers/gpio/gpio-ml-ioh.c
+++ b/drivers/gpio/gpio-ml-ioh.c
@@ -242,7 +242,7 @@ static void ioh_gpio_setup(struct ioh_gpio *chip, int num_port)
242 gpio->dbg_show = NULL; 242 gpio->dbg_show = NULL;
243 gpio->base = -1; 243 gpio->base = -1;
244 gpio->ngpio = num_port; 244 gpio->ngpio = num_port;
245 gpio->can_sleep = 0; 245 gpio->can_sleep = false;
246 gpio->to_irq = ioh_gpio_to_irq; 246 gpio->to_irq = ioh_gpio_to_irq;
247} 247}
248 248
@@ -596,7 +596,7 @@ static int ioh_gpio_resume(struct pci_dev *pdev)
596#define ioh_gpio_resume NULL 596#define ioh_gpio_resume NULL
597#endif 597#endif
598 598
599static DEFINE_PCI_DEVICE_TABLE(ioh_gpio_pcidev_id) = { 599static const struct pci_device_id ioh_gpio_pcidev_id[] = {
600 { PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x802E) }, 600 { PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x802E) },
601 { 0, } 601 { 0, }
602}; 602};
diff --git a/drivers/gpio/gpio-moxart.c b/drivers/gpio/gpio-moxart.c
new file mode 100644
index 000000000000..2af990022cc9
--- /dev/null
+++ b/drivers/gpio/gpio-moxart.c
@@ -0,0 +1,156 @@
1/*
2 * MOXA ART SoCs GPIO driver.
3 *
4 * Copyright (C) 2013 Jonas Jensen
5 *
6 * Jonas Jensen <jonas.jensen@gmail.com>
7 *
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
11 */
12
13#include <linux/err.h>
14#include <linux/init.h>
15#include <linux/irq.h>
16#include <linux/io.h>
17#include <linux/gpio.h>
18#include <linux/platform_device.h>
19#include <linux/module.h>
20#include <linux/of_address.h>
21#include <linux/of_gpio.h>
22#include <linux/pinctrl/consumer.h>
23#include <linux/delay.h>
24#include <linux/timer.h>
25#include <linux/bitops.h>
26
27#define GPIO_DATA_OUT 0x00
28#define GPIO_DATA_IN 0x04
29#define GPIO_PIN_DIRECTION 0x08
30
31struct moxart_gpio_chip {
32 struct gpio_chip gpio;
33 void __iomem *base;
34};
35
36static inline struct moxart_gpio_chip *to_moxart_gpio(struct gpio_chip *chip)
37{
38 return container_of(chip, struct moxart_gpio_chip, gpio);
39}
40
41static int moxart_gpio_request(struct gpio_chip *chip, unsigned offset)
42{
43 return pinctrl_request_gpio(offset);
44}
45
46static void moxart_gpio_free(struct gpio_chip *chip, unsigned offset)
47{
48 pinctrl_free_gpio(offset);
49}
50
51static int moxart_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
52{
53 struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
54 void __iomem *ioaddr = gc->base + GPIO_PIN_DIRECTION;
55
56 writel(readl(ioaddr) & ~BIT(offset), ioaddr);
57 return 0;
58}
59
60static int moxart_gpio_direction_output(struct gpio_chip *chip,
61 unsigned offset, int value)
62{
63 struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
64 void __iomem *ioaddr = gc->base + GPIO_PIN_DIRECTION;
65
66 writel(readl(ioaddr) | BIT(offset), ioaddr);
67 return 0;
68}
69
70static void moxart_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
71{
72 struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
73 void __iomem *ioaddr = gc->base + GPIO_DATA_OUT;
74 u32 reg = readl(ioaddr);
75
76 if (value)
77 reg = reg | BIT(offset);
78 else
79 reg = reg & ~BIT(offset);
80
81
82 writel(reg, ioaddr);
83}
84
85static int moxart_gpio_get(struct gpio_chip *chip, unsigned offset)
86{
87 struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
88 u32 ret = readl(gc->base + GPIO_PIN_DIRECTION);
89
90 if (ret & BIT(offset))
91 return !!(readl(gc->base + GPIO_DATA_OUT) & BIT(offset));
92 else
93 return !!(readl(gc->base + GPIO_DATA_IN) & BIT(offset));
94}
95
96static struct gpio_chip moxart_template_chip = {
97 .label = "moxart-gpio",
98 .request = moxart_gpio_request,
99 .free = moxart_gpio_free,
100 .direction_input = moxart_gpio_direction_input,
101 .direction_output = moxart_gpio_direction_output,
102 .set = moxart_gpio_set,
103 .get = moxart_gpio_get,
104 .ngpio = 32,
105 .owner = THIS_MODULE,
106};
107
108static int moxart_gpio_probe(struct platform_device *pdev)
109{
110 struct device *dev = &pdev->dev;
111 struct resource *res;
112 struct moxart_gpio_chip *mgc;
113 int ret;
114
115 mgc = devm_kzalloc(dev, sizeof(*mgc), GFP_KERNEL);
116 if (!mgc) {
117 dev_err(dev, "can't allocate GPIO chip container\n");
118 return -ENOMEM;
119 }
120 mgc->gpio = moxart_template_chip;
121
122 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
123 mgc->base = devm_ioremap_resource(dev, res);
124 if (IS_ERR(mgc->base))
125 return PTR_ERR(mgc->base);
126
127 mgc->gpio.dev = dev;
128
129 ret = gpiochip_add(&mgc->gpio);
130 if (ret) {
131 dev_err(dev, "%s: gpiochip_add failed\n",
132 dev->of_node->full_name);
133 return ret;
134 }
135
136 return 0;
137}
138
139static const struct of_device_id moxart_gpio_match[] = {
140 { .compatible = "moxa,moxart-gpio" },
141 { }
142};
143
144static struct platform_driver moxart_gpio_driver = {
145 .driver = {
146 .name = "moxart-gpio",
147 .owner = THIS_MODULE,
148 .of_match_table = moxart_gpio_match,
149 },
150 .probe = moxart_gpio_probe,
151};
152module_platform_driver(moxart_gpio_driver);
153
154MODULE_DESCRIPTION("MOXART GPIO chip driver");
155MODULE_LICENSE("GPL");
156MODULE_AUTHOR("Jonas Jensen <jonas.jensen@gmail.com>");
diff --git a/drivers/gpio/gpio-msic.c b/drivers/gpio/gpio-msic.c
index d75eaa3a1dcc..8f70ded82a2b 100644
--- a/drivers/gpio/gpio-msic.c
+++ b/drivers/gpio/gpio-msic.c
@@ -292,7 +292,7 @@ static int platform_msic_gpio_probe(struct platform_device *pdev)
292 mg->chip.to_irq = msic_gpio_to_irq; 292 mg->chip.to_irq = msic_gpio_to_irq;
293 mg->chip.base = pdata->gpio_base; 293 mg->chip.base = pdata->gpio_base;
294 mg->chip.ngpio = MSIC_NUM_GPIO; 294 mg->chip.ngpio = MSIC_NUM_GPIO;
295 mg->chip.can_sleep = 1; 295 mg->chip.can_sleep = true;
296 mg->chip.dev = dev; 296 mg->chip.dev = dev;
297 297
298 mutex_init(&mg->buslock); 298 mutex_init(&mg->buslock);
@@ -305,10 +305,9 @@ static int platform_msic_gpio_probe(struct platform_device *pdev)
305 305
306 for (i = 0; i < mg->chip.ngpio; i++) { 306 for (i = 0; i < mg->chip.ngpio; i++) {
307 irq_set_chip_data(i + mg->irq_base, mg); 307 irq_set_chip_data(i + mg->irq_base, mg);
308 irq_set_chip_and_handler_name(i + mg->irq_base, 308 irq_set_chip_and_handler(i + mg->irq_base,
309 &msic_irqchip, 309 &msic_irqchip,
310 handle_simple_irq, 310 handle_simple_irq);
311 "demux");
312 } 311 }
313 irq_set_chained_handler(mg->irq, msic_gpio_irq_handler); 312 irq_set_chained_handler(mg->irq, msic_gpio_irq_handler);
314 irq_set_handler_data(mg->irq, mg); 313 irq_set_handler_data(mg->irq, mg);
diff --git a/drivers/gpio/gpio-msm-v2.c b/drivers/gpio/gpio-msm-v2.c
index 2baf0ddf7e02..a3351acd4963 100644
--- a/drivers/gpio/gpio-msm-v2.c
+++ b/drivers/gpio/gpio-msm-v2.c
@@ -430,10 +430,11 @@ static int msm_gpio_probe(struct platform_device *pdev)
430 return 0; 430 return 0;
431} 431}
432 432
433static struct of_device_id msm_gpio_of_match[] = { 433static const struct of_device_id msm_gpio_of_match[] = {
434 { .compatible = "qcom,msm-gpio", }, 434 { .compatible = "qcom,msm-gpio", },
435 { }, 435 { },
436}; 436};
437MODULE_DEVICE_TABLE(of, msm_gpio_of_match);
437 438
438static int msm_gpio_remove(struct platform_device *dev) 439static int msm_gpio_remove(struct platform_device *dev)
439{ 440{
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index db3129043e63..3b1fd1ce460f 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -600,7 +600,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
600 mvchip->chip.to_irq = mvebu_gpio_to_irq; 600 mvchip->chip.to_irq = mvebu_gpio_to_irq;
601 mvchip->chip.base = id * MVEBU_MAX_GPIO_PER_BANK; 601 mvchip->chip.base = id * MVEBU_MAX_GPIO_PER_BANK;
602 mvchip->chip.ngpio = ngpios; 602 mvchip->chip.ngpio = ngpios;
603 mvchip->chip.can_sleep = 0; 603 mvchip->chip.can_sleep = false;
604 mvchip->chip.of_node = np; 604 mvchip->chip.of_node = np;
605 mvchip->chip.dbg_show = mvebu_gpio_dbg_show; 605 mvchip->chip.dbg_show = mvebu_gpio_dbg_show;
606 606
@@ -676,7 +676,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
676 mvchip->irqbase = irq_alloc_descs(-1, 0, ngpios, -1); 676 mvchip->irqbase = irq_alloc_descs(-1, 0, ngpios, -1);
677 if (mvchip->irqbase < 0) { 677 if (mvchip->irqbase < 0) {
678 dev_err(&pdev->dev, "no irqs\n"); 678 dev_err(&pdev->dev, "no irqs\n");
679 return -ENOMEM; 679 return mvchip->irqbase;
680 } 680 }
681 681
682 gc = irq_alloc_generic_chip("mvebu_gpio_irq", 2, mvchip->irqbase, 682 gc = irq_alloc_generic_chip("mvebu_gpio_irq", 2, mvchip->irqbase,
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 3307f6db3a92..db83b3c0a449 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -422,7 +422,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
422 port->irq_high = platform_get_irq(pdev, 1); 422 port->irq_high = platform_get_irq(pdev, 1);
423 port->irq = platform_get_irq(pdev, 0); 423 port->irq = platform_get_irq(pdev, 0);
424 if (port->irq < 0) 424 if (port->irq < 0)
425 return -EINVAL; 425 return port->irq;
426 426
427 /* disable the interrupt and clear the status */ 427 /* disable the interrupt and clear the status */
428 writel(0, port->base + GPIO_IMR); 428 writel(0, port->base + GPIO_IMR);
diff --git a/drivers/gpio/gpio-octeon.c b/drivers/gpio/gpio-octeon.c
index 71a4a318315d..dbb08546b9ec 100644
--- a/drivers/gpio/gpio-octeon.c
+++ b/drivers/gpio/gpio-octeon.c
@@ -111,7 +111,7 @@ static int octeon_gpio_probe(struct platform_device *pdev)
111 chip->dev = &pdev->dev; 111 chip->dev = &pdev->dev;
112 chip->owner = THIS_MODULE; 112 chip->owner = THIS_MODULE;
113 chip->base = 0; 113 chip->base = 0;
114 chip->can_sleep = 0; 114 chip->can_sleep = false;
115 chip->ngpio = 20; 115 chip->ngpio = 20;
116 chip->direction_input = octeon_gpio_dir_in; 116 chip->direction_input = octeon_gpio_dir_in;
117 chip->get = octeon_gpio_get; 117 chip->get = octeon_gpio_get;
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index f319c9ffd4a8..424319061e09 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -108,12 +108,12 @@ static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int is_input)
108 u32 l; 108 u32 l;
109 109
110 reg += bank->regs->direction; 110 reg += bank->regs->direction;
111 l = __raw_readl(reg); 111 l = readl_relaxed(reg);
112 if (is_input) 112 if (is_input)
113 l |= 1 << gpio; 113 l |= 1 << gpio;
114 else 114 else
115 l &= ~(1 << gpio); 115 l &= ~(1 << gpio);
116 __raw_writel(l, reg); 116 writel_relaxed(l, reg);
117 bank->context.oe = l; 117 bank->context.oe = l;
118} 118}
119 119
@@ -132,7 +132,7 @@ static void _set_gpio_dataout_reg(struct gpio_bank *bank, int gpio, int enable)
132 bank->context.dataout &= ~l; 132 bank->context.dataout &= ~l;
133 } 133 }
134 134
135 __raw_writel(l, reg); 135 writel_relaxed(l, reg);
136} 136}
137 137
138/* set data out value using mask register */ 138/* set data out value using mask register */
@@ -142,12 +142,12 @@ static void _set_gpio_dataout_mask(struct gpio_bank *bank, int gpio, int enable)
142 u32 gpio_bit = GPIO_BIT(bank, gpio); 142 u32 gpio_bit = GPIO_BIT(bank, gpio);
143 u32 l; 143 u32 l;
144 144
145 l = __raw_readl(reg); 145 l = readl_relaxed(reg);
146 if (enable) 146 if (enable)
147 l |= gpio_bit; 147 l |= gpio_bit;
148 else 148 else
149 l &= ~gpio_bit; 149 l &= ~gpio_bit;
150 __raw_writel(l, reg); 150 writel_relaxed(l, reg);
151 bank->context.dataout = l; 151 bank->context.dataout = l;
152} 152}
153 153
@@ -155,26 +155,26 @@ static int _get_gpio_datain(struct gpio_bank *bank, int offset)
155{ 155{
156 void __iomem *reg = bank->base + bank->regs->datain; 156 void __iomem *reg = bank->base + bank->regs->datain;
157 157
158 return (__raw_readl(reg) & (1 << offset)) != 0; 158 return (readl_relaxed(reg) & (1 << offset)) != 0;
159} 159}
160 160
161static int _get_gpio_dataout(struct gpio_bank *bank, int offset) 161static int _get_gpio_dataout(struct gpio_bank *bank, int offset)
162{ 162{
163 void __iomem *reg = bank->base + bank->regs->dataout; 163 void __iomem *reg = bank->base + bank->regs->dataout;
164 164
165 return (__raw_readl(reg) & (1 << offset)) != 0; 165 return (readl_relaxed(reg) & (1 << offset)) != 0;
166} 166}
167 167
168static inline void _gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set) 168static inline void _gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set)
169{ 169{
170 int l = __raw_readl(base + reg); 170 int l = readl_relaxed(base + reg);
171 171
172 if (set) 172 if (set)
173 l |= mask; 173 l |= mask;
174 else 174 else
175 l &= ~mask; 175 l &= ~mask;
176 176
177 __raw_writel(l, base + reg); 177 writel_relaxed(l, base + reg);
178} 178}
179 179
180static inline void _gpio_dbck_enable(struct gpio_bank *bank) 180static inline void _gpio_dbck_enable(struct gpio_bank *bank)
@@ -183,7 +183,7 @@ static inline void _gpio_dbck_enable(struct gpio_bank *bank)
183 clk_enable(bank->dbck); 183 clk_enable(bank->dbck);
184 bank->dbck_enabled = true; 184 bank->dbck_enabled = true;
185 185
186 __raw_writel(bank->dbck_enable_mask, 186 writel_relaxed(bank->dbck_enable_mask,
187 bank->base + bank->regs->debounce_en); 187 bank->base + bank->regs->debounce_en);
188 } 188 }
189} 189}
@@ -196,7 +196,7 @@ static inline void _gpio_dbck_disable(struct gpio_bank *bank)
196 * enabled but the clock is not, GPIO module seems to be unable 196 * enabled but the clock is not, GPIO module seems to be unable
197 * to detect events and generate interrupts at least on OMAP3. 197 * to detect events and generate interrupts at least on OMAP3.
198 */ 198 */
199 __raw_writel(0, bank->base + bank->regs->debounce_en); 199 writel_relaxed(0, bank->base + bank->regs->debounce_en);
200 200
201 clk_disable(bank->dbck); 201 clk_disable(bank->dbck);
202 bank->dbck_enabled = false; 202 bank->dbck_enabled = false;
@@ -233,10 +233,10 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
233 233
234 clk_enable(bank->dbck); 234 clk_enable(bank->dbck);
235 reg = bank->base + bank->regs->debounce; 235 reg = bank->base + bank->regs->debounce;
236 __raw_writel(debounce, reg); 236 writel_relaxed(debounce, reg);
237 237
238 reg = bank->base + bank->regs->debounce_en; 238 reg = bank->base + bank->regs->debounce_en;
239 val = __raw_readl(reg); 239 val = readl_relaxed(reg);
240 240
241 if (debounce) 241 if (debounce)
242 val |= l; 242 val |= l;
@@ -244,7 +244,7 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
244 val &= ~l; 244 val &= ~l;
245 bank->dbck_enable_mask = val; 245 bank->dbck_enable_mask = val;
246 246
247 __raw_writel(val, reg); 247 writel_relaxed(val, reg);
248 clk_disable(bank->dbck); 248 clk_disable(bank->dbck);
249 /* 249 /*
250 * Enable debounce clock per module. 250 * Enable debounce clock per module.
@@ -283,12 +283,12 @@ static void _clear_gpio_debounce(struct gpio_bank *bank, unsigned gpio)
283 283
284 bank->dbck_enable_mask &= ~gpio_bit; 284 bank->dbck_enable_mask &= ~gpio_bit;
285 bank->context.debounce_en &= ~gpio_bit; 285 bank->context.debounce_en &= ~gpio_bit;
286 __raw_writel(bank->context.debounce_en, 286 writel_relaxed(bank->context.debounce_en,
287 bank->base + bank->regs->debounce_en); 287 bank->base + bank->regs->debounce_en);
288 288
289 if (!bank->dbck_enable_mask) { 289 if (!bank->dbck_enable_mask) {
290 bank->context.debounce = 0; 290 bank->context.debounce = 0;
291 __raw_writel(bank->context.debounce, bank->base + 291 writel_relaxed(bank->context.debounce, bank->base +
292 bank->regs->debounce); 292 bank->regs->debounce);
293 clk_disable(bank->dbck); 293 clk_disable(bank->dbck);
294 bank->dbck_enabled = false; 294 bank->dbck_enabled = false;
@@ -311,18 +311,18 @@ static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
311 trigger & IRQ_TYPE_EDGE_FALLING); 311 trigger & IRQ_TYPE_EDGE_FALLING);
312 312
313 bank->context.leveldetect0 = 313 bank->context.leveldetect0 =
314 __raw_readl(bank->base + bank->regs->leveldetect0); 314 readl_relaxed(bank->base + bank->regs->leveldetect0);
315 bank->context.leveldetect1 = 315 bank->context.leveldetect1 =
316 __raw_readl(bank->base + bank->regs->leveldetect1); 316 readl_relaxed(bank->base + bank->regs->leveldetect1);
317 bank->context.risingdetect = 317 bank->context.risingdetect =
318 __raw_readl(bank->base + bank->regs->risingdetect); 318 readl_relaxed(bank->base + bank->regs->risingdetect);
319 bank->context.fallingdetect = 319 bank->context.fallingdetect =
320 __raw_readl(bank->base + bank->regs->fallingdetect); 320 readl_relaxed(bank->base + bank->regs->fallingdetect);
321 321
322 if (likely(!(bank->non_wakeup_gpios & gpio_bit))) { 322 if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {
323 _gpio_rmw(base, bank->regs->wkup_en, gpio_bit, trigger != 0); 323 _gpio_rmw(base, bank->regs->wkup_en, gpio_bit, trigger != 0);
324 bank->context.wake_en = 324 bank->context.wake_en =
325 __raw_readl(bank->base + bank->regs->wkup_en); 325 readl_relaxed(bank->base + bank->regs->wkup_en);
326 } 326 }
327 327
328 /* This part needs to be executed always for OMAP{34xx, 44xx} */ 328 /* This part needs to be executed always for OMAP{34xx, 44xx} */
@@ -347,8 +347,8 @@ static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
347 347
348exit: 348exit:
349 bank->level_mask = 349 bank->level_mask =
350 __raw_readl(bank->base + bank->regs->leveldetect0) | 350 readl_relaxed(bank->base + bank->regs->leveldetect0) |
351 __raw_readl(bank->base + bank->regs->leveldetect1); 351 readl_relaxed(bank->base + bank->regs->leveldetect1);
352} 352}
353 353
354#ifdef CONFIG_ARCH_OMAP1 354#ifdef CONFIG_ARCH_OMAP1
@@ -366,13 +366,13 @@ static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio)
366 366
367 reg += bank->regs->irqctrl; 367 reg += bank->regs->irqctrl;
368 368
369 l = __raw_readl(reg); 369 l = readl_relaxed(reg);
370 if ((l >> gpio) & 1) 370 if ((l >> gpio) & 1)
371 l &= ~(1 << gpio); 371 l &= ~(1 << gpio);
372 else 372 else
373 l |= 1 << gpio; 373 l |= 1 << gpio;
374 374
375 __raw_writel(l, reg); 375 writel_relaxed(l, reg);
376} 376}
377#else 377#else
378static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) {} 378static void _toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) {}
@@ -390,7 +390,7 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
390 } else if (bank->regs->irqctrl) { 390 } else if (bank->regs->irqctrl) {
391 reg += bank->regs->irqctrl; 391 reg += bank->regs->irqctrl;
392 392
393 l = __raw_readl(reg); 393 l = readl_relaxed(reg);
394 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH) 394 if ((trigger & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_EDGE_BOTH)
395 bank->toggle_mask |= 1 << gpio; 395 bank->toggle_mask |= 1 << gpio;
396 if (trigger & IRQ_TYPE_EDGE_RISING) 396 if (trigger & IRQ_TYPE_EDGE_RISING)
@@ -400,7 +400,7 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
400 else 400 else
401 return -EINVAL; 401 return -EINVAL;
402 402
403 __raw_writel(l, reg); 403 writel_relaxed(l, reg);
404 } else if (bank->regs->edgectrl1) { 404 } else if (bank->regs->edgectrl1) {
405 if (gpio & 0x08) 405 if (gpio & 0x08)
406 reg += bank->regs->edgectrl2; 406 reg += bank->regs->edgectrl2;
@@ -408,7 +408,7 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
408 reg += bank->regs->edgectrl1; 408 reg += bank->regs->edgectrl1;
409 409
410 gpio &= 0x07; 410 gpio &= 0x07;
411 l = __raw_readl(reg); 411 l = readl_relaxed(reg);
412 l &= ~(3 << (gpio << 1)); 412 l &= ~(3 << (gpio << 1));
413 if (trigger & IRQ_TYPE_EDGE_RISING) 413 if (trigger & IRQ_TYPE_EDGE_RISING)
414 l |= 2 << (gpio << 1); 414 l |= 2 << (gpio << 1);
@@ -418,8 +418,8 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int gpio,
418 /* Enable wake-up during idle for dynamic tick */ 418 /* Enable wake-up during idle for dynamic tick */
419 _gpio_rmw(base, bank->regs->wkup_en, 1 << gpio, trigger); 419 _gpio_rmw(base, bank->regs->wkup_en, 1 << gpio, trigger);
420 bank->context.wake_en = 420 bank->context.wake_en =
421 __raw_readl(bank->base + bank->regs->wkup_en); 421 readl_relaxed(bank->base + bank->regs->wkup_en);
422 __raw_writel(l, reg); 422 writel_relaxed(l, reg);
423 } 423 }
424 return 0; 424 return 0;
425} 425}
@@ -430,17 +430,17 @@ static void _enable_gpio_module(struct gpio_bank *bank, unsigned offset)
430 void __iomem *reg = bank->base + bank->regs->pinctrl; 430 void __iomem *reg = bank->base + bank->regs->pinctrl;
431 431
432 /* Claim the pin for MPU */ 432 /* Claim the pin for MPU */
433 __raw_writel(__raw_readl(reg) | (1 << offset), reg); 433 writel_relaxed(readl_relaxed(reg) | (1 << offset), reg);
434 } 434 }
435 435
436 if (bank->regs->ctrl && !BANK_USED(bank)) { 436 if (bank->regs->ctrl && !BANK_USED(bank)) {
437 void __iomem *reg = bank->base + bank->regs->ctrl; 437 void __iomem *reg = bank->base + bank->regs->ctrl;
438 u32 ctrl; 438 u32 ctrl;
439 439
440 ctrl = __raw_readl(reg); 440 ctrl = readl_relaxed(reg);
441 /* Module is enabled, clocks are not gated */ 441 /* Module is enabled, clocks are not gated */
442 ctrl &= ~GPIO_MOD_CTRL_BIT; 442 ctrl &= ~GPIO_MOD_CTRL_BIT;
443 __raw_writel(ctrl, reg); 443 writel_relaxed(ctrl, reg);
444 bank->context.ctrl = ctrl; 444 bank->context.ctrl = ctrl;
445 } 445 }
446} 446}
@@ -455,17 +455,17 @@ static void _disable_gpio_module(struct gpio_bank *bank, unsigned offset)
455 /* Disable wake-up during idle for dynamic tick */ 455 /* Disable wake-up during idle for dynamic tick */
456 _gpio_rmw(base, bank->regs->wkup_en, 1 << offset, 0); 456 _gpio_rmw(base, bank->regs->wkup_en, 1 << offset, 0);
457 bank->context.wake_en = 457 bank->context.wake_en =
458 __raw_readl(bank->base + bank->regs->wkup_en); 458 readl_relaxed(bank->base + bank->regs->wkup_en);
459 } 459 }
460 460
461 if (bank->regs->ctrl && !BANK_USED(bank)) { 461 if (bank->regs->ctrl && !BANK_USED(bank)) {
462 void __iomem *reg = bank->base + bank->regs->ctrl; 462 void __iomem *reg = bank->base + bank->regs->ctrl;
463 u32 ctrl; 463 u32 ctrl;
464 464
465 ctrl = __raw_readl(reg); 465 ctrl = readl_relaxed(reg);
466 /* Module is disabled, clocks are gated */ 466 /* Module is disabled, clocks are gated */
467 ctrl |= GPIO_MOD_CTRL_BIT; 467 ctrl |= GPIO_MOD_CTRL_BIT;
468 __raw_writel(ctrl, reg); 468 writel_relaxed(ctrl, reg);
469 bank->context.ctrl = ctrl; 469 bank->context.ctrl = ctrl;
470 } 470 }
471} 471}
@@ -474,7 +474,7 @@ static int gpio_is_input(struct gpio_bank *bank, int mask)
474{ 474{
475 void __iomem *reg = bank->base + bank->regs->direction; 475 void __iomem *reg = bank->base + bank->regs->direction;
476 476
477 return __raw_readl(reg) & mask; 477 return readl_relaxed(reg) & mask;
478} 478}
479 479
480static int gpio_irq_type(struct irq_data *d, unsigned type) 480static int gpio_irq_type(struct irq_data *d, unsigned type)
@@ -538,16 +538,16 @@ static void _clear_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
538 void __iomem *reg = bank->base; 538 void __iomem *reg = bank->base;
539 539
540 reg += bank->regs->irqstatus; 540 reg += bank->regs->irqstatus;
541 __raw_writel(gpio_mask, reg); 541 writel_relaxed(gpio_mask, reg);
542 542
543 /* Workaround for clearing DSP GPIO interrupts to allow retention */ 543 /* Workaround for clearing DSP GPIO interrupts to allow retention */
544 if (bank->regs->irqstatus2) { 544 if (bank->regs->irqstatus2) {
545 reg = bank->base + bank->regs->irqstatus2; 545 reg = bank->base + bank->regs->irqstatus2;
546 __raw_writel(gpio_mask, reg); 546 writel_relaxed(gpio_mask, reg);
547 } 547 }
548 548
549 /* Flush posted write for the irq status to avoid spurious interrupts */ 549 /* Flush posted write for the irq status to avoid spurious interrupts */
550 __raw_readl(reg); 550 readl_relaxed(reg);
551} 551}
552 552
553static inline void _clear_gpio_irqstatus(struct gpio_bank *bank, int gpio) 553static inline void _clear_gpio_irqstatus(struct gpio_bank *bank, int gpio)
@@ -562,7 +562,7 @@ static u32 _get_gpio_irqbank_mask(struct gpio_bank *bank)
562 u32 mask = (1 << bank->width) - 1; 562 u32 mask = (1 << bank->width) - 1;
563 563
564 reg += bank->regs->irqenable; 564 reg += bank->regs->irqenable;
565 l = __raw_readl(reg); 565 l = readl_relaxed(reg);
566 if (bank->regs->irqenable_inv) 566 if (bank->regs->irqenable_inv)
567 l = ~l; 567 l = ~l;
568 l &= mask; 568 l &= mask;
@@ -580,7 +580,7 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
580 bank->context.irqenable1 |= gpio_mask; 580 bank->context.irqenable1 |= gpio_mask;
581 } else { 581 } else {
582 reg += bank->regs->irqenable; 582 reg += bank->regs->irqenable;
583 l = __raw_readl(reg); 583 l = readl_relaxed(reg);
584 if (bank->regs->irqenable_inv) 584 if (bank->regs->irqenable_inv)
585 l &= ~gpio_mask; 585 l &= ~gpio_mask;
586 else 586 else
@@ -588,7 +588,7 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
588 bank->context.irqenable1 = l; 588 bank->context.irqenable1 = l;
589 } 589 }
590 590
591 __raw_writel(l, reg); 591 writel_relaxed(l, reg);
592} 592}
593 593
594static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask) 594static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
@@ -602,7 +602,7 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
602 bank->context.irqenable1 &= ~gpio_mask; 602 bank->context.irqenable1 &= ~gpio_mask;
603 } else { 603 } else {
604 reg += bank->regs->irqenable; 604 reg += bank->regs->irqenable;
605 l = __raw_readl(reg); 605 l = readl_relaxed(reg);
606 if (bank->regs->irqenable_inv) 606 if (bank->regs->irqenable_inv)
607 l |= gpio_mask; 607 l |= gpio_mask;
608 else 608 else
@@ -610,7 +610,7 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
610 bank->context.irqenable1 = l; 610 bank->context.irqenable1 = l;
611 } 611 }
612 612
613 __raw_writel(l, reg); 613 writel_relaxed(l, reg);
614} 614}
615 615
616static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int enable) 616static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int enable)
@@ -646,7 +646,7 @@ static int _set_gpio_wakeup(struct gpio_bank *bank, int gpio, int enable)
646 else 646 else
647 bank->context.wake_en &= ~gpio_bit; 647 bank->context.wake_en &= ~gpio_bit;
648 648
649 __raw_writel(bank->context.wake_en, bank->base + bank->regs->wkup_en); 649 writel_relaxed(bank->context.wake_en, bank->base + bank->regs->wkup_en);
650 spin_unlock_irqrestore(&bank->lock, flags); 650 spin_unlock_irqrestore(&bank->lock, flags);
651 651
652 return 0; 652 return 0;
@@ -748,7 +748,7 @@ static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
748 u32 enabled; 748 u32 enabled;
749 749
750 enabled = _get_gpio_irqbank_mask(bank); 750 enabled = _get_gpio_irqbank_mask(bank);
751 isr_saved = isr = __raw_readl(isr_reg) & enabled; 751 isr_saved = isr = readl_relaxed(isr_reg) & enabled;
752 752
753 if (bank->level_mask) 753 if (bank->level_mask)
754 level_mask = bank->level_mask & enabled; 754 level_mask = bank->level_mask & enabled;
@@ -883,7 +883,7 @@ static int omap_mpuio_suspend_noirq(struct device *dev)
883 unsigned long flags; 883 unsigned long flags;
884 884
885 spin_lock_irqsave(&bank->lock, flags); 885 spin_lock_irqsave(&bank->lock, flags);
886 __raw_writel(0xffff & ~bank->context.wake_en, mask_reg); 886 writel_relaxed(0xffff & ~bank->context.wake_en, mask_reg);
887 spin_unlock_irqrestore(&bank->lock, flags); 887 spin_unlock_irqrestore(&bank->lock, flags);
888 888
889 return 0; 889 return 0;
@@ -898,7 +898,7 @@ static int omap_mpuio_resume_noirq(struct device *dev)
898 unsigned long flags; 898 unsigned long flags;
899 899
900 spin_lock_irqsave(&bank->lock, flags); 900 spin_lock_irqsave(&bank->lock, flags);
901 __raw_writel(bank->context.wake_en, mask_reg); 901 writel_relaxed(bank->context.wake_en, mask_reg);
902 spin_unlock_irqrestore(&bank->lock, flags); 902 spin_unlock_irqrestore(&bank->lock, flags);
903 903
904 return 0; 904 return 0;
@@ -1011,7 +1011,7 @@ static void __init omap_gpio_show_rev(struct gpio_bank *bank)
1011 if (called || bank->regs->revision == USHRT_MAX) 1011 if (called || bank->regs->revision == USHRT_MAX)
1012 return; 1012 return;
1013 1013
1014 rev = __raw_readw(bank->base + bank->regs->revision); 1014 rev = readw_relaxed(bank->base + bank->regs->revision);
1015 pr_info("OMAP GPIO hardware version %d.%d\n", 1015 pr_info("OMAP GPIO hardware version %d.%d\n",
1016 (rev >> 4) & 0x0f, rev & 0x0f); 1016 (rev >> 4) & 0x0f, rev & 0x0f);
1017 1017
@@ -1032,20 +1032,20 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
1032 l = 0xffff; 1032 l = 0xffff;
1033 1033
1034 if (bank->is_mpuio) { 1034 if (bank->is_mpuio) {
1035 __raw_writel(l, bank->base + bank->regs->irqenable); 1035 writel_relaxed(l, bank->base + bank->regs->irqenable);
1036 return; 1036 return;
1037 } 1037 }
1038 1038
1039 _gpio_rmw(base, bank->regs->irqenable, l, bank->regs->irqenable_inv); 1039 _gpio_rmw(base, bank->regs->irqenable, l, bank->regs->irqenable_inv);
1040 _gpio_rmw(base, bank->regs->irqstatus, l, !bank->regs->irqenable_inv); 1040 _gpio_rmw(base, bank->regs->irqstatus, l, !bank->regs->irqenable_inv);
1041 if (bank->regs->debounce_en) 1041 if (bank->regs->debounce_en)
1042 __raw_writel(0, base + bank->regs->debounce_en); 1042 writel_relaxed(0, base + bank->regs->debounce_en);
1043 1043
1044 /* Save OE default value (0xffffffff) in the context */ 1044 /* Save OE default value (0xffffffff) in the context */
1045 bank->context.oe = __raw_readl(bank->base + bank->regs->direction); 1045 bank->context.oe = readl_relaxed(bank->base + bank->regs->direction);
1046 /* Initialize interface clk ungated, module enabled */ 1046 /* Initialize interface clk ungated, module enabled */
1047 if (bank->regs->ctrl) 1047 if (bank->regs->ctrl)
1048 __raw_writel(0, base + bank->regs->ctrl); 1048 writel_relaxed(0, base + bank->regs->ctrl);
1049 1049
1050 bank->dbck = clk_get(bank->dev, "dbclk"); 1050 bank->dbck = clk_get(bank->dev, "dbclk");
1051 if (IS_ERR(bank->dbck)) 1051 if (IS_ERR(bank->dbck))
@@ -1282,11 +1282,11 @@ static int omap_gpio_runtime_suspend(struct device *dev)
1282 */ 1282 */
1283 wake_low = bank->context.leveldetect0 & bank->context.wake_en; 1283 wake_low = bank->context.leveldetect0 & bank->context.wake_en;
1284 if (wake_low) 1284 if (wake_low)
1285 __raw_writel(wake_low | bank->context.fallingdetect, 1285 writel_relaxed(wake_low | bank->context.fallingdetect,
1286 bank->base + bank->regs->fallingdetect); 1286 bank->base + bank->regs->fallingdetect);
1287 wake_hi = bank->context.leveldetect1 & bank->context.wake_en; 1287 wake_hi = bank->context.leveldetect1 & bank->context.wake_en;
1288 if (wake_hi) 1288 if (wake_hi)
1289 __raw_writel(wake_hi | bank->context.risingdetect, 1289 writel_relaxed(wake_hi | bank->context.risingdetect,
1290 bank->base + bank->regs->risingdetect); 1290 bank->base + bank->regs->risingdetect);
1291 1291
1292 if (!bank->enabled_non_wakeup_gpios) 1292 if (!bank->enabled_non_wakeup_gpios)
@@ -1301,7 +1301,7 @@ static int omap_gpio_runtime_suspend(struct device *dev)
1301 * non-wakeup GPIOs. Otherwise spurious IRQs will be 1301 * non-wakeup GPIOs. Otherwise spurious IRQs will be
1302 * generated. See OMAP2420 Errata item 1.101. 1302 * generated. See OMAP2420 Errata item 1.101.
1303 */ 1303 */
1304 bank->saved_datain = __raw_readl(bank->base + 1304 bank->saved_datain = readl_relaxed(bank->base +
1305 bank->regs->datain); 1305 bank->regs->datain);
1306 l1 = bank->context.fallingdetect; 1306 l1 = bank->context.fallingdetect;
1307 l2 = bank->context.risingdetect; 1307 l2 = bank->context.risingdetect;
@@ -1309,8 +1309,8 @@ static int omap_gpio_runtime_suspend(struct device *dev)
1309 l1 &= ~bank->enabled_non_wakeup_gpios; 1309 l1 &= ~bank->enabled_non_wakeup_gpios;
1310 l2 &= ~bank->enabled_non_wakeup_gpios; 1310 l2 &= ~bank->enabled_non_wakeup_gpios;
1311 1311
1312 __raw_writel(l1, bank->base + bank->regs->fallingdetect); 1312 writel_relaxed(l1, bank->base + bank->regs->fallingdetect);
1313 __raw_writel(l2, bank->base + bank->regs->risingdetect); 1313 writel_relaxed(l2, bank->base + bank->regs->risingdetect);
1314 1314
1315 bank->workaround_enabled = true; 1315 bank->workaround_enabled = true;
1316 1316
@@ -1358,9 +1358,9 @@ static int omap_gpio_runtime_resume(struct device *dev)
1358 * generate a PRCM wakeup. Here we restore the 1358 * generate a PRCM wakeup. Here we restore the
1359 * pre-runtime_suspend() values for edge triggering. 1359 * pre-runtime_suspend() values for edge triggering.
1360 */ 1360 */
1361 __raw_writel(bank->context.fallingdetect, 1361 writel_relaxed(bank->context.fallingdetect,
1362 bank->base + bank->regs->fallingdetect); 1362 bank->base + bank->regs->fallingdetect);
1363 __raw_writel(bank->context.risingdetect, 1363 writel_relaxed(bank->context.risingdetect,
1364 bank->base + bank->regs->risingdetect); 1364 bank->base + bank->regs->risingdetect);
1365 1365
1366 if (bank->loses_context) { 1366 if (bank->loses_context) {
@@ -1382,7 +1382,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
1382 return 0; 1382 return 0;
1383 } 1383 }
1384 1384
1385 l = __raw_readl(bank->base + bank->regs->datain); 1385 l = readl_relaxed(bank->base + bank->regs->datain);
1386 1386
1387 /* 1387 /*
1388 * Check if any of the non-wakeup interrupt GPIOs have changed 1388 * Check if any of the non-wakeup interrupt GPIOs have changed
@@ -1412,24 +1412,24 @@ static int omap_gpio_runtime_resume(struct device *dev)
1412 if (gen) { 1412 if (gen) {
1413 u32 old0, old1; 1413 u32 old0, old1;
1414 1414
1415 old0 = __raw_readl(bank->base + bank->regs->leveldetect0); 1415 old0 = readl_relaxed(bank->base + bank->regs->leveldetect0);
1416 old1 = __raw_readl(bank->base + bank->regs->leveldetect1); 1416 old1 = readl_relaxed(bank->base + bank->regs->leveldetect1);
1417 1417
1418 if (!bank->regs->irqstatus_raw0) { 1418 if (!bank->regs->irqstatus_raw0) {
1419 __raw_writel(old0 | gen, bank->base + 1419 writel_relaxed(old0 | gen, bank->base +
1420 bank->regs->leveldetect0); 1420 bank->regs->leveldetect0);
1421 __raw_writel(old1 | gen, bank->base + 1421 writel_relaxed(old1 | gen, bank->base +
1422 bank->regs->leveldetect1); 1422 bank->regs->leveldetect1);
1423 } 1423 }
1424 1424
1425 if (bank->regs->irqstatus_raw0) { 1425 if (bank->regs->irqstatus_raw0) {
1426 __raw_writel(old0 | l, bank->base + 1426 writel_relaxed(old0 | l, bank->base +
1427 bank->regs->leveldetect0); 1427 bank->regs->leveldetect0);
1428 __raw_writel(old1 | l, bank->base + 1428 writel_relaxed(old1 | l, bank->base +
1429 bank->regs->leveldetect1); 1429 bank->regs->leveldetect1);
1430 } 1430 }
1431 __raw_writel(old0, bank->base + bank->regs->leveldetect0); 1431 writel_relaxed(old0, bank->base + bank->regs->leveldetect0);
1432 __raw_writel(old1, bank->base + bank->regs->leveldetect1); 1432 writel_relaxed(old1, bank->base + bank->regs->leveldetect1);
1433 } 1433 }
1434 1434
1435 bank->workaround_enabled = false; 1435 bank->workaround_enabled = false;
@@ -1471,55 +1471,55 @@ static void omap_gpio_init_context(struct gpio_bank *p)
1471 struct omap_gpio_reg_offs *regs = p->regs; 1471 struct omap_gpio_reg_offs *regs = p->regs;
1472 void __iomem *base = p->base; 1472 void __iomem *base = p->base;
1473 1473
1474 p->context.ctrl = __raw_readl(base + regs->ctrl); 1474 p->context.ctrl = readl_relaxed(base + regs->ctrl);
1475 p->context.oe = __raw_readl(base + regs->direction); 1475 p->context.oe = readl_relaxed(base + regs->direction);
1476 p->context.wake_en = __raw_readl(base + regs->wkup_en); 1476 p->context.wake_en = readl_relaxed(base + regs->wkup_en);
1477 p->context.leveldetect0 = __raw_readl(base + regs->leveldetect0); 1477 p->context.leveldetect0 = readl_relaxed(base + regs->leveldetect0);
1478 p->context.leveldetect1 = __raw_readl(base + regs->leveldetect1); 1478 p->context.leveldetect1 = readl_relaxed(base + regs->leveldetect1);
1479 p->context.risingdetect = __raw_readl(base + regs->risingdetect); 1479 p->context.risingdetect = readl_relaxed(base + regs->risingdetect);
1480 p->context.fallingdetect = __raw_readl(base + regs->fallingdetect); 1480 p->context.fallingdetect = readl_relaxed(base + regs->fallingdetect);
1481 p->context.irqenable1 = __raw_readl(base + regs->irqenable); 1481 p->context.irqenable1 = readl_relaxed(base + regs->irqenable);
1482 p->context.irqenable2 = __raw_readl(base + regs->irqenable2); 1482 p->context.irqenable2 = readl_relaxed(base + regs->irqenable2);
1483 1483
1484 if (regs->set_dataout && p->regs->clr_dataout) 1484 if (regs->set_dataout && p->regs->clr_dataout)
1485 p->context.dataout = __raw_readl(base + regs->set_dataout); 1485 p->context.dataout = readl_relaxed(base + regs->set_dataout);
1486 else 1486 else
1487 p->context.dataout = __raw_readl(base + regs->dataout); 1487 p->context.dataout = readl_relaxed(base + regs->dataout);
1488 1488
1489 p->context_valid = true; 1489 p->context_valid = true;
1490} 1490}
1491 1491
1492static void omap_gpio_restore_context(struct gpio_bank *bank) 1492static void omap_gpio_restore_context(struct gpio_bank *bank)
1493{ 1493{
1494 __raw_writel(bank->context.wake_en, 1494 writel_relaxed(bank->context.wake_en,
1495 bank->base + bank->regs->wkup_en); 1495 bank->base + bank->regs->wkup_en);
1496 __raw_writel(bank->context.ctrl, bank->base + bank->regs->ctrl); 1496 writel_relaxed(bank->context.ctrl, bank->base + bank->regs->ctrl);
1497 __raw_writel(bank->context.leveldetect0, 1497 writel_relaxed(bank->context.leveldetect0,
1498 bank->base + bank->regs->leveldetect0); 1498 bank->base + bank->regs->leveldetect0);
1499 __raw_writel(bank->context.leveldetect1, 1499 writel_relaxed(bank->context.leveldetect1,
1500 bank->base + bank->regs->leveldetect1); 1500 bank->base + bank->regs->leveldetect1);
1501 __raw_writel(bank->context.risingdetect, 1501 writel_relaxed(bank->context.risingdetect,
1502 bank->base + bank->regs->risingdetect); 1502 bank->base + bank->regs->risingdetect);
1503 __raw_writel(bank->context.fallingdetect, 1503 writel_relaxed(bank->context.fallingdetect,
1504 bank->base + bank->regs->fallingdetect); 1504 bank->base + bank->regs->fallingdetect);
1505 if (bank->regs->set_dataout && bank->regs->clr_dataout) 1505 if (bank->regs->set_dataout && bank->regs->clr_dataout)
1506 __raw_writel(bank->context.dataout, 1506 writel_relaxed(bank->context.dataout,
1507 bank->base + bank->regs->set_dataout); 1507 bank->base + bank->regs->set_dataout);
1508 else 1508 else
1509 __raw_writel(bank->context.dataout, 1509 writel_relaxed(bank->context.dataout,
1510 bank->base + bank->regs->dataout); 1510 bank->base + bank->regs->dataout);
1511 __raw_writel(bank->context.oe, bank->base + bank->regs->direction); 1511 writel_relaxed(bank->context.oe, bank->base + bank->regs->direction);
1512 1512
1513 if (bank->dbck_enable_mask) { 1513 if (bank->dbck_enable_mask) {
1514 __raw_writel(bank->context.debounce, bank->base + 1514 writel_relaxed(bank->context.debounce, bank->base +
1515 bank->regs->debounce); 1515 bank->regs->debounce);
1516 __raw_writel(bank->context.debounce_en, 1516 writel_relaxed(bank->context.debounce_en,
1517 bank->base + bank->regs->debounce_en); 1517 bank->base + bank->regs->debounce_en);
1518 } 1518 }
1519 1519
1520 __raw_writel(bank->context.irqenable1, 1520 writel_relaxed(bank->context.irqenable1,
1521 bank->base + bank->regs->irqenable); 1521 bank->base + bank->regs->irqenable);
1522 __raw_writel(bank->context.irqenable2, 1522 writel_relaxed(bank->context.irqenable2,
1523 bank->base + bank->regs->irqenable2); 1523 bank->base + bank->regs->irqenable2);
1524} 1524}
1525#endif /* CONFIG_PM_RUNTIME */ 1525#endif /* CONFIG_PM_RUNTIME */
diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c
index 11801e986dd9..da9d33252e56 100644
--- a/drivers/gpio/gpio-palmas.c
+++ b/drivers/gpio/gpio-palmas.c
@@ -182,7 +182,7 @@ static int palmas_gpio_probe(struct platform_device *pdev)
182 palmas_gpio->gpio_chip.owner = THIS_MODULE; 182 palmas_gpio->gpio_chip.owner = THIS_MODULE;
183 palmas_gpio->gpio_chip.label = dev_name(&pdev->dev); 183 palmas_gpio->gpio_chip.label = dev_name(&pdev->dev);
184 palmas_gpio->gpio_chip.ngpio = dev_data->ngpio; 184 palmas_gpio->gpio_chip.ngpio = dev_data->ngpio;
185 palmas_gpio->gpio_chip.can_sleep = 1; 185 palmas_gpio->gpio_chip.can_sleep = true;
186 palmas_gpio->gpio_chip.direction_input = palmas_gpio_input; 186 palmas_gpio->gpio_chip.direction_input = palmas_gpio_input;
187 palmas_gpio->gpio_chip.direction_output = palmas_gpio_output; 187 palmas_gpio->gpio_chip.direction_output = palmas_gpio_output;
188 palmas_gpio->gpio_chip.to_irq = palmas_gpio_to_irq; 188 palmas_gpio->gpio_chip.to_irq = palmas_gpio_to_irq;
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 6e48c07e3d8c..019b23b955a2 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -354,7 +354,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
354 gc->direction_output = pca953x_gpio_direction_output; 354 gc->direction_output = pca953x_gpio_direction_output;
355 gc->get = pca953x_gpio_get_value; 355 gc->get = pca953x_gpio_get_value;
356 gc->set = pca953x_gpio_set_value; 356 gc->set = pca953x_gpio_set_value;
357 gc->can_sleep = 1; 357 gc->can_sleep = true;
358 358
359 gc->base = chip->gpio_start; 359 gc->base = chip->gpio_start;
360 gc->ngpio = gpios; 360 gc->ngpio = gpios;
diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c
index 1535686e74ea..82735822bc9d 100644
--- a/drivers/gpio/gpio-pcf857x.c
+++ b/drivers/gpio/gpio-pcf857x.c
@@ -305,7 +305,7 @@ static int pcf857x_probe(struct i2c_client *client,
305 spin_lock_init(&gpio->slock); 305 spin_lock_init(&gpio->slock);
306 306
307 gpio->chip.base = pdata ? pdata->gpio_base : -1; 307 gpio->chip.base = pdata ? pdata->gpio_base : -1;
308 gpio->chip.can_sleep = 1; 308 gpio->chip.can_sleep = true;
309 gpio->chip.dev = &client->dev; 309 gpio->chip.dev = &client->dev;
310 gpio->chip.owner = THIS_MODULE; 310 gpio->chip.owner = THIS_MODULE;
311 gpio->chip.get = pcf857x_get; 311 gpio->chip.get = pcf857x_get;
diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c
index 0fec097e838d..9656c196772e 100644
--- a/drivers/gpio/gpio-pch.c
+++ b/drivers/gpio/gpio-pch.c
@@ -224,7 +224,7 @@ static void pch_gpio_setup(struct pch_gpio *chip)
224 gpio->dbg_show = NULL; 224 gpio->dbg_show = NULL;
225 gpio->base = -1; 225 gpio->base = -1;
226 gpio->ngpio = gpio_pins[chip->ioh]; 226 gpio->ngpio = gpio_pins[chip->ioh];
227 gpio->can_sleep = 0; 227 gpio->can_sleep = false;
228 gpio->to_irq = pch_gpio_to_irq; 228 gpio->to_irq = pch_gpio_to_irq;
229} 229}
230 230
@@ -518,7 +518,7 @@ static int pch_gpio_resume(struct pci_dev *pdev)
518#endif 518#endif
519 519
520#define PCI_VENDOR_ID_ROHM 0x10DB 520#define PCI_VENDOR_ID_ROHM 0x10DB
521static DEFINE_PCI_DEVICE_TABLE(pch_gpio_pcidev_id) = { 521static const struct pci_device_id pch_gpio_pcidev_id[] = {
522 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x8803) }, 522 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x8803) },
523 { PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x8014) }, 523 { PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x8014) },
524 { PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x8043) }, 524 { PCI_DEVICE(PCI_VENDOR_ID_ROHM, 0x8043) },
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index cc13d1b74fad..42e6e64f2120 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -263,7 +263,8 @@ static int pxa_gpio_direction_output(struct gpio_chip *chip,
263 263
264static int pxa_gpio_get(struct gpio_chip *chip, unsigned offset) 264static int pxa_gpio_get(struct gpio_chip *chip, unsigned offset)
265{ 265{
266 return readl_relaxed(gpio_chip_base(chip) + GPLR_OFFSET) & (1 << offset); 266 u32 gplr = readl_relaxed(gpio_chip_base(chip) + GPLR_OFFSET);
267 return !!(gplr & (1 << offset));
267} 268}
268 269
269static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 270static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
diff --git a/drivers/gpio/gpio-rc5t583.c b/drivers/gpio/gpio-rc5t583.c
index e63d6a397e17..122b776fdc0b 100644
--- a/drivers/gpio/gpio-rc5t583.c
+++ b/drivers/gpio/gpio-rc5t583.c
@@ -133,7 +133,7 @@ static int rc5t583_gpio_probe(struct platform_device *pdev)
133 rc5t583_gpio->gpio_chip.get = rc5t583_gpio_get, 133 rc5t583_gpio->gpio_chip.get = rc5t583_gpio_get,
134 rc5t583_gpio->gpio_chip.to_irq = rc5t583_gpio_to_irq, 134 rc5t583_gpio->gpio_chip.to_irq = rc5t583_gpio_to_irq,
135 rc5t583_gpio->gpio_chip.ngpio = RC5T583_MAX_GPIO, 135 rc5t583_gpio->gpio_chip.ngpio = RC5T583_MAX_GPIO,
136 rc5t583_gpio->gpio_chip.can_sleep = 1, 136 rc5t583_gpio->gpio_chip.can_sleep = true,
137 rc5t583_gpio->gpio_chip.dev = &pdev->dev; 137 rc5t583_gpio->gpio_chip.dev = &pdev->dev;
138 rc5t583_gpio->gpio_chip.base = -1; 138 rc5t583_gpio->gpio_chip.base = -1;
139 rc5t583_gpio->rc5t583 = rc5t583; 139 rc5t583_gpio->rc5t583 = rc5t583;
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 8b7e719a68c3..ca76ce751540 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -285,7 +285,34 @@ static struct irq_domain_ops gpio_rcar_irq_domain_ops = {
285 .map = gpio_rcar_irq_domain_map, 285 .map = gpio_rcar_irq_domain_map,
286}; 286};
287 287
288static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p) 288struct gpio_rcar_info {
289 bool has_both_edge_trigger;
290};
291
292static const struct of_device_id gpio_rcar_of_table[] = {
293 {
294 .compatible = "renesas,gpio-r8a7790",
295 .data = (void *)&(const struct gpio_rcar_info) {
296 .has_both_edge_trigger = true,
297 },
298 }, {
299 .compatible = "renesas,gpio-r8a7791",
300 .data = (void *)&(const struct gpio_rcar_info) {
301 .has_both_edge_trigger = true,
302 },
303 }, {
304 .compatible = "renesas,gpio-rcar",
305 .data = (void *)&(const struct gpio_rcar_info) {
306 .has_both_edge_trigger = false,
307 },
308 }, {
309 /* Terminator */
310 },
311};
312
313MODULE_DEVICE_TABLE(of, gpio_rcar_of_table);
314
315static int gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
289{ 316{
290 struct gpio_rcar_config *pdata = dev_get_platdata(&p->pdev->dev); 317 struct gpio_rcar_config *pdata = dev_get_platdata(&p->pdev->dev);
291 struct device_node *np = p->pdev->dev.of_node; 318 struct device_node *np = p->pdev->dev.of_node;
@@ -295,11 +322,21 @@ static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
295 if (pdata) { 322 if (pdata) {
296 p->config = *pdata; 323 p->config = *pdata;
297 } else if (IS_ENABLED(CONFIG_OF) && np) { 324 } else if (IS_ENABLED(CONFIG_OF) && np) {
325 const struct of_device_id *match;
326 const struct gpio_rcar_info *info;
327
328 match = of_match_node(gpio_rcar_of_table, np);
329 if (!match)
330 return -EINVAL;
331
332 info = match->data;
333
298 ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, 334 ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0,
299 &args); 335 &args);
300 p->config.number_of_pins = ret == 0 ? args.args[2] 336 p->config.number_of_pins = ret == 0 ? args.args[2]
301 : RCAR_MAX_GPIO_PER_BANK; 337 : RCAR_MAX_GPIO_PER_BANK;
302 p->config.gpio_base = -1; 338 p->config.gpio_base = -1;
339 p->config.has_both_edge_trigger = info->has_both_edge_trigger;
303 } 340 }
304 341
305 if (p->config.number_of_pins == 0 || 342 if (p->config.number_of_pins == 0 ||
@@ -309,6 +346,8 @@ static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
309 p->config.number_of_pins, RCAR_MAX_GPIO_PER_BANK); 346 p->config.number_of_pins, RCAR_MAX_GPIO_PER_BANK);
310 p->config.number_of_pins = RCAR_MAX_GPIO_PER_BANK; 347 p->config.number_of_pins = RCAR_MAX_GPIO_PER_BANK;
311 } 348 }
349
350 return 0;
312} 351}
313 352
314static int gpio_rcar_probe(struct platform_device *pdev) 353static int gpio_rcar_probe(struct platform_device *pdev)
@@ -331,7 +370,9 @@ static int gpio_rcar_probe(struct platform_device *pdev)
331 spin_lock_init(&p->lock); 370 spin_lock_init(&p->lock);
332 371
333 /* Get device configuration from DT node or platform data. */ 372 /* Get device configuration from DT node or platform data. */
334 gpio_rcar_parse_pdata(p); 373 ret = gpio_rcar_parse_pdata(p);
374 if (ret < 0)
375 return ret;
335 376
336 platform_set_drvdata(pdev, p); 377 platform_set_drvdata(pdev, p);
337 378
@@ -370,10 +411,9 @@ static int gpio_rcar_probe(struct platform_device *pdev)
370 irq_chip->name = name; 411 irq_chip->name = name;
371 irq_chip->irq_mask = gpio_rcar_irq_disable; 412 irq_chip->irq_mask = gpio_rcar_irq_disable;
372 irq_chip->irq_unmask = gpio_rcar_irq_enable; 413 irq_chip->irq_unmask = gpio_rcar_irq_enable;
373 irq_chip->irq_enable = gpio_rcar_irq_enable;
374 irq_chip->irq_disable = gpio_rcar_irq_disable;
375 irq_chip->irq_set_type = gpio_rcar_irq_set_type; 414 irq_chip->irq_set_type = gpio_rcar_irq_set_type;
376 irq_chip->flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_SET_TYPE_MASKED; 415 irq_chip->flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_SET_TYPE_MASKED
416 | IRQCHIP_MASK_ON_SUSPEND;
377 417
378 p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, 418 p->irq_domain = irq_domain_add_simple(pdev->dev.of_node,
379 p->config.number_of_pins, 419 p->config.number_of_pins,
@@ -436,17 +476,6 @@ static int gpio_rcar_remove(struct platform_device *pdev)
436 return 0; 476 return 0;
437} 477}
438 478
439#ifdef CONFIG_OF
440static const struct of_device_id gpio_rcar_of_table[] = {
441 {
442 .compatible = "renesas,gpio-rcar",
443 },
444 { },
445};
446
447MODULE_DEVICE_TABLE(of, gpio_rcar_of_table);
448#endif
449
450static struct platform_driver gpio_rcar_device_driver = { 479static struct platform_driver gpio_rcar_device_driver = {
451 .probe = gpio_rcar_probe, 480 .probe = gpio_rcar_probe,
452 .remove = gpio_rcar_remove, 481 .remove = gpio_rcar_remove,
diff --git a/drivers/gpio/gpio-samsung.c b/drivers/gpio/gpio-samsung.c
index 76e02b9460e6..a85e00bf9834 100644
--- a/drivers/gpio/gpio-samsung.c
+++ b/drivers/gpio/gpio-samsung.c
@@ -30,10 +30,13 @@
30 30
31#include <asm/irq.h> 31#include <asm/irq.h>
32 32
33#include <mach/hardware.h>
34#include <mach/map.h> 33#include <mach/map.h>
35#include <mach/regs-gpio.h> 34#include <mach/regs-gpio.h>
36 35
36#if defined(CONFIG_ARCH_S3C24XX) || defined(CONFIG_ARCH_S3C64XX)
37#include <mach/gpio-samsung.h>
38#endif
39
37#include <plat/cpu.h> 40#include <plat/cpu.h>
38#include <plat/gpio-core.h> 41#include <plat/gpio-core.h>
39#include <plat/gpio-cfg.h> 42#include <plat/gpio-cfg.h>
@@ -1053,7 +1056,7 @@ struct samsung_gpio_chip s3c24xx_gpios[] = {
1053 .base = S3C2410_GPA(0), 1056 .base = S3C2410_GPA(0),
1054 .owner = THIS_MODULE, 1057 .owner = THIS_MODULE,
1055 .label = "GPIOA", 1058 .label = "GPIOA",
1056 .ngpio = 24, 1059 .ngpio = 27,
1057 .direction_input = s3c24xx_gpiolib_banka_input, 1060 .direction_input = s3c24xx_gpiolib_banka_input,
1058 .direction_output = s3c24xx_gpiolib_banka_output, 1061 .direction_output = s3c24xx_gpiolib_banka_output,
1059 }, 1062 },
@@ -1062,7 +1065,7 @@ struct samsung_gpio_chip s3c24xx_gpios[] = {
1062 .base = S3C2410_GPB(0), 1065 .base = S3C2410_GPB(0),
1063 .owner = THIS_MODULE, 1066 .owner = THIS_MODULE,
1064 .label = "GPIOB", 1067 .label = "GPIOB",
1065 .ngpio = 16, 1068 .ngpio = 11,
1066 }, 1069 },
1067 }, { 1070 }, {
1068 .chip = { 1071 .chip = {
@@ -1107,7 +1110,7 @@ struct samsung_gpio_chip s3c24xx_gpios[] = {
1107 .base = S3C2410_GPH(0), 1110 .base = S3C2410_GPH(0),
1108 .owner = THIS_MODULE, 1111 .owner = THIS_MODULE,
1109 .label = "GPIOH", 1112 .label = "GPIOH",
1110 .ngpio = 11, 1113 .ngpio = 15,
1111 }, 1114 },
1112 }, 1115 },
1113 /* GPIOS for the S3C2443 and later devices. */ 1116 /* GPIOS for the S3C2443 and later devices. */
diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
new file mode 100644
index 000000000000..0357387b3645
--- /dev/null
+++ b/drivers/gpio/gpio-sch311x.c
@@ -0,0 +1,432 @@
1/*
2 * GPIO driver for the SMSC SCH311x Super-I/O chips
3 *
4 * Copyright (C) 2013 Bruno Randolf <br1@einfach.org>
5 *
6 * SuperIO functions and chip detection:
7 * (c) Copyright 2008 Wim Van Sebroeck <wim@iguana.be>.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */
14
15#include <linux/module.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/platform_device.h>
19#include <linux/gpio.h>
20#include <linux/bitops.h>
21#include <linux/io.h>
22
23#define DRV_NAME "gpio-sch311x"
24
25#define SCH311X_GPIO_CONF_OUT 0x00
26#define SCH311X_GPIO_CONF_IN 0x01
27#define SCH311X_GPIO_CONF_INVERT 0x02
28#define SCH311X_GPIO_CONF_OPEN_DRAIN 0x80
29
30#define SIO_CONFIG_KEY_ENTER 0x55
31#define SIO_CONFIG_KEY_EXIT 0xaa
32
33#define GP1 0x4b
34
35static int sch311x_ioports[] = { 0x2e, 0x4e, 0x162e, 0x164e };
36
37static struct platform_device *sch311x_gpio_pdev;
38
39struct sch311x_pdev_data { /* platform device data */
40 unsigned short runtime_reg; /* runtime register base address */
41};
42
43struct sch311x_gpio_block { /* one GPIO block runtime data */
44 struct gpio_chip chip;
45 unsigned short data_reg; /* from definition below */
46 unsigned short *config_regs; /* pointer to definition below */
47 unsigned short runtime_reg; /* runtime register */
48 spinlock_t lock; /* lock for this GPIO block */
49};
50
51struct sch311x_gpio_priv { /* driver private data */
52 struct sch311x_gpio_block blocks[6];
53};
54
55struct sch311x_gpio_block_def { /* register address definitions */
56 unsigned short data_reg;
57 unsigned short config_regs[8];
58 unsigned short base;
59};
60
61/* Note: some GPIOs are not available, these are marked with 0x00 */
62
63static struct sch311x_gpio_block_def sch311x_gpio_blocks[] = {
64 {
65 .data_reg = 0x4b, /* GP1 */
66 .config_regs = {0x23, 0x24, 0x25, 0x26, 0x27, 0x29, 0x2a, 0x2b},
67 .base = 10,
68 },
69 {
70 .data_reg = 0x4c, /* GP2 */
71 .config_regs = {0x00, 0x2c, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x32},
72 .base = 20,
73 },
74 {
75 .data_reg = 0x4d, /* GP3 */
76 .config_regs = {0x33, 0x34, 0x35, 0x36, 0x37, 0x00, 0x39, 0x3a},
77 .base = 30,
78 },
79 {
80 .data_reg = 0x4e, /* GP4 */
81 .config_regs = {0x3b, 0x00, 0x3d, 0x00, 0x6e, 0x6f, 0x72, 0x73},
82 .base = 40,
83 },
84 {
85 .data_reg = 0x4f, /* GP5 */
86 .config_regs = {0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46},
87 .base = 50,
88 },
89 {
90 .data_reg = 0x50, /* GP6 */
91 .config_regs = {0x47, 0x48, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59},
92 .base = 60,
93 },
94};
95
96static inline struct sch311x_gpio_block *
97to_sch311x_gpio_block(struct gpio_chip *chip)
98{
99 return container_of(chip, struct sch311x_gpio_block, chip);
100}
101
102
103/*
104 * Super-IO functions
105 */
106
107static inline int sch311x_sio_enter(int sio_config_port)
108{
109 /* Don't step on other drivers' I/O space by accident. */
110 if (!request_muxed_region(sio_config_port, 2, DRV_NAME)) {
111 pr_err(DRV_NAME "I/O address 0x%04x already in use\n",
112 sio_config_port);
113 return -EBUSY;
114 }
115
116 outb(SIO_CONFIG_KEY_ENTER, sio_config_port);
117 return 0;
118}
119
120static inline void sch311x_sio_exit(int sio_config_port)
121{
122 outb(SIO_CONFIG_KEY_EXIT, sio_config_port);
123 release_region(sio_config_port, 2);
124}
125
126static inline int sch311x_sio_inb(int sio_config_port, int reg)
127{
128 outb(reg, sio_config_port);
129 return inb(sio_config_port + 1);
130}
131
132static inline void sch311x_sio_outb(int sio_config_port, int reg, int val)
133{
134 outb(reg, sio_config_port);
135 outb(val, sio_config_port + 1);
136}
137
138
139/*
140 * GPIO functions
141 */
142
143static int sch311x_gpio_request(struct gpio_chip *chip, unsigned offset)
144{
145 struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip);
146
147 if (block->config_regs[offset] == 0) /* GPIO is not available */
148 return -ENODEV;
149
150 if (!request_region(block->runtime_reg + block->config_regs[offset],
151 1, DRV_NAME)) {
152 dev_err(chip->dev, "Failed to request region 0x%04x.\n",
153 block->runtime_reg + block->config_regs[offset]);
154 return -EBUSY;
155 }
156 return 0;
157}
158
159static void sch311x_gpio_free(struct gpio_chip *chip, unsigned offset)
160{
161 struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip);
162
163 if (block->config_regs[offset] == 0) /* GPIO is not available */
164 return;
165
166 release_region(block->runtime_reg + block->config_regs[offset], 1);
167}
168
169static int sch311x_gpio_get(struct gpio_chip *chip, unsigned offset)
170{
171 struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip);
172 unsigned char data;
173
174 spin_lock(&block->lock);
175 data = inb(block->runtime_reg + block->data_reg);
176 spin_unlock(&block->lock);
177
178 return !!(data & BIT(offset));
179}
180
181static void __sch311x_gpio_set(struct sch311x_gpio_block *block,
182 unsigned offset, int value)
183{
184 unsigned char data = inb(block->runtime_reg + block->data_reg);
185 if (value)
186 data |= BIT(offset);
187 else
188 data &= ~BIT(offset);
189 outb(data, block->runtime_reg + block->data_reg);
190}
191
192static void sch311x_gpio_set(struct gpio_chip *chip, unsigned offset,
193 int value)
194{
195 struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip);
196
197 spin_lock(&block->lock);
198 __sch311x_gpio_set(block, offset, value);
199 spin_unlock(&block->lock);
200}
201
202static int sch311x_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
203{
204 struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip);
205
206 spin_lock(&block->lock);
207 outb(SCH311X_GPIO_CONF_IN, block->runtime_reg +
208 block->config_regs[offset]);
209 spin_unlock(&block->lock);
210
211 return 0;
212}
213
214static int sch311x_gpio_direction_out(struct gpio_chip *chip, unsigned offset,
215 int value)
216{
217 struct sch311x_gpio_block *block = to_sch311x_gpio_block(chip);
218
219 spin_lock(&block->lock);
220
221 outb(SCH311X_GPIO_CONF_OUT, block->runtime_reg +
222 block->config_regs[offset]);
223
224 __sch311x_gpio_set(block, offset, value);
225
226 spin_unlock(&block->lock);
227 return 0;
228}
229
230static int sch311x_gpio_probe(struct platform_device *pdev)
231{
232 struct sch311x_pdev_data *pdata = pdev->dev.platform_data;
233 struct sch311x_gpio_priv *priv;
234 struct sch311x_gpio_block *block;
235 int err, i;
236
237 /* we can register all GPIO data registers at once */
238 if (!request_region(pdata->runtime_reg + GP1, 6, DRV_NAME)) {
239 dev_err(&pdev->dev, "Failed to request region 0x%04x-0x%04x.\n",
240 pdata->runtime_reg + GP1, pdata->runtime_reg + GP1 + 5);
241 return -EBUSY;
242 }
243
244 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
245 if (!priv)
246 return -ENOMEM;
247
248 platform_set_drvdata(pdev, priv);
249
250 for (i = 0; i < ARRAY_SIZE(priv->blocks); i++) {
251 block = &priv->blocks[i];
252
253 spin_lock_init(&block->lock);
254
255 block->chip.label = DRV_NAME;
256 block->chip.owner = THIS_MODULE;
257 block->chip.request = sch311x_gpio_request;
258 block->chip.free = sch311x_gpio_free;
259 block->chip.direction_input = sch311x_gpio_direction_in;
260 block->chip.direction_output = sch311x_gpio_direction_out;
261 block->chip.get = sch311x_gpio_get;
262 block->chip.set = sch311x_gpio_set;
263 block->chip.ngpio = 8;
264 block->chip.dev = &pdev->dev;
265 block->chip.base = sch311x_gpio_blocks[i].base;
266 block->config_regs = sch311x_gpio_blocks[i].config_regs;
267 block->data_reg = sch311x_gpio_blocks[i].data_reg;
268 block->runtime_reg = pdata->runtime_reg;
269
270 err = gpiochip_add(&block->chip);
271 if (err < 0) {
272 dev_err(&pdev->dev,
273 "Could not register gpiochip, %d\n", err);
274 goto exit_err;
275 }
276 dev_info(&pdev->dev,
277 "SMSC SCH311x GPIO block %d registered.\n", i);
278 }
279
280 return 0;
281
282exit_err:
283 release_region(pdata->runtime_reg + GP1, 6);
284 /* release already registered chips */
285 for (--i; i >= 0; i--)
286 gpiochip_remove(&priv->blocks[i].chip);
287 return err;
288}
289
290static int sch311x_gpio_remove(struct platform_device *pdev)
291{
292 struct sch311x_pdev_data *pdata = pdev->dev.platform_data;
293 struct sch311x_gpio_priv *priv = platform_get_drvdata(pdev);
294 int err, i;
295
296 release_region(pdata->runtime_reg + GP1, 6);
297
298 for (i = 0; i < ARRAY_SIZE(priv->blocks); i++) {
299 err = gpiochip_remove(&priv->blocks[i].chip);
300 if (err)
301 return err;
302 dev_info(&pdev->dev,
303 "SMSC SCH311x GPIO block %d unregistered.\n", i);
304 }
305 return 0;
306}
307
308static struct platform_driver sch311x_gpio_driver = {
309 .driver.name = DRV_NAME,
310 .driver.owner = THIS_MODULE,
311 .probe = sch311x_gpio_probe,
312 .remove = sch311x_gpio_remove,
313};
314
315
316/*
317 * Init & exit routines
318 */
319
320static int __init sch311x_detect(int sio_config_port, unsigned short *addr)
321{
322 int err = 0, reg;
323 unsigned short base_addr;
324 unsigned char dev_id;
325
326 err = sch311x_sio_enter(sio_config_port);
327 if (err)
328 return err;
329
330 /* Check device ID. We currently know about:
331 * SCH3112 (0x7c), SCH3114 (0x7d), and SCH3116 (0x7f). */
332 reg = sch311x_sio_inb(sio_config_port, 0x20);
333 if (!(reg == 0x7c || reg == 0x7d || reg == 0x7f)) {
334 err = -ENODEV;
335 goto exit;
336 }
337 dev_id = reg == 0x7c ? 2 : reg == 0x7d ? 4 : 6;
338
339 /* Select logical device A (runtime registers) */
340 sch311x_sio_outb(sio_config_port, 0x07, 0x0a);
341
342 /* Check if Logical Device Register is currently active */
343 if ((sch311x_sio_inb(sio_config_port, 0x30) & 0x01) == 0)
344 pr_info("Seems that LDN 0x0a is not active...\n");
345
346 /* Get the base address of the runtime registers */
347 base_addr = (sch311x_sio_inb(sio_config_port, 0x60) << 8) |
348 sch311x_sio_inb(sio_config_port, 0x61);
349 if (!base_addr) {
350 pr_err("Base address not set\n");
351 err = -ENODEV;
352 goto exit;
353 }
354 *addr = base_addr;
355
356 pr_info("Found an SMSC SCH311%d chip at 0x%04x\n", dev_id, base_addr);
357
358exit:
359 sch311x_sio_exit(sio_config_port);
360 return err;
361}
362
363static int __init sch311x_gpio_pdev_add(const unsigned short addr)
364{
365 struct sch311x_pdev_data pdata;
366 int err;
367
368 pdata.runtime_reg = addr;
369
370 sch311x_gpio_pdev = platform_device_alloc(DRV_NAME, -1);
371 if (!sch311x_gpio_pdev)
372 return -ENOMEM;
373
374 err = platform_device_add_data(sch311x_gpio_pdev,
375 &pdata, sizeof(pdata));
376 if (err) {
377 pr_err(DRV_NAME "Platform data allocation failed\n");
378 goto err;
379 }
380
381 err = platform_device_add(sch311x_gpio_pdev);
382 if (err) {
383 pr_err(DRV_NAME "Device addition failed\n");
384 goto err;
385 }
386 return 0;
387
388err:
389 platform_device_put(sch311x_gpio_pdev);
390 return err;
391}
392
393static int __init sch311x_gpio_init(void)
394{
395 int err, i;
396 unsigned short addr = 0;
397
398 for (i = 0; i < ARRAY_SIZE(sch311x_ioports); i++)
399 if (sch311x_detect(sch311x_ioports[i], &addr) == 0)
400 break;
401
402 if (!addr)
403 return -ENODEV;
404
405 err = platform_driver_register(&sch311x_gpio_driver);
406 if (err)
407 return err;
408
409 err = sch311x_gpio_pdev_add(addr);
410 if (err)
411 goto unreg_platform_driver;
412
413 return 0;
414
415unreg_platform_driver:
416 platform_driver_unregister(&sch311x_gpio_driver);
417 return err;
418}
419
420static void __exit sch311x_gpio_exit(void)
421{
422 platform_device_unregister(sch311x_gpio_pdev);
423 platform_driver_unregister(&sch311x_gpio_driver);
424}
425
426module_init(sch311x_gpio_init);
427module_exit(sch311x_gpio_exit);
428
429MODULE_AUTHOR("Bruno Randolf <br1@einfach.org>");
430MODULE_DESCRIPTION("SMSC SCH311x GPIO Driver");
431MODULE_LICENSE("GPL");
432MODULE_ALIAS("platform:gpio-sch311x");
diff --git a/drivers/gpio/gpio-sodaville.c b/drivers/gpio/gpio-sodaville.c
index 88f374ac7753..7c6c518929bc 100644
--- a/drivers/gpio/gpio-sodaville.c
+++ b/drivers/gpio/gpio-sodaville.c
@@ -176,8 +176,10 @@ static int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd,
176 176
177 sd->id = irq_domain_add_legacy(pdev->dev.of_node, SDV_NUM_PUB_GPIOS, 177 sd->id = irq_domain_add_legacy(pdev->dev.of_node, SDV_NUM_PUB_GPIOS,
178 sd->irq_base, 0, &irq_domain_sdv_ops, sd); 178 sd->irq_base, 0, &irq_domain_sdv_ops, sd);
179 if (!sd->id) 179 if (!sd->id) {
180 ret = -ENODEV;
180 goto out_free_irq; 181 goto out_free_irq;
182 }
181 return 0; 183 return 0;
182out_free_irq: 184out_free_irq:
183 free_irq(pdev->irq, sd); 185 free_irq(pdev->irq, sd);
@@ -212,8 +214,10 @@ static int sdv_gpio_probe(struct pci_dev *pdev,
212 } 214 }
213 215
214 addr = pci_resource_start(pdev, GPIO_BAR); 216 addr = pci_resource_start(pdev, GPIO_BAR);
215 if (!addr) 217 if (!addr) {
218 ret = -ENODEV;
216 goto release_reg; 219 goto release_reg;
220 }
217 sd->gpio_pub_base = ioremap(addr, pci_resource_len(pdev, GPIO_BAR)); 221 sd->gpio_pub_base = ioremap(addr, pci_resource_len(pdev, GPIO_BAR));
218 222
219 prop = of_get_property(pdev->dev.of_node, "intel,muxctl", &len); 223 prop = of_get_property(pdev->dev.of_node, "intel,muxctl", &len);
@@ -270,7 +274,7 @@ static void sdv_gpio_remove(struct pci_dev *pdev)
270 kfree(sd); 274 kfree(sd);
271} 275}
272 276
273static DEFINE_PCI_DEVICE_TABLE(sdv_gpio_pci_ids) = { 277static const struct pci_device_id sdv_gpio_pci_ids[] = {
274 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_SDV_GPIO) }, 278 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_SDV_GPIO) },
275 { 0, }, 279 { 0, },
276}; 280};
diff --git a/drivers/gpio/gpio-sta2x11.c b/drivers/gpio/gpio-sta2x11.c
index f2fb12c18da9..68e3fcb1acea 100644
--- a/drivers/gpio/gpio-sta2x11.c
+++ b/drivers/gpio/gpio-sta2x11.c
@@ -146,7 +146,7 @@ static void gsta_gpio_setup(struct gsta_gpio *chip) /* called from probe */
146 gpio->dbg_show = NULL; 146 gpio->dbg_show = NULL;
147 gpio->base = gpio_base; 147 gpio->base = gpio_base;
148 gpio->ngpio = GSTA_NR_GPIO; 148 gpio->ngpio = GSTA_NR_GPIO;
149 gpio->can_sleep = 0; 149 gpio->can_sleep = false;
150 gpio->to_irq = gsta_gpio_to_irq; 150 gpio->to_irq = gsta_gpio_to_irq;
151 151
152 /* 152 /*
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 2647e243d471..2776a09bee58 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -129,7 +129,7 @@ static struct gpio_chip template_chip = {
129 .set = stmpe_gpio_set, 129 .set = stmpe_gpio_set,
130 .to_irq = stmpe_gpio_to_irq, 130 .to_irq = stmpe_gpio_to_irq,
131 .request = stmpe_gpio_request, 131 .request = stmpe_gpio_request,
132 .can_sleep = 1, 132 .can_sleep = true,
133}; 133};
134 134
135static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type) 135static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type)
diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c
index d2983e9ad6af..13d73fb2b5e1 100644
--- a/drivers/gpio/gpio-sx150x.c
+++ b/drivers/gpio/gpio-sx150x.c
@@ -436,7 +436,7 @@ static void sx150x_init_chip(struct sx150x_chip *chip,
436 chip->gpio_chip.set = sx150x_gpio_set; 436 chip->gpio_chip.set = sx150x_gpio_set;
437 chip->gpio_chip.to_irq = sx150x_gpio_to_irq; 437 chip->gpio_chip.to_irq = sx150x_gpio_to_irq;
438 chip->gpio_chip.base = pdata->gpio_base; 438 chip->gpio_chip.base = pdata->gpio_base;
439 chip->gpio_chip.can_sleep = 1; 439 chip->gpio_chip.can_sleep = true;
440 chip->gpio_chip.ngpio = chip->dev_cfg->ngpios; 440 chip->gpio_chip.ngpio = chip->dev_cfg->ngpios;
441 if (pdata->oscio_is_gpo) 441 if (pdata->oscio_is_gpo)
442 ++chip->gpio_chip.ngpio; 442 ++chip->gpio_chip.ngpio;
diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
index da071ddbad99..07bce97647a6 100644
--- a/drivers/gpio/gpio-tb10x.c
+++ b/drivers/gpio/gpio-tb10x.c
@@ -222,7 +222,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev)
222 tb10x_gpio->gc.free = tb10x_gpio_free; 222 tb10x_gpio->gc.free = tb10x_gpio_free;
223 tb10x_gpio->gc.base = -1; 223 tb10x_gpio->gc.base = -1;
224 tb10x_gpio->gc.ngpio = ngpio; 224 tb10x_gpio->gc.ngpio = ngpio;
225 tb10x_gpio->gc.can_sleep = 0; 225 tb10x_gpio->gc.can_sleep = false;
226 226
227 227
228 ret = gpiochip_add(&tb10x_gpio->gc); 228 ret = gpiochip_add(&tb10x_gpio->gc);
@@ -318,7 +318,7 @@ static struct platform_driver tb10x_gpio_driver = {
318 .remove = tb10x_gpio_remove, 318 .remove = tb10x_gpio_remove,
319 .driver = { 319 .driver = {
320 .name = "tb10x-gpio", 320 .name = "tb10x-gpio",
321 .of_match_table = of_match_ptr(tb10x_gpio_dt_ids), 321 .of_match_table = tb10x_gpio_dt_ids,
322 .owner = THIS_MODULE, 322 .owner = THIS_MODULE,
323 } 323 }
324}; 324};
diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
index ddb5fefaa715..1019320984d7 100644
--- a/drivers/gpio/gpio-tc3589x.c
+++ b/drivers/gpio/gpio-tc3589x.c
@@ -127,7 +127,7 @@ static struct gpio_chip template_chip = {
127 .direction_output = tc3589x_gpio_direction_output, 127 .direction_output = tc3589x_gpio_direction_output,
128 .set = tc3589x_gpio_set, 128 .set = tc3589x_gpio_set,
129 .to_irq = tc3589x_gpio_to_irq, 129 .to_irq = tc3589x_gpio_to_irq,
130 .can_sleep = 1, 130 .can_sleep = true,
131}; 131};
132 132
133static int tc3589x_gpio_irq_set_type(struct irq_data *d, unsigned int type) 133static int tc3589x_gpio_irq_set_type(struct irq_data *d, unsigned int type)
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index cfd3b9037bc7..2b49f878b56c 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -425,6 +425,7 @@ static int tegra_gpio_probe(struct platform_device *pdev)
425 struct tegra_gpio_soc_config *config; 425 struct tegra_gpio_soc_config *config;
426 struct resource *res; 426 struct resource *res;
427 struct tegra_gpio_bank *bank; 427 struct tegra_gpio_bank *bank;
428 int ret;
428 int gpio; 429 int gpio;
429 int i; 430 int i;
430 int j; 431 int j;
@@ -494,7 +495,11 @@ static int tegra_gpio_probe(struct platform_device *pdev)
494 495
495 tegra_gpio_chip.of_node = pdev->dev.of_node; 496 tegra_gpio_chip.of_node = pdev->dev.of_node;
496 497
497 gpiochip_add(&tegra_gpio_chip); 498 ret = gpiochip_add(&tegra_gpio_chip);
499 if (ret < 0) {
500 irq_domain_remove(irq_domain);
501 return ret;
502 }
498 503
499 for (gpio = 0; gpio < tegra_gpio_chip.ngpio; gpio++) { 504 for (gpio = 0; gpio < tegra_gpio_chip.ngpio; gpio++) {
500 int irq = irq_create_mapping(irq_domain, gpio); 505 int irq = irq_create_mapping(irq_domain, gpio);
diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c
index 7a0e956ef1ed..f9a8fbde108e 100644
--- a/drivers/gpio/gpio-timberdale.c
+++ b/drivers/gpio/gpio-timberdale.c
@@ -275,7 +275,7 @@ static int timbgpio_probe(struct platform_device *pdev)
275 gc->dbg_show = NULL; 275 gc->dbg_show = NULL;
276 gc->base = pdata->gpio_base; 276 gc->base = pdata->gpio_base;
277 gc->ngpio = pdata->nr_pins; 277 gc->ngpio = pdata->nr_pins;
278 gc->can_sleep = 0; 278 gc->can_sleep = false;
279 279
280 err = gpiochip_add(gc); 280 err = gpiochip_add(gc);
281 if (err) 281 if (err)
@@ -290,8 +290,8 @@ static int timbgpio_probe(struct platform_device *pdev)
290 return 0; 290 return 0;
291 291
292 for (i = 0; i < pdata->nr_pins; i++) { 292 for (i = 0; i < pdata->nr_pins; i++) {
293 irq_set_chip_and_handler_name(tgpio->irq_base + i, 293 irq_set_chip_and_handler(tgpio->irq_base + i,
294 &timbgpio_irqchip, handle_simple_irq, "mux"); 294 &timbgpio_irqchip, handle_simple_irq);
295 irq_set_chip_data(tgpio->irq_base + i, tgpio); 295 irq_set_chip_data(tgpio->irq_base + i, tgpio);
296#ifdef CONFIG_ARM 296#ifdef CONFIG_ARM
297 set_irq_flags(tgpio->irq_base + i, IRQF_VALID | IRQF_PROBE); 297 set_irq_flags(tgpio->irq_base + i, IRQF_VALID | IRQF_PROBE);
diff --git a/drivers/gpio/gpio-tnetv107x.c b/drivers/gpio/gpio-tnetv107x.c
index 58445bb69106..4aa481579a05 100644
--- a/drivers/gpio/gpio-tnetv107x.c
+++ b/drivers/gpio/gpio-tnetv107x.c
@@ -176,7 +176,7 @@ static int __init tnetv107x_gpio_setup(void)
176 ctlr = &chips[i]; 176 ctlr = &chips[i];
177 177
178 ctlr->chip.label = "tnetv107x"; 178 ctlr->chip.label = "tnetv107x";
179 ctlr->chip.can_sleep = 0; 179 ctlr->chip.can_sleep = false;
180 ctlr->chip.base = base; 180 ctlr->chip.base = base;
181 ctlr->chip.ngpio = ngpio - base; 181 ctlr->chip.ngpio = ngpio - base;
182 if (ctlr->chip.ngpio > 32) 182 if (ctlr->chip.ngpio > 32)
diff --git a/drivers/gpio/gpio-tps6586x.c b/drivers/gpio/gpio-tps6586x.c
index 29e8e750bd49..8994dfa13491 100644
--- a/drivers/gpio/gpio-tps6586x.c
+++ b/drivers/gpio/gpio-tps6586x.c
@@ -108,7 +108,7 @@ static int tps6586x_gpio_probe(struct platform_device *pdev)
108 tps6586x_gpio->gpio_chip.label = pdev->name; 108 tps6586x_gpio->gpio_chip.label = pdev->name;
109 tps6586x_gpio->gpio_chip.dev = &pdev->dev; 109 tps6586x_gpio->gpio_chip.dev = &pdev->dev;
110 tps6586x_gpio->gpio_chip.ngpio = 4; 110 tps6586x_gpio->gpio_chip.ngpio = 4;
111 tps6586x_gpio->gpio_chip.can_sleep = 1; 111 tps6586x_gpio->gpio_chip.can_sleep = true;
112 112
113 /* FIXME: add handling of GPIOs as dedicated inputs */ 113 /* FIXME: add handling of GPIOs as dedicated inputs */
114 tps6586x_gpio->gpio_chip.direction_output = tps6586x_gpio_output; 114 tps6586x_gpio->gpio_chip.direction_output = tps6586x_gpio_output;
diff --git a/drivers/gpio/gpio-tps65910.c b/drivers/gpio/gpio-tps65910.c
index 06146219d9d2..b6e818e68007 100644
--- a/drivers/gpio/gpio-tps65910.c
+++ b/drivers/gpio/gpio-tps65910.c
@@ -143,7 +143,7 @@ static int tps65910_gpio_probe(struct platform_device *pdev)
143 default: 143 default:
144 return -EINVAL; 144 return -EINVAL;
145 } 145 }
146 tps65910_gpio->gpio_chip.can_sleep = 1; 146 tps65910_gpio->gpio_chip.can_sleep = true;
147 tps65910_gpio->gpio_chip.direction_input = tps65910_gpio_input; 147 tps65910_gpio->gpio_chip.direction_input = tps65910_gpio_input;
148 tps65910_gpio->gpio_chip.direction_output = tps65910_gpio_output; 148 tps65910_gpio->gpio_chip.direction_output = tps65910_gpio_output;
149 tps65910_gpio->gpio_chip.set = tps65910_gpio_set; 149 tps65910_gpio->gpio_chip.set = tps65910_gpio_set;
diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
index 276a4229b032..59ee486cb8b9 100644
--- a/drivers/gpio/gpio-tps65912.c
+++ b/drivers/gpio/gpio-tps65912.c
@@ -79,7 +79,7 @@ static struct gpio_chip template_chip = {
79 .direction_output = tps65912_gpio_output, 79 .direction_output = tps65912_gpio_output,
80 .get = tps65912_gpio_get, 80 .get = tps65912_gpio_get,
81 .set = tps65912_gpio_set, 81 .set = tps65912_gpio_set,
82 .can_sleep = 1, 82 .can_sleep = true,
83 .ngpio = 5, 83 .ngpio = 5,
84 .base = -1, 84 .base = -1,
85}; 85};
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index f9996899c1f2..8b88ca2eda9c 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -396,7 +396,7 @@ static struct gpio_chip template_chip = {
396 .direction_output = twl_direction_out, 396 .direction_output = twl_direction_out,
397 .set = twl_set, 397 .set = twl_set,
398 .to_irq = twl_to_irq, 398 .to_irq = twl_to_irq,
399 .can_sleep = 1, 399 .can_sleep = true,
400}; 400};
401 401
402/*----------------------------------------------------------------------*/ 402/*----------------------------------------------------------------------*/
diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c
index d420d30b86e7..0caf5cd1b47d 100644
--- a/drivers/gpio/gpio-twl6040.c
+++ b/drivers/gpio/gpio-twl6040.c
@@ -77,7 +77,7 @@ static struct gpio_chip twl6040gpo_chip = {
77 .get = twl6040gpo_get, 77 .get = twl6040gpo_get,
78 .direction_output = twl6040gpo_direction_out, 78 .direction_output = twl6040gpo_direction_out,
79 .set = twl6040gpo_set, 79 .set = twl6040gpo_set,
80 .can_sleep = 1, 80 .can_sleep = true,
81}; 81};
82 82
83/*----------------------------------------------------------------------*/ 83/*----------------------------------------------------------------------*/
diff --git a/drivers/gpio/gpio-ucb1400.c b/drivers/gpio/gpio-ucb1400.c
index 06fb5cf99ded..2445fe771179 100644
--- a/drivers/gpio/gpio-ucb1400.c
+++ b/drivers/gpio/gpio-ucb1400.c
@@ -64,7 +64,7 @@ static int ucb1400_gpio_probe(struct platform_device *dev)
64 ucb->gc.direction_output = ucb1400_gpio_dir_out; 64 ucb->gc.direction_output = ucb1400_gpio_dir_out;
65 ucb->gc.get = ucb1400_gpio_get; 65 ucb->gc.get = ucb1400_gpio_get;
66 ucb->gc.set = ucb1400_gpio_set; 66 ucb->gc.set = ucb1400_gpio_set;
67 ucb->gc.can_sleep = 1; 67 ucb->gc.can_sleep = true;
68 68
69 err = gpiochip_add(&ucb->gc); 69 err = gpiochip_add(&ucb->gc);
70 if (err) 70 if (err)
diff --git a/drivers/gpio/gpio-viperboard.c b/drivers/gpio/gpio-viperboard.c
index 5ac2919197fe..79e3b5836712 100644
--- a/drivers/gpio/gpio-viperboard.c
+++ b/drivers/gpio/gpio-viperboard.c
@@ -413,7 +413,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev)
413 vb_gpio->gpioa.owner = THIS_MODULE; 413 vb_gpio->gpioa.owner = THIS_MODULE;
414 vb_gpio->gpioa.base = -1; 414 vb_gpio->gpioa.base = -1;
415 vb_gpio->gpioa.ngpio = 16; 415 vb_gpio->gpioa.ngpio = 16;
416 vb_gpio->gpioa.can_sleep = 1; 416 vb_gpio->gpioa.can_sleep = true;
417 vb_gpio->gpioa.set = vprbrd_gpioa_set; 417 vb_gpio->gpioa.set = vprbrd_gpioa_set;
418 vb_gpio->gpioa.get = vprbrd_gpioa_get; 418 vb_gpio->gpioa.get = vprbrd_gpioa_get;
419 vb_gpio->gpioa.direction_input = vprbrd_gpioa_direction_input; 419 vb_gpio->gpioa.direction_input = vprbrd_gpioa_direction_input;
@@ -430,7 +430,7 @@ static int vprbrd_gpio_probe(struct platform_device *pdev)
430 vb_gpio->gpiob.owner = THIS_MODULE; 430 vb_gpio->gpiob.owner = THIS_MODULE;
431 vb_gpio->gpiob.base = -1; 431 vb_gpio->gpiob.base = -1;
432 vb_gpio->gpiob.ngpio = 16; 432 vb_gpio->gpiob.ngpio = 16;
433 vb_gpio->gpiob.can_sleep = 1; 433 vb_gpio->gpiob.can_sleep = true;
434 vb_gpio->gpiob.set = vprbrd_gpiob_set; 434 vb_gpio->gpiob.set = vprbrd_gpiob_set;
435 vb_gpio->gpiob.get = vprbrd_gpiob_get; 435 vb_gpio->gpiob.get = vprbrd_gpiob_get;
436 vb_gpio->gpiob.direction_input = vprbrd_gpiob_direction_input; 436 vb_gpio->gpiob.direction_input = vprbrd_gpiob_direction_input;
diff --git a/drivers/gpio/gpio-vx855.c b/drivers/gpio/gpio-vx855.c
index cddfa22edb41..0fd23b6a753d 100644
--- a/drivers/gpio/gpio-vx855.c
+++ b/drivers/gpio/gpio-vx855.c
@@ -214,7 +214,7 @@ static void vx855gpio_gpio_setup(struct vx855_gpio *vg)
214 c->dbg_show = NULL; 214 c->dbg_show = NULL;
215 c->base = 0; 215 c->base = 0;
216 c->ngpio = NR_VX855_GP; 216 c->ngpio = NR_VX855_GP;
217 c->can_sleep = 0; 217 c->can_sleep = false;
218 c->names = vx855gpio_names; 218 c->names = vx855gpio_names;
219} 219}
220 220
diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c
index 456000c5c457..b18a1a26425e 100644
--- a/drivers/gpio/gpio-wm831x.c
+++ b/drivers/gpio/gpio-wm831x.c
@@ -240,7 +240,7 @@ static struct gpio_chip template_chip = {
240 .to_irq = wm831x_gpio_to_irq, 240 .to_irq = wm831x_gpio_to_irq,
241 .set_debounce = wm831x_gpio_set_debounce, 241 .set_debounce = wm831x_gpio_set_debounce,
242 .dbg_show = wm831x_gpio_dbg_show, 242 .dbg_show = wm831x_gpio_dbg_show,
243 .can_sleep = 1, 243 .can_sleep = true,
244}; 244};
245 245
246static int wm831x_gpio_probe(struct platform_device *pdev) 246static int wm831x_gpio_probe(struct platform_device *pdev)
diff --git a/drivers/gpio/gpio-wm8350.c b/drivers/gpio/gpio-wm8350.c
index fc49154be7b1..2487f9d575d3 100644
--- a/drivers/gpio/gpio-wm8350.c
+++ b/drivers/gpio/gpio-wm8350.c
@@ -106,7 +106,7 @@ static struct gpio_chip template_chip = {
106 .direction_output = wm8350_gpio_direction_out, 106 .direction_output = wm8350_gpio_direction_out,
107 .set = wm8350_gpio_set, 107 .set = wm8350_gpio_set,
108 .to_irq = wm8350_gpio_to_irq, 108 .to_irq = wm8350_gpio_to_irq,
109 .can_sleep = 1, 109 .can_sleep = true,
110}; 110};
111 111
112static int wm8350_gpio_probe(struct platform_device *pdev) 112static int wm8350_gpio_probe(struct platform_device *pdev)
diff --git a/drivers/gpio/gpio-wm8994.c b/drivers/gpio/gpio-wm8994.c
index a53dbdefc7ee..d93b6b581677 100644
--- a/drivers/gpio/gpio-wm8994.c
+++ b/drivers/gpio/gpio-wm8994.c
@@ -242,7 +242,7 @@ static struct gpio_chip template_chip = {
242 .set = wm8994_gpio_set, 242 .set = wm8994_gpio_set,
243 .to_irq = wm8994_gpio_to_irq, 243 .to_irq = wm8994_gpio_to_irq,
244 .dbg_show = wm8994_gpio_dbg_show, 244 .dbg_show = wm8994_gpio_dbg_show,
245 .can_sleep = 1, 245 .can_sleep = true,
246}; 246};
247 247
248static int wm8994_gpio_probe(struct platform_device *pdev) 248static int wm8994_gpio_probe(struct platform_device *pdev)
diff --git a/drivers/gpio/gpio-xtensa.c b/drivers/gpio/gpio-xtensa.c
new file mode 100644
index 000000000000..1d136eceda62
--- /dev/null
+++ b/drivers/gpio/gpio-xtensa.c
@@ -0,0 +1,163 @@
1/*
2 * Copyright (C) 2013 TangoTec Ltd.
3 * Author: Baruch Siach <baruch@tkos.co.il>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Driver for the Xtensa LX4 GPIO32 Option
10 *
11 * Documentation: Xtensa LX4 Microprocessor Data Book, Section 2.22
12 *
13 * GPIO32 is a standard optional extension to the Xtensa architecture core that
14 * provides preconfigured output and input ports for intra SoC signaling. The
15 * GPIO32 option is implemented as 32bit Tensilica Instruction Extension (TIE)
16 * output state called EXPSTATE, and 32bit input wire called IMPWIRE. This
17 * driver treats input and output states as two distinct devices.
18 *
19 * Access to GPIO32 specific instructions is controlled by the CPENABLE
20 * (Coprocessor Enable Bits) register. By default Xtensa Linux startup code
21 * disables access to all coprocessors. This driver sets the CPENABLE bit
22 * corresponding to GPIO32 before any GPIO32 specific instruction, and restores
23 * CPENABLE state after that.
24 *
25 * This driver is currently incompatible with SMP. The GPIO32 extension is not
26 * guaranteed to be available in all cores. Moreover, each core controls a
27 * different set of IO wires. A theoretical SMP aware version of this driver
28 * would need to have a per core workqueue to do the actual GPIO manipulation.
29 */
30
31#include <linux/err.h>
32#include <linux/module.h>
33#include <linux/gpio.h>
34#include <linux/bitops.h>
35#include <linux/platform_device.h>
36
37#include <asm/coprocessor.h> /* CPENABLE read/write macros */
38
39#ifndef XCHAL_CP_ID_XTIOP
40#error GPIO32 option is not enabled for your xtensa core variant
41#endif
42
43static inline unsigned long enable_cp(unsigned long *cpenable)
44{
45 unsigned long flags;
46
47 local_irq_save(flags);
48 RSR_CPENABLE(*cpenable);
49 WSR_CPENABLE(*cpenable | BIT(XCHAL_CP_ID_XTIOP));
50
51 return flags;
52}
53
54static inline void disable_cp(unsigned long flags, unsigned long cpenable)
55{
56 WSR_CPENABLE(cpenable);
57 local_irq_restore(flags);
58}
59
60static int xtensa_impwire_get_direction(struct gpio_chip *gc, unsigned offset)
61{
62 return 1; /* input only */
63}
64
65static int xtensa_impwire_get_value(struct gpio_chip *gc, unsigned offset)
66{
67 unsigned long flags, saved_cpenable;
68 u32 impwire;
69
70 flags = enable_cp(&saved_cpenable);
71 __asm__ __volatile__("read_impwire %0" : "=a" (impwire));
72 disable_cp(flags, saved_cpenable);
73
74 return !!(impwire & BIT(offset));
75}
76
77static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
78 int value)
79{
80 BUG(); /* output only; should never be called */
81}
82
83static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
84{
85 return 0; /* output only */
86}
87
88static int xtensa_expstate_get_value(struct gpio_chip *gc, unsigned offset)
89{
90 unsigned long flags, saved_cpenable;
91 u32 expstate;
92
93 flags = enable_cp(&saved_cpenable);
94 __asm__ __volatile__("rur.expstate %0" : "=a" (expstate));
95 disable_cp(flags, saved_cpenable);
96
97 return !!(expstate & BIT(offset));
98}
99
100static void xtensa_expstate_set_value(struct gpio_chip *gc, unsigned offset,
101 int value)
102{
103 unsigned long flags, saved_cpenable;
104 u32 mask = BIT(offset);
105 u32 val = value ? BIT(offset) : 0;
106
107 flags = enable_cp(&saved_cpenable);
108 __asm__ __volatile__("wrmsk_expstate %0, %1"
109 :: "a" (val), "a" (mask));
110 disable_cp(flags, saved_cpenable);
111}
112
113static struct gpio_chip impwire_chip = {
114 .label = "impwire",
115 .base = -1,
116 .ngpio = 32,
117 .get_direction = xtensa_impwire_get_direction,
118 .get = xtensa_impwire_get_value,
119 .set = xtensa_impwire_set_value,
120};
121
122static struct gpio_chip expstate_chip = {
123 .label = "expstate",
124 .base = -1,
125 .ngpio = 32,
126 .get_direction = xtensa_expstate_get_direction,
127 .get = xtensa_expstate_get_value,
128 .set = xtensa_expstate_set_value,
129};
130
131static int xtensa_gpio_probe(struct platform_device *pdev)
132{
133 int ret;
134
135 ret = gpiochip_add(&impwire_chip);
136 if (ret)
137 return ret;
138 return gpiochip_add(&expstate_chip);
139}
140
141static struct platform_driver xtensa_gpio_driver = {
142 .driver = {
143 .name = "xtensa-gpio",
144 .owner = THIS_MODULE,
145 },
146 .probe = xtensa_gpio_probe,
147};
148
149static int __init xtensa_gpio_init(void)
150{
151 struct platform_device *pdev;
152
153 pdev = platform_device_register_simple("xtensa-gpio", 0, NULL, 0);
154 if (IS_ERR(pdev))
155 return PTR_ERR(pdev);
156
157 return platform_driver_register(&xtensa_gpio_driver);
158}
159device_initcall(xtensa_gpio_init);
160
161MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>");
162MODULE_DESCRIPTION("Xtensa LX4 GPIO32 driver");
163MODULE_LICENSE("GPL");
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index ae0ffdce8bd5..716ee9843110 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -12,11 +12,13 @@
12 12
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/gpio/consumer.h> 14#include <linux/gpio/consumer.h>
15#include <linux/gpio/driver.h>
15#include <linux/export.h> 16#include <linux/export.h>
16#include <linux/acpi_gpio.h>
17#include <linux/acpi.h> 17#include <linux/acpi.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19 19
20#include "gpiolib.h"
21
20struct acpi_gpio_evt_pin { 22struct acpi_gpio_evt_pin {
21 struct list_head node; 23 struct list_head node;
22 acpi_handle *evt_handle; 24 acpi_handle *evt_handle;
@@ -94,7 +96,7 @@ static void acpi_gpio_evt_dh(acpi_handle handle, void *data)
94 * gpio pins have acpi event methods and assigns interrupt handlers that calls 96 * gpio pins have acpi event methods and assigns interrupt handlers that calls
95 * the acpi event methods for those pins. 97 * the acpi event methods for those pins.
96 */ 98 */
97void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) 99static void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
98{ 100{
99 struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL}; 101 struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
100 struct acpi_resource *res; 102 struct acpi_resource *res;
@@ -192,7 +194,6 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
192 irq); 194 irq);
193 } 195 }
194} 196}
195EXPORT_SYMBOL(acpi_gpiochip_request_interrupts);
196 197
197/** 198/**
198 * acpi_gpiochip_free_interrupts() - Free GPIO _EVT ACPI event interrupts. 199 * acpi_gpiochip_free_interrupts() - Free GPIO _EVT ACPI event interrupts.
@@ -203,7 +204,7 @@ EXPORT_SYMBOL(acpi_gpiochip_request_interrupts);
203 * The remaining ACPI event interrupts associated with the chip are freed 204 * The remaining ACPI event interrupts associated with the chip are freed
204 * automatically. 205 * automatically.
205 */ 206 */
206void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) 207static void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
207{ 208{
208 acpi_handle handle; 209 acpi_handle handle;
209 acpi_status status; 210 acpi_status status;
@@ -230,7 +231,6 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
230 acpi_detach_data(handle, acpi_gpio_evt_dh); 231 acpi_detach_data(handle, acpi_gpio_evt_dh);
231 kfree(evt_pins); 232 kfree(evt_pins);
232} 233}
233EXPORT_SYMBOL(acpi_gpiochip_free_interrupts);
234 234
235struct acpi_gpio_lookup { 235struct acpi_gpio_lookup {
236 struct acpi_gpio_info info; 236 struct acpi_gpio_info info;
@@ -307,6 +307,15 @@ struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
307 if (lookup.desc && info) 307 if (lookup.desc && info)
308 *info = lookup.info; 308 *info = lookup.info;
309 309
310 return lookup.desc ? lookup.desc : ERR_PTR(-ENODEV); 310 return lookup.desc ? lookup.desc : ERR_PTR(-ENOENT);
311}
312
313void acpi_gpiochip_add(struct gpio_chip *chip)
314{
315 acpi_gpiochip_request_interrupts(chip);
316}
317
318void acpi_gpiochip_remove(struct gpio_chip *chip)
319{
320 acpi_gpiochip_free_interrupts(chip);
311} 321}
312EXPORT_SYMBOL_GPL(acpi_get_gpiod_by_index);
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c8a7c810bade..50c4922fe53a 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -10,12 +10,13 @@
10#include <linux/seq_file.h> 10#include <linux/seq_file.h>
11#include <linux/gpio.h> 11#include <linux/gpio.h>
12#include <linux/of_gpio.h> 12#include <linux/of_gpio.h>
13#include <linux/acpi_gpio.h>
14#include <linux/idr.h> 13#include <linux/idr.h>
15#include <linux/slab.h> 14#include <linux/slab.h>
16#include <linux/acpi.h> 15#include <linux/acpi.h>
17#include <linux/gpio/driver.h> 16#include <linux/gpio/driver.h>
18 17
18#include "gpiolib.h"
19
19#define CREATE_TRACE_POINTS 20#define CREATE_TRACE_POINTS
20#include <trace/events/gpio.h> 21#include <trace/events/gpio.h>
21 22
@@ -84,40 +85,57 @@ static DEFINE_IDR(dirent_idr);
84static int gpiod_request(struct gpio_desc *desc, const char *label); 85static int gpiod_request(struct gpio_desc *desc, const char *label);
85static void gpiod_free(struct gpio_desc *desc); 86static void gpiod_free(struct gpio_desc *desc);
86 87
88/* With descriptor prefix */
89
87#ifdef CONFIG_DEBUG_FS 90#ifdef CONFIG_DEBUG_FS
88#define gpiod_emerg(desc, fmt, ...) \ 91#define gpiod_emerg(desc, fmt, ...) \
89 pr_emerg("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label, \ 92 pr_emerg("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\
90 ##__VA_ARGS__) 93 ##__VA_ARGS__)
91#define gpiod_crit(desc, fmt, ...) \ 94#define gpiod_crit(desc, fmt, ...) \
92 pr_crit("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label, \ 95 pr_crit("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \
93 ##__VA_ARGS__) 96 ##__VA_ARGS__)
94#define gpiod_err(desc, fmt, ...) \ 97#define gpiod_err(desc, fmt, ...) \
95 pr_err("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label, \ 98 pr_err("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \
96 ##__VA_ARGS__) 99 ##__VA_ARGS__)
97#define gpiod_warn(desc, fmt, ...) \ 100#define gpiod_warn(desc, fmt, ...) \
98 pr_warn("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label, \ 101 pr_warn("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \
99 ##__VA_ARGS__) 102 ##__VA_ARGS__)
100#define gpiod_info(desc, fmt, ...) \ 103#define gpiod_info(desc, fmt, ...) \
101 pr_info("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label, \ 104 pr_info("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \
102 ##__VA_ARGS__) 105 ##__VA_ARGS__)
103#define gpiod_dbg(desc, fmt, ...) \ 106#define gpiod_dbg(desc, fmt, ...) \
104 pr_debug("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label, \ 107 pr_debug("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\
105 ##__VA_ARGS__) 108 ##__VA_ARGS__)
106#else 109#else
107#define gpiod_emerg(desc, fmt, ...) \ 110#define gpiod_emerg(desc, fmt, ...) \
108 pr_emerg("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__) 111 pr_emerg("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
109#define gpiod_crit(desc, fmt, ...) \ 112#define gpiod_crit(desc, fmt, ...) \
110 pr_crit("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__) 113 pr_crit("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
111#define gpiod_err(desc, fmt, ...) \ 114#define gpiod_err(desc, fmt, ...) \
112 pr_err("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__) 115 pr_err("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
113#define gpiod_warn(desc, fmt, ...) \ 116#define gpiod_warn(desc, fmt, ...) \
114 pr_warn("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__) 117 pr_warn("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
115#define gpiod_info(desc, fmt, ...) \ 118#define gpiod_info(desc, fmt, ...) \
116 pr_info("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__) 119 pr_info("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
117#define gpiod_dbg(desc, fmt, ...) \ 120#define gpiod_dbg(desc, fmt, ...) \
118 pr_debug("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__) 121 pr_debug("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
119#endif 122#endif
120 123
124/* With chip prefix */
125
126#define chip_emerg(chip, fmt, ...) \
127 pr_emerg("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
128#define chip_crit(chip, fmt, ...) \
129 pr_crit("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
130#define chip_err(chip, fmt, ...) \
131 pr_err("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
132#define chip_warn(chip, fmt, ...) \
133 pr_warn("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
134#define chip_info(chip, fmt, ...) \
135 pr_info("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
136#define chip_dbg(chip, fmt, ...) \
137 pr_debug("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
138
121static inline void desc_set_label(struct gpio_desc *d, const char *label) 139static inline void desc_set_label(struct gpio_desc *d, const char *label)
122{ 140{
123#ifdef CONFIG_DEBUG_FS 141#ifdef CONFIG_DEBUG_FS
@@ -151,9 +169,10 @@ EXPORT_SYMBOL_GPL(gpio_to_desc);
151static struct gpio_desc *gpiochip_offset_to_desc(struct gpio_chip *chip, 169static struct gpio_desc *gpiochip_offset_to_desc(struct gpio_chip *chip,
152 unsigned int offset) 170 unsigned int offset)
153{ 171{
154 unsigned int gpio = chip->base + offset; 172 if (offset >= chip->ngpio)
173 return ERR_PTR(-EINVAL);
155 174
156 return gpio_to_desc(gpio); 175 return &chip->desc[offset];
157} 176}
158 177
159/** 178/**
@@ -187,7 +206,8 @@ static int gpio_ensure_requested(struct gpio_desc *desc)
187 if (WARN(test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0, 206 if (WARN(test_and_set_bit(FLAG_REQUESTED, &desc->flags) == 0,
188 "autorequest GPIO-%d\n", gpio)) { 207 "autorequest GPIO-%d\n", gpio)) {
189 if (!try_module_get(chip->owner)) { 208 if (!try_module_get(chip->owner)) {
190 pr_err("GPIO-%d: module can't be gotten \n", gpio); 209 gpiod_err(desc, "%s: module can't be gotten\n",
210 __func__);
191 clear_bit(FLAG_REQUESTED, &desc->flags); 211 clear_bit(FLAG_REQUESTED, &desc->flags);
192 /* lose */ 212 /* lose */
193 return -EIO; 213 return -EIO;
@@ -808,8 +828,8 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
808 if (!test_bit(FLAG_REQUESTED, &desc->flags) || 828 if (!test_bit(FLAG_REQUESTED, &desc->flags) ||
809 test_bit(FLAG_EXPORT, &desc->flags)) { 829 test_bit(FLAG_EXPORT, &desc->flags)) {
810 spin_unlock_irqrestore(&gpio_lock, flags); 830 spin_unlock_irqrestore(&gpio_lock, flags);
811 pr_debug("%s: gpio %d unavailable (requested=%d, exported=%d)\n", 831 gpiod_dbg(desc, "%s: unavailable (requested=%d, exported=%d)\n",
812 __func__, desc_to_gpio(desc), 832 __func__,
813 test_bit(FLAG_REQUESTED, &desc->flags), 833 test_bit(FLAG_REQUESTED, &desc->flags),
814 test_bit(FLAG_EXPORT, &desc->flags)); 834 test_bit(FLAG_EXPORT, &desc->flags));
815 status = -EPERM; 835 status = -EPERM;
@@ -857,8 +877,7 @@ fail_unregister_device:
857 device_unregister(dev); 877 device_unregister(dev);
858fail_unlock: 878fail_unlock:
859 mutex_unlock(&sysfs_lock); 879 mutex_unlock(&sysfs_lock);
860 pr_debug("%s: gpio%d status %d\n", __func__, desc_to_gpio(desc), 880 gpiod_dbg(desc, "%s: status %d\n", __func__, status);
861 status);
862 return status; 881 return status;
863} 882}
864EXPORT_SYMBOL_GPL(gpiod_export); 883EXPORT_SYMBOL_GPL(gpiod_export);
@@ -906,8 +925,7 @@ int gpiod_export_link(struct device *dev, const char *name,
906 mutex_unlock(&sysfs_lock); 925 mutex_unlock(&sysfs_lock);
907 926
908 if (status) 927 if (status)
909 pr_debug("%s: gpio%d status %d\n", __func__, desc_to_gpio(desc), 928 gpiod_dbg(desc, "%s: status %d\n", __func__, status);
910 status);
911 929
912 return status; 930 return status;
913} 931}
@@ -951,8 +969,7 @@ unlock:
951 mutex_unlock(&sysfs_lock); 969 mutex_unlock(&sysfs_lock);
952 970
953 if (status) 971 if (status)
954 pr_debug("%s: gpio%d status %d\n", __func__, desc_to_gpio(desc), 972 gpiod_dbg(desc, "%s: status %d\n", __func__, status);
955 status);
956 973
957 return status; 974 return status;
958} 975}
@@ -994,8 +1011,7 @@ void gpiod_unexport(struct gpio_desc *desc)
994 } 1011 }
995 1012
996 if (status) 1013 if (status)
997 pr_debug("%s: gpio%d status %d\n", __func__, desc_to_gpio(desc), 1014 gpiod_dbg(desc, "%s: status %d\n", __func__, status);
998 status);
999} 1015}
1000EXPORT_SYMBOL_GPL(gpiod_unexport); 1016EXPORT_SYMBOL_GPL(gpiod_unexport);
1001 1017
@@ -1034,8 +1050,7 @@ static int gpiochip_export(struct gpio_chip *chip)
1034 chip->desc[gpio++].chip = NULL; 1050 chip->desc[gpio++].chip = NULL;
1035 spin_unlock_irqrestore(&gpio_lock, flags); 1051 spin_unlock_irqrestore(&gpio_lock, flags);
1036 1052
1037 pr_debug("%s: chip %s status %d\n", __func__, 1053 chip_dbg(chip, "%s: status %d\n", __func__, status);
1038 chip->label, status);
1039 } 1054 }
1040 1055
1041 return status; 1056 return status;
@@ -1051,15 +1066,14 @@ static void gpiochip_unexport(struct gpio_chip *chip)
1051 if (dev) { 1066 if (dev) {
1052 put_device(dev); 1067 put_device(dev);
1053 device_unregister(dev); 1068 device_unregister(dev);
1054 chip->exported = 0; 1069 chip->exported = false;
1055 status = 0; 1070 status = 0;
1056 } else 1071 } else
1057 status = -ENODEV; 1072 status = -ENODEV;
1058 mutex_unlock(&sysfs_lock); 1073 mutex_unlock(&sysfs_lock);
1059 1074
1060 if (status) 1075 if (status)
1061 pr_debug("%s: chip %s status %d\n", __func__, 1076 chip_dbg(chip, "%s: status %d\n", __func__, status);
1062 chip->label, status);
1063} 1077}
1064 1078
1065static int __init gpiolib_sysfs_init(void) 1079static int __init gpiolib_sysfs_init(void)
@@ -1213,6 +1227,7 @@ int gpiochip_add(struct gpio_chip *chip)
1213#endif 1227#endif
1214 1228
1215 of_gpiochip_add(chip); 1229 of_gpiochip_add(chip);
1230 acpi_gpiochip_add(chip);
1216 1231
1217 if (status) 1232 if (status)
1218 goto fail; 1233 goto fail;
@@ -1221,7 +1236,7 @@ int gpiochip_add(struct gpio_chip *chip)
1221 if (status) 1236 if (status)
1222 goto fail; 1237 goto fail;
1223 1238
1224 pr_debug("gpiochip_add: registered GPIOs %d to %d on device: %s\n", 1239 pr_debug("%s: registered GPIOs %d to %d on device: %s\n", __func__,
1225 chip->base, chip->base + chip->ngpio - 1, 1240 chip->base, chip->base + chip->ngpio - 1,
1226 chip->label ? : "generic"); 1241 chip->label ? : "generic");
1227 1242
@@ -1231,7 +1246,7 @@ unlock:
1231 spin_unlock_irqrestore(&gpio_lock, flags); 1246 spin_unlock_irqrestore(&gpio_lock, flags);
1232fail: 1247fail:
1233 /* failures here can mean systems won't boot... */ 1248 /* failures here can mean systems won't boot... */
1234 pr_err("gpiochip_add: gpios %d..%d (%s) failed to register\n", 1249 pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__,
1235 chip->base, chip->base + chip->ngpio - 1, 1250 chip->base, chip->base + chip->ngpio - 1,
1236 chip->label ? : "generic"); 1251 chip->label ? : "generic");
1237 return status; 1252 return status;
@@ -1254,6 +1269,7 @@ int gpiochip_remove(struct gpio_chip *chip)
1254 1269
1255 gpiochip_remove_pin_ranges(chip); 1270 gpiochip_remove_pin_ranges(chip);
1256 of_gpiochip_remove(chip); 1271 of_gpiochip_remove(chip);
1272 acpi_gpiochip_remove(chip);
1257 1273
1258 for (id = 0; id < chip->ngpio; id++) { 1274 for (id = 0; id < chip->ngpio; id++) {
1259 if (test_bit(FLAG_REQUESTED, &chip->desc[id].flags)) { 1275 if (test_bit(FLAG_REQUESTED, &chip->desc[id].flags)) {
@@ -1339,8 +1355,7 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip,
1339 1355
1340 pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); 1356 pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL);
1341 if (!pin_range) { 1357 if (!pin_range) {
1342 pr_err("%s: GPIO chip: failed to allocate pin ranges\n", 1358 chip_err(chip, "failed to allocate pin ranges\n");
1343 chip->label);
1344 return -ENOMEM; 1359 return -ENOMEM;
1345 } 1360 }
1346 1361
@@ -1361,9 +1376,8 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip,
1361 1376
1362 pinctrl_add_gpio_range(pctldev, &pin_range->range); 1377 pinctrl_add_gpio_range(pctldev, &pin_range->range);
1363 1378
1364 pr_debug("GPIO chip %s: created GPIO range %d->%d ==> %s PINGRP %s\n", 1379 chip_dbg(chip, "created GPIO range %d->%d ==> %s PINGRP %s\n",
1365 chip->label, gpio_offset, 1380 gpio_offset, gpio_offset + pin_range->range.npins - 1,
1366 gpio_offset + pin_range->range.npins - 1,
1367 pinctrl_dev_get_devname(pctldev), pin_group); 1381 pinctrl_dev_get_devname(pctldev), pin_group);
1368 1382
1369 list_add_tail(&pin_range->node, &chip->pin_ranges); 1383 list_add_tail(&pin_range->node, &chip->pin_ranges);
@@ -1390,8 +1404,7 @@ int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
1390 1404
1391 pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); 1405 pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL);
1392 if (!pin_range) { 1406 if (!pin_range) {
1393 pr_err("%s: GPIO chip: failed to allocate pin ranges\n", 1407 chip_err(chip, "failed to allocate pin ranges\n");
1394 chip->label);
1395 return -ENOMEM; 1408 return -ENOMEM;
1396 } 1409 }
1397 1410
@@ -1406,13 +1419,12 @@ int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
1406 &pin_range->range); 1419 &pin_range->range);
1407 if (IS_ERR(pin_range->pctldev)) { 1420 if (IS_ERR(pin_range->pctldev)) {
1408 ret = PTR_ERR(pin_range->pctldev); 1421 ret = PTR_ERR(pin_range->pctldev);
1409 pr_err("%s: GPIO chip: could not create pin range\n", 1422 chip_err(chip, "could not create pin range\n");
1410 chip->label);
1411 kfree(pin_range); 1423 kfree(pin_range);
1412 return ret; 1424 return ret;
1413 } 1425 }
1414 pr_debug("GPIO chip %s: created GPIO range %d->%d ==> %s PIN %d->%d\n", 1426 chip_dbg(chip, "created GPIO range %d->%d ==> %s PIN %d->%d\n",
1415 chip->label, gpio_offset, gpio_offset + npins - 1, 1427 gpio_offset, gpio_offset + npins - 1,
1416 pinctl_name, 1428 pinctl_name,
1417 pin_offset, pin_offset + npins - 1); 1429 pin_offset, pin_offset + npins - 1);
1418 1430
@@ -1499,8 +1511,7 @@ static int gpiod_request(struct gpio_desc *desc, const char *label)
1499 } 1511 }
1500done: 1512done:
1501 if (status) 1513 if (status)
1502 pr_debug("_gpio_request: gpio-%d (%s) status %d\n", 1514 gpiod_dbg(desc, "%s: status %d\n", __func__, status);
1503 desc_to_gpio(desc), label ? : "?", status);
1504 spin_unlock_irqrestore(&gpio_lock, flags); 1515 spin_unlock_irqrestore(&gpio_lock, flags);
1505 return status; 1516 return status;
1506} 1517}
@@ -1701,7 +1712,7 @@ int gpiod_direction_input(struct gpio_desc *desc)
1701 if (!chip->get || !chip->direction_input) { 1712 if (!chip->get || !chip->direction_input) {
1702 gpiod_warn(desc, 1713 gpiod_warn(desc,
1703 "%s: missing get() or direction_input() operations\n", 1714 "%s: missing get() or direction_input() operations\n",
1704 __func__); 1715 __func__);
1705 return -EIO; 1716 return -EIO;
1706 } 1717 }
1707 1718
@@ -1721,7 +1732,8 @@ int gpiod_direction_input(struct gpio_desc *desc)
1721 if (status) { 1732 if (status) {
1722 status = chip->request(chip, offset); 1733 status = chip->request(chip, offset);
1723 if (status < 0) { 1734 if (status < 0) {
1724 gpiod_dbg(desc, "chip request fail, %d\n", status); 1735 gpiod_dbg(desc, "%s: chip request fail, %d\n",
1736 __func__, status);
1725 /* and it's not available to anyone else ... 1737 /* and it's not available to anyone else ...
1726 * gpio_request() is the fully clean solution. 1738 * gpio_request() is the fully clean solution.
1727 */ 1739 */
@@ -1739,7 +1751,7 @@ lose:
1739fail: 1751fail:
1740 spin_unlock_irqrestore(&gpio_lock, flags); 1752 spin_unlock_irqrestore(&gpio_lock, flags);
1741 if (status) 1753 if (status)
1742 gpiod_dbg(desc, "%s status %d\n", __func__, status); 1754 gpiod_dbg(desc, "%s: status %d\n", __func__, status);
1743 return status; 1755 return status;
1744} 1756}
1745EXPORT_SYMBOL_GPL(gpiod_direction_input); 1757EXPORT_SYMBOL_GPL(gpiod_direction_input);
@@ -1806,7 +1818,8 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
1806 if (status) { 1818 if (status) {
1807 status = chip->request(chip, offset); 1819 status = chip->request(chip, offset);
1808 if (status < 0) { 1820 if (status < 0) {
1809 gpiod_dbg(desc, "chip request fail, %d\n", status); 1821 gpiod_dbg(desc, "%s: chip request fail, %d\n",
1822 __func__, status);
1810 /* and it's not available to anyone else ... 1823 /* and it's not available to anyone else ...
1811 * gpio_request() is the fully clean solution. 1824 * gpio_request() is the fully clean solution.
1812 */ 1825 */
@@ -2259,18 +2272,14 @@ void gpiod_set_value_cansleep(struct gpio_desc *desc, int value)
2259EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep); 2272EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep);
2260 2273
2261/** 2274/**
2262 * gpiod_add_table() - register GPIO device consumers 2275 * gpiod_add_lookup_table() - register GPIO device consumers
2263 * @table: array of consumers to register 2276 * @table: table of consumers to register
2264 * @num: number of consumers in table
2265 */ 2277 */
2266void gpiod_add_table(struct gpiod_lookup *table, size_t size) 2278void gpiod_add_lookup_table(struct gpiod_lookup_table *table)
2267{ 2279{
2268 mutex_lock(&gpio_lookup_lock); 2280 mutex_lock(&gpio_lookup_lock);
2269 2281
2270 while (size--) { 2282 list_add_tail(&table->list, &gpio_lookup_list);
2271 list_add_tail(&table->list, &gpio_lookup_list);
2272 table++;
2273 }
2274 2283
2275 mutex_unlock(&gpio_lookup_lock); 2284 mutex_unlock(&gpio_lookup_lock);
2276} 2285}
@@ -2326,76 +2335,92 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
2326 return desc; 2335 return desc;
2327} 2336}
2328 2337
2329static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, 2338static struct gpiod_lookup_table *gpiod_find_lookup_table(struct device *dev)
2330 unsigned int idx,
2331 enum gpio_lookup_flags *flags)
2332{ 2339{
2333 const char *dev_id = dev ? dev_name(dev) : NULL; 2340 const char *dev_id = dev ? dev_name(dev) : NULL;
2334 struct gpio_desc *desc = ERR_PTR(-ENODEV); 2341 struct gpiod_lookup_table *table;
2335 unsigned int match, best = 0;
2336 struct gpiod_lookup *p;
2337 2342
2338 mutex_lock(&gpio_lookup_lock); 2343 mutex_lock(&gpio_lookup_lock);
2339 2344
2340 list_for_each_entry(p, &gpio_lookup_list, list) { 2345 list_for_each_entry(table, &gpio_lookup_list, list) {
2341 match = 0; 2346 if (table->dev_id && dev_id) {
2347 /*
2348 * Valid strings on both ends, must be identical to have
2349 * a match
2350 */
2351 if (!strcmp(table->dev_id, dev_id))
2352 goto found;
2353 } else {
2354 /*
2355 * One of the pointers is NULL, so both must be to have
2356 * a match
2357 */
2358 if (dev_id == table->dev_id)
2359 goto found;
2360 }
2361 }
2362 table = NULL;
2342 2363
2343 if (p->dev_id) { 2364found:
2344 if (!dev_id || strcmp(p->dev_id, dev_id)) 2365 mutex_unlock(&gpio_lookup_lock);
2345 continue; 2366 return table;
2367}
2346 2368
2347 match += 2; 2369static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
2348 } 2370 unsigned int idx,
2371 enum gpio_lookup_flags *flags)
2372{
2373 struct gpio_desc *desc = ERR_PTR(-ENOENT);
2374 struct gpiod_lookup_table *table;
2375 struct gpiod_lookup *p;
2349 2376
2350 if (p->con_id) { 2377 table = gpiod_find_lookup_table(dev);
2351 if (!con_id || strcmp(p->con_id, con_id)) 2378 if (!table)
2352 continue; 2379 return desc;
2353 2380
2354 match += 1; 2381 for (p = &table->table[0]; p->chip_label; p++) {
2355 } 2382 struct gpio_chip *chip;
2356 2383
2384 /* idx must always match exactly */
2357 if (p->idx != idx) 2385 if (p->idx != idx)
2358 continue; 2386 continue;
2359 2387
2360 if (match > best) { 2388 /* If the lookup entry has a con_id, require exact match */
2361 struct gpio_chip *chip; 2389 if (p->con_id && (!con_id || strcmp(p->con_id, con_id)))
2390 continue;
2362 2391
2363 chip = find_chip_by_name(p->chip_label); 2392 chip = find_chip_by_name(p->chip_label);
2364 2393
2365 if (!chip) { 2394 if (!chip) {
2366 dev_warn(dev, "cannot find GPIO chip %s\n", 2395 dev_err(dev, "cannot find GPIO chip %s\n",
2367 p->chip_label); 2396 p->chip_label);
2368 continue; 2397 return ERR_PTR(-ENODEV);
2369 } 2398 }
2370 2399
2371 if (chip->ngpio <= p->chip_hwnum) { 2400 if (chip->ngpio <= p->chip_hwnum) {
2372 dev_warn(dev, "GPIO chip %s has %d GPIOs\n", 2401 dev_err(dev,
2373 chip->label, chip->ngpio); 2402 "requested GPIO %d is out of range [0..%d] for chip %s\n",
2374 continue; 2403 idx, chip->ngpio, chip->label);
2375 } 2404 return ERR_PTR(-EINVAL);
2405 }
2376 2406
2377 desc = gpio_to_desc(chip->base + p->chip_hwnum); 2407 desc = gpiochip_offset_to_desc(chip, p->chip_hwnum);
2378 *flags = p->flags; 2408 *flags = p->flags;
2379 2409
2380 if (match != 3) 2410 return desc;
2381 best = match;
2382 else
2383 break;
2384 }
2385 } 2411 }
2386 2412
2387 mutex_unlock(&gpio_lookup_lock);
2388
2389 return desc; 2413 return desc;
2390} 2414}
2391 2415
2392/** 2416/**
2393 * gpio_get - obtain a GPIO for a given GPIO function 2417 * gpio_get - obtain a GPIO for a given GPIO function
2394 * @dev: GPIO consumer 2418 * @dev: GPIO consumer, can be NULL for system-global GPIOs
2395 * @con_id: function within the GPIO consumer 2419 * @con_id: function within the GPIO consumer
2396 * 2420 *
2397 * Return the GPIO descriptor corresponding to the function con_id of device 2421 * Return the GPIO descriptor corresponding to the function con_id of device
2398 * dev, or an IS_ERR() condition if an error occured. 2422 * dev, -ENOENT if no GPIO has been assigned to the requested function, or
2423 * another IS_ERR() code if an error occured while trying to acquire the GPIO.
2399 */ 2424 */
2400struct gpio_desc *__must_check gpiod_get(struct device *dev, const char *con_id) 2425struct gpio_desc *__must_check gpiod_get(struct device *dev, const char *con_id)
2401{ 2426{
@@ -2405,14 +2430,16 @@ EXPORT_SYMBOL_GPL(gpiod_get);
2405 2430
2406/** 2431/**
2407 * gpiod_get_index - obtain a GPIO from a multi-index GPIO function 2432 * gpiod_get_index - obtain a GPIO from a multi-index GPIO function
2408 * @dev: GPIO consumer 2433 * @dev: GPIO consumer, can be NULL for system-global GPIOs
2409 * @con_id: function within the GPIO consumer 2434 * @con_id: function within the GPIO consumer
2410 * @idx: index of the GPIO to obtain in the consumer 2435 * @idx: index of the GPIO to obtain in the consumer
2411 * 2436 *
2412 * This variant of gpiod_get() allows to access GPIOs other than the first 2437 * This variant of gpiod_get() allows to access GPIOs other than the first
2413 * defined one for functions that define several GPIOs. 2438 * defined one for functions that define several GPIOs.
2414 * 2439 *
2415 * Return a valid GPIO descriptor, or an IS_ERR() condition in case of error. 2440 * Return a valid GPIO descriptor, -ENOENT if no GPIO has been assigned to the
2441 * requested function and/or index, or another IS_ERR() code if an error
2442 * occured while trying to acquire the GPIO.
2416 */ 2443 */
2417struct gpio_desc *__must_check gpiod_get_index(struct device *dev, 2444struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
2418 const char *con_id, 2445 const char *con_id,
@@ -2437,13 +2464,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
2437 * Either we are not using DT or ACPI, or their lookup did not return 2464 * Either we are not using DT or ACPI, or their lookup did not return
2438 * a result. In that case, use platform lookup as a fallback. 2465 * a result. In that case, use platform lookup as a fallback.
2439 */ 2466 */
2440 if (!desc || IS_ERR(desc)) { 2467 if (!desc || desc == ERR_PTR(-ENOENT)) {
2441 struct gpio_desc *pdesc;
2442 dev_dbg(dev, "using lookup tables for GPIO lookup"); 2468 dev_dbg(dev, "using lookup tables for GPIO lookup");
2443 pdesc = gpiod_find(dev, con_id, idx, &flags); 2469 desc = gpiod_find(dev, con_id, idx, &flags);
2444 /* If used as fallback, do not replace the previous error */
2445 if (!IS_ERR(pdesc) || !desc)
2446 desc = pdesc;
2447 } 2470 }
2448 2471
2449 if (IS_ERR(desc)) { 2472 if (IS_ERR(desc)) {
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
new file mode 100644
index 000000000000..82be586c1f90
--- /dev/null
+++ b/drivers/gpio/gpiolib.h
@@ -0,0 +1,46 @@
1/*
2 * Internal GPIO functions.
3 *
4 * Copyright (C) 2013, Intel Corporation
5 * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef GPIOLIB_H
13#define GPIOLIB_H
14
15#include <linux/err.h>
16#include <linux/device.h>
17
18/**
19 * struct acpi_gpio_info - ACPI GPIO specific information
20 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
21 * @active_low: in case of @gpioint, the pin is active low
22 */
23struct acpi_gpio_info {
24 bool gpioint;
25 bool active_low;
26};
27
28#ifdef CONFIG_ACPI
29void acpi_gpiochip_add(struct gpio_chip *chip);
30void acpi_gpiochip_remove(struct gpio_chip *chip);
31
32struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
33 struct acpi_gpio_info *info);
34#else
35static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
36static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
37
38static inline struct gpio_desc *
39acpi_get_gpiod_by_index(struct device *dev, int index,
40 struct acpi_gpio_info *info)
41{
42 return ERR_PTR(-ENOSYS);
43}
44#endif
45
46#endif /* GPIOLIB_H */
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index 76483fb5ee45..87cf215af798 100644
--- a/drivers/leds/leds-s3c24xx.c
+++ b/drivers/leds/leds-s3c24xx.c
@@ -21,6 +21,7 @@
21 21
22#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <mach/regs-gpio.h> 23#include <mach/regs-gpio.h>
24#include <plat/gpio-cfg.h>
24#include <linux/platform_data/leds-s3c24xx.h> 25#include <linux/platform_data/leds-s3c24xx.h>
25 26
26/* our context */ 27/* our context */
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c
index 2fce5ea5eb39..f23782683a7c 100644
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -23,7 +23,9 @@
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/io.h> 24#include <linux/io.h>
25 25
26#include <plat/gpio-cfg.h>
26#include <mach/dma.h> 27#include <mach/dma.h>
28#include <mach/gpio-samsung.h>
27 29
28#include <linux/platform_data/mmc-s3cmci.h> 30#include <linux/platform_data/mmc-s3cmci.h>
29 31
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index ef19874fcd1f..4ede2307b293 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -31,10 +31,9 @@
31#include <linux/bitops.h> 31#include <linux/bitops.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/err.h> 33#include <linux/err.h>
34#include <linux/gpio.h> 34#include <linux/gpio/consumer.h>
35#include <linux/interrupt.h> 35#include <linux/interrupt.h>
36#include <linux/acpi.h> 36#include <linux/acpi.h>
37#include <linux/acpi_gpio.h>
38#include <linux/pm.h> 37#include <linux/pm.h>
39#include <linux/pm_runtime.h> 38#include <linux/pm_runtime.h>
40#include <linux/delay.h> 39#include <linux/delay.h>
@@ -199,22 +198,23 @@ static irqreturn_t sdhci_acpi_sd_cd(int irq, void *dev_id)
199 return IRQ_HANDLED; 198 return IRQ_HANDLED;
200} 199}
201 200
202static int sdhci_acpi_add_own_cd(struct device *dev, int gpio, 201static int sdhci_acpi_add_own_cd(struct device *dev, struct mmc_host *mmc)
203 struct mmc_host *mmc)
204{ 202{
203 struct gpio_desc *desc;
205 unsigned long flags; 204 unsigned long flags;
206 int err, irq; 205 int err, irq;
207 206
208 if (gpio < 0) { 207 desc = devm_gpiod_get_index(dev, "sd_cd", 0);
209 err = gpio; 208 if (IS_ERR(desc)) {
209 err = PTR_ERR(desc);
210 goto out; 210 goto out;
211 } 211 }
212 212
213 err = devm_gpio_request_one(dev, gpio, GPIOF_DIR_IN, "sd_cd"); 213 err = gpiod_direction_input(desc);
214 if (err) 214 if (err)
215 goto out; 215 goto out_free;
216 216
217 irq = gpio_to_irq(gpio); 217 irq = gpiod_to_irq(desc);
218 if (irq < 0) { 218 if (irq < 0) {
219 err = irq; 219 err = irq;
220 goto out_free; 220 goto out_free;
@@ -228,7 +228,7 @@ static int sdhci_acpi_add_own_cd(struct device *dev, int gpio,
228 return 0; 228 return 0;
229 229
230out_free: 230out_free:
231 devm_gpio_free(dev, gpio); 231 devm_gpiod_put(dev, desc);
232out: 232out:
233 dev_warn(dev, "failed to setup card detect wake up\n"); 233 dev_warn(dev, "failed to setup card detect wake up\n");
234 return err; 234 return err;
@@ -236,8 +236,7 @@ out:
236 236
237#else 237#else
238 238
239static int sdhci_acpi_add_own_cd(struct device *dev, int gpio, 239static int sdhci_acpi_add_own_cd(struct device *dev, struct mmc_host *mmc)
240 struct mmc_host *mmc)
241{ 240{
242 return 0; 241 return 0;
243} 242}
@@ -254,7 +253,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
254 struct resource *iomem; 253 struct resource *iomem;
255 resource_size_t len; 254 resource_size_t len;
256 const char *hid; 255 const char *hid;
257 int err, gpio; 256 int err;
258 257
259 if (acpi_bus_get_device(handle, &device)) 258 if (acpi_bus_get_device(handle, &device))
260 return -ENODEV; 259 return -ENODEV;
@@ -279,8 +278,6 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
279 if (IS_ERR(host)) 278 if (IS_ERR(host))
280 return PTR_ERR(host); 279 return PTR_ERR(host);
281 280
282 gpio = acpi_get_gpio_by_index(dev, 0, NULL);
283
284 c = sdhci_priv(host); 281 c = sdhci_priv(host);
285 c->host = host; 282 c->host = host;
286 c->slot = sdhci_acpi_get_slot(handle, hid); 283 c->slot = sdhci_acpi_get_slot(handle, hid);
@@ -338,7 +335,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
338 goto err_free; 335 goto err_free;
339 336
340 if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) { 337 if (sdhci_acpi_flag(c, SDHCI_ACPI_SD_CD)) {
341 if (sdhci_acpi_add_own_cd(dev, gpio, host->mmc)) 338 if (sdhci_acpi_add_own_cd(dev, host->mmc))
342 c->use_runtime_pm = false; 339 c->use_runtime_pm = false;
343 } 340 }
344 341
diff --git a/drivers/pinctrl/pinctrl-as3722.c b/drivers/pinctrl/pinctrl-as3722.c
index 01bffc1d52fd..b80f1e150f53 100644
--- a/drivers/pinctrl/pinctrl-as3722.c
+++ b/drivers/pinctrl/pinctrl-as3722.c
@@ -531,7 +531,7 @@ static const struct gpio_chip as3722_gpio_chip = {
531 .direction_input = as3722_gpio_direction_input, 531 .direction_input = as3722_gpio_direction_input,
532 .direction_output = as3722_gpio_direction_output, 532 .direction_output = as3722_gpio_direction_output,
533 .to_irq = as3722_gpio_to_irq, 533 .to_irq = as3722_gpio_to_irq,
534 .can_sleep = 1, 534 .can_sleep = true,
535 .ngpio = AS3722_PIN_NUM, 535 .ngpio = AS3722_PIN_NUM,
536 .base = -1, 536 .base = -1,
537}; 537};
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index a7549c4c83b4..943805185f3f 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1527,7 +1527,7 @@ static struct gpio_chip at91_gpio_template = {
1527 .set = at91_gpio_set, 1527 .set = at91_gpio_set,
1528 .to_irq = at91_gpio_to_irq, 1528 .to_irq = at91_gpio_to_irq,
1529 .dbg_show = at91_gpio_dbg_show, 1529 .dbg_show = at91_gpio_dbg_show,
1530 .can_sleep = 0, 1530 .can_sleep = false,
1531 .ngpio = MAX_NB_GPIO_PER_BANK, 1531 .ngpio = MAX_NB_GPIO_PER_BANK,
1532}; 1532};
1533 1533
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
index 2832576d8b12..72e6a298a1e9 100644
--- a/drivers/pinctrl/pinctrl-baytrail.c
+++ b/drivers/pinctrl/pinctrl-baytrail.c
@@ -29,7 +29,6 @@
29#include <linux/gpio.h> 29#include <linux/gpio.h>
30#include <linux/irqdomain.h> 30#include <linux/irqdomain.h>
31#include <linux/acpi.h> 31#include <linux/acpi.h>
32#include <linux/acpi_gpio.h>
33#include <linux/platform_device.h> 32#include <linux/platform_device.h>
34#include <linux/seq_file.h> 33#include <linux/seq_file.h>
35#include <linux/io.h> 34#include <linux/io.h>
@@ -461,7 +460,7 @@ static int byt_gpio_probe(struct platform_device *pdev)
461 gc->set = byt_gpio_set; 460 gc->set = byt_gpio_set;
462 gc->dbg_show = byt_gpio_dbg_show; 461 gc->dbg_show = byt_gpio_dbg_show;
463 gc->base = -1; 462 gc->base = -1;
464 gc->can_sleep = 0; 463 gc->can_sleep = false;
465 gc->dev = dev; 464 gc->dev = dev;
466 465
467 ret = gpiochip_add(gc); 466 ret = gpiochip_add(gc);
@@ -485,9 +484,6 @@ static int byt_gpio_probe(struct platform_device *pdev)
485 484
486 irq_set_handler_data(hwirq, vg); 485 irq_set_handler_data(hwirq, vg);
487 irq_set_chained_handler(hwirq, byt_gpio_irq_handler); 486 irq_set_chained_handler(hwirq, byt_gpio_irq_handler);
488
489 /* Register interrupt handlers for gpio signaled acpi events */
490 acpi_gpiochip_request_interrupts(gc);
491 } 487 }
492 488
493 pm_runtime_enable(dev); 489 pm_runtime_enable(dev);
diff --git a/drivers/pinctrl/pinctrl-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c
index c05c1ef2cc3c..3d907de9bc91 100644
--- a/drivers/pinctrl/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/pinctrl-bcm2835.c
@@ -384,7 +384,7 @@ static struct gpio_chip bcm2835_gpio_chip = {
384 .to_irq = bcm2835_gpio_to_irq, 384 .to_irq = bcm2835_gpio_to_irq,
385 .base = -1, 385 .base = -1,
386 .ngpio = BCM2835_NUM_GPIOS, 386 .ngpio = BCM2835_NUM_GPIOS,
387 .can_sleep = 0, 387 .can_sleep = false,
388}; 388};
389 389
390static irqreturn_t bcm2835_gpio_irq_handler(int irq, void *dev_id) 390static irqreturn_t bcm2835_gpio_irq_handler(int irq, void *dev_id)
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index 7111c3b59130..a21820fc4b7c 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -904,7 +904,7 @@ static struct gpio_chip nmk_gpio_template = {
904 .set = nmk_gpio_set_output, 904 .set = nmk_gpio_set_output,
905 .to_irq = nmk_gpio_to_irq, 905 .to_irq = nmk_gpio_to_irq,
906 .dbg_show = nmk_gpio_dbg_show, 906 .dbg_show = nmk_gpio_dbg_show,
907 .can_sleep = 0, 907 .can_sleep = false,
908}; 908};
909 909
910void nmk_gpio_clocks_enable(void) 910void nmk_gpio_clocks_enable(void)
diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
index 119d2ddedfe7..6b181cb90d39 100644
--- a/drivers/pinctrl/pinctrl-sunxi.c
+++ b/drivers/pinctrl/pinctrl-sunxi.c
@@ -547,7 +547,7 @@ static struct gpio_chip sunxi_pinctrl_gpio_chip = {
547 .of_xlate = sunxi_pinctrl_gpio_of_xlate, 547 .of_xlate = sunxi_pinctrl_gpio_of_xlate,
548 .to_irq = sunxi_pinctrl_gpio_to_irq, 548 .to_irq = sunxi_pinctrl_gpio_to_irq,
549 .of_gpio_n_cells = 3, 549 .of_gpio_n_cells = 3,
550 .can_sleep = 0, 550 .can_sleep = false,
551}; 551};
552 552
553static int sunxi_pinctrl_irq_set_type(struct irq_data *d, 553static int sunxi_pinctrl_irq_set_type(struct irq_data *d,
diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c
index 39aec0850810..b28d1af9c232 100644
--- a/drivers/pinctrl/vt8500/pinctrl-wmt.c
+++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c
@@ -565,7 +565,7 @@ static struct gpio_chip wmt_gpio_chip = {
565 .direction_output = wmt_gpio_direction_output, 565 .direction_output = wmt_gpio_direction_output,
566 .get = wmt_gpio_get_value, 566 .get = wmt_gpio_get_value,
567 .set = wmt_gpio_set_value, 567 .set = wmt_gpio_set_value,
568 .can_sleep = 0, 568 .can_sleep = false,
569}; 569};
570 570
571int wmt_pinctrl_probe(struct platform_device *pdev, 571int wmt_pinctrl_probe(struct platform_device *pdev,
diff --git a/include/linux/acpi_gpio.h b/include/linux/acpi_gpio.h
deleted file mode 100644
index d875bc3dba3c..000000000000
--- a/include/linux/acpi_gpio.h
+++ /dev/null
@@ -1,51 +0,0 @@
1#ifndef _LINUX_ACPI_GPIO_H_
2#define _LINUX_ACPI_GPIO_H_
3
4#include <linux/device.h>
5#include <linux/err.h>
6#include <linux/errno.h>
7#include <linux/gpio.h>
8#include <linux/gpio/consumer.h>
9
10/**
11 * struct acpi_gpio_info - ACPI GPIO specific information
12 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
13 * @active_low: in case of @gpioint, the pin is active low
14 */
15struct acpi_gpio_info {
16 bool gpioint;
17 bool active_low;
18};
19
20#ifdef CONFIG_GPIO_ACPI
21
22struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
23 struct acpi_gpio_info *info);
24void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
25void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
26
27#else /* CONFIG_GPIO_ACPI */
28
29static inline struct gpio_desc *
30acpi_get_gpiod_by_index(struct device *dev, int index,
31 struct acpi_gpio_info *info)
32{
33 return ERR_PTR(-ENOSYS);
34}
35
36static inline void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
37static inline void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
38
39#endif /* CONFIG_GPIO_ACPI */
40
41static inline int acpi_get_gpio_by_index(struct device *dev, int index,
42 struct acpi_gpio_info *info)
43{
44 struct gpio_desc *desc = acpi_get_gpiod_by_index(dev, index, info);
45
46 if (IS_ERR(desc))
47 return PTR_ERR(desc);
48 return desc_to_gpio(desc);
49}
50
51#endif /* _LINUX_ACPI_GPIO_H_ */
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 13dfd24d01ab..b581b13d29d9 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -90,7 +90,6 @@ void devm_gpio_free(struct device *dev, unsigned int gpio);
90 90
91#include <linux/kernel.h> 91#include <linux/kernel.h>
92#include <linux/types.h> 92#include <linux/types.h>
93#include <linux/errno.h>
94#include <linux/bug.h> 93#include <linux/bug.h>
95#include <linux/pinctrl/pinctrl.h> 94#include <linux/pinctrl/pinctrl.h>
96 95
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 3ea2cf6b0e6c..a3e181e09636 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -39,14 +39,15 @@ struct seq_file;
39 * @ngpio: the number of GPIOs handled by this controller; the last GPIO 39 * @ngpio: the number of GPIOs handled by this controller; the last GPIO
40 * handled is (base + ngpio - 1). 40 * handled is (base + ngpio - 1).
41 * @desc: array of ngpio descriptors. Private. 41 * @desc: array of ngpio descriptors. Private.
42 * @can_sleep: flag must be set iff get()/set() methods sleep, as they
43 * must while accessing GPIO expander chips over I2C or SPI
44 * @names: if set, must be an array of strings to use as alternative 42 * @names: if set, must be an array of strings to use as alternative
45 * names for the GPIOs in this chip. Any entry in the array 43 * names for the GPIOs in this chip. Any entry in the array
46 * may be NULL if there is no alias for the GPIO, however the 44 * may be NULL if there is no alias for the GPIO, however the
47 * array must be @ngpio entries long. A name can include a single printk 45 * array must be @ngpio entries long. A name can include a single printk
48 * format specifier for an unsigned int. It is substituted by the actual 46 * format specifier for an unsigned int. It is substituted by the actual
49 * number of the gpio. 47 * number of the gpio.
48 * @can_sleep: flag must be set iff get()/set() methods sleep, as they
49 * must while accessing GPIO expander chips over I2C or SPI
50 * @exported: flags if the gpiochip is exported for use from sysfs. Private.
50 * 51 *
51 * A gpio_chip can help platforms abstract various sources of GPIOs so 52 * A gpio_chip can help platforms abstract various sources of GPIOs so
52 * they can all be accessed through a common programing interface. 53 * they can all be accessed through a common programing interface.
@@ -91,8 +92,8 @@ struct gpio_chip {
91 u16 ngpio; 92 u16 ngpio;
92 struct gpio_desc *desc; 93 struct gpio_desc *desc;
93 const char *const *names; 94 const char *const *names;
94 unsigned can_sleep:1; 95 bool can_sleep;
95 unsigned exported:1; 96 bool exported;
96 97
97#if defined(CONFIG_OF_GPIO) 98#if defined(CONFIG_OF_GPIO)
98 /* 99 /*
@@ -136,59 +137,50 @@ enum gpio_lookup_flags {
136}; 137};
137 138
138/** 139/**
139 * Lookup table for associating GPIOs to specific devices and functions using 140 * struct gpiod_lookup - lookup table
140 * platform data. 141 * @chip_label: name of the chip the GPIO belongs to
142 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
143 * @con_id: name of the GPIO from the device's point of view
144 * @idx: index of the GPIO in case several GPIOs share the same name
145 * @flags: mask of GPIO_* values
146 *
147 * gpiod_lookup is a lookup table for associating GPIOs to specific devices and
148 * functions using platform data.
141 */ 149 */
142struct gpiod_lookup { 150struct gpiod_lookup {
143 struct list_head list;
144 /*
145 * name of the chip the GPIO belongs to
146 */
147 const char *chip_label; 151 const char *chip_label;
148 /*
149 * hardware number (i.e. relative to the chip) of the GPIO
150 */
151 u16 chip_hwnum; 152 u16 chip_hwnum;
152 /*
153 * name of device that can claim this GPIO
154 */
155 const char *dev_id;
156 /*
157 * name of the GPIO from the device's point of view
158 */
159 const char *con_id; 153 const char *con_id;
160 /*
161 * index of the GPIO in case several GPIOs share the same name
162 */
163 unsigned int idx; 154 unsigned int idx;
164 /*
165 * mask of GPIO_* values
166 */
167 enum gpio_lookup_flags flags; 155 enum gpio_lookup_flags flags;
168}; 156};
169 157
158struct gpiod_lookup_table {
159 struct list_head list;
160 const char *dev_id;
161 struct gpiod_lookup table[];
162};
163
170/* 164/*
171 * Simple definition of a single GPIO under a con_id 165 * Simple definition of a single GPIO under a con_id
172 */ 166 */
173#define GPIO_LOOKUP(_chip_label, _chip_hwnum, _dev_id, _con_id, _flags) \ 167#define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \
174 GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _dev_id, _con_id, 0, _flags) 168 GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags)
175 169
176/* 170/*
177 * Use this macro if you need to have several GPIOs under the same con_id. 171 * Use this macro if you need to have several GPIOs under the same con_id.
178 * Each GPIO needs to use a different index and can be accessed using 172 * Each GPIO needs to use a different index and can be accessed using
179 * gpiod_get_index() 173 * gpiod_get_index()
180 */ 174 */
181#define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _dev_id, _con_id, _idx, \ 175#define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags) \
182 _flags) \
183{ \ 176{ \
184 .chip_label = _chip_label, \ 177 .chip_label = _chip_label, \
185 .chip_hwnum = _chip_hwnum, \ 178 .chip_hwnum = _chip_hwnum, \
186 .dev_id = _dev_id, \
187 .con_id = _con_id, \ 179 .con_id = _con_id, \
188 .idx = _idx, \ 180 .idx = _idx, \
189 .flags = _flags, \ 181 .flags = _flags, \
190} 182}
191 183
192void gpiod_add_table(struct gpiod_lookup *table, size_t size); 184void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
193 185
194#endif 186#endif
diff --git a/arch/arm/mach-lpc32xx/include/mach/gpio-lpc32xx.h b/include/linux/platform_data/gpio-lpc32xx.h
index a544e962a818..a544e962a818 100644
--- a/arch/arm/mach-lpc32xx/include/mach/gpio-lpc32xx.h
+++ b/include/linux/platform_data/gpio-lpc32xx.h
diff --git a/include/linux/spi/74x164.h b/include/linux/spi/74x164.h
deleted file mode 100644
index 0aa6acc73317..000000000000
--- a/include/linux/spi/74x164.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef LINUX_SPI_74X164_H
2#define LINUX_SPI_74X164_H
3
4struct gen_74x164_chip_platform_data {
5 /* number assigned to the first GPIO */
6 unsigned base;
7};
8
9#endif
diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
index 5620d3c07479..bd2a5b90400c 100644
--- a/net/rfkill/rfkill-gpio.c
+++ b/net/rfkill/rfkill-gpio.c
@@ -25,15 +25,15 @@
25#include <linux/clk.h> 25#include <linux/clk.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/acpi.h> 27#include <linux/acpi.h>
28#include <linux/acpi_gpio.h> 28#include <linux/gpio/consumer.h>
29 29
30#include <linux/rfkill-gpio.h> 30#include <linux/rfkill-gpio.h>
31 31
32struct rfkill_gpio_data { 32struct rfkill_gpio_data {
33 const char *name; 33 const char *name;
34 enum rfkill_type type; 34 enum rfkill_type type;
35 int reset_gpio; 35 struct gpio_desc *reset_gpio;
36 int shutdown_gpio; 36 struct gpio_desc *shutdown_gpio;
37 37
38 struct rfkill *rfkill_dev; 38 struct rfkill *rfkill_dev;
39 char *reset_name; 39 char *reset_name;
@@ -48,19 +48,15 @@ static int rfkill_gpio_set_power(void *data, bool blocked)
48 struct rfkill_gpio_data *rfkill = data; 48 struct rfkill_gpio_data *rfkill = data;
49 49
50 if (blocked) { 50 if (blocked) {
51 if (gpio_is_valid(rfkill->shutdown_gpio)) 51 gpiod_set_value(rfkill->shutdown_gpio, 0);
52 gpio_set_value(rfkill->shutdown_gpio, 0); 52 gpiod_set_value(rfkill->reset_gpio, 0);
53 if (gpio_is_valid(rfkill->reset_gpio))
54 gpio_set_value(rfkill->reset_gpio, 0);
55 if (!IS_ERR(rfkill->clk) && rfkill->clk_enabled) 53 if (!IS_ERR(rfkill->clk) && rfkill->clk_enabled)
56 clk_disable(rfkill->clk); 54 clk_disable(rfkill->clk);
57 } else { 55 } else {
58 if (!IS_ERR(rfkill->clk) && !rfkill->clk_enabled) 56 if (!IS_ERR(rfkill->clk) && !rfkill->clk_enabled)
59 clk_enable(rfkill->clk); 57 clk_enable(rfkill->clk);
60 if (gpio_is_valid(rfkill->reset_gpio)) 58 gpiod_set_value(rfkill->reset_gpio, 1);
61 gpio_set_value(rfkill->reset_gpio, 1); 59 gpiod_set_value(rfkill->shutdown_gpio, 1);
62 if (gpio_is_valid(rfkill->shutdown_gpio))
63 gpio_set_value(rfkill->shutdown_gpio, 1);
64 } 60 }
65 61
66 rfkill->clk_enabled = blocked; 62 rfkill->clk_enabled = blocked;
@@ -83,8 +79,6 @@ static int rfkill_gpio_acpi_probe(struct device *dev,
83 79
84 rfkill->name = dev_name(dev); 80 rfkill->name = dev_name(dev);
85 rfkill->type = (unsigned)id->driver_data; 81 rfkill->type = (unsigned)id->driver_data;
86 rfkill->reset_gpio = acpi_get_gpio_by_index(dev, 0, NULL);
87 rfkill->shutdown_gpio = acpi_get_gpio_by_index(dev, 1, NULL);
88 82
89 return 0; 83 return 0;
90} 84}
@@ -94,8 +88,9 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
94 struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data; 88 struct rfkill_gpio_platform_data *pdata = pdev->dev.platform_data;
95 struct rfkill_gpio_data *rfkill; 89 struct rfkill_gpio_data *rfkill;
96 const char *clk_name = NULL; 90 const char *clk_name = NULL;
97 int ret = 0; 91 struct gpio_desc *gpio;
98 int len = 0; 92 int ret;
93 int len;
99 94
100 rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL); 95 rfkill = devm_kzalloc(&pdev->dev, sizeof(*rfkill), GFP_KERNEL);
101 if (!rfkill) 96 if (!rfkill)
@@ -109,28 +104,10 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
109 clk_name = pdata->power_clk_name; 104 clk_name = pdata->power_clk_name;
110 rfkill->name = pdata->name; 105 rfkill->name = pdata->name;
111 rfkill->type = pdata->type; 106 rfkill->type = pdata->type;
112 rfkill->reset_gpio = pdata->reset_gpio;
113 rfkill->shutdown_gpio = pdata->shutdown_gpio;
114 } else { 107 } else {
115 return -ENODEV; 108 return -ENODEV;
116 } 109 }
117 110
118 /* make sure at-least one of the GPIO is defined and that
119 * a name is specified for this instance */
120 if ((!gpio_is_valid(rfkill->reset_gpio) &&
121 !gpio_is_valid(rfkill->shutdown_gpio)) || !rfkill->name) {
122 pr_warn("%s: invalid platform data\n", __func__);
123 return -EINVAL;
124 }
125
126 if (pdata && pdata->gpio_runtime_setup) {
127 ret = pdata->gpio_runtime_setup(pdev);
128 if (ret) {
129 pr_warn("%s: can't set up gpio\n", __func__);
130 return ret;
131 }
132 }
133
134 len = strlen(rfkill->name); 111 len = strlen(rfkill->name);
135 rfkill->reset_name = devm_kzalloc(&pdev->dev, len + 7, GFP_KERNEL); 112 rfkill->reset_name = devm_kzalloc(&pdev->dev, len + 7, GFP_KERNEL);
136 if (!rfkill->reset_name) 113 if (!rfkill->reset_name)
@@ -145,20 +122,34 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
145 122
146 rfkill->clk = devm_clk_get(&pdev->dev, clk_name); 123 rfkill->clk = devm_clk_get(&pdev->dev, clk_name);
147 124
148 if (gpio_is_valid(rfkill->reset_gpio)) { 125 gpio = devm_gpiod_get_index(&pdev->dev, rfkill->reset_name, 0);
149 ret = devm_gpio_request_one(&pdev->dev, rfkill->reset_gpio, 126 if (!IS_ERR(gpio)) {
150 0, rfkill->reset_name); 127 ret = gpiod_direction_output(gpio, 0);
151 if (ret) { 128 if (ret)
152 pr_warn("%s: failed to get reset gpio.\n", __func__);
153 return ret; 129 return ret;
154 } 130 rfkill->reset_gpio = gpio;
131 }
132
133 gpio = devm_gpiod_get_index(&pdev->dev, rfkill->shutdown_name, 1);
134 if (!IS_ERR(gpio)) {
135 ret = gpiod_direction_output(gpio, 0);
136 if (ret)
137 return ret;
138 rfkill->shutdown_gpio = gpio;
155 } 139 }
156 140
157 if (gpio_is_valid(rfkill->shutdown_gpio)) { 141 /* Make sure at-least one of the GPIO is defined and that
158 ret = devm_gpio_request_one(&pdev->dev, rfkill->shutdown_gpio, 142 * a name is specified for this instance
159 0, rfkill->shutdown_name); 143 */
144 if ((!rfkill->reset_gpio && !rfkill->shutdown_gpio) || !rfkill->name) {
145 dev_err(&pdev->dev, "invalid platform data\n");
146 return -EINVAL;
147 }
148
149 if (pdata && pdata->gpio_runtime_setup) {
150 ret = pdata->gpio_runtime_setup(pdev);
160 if (ret) { 151 if (ret) {
161 pr_warn("%s: failed to get shutdown gpio.\n", __func__); 152 dev_err(&pdev->dev, "can't set up gpio\n");
162 return ret; 153 return ret;
163 } 154 }
164 } 155 }