diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-07 13:53:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-07 13:53:00 -0400 |
commit | 27c7651a6a5f143eccd66db38c7a3035e1f8bcfb (patch) | |
tree | c20d3525a2933a8ea7e9ab03022c432b18e0e48a /drivers/gpio | |
parent | 8b8a7df9a1d87ba413fce246b11f54c636bb456a (diff) | |
parent | 65d876564e989b63b0f769e0e06b9830db97b2d9 (diff) |
Merge tag 'gpio-v3.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij:
"This is the bulk of GPIO changes for the v3.12 series:
- A new driver for the TZ1090 PDC which is used on the metag
architecture.
- A new driver for the Kontron ETX or COMexpress GPIO block. This is
found on some ETX x86 devices.
- A new driver for the Fintek Super-I/O chips, used on some x86
boards.
- Added device tree probing on a few select GPIO blocks.
- Drop the Exynos support from the Samsung GPIO driver.
The Samsung maintainers have moved over to use the modernized pin
control driver to provide GPIO for the modern platforms instead.
- The usual bunch of non-critical fixes and cleanups"
* tag 'gpio-v3.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (36 commits)
gpio: return -ENOTSUPP if debounce cannot be set
gpio: improve error path in gpiolib
gpio: add GPIO support for F71882FG and F71889F
of: add vendor prefix for Microchip Technology Inc
gpio: mcp23s08: rename the device tree property
gpio: samsung: Drop support for Exynos SoCs
gpio: pcf857x: Remove pdata argument to pcf857x_irq_domain_init()
gpio: pcf857x: Sort headers alphabetically
gpio: max7301: Reverting "Do not force SPI speed when using OF Platform"
gpio: Fix bit masking in Kontron PLD GPIO driver
gpio: pca953x: fix gpio input on gpio offsets >= 8
drivers/gpio: simplify use of devm_ioremap_resource
drivers/gpio/gpio-omap.c: convert comma to semicolon
gpio-lynxpoint: Fix warning about unbalanced pm_runtime_enable
gpio: Fix platform driver name in Kontron PLD GPIO driver
gpio: adnp: Fix segfault if request_threaded_irq fails
gpio: msm: Staticize local variable 'msm_gpio'
gpio: gpiolib-of.c: make error message more meaningful by adding the node name and index
gpio: use dev_get_platdata()
gpio/mxc: add chained_irq_enter/exit() to mx2_gpio_irq_handler
...
Diffstat (limited to 'drivers/gpio')
49 files changed, 1775 insertions, 1019 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index b2450ba14138..349b16160ac9 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -146,6 +146,16 @@ config GPIO_MM_LANTIQ | |||
146 | (EBU) found on Lantiq SoCs. The gpios are output only as they are | 146 | (EBU) found on Lantiq SoCs. The gpios are output only as they are |
147 | created by attaching a 16bit latch to the bus. | 147 | created by attaching a 16bit latch to the bus. |
148 | 148 | ||
149 | config GPIO_F7188X | ||
150 | tristate "F71882FG and F71889F GPIO support" | ||
151 | depends on X86 | ||
152 | help | ||
153 | This option enables support for GPIOs found on Fintek Super-I/O | ||
154 | chips F71882FG and F71889F. | ||
155 | |||
156 | To compile this driver as a module, choose M here: the module will | ||
157 | be called f7188x-gpio. | ||
158 | |||
149 | config GPIO_MPC5200 | 159 | config GPIO_MPC5200 |
150 | def_bool y | 160 | def_bool y |
151 | depends on PPC_MPC52xx | 161 | depends on PPC_MPC52xx |
@@ -242,6 +252,21 @@ config GPIO_TS5500 | |||
242 | blocks of the TS-5500: DIO1, DIO2 and the LCD port, and the TS-5600 | 252 | blocks of the TS-5500: DIO1, DIO2 and the LCD port, and the TS-5600 |
243 | LCD port. | 253 | LCD port. |
244 | 254 | ||
255 | config GPIO_TZ1090 | ||
256 | bool "Toumaz Xenif TZ1090 GPIO support" | ||
257 | depends on SOC_TZ1090 | ||
258 | select GENERIC_IRQ_CHIP | ||
259 | default y | ||
260 | help | ||
261 | Say yes here to support Toumaz Xenif TZ1090 GPIOs. | ||
262 | |||
263 | config GPIO_TZ1090_PDC | ||
264 | bool "Toumaz Xenif TZ1090 PDC GPIO support" | ||
265 | depends on SOC_TZ1090 | ||
266 | default y | ||
267 | help | ||
268 | Say yes here to support Toumaz Xenif TZ1090 PDC GPIOs. | ||
269 | |||
245 | config GPIO_XILINX | 270 | config GPIO_XILINX |
246 | bool "Xilinx GPIO support" | 271 | bool "Xilinx GPIO support" |
247 | depends on PPC_OF || MICROBLAZE || ARCH_ZYNQ | 272 | depends on PPC_OF || MICROBLAZE || ARCH_ZYNQ |
@@ -676,6 +701,18 @@ config GPIO_UCB1400 | |||
676 | This enables support for the Philips UCB1400 GPIO pins. | 701 | This enables support for the Philips UCB1400 GPIO pins. |
677 | The UCB1400 is an AC97 audio codec. | 702 | The UCB1400 is an AC97 audio codec. |
678 | 703 | ||
704 | comment "LPC GPIO expanders:" | ||
705 | |||
706 | config GPIO_KEMPLD | ||
707 | tristate "Kontron ETX / COMexpress GPIO" | ||
708 | depends on MFD_KEMPLD | ||
709 | help | ||
710 | This enables support for the PLD GPIO interface on some Kontron ETX | ||
711 | and COMexpress (ETXexpress) modules. | ||
712 | |||
713 | This driver can also be built as a module. If so, the module will be | ||
714 | called gpio-kempld. | ||
715 | |||
679 | comment "MODULbus GPIO expanders:" | 716 | comment "MODULbus GPIO expanders:" |
680 | 717 | ||
681 | config GPIO_JANZ_TTL | 718 | config GPIO_JANZ_TTL |
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index ef3e983a2f1e..97438bf8434a 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile | |||
@@ -24,11 +24,13 @@ obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o | |||
24 | obj-$(CONFIG_ARCH_DAVINCI) += gpio-davinci.o | 24 | obj-$(CONFIG_ARCH_DAVINCI) += gpio-davinci.o |
25 | obj-$(CONFIG_GPIO_EM) += gpio-em.o | 25 | obj-$(CONFIG_GPIO_EM) += gpio-em.o |
26 | obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o | 26 | obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o |
27 | obj-$(CONFIG_GPIO_F7188X) += gpio-f7188x.o | ||
27 | obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o | 28 | obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o |
28 | obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o | 29 | obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o |
29 | obj-$(CONFIG_GPIO_ICH) += gpio-ich.o | 30 | obj-$(CONFIG_GPIO_ICH) += gpio-ich.o |
30 | obj-$(CONFIG_GPIO_IT8761E) += gpio-it8761e.o | 31 | obj-$(CONFIG_GPIO_IT8761E) += gpio-it8761e.o |
31 | obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o | 32 | obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o |
33 | obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o | ||
32 | obj-$(CONFIG_ARCH_KS8695) += gpio-ks8695.o | 34 | obj-$(CONFIG_ARCH_KS8695) += gpio-ks8695.o |
33 | obj-$(CONFIG_GPIO_LANGWELL) += gpio-langwell.o | 35 | obj-$(CONFIG_GPIO_LANGWELL) += gpio-langwell.o |
34 | obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o | 36 | obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o |
@@ -79,6 +81,8 @@ obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o | |||
79 | obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o | 81 | obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o |
80 | obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o | 82 | obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o |
81 | obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o | 83 | obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o |
84 | obj-$(CONFIG_GPIO_TZ1090) += gpio-tz1090.o | ||
85 | obj-$(CONFIG_GPIO_TZ1090_PDC) += gpio-tz1090-pdc.o | ||
82 | obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o | 86 | obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o |
83 | obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o | 87 | obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o |
84 | obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o | 88 | obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o |
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index 721607904d0a..5d518d5db7a0 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c | |||
@@ -129,7 +129,7 @@ static int gen_74x164_probe(struct spi_device *spi) | |||
129 | if (!chip) | 129 | if (!chip) |
130 | return -ENOMEM; | 130 | return -ENOMEM; |
131 | 131 | ||
132 | pdata = spi->dev.platform_data; | 132 | pdata = dev_get_platdata(&spi->dev); |
133 | if (pdata && pdata->base) | 133 | if (pdata && pdata->base) |
134 | chip->gpio_chip.base = pdata->base; | 134 | chip->gpio_chip.base = pdata->base; |
135 | else | 135 | else |
diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index e60567fc5073..c0f3fc44ab0e 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c | |||
@@ -490,15 +490,11 @@ static int adnp_irq_setup(struct adnp *adnp) | |||
490 | if (err != 0) { | 490 | if (err != 0) { |
491 | dev_err(chip->dev, "can't request IRQ#%d: %d\n", | 491 | dev_err(chip->dev, "can't request IRQ#%d: %d\n", |
492 | adnp->client->irq, err); | 492 | adnp->client->irq, err); |
493 | goto error; | 493 | return err; |
494 | } | 494 | } |
495 | 495 | ||
496 | chip->to_irq = adnp_gpio_to_irq; | 496 | chip->to_irq = adnp_gpio_to_irq; |
497 | return 0; | 497 | return 0; |
498 | |||
499 | error: | ||
500 | irq_domain_remove(adnp->domain); | ||
501 | return err; | ||
502 | } | 498 | } |
503 | 499 | ||
504 | static void adnp_irq_teardown(struct adnp *adnp) | 500 | static void adnp_irq_teardown(struct adnp *adnp) |
diff --git a/drivers/gpio/gpio-adp5520.c b/drivers/gpio/gpio-adp5520.c index f33f78dcadaa..084337d5514d 100644 --- a/drivers/gpio/gpio-adp5520.c +++ b/drivers/gpio/gpio-adp5520.c | |||
@@ -89,7 +89,7 @@ static int adp5520_gpio_direction_output(struct gpio_chip *chip, | |||
89 | 89 | ||
90 | static int adp5520_gpio_probe(struct platform_device *pdev) | 90 | static int adp5520_gpio_probe(struct platform_device *pdev) |
91 | { | 91 | { |
92 | struct adp5520_gpio_platform_data *pdata = pdev->dev.platform_data; | 92 | struct adp5520_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); |
93 | struct adp5520_gpio *dev; | 93 | struct adp5520_gpio *dev; |
94 | struct gpio_chip *gc; | 94 | struct gpio_chip *gc; |
95 | int ret, i, gpios; | 95 | int ret, i, gpios; |
diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c index 2ba56987db04..90fc4c99c024 100644 --- a/drivers/gpio/gpio-adp5588.c +++ b/drivers/gpio/gpio-adp5588.c | |||
@@ -276,7 +276,8 @@ static irqreturn_t adp5588_irq_handler(int irq, void *devid) | |||
276 | static int adp5588_irq_setup(struct adp5588_gpio *dev) | 276 | static int adp5588_irq_setup(struct adp5588_gpio *dev) |
277 | { | 277 | { |
278 | struct i2c_client *client = dev->client; | 278 | struct i2c_client *client = dev->client; |
279 | struct adp5588_gpio_platform_data *pdata = client->dev.platform_data; | 279 | struct adp5588_gpio_platform_data *pdata = |
280 | dev_get_platdata(&client->dev); | ||
280 | unsigned gpio; | 281 | unsigned gpio; |
281 | int ret; | 282 | int ret; |
282 | 283 | ||
@@ -349,7 +350,8 @@ static void adp5588_irq_teardown(struct adp5588_gpio *dev) | |||
349 | static int adp5588_gpio_probe(struct i2c_client *client, | 350 | static int adp5588_gpio_probe(struct i2c_client *client, |
350 | const struct i2c_device_id *id) | 351 | const struct i2c_device_id *id) |
351 | { | 352 | { |
352 | struct adp5588_gpio_platform_data *pdata = client->dev.platform_data; | 353 | struct adp5588_gpio_platform_data *pdata = |
354 | dev_get_platdata(&client->dev); | ||
353 | struct adp5588_gpio *dev; | 355 | struct adp5588_gpio *dev; |
354 | struct gpio_chip *gc; | 356 | struct gpio_chip *gc; |
355 | int ret, i, revid; | 357 | int ret, i, revid; |
@@ -440,7 +442,8 @@ err: | |||
440 | 442 | ||
441 | static int adp5588_gpio_remove(struct i2c_client *client) | 443 | static int adp5588_gpio_remove(struct i2c_client *client) |
442 | { | 444 | { |
443 | struct adp5588_gpio_platform_data *pdata = client->dev.platform_data; | 445 | struct adp5588_gpio_platform_data *pdata = |
446 | dev_get_platdata(&client->dev); | ||
444 | struct adp5588_gpio *dev = i2c_get_clientdata(client); | 447 | struct adp5588_gpio *dev = i2c_get_clientdata(client); |
445 | int ret; | 448 | int ret; |
446 | 449 | ||
diff --git a/drivers/gpio/gpio-arizona.c b/drivers/gpio/gpio-arizona.c index 0ea853f68db2..fa8b6a762761 100644 --- a/drivers/gpio/gpio-arizona.c +++ b/drivers/gpio/gpio-arizona.c | |||
@@ -97,7 +97,7 @@ static struct gpio_chip template_chip = { | |||
97 | static int arizona_gpio_probe(struct platform_device *pdev) | 97 | static int arizona_gpio_probe(struct platform_device *pdev) |
98 | { | 98 | { |
99 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); | 99 | struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); |
100 | struct arizona_pdata *pdata = arizona->dev->platform_data; | 100 | struct arizona_pdata *pdata = dev_get_platdata(arizona->dev); |
101 | struct arizona_gpio *arizona_gpio; | 101 | struct arizona_gpio *arizona_gpio; |
102 | int ret; | 102 | int ret; |
103 | 103 | ||
diff --git a/drivers/gpio/gpio-da9052.c b/drivers/gpio/gpio-da9052.c index 29b11e9b6a78..9b77dc05d4ad 100644 --- a/drivers/gpio/gpio-da9052.c +++ b/drivers/gpio/gpio-da9052.c | |||
@@ -216,7 +216,7 @@ static int da9052_gpio_probe(struct platform_device *pdev) | |||
216 | return -ENOMEM; | 216 | return -ENOMEM; |
217 | 217 | ||
218 | gpio->da9052 = dev_get_drvdata(pdev->dev.parent); | 218 | gpio->da9052 = dev_get_drvdata(pdev->dev.parent); |
219 | pdata = gpio->da9052->dev->platform_data; | 219 | pdata = dev_get_platdata(gpio->da9052->dev); |
220 | 220 | ||
221 | gpio->gp = reference_gp; | 221 | gpio->gp = reference_gp; |
222 | if (pdata && pdata->gpio_base) | 222 | if (pdata && pdata->gpio_base) |
diff --git a/drivers/gpio/gpio-da9055.c b/drivers/gpio/gpio-da9055.c index fd6dfe382f13..7ef0820032bd 100644 --- a/drivers/gpio/gpio-da9055.c +++ b/drivers/gpio/gpio-da9055.c | |||
@@ -150,7 +150,7 @@ static int da9055_gpio_probe(struct platform_device *pdev) | |||
150 | return -ENOMEM; | 150 | return -ENOMEM; |
151 | 151 | ||
152 | gpio->da9055 = dev_get_drvdata(pdev->dev.parent); | 152 | gpio->da9055 = dev_get_drvdata(pdev->dev.parent); |
153 | pdata = gpio->da9055->dev->platform_data; | 153 | pdata = dev_get_platdata(gpio->da9055->dev); |
154 | 154 | ||
155 | gpio->gp = reference_gp; | 155 | gpio->gp = reference_gp; |
156 | if (pdata && pdata->gpio_base) | 156 | if (pdata && pdata->gpio_base) |
diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index 5cba855638bf..c6e1f086efe8 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/gpio.h> | 30 | #include <linux/gpio.h> |
31 | #include <linux/slab.h> | 31 | #include <linux/slab.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/pinctrl/consumer.h> | ||
33 | #include <linux/platform_data/gpio-em.h> | 34 | #include <linux/platform_data/gpio-em.h> |
34 | 35 | ||
35 | struct em_gio_priv { | 36 | struct em_gio_priv { |
@@ -216,6 +217,21 @@ static int em_gio_to_irq(struct gpio_chip *chip, unsigned offset) | |||
216 | return irq_create_mapping(gpio_to_priv(chip)->irq_domain, offset); | 217 | return irq_create_mapping(gpio_to_priv(chip)->irq_domain, offset); |
217 | } | 218 | } |
218 | 219 | ||
220 | static int em_gio_request(struct gpio_chip *chip, unsigned offset) | ||
221 | { | ||
222 | return pinctrl_request_gpio(chip->base + offset); | ||
223 | } | ||
224 | |||
225 | static void em_gio_free(struct gpio_chip *chip, unsigned offset) | ||
226 | { | ||
227 | pinctrl_free_gpio(chip->base + offset); | ||
228 | |||
229 | /* Set the GPIO as an input to ensure that the next GPIO request won't | ||
230 | * drive the GPIO pin as an output. | ||
231 | */ | ||
232 | em_gio_direction_input(chip, offset); | ||
233 | } | ||
234 | |||
219 | static int em_gio_irq_domain_map(struct irq_domain *h, unsigned int virq, | 235 | static int em_gio_irq_domain_map(struct irq_domain *h, unsigned int virq, |
220 | irq_hw_number_t hw) | 236 | irq_hw_number_t hw) |
221 | { | 237 | { |
@@ -237,7 +253,7 @@ static struct irq_domain_ops em_gio_irq_domain_ops = { | |||
237 | static int em_gio_probe(struct platform_device *pdev) | 253 | static int em_gio_probe(struct platform_device *pdev) |
238 | { | 254 | { |
239 | struct gpio_em_config pdata_dt; | 255 | struct gpio_em_config pdata_dt; |
240 | struct gpio_em_config *pdata = pdev->dev.platform_data; | 256 | struct gpio_em_config *pdata = dev_get_platdata(&pdev->dev); |
241 | struct em_gio_priv *p; | 257 | struct em_gio_priv *p; |
242 | struct resource *io[2], *irq[2]; | 258 | struct resource *io[2], *irq[2]; |
243 | struct gpio_chip *gpio_chip; | 259 | struct gpio_chip *gpio_chip; |
@@ -308,6 +324,8 @@ static int em_gio_probe(struct platform_device *pdev) | |||
308 | gpio_chip->direction_output = em_gio_direction_output; | 324 | gpio_chip->direction_output = em_gio_direction_output; |
309 | gpio_chip->set = em_gio_set; | 325 | gpio_chip->set = em_gio_set; |
310 | gpio_chip->to_irq = em_gio_to_irq; | 326 | gpio_chip->to_irq = em_gio_to_irq; |
327 | gpio_chip->request = em_gio_request; | ||
328 | gpio_chip->free = em_gio_free; | ||
311 | gpio_chip->label = name; | 329 | gpio_chip->label = name; |
312 | gpio_chip->owner = THIS_MODULE; | 330 | gpio_chip->owner = THIS_MODULE; |
313 | gpio_chip->base = pdata->gpio_base; | 331 | gpio_chip->base = pdata->gpio_base; |
@@ -351,6 +369,13 @@ static int em_gio_probe(struct platform_device *pdev) | |||
351 | dev_err(&pdev->dev, "failed to add GPIO controller\n"); | 369 | dev_err(&pdev->dev, "failed to add GPIO controller\n"); |
352 | goto err1; | 370 | goto err1; |
353 | } | 371 | } |
372 | |||
373 | if (pdata->pctl_name) { | ||
374 | ret = gpiochip_add_pin_range(gpio_chip, pdata->pctl_name, 0, | ||
375 | gpio_chip->base, gpio_chip->ngpio); | ||
376 | if (ret < 0) | ||
377 | dev_warn(&pdev->dev, "failed to add pin range\n"); | ||
378 | } | ||
354 | return 0; | 379 | return 0; |
355 | 380 | ||
356 | err1: | 381 | err1: |
diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c new file mode 100644 index 000000000000..9cb8320e1181 --- /dev/null +++ b/drivers/gpio/gpio-f7188x.c | |||
@@ -0,0 +1,469 @@ | |||
1 | /* | ||
2 | * GPIO driver for Fintek Super-I/O F71882 and F71889 | ||
3 | * | ||
4 | * Copyright (C) 2010-2013 LaCie | ||
5 | * | ||
6 | * Author: Simon Guinot <simon.guinot@sequanux.org> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/gpio.h> | ||
19 | |||
20 | #define DRVNAME "gpio-f7188x" | ||
21 | |||
22 | /* | ||
23 | * Super-I/O registers | ||
24 | */ | ||
25 | #define SIO_LDSEL 0x07 /* Logical device select */ | ||
26 | #define SIO_DEVID 0x20 /* Device ID (2 bytes) */ | ||
27 | #define SIO_DEVREV 0x22 /* Device revision */ | ||
28 | #define SIO_MANID 0x23 /* Fintek ID (2 bytes) */ | ||
29 | |||
30 | #define SIO_LD_GPIO 0x06 /* GPIO logical device */ | ||
31 | #define SIO_UNLOCK_KEY 0x87 /* Key to enable Super-I/O */ | ||
32 | #define SIO_LOCK_KEY 0xAA /* Key to disable Super-I/O */ | ||
33 | |||
34 | #define SIO_FINTEK_ID 0x1934 /* Manufacturer ID */ | ||
35 | #define SIO_F71882_ID 0x0541 /* F71882 chipset ID */ | ||
36 | #define SIO_F71889_ID 0x0909 /* F71889 chipset ID */ | ||
37 | |||
38 | enum chips { f71882fg, f71889f }; | ||
39 | |||
40 | static const char * const f7188x_names[] = { | ||
41 | "f71882fg", | ||
42 | "f71889f", | ||
43 | }; | ||
44 | |||
45 | struct f7188x_sio { | ||
46 | int addr; | ||
47 | enum chips type; | ||
48 | }; | ||
49 | |||
50 | struct f7188x_gpio_bank { | ||
51 | struct gpio_chip chip; | ||
52 | unsigned int regbase; | ||
53 | struct f7188x_gpio_data *data; | ||
54 | }; | ||
55 | |||
56 | struct f7188x_gpio_data { | ||
57 | struct f7188x_sio *sio; | ||
58 | int nr_bank; | ||
59 | struct f7188x_gpio_bank *bank; | ||
60 | }; | ||
61 | |||
62 | /* | ||
63 | * Super-I/O functions. | ||
64 | */ | ||
65 | |||
66 | static inline int superio_inb(int base, int reg) | ||
67 | { | ||
68 | outb(reg, base); | ||
69 | return inb(base + 1); | ||
70 | } | ||
71 | |||
72 | static int superio_inw(int base, int reg) | ||
73 | { | ||
74 | int val; | ||
75 | |||
76 | outb(reg++, base); | ||
77 | val = inb(base + 1) << 8; | ||
78 | outb(reg, base); | ||
79 | val |= inb(base + 1); | ||
80 | |||
81 | return val; | ||
82 | } | ||
83 | |||
84 | static inline void superio_outb(int base, int reg, int val) | ||
85 | { | ||
86 | outb(reg, base); | ||
87 | outb(val, base + 1); | ||
88 | } | ||
89 | |||
90 | static inline int superio_enter(int base) | ||
91 | { | ||
92 | /* Don't step on other drivers' I/O space by accident. */ | ||
93 | if (!request_muxed_region(base, 2, DRVNAME)) { | ||
94 | pr_err(DRVNAME "I/O address 0x%04x already in use\n", base); | ||
95 | return -EBUSY; | ||
96 | } | ||
97 | |||
98 | /* According to the datasheet the key must be send twice. */ | ||
99 | outb(SIO_UNLOCK_KEY, base); | ||
100 | outb(SIO_UNLOCK_KEY, base); | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static inline void superio_select(int base, int ld) | ||
106 | { | ||
107 | outb(SIO_LDSEL, base); | ||
108 | outb(ld, base + 1); | ||
109 | } | ||
110 | |||
111 | static inline void superio_exit(int base) | ||
112 | { | ||
113 | outb(SIO_LOCK_KEY, base); | ||
114 | release_region(base, 2); | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | * GPIO chip. | ||
119 | */ | ||
120 | |||
121 | static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset); | ||
122 | static int f7188x_gpio_get(struct gpio_chip *chip, unsigned offset); | ||
123 | static int f7188x_gpio_direction_out(struct gpio_chip *chip, | ||
124 | unsigned offset, int value); | ||
125 | static void f7188x_gpio_set(struct gpio_chip *chip, unsigned offset, int value); | ||
126 | |||
127 | #define F7188X_GPIO_BANK(_base, _ngpio, _regbase) \ | ||
128 | { \ | ||
129 | .chip = { \ | ||
130 | .label = DRVNAME, \ | ||
131 | .owner = THIS_MODULE, \ | ||
132 | .direction_input = f7188x_gpio_direction_in, \ | ||
133 | .get = f7188x_gpio_get, \ | ||
134 | .direction_output = f7188x_gpio_direction_out, \ | ||
135 | .set = f7188x_gpio_set, \ | ||
136 | .base = _base, \ | ||
137 | .ngpio = _ngpio, \ | ||
138 | }, \ | ||
139 | .regbase = _regbase, \ | ||
140 | } | ||
141 | |||
142 | #define gpio_dir(base) (base + 0) | ||
143 | #define gpio_data_out(base) (base + 1) | ||
144 | #define gpio_data_in(base) (base + 2) | ||
145 | /* Output mode register (0:open drain 1:push-pull). */ | ||
146 | #define gpio_out_mode(base) (base + 3) | ||
147 | |||
148 | static struct f7188x_gpio_bank f71882_gpio_bank[] = { | ||
149 | F7188X_GPIO_BANK(0 , 8, 0xF0), | ||
150 | F7188X_GPIO_BANK(10, 8, 0xE0), | ||
151 | F7188X_GPIO_BANK(20, 8, 0xD0), | ||
152 | F7188X_GPIO_BANK(30, 4, 0xC0), | ||
153 | F7188X_GPIO_BANK(40, 4, 0xB0), | ||
154 | }; | ||
155 | |||
156 | static struct f7188x_gpio_bank f71889_gpio_bank[] = { | ||
157 | F7188X_GPIO_BANK(0 , 7, 0xF0), | ||
158 | F7188X_GPIO_BANK(10, 7, 0xE0), | ||
159 | F7188X_GPIO_BANK(20, 8, 0xD0), | ||
160 | F7188X_GPIO_BANK(30, 8, 0xC0), | ||
161 | F7188X_GPIO_BANK(40, 8, 0xB0), | ||
162 | F7188X_GPIO_BANK(50, 5, 0xA0), | ||
163 | F7188X_GPIO_BANK(60, 8, 0x90), | ||
164 | F7188X_GPIO_BANK(70, 8, 0x80), | ||
165 | }; | ||
166 | |||
167 | static int f7188x_gpio_direction_in(struct gpio_chip *chip, unsigned offset) | ||
168 | { | ||
169 | int err; | ||
170 | struct f7188x_gpio_bank *bank = | ||
171 | container_of(chip, struct f7188x_gpio_bank, chip); | ||
172 | struct f7188x_sio *sio = bank->data->sio; | ||
173 | u8 dir; | ||
174 | |||
175 | err = superio_enter(sio->addr); | ||
176 | if (err) | ||
177 | return err; | ||
178 | superio_select(sio->addr, SIO_LD_GPIO); | ||
179 | |||
180 | dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); | ||
181 | dir &= ~(1 << offset); | ||
182 | superio_outb(sio->addr, gpio_dir(bank->regbase), dir); | ||
183 | |||
184 | superio_exit(sio->addr); | ||
185 | |||
186 | return 0; | ||
187 | } | ||
188 | |||
189 | static int f7188x_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
190 | { | ||
191 | int err; | ||
192 | struct f7188x_gpio_bank *bank = | ||
193 | container_of(chip, struct f7188x_gpio_bank, chip); | ||
194 | struct f7188x_sio *sio = bank->data->sio; | ||
195 | u8 dir, data; | ||
196 | |||
197 | err = superio_enter(sio->addr); | ||
198 | if (err) | ||
199 | return err; | ||
200 | superio_select(sio->addr, SIO_LD_GPIO); | ||
201 | |||
202 | dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); | ||
203 | dir = !!(dir & (1 << offset)); | ||
204 | if (dir) | ||
205 | data = superio_inb(sio->addr, gpio_data_out(bank->regbase)); | ||
206 | else | ||
207 | data = superio_inb(sio->addr, gpio_data_in(bank->regbase)); | ||
208 | |||
209 | superio_exit(sio->addr); | ||
210 | |||
211 | return !!(data & 1 << offset); | ||
212 | } | ||
213 | |||
214 | static int f7188x_gpio_direction_out(struct gpio_chip *chip, | ||
215 | unsigned offset, int value) | ||
216 | { | ||
217 | int err; | ||
218 | struct f7188x_gpio_bank *bank = | ||
219 | container_of(chip, struct f7188x_gpio_bank, chip); | ||
220 | struct f7188x_sio *sio = bank->data->sio; | ||
221 | u8 dir, data_out; | ||
222 | |||
223 | err = superio_enter(sio->addr); | ||
224 | if (err) | ||
225 | return err; | ||
226 | superio_select(sio->addr, SIO_LD_GPIO); | ||
227 | |||
228 | data_out = superio_inb(sio->addr, gpio_data_out(bank->regbase)); | ||
229 | if (value) | ||
230 | data_out |= (1 << offset); | ||
231 | else | ||
232 | data_out &= ~(1 << offset); | ||
233 | superio_outb(sio->addr, gpio_data_out(bank->regbase), data_out); | ||
234 | |||
235 | dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); | ||
236 | dir |= (1 << offset); | ||
237 | superio_outb(sio->addr, gpio_dir(bank->regbase), dir); | ||
238 | |||
239 | superio_exit(sio->addr); | ||
240 | |||
241 | return 0; | ||
242 | } | ||
243 | |||
244 | static void f7188x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | ||
245 | { | ||
246 | int err; | ||
247 | struct f7188x_gpio_bank *bank = | ||
248 | container_of(chip, struct f7188x_gpio_bank, chip); | ||
249 | struct f7188x_sio *sio = bank->data->sio; | ||
250 | u8 data_out; | ||
251 | |||
252 | err = superio_enter(sio->addr); | ||
253 | if (err) | ||
254 | return; | ||
255 | superio_select(sio->addr, SIO_LD_GPIO); | ||
256 | |||
257 | data_out = superio_inb(sio->addr, gpio_data_out(bank->regbase)); | ||
258 | if (value) | ||
259 | data_out |= (1 << offset); | ||
260 | else | ||
261 | data_out &= ~(1 << offset); | ||
262 | superio_outb(sio->addr, gpio_data_out(bank->regbase), data_out); | ||
263 | |||
264 | superio_exit(sio->addr); | ||
265 | } | ||
266 | |||
267 | /* | ||
268 | * Platform device and driver. | ||
269 | */ | ||
270 | |||
271 | static int f7188x_gpio_probe(struct platform_device *pdev) | ||
272 | { | ||
273 | int err; | ||
274 | int i; | ||
275 | struct f7188x_sio *sio = pdev->dev.platform_data; | ||
276 | struct f7188x_gpio_data *data; | ||
277 | |||
278 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | ||
279 | if (!data) | ||
280 | return -ENOMEM; | ||
281 | |||
282 | switch (sio->type) { | ||
283 | case f71882fg: | ||
284 | data->nr_bank = ARRAY_SIZE(f71882_gpio_bank); | ||
285 | data->bank = f71882_gpio_bank; | ||
286 | break; | ||
287 | case f71889f: | ||
288 | data->nr_bank = ARRAY_SIZE(f71889_gpio_bank); | ||
289 | data->bank = f71889_gpio_bank; | ||
290 | break; | ||
291 | default: | ||
292 | return -ENODEV; | ||
293 | } | ||
294 | data->sio = sio; | ||
295 | |||
296 | platform_set_drvdata(pdev, data); | ||
297 | |||
298 | /* For each GPIO bank, register a GPIO chip. */ | ||
299 | for (i = 0; i < data->nr_bank; i++) { | ||
300 | struct f7188x_gpio_bank *bank = &data->bank[i]; | ||
301 | |||
302 | bank->chip.dev = &pdev->dev; | ||
303 | bank->data = data; | ||
304 | |||
305 | err = gpiochip_add(&bank->chip); | ||
306 | if (err) { | ||
307 | dev_err(&pdev->dev, | ||
308 | "Failed to register gpiochip %d: %d\n", | ||
309 | i, err); | ||
310 | goto err_gpiochip; | ||
311 | } | ||
312 | } | ||
313 | |||
314 | return 0; | ||
315 | |||
316 | err_gpiochip: | ||
317 | for (i = i - 1; i >= 0; i--) { | ||
318 | struct f7188x_gpio_bank *bank = &data->bank[i]; | ||
319 | int tmp; | ||
320 | |||
321 | tmp = gpiochip_remove(&bank->chip); | ||
322 | if (tmp < 0) | ||
323 | dev_err(&pdev->dev, | ||
324 | "Failed to remove gpiochip %d: %d\n", | ||
325 | i, tmp); | ||
326 | } | ||
327 | |||
328 | return err; | ||
329 | } | ||
330 | |||
331 | static int f7188x_gpio_remove(struct platform_device *pdev) | ||
332 | { | ||
333 | int err; | ||
334 | int i; | ||
335 | struct f7188x_gpio_data *data = platform_get_drvdata(pdev); | ||
336 | |||
337 | for (i = 0; i < data->nr_bank; i++) { | ||
338 | struct f7188x_gpio_bank *bank = &data->bank[i]; | ||
339 | |||
340 | err = gpiochip_remove(&bank->chip); | ||
341 | if (err) { | ||
342 | dev_err(&pdev->dev, | ||
343 | "Failed to remove GPIO gpiochip %d: %d\n", | ||
344 | i, err); | ||
345 | return err; | ||
346 | } | ||
347 | } | ||
348 | |||
349 | return 0; | ||
350 | } | ||
351 | |||
352 | static int __init f7188x_find(int addr, struct f7188x_sio *sio) | ||
353 | { | ||
354 | int err; | ||
355 | u16 devid; | ||
356 | |||
357 | err = superio_enter(addr); | ||
358 | if (err) | ||
359 | return err; | ||
360 | |||
361 | err = -ENODEV; | ||
362 | devid = superio_inw(addr, SIO_MANID); | ||
363 | if (devid != SIO_FINTEK_ID) { | ||
364 | pr_debug(DRVNAME ": Not a Fintek device at 0x%08x\n", addr); | ||
365 | goto err; | ||
366 | } | ||
367 | |||
368 | devid = superio_inw(addr, SIO_DEVID); | ||
369 | switch (devid) { | ||
370 | case SIO_F71882_ID: | ||
371 | sio->type = f71882fg; | ||
372 | break; | ||
373 | case SIO_F71889_ID: | ||
374 | sio->type = f71889f; | ||
375 | break; | ||
376 | default: | ||
377 | pr_info(DRVNAME ": Unsupported Fintek device 0x%04x\n", devid); | ||
378 | goto err; | ||
379 | } | ||
380 | sio->addr = addr; | ||
381 | err = 0; | ||
382 | |||
383 | pr_info(DRVNAME ": Found %s at %#x, revision %d\n", | ||
384 | f7188x_names[sio->type], | ||
385 | (unsigned int) addr, | ||
386 | (int) superio_inb(addr, SIO_DEVREV)); | ||
387 | |||
388 | err: | ||
389 | superio_exit(addr); | ||
390 | return err; | ||
391 | } | ||
392 | |||
393 | static struct platform_device *f7188x_gpio_pdev; | ||
394 | |||
395 | static int __init | ||
396 | f7188x_gpio_device_add(const struct f7188x_sio *sio) | ||
397 | { | ||
398 | int err; | ||
399 | |||
400 | f7188x_gpio_pdev = platform_device_alloc(DRVNAME, -1); | ||
401 | if (!f7188x_gpio_pdev) | ||
402 | return -ENOMEM; | ||
403 | |||
404 | err = platform_device_add_data(f7188x_gpio_pdev, | ||
405 | sio, sizeof(*sio)); | ||
406 | if (err) { | ||
407 | pr_err(DRVNAME "Platform data allocation failed\n"); | ||
408 | goto err; | ||
409 | } | ||
410 | |||
411 | err = platform_device_add(f7188x_gpio_pdev); | ||
412 | if (err) { | ||
413 | pr_err(DRVNAME "Device addition failed\n"); | ||
414 | goto err; | ||
415 | } | ||
416 | |||
417 | return 0; | ||
418 | |||
419 | err: | ||
420 | platform_device_put(f7188x_gpio_pdev); | ||
421 | |||
422 | return err; | ||
423 | } | ||
424 | |||
425 | /* | ||
426 | * Try to match a supported Fintech device by reading the (hard-wired) | ||
427 | * configuration I/O ports. If available, then register both the platform | ||
428 | * device and driver to support the GPIOs. | ||
429 | */ | ||
430 | |||
431 | static struct platform_driver f7188x_gpio_driver = { | ||
432 | .driver = { | ||
433 | .owner = THIS_MODULE, | ||
434 | .name = DRVNAME, | ||
435 | }, | ||
436 | .probe = f7188x_gpio_probe, | ||
437 | .remove = f7188x_gpio_remove, | ||
438 | }; | ||
439 | |||
440 | static int __init f7188x_gpio_init(void) | ||
441 | { | ||
442 | int err; | ||
443 | struct f7188x_sio sio; | ||
444 | |||
445 | if (f7188x_find(0x2e, &sio) && | ||
446 | f7188x_find(0x4e, &sio)) | ||
447 | return -ENODEV; | ||
448 | |||
449 | err = platform_driver_register(&f7188x_gpio_driver); | ||
450 | if (!err) { | ||
451 | err = f7188x_gpio_device_add(&sio); | ||
452 | if (err) | ||
453 | platform_driver_unregister(&f7188x_gpio_driver); | ||
454 | } | ||
455 | |||
456 | return err; | ||
457 | } | ||
458 | subsys_initcall(f7188x_gpio_init); | ||
459 | |||
460 | static void __exit f7188x_gpio_exit(void) | ||
461 | { | ||
462 | platform_device_unregister(f7188x_gpio_pdev); | ||
463 | platform_driver_unregister(&f7188x_gpio_driver); | ||
464 | } | ||
465 | module_exit(f7188x_gpio_exit); | ||
466 | |||
467 | MODULE_DESCRIPTION("GPIO driver for Super-I/O chips F71882FG and F71889F"); | ||
468 | MODULE_AUTHOR("Simon Guinot <simon.guinot@sequanux.org>"); | ||
469 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c index 2729e3d2d5bb..814addb62d2c 100644 --- a/drivers/gpio/gpio-ich.c +++ b/drivers/gpio/gpio-ich.c | |||
@@ -354,7 +354,7 @@ static int ichx_gpio_probe(struct platform_device *pdev) | |||
354 | { | 354 | { |
355 | struct resource *res_base, *res_pm; | 355 | struct resource *res_base, *res_pm; |
356 | int err; | 356 | int err; |
357 | struct lpc_ich_info *ich_info = pdev->dev.platform_data; | 357 | struct lpc_ich_info *ich_info = dev_get_platdata(&pdev->dev); |
358 | 358 | ||
359 | if (!ich_info) | 359 | if (!ich_info) |
360 | return -ENODEV; | 360 | return -ENODEV; |
diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c index 7d0a04169a35..2ecd3a09c743 100644 --- a/drivers/gpio/gpio-janz-ttl.c +++ b/drivers/gpio/gpio-janz-ttl.c | |||
@@ -149,7 +149,7 @@ static int ttl_probe(struct platform_device *pdev) | |||
149 | struct resource *res; | 149 | struct resource *res; |
150 | int ret; | 150 | int ret; |
151 | 151 | ||
152 | pdata = pdev->dev.platform_data; | 152 | pdata = dev_get_platdata(&pdev->dev); |
153 | if (!pdata) { | 153 | if (!pdata) { |
154 | dev_err(dev, "no platform data\n"); | 154 | dev_err(dev, "no platform data\n"); |
155 | ret = -ENXIO; | 155 | ret = -ENXIO; |
diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c new file mode 100644 index 000000000000..efdc3924d7df --- /dev/null +++ b/drivers/gpio/gpio-kempld.c | |||
@@ -0,0 +1,219 @@ | |||
1 | /* | ||
2 | * Kontron PLD GPIO driver | ||
3 | * | ||
4 | * Copyright (c) 2010-2013 Kontron Europe GmbH | ||
5 | * Author: Michael Brunner <michael.brunner@kontron.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 2 as published | ||
9 | * by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | */ | ||
16 | |||
17 | #include <linux/init.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/bitops.h> | ||
21 | #include <linux/errno.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/gpio.h> | ||
24 | #include <linux/mfd/kempld.h> | ||
25 | |||
26 | #define KEMPLD_GPIO_MAX_NUM 16 | ||
27 | #define KEMPLD_GPIO_MASK(x) (1 << ((x) % 8)) | ||
28 | #define KEMPLD_GPIO_DIR_NUM(x) (0x40 + (x) / 8) | ||
29 | #define KEMPLD_GPIO_LVL_NUM(x) (0x42 + (x) / 8) | ||
30 | #define KEMPLD_GPIO_EVT_LVL_EDGE 0x46 | ||
31 | #define KEMPLD_GPIO_IEN 0x4A | ||
32 | |||
33 | struct kempld_gpio_data { | ||
34 | struct gpio_chip chip; | ||
35 | struct kempld_device_data *pld; | ||
36 | }; | ||
37 | |||
38 | /* | ||
39 | * Set or clear GPIO bit | ||
40 | * kempld_get_mutex must be called prior to calling this function. | ||
41 | */ | ||
42 | static void kempld_gpio_bitop(struct kempld_device_data *pld, | ||
43 | u8 reg, u8 bit, u8 val) | ||
44 | { | ||
45 | u8 status; | ||
46 | |||
47 | status = kempld_read8(pld, reg); | ||
48 | if (val) | ||
49 | status |= KEMPLD_GPIO_MASK(bit); | ||
50 | else | ||
51 | status &= ~KEMPLD_GPIO_MASK(bit); | ||
52 | kempld_write8(pld, reg, status); | ||
53 | } | ||
54 | |||
55 | static int kempld_gpio_get_bit(struct kempld_device_data *pld, u8 reg, u8 bit) | ||
56 | { | ||
57 | u8 status; | ||
58 | |||
59 | kempld_get_mutex(pld); | ||
60 | status = kempld_read8(pld, reg); | ||
61 | kempld_release_mutex(pld); | ||
62 | |||
63 | return !!(status & KEMPLD_GPIO_MASK(bit)); | ||
64 | } | ||
65 | |||
66 | static int kempld_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
67 | { | ||
68 | struct kempld_gpio_data *gpio | ||
69 | = container_of(chip, struct kempld_gpio_data, chip); | ||
70 | struct kempld_device_data *pld = gpio->pld; | ||
71 | |||
72 | return kempld_gpio_get_bit(pld, KEMPLD_GPIO_LVL_NUM(offset), offset); | ||
73 | } | ||
74 | |||
75 | static void kempld_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | ||
76 | { | ||
77 | struct kempld_gpio_data *gpio | ||
78 | = container_of(chip, struct kempld_gpio_data, chip); | ||
79 | struct kempld_device_data *pld = gpio->pld; | ||
80 | |||
81 | kempld_get_mutex(pld); | ||
82 | kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value); | ||
83 | kempld_release_mutex(pld); | ||
84 | } | ||
85 | |||
86 | static int kempld_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | ||
87 | { | ||
88 | struct kempld_gpio_data *gpio | ||
89 | = container_of(chip, struct kempld_gpio_data, chip); | ||
90 | struct kempld_device_data *pld = gpio->pld; | ||
91 | |||
92 | kempld_get_mutex(pld); | ||
93 | kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 0); | ||
94 | kempld_release_mutex(pld); | ||
95 | |||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static int kempld_gpio_direction_output(struct gpio_chip *chip, unsigned offset, | ||
100 | int value) | ||
101 | { | ||
102 | struct kempld_gpio_data *gpio | ||
103 | = container_of(chip, struct kempld_gpio_data, chip); | ||
104 | struct kempld_device_data *pld = gpio->pld; | ||
105 | |||
106 | kempld_get_mutex(pld); | ||
107 | kempld_gpio_bitop(pld, KEMPLD_GPIO_LVL_NUM(offset), offset, value); | ||
108 | kempld_gpio_bitop(pld, KEMPLD_GPIO_DIR_NUM(offset), offset, 1); | ||
109 | kempld_release_mutex(pld); | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset) | ||
115 | { | ||
116 | struct kempld_gpio_data *gpio | ||
117 | = container_of(chip, struct kempld_gpio_data, chip); | ||
118 | struct kempld_device_data *pld = gpio->pld; | ||
119 | |||
120 | return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset); | ||
121 | } | ||
122 | |||
123 | static int kempld_gpio_pincount(struct kempld_device_data *pld) | ||
124 | { | ||
125 | u16 evt, evt_back; | ||
126 | |||
127 | kempld_get_mutex(pld); | ||
128 | |||
129 | /* Backup event register as it might be already initialized */ | ||
130 | evt_back = kempld_read16(pld, KEMPLD_GPIO_EVT_LVL_EDGE); | ||
131 | /* Clear event register */ | ||
132 | kempld_write16(pld, KEMPLD_GPIO_EVT_LVL_EDGE, 0x0000); | ||
133 | /* Read back event register */ | ||
134 | evt = kempld_read16(pld, KEMPLD_GPIO_EVT_LVL_EDGE); | ||
135 | /* Restore event register */ | ||
136 | kempld_write16(pld, KEMPLD_GPIO_EVT_LVL_EDGE, evt_back); | ||
137 | |||
138 | kempld_release_mutex(pld); | ||
139 | |||
140 | return evt ? __ffs(evt) : 16; | ||
141 | } | ||
142 | |||
143 | static int kempld_gpio_probe(struct platform_device *pdev) | ||
144 | { | ||
145 | struct device *dev = &pdev->dev; | ||
146 | struct kempld_device_data *pld = dev_get_drvdata(dev->parent); | ||
147 | struct kempld_platform_data *pdata = dev_get_platdata(pld->dev); | ||
148 | struct kempld_gpio_data *gpio; | ||
149 | struct gpio_chip *chip; | ||
150 | int ret; | ||
151 | |||
152 | if (pld->info.spec_major < 2) { | ||
153 | dev_err(dev, | ||
154 | "Driver only supports GPIO devices compatible to PLD spec. rev. 2.0 or higher\n"); | ||
155 | return -ENODEV; | ||
156 | } | ||
157 | |||
158 | gpio = devm_kzalloc(dev, sizeof(*gpio), GFP_KERNEL); | ||
159 | if (gpio == NULL) | ||
160 | return -ENOMEM; | ||
161 | |||
162 | gpio->pld = pld; | ||
163 | |||
164 | platform_set_drvdata(pdev, gpio); | ||
165 | |||
166 | chip = &gpio->chip; | ||
167 | chip->label = "gpio-kempld"; | ||
168 | chip->owner = THIS_MODULE; | ||
169 | chip->dev = dev; | ||
170 | chip->can_sleep = 1; | ||
171 | if (pdata && pdata->gpio_base) | ||
172 | chip->base = pdata->gpio_base; | ||
173 | else | ||
174 | chip->base = -1; | ||
175 | chip->direction_input = kempld_gpio_direction_input; | ||
176 | chip->direction_output = kempld_gpio_direction_output; | ||
177 | chip->get_direction = kempld_gpio_get_direction; | ||
178 | chip->get = kempld_gpio_get; | ||
179 | chip->set = kempld_gpio_set; | ||
180 | chip->ngpio = kempld_gpio_pincount(pld); | ||
181 | if (chip->ngpio == 0) { | ||
182 | dev_err(dev, "No GPIO pins detected\n"); | ||
183 | return -ENODEV; | ||
184 | } | ||
185 | |||
186 | ret = gpiochip_add(chip); | ||
187 | if (ret) { | ||
188 | dev_err(dev, "Could not register GPIO chip\n"); | ||
189 | return ret; | ||
190 | } | ||
191 | |||
192 | dev_info(dev, "GPIO functionality initialized with %d pins\n", | ||
193 | chip->ngpio); | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static int kempld_gpio_remove(struct platform_device *pdev) | ||
199 | { | ||
200 | struct kempld_gpio_data *gpio = platform_get_drvdata(pdev); | ||
201 | |||
202 | return gpiochip_remove(&gpio->chip); | ||
203 | } | ||
204 | |||
205 | static struct platform_driver kempld_gpio_driver = { | ||
206 | .driver = { | ||
207 | .name = "kempld-gpio", | ||
208 | .owner = THIS_MODULE, | ||
209 | }, | ||
210 | .probe = kempld_gpio_probe, | ||
211 | .remove = kempld_gpio_remove, | ||
212 | }; | ||
213 | |||
214 | module_platform_driver(kempld_gpio_driver); | ||
215 | |||
216 | MODULE_DESCRIPTION("KEM PLD GPIO Driver"); | ||
217 | MODULE_AUTHOR("Michael Brunner <michael.brunner@kontron.com>"); | ||
218 | MODULE_LICENSE("GPL"); | ||
219 | MODULE_ALIAS("platform:gpio-kempld"); | ||
diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c index 761c4705dfbb..2d9ca6055e5e 100644 --- a/drivers/gpio/gpio-lynxpoint.c +++ b/drivers/gpio/gpio-lynxpoint.c | |||
@@ -444,6 +444,7 @@ static int lp_gpio_remove(struct platform_device *pdev) | |||
444 | { | 444 | { |
445 | struct lp_gpio *lg = platform_get_drvdata(pdev); | 445 | struct lp_gpio *lg = platform_get_drvdata(pdev); |
446 | int err; | 446 | int err; |
447 | pm_runtime_disable(&pdev->dev); | ||
447 | err = gpiochip_remove(&lg->chip); | 448 | err = gpiochip_remove(&lg->chip); |
448 | if (err) | 449 | if (err) |
449 | dev_warn(&pdev->dev, "failed to remove gpio_chip.\n"); | 450 | dev_warn(&pdev->dev, "failed to remove gpio_chip.\n"); |
diff --git a/drivers/gpio/gpio-max7301.c b/drivers/gpio/gpio-max7301.c index 3b16ab701630..6e1c984a75d4 100644 --- a/drivers/gpio/gpio-max7301.c +++ b/drivers/gpio/gpio-max7301.c | |||
@@ -56,8 +56,7 @@ static int max7301_probe(struct spi_device *spi) | |||
56 | int ret; | 56 | int ret; |
57 | 57 | ||
58 | /* bits_per_word cannot be configured in platform data */ | 58 | /* bits_per_word cannot be configured in platform data */ |
59 | if (spi->dev.platform_data) | 59 | spi->bits_per_word = 16; |
60 | spi->bits_per_word = 16; | ||
61 | ret = spi_setup(spi); | 60 | ret = spi_setup(spi); |
62 | if (ret < 0) | 61 | if (ret < 0) |
63 | return ret; | 62 | return ret; |
diff --git a/drivers/gpio/gpio-max730x.c b/drivers/gpio/gpio-max730x.c index 00092342b84c..f4f4ed19bdc1 100644 --- a/drivers/gpio/gpio-max730x.c +++ b/drivers/gpio/gpio-max730x.c | |||
@@ -166,7 +166,7 @@ int __max730x_probe(struct max7301 *ts) | |||
166 | struct max7301_platform_data *pdata; | 166 | struct max7301_platform_data *pdata; |
167 | int i, ret; | 167 | int i, ret; |
168 | 168 | ||
169 | pdata = dev->platform_data; | 169 | pdata = dev_get_platdata(dev); |
170 | 170 | ||
171 | mutex_init(&ts->lock); | 171 | mutex_init(&ts->lock); |
172 | dev_set_drvdata(dev, ts); | 172 | dev_set_drvdata(dev, ts); |
diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c index d4b51b163b03..91ad74dea8ce 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c | |||
@@ -453,7 +453,7 @@ static int max732x_irq_setup(struct max732x_chip *chip, | |||
453 | const struct i2c_device_id *id) | 453 | const struct i2c_device_id *id) |
454 | { | 454 | { |
455 | struct i2c_client *client = chip->client; | 455 | struct i2c_client *client = chip->client; |
456 | struct max732x_platform_data *pdata = client->dev.platform_data; | 456 | struct max732x_platform_data *pdata = dev_get_platdata(&client->dev); |
457 | int has_irq = max732x_features[id->driver_data] >> 32; | 457 | int has_irq = max732x_features[id->driver_data] >> 32; |
458 | int ret; | 458 | int ret; |
459 | 459 | ||
@@ -512,7 +512,7 @@ static int max732x_irq_setup(struct max732x_chip *chip, | |||
512 | const struct i2c_device_id *id) | 512 | const struct i2c_device_id *id) |
513 | { | 513 | { |
514 | struct i2c_client *client = chip->client; | 514 | struct i2c_client *client = chip->client; |
515 | struct max732x_platform_data *pdata = client->dev.platform_data; | 515 | struct max732x_platform_data *pdata = dev_get_platdata(&client->dev); |
516 | int has_irq = max732x_features[id->driver_data] >> 32; | 516 | int has_irq = max732x_features[id->driver_data] >> 32; |
517 | 517 | ||
518 | if (pdata->irq_base && has_irq != INT_NONE) | 518 | if (pdata->irq_base && has_irq != INT_NONE) |
@@ -583,7 +583,7 @@ static int max732x_probe(struct i2c_client *client, | |||
583 | uint16_t addr_a, addr_b; | 583 | uint16_t addr_a, addr_b; |
584 | int ret, nr_port; | 584 | int ret, nr_port; |
585 | 585 | ||
586 | pdata = client->dev.platform_data; | 586 | pdata = dev_get_platdata(&client->dev); |
587 | if (pdata == NULL) { | 587 | if (pdata == NULL) { |
588 | dev_dbg(&client->dev, "no platform data\n"); | 588 | dev_dbg(&client->dev, "no platform data\n"); |
589 | return -EINVAL; | 589 | return -EINVAL; |
@@ -653,7 +653,7 @@ out_failed: | |||
653 | 653 | ||
654 | static int max732x_remove(struct i2c_client *client) | 654 | static int max732x_remove(struct i2c_client *client) |
655 | { | 655 | { |
656 | struct max732x_platform_data *pdata = client->dev.platform_data; | 656 | struct max732x_platform_data *pdata = dev_get_platdata(&client->dev); |
657 | struct max732x_chip *chip = i2c_get_clientdata(client); | 657 | struct max732x_chip *chip = i2c_get_clientdata(client); |
658 | int ret; | 658 | int ret; |
659 | 659 | ||
diff --git a/drivers/gpio/gpio-mc33880.c b/drivers/gpio/gpio-mc33880.c index 63a7a1bfb2d9..3fd2caa4a2e0 100644 --- a/drivers/gpio/gpio-mc33880.c +++ b/drivers/gpio/gpio-mc33880.c | |||
@@ -86,7 +86,7 @@ static int mc33880_probe(struct spi_device *spi) | |||
86 | struct mc33880_platform_data *pdata; | 86 | struct mc33880_platform_data *pdata; |
87 | int ret; | 87 | int ret; |
88 | 88 | ||
89 | pdata = spi->dev.platform_data; | 89 | pdata = dev_get_platdata(&spi->dev); |
90 | if (!pdata || !pdata->base) { | 90 | if (!pdata || !pdata->base) { |
91 | dev_dbg(&spi->dev, "incorrect or missing platform data\n"); | 91 | dev_dbg(&spi->dev, "incorrect or missing platform data\n"); |
92 | return -EINVAL; | 92 | return -EINVAL; |
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c index 6a4470b84488..2deb0c5e54a4 100644 --- a/drivers/gpio/gpio-mcp23s08.c +++ b/drivers/gpio/gpio-mcp23s08.c | |||
@@ -483,10 +483,21 @@ fail: | |||
483 | #ifdef CONFIG_SPI_MASTER | 483 | #ifdef CONFIG_SPI_MASTER |
484 | static struct of_device_id mcp23s08_spi_of_match[] = { | 484 | static struct of_device_id mcp23s08_spi_of_match[] = { |
485 | { | 485 | { |
486 | .compatible = "mcp,mcp23s08", .data = (void *) MCP_TYPE_S08, | 486 | .compatible = "microchip,mcp23s08", |
487 | .data = (void *) MCP_TYPE_S08, | ||
487 | }, | 488 | }, |
488 | { | 489 | { |
489 | .compatible = "mcp,mcp23s17", .data = (void *) MCP_TYPE_S17, | 490 | .compatible = "microchip,mcp23s17", |
491 | .data = (void *) MCP_TYPE_S17, | ||
492 | }, | ||
493 | /* NOTE: The use of the mcp prefix is deprecated and will be removed. */ | ||
494 | { | ||
495 | .compatible = "mcp,mcp23s08", | ||
496 | .data = (void *) MCP_TYPE_S08, | ||
497 | }, | ||
498 | { | ||
499 | .compatible = "mcp,mcp23s17", | ||
500 | .data = (void *) MCP_TYPE_S17, | ||
490 | }, | 501 | }, |
491 | { }, | 502 | { }, |
492 | }; | 503 | }; |
@@ -496,10 +507,21 @@ MODULE_DEVICE_TABLE(of, mcp23s08_spi_of_match); | |||
496 | #if IS_ENABLED(CONFIG_I2C) | 507 | #if IS_ENABLED(CONFIG_I2C) |
497 | static struct of_device_id mcp23s08_i2c_of_match[] = { | 508 | static struct of_device_id mcp23s08_i2c_of_match[] = { |
498 | { | 509 | { |
499 | .compatible = "mcp,mcp23008", .data = (void *) MCP_TYPE_008, | 510 | .compatible = "microchip,mcp23008", |
511 | .data = (void *) MCP_TYPE_008, | ||
512 | }, | ||
513 | { | ||
514 | .compatible = "microchip,mcp23017", | ||
515 | .data = (void *) MCP_TYPE_017, | ||
516 | }, | ||
517 | /* NOTE: The use of the mcp prefix is deprecated and will be removed. */ | ||
518 | { | ||
519 | .compatible = "mcp,mcp23008", | ||
520 | .data = (void *) MCP_TYPE_008, | ||
500 | }, | 521 | }, |
501 | { | 522 | { |
502 | .compatible = "mcp,mcp23017", .data = (void *) MCP_TYPE_017, | 523 | .compatible = "mcp,mcp23017", |
524 | .data = (void *) MCP_TYPE_017, | ||
503 | }, | 525 | }, |
504 | { }, | 526 | { }, |
505 | }; | 527 | }; |
@@ -520,14 +542,13 @@ static int mcp230xx_probe(struct i2c_client *client, | |||
520 | 542 | ||
521 | match = of_match_device(of_match_ptr(mcp23s08_i2c_of_match), | 543 | match = of_match_device(of_match_ptr(mcp23s08_i2c_of_match), |
522 | &client->dev); | 544 | &client->dev); |
523 | if (match) { | 545 | pdata = dev_get_platdata(&client->dev); |
546 | if (match || !pdata) { | ||
524 | base = -1; | 547 | base = -1; |
525 | pullups = 0; | 548 | pullups = 0; |
526 | } else { | 549 | } else { |
527 | pdata = client->dev.platform_data; | 550 | if (!gpio_is_valid(pdata->base)) { |
528 | if (!pdata || !gpio_is_valid(pdata->base)) { | 551 | dev_dbg(&client->dev, "invalid platform data\n"); |
529 | dev_dbg(&client->dev, | ||
530 | "invalid or missing platform data\n"); | ||
531 | return -EINVAL; | 552 | return -EINVAL; |
532 | } | 553 | } |
533 | base = pdata->base; | 554 | base = pdata->base; |
@@ -621,10 +642,15 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
621 | if (match) { | 642 | if (match) { |
622 | type = (int)match->data; | 643 | type = (int)match->data; |
623 | status = of_property_read_u32(spi->dev.of_node, | 644 | status = of_property_read_u32(spi->dev.of_node, |
624 | "mcp,spi-present-mask", &spi_present_mask); | 645 | "microchip,spi-present-mask", &spi_present_mask); |
625 | if (status) { | 646 | if (status) { |
626 | dev_err(&spi->dev, "DT has no spi-present-mask\n"); | 647 | status = of_property_read_u32(spi->dev.of_node, |
627 | return -ENODEV; | 648 | "mcp,spi-present-mask", &spi_present_mask); |
649 | if (status) { | ||
650 | dev_err(&spi->dev, | ||
651 | "DT has no spi-present-mask\n"); | ||
652 | return -ENODEV; | ||
653 | } | ||
628 | } | 654 | } |
629 | if ((spi_present_mask <= 0) || (spi_present_mask >= 256)) { | 655 | if ((spi_present_mask <= 0) || (spi_present_mask >= 256)) { |
630 | dev_err(&spi->dev, "invalid spi-present-mask\n"); | 656 | dev_err(&spi->dev, "invalid spi-present-mask\n"); |
@@ -635,7 +661,7 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
635 | pullups[addr] = 0; | 661 | pullups[addr] = 0; |
636 | } else { | 662 | } else { |
637 | type = spi_get_device_id(spi)->driver_data; | 663 | type = spi_get_device_id(spi)->driver_data; |
638 | pdata = spi->dev.platform_data; | 664 | pdata = dev_get_platdata(&spi->dev); |
639 | if (!pdata || !gpio_is_valid(pdata->base)) { | 665 | if (!pdata || !gpio_is_valid(pdata->base)) { |
640 | dev_dbg(&spi->dev, | 666 | dev_dbg(&spi->dev, |
641 | "invalid or missing platform data\n"); | 667 | "invalid or missing platform data\n"); |
diff --git a/drivers/gpio/gpio-msic.c b/drivers/gpio/gpio-msic.c index 27ea7b9257ff..d75eaa3a1dcc 100644 --- a/drivers/gpio/gpio-msic.c +++ b/drivers/gpio/gpio-msic.c | |||
@@ -259,7 +259,7 @@ static void msic_gpio_irq_handler(unsigned irq, struct irq_desc *desc) | |||
259 | static int platform_msic_gpio_probe(struct platform_device *pdev) | 259 | static int platform_msic_gpio_probe(struct platform_device *pdev) |
260 | { | 260 | { |
261 | struct device *dev = &pdev->dev; | 261 | struct device *dev = &pdev->dev; |
262 | struct intel_msic_gpio_pdata *pdata = dev->platform_data; | 262 | struct intel_msic_gpio_pdata *pdata = dev_get_platdata(dev); |
263 | struct msic_gpio *mg; | 263 | struct msic_gpio *mg; |
264 | int irq = platform_get_irq(pdev, 0); | 264 | int irq = platform_get_irq(pdev, 0); |
265 | int retval; | 265 | int retval; |
diff --git a/drivers/gpio/gpio-msm-v2.c b/drivers/gpio/gpio-msm-v2.c index c2fa77086eb5..f7a0cc4da950 100644 --- a/drivers/gpio/gpio-msm-v2.c +++ b/drivers/gpio/gpio-msm-v2.c | |||
@@ -106,7 +106,7 @@ struct msm_gpio_dev { | |||
106 | void __iomem *msm_tlmm_base; | 106 | void __iomem *msm_tlmm_base; |
107 | }; | 107 | }; |
108 | 108 | ||
109 | struct msm_gpio_dev msm_gpio; | 109 | static struct msm_gpio_dev msm_gpio; |
110 | 110 | ||
111 | #define GPIO_INTR_CFG_SU(gpio) (msm_gpio.msm_tlmm_base + 0x0400 + \ | 111 | #define GPIO_INTR_CFG_SU(gpio) (msm_gpio.msm_tlmm_base + 0x0400 + \ |
112 | (0x04 * (gpio))) | 112 | (0x04 * (gpio))) |
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index 80ad35e2a8cd..3c3321f94053 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c | |||
@@ -566,12 +566,6 @@ static int mvebu_gpio_probe(struct platform_device *pdev) | |||
566 | else | 566 | else |
567 | soc_variant = MVEBU_GPIO_SOC_VARIANT_ORION; | 567 | soc_variant = MVEBU_GPIO_SOC_VARIANT_ORION; |
568 | 568 | ||
569 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
570 | if (!res) { | ||
571 | dev_err(&pdev->dev, "Cannot get memory resource\n"); | ||
572 | return -ENODEV; | ||
573 | } | ||
574 | |||
575 | mvchip = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_gpio_chip), GFP_KERNEL); | 569 | mvchip = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_gpio_chip), GFP_KERNEL); |
576 | if (!mvchip) { | 570 | if (!mvchip) { |
577 | dev_err(&pdev->dev, "Cannot allocate memory\n"); | 571 | dev_err(&pdev->dev, "Cannot allocate memory\n"); |
@@ -611,6 +605,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) | |||
611 | mvchip->chip.dbg_show = mvebu_gpio_dbg_show; | 605 | mvchip->chip.dbg_show = mvebu_gpio_dbg_show; |
612 | 606 | ||
613 | spin_lock_init(&mvchip->lock); | 607 | spin_lock_init(&mvchip->lock); |
608 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
614 | mvchip->membase = devm_ioremap_resource(&pdev->dev, res); | 609 | mvchip->membase = devm_ioremap_resource(&pdev->dev, res); |
615 | if (IS_ERR(mvchip->membase)) | 610 | if (IS_ERR(mvchip->membase)) |
616 | return PTR_ERR(mvchip->membase); | 611 | return PTR_ERR(mvchip->membase); |
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 7176743915d3..3307f6db3a92 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c | |||
@@ -19,6 +19,7 @@ | |||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/err.h> | ||
22 | #include <linux/init.h> | 23 | #include <linux/init.h> |
23 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
24 | #include <linux/io.h> | 25 | #include <linux/io.h> |
@@ -291,6 +292,9 @@ static void mx2_gpio_irq_handler(u32 irq, struct irq_desc *desc) | |||
291 | { | 292 | { |
292 | u32 irq_msk, irq_stat; | 293 | u32 irq_msk, irq_stat; |
293 | struct mxc_gpio_port *port; | 294 | struct mxc_gpio_port *port; |
295 | struct irq_chip *chip = irq_get_chip(irq); | ||
296 | |||
297 | chained_irq_enter(chip, desc); | ||
294 | 298 | ||
295 | /* walk through all interrupt status registers */ | 299 | /* walk through all interrupt status registers */ |
296 | list_for_each_entry(port, &mxc_gpio_ports, node) { | 300 | list_for_each_entry(port, &mxc_gpio_ports, node) { |
@@ -302,6 +306,7 @@ static void mx2_gpio_irq_handler(u32 irq, struct irq_desc *desc) | |||
302 | if (irq_stat) | 306 | if (irq_stat) |
303 | mxc_gpio_irq_handler(port, irq_stat); | 307 | mxc_gpio_irq_handler(port, irq_stat); |
304 | } | 308 | } |
309 | chained_irq_exit(chip, desc); | ||
305 | } | 310 | } |
306 | 311 | ||
307 | /* | 312 | /* |
@@ -405,34 +410,19 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
405 | 410 | ||
406 | mxc_gpio_get_hw(pdev); | 411 | mxc_gpio_get_hw(pdev); |
407 | 412 | ||
408 | port = kzalloc(sizeof(struct mxc_gpio_port), GFP_KERNEL); | 413 | port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL); |
409 | if (!port) | 414 | if (!port) |
410 | return -ENOMEM; | 415 | return -ENOMEM; |
411 | 416 | ||
412 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 417 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
413 | if (!iores) { | 418 | port->base = devm_ioremap_resource(&pdev->dev, iores); |
414 | err = -ENODEV; | 419 | if (IS_ERR(port->base)) |
415 | goto out_kfree; | 420 | return PTR_ERR(port->base); |
416 | } | ||
417 | |||
418 | if (!request_mem_region(iores->start, resource_size(iores), | ||
419 | pdev->name)) { | ||
420 | err = -EBUSY; | ||
421 | goto out_kfree; | ||
422 | } | ||
423 | |||
424 | port->base = ioremap(iores->start, resource_size(iores)); | ||
425 | if (!port->base) { | ||
426 | err = -ENOMEM; | ||
427 | goto out_release_mem; | ||
428 | } | ||
429 | 421 | ||
430 | port->irq_high = platform_get_irq(pdev, 1); | 422 | port->irq_high = platform_get_irq(pdev, 1); |
431 | port->irq = platform_get_irq(pdev, 0); | 423 | port->irq = platform_get_irq(pdev, 0); |
432 | if (port->irq < 0) { | 424 | if (port->irq < 0) |
433 | err = -EINVAL; | 425 | return -EINVAL; |
434 | goto out_iounmap; | ||
435 | } | ||
436 | 426 | ||
437 | /* disable the interrupt and clear the status */ | 427 | /* disable the interrupt and clear the status */ |
438 | writel(0, port->base + GPIO_IMR); | 428 | writel(0, port->base + GPIO_IMR); |
@@ -462,7 +452,7 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
462 | port->base + GPIO_DR, NULL, | 452 | port->base + GPIO_DR, NULL, |
463 | port->base + GPIO_GDIR, NULL, 0); | 453 | port->base + GPIO_GDIR, NULL, 0); |
464 | if (err) | 454 | if (err) |
465 | goto out_iounmap; | 455 | goto out_bgio; |
466 | 456 | ||
467 | port->bgc.gc.to_irq = mxc_gpio_to_irq; | 457 | port->bgc.gc.to_irq = mxc_gpio_to_irq; |
468 | port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 : | 458 | port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 : |
@@ -498,12 +488,7 @@ out_gpiochip_remove: | |||
498 | WARN_ON(gpiochip_remove(&port->bgc.gc) < 0); | 488 | WARN_ON(gpiochip_remove(&port->bgc.gc) < 0); |
499 | out_bgpio_remove: | 489 | out_bgpio_remove: |
500 | bgpio_remove(&port->bgc); | 490 | bgpio_remove(&port->bgc); |
501 | out_iounmap: | 491 | out_bgio: |
502 | iounmap(port->base); | ||
503 | out_release_mem: | ||
504 | release_mem_region(iores->start, resource_size(iores)); | ||
505 | out_kfree: | ||
506 | kfree(port); | ||
507 | dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err); | 492 | dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err); |
508 | return err; | 493 | return err; |
509 | } | 494 | } |
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index dfeb3a3a8f20..0ff43552d472 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -1030,7 +1030,7 @@ omap_mpuio_alloc_gc(struct gpio_bank *bank, unsigned int irq_start, | |||
1030 | ct->chip.irq_set_type = gpio_irq_type; | 1030 | ct->chip.irq_set_type = gpio_irq_type; |
1031 | 1031 | ||
1032 | if (bank->regs->wkup_en) | 1032 | if (bank->regs->wkup_en) |
1033 | ct->chip.irq_set_wake = gpio_wake_enable, | 1033 | ct->chip.irq_set_wake = gpio_wake_enable; |
1034 | 1034 | ||
1035 | ct->regs.mask = OMAP_MPUIO_GPIO_INT / bank->stride; | 1035 | ct->regs.mask = OMAP_MPUIO_GPIO_INT / bank->stride; |
1036 | irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE, | 1036 | irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE, |
@@ -1100,7 +1100,7 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1100 | 1100 | ||
1101 | match = of_match_device(of_match_ptr(omap_gpio_match), dev); | 1101 | match = of_match_device(of_match_ptr(omap_gpio_match), dev); |
1102 | 1102 | ||
1103 | pdata = match ? match->data : dev->platform_data; | 1103 | pdata = match ? match->data : dev_get_platdata(dev); |
1104 | if (!pdata) | 1104 | if (!pdata) |
1105 | return -EINVAL; | 1105 | return -EINVAL; |
1106 | 1106 | ||
diff --git a/drivers/gpio/gpio-palmas.c b/drivers/gpio/gpio-palmas.c index e3a4e56f5a42..8588af0f7661 100644 --- a/drivers/gpio/gpio-palmas.c +++ b/drivers/gpio/gpio-palmas.c | |||
@@ -43,9 +43,22 @@ static int palmas_gpio_get(struct gpio_chip *gc, unsigned offset) | |||
43 | unsigned int val; | 43 | unsigned int val; |
44 | int ret; | 44 | int ret; |
45 | 45 | ||
46 | ret = palmas_read(palmas, PALMAS_GPIO_BASE, PALMAS_GPIO_DATA_IN, &val); | 46 | ret = palmas_read(palmas, PALMAS_GPIO_BASE, PALMAS_GPIO_DATA_DIR, &val); |
47 | if (ret < 0) { | 47 | if (ret < 0) { |
48 | dev_err(gc->dev, "GPIO_DATA_IN read failed, err = %d\n", ret); | 48 | dev_err(gc->dev, "GPIO_DATA_DIR read failed, err = %d\n", ret); |
49 | return ret; | ||
50 | } | ||
51 | |||
52 | if (val & (1 << offset)) { | ||
53 | ret = palmas_read(palmas, PALMAS_GPIO_BASE, | ||
54 | PALMAS_GPIO_DATA_OUT, &val); | ||
55 | } else { | ||
56 | ret = palmas_read(palmas, PALMAS_GPIO_BASE, | ||
57 | PALMAS_GPIO_DATA_IN, &val); | ||
58 | } | ||
59 | if (ret < 0) { | ||
60 | dev_err(gc->dev, "GPIO_DATA_IN/OUT read failed, err = %d\n", | ||
61 | ret); | ||
49 | return ret; | 62 | return ret; |
50 | } | 63 | } |
51 | return !!(val & BIT(offset)); | 64 | return !!(val & BIT(offset)); |
@@ -134,7 +147,7 @@ static int palmas_gpio_probe(struct platform_device *pdev) | |||
134 | palmas_gpio->gpio_chip.get = palmas_gpio_get; | 147 | palmas_gpio->gpio_chip.get = palmas_gpio_get; |
135 | palmas_gpio->gpio_chip.dev = &pdev->dev; | 148 | palmas_gpio->gpio_chip.dev = &pdev->dev; |
136 | #ifdef CONFIG_OF_GPIO | 149 | #ifdef CONFIG_OF_GPIO |
137 | palmas_gpio->gpio_chip.of_node = palmas->dev->of_node; | 150 | palmas_gpio->gpio_chip.of_node = pdev->dev.of_node; |
138 | #endif | 151 | #endif |
139 | palmas_pdata = dev_get_platdata(palmas->dev); | 152 | palmas_pdata = dev_get_platdata(palmas->dev); |
140 | if (palmas_pdata && palmas_pdata->gpio_base) | 153 | if (palmas_pdata && palmas_pdata->gpio_base) |
@@ -159,9 +172,19 @@ static int palmas_gpio_remove(struct platform_device *pdev) | |||
159 | return gpiochip_remove(&palmas_gpio->gpio_chip); | 172 | return gpiochip_remove(&palmas_gpio->gpio_chip); |
160 | } | 173 | } |
161 | 174 | ||
175 | static struct of_device_id of_palmas_gpio_match[] = { | ||
176 | { .compatible = "ti,palmas-gpio"}, | ||
177 | { .compatible = "ti,tps65913-gpio"}, | ||
178 | { .compatible = "ti,tps65914-gpio"}, | ||
179 | { .compatible = "ti,tps80036-gpio"}, | ||
180 | { }, | ||
181 | }; | ||
182 | MODULE_DEVICE_TABLE(of, of_palmas_gpio_match); | ||
183 | |||
162 | static struct platform_driver palmas_gpio_driver = { | 184 | static struct platform_driver palmas_gpio_driver = { |
163 | .driver.name = "palmas-gpio", | 185 | .driver.name = "palmas-gpio", |
164 | .driver.owner = THIS_MODULE, | 186 | .driver.owner = THIS_MODULE, |
187 | .driver.of_match_table = of_palmas_gpio_match, | ||
165 | .probe = palmas_gpio_probe, | 188 | .probe = palmas_gpio_probe, |
166 | .remove = palmas_gpio_remove, | 189 | .remove = palmas_gpio_remove, |
167 | }; | 190 | }; |
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 8804aec2950f..cdd1aa12b895 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c | |||
@@ -308,7 +308,7 @@ static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off) | |||
308 | return 0; | 308 | return 0; |
309 | } | 309 | } |
310 | 310 | ||
311 | return (reg_val & (1u << off)) ? 1 : 0; | 311 | return (reg_val & (1u << (off % BANK_SZ))) ? 1 : 0; |
312 | } | 312 | } |
313 | 313 | ||
314 | static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val) | 314 | static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val) |
@@ -731,7 +731,7 @@ static int pca953x_probe(struct i2c_client *client, | |||
731 | if (chip == NULL) | 731 | if (chip == NULL) |
732 | return -ENOMEM; | 732 | return -ENOMEM; |
733 | 733 | ||
734 | pdata = client->dev.platform_data; | 734 | pdata = dev_get_platdata(&client->dev); |
735 | if (pdata) { | 735 | if (pdata) { |
736 | irq_base = pdata->irq_base; | 736 | irq_base = pdata->irq_base; |
737 | chip->gpio_start = pdata->gpio_base; | 737 | chip->gpio_start = pdata->gpio_base; |
@@ -785,7 +785,7 @@ static int pca953x_probe(struct i2c_client *client, | |||
785 | 785 | ||
786 | static int pca953x_remove(struct i2c_client *client) | 786 | static int pca953x_remove(struct i2c_client *client) |
787 | { | 787 | { |
788 | struct pca953x_platform_data *pdata = client->dev.platform_data; | 788 | struct pca953x_platform_data *pdata = dev_get_platdata(&client->dev); |
789 | struct pca953x_chip *chip = i2c_get_clientdata(client); | 789 | struct pca953x_chip *chip = i2c_get_clientdata(client); |
790 | int ret = 0; | 790 | int ret = 0; |
791 | 791 | ||
diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c index e8faf53f3875..9e61bb0719d0 100644 --- a/drivers/gpio/gpio-pcf857x.c +++ b/drivers/gpio/gpio-pcf857x.c | |||
@@ -18,15 +18,15 @@ | |||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/gpio.h> | 21 | #include <linux/gpio.h> |
24 | #include <linux/i2c.h> | 22 | #include <linux/i2c.h> |
25 | #include <linux/i2c/pcf857x.h> | 23 | #include <linux/i2c/pcf857x.h> |
26 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
27 | #include <linux/irq.h> | 25 | #include <linux/irq.h> |
28 | #include <linux/irqdomain.h> | 26 | #include <linux/irqdomain.h> |
27 | #include <linux/kernel.h> | ||
29 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/slab.h> | ||
30 | #include <linux/spinlock.h> | 30 | #include <linux/spinlock.h> |
31 | #include <linux/workqueue.h> | 31 | #include <linux/workqueue.h> |
32 | 32 | ||
@@ -223,7 +223,6 @@ static void pcf857x_irq_domain_cleanup(struct pcf857x *gpio) | |||
223 | } | 223 | } |
224 | 224 | ||
225 | static int pcf857x_irq_domain_init(struct pcf857x *gpio, | 225 | static int pcf857x_irq_domain_init(struct pcf857x *gpio, |
226 | struct pcf857x_platform_data *pdata, | ||
227 | struct i2c_client *client) | 226 | struct i2c_client *client) |
228 | { | 227 | { |
229 | int status; | 228 | int status; |
@@ -262,7 +261,7 @@ static int pcf857x_probe(struct i2c_client *client, | |||
262 | struct pcf857x *gpio; | 261 | struct pcf857x *gpio; |
263 | int status; | 262 | int status; |
264 | 263 | ||
265 | pdata = client->dev.platform_data; | 264 | pdata = dev_get_platdata(&client->dev); |
266 | if (!pdata) { | 265 | if (!pdata) { |
267 | dev_dbg(&client->dev, "no platform data\n"); | 266 | dev_dbg(&client->dev, "no platform data\n"); |
268 | } | 267 | } |
@@ -286,8 +285,8 @@ static int pcf857x_probe(struct i2c_client *client, | |||
286 | gpio->chip.ngpio = id->driver_data; | 285 | gpio->chip.ngpio = id->driver_data; |
287 | 286 | ||
288 | /* enable gpio_to_irq() if platform has settings */ | 287 | /* enable gpio_to_irq() if platform has settings */ |
289 | if (pdata && client->irq) { | 288 | if (client->irq) { |
290 | status = pcf857x_irq_domain_init(gpio, pdata, client); | 289 | status = pcf857x_irq_domain_init(gpio, client); |
291 | if (status < 0) { | 290 | if (status < 0) { |
292 | dev_err(&client->dev, "irq_domain init failed\n"); | 291 | dev_err(&client->dev, "irq_domain init failed\n"); |
293 | goto fail; | 292 | goto fail; |
@@ -388,7 +387,7 @@ fail: | |||
388 | dev_dbg(&client->dev, "probe error %d for '%s'\n", | 387 | dev_dbg(&client->dev, "probe error %d for '%s'\n", |
389 | status, client->name); | 388 | status, client->name); |
390 | 389 | ||
391 | if (pdata && client->irq) | 390 | if (client->irq) |
392 | pcf857x_irq_domain_cleanup(gpio); | 391 | pcf857x_irq_domain_cleanup(gpio); |
393 | 392 | ||
394 | return status; | 393 | return status; |
@@ -396,7 +395,7 @@ fail: | |||
396 | 395 | ||
397 | static int pcf857x_remove(struct i2c_client *client) | 396 | static int pcf857x_remove(struct i2c_client *client) |
398 | { | 397 | { |
399 | struct pcf857x_platform_data *pdata = client->dev.platform_data; | 398 | struct pcf857x_platform_data *pdata = dev_get_platdata(&client->dev); |
400 | struct pcf857x *gpio = i2c_get_clientdata(client); | 399 | struct pcf857x *gpio = i2c_get_clientdata(client); |
401 | int status = 0; | 400 | int status = 0; |
402 | 401 | ||
@@ -411,7 +410,7 @@ static int pcf857x_remove(struct i2c_client *client) | |||
411 | } | 410 | } |
412 | } | 411 | } |
413 | 412 | ||
414 | if (pdata && client->irq) | 413 | if (client->irq) |
415 | pcf857x_irq_domain_cleanup(gpio); | 414 | pcf857x_irq_domain_cleanup(gpio); |
416 | 415 | ||
417 | status = gpiochip_remove(&gpio->chip); | 416 | status = gpiochip_remove(&gpio->chip); |
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 6a4bd0dae0ce..4274e2e70ef8 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
@@ -259,7 +259,7 @@ static const struct irq_domain_ops pl061_domain_ops = { | |||
259 | static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | 259 | static int pl061_probe(struct amba_device *adev, const struct amba_id *id) |
260 | { | 260 | { |
261 | struct device *dev = &adev->dev; | 261 | struct device *dev = &adev->dev; |
262 | struct pl061_platform_data *pdata = dev->platform_data; | 262 | struct pl061_platform_data *pdata = dev_get_platdata(dev); |
263 | struct pl061_gpio *chip; | 263 | struct pl061_gpio *chip; |
264 | int ret, irq, i, irq_base; | 264 | int ret, irq, i, irq_base; |
265 | 265 | ||
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index df2199dd1499..cc13d1b74fad 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c | |||
@@ -524,8 +524,8 @@ const struct irq_domain_ops pxa_irq_domain_ops = { | |||
524 | 524 | ||
525 | static int pxa_gpio_probe_dt(struct platform_device *pdev) | 525 | static int pxa_gpio_probe_dt(struct platform_device *pdev) |
526 | { | 526 | { |
527 | int ret, nr_gpios; | 527 | int ret = 0, nr_gpios; |
528 | struct device_node *prev, *next, *np = pdev->dev.of_node; | 528 | struct device_node *np = pdev->dev.of_node; |
529 | const struct of_device_id *of_id = | 529 | const struct of_device_id *of_id = |
530 | of_match_device(pxa_gpio_dt_ids, &pdev->dev); | 530 | of_match_device(pxa_gpio_dt_ids, &pdev->dev); |
531 | const struct pxa_gpio_id *gpio_id; | 531 | const struct pxa_gpio_id *gpio_id; |
@@ -537,20 +537,13 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) | |||
537 | gpio_id = of_id->data; | 537 | gpio_id = of_id->data; |
538 | gpio_type = gpio_id->type; | 538 | gpio_type = gpio_id->type; |
539 | 539 | ||
540 | next = of_get_next_child(np, NULL); | ||
541 | prev = next; | ||
542 | if (!next) { | ||
543 | dev_err(&pdev->dev, "Failed to find child gpio node\n"); | ||
544 | ret = -EINVAL; | ||
545 | goto err; | ||
546 | } | ||
547 | of_node_put(prev); | ||
548 | nr_gpios = gpio_id->gpio_nums; | 540 | nr_gpios = gpio_id->gpio_nums; |
549 | pxa_last_gpio = nr_gpios - 1; | 541 | pxa_last_gpio = nr_gpios - 1; |
550 | 542 | ||
551 | irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0); | 543 | irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0); |
552 | if (irq_base < 0) { | 544 | if (irq_base < 0) { |
553 | dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); | 545 | dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); |
546 | ret = irq_base; | ||
554 | goto err; | 547 | goto err; |
555 | } | 548 | } |
556 | domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0, | 549 | domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0, |
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index e8198dd68615..e3745eb07570 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c | |||
@@ -285,7 +285,7 @@ static struct irq_domain_ops gpio_rcar_irq_domain_ops = { | |||
285 | 285 | ||
286 | static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p) | 286 | static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p) |
287 | { | 287 | { |
288 | struct gpio_rcar_config *pdata = p->pdev->dev.platform_data; | 288 | struct gpio_rcar_config *pdata = dev_get_platdata(&p->pdev->dev); |
289 | struct device_node *np = p->pdev->dev.of_node; | 289 | struct device_node *np = p->pdev->dev.of_node; |
290 | struct of_phandle_args args; | 290 | struct of_phandle_args args; |
291 | int ret; | 291 | int ret; |
diff --git a/drivers/gpio/gpio-rdc321x.c b/drivers/gpio/gpio-rdc321x.c index 368c3c00fca5..88577c3272a5 100644 --- a/drivers/gpio/gpio-rdc321x.c +++ b/drivers/gpio/gpio-rdc321x.c | |||
@@ -135,7 +135,7 @@ static int rdc321x_gpio_probe(struct platform_device *pdev) | |||
135 | struct rdc321x_gpio *rdc321x_gpio_dev; | 135 | struct rdc321x_gpio *rdc321x_gpio_dev; |
136 | struct rdc321x_gpio_pdata *pdata; | 136 | struct rdc321x_gpio_pdata *pdata; |
137 | 137 | ||
138 | pdata = pdev->dev.platform_data; | 138 | pdata = dev_get_platdata(&pdev->dev); |
139 | if (!pdata) { | 139 | if (!pdata) { |
140 | dev_err(&pdev->dev, "no platform data supplied\n"); | 140 | dev_err(&pdev->dev, "no platform data supplied\n"); |
141 | return -ENODEV; | 141 | return -ENODEV; |
diff --git a/drivers/gpio/gpio-samsung.c b/drivers/gpio/gpio-samsung.c index a1392f47bbda..358a21c2d811 100644 --- a/drivers/gpio/gpio-samsung.c +++ b/drivers/gpio/gpio-samsung.c | |||
@@ -161,28 +161,6 @@ int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip, | |||
161 | return s3c24xx_gpio_setpull_1(chip, off, pull, S3C_GPIO_PULL_DOWN); | 161 | return s3c24xx_gpio_setpull_1(chip, off, pull, S3C_GPIO_PULL_DOWN); |
162 | } | 162 | } |
163 | 163 | ||
164 | static int exynos_gpio_setpull(struct samsung_gpio_chip *chip, | ||
165 | unsigned int off, samsung_gpio_pull_t pull) | ||
166 | { | ||
167 | if (pull == S3C_GPIO_PULL_UP) | ||
168 | pull = 3; | ||
169 | |||
170 | return samsung_gpio_setpull_updown(chip, off, pull); | ||
171 | } | ||
172 | |||
173 | static samsung_gpio_pull_t exynos_gpio_getpull(struct samsung_gpio_chip *chip, | ||
174 | unsigned int off) | ||
175 | { | ||
176 | samsung_gpio_pull_t pull; | ||
177 | |||
178 | pull = samsung_gpio_getpull_updown(chip, off); | ||
179 | |||
180 | if (pull == 3) | ||
181 | pull = S3C_GPIO_PULL_UP; | ||
182 | |||
183 | return pull; | ||
184 | } | ||
185 | |||
186 | /* | 164 | /* |
187 | * samsung_gpio_setcfg_2bit - Samsung 2bit style GPIO configuration. | 165 | * samsung_gpio_setcfg_2bit - Samsung 2bit style GPIO configuration. |
188 | * @chip: The gpio chip that is being configured. | 166 | * @chip: The gpio chip that is being configured. |
@@ -444,15 +422,6 @@ static struct samsung_gpio_cfg s3c24xx_gpiocfg_banka = { | |||
444 | }; | 422 | }; |
445 | #endif | 423 | #endif |
446 | 424 | ||
447 | #if defined(CONFIG_ARCH_EXYNOS4) || defined(CONFIG_SOC_EXYNOS5250) | ||
448 | static struct samsung_gpio_cfg exynos_gpio_cfg = { | ||
449 | .set_pull = exynos_gpio_setpull, | ||
450 | .get_pull = exynos_gpio_getpull, | ||
451 | .set_config = samsung_gpio_setcfg_4bit, | ||
452 | .get_config = samsung_gpio_getcfg_4bit, | ||
453 | }; | ||
454 | #endif | ||
455 | |||
456 | #if defined(CONFIG_CPU_S5P6440) || defined(CONFIG_CPU_S5P6450) | 425 | #if defined(CONFIG_CPU_S5P6440) || defined(CONFIG_CPU_S5P6450) |
457 | static struct samsung_gpio_cfg s5p64x0_gpio_cfg_rbank = { | 426 | static struct samsung_gpio_cfg s5p64x0_gpio_cfg_rbank = { |
458 | .cfg_eint = 0x3, | 427 | .cfg_eint = 0x3, |
@@ -495,15 +464,6 @@ static struct samsung_gpio_cfg samsung_gpio_cfgs[] = { | |||
495 | .set_config = samsung_gpio_setcfg_2bit, | 464 | .set_config = samsung_gpio_setcfg_2bit, |
496 | .get_config = samsung_gpio_getcfg_2bit, | 465 | .get_config = samsung_gpio_getcfg_2bit, |
497 | }, | 466 | }, |
498 | [8] = { | ||
499 | .set_pull = exynos_gpio_setpull, | ||
500 | .get_pull = exynos_gpio_getpull, | ||
501 | }, | ||
502 | [9] = { | ||
503 | .cfg_eint = 0x3, | ||
504 | .set_pull = exynos_gpio_setpull, | ||
505 | .get_pull = exynos_gpio_getpull, | ||
506 | } | ||
507 | }; | 467 | }; |
508 | 468 | ||
509 | /* | 469 | /* |
@@ -2115,833 +2075,6 @@ static struct samsung_gpio_chip s5pv210_gpios_4bit[] = { | |||
2115 | #endif | 2075 | #endif |
2116 | }; | 2076 | }; |
2117 | 2077 | ||
2118 | /* | ||
2119 | * Followings are the gpio banks in EXYNOS SoCs | ||
2120 | * | ||
2121 | * The 'config' member when left to NULL, is initialized to the default | ||
2122 | * structure exynos_gpio_cfg in the init function below. | ||
2123 | * | ||
2124 | * The 'base' member is also initialized in the init function below. | ||
2125 | * Note: The initialization of 'base' member of samsung_gpio_chip structure | ||
2126 | * uses the above macro and depends on the banks being listed in order here. | ||
2127 | */ | ||
2128 | |||
2129 | #ifdef CONFIG_ARCH_EXYNOS4 | ||
2130 | static struct samsung_gpio_chip exynos4_gpios_1[] = { | ||
2131 | { | ||
2132 | .chip = { | ||
2133 | .base = EXYNOS4_GPA0(0), | ||
2134 | .ngpio = EXYNOS4_GPIO_A0_NR, | ||
2135 | .label = "GPA0", | ||
2136 | }, | ||
2137 | }, { | ||
2138 | .chip = { | ||
2139 | .base = EXYNOS4_GPA1(0), | ||
2140 | .ngpio = EXYNOS4_GPIO_A1_NR, | ||
2141 | .label = "GPA1", | ||
2142 | }, | ||
2143 | }, { | ||
2144 | .chip = { | ||
2145 | .base = EXYNOS4_GPB(0), | ||
2146 | .ngpio = EXYNOS4_GPIO_B_NR, | ||
2147 | .label = "GPB", | ||
2148 | }, | ||
2149 | }, { | ||
2150 | .chip = { | ||
2151 | .base = EXYNOS4_GPC0(0), | ||
2152 | .ngpio = EXYNOS4_GPIO_C0_NR, | ||
2153 | .label = "GPC0", | ||
2154 | }, | ||
2155 | }, { | ||
2156 | .chip = { | ||
2157 | .base = EXYNOS4_GPC1(0), | ||
2158 | .ngpio = EXYNOS4_GPIO_C1_NR, | ||
2159 | .label = "GPC1", | ||
2160 | }, | ||
2161 | }, { | ||
2162 | .chip = { | ||
2163 | .base = EXYNOS4_GPD0(0), | ||
2164 | .ngpio = EXYNOS4_GPIO_D0_NR, | ||
2165 | .label = "GPD0", | ||
2166 | }, | ||
2167 | }, { | ||
2168 | .chip = { | ||
2169 | .base = EXYNOS4_GPD1(0), | ||
2170 | .ngpio = EXYNOS4_GPIO_D1_NR, | ||
2171 | .label = "GPD1", | ||
2172 | }, | ||
2173 | }, { | ||
2174 | .chip = { | ||
2175 | .base = EXYNOS4_GPE0(0), | ||
2176 | .ngpio = EXYNOS4_GPIO_E0_NR, | ||
2177 | .label = "GPE0", | ||
2178 | }, | ||
2179 | }, { | ||
2180 | .chip = { | ||
2181 | .base = EXYNOS4_GPE1(0), | ||
2182 | .ngpio = EXYNOS4_GPIO_E1_NR, | ||
2183 | .label = "GPE1", | ||
2184 | }, | ||
2185 | }, { | ||
2186 | .chip = { | ||
2187 | .base = EXYNOS4_GPE2(0), | ||
2188 | .ngpio = EXYNOS4_GPIO_E2_NR, | ||
2189 | .label = "GPE2", | ||
2190 | }, | ||
2191 | }, { | ||
2192 | .chip = { | ||
2193 | .base = EXYNOS4_GPE3(0), | ||
2194 | .ngpio = EXYNOS4_GPIO_E3_NR, | ||
2195 | .label = "GPE3", | ||
2196 | }, | ||
2197 | }, { | ||
2198 | .chip = { | ||
2199 | .base = EXYNOS4_GPE4(0), | ||
2200 | .ngpio = EXYNOS4_GPIO_E4_NR, | ||
2201 | .label = "GPE4", | ||
2202 | }, | ||
2203 | }, { | ||
2204 | .chip = { | ||
2205 | .base = EXYNOS4_GPF0(0), | ||
2206 | .ngpio = EXYNOS4_GPIO_F0_NR, | ||
2207 | .label = "GPF0", | ||
2208 | }, | ||
2209 | }, { | ||
2210 | .chip = { | ||
2211 | .base = EXYNOS4_GPF1(0), | ||
2212 | .ngpio = EXYNOS4_GPIO_F1_NR, | ||
2213 | .label = "GPF1", | ||
2214 | }, | ||
2215 | }, { | ||
2216 | .chip = { | ||
2217 | .base = EXYNOS4_GPF2(0), | ||
2218 | .ngpio = EXYNOS4_GPIO_F2_NR, | ||
2219 | .label = "GPF2", | ||
2220 | }, | ||
2221 | }, { | ||
2222 | .chip = { | ||
2223 | .base = EXYNOS4_GPF3(0), | ||
2224 | .ngpio = EXYNOS4_GPIO_F3_NR, | ||
2225 | .label = "GPF3", | ||
2226 | }, | ||
2227 | }, | ||
2228 | }; | ||
2229 | #endif | ||
2230 | |||
2231 | #ifdef CONFIG_ARCH_EXYNOS4 | ||
2232 | static struct samsung_gpio_chip exynos4_gpios_2[] = { | ||
2233 | { | ||
2234 | .chip = { | ||
2235 | .base = EXYNOS4_GPJ0(0), | ||
2236 | .ngpio = EXYNOS4_GPIO_J0_NR, | ||
2237 | .label = "GPJ0", | ||
2238 | }, | ||
2239 | }, { | ||
2240 | .chip = { | ||
2241 | .base = EXYNOS4_GPJ1(0), | ||
2242 | .ngpio = EXYNOS4_GPIO_J1_NR, | ||
2243 | .label = "GPJ1", | ||
2244 | }, | ||
2245 | }, { | ||
2246 | .chip = { | ||
2247 | .base = EXYNOS4_GPK0(0), | ||
2248 | .ngpio = EXYNOS4_GPIO_K0_NR, | ||
2249 | .label = "GPK0", | ||
2250 | }, | ||
2251 | }, { | ||
2252 | .chip = { | ||
2253 | .base = EXYNOS4_GPK1(0), | ||
2254 | .ngpio = EXYNOS4_GPIO_K1_NR, | ||
2255 | .label = "GPK1", | ||
2256 | }, | ||
2257 | }, { | ||
2258 | .chip = { | ||
2259 | .base = EXYNOS4_GPK2(0), | ||
2260 | .ngpio = EXYNOS4_GPIO_K2_NR, | ||
2261 | .label = "GPK2", | ||
2262 | }, | ||
2263 | }, { | ||
2264 | .chip = { | ||
2265 | .base = EXYNOS4_GPK3(0), | ||
2266 | .ngpio = EXYNOS4_GPIO_K3_NR, | ||
2267 | .label = "GPK3", | ||
2268 | }, | ||
2269 | }, { | ||
2270 | .chip = { | ||
2271 | .base = EXYNOS4_GPL0(0), | ||
2272 | .ngpio = EXYNOS4_GPIO_L0_NR, | ||
2273 | .label = "GPL0", | ||
2274 | }, | ||
2275 | }, { | ||
2276 | .chip = { | ||
2277 | .base = EXYNOS4_GPL1(0), | ||
2278 | .ngpio = EXYNOS4_GPIO_L1_NR, | ||
2279 | .label = "GPL1", | ||
2280 | }, | ||
2281 | }, { | ||
2282 | .chip = { | ||
2283 | .base = EXYNOS4_GPL2(0), | ||
2284 | .ngpio = EXYNOS4_GPIO_L2_NR, | ||
2285 | .label = "GPL2", | ||
2286 | }, | ||
2287 | }, { | ||
2288 | .config = &samsung_gpio_cfgs[8], | ||
2289 | .chip = { | ||
2290 | .base = EXYNOS4_GPY0(0), | ||
2291 | .ngpio = EXYNOS4_GPIO_Y0_NR, | ||
2292 | .label = "GPY0", | ||
2293 | }, | ||
2294 | }, { | ||
2295 | .config = &samsung_gpio_cfgs[8], | ||
2296 | .chip = { | ||
2297 | .base = EXYNOS4_GPY1(0), | ||
2298 | .ngpio = EXYNOS4_GPIO_Y1_NR, | ||
2299 | .label = "GPY1", | ||
2300 | }, | ||
2301 | }, { | ||
2302 | .config = &samsung_gpio_cfgs[8], | ||
2303 | .chip = { | ||
2304 | .base = EXYNOS4_GPY2(0), | ||
2305 | .ngpio = EXYNOS4_GPIO_Y2_NR, | ||
2306 | .label = "GPY2", | ||
2307 | }, | ||
2308 | }, { | ||
2309 | .config = &samsung_gpio_cfgs[8], | ||
2310 | .chip = { | ||
2311 | .base = EXYNOS4_GPY3(0), | ||
2312 | .ngpio = EXYNOS4_GPIO_Y3_NR, | ||
2313 | .label = "GPY3", | ||
2314 | }, | ||
2315 | }, { | ||
2316 | .config = &samsung_gpio_cfgs[8], | ||
2317 | .chip = { | ||
2318 | .base = EXYNOS4_GPY4(0), | ||
2319 | .ngpio = EXYNOS4_GPIO_Y4_NR, | ||
2320 | .label = "GPY4", | ||
2321 | }, | ||
2322 | }, { | ||
2323 | .config = &samsung_gpio_cfgs[8], | ||
2324 | .chip = { | ||
2325 | .base = EXYNOS4_GPY5(0), | ||
2326 | .ngpio = EXYNOS4_GPIO_Y5_NR, | ||
2327 | .label = "GPY5", | ||
2328 | }, | ||
2329 | }, { | ||
2330 | .config = &samsung_gpio_cfgs[8], | ||
2331 | .chip = { | ||
2332 | .base = EXYNOS4_GPY6(0), | ||
2333 | .ngpio = EXYNOS4_GPIO_Y6_NR, | ||
2334 | .label = "GPY6", | ||
2335 | }, | ||
2336 | }, { | ||
2337 | .config = &samsung_gpio_cfgs[9], | ||
2338 | .irq_base = IRQ_EINT(0), | ||
2339 | .chip = { | ||
2340 | .base = EXYNOS4_GPX0(0), | ||
2341 | .ngpio = EXYNOS4_GPIO_X0_NR, | ||
2342 | .label = "GPX0", | ||
2343 | .to_irq = samsung_gpiolib_to_irq, | ||
2344 | }, | ||
2345 | }, { | ||
2346 | .config = &samsung_gpio_cfgs[9], | ||
2347 | .irq_base = IRQ_EINT(8), | ||
2348 | .chip = { | ||
2349 | .base = EXYNOS4_GPX1(0), | ||
2350 | .ngpio = EXYNOS4_GPIO_X1_NR, | ||
2351 | .label = "GPX1", | ||
2352 | .to_irq = samsung_gpiolib_to_irq, | ||
2353 | }, | ||
2354 | }, { | ||
2355 | .config = &samsung_gpio_cfgs[9], | ||
2356 | .irq_base = IRQ_EINT(16), | ||
2357 | .chip = { | ||
2358 | .base = EXYNOS4_GPX2(0), | ||
2359 | .ngpio = EXYNOS4_GPIO_X2_NR, | ||
2360 | .label = "GPX2", | ||
2361 | .to_irq = samsung_gpiolib_to_irq, | ||
2362 | }, | ||
2363 | }, { | ||
2364 | .config = &samsung_gpio_cfgs[9], | ||
2365 | .irq_base = IRQ_EINT(24), | ||
2366 | .chip = { | ||
2367 | .base = EXYNOS4_GPX3(0), | ||
2368 | .ngpio = EXYNOS4_GPIO_X3_NR, | ||
2369 | .label = "GPX3", | ||
2370 | .to_irq = samsung_gpiolib_to_irq, | ||
2371 | }, | ||
2372 | }, | ||
2373 | }; | ||
2374 | #endif | ||
2375 | |||
2376 | #ifdef CONFIG_ARCH_EXYNOS4 | ||
2377 | static struct samsung_gpio_chip exynos4_gpios_3[] = { | ||
2378 | { | ||
2379 | .chip = { | ||
2380 | .base = EXYNOS4_GPZ(0), | ||
2381 | .ngpio = EXYNOS4_GPIO_Z_NR, | ||
2382 | .label = "GPZ", | ||
2383 | }, | ||
2384 | }, | ||
2385 | }; | ||
2386 | #endif | ||
2387 | |||
2388 | #ifdef CONFIG_SOC_EXYNOS5250 | ||
2389 | static struct samsung_gpio_chip exynos5_gpios_1[] = { | ||
2390 | { | ||
2391 | .chip = { | ||
2392 | .base = EXYNOS5_GPA0(0), | ||
2393 | .ngpio = EXYNOS5_GPIO_A0_NR, | ||
2394 | .label = "GPA0", | ||
2395 | }, | ||
2396 | }, { | ||
2397 | .chip = { | ||
2398 | .base = EXYNOS5_GPA1(0), | ||
2399 | .ngpio = EXYNOS5_GPIO_A1_NR, | ||
2400 | .label = "GPA1", | ||
2401 | }, | ||
2402 | }, { | ||
2403 | .chip = { | ||
2404 | .base = EXYNOS5_GPA2(0), | ||
2405 | .ngpio = EXYNOS5_GPIO_A2_NR, | ||
2406 | .label = "GPA2", | ||
2407 | }, | ||
2408 | }, { | ||
2409 | .chip = { | ||
2410 | .base = EXYNOS5_GPB0(0), | ||
2411 | .ngpio = EXYNOS5_GPIO_B0_NR, | ||
2412 | .label = "GPB0", | ||
2413 | }, | ||
2414 | }, { | ||
2415 | .chip = { | ||
2416 | .base = EXYNOS5_GPB1(0), | ||
2417 | .ngpio = EXYNOS5_GPIO_B1_NR, | ||
2418 | .label = "GPB1", | ||
2419 | }, | ||
2420 | }, { | ||
2421 | .chip = { | ||
2422 | .base = EXYNOS5_GPB2(0), | ||
2423 | .ngpio = EXYNOS5_GPIO_B2_NR, | ||
2424 | .label = "GPB2", | ||
2425 | }, | ||
2426 | }, { | ||
2427 | .chip = { | ||
2428 | .base = EXYNOS5_GPB3(0), | ||
2429 | .ngpio = EXYNOS5_GPIO_B3_NR, | ||
2430 | .label = "GPB3", | ||
2431 | }, | ||
2432 | }, { | ||
2433 | .chip = { | ||
2434 | .base = EXYNOS5_GPC0(0), | ||
2435 | .ngpio = EXYNOS5_GPIO_C0_NR, | ||
2436 | .label = "GPC0", | ||
2437 | }, | ||
2438 | }, { | ||
2439 | .chip = { | ||
2440 | .base = EXYNOS5_GPC1(0), | ||
2441 | .ngpio = EXYNOS5_GPIO_C1_NR, | ||
2442 | .label = "GPC1", | ||
2443 | }, | ||
2444 | }, { | ||
2445 | .chip = { | ||
2446 | .base = EXYNOS5_GPC2(0), | ||
2447 | .ngpio = EXYNOS5_GPIO_C2_NR, | ||
2448 | .label = "GPC2", | ||
2449 | }, | ||
2450 | }, { | ||
2451 | .chip = { | ||
2452 | .base = EXYNOS5_GPC3(0), | ||
2453 | .ngpio = EXYNOS5_GPIO_C3_NR, | ||
2454 | .label = "GPC3", | ||
2455 | }, | ||
2456 | }, { | ||
2457 | .chip = { | ||
2458 | .base = EXYNOS5_GPD0(0), | ||
2459 | .ngpio = EXYNOS5_GPIO_D0_NR, | ||
2460 | .label = "GPD0", | ||
2461 | }, | ||
2462 | }, { | ||
2463 | .chip = { | ||
2464 | .base = EXYNOS5_GPD1(0), | ||
2465 | .ngpio = EXYNOS5_GPIO_D1_NR, | ||
2466 | .label = "GPD1", | ||
2467 | }, | ||
2468 | }, { | ||
2469 | .chip = { | ||
2470 | .base = EXYNOS5_GPY0(0), | ||
2471 | .ngpio = EXYNOS5_GPIO_Y0_NR, | ||
2472 | .label = "GPY0", | ||
2473 | }, | ||
2474 | }, { | ||
2475 | .chip = { | ||
2476 | .base = EXYNOS5_GPY1(0), | ||
2477 | .ngpio = EXYNOS5_GPIO_Y1_NR, | ||
2478 | .label = "GPY1", | ||
2479 | }, | ||
2480 | }, { | ||
2481 | .chip = { | ||
2482 | .base = EXYNOS5_GPY2(0), | ||
2483 | .ngpio = EXYNOS5_GPIO_Y2_NR, | ||
2484 | .label = "GPY2", | ||
2485 | }, | ||
2486 | }, { | ||
2487 | .chip = { | ||
2488 | .base = EXYNOS5_GPY3(0), | ||
2489 | .ngpio = EXYNOS5_GPIO_Y3_NR, | ||
2490 | .label = "GPY3", | ||
2491 | }, | ||
2492 | }, { | ||
2493 | .chip = { | ||
2494 | .base = EXYNOS5_GPY4(0), | ||
2495 | .ngpio = EXYNOS5_GPIO_Y4_NR, | ||
2496 | .label = "GPY4", | ||
2497 | }, | ||
2498 | }, { | ||
2499 | .chip = { | ||
2500 | .base = EXYNOS5_GPY5(0), | ||
2501 | .ngpio = EXYNOS5_GPIO_Y5_NR, | ||
2502 | .label = "GPY5", | ||
2503 | }, | ||
2504 | }, { | ||
2505 | .chip = { | ||
2506 | .base = EXYNOS5_GPY6(0), | ||
2507 | .ngpio = EXYNOS5_GPIO_Y6_NR, | ||
2508 | .label = "GPY6", | ||
2509 | }, | ||
2510 | }, { | ||
2511 | .chip = { | ||
2512 | .base = EXYNOS5_GPC4(0), | ||
2513 | .ngpio = EXYNOS5_GPIO_C4_NR, | ||
2514 | .label = "GPC4", | ||
2515 | }, | ||
2516 | }, { | ||
2517 | .config = &samsung_gpio_cfgs[9], | ||
2518 | .irq_base = IRQ_EINT(0), | ||
2519 | .chip = { | ||
2520 | .base = EXYNOS5_GPX0(0), | ||
2521 | .ngpio = EXYNOS5_GPIO_X0_NR, | ||
2522 | .label = "GPX0", | ||
2523 | .to_irq = samsung_gpiolib_to_irq, | ||
2524 | }, | ||
2525 | }, { | ||
2526 | .config = &samsung_gpio_cfgs[9], | ||
2527 | .irq_base = IRQ_EINT(8), | ||
2528 | .chip = { | ||
2529 | .base = EXYNOS5_GPX1(0), | ||
2530 | .ngpio = EXYNOS5_GPIO_X1_NR, | ||
2531 | .label = "GPX1", | ||
2532 | .to_irq = samsung_gpiolib_to_irq, | ||
2533 | }, | ||
2534 | }, { | ||
2535 | .config = &samsung_gpio_cfgs[9], | ||
2536 | .irq_base = IRQ_EINT(16), | ||
2537 | .chip = { | ||
2538 | .base = EXYNOS5_GPX2(0), | ||
2539 | .ngpio = EXYNOS5_GPIO_X2_NR, | ||
2540 | .label = "GPX2", | ||
2541 | .to_irq = samsung_gpiolib_to_irq, | ||
2542 | }, | ||
2543 | }, { | ||
2544 | .config = &samsung_gpio_cfgs[9], | ||
2545 | .irq_base = IRQ_EINT(24), | ||
2546 | .chip = { | ||
2547 | .base = EXYNOS5_GPX3(0), | ||
2548 | .ngpio = EXYNOS5_GPIO_X3_NR, | ||
2549 | .label = "GPX3", | ||
2550 | .to_irq = samsung_gpiolib_to_irq, | ||
2551 | }, | ||
2552 | }, | ||
2553 | }; | ||
2554 | #endif | ||
2555 | |||
2556 | #ifdef CONFIG_SOC_EXYNOS5250 | ||
2557 | static struct samsung_gpio_chip exynos5_gpios_2[] = { | ||
2558 | { | ||
2559 | .chip = { | ||
2560 | .base = EXYNOS5_GPE0(0), | ||
2561 | .ngpio = EXYNOS5_GPIO_E0_NR, | ||
2562 | .label = "GPE0", | ||
2563 | }, | ||
2564 | }, { | ||
2565 | .chip = { | ||
2566 | .base = EXYNOS5_GPE1(0), | ||
2567 | .ngpio = EXYNOS5_GPIO_E1_NR, | ||
2568 | .label = "GPE1", | ||
2569 | }, | ||
2570 | }, { | ||
2571 | .chip = { | ||
2572 | .base = EXYNOS5_GPF0(0), | ||
2573 | .ngpio = EXYNOS5_GPIO_F0_NR, | ||
2574 | .label = "GPF0", | ||
2575 | }, | ||
2576 | }, { | ||
2577 | .chip = { | ||
2578 | .base = EXYNOS5_GPF1(0), | ||
2579 | .ngpio = EXYNOS5_GPIO_F1_NR, | ||
2580 | .label = "GPF1", | ||
2581 | }, | ||
2582 | }, { | ||
2583 | .chip = { | ||
2584 | .base = EXYNOS5_GPG0(0), | ||
2585 | .ngpio = EXYNOS5_GPIO_G0_NR, | ||
2586 | .label = "GPG0", | ||
2587 | }, | ||
2588 | }, { | ||
2589 | .chip = { | ||
2590 | .base = EXYNOS5_GPG1(0), | ||
2591 | .ngpio = EXYNOS5_GPIO_G1_NR, | ||
2592 | .label = "GPG1", | ||
2593 | }, | ||
2594 | }, { | ||
2595 | .chip = { | ||
2596 | .base = EXYNOS5_GPG2(0), | ||
2597 | .ngpio = EXYNOS5_GPIO_G2_NR, | ||
2598 | .label = "GPG2", | ||
2599 | }, | ||
2600 | }, { | ||
2601 | .chip = { | ||
2602 | .base = EXYNOS5_GPH0(0), | ||
2603 | .ngpio = EXYNOS5_GPIO_H0_NR, | ||
2604 | .label = "GPH0", | ||
2605 | }, | ||
2606 | }, { | ||
2607 | .chip = { | ||
2608 | .base = EXYNOS5_GPH1(0), | ||
2609 | .ngpio = EXYNOS5_GPIO_H1_NR, | ||
2610 | .label = "GPH1", | ||
2611 | |||
2612 | }, | ||
2613 | }, | ||
2614 | }; | ||
2615 | #endif | ||
2616 | |||
2617 | #ifdef CONFIG_SOC_EXYNOS5250 | ||
2618 | static struct samsung_gpio_chip exynos5_gpios_3[] = { | ||
2619 | { | ||
2620 | .chip = { | ||
2621 | .base = EXYNOS5_GPV0(0), | ||
2622 | .ngpio = EXYNOS5_GPIO_V0_NR, | ||
2623 | .label = "GPV0", | ||
2624 | }, | ||
2625 | }, { | ||
2626 | .chip = { | ||
2627 | .base = EXYNOS5_GPV1(0), | ||
2628 | .ngpio = EXYNOS5_GPIO_V1_NR, | ||
2629 | .label = "GPV1", | ||
2630 | }, | ||
2631 | }, { | ||
2632 | .chip = { | ||
2633 | .base = EXYNOS5_GPV2(0), | ||
2634 | .ngpio = EXYNOS5_GPIO_V2_NR, | ||
2635 | .label = "GPV2", | ||
2636 | }, | ||
2637 | }, { | ||
2638 | .chip = { | ||
2639 | .base = EXYNOS5_GPV3(0), | ||
2640 | .ngpio = EXYNOS5_GPIO_V3_NR, | ||
2641 | .label = "GPV3", | ||
2642 | }, | ||
2643 | }, { | ||
2644 | .chip = { | ||
2645 | .base = EXYNOS5_GPV4(0), | ||
2646 | .ngpio = EXYNOS5_GPIO_V4_NR, | ||
2647 | .label = "GPV4", | ||
2648 | }, | ||
2649 | }, | ||
2650 | }; | ||
2651 | #endif | ||
2652 | |||
2653 | #ifdef CONFIG_SOC_EXYNOS5250 | ||
2654 | static struct samsung_gpio_chip exynos5_gpios_4[] = { | ||
2655 | { | ||
2656 | .chip = { | ||
2657 | .base = EXYNOS5_GPZ(0), | ||
2658 | .ngpio = EXYNOS5_GPIO_Z_NR, | ||
2659 | .label = "GPZ", | ||
2660 | }, | ||
2661 | }, | ||
2662 | }; | ||
2663 | #endif | ||
2664 | |||
2665 | |||
2666 | #if defined(CONFIG_ARCH_EXYNOS) && defined(CONFIG_OF) | ||
2667 | static int exynos_gpio_xlate(struct gpio_chip *gc, | ||
2668 | const struct of_phandle_args *gpiospec, u32 *flags) | ||
2669 | { | ||
2670 | unsigned int pin; | ||
2671 | |||
2672 | if (WARN_ON(gc->of_gpio_n_cells < 4)) | ||
2673 | return -EINVAL; | ||
2674 | |||
2675 | if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells)) | ||
2676 | return -EINVAL; | ||
2677 | |||
2678 | if (gpiospec->args[0] > gc->ngpio) | ||
2679 | return -EINVAL; | ||
2680 | |||
2681 | pin = gc->base + gpiospec->args[0]; | ||
2682 | |||
2683 | if (s3c_gpio_cfgpin(pin, S3C_GPIO_SFN(gpiospec->args[1]))) | ||
2684 | pr_warn("gpio_xlate: failed to set pin function\n"); | ||
2685 | if (s3c_gpio_setpull(pin, gpiospec->args[2] & 0xffff)) | ||
2686 | pr_warn("gpio_xlate: failed to set pin pull up/down\n"); | ||
2687 | if (s5p_gpio_set_drvstr(pin, gpiospec->args[3])) | ||
2688 | pr_warn("gpio_xlate: failed to set pin drive strength\n"); | ||
2689 | |||
2690 | if (flags) | ||
2691 | *flags = gpiospec->args[2] >> 16; | ||
2692 | |||
2693 | return gpiospec->args[0]; | ||
2694 | } | ||
2695 | |||
2696 | static const struct of_device_id exynos_gpio_dt_match[] __initdata = { | ||
2697 | { .compatible = "samsung,exynos4-gpio", }, | ||
2698 | {} | ||
2699 | }; | ||
2700 | |||
2701 | static __init void exynos_gpiolib_attach_ofnode(struct samsung_gpio_chip *chip, | ||
2702 | u64 base, u64 offset) | ||
2703 | { | ||
2704 | struct gpio_chip *gc = &chip->chip; | ||
2705 | u64 address; | ||
2706 | |||
2707 | if (!of_have_populated_dt()) | ||
2708 | return; | ||
2709 | |||
2710 | address = chip->base ? base + ((u32)chip->base & 0xfff) : base + offset; | ||
2711 | gc->of_node = of_find_matching_node_by_address(NULL, | ||
2712 | exynos_gpio_dt_match, address); | ||
2713 | if (!gc->of_node) { | ||
2714 | pr_info("gpio: device tree node not found for gpio controller" | ||
2715 | " with base address %08llx\n", address); | ||
2716 | return; | ||
2717 | } | ||
2718 | gc->of_gpio_n_cells = 4; | ||
2719 | gc->of_xlate = exynos_gpio_xlate; | ||
2720 | } | ||
2721 | #elif defined(CONFIG_ARCH_EXYNOS) | ||
2722 | static __init void exynos_gpiolib_attach_ofnode(struct samsung_gpio_chip *chip, | ||
2723 | u64 base, u64 offset) | ||
2724 | { | ||
2725 | return; | ||
2726 | } | ||
2727 | #endif /* defined(CONFIG_ARCH_EXYNOS) && defined(CONFIG_OF) */ | ||
2728 | |||
2729 | static __init void exynos4_gpiolib_init(void) | ||
2730 | { | ||
2731 | #ifdef CONFIG_CPU_EXYNOS4210 | ||
2732 | struct samsung_gpio_chip *chip; | ||
2733 | int i, nr_chips; | ||
2734 | void __iomem *gpio_base1, *gpio_base2, *gpio_base3; | ||
2735 | int group = 0; | ||
2736 | void __iomem *gpx_base; | ||
2737 | |||
2738 | /* gpio part1 */ | ||
2739 | gpio_base1 = ioremap(EXYNOS4_PA_GPIO1, SZ_4K); | ||
2740 | if (gpio_base1 == NULL) { | ||
2741 | pr_err("unable to ioremap for gpio_base1\n"); | ||
2742 | goto err_ioremap1; | ||
2743 | } | ||
2744 | |||
2745 | chip = exynos4_gpios_1; | ||
2746 | nr_chips = ARRAY_SIZE(exynos4_gpios_1); | ||
2747 | |||
2748 | for (i = 0; i < nr_chips; i++, chip++) { | ||
2749 | if (!chip->config) { | ||
2750 | chip->config = &exynos_gpio_cfg; | ||
2751 | chip->group = group++; | ||
2752 | } | ||
2753 | exynos_gpiolib_attach_ofnode(chip, | ||
2754 | EXYNOS4_PA_GPIO1, i * 0x20); | ||
2755 | } | ||
2756 | samsung_gpiolib_add_4bit_chips(exynos4_gpios_1, | ||
2757 | nr_chips, gpio_base1); | ||
2758 | |||
2759 | /* gpio part2 */ | ||
2760 | gpio_base2 = ioremap(EXYNOS4_PA_GPIO2, SZ_4K); | ||
2761 | if (gpio_base2 == NULL) { | ||
2762 | pr_err("unable to ioremap for gpio_base2\n"); | ||
2763 | goto err_ioremap2; | ||
2764 | } | ||
2765 | |||
2766 | /* need to set base address for gpx */ | ||
2767 | chip = &exynos4_gpios_2[16]; | ||
2768 | gpx_base = gpio_base2 + 0xC00; | ||
2769 | for (i = 0; i < 4; i++, chip++, gpx_base += 0x20) | ||
2770 | chip->base = gpx_base; | ||
2771 | |||
2772 | chip = exynos4_gpios_2; | ||
2773 | nr_chips = ARRAY_SIZE(exynos4_gpios_2); | ||
2774 | |||
2775 | for (i = 0; i < nr_chips; i++, chip++) { | ||
2776 | if (!chip->config) { | ||
2777 | chip->config = &exynos_gpio_cfg; | ||
2778 | chip->group = group++; | ||
2779 | } | ||
2780 | exynos_gpiolib_attach_ofnode(chip, | ||
2781 | EXYNOS4_PA_GPIO2, i * 0x20); | ||
2782 | } | ||
2783 | samsung_gpiolib_add_4bit_chips(exynos4_gpios_2, | ||
2784 | nr_chips, gpio_base2); | ||
2785 | |||
2786 | /* gpio part3 */ | ||
2787 | gpio_base3 = ioremap(EXYNOS4_PA_GPIO3, SZ_256); | ||
2788 | if (gpio_base3 == NULL) { | ||
2789 | pr_err("unable to ioremap for gpio_base3\n"); | ||
2790 | goto err_ioremap3; | ||
2791 | } | ||
2792 | |||
2793 | chip = exynos4_gpios_3; | ||
2794 | nr_chips = ARRAY_SIZE(exynos4_gpios_3); | ||
2795 | |||
2796 | for (i = 0; i < nr_chips; i++, chip++) { | ||
2797 | if (!chip->config) { | ||
2798 | chip->config = &exynos_gpio_cfg; | ||
2799 | chip->group = group++; | ||
2800 | } | ||
2801 | exynos_gpiolib_attach_ofnode(chip, | ||
2802 | EXYNOS4_PA_GPIO3, i * 0x20); | ||
2803 | } | ||
2804 | samsung_gpiolib_add_4bit_chips(exynos4_gpios_3, | ||
2805 | nr_chips, gpio_base3); | ||
2806 | |||
2807 | #if defined(CONFIG_CPU_EXYNOS4210) && defined(CONFIG_S5P_GPIO_INT) | ||
2808 | s5p_register_gpioint_bank(IRQ_GPIO_XA, 0, IRQ_GPIO1_NR_GROUPS); | ||
2809 | s5p_register_gpioint_bank(IRQ_GPIO_XB, IRQ_GPIO1_NR_GROUPS, IRQ_GPIO2_NR_GROUPS); | ||
2810 | #endif | ||
2811 | |||
2812 | return; | ||
2813 | |||
2814 | err_ioremap3: | ||
2815 | iounmap(gpio_base2); | ||
2816 | err_ioremap2: | ||
2817 | iounmap(gpio_base1); | ||
2818 | err_ioremap1: | ||
2819 | return; | ||
2820 | #endif /* CONFIG_CPU_EXYNOS4210 */ | ||
2821 | } | ||
2822 | |||
2823 | static __init void exynos5_gpiolib_init(void) | ||
2824 | { | ||
2825 | #ifdef CONFIG_SOC_EXYNOS5250 | ||
2826 | struct samsung_gpio_chip *chip; | ||
2827 | int i, nr_chips; | ||
2828 | void __iomem *gpio_base1, *gpio_base2, *gpio_base3, *gpio_base4; | ||
2829 | int group = 0; | ||
2830 | void __iomem *gpx_base; | ||
2831 | |||
2832 | /* gpio part1 */ | ||
2833 | gpio_base1 = ioremap(EXYNOS5_PA_GPIO1, SZ_4K); | ||
2834 | if (gpio_base1 == NULL) { | ||
2835 | pr_err("unable to ioremap for gpio_base1\n"); | ||
2836 | goto err_ioremap1; | ||
2837 | } | ||
2838 | |||
2839 | /* need to set base address for gpc4 */ | ||
2840 | exynos5_gpios_1[20].base = gpio_base1 + 0x2E0; | ||
2841 | |||
2842 | /* need to set base address for gpx */ | ||
2843 | chip = &exynos5_gpios_1[21]; | ||
2844 | gpx_base = gpio_base1 + 0xC00; | ||
2845 | for (i = 0; i < 4; i++, chip++, gpx_base += 0x20) | ||
2846 | chip->base = gpx_base; | ||
2847 | |||
2848 | chip = exynos5_gpios_1; | ||
2849 | nr_chips = ARRAY_SIZE(exynos5_gpios_1); | ||
2850 | |||
2851 | for (i = 0; i < nr_chips; i++, chip++) { | ||
2852 | if (!chip->config) { | ||
2853 | chip->config = &exynos_gpio_cfg; | ||
2854 | chip->group = group++; | ||
2855 | } | ||
2856 | exynos_gpiolib_attach_ofnode(chip, | ||
2857 | EXYNOS5_PA_GPIO1, i * 0x20); | ||
2858 | } | ||
2859 | samsung_gpiolib_add_4bit_chips(exynos5_gpios_1, | ||
2860 | nr_chips, gpio_base1); | ||
2861 | |||
2862 | /* gpio part2 */ | ||
2863 | gpio_base2 = ioremap(EXYNOS5_PA_GPIO2, SZ_4K); | ||
2864 | if (gpio_base2 == NULL) { | ||
2865 | pr_err("unable to ioremap for gpio_base2\n"); | ||
2866 | goto err_ioremap2; | ||
2867 | } | ||
2868 | |||
2869 | chip = exynos5_gpios_2; | ||
2870 | nr_chips = ARRAY_SIZE(exynos5_gpios_2); | ||
2871 | |||
2872 | for (i = 0; i < nr_chips; i++, chip++) { | ||
2873 | if (!chip->config) { | ||
2874 | chip->config = &exynos_gpio_cfg; | ||
2875 | chip->group = group++; | ||
2876 | } | ||
2877 | exynos_gpiolib_attach_ofnode(chip, | ||
2878 | EXYNOS5_PA_GPIO2, i * 0x20); | ||
2879 | } | ||
2880 | samsung_gpiolib_add_4bit_chips(exynos5_gpios_2, | ||
2881 | nr_chips, gpio_base2); | ||
2882 | |||
2883 | /* gpio part3 */ | ||
2884 | gpio_base3 = ioremap(EXYNOS5_PA_GPIO3, SZ_4K); | ||
2885 | if (gpio_base3 == NULL) { | ||
2886 | pr_err("unable to ioremap for gpio_base3\n"); | ||
2887 | goto err_ioremap3; | ||
2888 | } | ||
2889 | |||
2890 | /* need to set base address for gpv */ | ||
2891 | exynos5_gpios_3[0].base = gpio_base3; | ||
2892 | exynos5_gpios_3[1].base = gpio_base3 + 0x20; | ||
2893 | exynos5_gpios_3[2].base = gpio_base3 + 0x60; | ||
2894 | exynos5_gpios_3[3].base = gpio_base3 + 0x80; | ||
2895 | exynos5_gpios_3[4].base = gpio_base3 + 0xC0; | ||
2896 | |||
2897 | chip = exynos5_gpios_3; | ||
2898 | nr_chips = ARRAY_SIZE(exynos5_gpios_3); | ||
2899 | |||
2900 | for (i = 0; i < nr_chips; i++, chip++) { | ||
2901 | if (!chip->config) { | ||
2902 | chip->config = &exynos_gpio_cfg; | ||
2903 | chip->group = group++; | ||
2904 | } | ||
2905 | exynos_gpiolib_attach_ofnode(chip, | ||
2906 | EXYNOS5_PA_GPIO3, i * 0x20); | ||
2907 | } | ||
2908 | samsung_gpiolib_add_4bit_chips(exynos5_gpios_3, | ||
2909 | nr_chips, gpio_base3); | ||
2910 | |||
2911 | /* gpio part4 */ | ||
2912 | gpio_base4 = ioremap(EXYNOS5_PA_GPIO4, SZ_4K); | ||
2913 | if (gpio_base4 == NULL) { | ||
2914 | pr_err("unable to ioremap for gpio_base4\n"); | ||
2915 | goto err_ioremap4; | ||
2916 | } | ||
2917 | |||
2918 | chip = exynos5_gpios_4; | ||
2919 | nr_chips = ARRAY_SIZE(exynos5_gpios_4); | ||
2920 | |||
2921 | for (i = 0; i < nr_chips; i++, chip++) { | ||
2922 | if (!chip->config) { | ||
2923 | chip->config = &exynos_gpio_cfg; | ||
2924 | chip->group = group++; | ||
2925 | } | ||
2926 | exynos_gpiolib_attach_ofnode(chip, | ||
2927 | EXYNOS5_PA_GPIO4, i * 0x20); | ||
2928 | } | ||
2929 | samsung_gpiolib_add_4bit_chips(exynos5_gpios_4, | ||
2930 | nr_chips, gpio_base4); | ||
2931 | return; | ||
2932 | |||
2933 | err_ioremap4: | ||
2934 | iounmap(gpio_base3); | ||
2935 | err_ioremap3: | ||
2936 | iounmap(gpio_base2); | ||
2937 | err_ioremap2: | ||
2938 | iounmap(gpio_base1); | ||
2939 | err_ioremap1: | ||
2940 | return; | ||
2941 | |||
2942 | #endif /* CONFIG_SOC_EXYNOS5250 */ | ||
2943 | } | ||
2944 | |||
2945 | /* TODO: cleanup soc_is_* */ | 2078 | /* TODO: cleanup soc_is_* */ |
2946 | static __init int samsung_gpiolib_init(void) | 2079 | static __init int samsung_gpiolib_init(void) |
2947 | { | 2080 | { |
@@ -3040,10 +2173,6 @@ static __init int samsung_gpiolib_init(void) | |||
3040 | #if defined(CONFIG_CPU_S5PV210) && defined(CONFIG_S5P_GPIO_INT) | 2173 | #if defined(CONFIG_CPU_S5PV210) && defined(CONFIG_S5P_GPIO_INT) |
3041 | s5p_register_gpioint_bank(IRQ_GPIOINT, 0, S5P_GPIOINT_GROUP_MAXNR); | 2174 | s5p_register_gpioint_bank(IRQ_GPIOINT, 0, S5P_GPIOINT_GROUP_MAXNR); |
3042 | #endif | 2175 | #endif |
3043 | } else if (soc_is_exynos4210()) { | ||
3044 | exynos4_gpiolib_init(); | ||
3045 | } else if (soc_is_exynos5250()) { | ||
3046 | exynos5_gpiolib_init(); | ||
3047 | } else { | 2176 | } else { |
3048 | WARN(1, "Unknown SoC in gpio-samsung, no GPIOs added\n"); | 2177 | WARN(1, "Unknown SoC in gpio-samsung, no GPIOs added\n"); |
3049 | return -ENODEV; | 2178 | return -ENODEV; |
diff --git a/drivers/gpio/gpio-spear-spics.c b/drivers/gpio/gpio-spear-spics.c index 7a4bf7c0d98f..e9a0415834ea 100644 --- a/drivers/gpio/gpio-spear-spics.c +++ b/drivers/gpio/gpio-spear-spics.c | |||
@@ -128,18 +128,13 @@ static int spics_gpio_probe(struct platform_device *pdev) | |||
128 | struct resource *res; | 128 | struct resource *res; |
129 | int ret; | 129 | int ret; |
130 | 130 | ||
131 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
132 | if (!res) { | ||
133 | dev_err(&pdev->dev, "invalid IORESOURCE_MEM\n"); | ||
134 | return -EBUSY; | ||
135 | } | ||
136 | |||
137 | spics = devm_kzalloc(&pdev->dev, sizeof(*spics), GFP_KERNEL); | 131 | spics = devm_kzalloc(&pdev->dev, sizeof(*spics), GFP_KERNEL); |
138 | if (!spics) { | 132 | if (!spics) { |
139 | dev_err(&pdev->dev, "memory allocation fail\n"); | 133 | dev_err(&pdev->dev, "memory allocation fail\n"); |
140 | return -ENOMEM; | 134 | return -ENOMEM; |
141 | } | 135 | } |
142 | 136 | ||
137 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
143 | spics->base = devm_ioremap_resource(&pdev->dev, res); | 138 | spics->base = devm_ioremap_resource(&pdev->dev, res); |
144 | if (IS_ERR(spics->base)) | 139 | if (IS_ERR(spics->base)) |
145 | return PTR_ERR(spics->base); | 140 | return PTR_ERR(spics->base); |
diff --git a/drivers/gpio/gpio-sta2x11.c b/drivers/gpio/gpio-sta2x11.c index f43ab6aea281..f2fb12c18da9 100644 --- a/drivers/gpio/gpio-sta2x11.c +++ b/drivers/gpio/gpio-sta2x11.c | |||
@@ -361,7 +361,7 @@ static int gsta_probe(struct platform_device *dev) | |||
361 | struct gsta_gpio *chip; | 361 | struct gsta_gpio *chip; |
362 | struct resource *res; | 362 | struct resource *res; |
363 | 363 | ||
364 | pdev = *(struct pci_dev **)(dev->dev.platform_data); | 364 | pdev = *(struct pci_dev **)dev_get_platdata(&dev->dev); |
365 | gpio_pdata = dev_get_platdata(&pdev->dev); | 365 | gpio_pdata = dev_get_platdata(&pdev->dev); |
366 | 366 | ||
367 | if (gpio_pdata == NULL) | 367 | if (gpio_pdata == NULL) |
diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c index f371732591d2..d2983e9ad6af 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c | |||
@@ -583,7 +583,7 @@ static int sx150x_probe(struct i2c_client *client, | |||
583 | struct sx150x_chip *chip; | 583 | struct sx150x_chip *chip; |
584 | int rc; | 584 | int rc; |
585 | 585 | ||
586 | pdata = client->dev.platform_data; | 586 | pdata = dev_get_platdata(&client->dev); |
587 | if (!pdata) | 587 | if (!pdata) |
588 | return -EINVAL; | 588 | return -EINVAL; |
589 | 589 | ||
diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c index 4c65f8883204..7a0e956ef1ed 100644 --- a/drivers/gpio/gpio-timberdale.c +++ b/drivers/gpio/gpio-timberdale.c | |||
@@ -227,7 +227,7 @@ static int timbgpio_probe(struct platform_device *pdev) | |||
227 | struct gpio_chip *gc; | 227 | struct gpio_chip *gc; |
228 | struct timbgpio *tgpio; | 228 | struct timbgpio *tgpio; |
229 | struct resource *iomem; | 229 | struct resource *iomem; |
230 | struct timbgpio_platform_data *pdata = pdev->dev.platform_data; | 230 | struct timbgpio_platform_data *pdata = dev_get_platdata(&pdev->dev); |
231 | int irq = platform_get_irq(pdev, 0); | 231 | int irq = platform_get_irq(pdev, 0); |
232 | 232 | ||
233 | if (!pdata || pdata->nr_pins > 32) { | 233 | if (!pdata || pdata->nr_pins > 32) { |
@@ -318,7 +318,7 @@ err_mem: | |||
318 | static int timbgpio_remove(struct platform_device *pdev) | 318 | static int timbgpio_remove(struct platform_device *pdev) |
319 | { | 319 | { |
320 | int err; | 320 | int err; |
321 | struct timbgpio_platform_data *pdata = pdev->dev.platform_data; | 321 | struct timbgpio_platform_data *pdata = dev_get_platdata(&pdev->dev); |
322 | struct timbgpio *tgpio = platform_get_drvdata(pdev); | 322 | struct timbgpio *tgpio = platform_get_drvdata(pdev); |
323 | struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 323 | struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
324 | int irq = platform_get_irq(pdev, 0); | 324 | int irq = platform_get_irq(pdev, 0); |
diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c index 30a5844a7dca..276a4229b032 100644 --- a/drivers/gpio/gpio-tps65912.c +++ b/drivers/gpio/gpio-tps65912.c | |||
@@ -87,7 +87,7 @@ static struct gpio_chip template_chip = { | |||
87 | static int tps65912_gpio_probe(struct platform_device *pdev) | 87 | static int tps65912_gpio_probe(struct platform_device *pdev) |
88 | { | 88 | { |
89 | struct tps65912 *tps65912 = dev_get_drvdata(pdev->dev.parent); | 89 | struct tps65912 *tps65912 = dev_get_drvdata(pdev->dev.parent); |
90 | struct tps65912_board *pdata = tps65912->dev->platform_data; | 90 | struct tps65912_board *pdata = dev_get_platdata(tps65912->dev); |
91 | struct tps65912_gpio_data *tps65912_gpio; | 91 | struct tps65912_gpio_data *tps65912_gpio; |
92 | int ret; | 92 | int ret; |
93 | 93 | ||
diff --git a/drivers/gpio/gpio-ts5500.c b/drivers/gpio/gpio-ts5500.c index cc53cab8df2a..3df3ebdb3e52 100644 --- a/drivers/gpio/gpio-ts5500.c +++ b/drivers/gpio/gpio-ts5500.c | |||
@@ -322,7 +322,7 @@ static void ts5500_disable_irq(struct ts5500_priv *priv) | |||
322 | static int ts5500_dio_probe(struct platform_device *pdev) | 322 | static int ts5500_dio_probe(struct platform_device *pdev) |
323 | { | 323 | { |
324 | enum ts5500_blocks block = platform_get_device_id(pdev)->driver_data; | 324 | enum ts5500_blocks block = platform_get_device_id(pdev)->driver_data; |
325 | struct ts5500_dio_platform_data *pdata = pdev->dev.platform_data; | 325 | struct ts5500_dio_platform_data *pdata = dev_get_platdata(&pdev->dev); |
326 | struct device *dev = &pdev->dev; | 326 | struct device *dev = &pdev->dev; |
327 | const char *name = dev_name(dev); | 327 | const char *name = dev_name(dev); |
328 | struct ts5500_priv *priv; | 328 | struct ts5500_priv *priv; |
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c index 4d330e36da1d..d8e4f6efcb29 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c | |||
@@ -256,7 +256,7 @@ static int twl_request(struct gpio_chip *chip, unsigned offset) | |||
256 | /* optionally have the first two GPIOs switch vMMC1 | 256 | /* optionally have the first two GPIOs switch vMMC1 |
257 | * and vMMC2 power supplies based on card presence. | 257 | * and vMMC2 power supplies based on card presence. |
258 | */ | 258 | */ |
259 | pdata = chip->dev->platform_data; | 259 | pdata = dev_get_platdata(chip->dev); |
260 | if (pdata) | 260 | if (pdata) |
261 | value |= pdata->mmc_cd & 0x03; | 261 | value |= pdata->mmc_cd & 0x03; |
262 | 262 | ||
@@ -460,7 +460,7 @@ static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev) | |||
460 | 460 | ||
461 | static int gpio_twl4030_probe(struct platform_device *pdev) | 461 | static int gpio_twl4030_probe(struct platform_device *pdev) |
462 | { | 462 | { |
463 | struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data; | 463 | struct twl4030_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); |
464 | struct device_node *node = pdev->dev.of_node; | 464 | struct device_node *node = pdev->dev.of_node; |
465 | struct gpio_twl4030_priv *priv; | 465 | struct gpio_twl4030_priv *priv; |
466 | int ret, irq_base; | 466 | int ret, irq_base; |
@@ -556,7 +556,7 @@ out: | |||
556 | /* Cannot use as gpio_twl4030_probe() calls us */ | 556 | /* Cannot use as gpio_twl4030_probe() calls us */ |
557 | static int gpio_twl4030_remove(struct platform_device *pdev) | 557 | static int gpio_twl4030_remove(struct platform_device *pdev) |
558 | { | 558 | { |
559 | struct twl4030_gpio_platform_data *pdata = pdev->dev.platform_data; | 559 | struct twl4030_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); |
560 | struct gpio_twl4030_priv *priv = platform_get_drvdata(pdev); | 560 | struct gpio_twl4030_priv *priv = platform_get_drvdata(pdev); |
561 | int status; | 561 | int status; |
562 | 562 | ||
diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c index 0be82c6dd796..d420d30b86e7 100644 --- a/drivers/gpio/gpio-twl6040.c +++ b/drivers/gpio/gpio-twl6040.c | |||
@@ -84,15 +84,11 @@ static struct gpio_chip twl6040gpo_chip = { | |||
84 | 84 | ||
85 | static int gpo_twl6040_probe(struct platform_device *pdev) | 85 | static int gpo_twl6040_probe(struct platform_device *pdev) |
86 | { | 86 | { |
87 | struct twl6040_gpo_data *pdata = pdev->dev.platform_data; | ||
88 | struct device *twl6040_core_dev = pdev->dev.parent; | 87 | struct device *twl6040_core_dev = pdev->dev.parent; |
89 | struct twl6040 *twl6040 = dev_get_drvdata(twl6040_core_dev); | 88 | struct twl6040 *twl6040 = dev_get_drvdata(twl6040_core_dev); |
90 | int ret; | 89 | int ret; |
91 | 90 | ||
92 | if (pdata) | 91 | twl6040gpo_chip.base = -1; |
93 | twl6040gpo_chip.base = pdata->gpio_base; | ||
94 | else | ||
95 | twl6040gpo_chip.base = -1; | ||
96 | 92 | ||
97 | if (twl6040_get_revid(twl6040) < TWL6041_REV_ES2_0) | 93 | if (twl6040_get_revid(twl6040) < TWL6041_REV_ES2_0) |
98 | twl6040gpo_chip.ngpio = 3; /* twl6040 have 3 GPO */ | 94 | twl6040gpo_chip.ngpio = 3; /* twl6040 have 3 GPO */ |
diff --git a/drivers/gpio/gpio-tz1090-pdc.c b/drivers/gpio/gpio-tz1090-pdc.c new file mode 100644 index 000000000000..f512da299b3d --- /dev/null +++ b/drivers/gpio/gpio-tz1090-pdc.c | |||
@@ -0,0 +1,243 @@ | |||
1 | /* | ||
2 | * Toumaz Xenif TZ1090 PDC GPIO handling. | ||
3 | * | ||
4 | * Copyright (C) 2012-2013 Imagination Technologies Ltd. | ||
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 | #include <linux/bitops.h> | ||
12 | #include <linux/gpio.h> | ||
13 | #include <linux/io.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/of_irq.h> | ||
16 | #include <linux/pinctrl/consumer.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/syscore_ops.h> | ||
20 | #include <asm/global_lock.h> | ||
21 | |||
22 | /* Register offsets from SOC_GPIO_CONTROL0 */ | ||
23 | #define REG_SOC_GPIO_CONTROL0 0x00 | ||
24 | #define REG_SOC_GPIO_CONTROL1 0x04 | ||
25 | #define REG_SOC_GPIO_CONTROL2 0x08 | ||
26 | #define REG_SOC_GPIO_CONTROL3 0x0c | ||
27 | #define REG_SOC_GPIO_STATUS 0x80 | ||
28 | |||
29 | /* PDC GPIOs go after normal GPIOs */ | ||
30 | #define GPIO_PDC_BASE 90 | ||
31 | #define GPIO_PDC_NGPIO 7 | ||
32 | |||
33 | /* Out of PDC gpios, only syswakes have irqs */ | ||
34 | #define GPIO_PDC_IRQ_FIRST 2 | ||
35 | #define GPIO_PDC_NIRQ 3 | ||
36 | |||
37 | /** | ||
38 | * struct tz1090_pdc_gpio - GPIO bank private data | ||
39 | * @chip: Generic GPIO chip for GPIO bank | ||
40 | * @reg: Base of registers, offset for this GPIO bank | ||
41 | * @irq: IRQ numbers for Syswake GPIOs | ||
42 | * | ||
43 | * This is the main private data for the PDC GPIO driver. It encapsulates a | ||
44 | * gpio_chip, and the callbacks for the gpio_chip can access the private data | ||
45 | * with the to_pdc() macro below. | ||
46 | */ | ||
47 | struct tz1090_pdc_gpio { | ||
48 | struct gpio_chip chip; | ||
49 | void __iomem *reg; | ||
50 | int irq[GPIO_PDC_NIRQ]; | ||
51 | }; | ||
52 | #define to_pdc(c) container_of(c, struct tz1090_pdc_gpio, chip) | ||
53 | |||
54 | /* Register accesses into the PDC MMIO area */ | ||
55 | |||
56 | static inline void pdc_write(struct tz1090_pdc_gpio *priv, unsigned int reg_offs, | ||
57 | unsigned int data) | ||
58 | { | ||
59 | writel(data, priv->reg + reg_offs); | ||
60 | } | ||
61 | |||
62 | static inline unsigned int pdc_read(struct tz1090_pdc_gpio *priv, | ||
63 | unsigned int reg_offs) | ||
64 | { | ||
65 | return readl(priv->reg + reg_offs); | ||
66 | } | ||
67 | |||
68 | /* Generic GPIO interface */ | ||
69 | |||
70 | static int tz1090_pdc_gpio_direction_input(struct gpio_chip *chip, | ||
71 | unsigned int offset) | ||
72 | { | ||
73 | struct tz1090_pdc_gpio *priv = to_pdc(chip); | ||
74 | u32 value; | ||
75 | int lstat; | ||
76 | |||
77 | __global_lock2(lstat); | ||
78 | value = pdc_read(priv, REG_SOC_GPIO_CONTROL1); | ||
79 | value |= BIT(offset); | ||
80 | pdc_write(priv, REG_SOC_GPIO_CONTROL1, value); | ||
81 | __global_unlock2(lstat); | ||
82 | |||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | static int tz1090_pdc_gpio_direction_output(struct gpio_chip *chip, | ||
87 | unsigned int offset, | ||
88 | int output_value) | ||
89 | { | ||
90 | struct tz1090_pdc_gpio *priv = to_pdc(chip); | ||
91 | u32 value; | ||
92 | int lstat; | ||
93 | |||
94 | __global_lock2(lstat); | ||
95 | /* EXT_POWER doesn't seem to have an output value bit */ | ||
96 | if (offset < 6) { | ||
97 | value = pdc_read(priv, REG_SOC_GPIO_CONTROL0); | ||
98 | if (output_value) | ||
99 | value |= BIT(offset); | ||
100 | else | ||
101 | value &= ~BIT(offset); | ||
102 | pdc_write(priv, REG_SOC_GPIO_CONTROL0, value); | ||
103 | } | ||
104 | |||
105 | value = pdc_read(priv, REG_SOC_GPIO_CONTROL1); | ||
106 | value &= ~BIT(offset); | ||
107 | pdc_write(priv, REG_SOC_GPIO_CONTROL1, value); | ||
108 | __global_unlock2(lstat); | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static int tz1090_pdc_gpio_get(struct gpio_chip *chip, unsigned int offset) | ||
114 | { | ||
115 | struct tz1090_pdc_gpio *priv = to_pdc(chip); | ||
116 | return pdc_read(priv, REG_SOC_GPIO_STATUS) & BIT(offset); | ||
117 | } | ||
118 | |||
119 | static void tz1090_pdc_gpio_set(struct gpio_chip *chip, unsigned int offset, | ||
120 | int output_value) | ||
121 | { | ||
122 | struct tz1090_pdc_gpio *priv = to_pdc(chip); | ||
123 | u32 value; | ||
124 | int lstat; | ||
125 | |||
126 | /* EXT_POWER doesn't seem to have an output value bit */ | ||
127 | if (offset >= 6) | ||
128 | return; | ||
129 | |||
130 | __global_lock2(lstat); | ||
131 | value = pdc_read(priv, REG_SOC_GPIO_CONTROL0); | ||
132 | if (output_value) | ||
133 | value |= BIT(offset); | ||
134 | else | ||
135 | value &= ~BIT(offset); | ||
136 | pdc_write(priv, REG_SOC_GPIO_CONTROL0, value); | ||
137 | __global_unlock2(lstat); | ||
138 | } | ||
139 | |||
140 | static int tz1090_pdc_gpio_request(struct gpio_chip *chip, unsigned int offset) | ||
141 | { | ||
142 | return pinctrl_request_gpio(chip->base + offset); | ||
143 | } | ||
144 | |||
145 | static void tz1090_pdc_gpio_free(struct gpio_chip *chip, unsigned int offset) | ||
146 | { | ||
147 | pinctrl_free_gpio(chip->base + offset); | ||
148 | } | ||
149 | |||
150 | static int tz1090_pdc_gpio_to_irq(struct gpio_chip *chip, unsigned int offset) | ||
151 | { | ||
152 | struct tz1090_pdc_gpio *priv = to_pdc(chip); | ||
153 | unsigned int syswake = offset - GPIO_PDC_IRQ_FIRST; | ||
154 | int irq; | ||
155 | |||
156 | /* only syswakes have irqs */ | ||
157 | if (syswake >= GPIO_PDC_NIRQ) | ||
158 | return -EINVAL; | ||
159 | |||
160 | irq = priv->irq[syswake]; | ||
161 | if (!irq) | ||
162 | return -EINVAL; | ||
163 | |||
164 | return irq; | ||
165 | } | ||
166 | |||
167 | static int tz1090_pdc_gpio_probe(struct platform_device *pdev) | ||
168 | { | ||
169 | struct device_node *np = pdev->dev.of_node; | ||
170 | struct resource *res_regs; | ||
171 | struct tz1090_pdc_gpio *priv; | ||
172 | unsigned int i; | ||
173 | |||
174 | if (!np) { | ||
175 | dev_err(&pdev->dev, "must be instantiated via devicetree\n"); | ||
176 | return -ENOENT; | ||
177 | } | ||
178 | |||
179 | res_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
180 | if (!res_regs) { | ||
181 | dev_err(&pdev->dev, "cannot find registers resource\n"); | ||
182 | return -ENOENT; | ||
183 | } | ||
184 | |||
185 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); | ||
186 | if (!priv) { | ||
187 | dev_err(&pdev->dev, "unable to allocate driver data\n"); | ||
188 | return -ENOMEM; | ||
189 | } | ||
190 | |||
191 | /* Ioremap the registers */ | ||
192 | priv->reg = devm_ioremap(&pdev->dev, res_regs->start, | ||
193 | res_regs->end - res_regs->start); | ||
194 | if (!priv->reg) { | ||
195 | dev_err(&pdev->dev, "unable to ioremap registers\n"); | ||
196 | return -ENOMEM; | ||
197 | } | ||
198 | |||
199 | /* Set up GPIO chip */ | ||
200 | priv->chip.label = "tz1090-pdc-gpio"; | ||
201 | priv->chip.dev = &pdev->dev; | ||
202 | priv->chip.direction_input = tz1090_pdc_gpio_direction_input; | ||
203 | priv->chip.direction_output = tz1090_pdc_gpio_direction_output; | ||
204 | priv->chip.get = tz1090_pdc_gpio_get; | ||
205 | priv->chip.set = tz1090_pdc_gpio_set; | ||
206 | priv->chip.free = tz1090_pdc_gpio_free; | ||
207 | priv->chip.request = tz1090_pdc_gpio_request; | ||
208 | priv->chip.to_irq = tz1090_pdc_gpio_to_irq; | ||
209 | priv->chip.of_node = np; | ||
210 | |||
211 | /* GPIO numbering */ | ||
212 | priv->chip.base = GPIO_PDC_BASE; | ||
213 | priv->chip.ngpio = GPIO_PDC_NGPIO; | ||
214 | |||
215 | /* Map the syswake irqs */ | ||
216 | for (i = 0; i < GPIO_PDC_NIRQ; ++i) | ||
217 | priv->irq[i] = irq_of_parse_and_map(np, i); | ||
218 | |||
219 | /* Add the GPIO bank */ | ||
220 | gpiochip_add(&priv->chip); | ||
221 | |||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | static struct of_device_id tz1090_pdc_gpio_of_match[] = { | ||
226 | { .compatible = "img,tz1090-pdc-gpio" }, | ||
227 | { }, | ||
228 | }; | ||
229 | |||
230 | static struct platform_driver tz1090_pdc_gpio_driver = { | ||
231 | .driver = { | ||
232 | .name = "tz1090-pdc-gpio", | ||
233 | .owner = THIS_MODULE, | ||
234 | .of_match_table = tz1090_pdc_gpio_of_match, | ||
235 | }, | ||
236 | .probe = tz1090_pdc_gpio_probe, | ||
237 | }; | ||
238 | |||
239 | static int __init tz1090_pdc_gpio_init(void) | ||
240 | { | ||
241 | return platform_driver_register(&tz1090_pdc_gpio_driver); | ||
242 | } | ||
243 | subsys_initcall(tz1090_pdc_gpio_init); | ||
diff --git a/drivers/gpio/gpio-tz1090.c b/drivers/gpio/gpio-tz1090.c new file mode 100644 index 000000000000..23e061392411 --- /dev/null +++ b/drivers/gpio/gpio-tz1090.c | |||
@@ -0,0 +1,606 @@ | |||
1 | /* | ||
2 | * Toumaz Xenif TZ1090 GPIO handling. | ||
3 | * | ||
4 | * Copyright (C) 2008-2013 Imagination Technologies Ltd. | ||
5 | * | ||
6 | * Based on ARM PXA code and others. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/bitops.h> | ||
14 | #include <linux/export.h> | ||
15 | #include <linux/gpio.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/irq.h> | ||
19 | #include <linux/irqdomain.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/of_irq.h> | ||
22 | #include <linux/pinctrl/consumer.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include <linux/syscore_ops.h> | ||
26 | #include <asm/global_lock.h> | ||
27 | |||
28 | /* Register offsets from bank base address */ | ||
29 | #define REG_GPIO_DIR 0x00 | ||
30 | #define REG_GPIO_IRQ_PLRT 0x20 | ||
31 | #define REG_GPIO_IRQ_TYPE 0x30 | ||
32 | #define REG_GPIO_IRQ_EN 0x40 | ||
33 | #define REG_GPIO_IRQ_STS 0x50 | ||
34 | #define REG_GPIO_BIT_EN 0x60 | ||
35 | #define REG_GPIO_DIN 0x70 | ||
36 | #define REG_GPIO_DOUT 0x80 | ||
37 | |||
38 | /* REG_GPIO_IRQ_PLRT */ | ||
39 | #define REG_GPIO_IRQ_PLRT_LOW 0 | ||
40 | #define REG_GPIO_IRQ_PLRT_HIGH 1 | ||
41 | |||
42 | /* REG_GPIO_IRQ_TYPE */ | ||
43 | #define REG_GPIO_IRQ_TYPE_LEVEL 0 | ||
44 | #define REG_GPIO_IRQ_TYPE_EDGE 1 | ||
45 | |||
46 | /** | ||
47 | * struct tz1090_gpio_bank - GPIO bank private data | ||
48 | * @chip: Generic GPIO chip for GPIO bank | ||
49 | * @domain: IRQ domain for GPIO bank (may be NULL) | ||
50 | * @reg: Base of registers, offset for this GPIO bank | ||
51 | * @irq: IRQ number for GPIO bank | ||
52 | * @label: Debug GPIO bank label, used for storage of chip->label | ||
53 | * | ||
54 | * This is the main private data for a GPIO bank. It encapsulates a gpio_chip, | ||
55 | * and the callbacks for the gpio_chip can access the private data with the | ||
56 | * to_bank() macro below. | ||
57 | */ | ||
58 | struct tz1090_gpio_bank { | ||
59 | struct gpio_chip chip; | ||
60 | struct irq_domain *domain; | ||
61 | void __iomem *reg; | ||
62 | int irq; | ||
63 | char label[16]; | ||
64 | }; | ||
65 | #define to_bank(c) container_of(c, struct tz1090_gpio_bank, chip) | ||
66 | |||
67 | /** | ||
68 | * struct tz1090_gpio - Overall GPIO device private data | ||
69 | * @dev: Device (from platform device) | ||
70 | * @reg: Base of GPIO registers | ||
71 | * | ||
72 | * Represents the overall GPIO device. This structure is actually only | ||
73 | * temporary, and used during init. | ||
74 | */ | ||
75 | struct tz1090_gpio { | ||
76 | struct device *dev; | ||
77 | void __iomem *reg; | ||
78 | }; | ||
79 | |||
80 | /** | ||
81 | * struct tz1090_gpio_bank_info - Temporary registration info for GPIO bank | ||
82 | * @priv: Overall GPIO device private data | ||
83 | * @node: Device tree node specific to this GPIO bank | ||
84 | * @index: Index of bank in range 0-2 | ||
85 | */ | ||
86 | struct tz1090_gpio_bank_info { | ||
87 | struct tz1090_gpio *priv; | ||
88 | struct device_node *node; | ||
89 | unsigned int index; | ||
90 | }; | ||
91 | |||
92 | /* Convenience register accessors */ | ||
93 | static inline void tz1090_gpio_write(struct tz1090_gpio_bank *bank, | ||
94 | unsigned int reg_offs, u32 data) | ||
95 | { | ||
96 | iowrite32(data, bank->reg + reg_offs); | ||
97 | } | ||
98 | |||
99 | static inline u32 tz1090_gpio_read(struct tz1090_gpio_bank *bank, | ||
100 | unsigned int reg_offs) | ||
101 | { | ||
102 | return ioread32(bank->reg + reg_offs); | ||
103 | } | ||
104 | |||
105 | /* caller must hold LOCK2 */ | ||
106 | static inline void _tz1090_gpio_clear_bit(struct tz1090_gpio_bank *bank, | ||
107 | unsigned int reg_offs, | ||
108 | unsigned int offset) | ||
109 | { | ||
110 | u32 value; | ||
111 | |||
112 | value = tz1090_gpio_read(bank, reg_offs); | ||
113 | value &= ~BIT(offset); | ||
114 | tz1090_gpio_write(bank, reg_offs, value); | ||
115 | } | ||
116 | |||
117 | static void tz1090_gpio_clear_bit(struct tz1090_gpio_bank *bank, | ||
118 | unsigned int reg_offs, | ||
119 | unsigned int offset) | ||
120 | { | ||
121 | int lstat; | ||
122 | |||
123 | __global_lock2(lstat); | ||
124 | _tz1090_gpio_clear_bit(bank, reg_offs, offset); | ||
125 | __global_unlock2(lstat); | ||
126 | } | ||
127 | |||
128 | /* caller must hold LOCK2 */ | ||
129 | static inline void _tz1090_gpio_set_bit(struct tz1090_gpio_bank *bank, | ||
130 | unsigned int reg_offs, | ||
131 | unsigned int offset) | ||
132 | { | ||
133 | u32 value; | ||
134 | |||
135 | value = tz1090_gpio_read(bank, reg_offs); | ||
136 | value |= BIT(offset); | ||
137 | tz1090_gpio_write(bank, reg_offs, value); | ||
138 | } | ||
139 | |||
140 | static void tz1090_gpio_set_bit(struct tz1090_gpio_bank *bank, | ||
141 | unsigned int reg_offs, | ||
142 | unsigned int offset) | ||
143 | { | ||
144 | int lstat; | ||
145 | |||
146 | __global_lock2(lstat); | ||
147 | _tz1090_gpio_set_bit(bank, reg_offs, offset); | ||
148 | __global_unlock2(lstat); | ||
149 | } | ||
150 | |||
151 | /* caller must hold LOCK2 */ | ||
152 | static inline void _tz1090_gpio_mod_bit(struct tz1090_gpio_bank *bank, | ||
153 | unsigned int reg_offs, | ||
154 | unsigned int offset, | ||
155 | bool val) | ||
156 | { | ||
157 | u32 value; | ||
158 | |||
159 | value = tz1090_gpio_read(bank, reg_offs); | ||
160 | value &= ~BIT(offset); | ||
161 | if (val) | ||
162 | value |= BIT(offset); | ||
163 | tz1090_gpio_write(bank, reg_offs, value); | ||
164 | } | ||
165 | |||
166 | static void tz1090_gpio_mod_bit(struct tz1090_gpio_bank *bank, | ||
167 | unsigned int reg_offs, | ||
168 | unsigned int offset, | ||
169 | bool val) | ||
170 | { | ||
171 | int lstat; | ||
172 | |||
173 | __global_lock2(lstat); | ||
174 | _tz1090_gpio_mod_bit(bank, reg_offs, offset, val); | ||
175 | __global_unlock2(lstat); | ||
176 | } | ||
177 | |||
178 | static inline int tz1090_gpio_read_bit(struct tz1090_gpio_bank *bank, | ||
179 | unsigned int reg_offs, | ||
180 | unsigned int offset) | ||
181 | { | ||
182 | return tz1090_gpio_read(bank, reg_offs) & BIT(offset); | ||
183 | } | ||
184 | |||
185 | /* GPIO chip callbacks */ | ||
186 | |||
187 | static int tz1090_gpio_direction_input(struct gpio_chip *chip, | ||
188 | unsigned int offset) | ||
189 | { | ||
190 | struct tz1090_gpio_bank *bank = to_bank(chip); | ||
191 | tz1090_gpio_set_bit(bank, REG_GPIO_DIR, offset); | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | static int tz1090_gpio_direction_output(struct gpio_chip *chip, | ||
197 | unsigned int offset, int output_value) | ||
198 | { | ||
199 | struct tz1090_gpio_bank *bank = to_bank(chip); | ||
200 | int lstat; | ||
201 | |||
202 | __global_lock2(lstat); | ||
203 | _tz1090_gpio_mod_bit(bank, REG_GPIO_DOUT, offset, output_value); | ||
204 | _tz1090_gpio_clear_bit(bank, REG_GPIO_DIR, offset); | ||
205 | __global_unlock2(lstat); | ||
206 | |||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | /* | ||
211 | * Return GPIO level | ||
212 | */ | ||
213 | static int tz1090_gpio_get(struct gpio_chip *chip, unsigned int offset) | ||
214 | { | ||
215 | struct tz1090_gpio_bank *bank = to_bank(chip); | ||
216 | |||
217 | return tz1090_gpio_read_bit(bank, REG_GPIO_DIN, offset); | ||
218 | } | ||
219 | |||
220 | /* | ||
221 | * Set output GPIO level | ||
222 | */ | ||
223 | static void tz1090_gpio_set(struct gpio_chip *chip, unsigned int offset, | ||
224 | int output_value) | ||
225 | { | ||
226 | struct tz1090_gpio_bank *bank = to_bank(chip); | ||
227 | |||
228 | tz1090_gpio_mod_bit(bank, REG_GPIO_DOUT, offset, output_value); | ||
229 | } | ||
230 | |||
231 | static int tz1090_gpio_request(struct gpio_chip *chip, unsigned int offset) | ||
232 | { | ||
233 | struct tz1090_gpio_bank *bank = to_bank(chip); | ||
234 | int ret; | ||
235 | |||
236 | ret = pinctrl_request_gpio(chip->base + offset); | ||
237 | if (ret) | ||
238 | return ret; | ||
239 | |||
240 | tz1090_gpio_set_bit(bank, REG_GPIO_DIR, offset); | ||
241 | tz1090_gpio_set_bit(bank, REG_GPIO_BIT_EN, offset); | ||
242 | |||
243 | return 0; | ||
244 | } | ||
245 | |||
246 | static void tz1090_gpio_free(struct gpio_chip *chip, unsigned int offset) | ||
247 | { | ||
248 | struct tz1090_gpio_bank *bank = to_bank(chip); | ||
249 | |||
250 | pinctrl_free_gpio(chip->base + offset); | ||
251 | |||
252 | tz1090_gpio_clear_bit(bank, REG_GPIO_BIT_EN, offset); | ||
253 | } | ||
254 | |||
255 | static int tz1090_gpio_to_irq(struct gpio_chip *chip, unsigned int offset) | ||
256 | { | ||
257 | struct tz1090_gpio_bank *bank = to_bank(chip); | ||
258 | |||
259 | if (!bank->domain) | ||
260 | return -EINVAL; | ||
261 | |||
262 | return irq_create_mapping(bank->domain, offset); | ||
263 | } | ||
264 | |||
265 | /* IRQ chip handlers */ | ||
266 | |||
267 | /* Get TZ1090 GPIO chip from irq data provided to generic IRQ callbacks */ | ||
268 | static inline struct tz1090_gpio_bank *irqd_to_gpio_bank(struct irq_data *data) | ||
269 | { | ||
270 | return (struct tz1090_gpio_bank *)data->domain->host_data; | ||
271 | } | ||
272 | |||
273 | static void tz1090_gpio_irq_polarity(struct tz1090_gpio_bank *bank, | ||
274 | unsigned int offset, unsigned int polarity) | ||
275 | { | ||
276 | tz1090_gpio_mod_bit(bank, REG_GPIO_IRQ_PLRT, offset, polarity); | ||
277 | } | ||
278 | |||
279 | static void tz1090_gpio_irq_type(struct tz1090_gpio_bank *bank, | ||
280 | unsigned int offset, unsigned int type) | ||
281 | { | ||
282 | tz1090_gpio_mod_bit(bank, REG_GPIO_IRQ_TYPE, offset, type); | ||
283 | } | ||
284 | |||
285 | /* set polarity to trigger on next edge, whether rising or falling */ | ||
286 | static void tz1090_gpio_irq_next_edge(struct tz1090_gpio_bank *bank, | ||
287 | unsigned int offset) | ||
288 | { | ||
289 | unsigned int value_p, value_i; | ||
290 | int lstat; | ||
291 | |||
292 | /* | ||
293 | * Set the GPIO's interrupt polarity to the opposite of the current | ||
294 | * input value so that the next edge triggers an interrupt. | ||
295 | */ | ||
296 | __global_lock2(lstat); | ||
297 | value_i = ~tz1090_gpio_read(bank, REG_GPIO_DIN); | ||
298 | value_p = tz1090_gpio_read(bank, REG_GPIO_IRQ_PLRT); | ||
299 | value_p &= ~BIT(offset); | ||
300 | value_p |= value_i & BIT(offset); | ||
301 | tz1090_gpio_write(bank, REG_GPIO_IRQ_PLRT, value_p); | ||
302 | __global_unlock2(lstat); | ||
303 | } | ||
304 | |||
305 | static unsigned int gpio_startup_irq(struct irq_data *data) | ||
306 | { | ||
307 | /* | ||
308 | * This warning indicates that the type of the irq hasn't been set | ||
309 | * before enabling the irq. This would normally be done by passing some | ||
310 | * trigger flags to request_irq(). | ||
311 | */ | ||
312 | WARN(irqd_get_trigger_type(data) == IRQ_TYPE_NONE, | ||
313 | "irq type not set before enabling gpio irq %d", data->irq); | ||
314 | |||
315 | irq_gc_ack_clr_bit(data); | ||
316 | irq_gc_mask_set_bit(data); | ||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | static int gpio_set_irq_type(struct irq_data *data, unsigned int flow_type) | ||
321 | { | ||
322 | struct tz1090_gpio_bank *bank = irqd_to_gpio_bank(data); | ||
323 | unsigned int type; | ||
324 | unsigned int polarity; | ||
325 | |||
326 | switch (flow_type) { | ||
327 | case IRQ_TYPE_EDGE_BOTH: | ||
328 | type = REG_GPIO_IRQ_TYPE_EDGE; | ||
329 | polarity = REG_GPIO_IRQ_PLRT_LOW; | ||
330 | break; | ||
331 | case IRQ_TYPE_EDGE_RISING: | ||
332 | type = REG_GPIO_IRQ_TYPE_EDGE; | ||
333 | polarity = REG_GPIO_IRQ_PLRT_HIGH; | ||
334 | break; | ||
335 | case IRQ_TYPE_EDGE_FALLING: | ||
336 | type = REG_GPIO_IRQ_TYPE_EDGE; | ||
337 | polarity = REG_GPIO_IRQ_PLRT_LOW; | ||
338 | break; | ||
339 | case IRQ_TYPE_LEVEL_HIGH: | ||
340 | type = REG_GPIO_IRQ_TYPE_LEVEL; | ||
341 | polarity = REG_GPIO_IRQ_PLRT_HIGH; | ||
342 | break; | ||
343 | case IRQ_TYPE_LEVEL_LOW: | ||
344 | type = REG_GPIO_IRQ_TYPE_LEVEL; | ||
345 | polarity = REG_GPIO_IRQ_PLRT_LOW; | ||
346 | break; | ||
347 | default: | ||
348 | return -EINVAL; | ||
349 | } | ||
350 | |||
351 | tz1090_gpio_irq_type(bank, data->hwirq, type); | ||
352 | irq_setup_alt_chip(data, flow_type); | ||
353 | |||
354 | if (flow_type == IRQ_TYPE_EDGE_BOTH) | ||
355 | tz1090_gpio_irq_next_edge(bank, data->hwirq); | ||
356 | else | ||
357 | tz1090_gpio_irq_polarity(bank, data->hwirq, polarity); | ||
358 | |||
359 | return 0; | ||
360 | } | ||
361 | |||
362 | #ifdef CONFIG_SUSPEND | ||
363 | static int gpio_set_irq_wake(struct irq_data *data, unsigned int on) | ||
364 | { | ||
365 | struct tz1090_gpio_bank *bank = irqd_to_gpio_bank(data); | ||
366 | |||
367 | #ifdef CONFIG_PM_DEBUG | ||
368 | pr_info("irq_wake irq%d state:%d\n", data->irq, on); | ||
369 | #endif | ||
370 | |||
371 | /* wake on gpio block interrupt */ | ||
372 | return irq_set_irq_wake(bank->irq, on); | ||
373 | } | ||
374 | #else | ||
375 | #define gpio_set_irq_wake NULL | ||
376 | #endif | ||
377 | |||
378 | static void tz1090_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | ||
379 | { | ||
380 | irq_hw_number_t hw; | ||
381 | unsigned int irq_stat, irq_no; | ||
382 | struct tz1090_gpio_bank *bank; | ||
383 | struct irq_desc *child_desc; | ||
384 | |||
385 | bank = (struct tz1090_gpio_bank *)irq_desc_get_handler_data(desc); | ||
386 | irq_stat = tz1090_gpio_read(bank, REG_GPIO_DIR) & | ||
387 | tz1090_gpio_read(bank, REG_GPIO_IRQ_STS) & | ||
388 | tz1090_gpio_read(bank, REG_GPIO_IRQ_EN) & | ||
389 | 0x3FFFFFFF; /* 30 bits only */ | ||
390 | |||
391 | for (hw = 0; irq_stat; irq_stat >>= 1, ++hw) { | ||
392 | if (!(irq_stat & 1)) | ||
393 | continue; | ||
394 | |||
395 | irq_no = irq_linear_revmap(bank->domain, hw); | ||
396 | child_desc = irq_to_desc(irq_no); | ||
397 | |||
398 | /* Toggle edge for pin with both edges triggering enabled */ | ||
399 | if (irqd_get_trigger_type(&child_desc->irq_data) | ||
400 | == IRQ_TYPE_EDGE_BOTH) | ||
401 | tz1090_gpio_irq_next_edge(bank, hw); | ||
402 | |||
403 | generic_handle_irq_desc(irq_no, child_desc); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | static int tz1090_gpio_bank_probe(struct tz1090_gpio_bank_info *info) | ||
408 | { | ||
409 | struct device_node *np = info->node; | ||
410 | struct device *dev = info->priv->dev; | ||
411 | struct tz1090_gpio_bank *bank; | ||
412 | struct irq_chip_generic *gc; | ||
413 | int err; | ||
414 | |||
415 | bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); | ||
416 | if (!bank) { | ||
417 | dev_err(dev, "unable to allocate driver data\n"); | ||
418 | return -ENOMEM; | ||
419 | } | ||
420 | |||
421 | /* Offset the main registers to the first register in this bank */ | ||
422 | bank->reg = info->priv->reg + info->index * 4; | ||
423 | |||
424 | /* Set up GPIO chip */ | ||
425 | snprintf(bank->label, sizeof(bank->label), "tz1090-gpio-%u", | ||
426 | info->index); | ||
427 | bank->chip.label = bank->label; | ||
428 | bank->chip.dev = dev; | ||
429 | bank->chip.direction_input = tz1090_gpio_direction_input; | ||
430 | bank->chip.direction_output = tz1090_gpio_direction_output; | ||
431 | bank->chip.get = tz1090_gpio_get; | ||
432 | bank->chip.set = tz1090_gpio_set; | ||
433 | bank->chip.free = tz1090_gpio_free; | ||
434 | bank->chip.request = tz1090_gpio_request; | ||
435 | bank->chip.to_irq = tz1090_gpio_to_irq; | ||
436 | bank->chip.of_node = np; | ||
437 | |||
438 | /* GPIO numbering from 0 */ | ||
439 | bank->chip.base = info->index * 30; | ||
440 | bank->chip.ngpio = 30; | ||
441 | |||
442 | /* Add the GPIO bank */ | ||
443 | gpiochip_add(&bank->chip); | ||
444 | |||
445 | /* Get the GPIO bank IRQ if provided */ | ||
446 | bank->irq = irq_of_parse_and_map(np, 0); | ||
447 | |||
448 | /* The interrupt is optional (it may be used by another core on chip) */ | ||
449 | if (bank->irq < 0) { | ||
450 | dev_info(dev, "IRQ not provided for bank %u, IRQs disabled\n", | ||
451 | info->index); | ||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | dev_info(dev, "Setting up IRQs for GPIO bank %u\n", | ||
456 | info->index); | ||
457 | |||
458 | /* | ||
459 | * Initialise all interrupts to disabled so we don't get | ||
460 | * spurious ones on a dirty boot and hit the BUG_ON in the | ||
461 | * handler. | ||
462 | */ | ||
463 | tz1090_gpio_write(bank, REG_GPIO_IRQ_EN, 0); | ||
464 | |||
465 | /* Add a virtual IRQ for each GPIO */ | ||
466 | bank->domain = irq_domain_add_linear(np, | ||
467 | bank->chip.ngpio, | ||
468 | &irq_generic_chip_ops, | ||
469 | bank); | ||
470 | |||
471 | /* Set up a generic irq chip with 2 chip types (level and edge) */ | ||
472 | err = irq_alloc_domain_generic_chips(bank->domain, bank->chip.ngpio, 2, | ||
473 | bank->label, handle_bad_irq, 0, 0, | ||
474 | IRQ_GC_INIT_NESTED_LOCK); | ||
475 | if (err) { | ||
476 | dev_info(dev, | ||
477 | "irq_alloc_domain_generic_chips failed for bank %u, IRQs disabled\n", | ||
478 | info->index); | ||
479 | irq_domain_remove(bank->domain); | ||
480 | return 0; | ||
481 | } | ||
482 | |||
483 | gc = irq_get_domain_generic_chip(bank->domain, 0); | ||
484 | gc->reg_base = bank->reg; | ||
485 | |||
486 | /* level chip type */ | ||
487 | gc->chip_types[0].type = IRQ_TYPE_LEVEL_MASK; | ||
488 | gc->chip_types[0].handler = handle_level_irq; | ||
489 | gc->chip_types[0].regs.ack = REG_GPIO_IRQ_STS; | ||
490 | gc->chip_types[0].regs.mask = REG_GPIO_IRQ_EN; | ||
491 | gc->chip_types[0].chip.irq_startup = gpio_startup_irq, | ||
492 | gc->chip_types[0].chip.irq_ack = irq_gc_ack_clr_bit, | ||
493 | gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit, | ||
494 | gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit, | ||
495 | gc->chip_types[0].chip.irq_set_type = gpio_set_irq_type, | ||
496 | gc->chip_types[0].chip.irq_set_wake = gpio_set_irq_wake, | ||
497 | gc->chip_types[0].chip.flags = IRQCHIP_MASK_ON_SUSPEND, | ||
498 | |||
499 | /* edge chip type */ | ||
500 | gc->chip_types[1].type = IRQ_TYPE_EDGE_BOTH; | ||
501 | gc->chip_types[1].handler = handle_edge_irq; | ||
502 | gc->chip_types[1].regs.ack = REG_GPIO_IRQ_STS; | ||
503 | gc->chip_types[1].regs.mask = REG_GPIO_IRQ_EN; | ||
504 | gc->chip_types[1].chip.irq_startup = gpio_startup_irq, | ||
505 | gc->chip_types[1].chip.irq_ack = irq_gc_ack_clr_bit, | ||
506 | gc->chip_types[1].chip.irq_mask = irq_gc_mask_clr_bit, | ||
507 | gc->chip_types[1].chip.irq_unmask = irq_gc_mask_set_bit, | ||
508 | gc->chip_types[1].chip.irq_set_type = gpio_set_irq_type, | ||
509 | gc->chip_types[1].chip.irq_set_wake = gpio_set_irq_wake, | ||
510 | gc->chip_types[1].chip.flags = IRQCHIP_MASK_ON_SUSPEND, | ||
511 | |||
512 | /* Setup chained handler for this GPIO bank */ | ||
513 | irq_set_handler_data(bank->irq, bank); | ||
514 | irq_set_chained_handler(bank->irq, tz1090_gpio_irq_handler); | ||
515 | |||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | static void tz1090_gpio_register_banks(struct tz1090_gpio *priv) | ||
520 | { | ||
521 | struct device_node *np = priv->dev->of_node; | ||
522 | struct device_node *node; | ||
523 | |||
524 | for_each_available_child_of_node(np, node) { | ||
525 | struct tz1090_gpio_bank_info info; | ||
526 | u32 addr; | ||
527 | int ret; | ||
528 | |||
529 | ret = of_property_read_u32(node, "reg", &addr); | ||
530 | if (ret) { | ||
531 | dev_err(priv->dev, "invalid reg on %s\n", | ||
532 | node->full_name); | ||
533 | continue; | ||
534 | } | ||
535 | if (addr >= 3) { | ||
536 | dev_err(priv->dev, "index %u in %s out of range\n", | ||
537 | addr, node->full_name); | ||
538 | continue; | ||
539 | } | ||
540 | |||
541 | info.index = addr; | ||
542 | info.node = of_node_get(node); | ||
543 | info.priv = priv; | ||
544 | |||
545 | ret = tz1090_gpio_bank_probe(&info); | ||
546 | if (ret) { | ||
547 | dev_err(priv->dev, "failure registering %s\n", | ||
548 | node->full_name); | ||
549 | of_node_put(node); | ||
550 | continue; | ||
551 | } | ||
552 | } | ||
553 | } | ||
554 | |||
555 | static int tz1090_gpio_probe(struct platform_device *pdev) | ||
556 | { | ||
557 | struct device_node *np = pdev->dev.of_node; | ||
558 | struct resource *res_regs; | ||
559 | struct tz1090_gpio priv; | ||
560 | |||
561 | if (!np) { | ||
562 | dev_err(&pdev->dev, "must be instantiated via devicetree\n"); | ||
563 | return -ENOENT; | ||
564 | } | ||
565 | |||
566 | res_regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
567 | if (!res_regs) { | ||
568 | dev_err(&pdev->dev, "cannot find registers resource\n"); | ||
569 | return -ENOENT; | ||
570 | } | ||
571 | |||
572 | priv.dev = &pdev->dev; | ||
573 | |||
574 | /* Ioremap the registers */ | ||
575 | priv.reg = devm_ioremap(&pdev->dev, res_regs->start, | ||
576 | res_regs->end - res_regs->start); | ||
577 | if (!priv.reg) { | ||
578 | dev_err(&pdev->dev, "unable to ioremap registers\n"); | ||
579 | return -ENOMEM; | ||
580 | } | ||
581 | |||
582 | /* Look for banks */ | ||
583 | tz1090_gpio_register_banks(&priv); | ||
584 | |||
585 | return 0; | ||
586 | } | ||
587 | |||
588 | static struct of_device_id tz1090_gpio_of_match[] = { | ||
589 | { .compatible = "img,tz1090-gpio" }, | ||
590 | { }, | ||
591 | }; | ||
592 | |||
593 | static struct platform_driver tz1090_gpio_driver = { | ||
594 | .driver = { | ||
595 | .name = "tz1090-gpio", | ||
596 | .owner = THIS_MODULE, | ||
597 | .of_match_table = tz1090_gpio_of_match, | ||
598 | }, | ||
599 | .probe = tz1090_gpio_probe, | ||
600 | }; | ||
601 | |||
602 | static int __init tz1090_gpio_init(void) | ||
603 | { | ||
604 | return platform_driver_register(&tz1090_gpio_driver); | ||
605 | } | ||
606 | subsys_initcall(tz1090_gpio_init); | ||
diff --git a/drivers/gpio/gpio-ucb1400.c b/drivers/gpio/gpio-ucb1400.c index 6d0feb234d3c..1a605f2a0f55 100644 --- a/drivers/gpio/gpio-ucb1400.c +++ b/drivers/gpio/gpio-ucb1400.c | |||
@@ -45,7 +45,7 @@ static void ucb1400_gpio_set(struct gpio_chip *gc, unsigned off, int val) | |||
45 | 45 | ||
46 | static int ucb1400_gpio_probe(struct platform_device *dev) | 46 | static int ucb1400_gpio_probe(struct platform_device *dev) |
47 | { | 47 | { |
48 | struct ucb1400_gpio *ucb = dev->dev.platform_data; | 48 | struct ucb1400_gpio *ucb = dev_get_platdata(&dev->dev); |
49 | int err = 0; | 49 | int err = 0; |
50 | 50 | ||
51 | if (!(ucb && ucb->gpio_offset)) { | 51 | if (!(ucb && ucb->gpio_offset)) { |
diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c index 2a743e10ecb6..456000c5c457 100644 --- a/drivers/gpio/gpio-wm831x.c +++ b/drivers/gpio/gpio-wm831x.c | |||
@@ -246,7 +246,7 @@ static struct gpio_chip template_chip = { | |||
246 | static int wm831x_gpio_probe(struct platform_device *pdev) | 246 | static int wm831x_gpio_probe(struct platform_device *pdev) |
247 | { | 247 | { |
248 | struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); | 248 | struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); |
249 | struct wm831x_pdata *pdata = wm831x->dev->platform_data; | 249 | struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev); |
250 | struct wm831x_gpio *wm831x_gpio; | 250 | struct wm831x_gpio *wm831x_gpio; |
251 | int ret; | 251 | int ret; |
252 | 252 | ||
diff --git a/drivers/gpio/gpio-wm8350.c b/drivers/gpio/gpio-wm8350.c index 0b598cf3df9d..fc49154be7b1 100644 --- a/drivers/gpio/gpio-wm8350.c +++ b/drivers/gpio/gpio-wm8350.c | |||
@@ -112,7 +112,7 @@ static struct gpio_chip template_chip = { | |||
112 | static int wm8350_gpio_probe(struct platform_device *pdev) | 112 | static int wm8350_gpio_probe(struct platform_device *pdev) |
113 | { | 113 | { |
114 | struct wm8350 *wm8350 = dev_get_drvdata(pdev->dev.parent); | 114 | struct wm8350 *wm8350 = dev_get_drvdata(pdev->dev.parent); |
115 | struct wm8350_platform_data *pdata = wm8350->dev->platform_data; | 115 | struct wm8350_platform_data *pdata = dev_get_platdata(wm8350->dev); |
116 | struct wm8350_gpio_data *wm8350_gpio; | 116 | struct wm8350_gpio_data *wm8350_gpio; |
117 | int ret; | 117 | int ret; |
118 | 118 | ||
diff --git a/drivers/gpio/gpio-wm8994.c b/drivers/gpio/gpio-wm8994.c index ae409fd94af7..a53dbdefc7ee 100644 --- a/drivers/gpio/gpio-wm8994.c +++ b/drivers/gpio/gpio-wm8994.c | |||
@@ -248,7 +248,7 @@ static struct gpio_chip template_chip = { | |||
248 | static int wm8994_gpio_probe(struct platform_device *pdev) | 248 | static int wm8994_gpio_probe(struct platform_device *pdev) |
249 | { | 249 | { |
250 | struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent); | 250 | struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent); |
251 | struct wm8994_pdata *pdata = wm8994->dev->platform_data; | 251 | struct wm8994_pdata *pdata = dev_get_platdata(wm8994->dev); |
252 | struct wm8994_gpio *wm8994_gpio; | 252 | struct wm8994_gpio *wm8994_gpio; |
253 | int ret; | 253 | int ret; |
254 | 254 | ||
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 665f9530c950..ba9876ffb017 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c | |||
@@ -76,7 +76,8 @@ int of_get_named_gpio_flags(struct device_node *np, const char *propname, | |||
76 | ret = of_parse_phandle_with_args(np, propname, "#gpio-cells", index, | 76 | ret = of_parse_phandle_with_args(np, propname, "#gpio-cells", index, |
77 | &gg_data.gpiospec); | 77 | &gg_data.gpiospec); |
78 | if (ret) { | 78 | if (ret) { |
79 | pr_debug("%s: can't parse gpios property\n", __func__); | 79 | pr_debug("%s: can't parse gpios property of node '%s[%d]'\n", |
80 | __func__, np->full_name, index); | ||
80 | return ret; | 81 | return ret; |
81 | } | 82 | } |
82 | 83 | ||
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index ff0fd655729f..86ef3461ec06 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -349,7 +349,7 @@ static ssize_t gpio_value_store(struct device *dev, | |||
349 | else { | 349 | else { |
350 | long value; | 350 | long value; |
351 | 351 | ||
352 | status = strict_strtol(buf, 0, &value); | 352 | status = kstrtol(buf, 0, &value); |
353 | if (status == 0) { | 353 | if (status == 0) { |
354 | if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) | 354 | if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) |
355 | value = !value; | 355 | value = !value; |
@@ -570,7 +570,7 @@ static ssize_t gpio_active_low_store(struct device *dev, | |||
570 | } else { | 570 | } else { |
571 | long value; | 571 | long value; |
572 | 572 | ||
573 | status = strict_strtol(buf, 0, &value); | 573 | status = kstrtol(buf, 0, &value); |
574 | if (status == 0) | 574 | if (status == 0) |
575 | status = sysfs_set_active_low(desc, dev, value != 0); | 575 | status = sysfs_set_active_low(desc, dev, value != 0); |
576 | } | 576 | } |
@@ -652,7 +652,7 @@ static ssize_t export_store(struct class *class, | |||
652 | struct gpio_desc *desc; | 652 | struct gpio_desc *desc; |
653 | int status; | 653 | int status; |
654 | 654 | ||
655 | status = strict_strtol(buf, 0, &gpio); | 655 | status = kstrtol(buf, 0, &gpio); |
656 | if (status < 0) | 656 | if (status < 0) |
657 | goto done; | 657 | goto done; |
658 | 658 | ||
@@ -694,7 +694,7 @@ static ssize_t unexport_store(struct class *class, | |||
694 | struct gpio_desc *desc; | 694 | struct gpio_desc *desc; |
695 | int status; | 695 | int status; |
696 | 696 | ||
697 | status = strict_strtol(buf, 0, &gpio); | 697 | status = kstrtol(buf, 0, &gpio); |
698 | if (status < 0) | 698 | if (status < 0) |
699 | goto done; | 699 | goto done; |
700 | 700 | ||
@@ -1398,7 +1398,7 @@ static int gpiod_request(struct gpio_desc *desc, const char *label) | |||
1398 | int status = -EPROBE_DEFER; | 1398 | int status = -EPROBE_DEFER; |
1399 | unsigned long flags; | 1399 | unsigned long flags; |
1400 | 1400 | ||
1401 | if (!desc) { | 1401 | if (!desc || !desc->chip) { |
1402 | pr_warn("%s: invalid GPIO\n", __func__); | 1402 | pr_warn("%s: invalid GPIO\n", __func__); |
1403 | return -EINVAL; | 1403 | return -EINVAL; |
1404 | } | 1404 | } |
@@ -1406,8 +1406,6 @@ static int gpiod_request(struct gpio_desc *desc, const char *label) | |||
1406 | spin_lock_irqsave(&gpio_lock, flags); | 1406 | spin_lock_irqsave(&gpio_lock, flags); |
1407 | 1407 | ||
1408 | chip = desc->chip; | 1408 | chip = desc->chip; |
1409 | if (chip == NULL) | ||
1410 | goto done; | ||
1411 | 1409 | ||
1412 | if (!try_module_get(chip->owner)) | 1410 | if (!try_module_get(chip->owner)) |
1413 | goto done; | 1411 | goto done; |
@@ -1630,16 +1628,20 @@ static int gpiod_direction_input(struct gpio_desc *desc) | |||
1630 | int status = -EINVAL; | 1628 | int status = -EINVAL; |
1631 | int offset; | 1629 | int offset; |
1632 | 1630 | ||
1633 | if (!desc) { | 1631 | if (!desc || !desc->chip) { |
1634 | pr_warn("%s: invalid GPIO\n", __func__); | 1632 | pr_warn("%s: invalid GPIO\n", __func__); |
1635 | return -EINVAL; | 1633 | return -EINVAL; |
1636 | } | 1634 | } |
1637 | 1635 | ||
1636 | chip = desc->chip; | ||
1637 | if (!chip->get || !chip->direction_input) { | ||
1638 | pr_warn("%s: missing get() or direction_input() operations\n", | ||
1639 | __func__); | ||
1640 | return -EIO; | ||
1641 | } | ||
1642 | |||
1638 | spin_lock_irqsave(&gpio_lock, flags); | 1643 | spin_lock_irqsave(&gpio_lock, flags); |
1639 | 1644 | ||
1640 | chip = desc->chip; | ||
1641 | if (!chip || !chip->get || !chip->direction_input) | ||
1642 | goto fail; | ||
1643 | status = gpio_ensure_requested(desc); | 1645 | status = gpio_ensure_requested(desc); |
1644 | if (status < 0) | 1646 | if (status < 0) |
1645 | goto fail; | 1647 | goto fail; |
@@ -1691,7 +1693,7 @@ static int gpiod_direction_output(struct gpio_desc *desc, int value) | |||
1691 | int status = -EINVAL; | 1693 | int status = -EINVAL; |
1692 | int offset; | 1694 | int offset; |
1693 | 1695 | ||
1694 | if (!desc) { | 1696 | if (!desc || !desc->chip) { |
1695 | pr_warn("%s: invalid GPIO\n", __func__); | 1697 | pr_warn("%s: invalid GPIO\n", __func__); |
1696 | return -EINVAL; | 1698 | return -EINVAL; |
1697 | } | 1699 | } |
@@ -1704,11 +1706,15 @@ static int gpiod_direction_output(struct gpio_desc *desc, int value) | |||
1704 | if (!value && test_bit(FLAG_OPEN_SOURCE, &desc->flags)) | 1706 | if (!value && test_bit(FLAG_OPEN_SOURCE, &desc->flags)) |
1705 | return gpiod_direction_input(desc); | 1707 | return gpiod_direction_input(desc); |
1706 | 1708 | ||
1709 | chip = desc->chip; | ||
1710 | if (!chip->set || !chip->direction_output) { | ||
1711 | pr_warn("%s: missing set() or direction_output() operations\n", | ||
1712 | __func__); | ||
1713 | return -EIO; | ||
1714 | } | ||
1715 | |||
1707 | spin_lock_irqsave(&gpio_lock, flags); | 1716 | spin_lock_irqsave(&gpio_lock, flags); |
1708 | 1717 | ||
1709 | chip = desc->chip; | ||
1710 | if (!chip || !chip->set || !chip->direction_output) | ||
1711 | goto fail; | ||
1712 | status = gpio_ensure_requested(desc); | 1718 | status = gpio_ensure_requested(desc); |
1713 | if (status < 0) | 1719 | if (status < 0) |
1714 | goto fail; | 1720 | goto fail; |
@@ -1757,6 +1763,9 @@ EXPORT_SYMBOL_GPL(gpio_direction_output); | |||
1757 | * gpio_set_debounce - sets @debounce time for a @gpio | 1763 | * gpio_set_debounce - sets @debounce time for a @gpio |
1758 | * @gpio: the gpio to set debounce time | 1764 | * @gpio: the gpio to set debounce time |
1759 | * @debounce: debounce time is microseconds | 1765 | * @debounce: debounce time is microseconds |
1766 | * | ||
1767 | * returns -ENOTSUPP if the controller does not support setting | ||
1768 | * debounce. | ||
1760 | */ | 1769 | */ |
1761 | static int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) | 1770 | static int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) |
1762 | { | 1771 | { |
@@ -1765,16 +1774,19 @@ static int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce) | |||
1765 | int status = -EINVAL; | 1774 | int status = -EINVAL; |
1766 | int offset; | 1775 | int offset; |
1767 | 1776 | ||
1768 | if (!desc) { | 1777 | if (!desc || !desc->chip) { |
1769 | pr_warn("%s: invalid GPIO\n", __func__); | 1778 | pr_warn("%s: invalid GPIO\n", __func__); |
1770 | return -EINVAL; | 1779 | return -EINVAL; |
1771 | } | 1780 | } |
1772 | 1781 | ||
1773 | spin_lock_irqsave(&gpio_lock, flags); | ||
1774 | |||
1775 | chip = desc->chip; | 1782 | chip = desc->chip; |
1776 | if (!chip || !chip->set || !chip->set_debounce) | 1783 | if (!chip->set || !chip->set_debounce) { |
1777 | goto fail; | 1784 | pr_debug("%s: missing set() or set_debounce() operations\n", |
1785 | __func__); | ||
1786 | return -ENOTSUPP; | ||
1787 | } | ||
1788 | |||
1789 | spin_lock_irqsave(&gpio_lock, flags); | ||
1778 | 1790 | ||
1779 | status = gpio_ensure_requested(desc); | 1791 | status = gpio_ensure_requested(desc); |
1780 | if (status < 0) | 1792 | if (status < 0) |