diff options
Diffstat (limited to 'drivers')
47 files changed, 756 insertions, 833 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 0f91600c27ae..9370276fe7fe 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -26,12 +26,12 @@ config GPIOLIB_FASTPATH_LIMIT | |||
26 | range 32 512 | 26 | range 32 512 |
27 | default 512 | 27 | default 512 |
28 | help | 28 | help |
29 | This adjusts the point at which certain APIs will switch from | 29 | This adjusts the point at which certain APIs will switch from |
30 | using a stack allocated buffer to a dynamically allocated buffer. | 30 | using a stack allocated buffer to a dynamically allocated buffer. |
31 | 31 | ||
32 | You shouldn't need to change this unless you really need to | 32 | You shouldn't need to change this unless you really need to |
33 | optimize either stack space or performance. Change this carefully | 33 | optimize either stack space or performance. Change this carefully |
34 | since setting an incorrect value could cause stack corruption. | 34 | since setting an incorrect value could cause stack corruption. |
35 | 35 | ||
36 | config OF_GPIO | 36 | config OF_GPIO |
37 | def_bool y | 37 | def_bool y |
@@ -319,7 +319,7 @@ config GPIO_MENZ127 | |||
319 | depends on MCB | 319 | depends on MCB |
320 | select GPIO_GENERIC | 320 | select GPIO_GENERIC |
321 | help | 321 | help |
322 | Say yes here to support the MEN 16Z127 GPIO Controller | 322 | Say yes here to support the MEN 16Z127 GPIO Controller |
323 | 323 | ||
324 | config GPIO_MM_LANTIQ | 324 | config GPIO_MM_LANTIQ |
325 | bool "Lantiq Memory mapped GPIOs" | 325 | bool "Lantiq Memory mapped GPIOs" |
@@ -329,20 +329,6 @@ config GPIO_MM_LANTIQ | |||
329 | (EBU) found on Lantiq SoCs. The gpios are output only as they are | 329 | (EBU) found on Lantiq SoCs. The gpios are output only as they are |
330 | created by attaching a 16bit latch to the bus. | 330 | created by attaching a 16bit latch to the bus. |
331 | 331 | ||
332 | config GPIO_MOCKUP | ||
333 | tristate "GPIO Testing Driver" | ||
334 | depends on GPIOLIB && SYSFS | ||
335 | select GPIO_SYSFS | ||
336 | select GPIOLIB_IRQCHIP | ||
337 | select IRQ_SIM | ||
338 | help | ||
339 | This enables GPIO Testing driver, which provides a way to test GPIO | ||
340 | subsystem through sysfs(or char device) and debugfs. GPIO_SYSFS | ||
341 | must be selected for this test. | ||
342 | User could use it through the script in | ||
343 | tools/testing/selftests/gpio/gpio-mockup.sh. Reference the usage in | ||
344 | it. | ||
345 | |||
346 | config GPIO_MPC5200 | 332 | config GPIO_MPC5200 |
347 | def_bool y | 333 | def_bool y |
348 | depends on PPC_MPC52xx | 334 | depends on PPC_MPC52xx |
@@ -861,11 +847,11 @@ config GPIO_MAX732X | |||
861 | Input and Output (designed by 'P'). The combinations are listed | 847 | Input and Output (designed by 'P'). The combinations are listed |
862 | below: | 848 | below: |
863 | 849 | ||
864 | 8 bits: max7319 (8I), max7320 (8O), max7321 (8P), | 850 | 8 bits: max7319 (8I), max7320 (8O), max7321 (8P), |
865 | max7322 (4I4O), max7323 (4P4O) | 851 | max7322 (4I4O), max7323 (4P4O) |
866 | 852 | ||
867 | 16 bits: max7324 (8I8O), max7325 (8P8O), | 853 | 16 bits: max7324 (8I8O), max7325 (8P8O), |
868 | max7326 (4I12O), max7327 (4P12O) | 854 | max7326 (4I12O), max7327 (4P12O) |
869 | 855 | ||
870 | Board setup code must specify the model to use, and the start | 856 | Board setup code must specify the model to use, and the start |
871 | number for these GPIOs. | 857 | number for these GPIOs. |
@@ -892,17 +878,17 @@ config GPIO_PCA953X | |||
892 | SMBus I/O expanders, made mostly by NXP or TI. Compatible | 878 | SMBus I/O expanders, made mostly by NXP or TI. Compatible |
893 | models include: | 879 | models include: |
894 | 880 | ||
895 | 4 bits: pca9536, pca9537 | 881 | 4 bits: pca9536, pca9537 |
896 | 882 | ||
897 | 8 bits: max7310, max7315, pca6107, pca9534, pca9538, pca9554, | 883 | 8 bits: max7310, max7315, pca6107, pca9534, pca9538, pca9554, |
898 | pca9556, pca9557, pca9574, tca6408, tca9554, xra1202 | 884 | pca9556, pca9557, pca9574, tca6408, tca9554, xra1202 |
899 | 885 | ||
900 | 16 bits: max7312, max7313, pca9535, pca9539, pca9555, pca9575, | 886 | 16 bits: max7312, max7313, pca9535, pca9539, pca9555, pca9575, |
901 | tca6416 | 887 | tca6416 |
902 | 888 | ||
903 | 24 bits: tca6424 | 889 | 24 bits: tca6424 |
904 | 890 | ||
905 | 40 bits: pca9505, pca9698 | 891 | 40 bits: pca9505, pca9698 |
906 | 892 | ||
907 | config GPIO_PCA953X_IRQ | 893 | config GPIO_PCA953X_IRQ |
908 | bool "Interrupt controller support for PCA953x" | 894 | bool "Interrupt controller support for PCA953x" |
@@ -924,7 +910,7 @@ config GPIO_PCF857X | |||
924 | 910 | ||
925 | 8 bits: pcf8574, pcf8574a, pca8574, pca8574a, | 911 | 8 bits: pcf8574, pcf8574a, pca8574, pca8574a, |
926 | pca9670, pca9672, pca9674, pca9674a, | 912 | pca9670, pca9672, pca9674, pca9674a, |
927 | max7328, max7329 | 913 | max7328, max7329 |
928 | 914 | ||
929 | 16 bits: pcf8575, pcf8575c, pca8575, | 915 | 16 bits: pcf8575, pcf8575c, pca8575, |
930 | pca9671, pca9673, pca9675 | 916 | pca9671, pca9673, pca9675 |
@@ -1046,9 +1032,9 @@ config HTC_EGPIO | |||
1046 | bool "HTC EGPIO support" | 1032 | bool "HTC EGPIO support" |
1047 | depends on GPIOLIB && ARM | 1033 | depends on GPIOLIB && ARM |
1048 | help | 1034 | help |
1049 | This driver supports the CPLD egpio chip present on | 1035 | This driver supports the CPLD egpio chip present on |
1050 | several HTC phones. It provides basic support for input | 1036 | several HTC phones. It provides basic support for input |
1051 | pins, output pins, and irqs. | 1037 | pins, output pins, and irqs. |
1052 | 1038 | ||
1053 | config GPIO_JANZ_TTL | 1039 | config GPIO_JANZ_TTL |
1054 | tristate "Janz VMOD-TTL Digital IO Module" | 1040 | tristate "Janz VMOD-TTL Digital IO Module" |
@@ -1084,7 +1070,7 @@ config GPIO_LP873X | |||
1084 | on LP873X PMICs. | 1070 | on LP873X PMICs. |
1085 | 1071 | ||
1086 | This driver can also be built as a module. If so, the module will be | 1072 | This driver can also be built as a module. If so, the module will be |
1087 | called gpio-lp873x. | 1073 | called gpio-lp873x. |
1088 | 1074 | ||
1089 | config GPIO_LP87565 | 1075 | config GPIO_LP87565 |
1090 | tristate "TI LP87565 GPIO" | 1076 | tristate "TI LP87565 GPIO" |
@@ -1315,6 +1301,13 @@ config GPIO_MERRIFIELD | |||
1315 | help | 1301 | help |
1316 | Say Y here to support Intel Merrifield GPIO. | 1302 | Say Y here to support Intel Merrifield GPIO. |
1317 | 1303 | ||
1304 | config GPIO_MLXBF | ||
1305 | tristate "Mellanox BlueField SoC GPIO" | ||
1306 | depends on (MELLANOX_PLATFORM && ARM64 && ACPI) || (64BIT && COMPILE_TEST) | ||
1307 | select GPIO_GENERIC | ||
1308 | help | ||
1309 | Say Y here if you want GPIO support on Mellanox BlueField SoC. | ||
1310 | |||
1318 | config GPIO_ML_IOH | 1311 | config GPIO_ML_IOH |
1319 | tristate "OKI SEMICONDUCTOR ML7213 IOH GPIO support" | 1312 | tristate "OKI SEMICONDUCTOR ML7213 IOH GPIO support" |
1320 | depends on X86 || COMPILE_TEST | 1313 | depends on X86 || COMPILE_TEST |
@@ -1435,10 +1428,22 @@ config GPIO_VIPERBOARD | |||
1435 | Say yes here to access the GPIO signals of Nano River | 1428 | Say yes here to access the GPIO signals of Nano River |
1436 | Technologies Viperboard. There are two GPIO chips on the | 1429 | Technologies Viperboard. There are two GPIO chips on the |
1437 | board: gpioa and gpiob. | 1430 | board: gpioa and gpiob. |
1438 | See viperboard API specification and Nano | 1431 | See viperboard API specification and Nano |
1439 | River Tech's viperboard.h for detailed meaning | 1432 | River Tech's viperboard.h for detailed meaning |
1440 | of the module parameters. | 1433 | of the module parameters. |
1441 | 1434 | ||
1442 | endmenu | 1435 | endmenu |
1443 | 1436 | ||
1437 | config GPIO_MOCKUP | ||
1438 | tristate "GPIO Testing Driver" | ||
1439 | depends on GPIOLIB | ||
1440 | select IRQ_SIM | ||
1441 | help | ||
1442 | This enables GPIO Testing driver, which provides a way to test GPIO | ||
1443 | subsystem through sysfs(or char device) and debugfs. GPIO_SYSFS | ||
1444 | must be selected for this test. | ||
1445 | User could use it through the script in | ||
1446 | tools/testing/selftests/gpio/gpio-mockup.sh. Reference the usage in | ||
1447 | it. | ||
1448 | |||
1444 | endif | 1449 | endif |
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 54d55274b93a..db8d854f9aea 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile | |||
@@ -85,6 +85,7 @@ obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o | |||
85 | obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o | 85 | obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o |
86 | obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o | 86 | obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o |
87 | obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o | 87 | obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o |
88 | obj-$(CONFIG_GPIO_MLXBF) += gpio-mlxbf.o | ||
88 | obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o | 89 | obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o |
89 | obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o | 90 | obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o |
90 | obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o | 91 | obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o |
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index fb7b620763a2..e81307f9754e 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c | |||
@@ -1,21 +1,18 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-only | ||
1 | /* | 2 | /* |
2 | * 74Hx164 - Generic serial-in/parallel-out 8-bits shift register GPIO driver | 3 | * 74Hx164 - Generic serial-in/parallel-out 8-bits shift register GPIO driver |
3 | * | 4 | * |
4 | * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org> | 5 | * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org> |
5 | * Copyright (C) 2010 Miguel Gaio <miguel.gaio@efixo.com> | 6 | * Copyright (C) 2010 Miguel Gaio <miguel.gaio@efixo.com> |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | 7 | */ |
11 | 8 | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/mutex.h> | ||
14 | #include <linux/spi/spi.h> | ||
15 | #include <linux/gpio/driver.h> | ||
16 | #include <linux/gpio/consumer.h> | 9 | #include <linux/gpio/consumer.h> |
17 | #include <linux/slab.h> | 10 | #include <linux/gpio/driver.h> |
18 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/mutex.h> | ||
13 | #include <linux/property.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/spi/spi.h> | ||
19 | 16 | ||
20 | #define GEN_74X164_NUMBER_GPIOS 8 | 17 | #define GEN_74X164_NUMBER_GPIOS 8 |
21 | 18 | ||
@@ -116,10 +113,9 @@ static int gen_74x164_probe(struct spi_device *spi) | |||
116 | if (ret < 0) | 113 | if (ret < 0) |
117 | return ret; | 114 | return ret; |
118 | 115 | ||
119 | if (of_property_read_u32(spi->dev.of_node, "registers-number", | 116 | ret = device_property_read_u32(&spi->dev, "registers-number", &nregs); |
120 | &nregs)) { | 117 | if (ret) { |
121 | dev_err(&spi->dev, | 118 | dev_err(&spi->dev, "Missing 'registers-number' property.\n"); |
122 | "Missing registers-number property in the DT.\n"); | ||
123 | return -EINVAL; | 119 | return -EINVAL; |
124 | } | 120 | } |
125 | 121 | ||
diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c index 49616ec815ee..04247075091d 100644 --- a/drivers/gpio/gpio-74xx-mmio.c +++ b/drivers/gpio/gpio-74xx-mmio.c | |||
@@ -106,7 +106,6 @@ static int mmio_74xx_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | |||
106 | static int mmio_74xx_gpio_probe(struct platform_device *pdev) | 106 | static int mmio_74xx_gpio_probe(struct platform_device *pdev) |
107 | { | 107 | { |
108 | struct mmio_74xx_gpio_priv *priv; | 108 | struct mmio_74xx_gpio_priv *priv; |
109 | struct resource *res; | ||
110 | void __iomem *dat; | 109 | void __iomem *dat; |
111 | int err; | 110 | int err; |
112 | 111 | ||
@@ -116,8 +115,7 @@ static int mmio_74xx_gpio_probe(struct platform_device *pdev) | |||
116 | 115 | ||
117 | priv->flags = (uintptr_t)of_device_get_match_data(&pdev->dev); | 116 | priv->flags = (uintptr_t)of_device_get_match_data(&pdev->dev); |
118 | 117 | ||
119 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 118 | dat = devm_platform_ioremap_resource(pdev, 0); |
120 | dat = devm_ioremap_resource(&pdev->dev, res); | ||
121 | if (IS_ERR(dat)) | 119 | if (IS_ERR(dat)) |
122 | return PTR_ERR(dat); | 120 | return PTR_ERR(dat); |
123 | 121 | ||
diff --git a/drivers/gpio/gpio-amdpt.c b/drivers/gpio/gpio-amdpt.c index 9b78dc837603..1ffd7c2d1285 100644 --- a/drivers/gpio/gpio-amdpt.c +++ b/drivers/gpio/gpio-amdpt.c | |||
@@ -78,7 +78,6 @@ static int pt_gpio_probe(struct platform_device *pdev) | |||
78 | struct acpi_device *acpi_dev; | 78 | struct acpi_device *acpi_dev; |
79 | acpi_handle handle = ACPI_HANDLE(dev); | 79 | acpi_handle handle = ACPI_HANDLE(dev); |
80 | struct pt_gpio_chip *pt_gpio; | 80 | struct pt_gpio_chip *pt_gpio; |
81 | struct resource *res_mem; | ||
82 | int ret = 0; | 81 | int ret = 0; |
83 | 82 | ||
84 | if (acpi_bus_get_device(handle, &acpi_dev)) { | 83 | if (acpi_bus_get_device(handle, &acpi_dev)) { |
@@ -90,12 +89,7 @@ static int pt_gpio_probe(struct platform_device *pdev) | |||
90 | if (!pt_gpio) | 89 | if (!pt_gpio) |
91 | return -ENOMEM; | 90 | return -ENOMEM; |
92 | 91 | ||
93 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 92 | pt_gpio->reg_base = devm_platform_ioremap_resource(pdev, 0); |
94 | if (!res_mem) { | ||
95 | dev_err(&pdev->dev, "Failed to get MMIO resource for PT GPIO.\n"); | ||
96 | return -EINVAL; | ||
97 | } | ||
98 | pt_gpio->reg_base = devm_ioremap_resource(dev, res_mem); | ||
99 | if (IS_ERR(pt_gpio->reg_base)) { | 93 | if (IS_ERR(pt_gpio->reg_base)) { |
100 | dev_err(&pdev->dev, "Failed to map MMIO resource for PT GPIO.\n"); | 94 | dev_err(&pdev->dev, "Failed to map MMIO resource for PT GPIO.\n"); |
101 | return PTR_ERR(pt_gpio->reg_base); | 95 | return PTR_ERR(pt_gpio->reg_base); |
diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c index 217507002dbc..0f1b55c7c361 100644 --- a/drivers/gpio/gpio-aspeed.c +++ b/drivers/gpio/gpio-aspeed.c | |||
@@ -1156,15 +1156,13 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) | |||
1156 | { | 1156 | { |
1157 | const struct of_device_id *gpio_id; | 1157 | const struct of_device_id *gpio_id; |
1158 | struct aspeed_gpio *gpio; | 1158 | struct aspeed_gpio *gpio; |
1159 | struct resource *res; | ||
1160 | int rc, i, banks; | 1159 | int rc, i, banks; |
1161 | 1160 | ||
1162 | gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); | 1161 | gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); |
1163 | if (!gpio) | 1162 | if (!gpio) |
1164 | return -ENOMEM; | 1163 | return -ENOMEM; |
1165 | 1164 | ||
1166 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1165 | gpio->base = devm_platform_ioremap_resource(pdev, 0); |
1167 | gpio->base = devm_ioremap_resource(&pdev->dev, res); | ||
1168 | if (IS_ERR(gpio->base)) | 1166 | if (IS_ERR(gpio->base)) |
1169 | return PTR_ERR(gpio->base); | 1167 | return PTR_ERR(gpio->base); |
1170 | 1168 | ||
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index c5536a509b59..9fa6d3a967d2 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c | |||
@@ -568,7 +568,6 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) | |||
568 | { | 568 | { |
569 | struct device *dev = &pdev->dev; | 569 | struct device *dev = &pdev->dev; |
570 | const struct of_device_id *match; | 570 | const struct of_device_id *match; |
571 | struct resource *res; | ||
572 | struct bcm_kona_gpio_bank *bank; | 571 | struct bcm_kona_gpio_bank *bank; |
573 | struct bcm_kona_gpio *kona_gpio; | 572 | struct bcm_kona_gpio *kona_gpio; |
574 | struct gpio_chip *chip; | 573 | struct gpio_chip *chip; |
@@ -618,8 +617,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) | |||
618 | return -ENXIO; | 617 | return -ENXIO; |
619 | } | 618 | } |
620 | 619 | ||
621 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 620 | kona_gpio->reg_base = devm_platform_ioremap_resource(pdev, 0); |
622 | kona_gpio->reg_base = devm_ioremap_resource(dev, res); | ||
623 | if (IS_ERR(kona_gpio->reg_base)) { | 621 | if (IS_ERR(kona_gpio->reg_base)) { |
624 | ret = -ENXIO; | 622 | ret = -ENXIO; |
625 | goto err_irq_domain; | 623 | goto err_irq_domain; |
diff --git a/drivers/gpio/gpio-cadence.c b/drivers/gpio/gpio-cadence.c index aec8d5df9f30..712ae212b0b4 100644 --- a/drivers/gpio/gpio-cadence.c +++ b/drivers/gpio/gpio-cadence.c | |||
@@ -148,7 +148,6 @@ static struct irq_chip cdns_gpio_irqchip = { | |||
148 | static int cdns_gpio_probe(struct platform_device *pdev) | 148 | static int cdns_gpio_probe(struct platform_device *pdev) |
149 | { | 149 | { |
150 | struct cdns_gpio_chip *cgpio; | 150 | struct cdns_gpio_chip *cgpio; |
151 | struct resource *res; | ||
152 | int ret, irq; | 151 | int ret, irq; |
153 | u32 dir_prev; | 152 | u32 dir_prev; |
154 | u32 num_gpios = 32; | 153 | u32 num_gpios = 32; |
@@ -157,8 +156,7 @@ static int cdns_gpio_probe(struct platform_device *pdev) | |||
157 | if (!cgpio) | 156 | if (!cgpio) |
158 | return -ENOMEM; | 157 | return -ENOMEM; |
159 | 158 | ||
160 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 159 | cgpio->regs = devm_platform_ioremap_resource(pdev, 0); |
161 | cgpio->regs = devm_ioremap_resource(&pdev->dev, res); | ||
162 | if (IS_ERR(cgpio->regs)) | 160 | if (IS_ERR(cgpio->regs)) |
163 | return PTR_ERR(cgpio->regs); | 161 | return PTR_ERR(cgpio->regs); |
164 | 162 | ||
diff --git a/drivers/gpio/gpio-clps711x.c b/drivers/gpio/gpio-clps711x.c index 52fd63f02134..0fbbb0edc0ba 100644 --- a/drivers/gpio/gpio-clps711x.c +++ b/drivers/gpio/gpio-clps711x.c | |||
@@ -19,7 +19,6 @@ static int clps711x_gpio_probe(struct platform_device *pdev) | |||
19 | struct device_node *np = pdev->dev.of_node; | 19 | struct device_node *np = pdev->dev.of_node; |
20 | void __iomem *dat, *dir; | 20 | void __iomem *dat, *dir; |
21 | struct gpio_chip *gc; | 21 | struct gpio_chip *gc; |
22 | struct resource *res; | ||
23 | int err, id; | 22 | int err, id; |
24 | 23 | ||
25 | if (!np) | 24 | if (!np) |
@@ -33,13 +32,11 @@ static int clps711x_gpio_probe(struct platform_device *pdev) | |||
33 | if (!gc) | 32 | if (!gc) |
34 | return -ENOMEM; | 33 | return -ENOMEM; |
35 | 34 | ||
36 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 35 | dat = devm_platform_ioremap_resource(pdev, 0); |
37 | dat = devm_ioremap_resource(&pdev->dev, res); | ||
38 | if (IS_ERR(dat)) | 36 | if (IS_ERR(dat)) |
39 | return PTR_ERR(dat); | 37 | return PTR_ERR(dat); |
40 | 38 | ||
41 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 39 | dir = devm_platform_ioremap_resource(pdev, 1); |
42 | dir = devm_ioremap_resource(&pdev->dev, res); | ||
43 | if (IS_ERR(dir)) | 40 | if (IS_ERR(dir)) |
44 | return PTR_ERR(dir); | 41 | return PTR_ERR(dir); |
45 | 42 | ||
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 84ae04402f70..d3eda65fd6d3 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c | |||
@@ -655,7 +655,6 @@ MODULE_DEVICE_TABLE(acpi, dwapb_acpi_match); | |||
655 | static int dwapb_gpio_probe(struct platform_device *pdev) | 655 | static int dwapb_gpio_probe(struct platform_device *pdev) |
656 | { | 656 | { |
657 | unsigned int i; | 657 | unsigned int i; |
658 | struct resource *res; | ||
659 | struct dwapb_gpio *gpio; | 658 | struct dwapb_gpio *gpio; |
660 | int err; | 659 | int err; |
661 | struct device *dev = &pdev->dev; | 660 | struct device *dev = &pdev->dev; |
@@ -688,8 +687,7 @@ static int dwapb_gpio_probe(struct platform_device *pdev) | |||
688 | if (!gpio->ports) | 687 | if (!gpio->ports) |
689 | return -ENOMEM; | 688 | return -ENOMEM; |
690 | 689 | ||
691 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 690 | gpio->regs = devm_platform_ioremap_resource(pdev, 0); |
692 | gpio->regs = devm_ioremap_resource(&pdev->dev, res); | ||
693 | if (IS_ERR(gpio->regs)) | 691 | if (IS_ERR(gpio->regs)) |
694 | return PTR_ERR(gpio->regs); | 692 | return PTR_ERR(gpio->regs); |
695 | 693 | ||
diff --git a/drivers/gpio/gpio-ftgpio010.c b/drivers/gpio/gpio-ftgpio010.c index 45fe125823a8..8ff8ce2970d9 100644 --- a/drivers/gpio/gpio-ftgpio010.c +++ b/drivers/gpio/gpio-ftgpio010.c | |||
@@ -225,7 +225,6 @@ static int ftgpio_gpio_set_config(struct gpio_chip *gc, unsigned int offset, | |||
225 | static int ftgpio_gpio_probe(struct platform_device *pdev) | 225 | static int ftgpio_gpio_probe(struct platform_device *pdev) |
226 | { | 226 | { |
227 | struct device *dev = &pdev->dev; | 227 | struct device *dev = &pdev->dev; |
228 | struct resource *res; | ||
229 | struct ftgpio_gpio *g; | 228 | struct ftgpio_gpio *g; |
230 | int irq; | 229 | int irq; |
231 | int ret; | 230 | int ret; |
@@ -236,8 +235,7 @@ static int ftgpio_gpio_probe(struct platform_device *pdev) | |||
236 | 235 | ||
237 | g->dev = dev; | 236 | g->dev = dev; |
238 | 237 | ||
239 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 238 | g->base = devm_platform_ioremap_resource(pdev, 0); |
240 | g->base = devm_ioremap_resource(dev, res); | ||
241 | if (IS_ERR(g->base)) | 239 | if (IS_ERR(g->base)) |
242 | return PTR_ERR(g->base); | 240 | return PTR_ERR(g->base); |
243 | 241 | ||
diff --git a/drivers/gpio/gpio-hlwd.c b/drivers/gpio/gpio-hlwd.c index a7b17897356e..e5fa00f8145f 100644 --- a/drivers/gpio/gpio-hlwd.c +++ b/drivers/gpio/gpio-hlwd.c | |||
@@ -208,7 +208,6 @@ static int hlwd_gpio_irq_set_type(struct irq_data *data, unsigned int flow_type) | |||
208 | static int hlwd_gpio_probe(struct platform_device *pdev) | 208 | static int hlwd_gpio_probe(struct platform_device *pdev) |
209 | { | 209 | { |
210 | struct hlwd_gpio *hlwd; | 210 | struct hlwd_gpio *hlwd; |
211 | struct resource *regs_resource; | ||
212 | u32 ngpios; | 211 | u32 ngpios; |
213 | int res; | 212 | int res; |
214 | 213 | ||
@@ -216,8 +215,7 @@ static int hlwd_gpio_probe(struct platform_device *pdev) | |||
216 | if (!hlwd) | 215 | if (!hlwd) |
217 | return -ENOMEM; | 216 | return -ENOMEM; |
218 | 217 | ||
219 | regs_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 218 | hlwd->regs = devm_platform_ioremap_resource(pdev, 0); |
220 | hlwd->regs = devm_ioremap_resource(&pdev->dev, regs_resource); | ||
221 | if (IS_ERR(hlwd->regs)) | 219 | if (IS_ERR(hlwd->regs)) |
222 | return PTR_ERR(hlwd->regs); | 220 | return PTR_ERR(hlwd->regs); |
223 | 221 | ||
diff --git a/drivers/gpio/gpio-iop.c b/drivers/gpio/gpio-iop.c index 8d62db447ec1..11b77d868c89 100644 --- a/drivers/gpio/gpio-iop.c +++ b/drivers/gpio/gpio-iop.c | |||
@@ -21,7 +21,6 @@ | |||
21 | 21 | ||
22 | static int iop3xx_gpio_probe(struct platform_device *pdev) | 22 | static int iop3xx_gpio_probe(struct platform_device *pdev) |
23 | { | 23 | { |
24 | struct resource *res; | ||
25 | struct gpio_chip *gc; | 24 | struct gpio_chip *gc; |
26 | void __iomem *base; | 25 | void __iomem *base; |
27 | int err; | 26 | int err; |
@@ -30,8 +29,7 @@ static int iop3xx_gpio_probe(struct platform_device *pdev) | |||
30 | if (!gc) | 29 | if (!gc) |
31 | return -ENOMEM; | 30 | return -ENOMEM; |
32 | 31 | ||
33 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 32 | base = devm_platform_ioremap_resource(pdev, 0); |
34 | base = devm_ioremap_resource(&pdev->dev, res); | ||
35 | if (IS_ERR(base)) | 33 | if (IS_ERR(base)) |
36 | return PTR_ERR(base); | 34 | return PTR_ERR(base); |
37 | 35 | ||
diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c index 6b9bf8b7bf16..b97a91166497 100644 --- a/drivers/gpio/gpio-janz-ttl.c +++ b/drivers/gpio/gpio-janz-ttl.c | |||
@@ -147,7 +147,6 @@ static int ttl_probe(struct platform_device *pdev) | |||
147 | struct device *dev = &pdev->dev; | 147 | struct device *dev = &pdev->dev; |
148 | struct ttl_module *mod; | 148 | struct ttl_module *mod; |
149 | struct gpio_chip *gpio; | 149 | struct gpio_chip *gpio; |
150 | struct resource *res; | ||
151 | int ret; | 150 | int ret; |
152 | 151 | ||
153 | pdata = dev_get_platdata(&pdev->dev); | 152 | pdata = dev_get_platdata(&pdev->dev); |
@@ -164,8 +163,7 @@ static int ttl_probe(struct platform_device *pdev) | |||
164 | spin_lock_init(&mod->lock); | 163 | spin_lock_init(&mod->lock); |
165 | 164 | ||
166 | /* get access to the MODULbus registers for this module */ | 165 | /* get access to the MODULbus registers for this module */ |
167 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 166 | mod->regs = devm_platform_ioremap_resource(pdev, 0); |
168 | mod->regs = devm_ioremap_resource(dev, res); | ||
169 | if (IS_ERR(mod->regs)) | 167 | if (IS_ERR(mod->regs)) |
170 | return PTR_ERR(mod->regs); | 168 | return PTR_ERR(mod->regs); |
171 | 169 | ||
diff --git a/drivers/gpio/gpio-loongson1.c b/drivers/gpio/gpio-loongson1.c index fca84ccac35c..1b1ee94eeab4 100644 --- a/drivers/gpio/gpio-loongson1.c +++ b/drivers/gpio/gpio-loongson1.c | |||
@@ -47,15 +47,13 @@ static int ls1x_gpio_probe(struct platform_device *pdev) | |||
47 | { | 47 | { |
48 | struct device *dev = &pdev->dev; | 48 | struct device *dev = &pdev->dev; |
49 | struct gpio_chip *gc; | 49 | struct gpio_chip *gc; |
50 | struct resource *res; | ||
51 | int ret; | 50 | int ret; |
52 | 51 | ||
53 | gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL); | 52 | gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL); |
54 | if (!gc) | 53 | if (!gc) |
55 | return -ENOMEM; | 54 | return -ENOMEM; |
56 | 55 | ||
57 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 56 | gpio_reg_base = devm_platform_ioremap_resource(pdev, 0); |
58 | gpio_reg_base = devm_ioremap_resource(dev, res); | ||
59 | if (IS_ERR(gpio_reg_base)) | 57 | if (IS_ERR(gpio_reg_base)) |
60 | return PTR_ERR(gpio_reg_base); | 58 | return PTR_ERR(gpio_reg_base); |
61 | 59 | ||
diff --git a/drivers/gpio/gpio-lpc18xx.c b/drivers/gpio/gpio-lpc18xx.c index d441dbaed7a3..d711ae06747e 100644 --- a/drivers/gpio/gpio-lpc18xx.c +++ b/drivers/gpio/gpio-lpc18xx.c | |||
@@ -340,10 +340,7 @@ static int lpc18xx_gpio_probe(struct platform_device *pdev) | |||
340 | index = of_property_match_string(dev->of_node, "reg-names", "gpio"); | 340 | index = of_property_match_string(dev->of_node, "reg-names", "gpio"); |
341 | if (index < 0) { | 341 | if (index < 0) { |
342 | /* To support backward compatibility take the first resource */ | 342 | /* To support backward compatibility take the first resource */ |
343 | struct resource *res; | 343 | gc->base = devm_platform_ioremap_resource(pdev, 0); |
344 | |||
345 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
346 | gc->base = devm_ioremap_resource(dev, res); | ||
347 | } else { | 344 | } else { |
348 | struct resource res; | 345 | struct resource res; |
349 | 346 | ||
diff --git a/drivers/gpio/gpio-mb86s7x.c b/drivers/gpio/gpio-mb86s7x.c index 3134c0d2bfe4..9308081e0a4a 100644 --- a/drivers/gpio/gpio-mb86s7x.c +++ b/drivers/gpio/gpio-mb86s7x.c | |||
@@ -146,7 +146,6 @@ static void mb86s70_gpio_set(struct gpio_chip *gc, unsigned gpio, int value) | |||
146 | static int mb86s70_gpio_probe(struct platform_device *pdev) | 146 | static int mb86s70_gpio_probe(struct platform_device *pdev) |
147 | { | 147 | { |
148 | struct mb86s70_gpio_chip *gchip; | 148 | struct mb86s70_gpio_chip *gchip; |
149 | struct resource *res; | ||
150 | int ret; | 149 | int ret; |
151 | 150 | ||
152 | gchip = devm_kzalloc(&pdev->dev, sizeof(*gchip), GFP_KERNEL); | 151 | gchip = devm_kzalloc(&pdev->dev, sizeof(*gchip), GFP_KERNEL); |
@@ -155,8 +154,7 @@ static int mb86s70_gpio_probe(struct platform_device *pdev) | |||
155 | 154 | ||
156 | platform_set_drvdata(pdev, gchip); | 155 | platform_set_drvdata(pdev, gchip); |
157 | 156 | ||
158 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 157 | gchip->base = devm_platform_ioremap_resource(pdev, 0); |
159 | gchip->base = devm_ioremap_resource(&pdev->dev, res); | ||
160 | if (IS_ERR(gchip->base)) | 158 | if (IS_ERR(gchip->base)) |
161 | return PTR_ERR(gchip->base); | 159 | return PTR_ERR(gchip->base); |
162 | 160 | ||
diff --git a/drivers/gpio/gpio-mlxbf.c b/drivers/gpio/gpio-mlxbf.c new file mode 100644 index 000000000000..894aaf55fc96 --- /dev/null +++ b/drivers/gpio/gpio-mlxbf.c | |||
@@ -0,0 +1,152 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | |||
3 | #include <linux/acpi.h> | ||
4 | #include <linux/bitops.h> | ||
5 | #include <linux/device.h> | ||
6 | #include <linux/gpio/driver.h> | ||
7 | #include <linux/io.h> | ||
8 | #include <linux/kernel.h> | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | #include <linux/pm.h> | ||
12 | #include <linux/resource.h> | ||
13 | #include <linux/types.h> | ||
14 | |||
15 | /* Number of pins on BlueField */ | ||
16 | #define MLXBF_GPIO_NR 54 | ||
17 | |||
18 | /* Pad Electrical Controls. */ | ||
19 | #define MLXBF_GPIO_PAD_CONTROL_FIRST_WORD 0x0700 | ||
20 | #define MLXBF_GPIO_PAD_CONTROL_1_FIRST_WORD 0x0708 | ||
21 | #define MLXBF_GPIO_PAD_CONTROL_2_FIRST_WORD 0x0710 | ||
22 | #define MLXBF_GPIO_PAD_CONTROL_3_FIRST_WORD 0x0718 | ||
23 | |||
24 | #define MLXBF_GPIO_PIN_DIR_I 0x1040 | ||
25 | #define MLXBF_GPIO_PIN_DIR_O 0x1048 | ||
26 | #define MLXBF_GPIO_PIN_STATE 0x1000 | ||
27 | #define MLXBF_GPIO_SCRATCHPAD 0x20 | ||
28 | |||
29 | #ifdef CONFIG_PM | ||
30 | struct mlxbf_gpio_context_save_regs { | ||
31 | u64 scratchpad; | ||
32 | u64 pad_control[MLXBF_GPIO_NR]; | ||
33 | u64 pin_dir_i; | ||
34 | u64 pin_dir_o; | ||
35 | }; | ||
36 | #endif | ||
37 | |||
38 | /* Device state structure. */ | ||
39 | struct mlxbf_gpio_state { | ||
40 | struct gpio_chip gc; | ||
41 | |||
42 | /* Memory Address */ | ||
43 | void __iomem *base; | ||
44 | |||
45 | #ifdef CONFIG_PM | ||
46 | struct mlxbf_gpio_context_save_regs csave_regs; | ||
47 | #endif | ||
48 | }; | ||
49 | |||
50 | static int mlxbf_gpio_probe(struct platform_device *pdev) | ||
51 | { | ||
52 | struct mlxbf_gpio_state *gs; | ||
53 | struct device *dev = &pdev->dev; | ||
54 | struct gpio_chip *gc; | ||
55 | int ret; | ||
56 | |||
57 | gs = devm_kzalloc(&pdev->dev, sizeof(*gs), GFP_KERNEL); | ||
58 | if (!gs) | ||
59 | return -ENOMEM; | ||
60 | |||
61 | gs->base = devm_platform_ioremap_resource(pdev, 0); | ||
62 | if (IS_ERR(gs->base)) | ||
63 | return PTR_ERR(gs->base); | ||
64 | |||
65 | gc = &gs->gc; | ||
66 | ret = bgpio_init(gc, dev, 8, | ||
67 | gs->base + MLXBF_GPIO_PIN_STATE, | ||
68 | NULL, | ||
69 | NULL, | ||
70 | gs->base + MLXBF_GPIO_PIN_DIR_O, | ||
71 | gs->base + MLXBF_GPIO_PIN_DIR_I, | ||
72 | 0); | ||
73 | if (ret) | ||
74 | return -ENODEV; | ||
75 | |||
76 | gc->owner = THIS_MODULE; | ||
77 | gc->ngpio = MLXBF_GPIO_NR; | ||
78 | |||
79 | ret = devm_gpiochip_add_data(dev, &gs->gc, gs); | ||
80 | if (ret) { | ||
81 | dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n"); | ||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | platform_set_drvdata(pdev, gs); | ||
86 | dev_info(&pdev->dev, "registered Mellanox BlueField GPIO"); | ||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | #ifdef CONFIG_PM | ||
91 | static int mlxbf_gpio_suspend(struct platform_device *pdev, pm_message_t state) | ||
92 | { | ||
93 | struct mlxbf_gpio_state *gs = platform_get_drvdata(pdev); | ||
94 | |||
95 | gs->csave_regs.scratchpad = readq(gs->base + MLXBF_GPIO_SCRATCHPAD); | ||
96 | gs->csave_regs.pad_control[0] = | ||
97 | readq(gs->base + MLXBF_GPIO_PAD_CONTROL_FIRST_WORD); | ||
98 | gs->csave_regs.pad_control[1] = | ||
99 | readq(gs->base + MLXBF_GPIO_PAD_CONTROL_1_FIRST_WORD); | ||
100 | gs->csave_regs.pad_control[2] = | ||
101 | readq(gs->base + MLXBF_GPIO_PAD_CONTROL_2_FIRST_WORD); | ||
102 | gs->csave_regs.pad_control[3] = | ||
103 | readq(gs->base + MLXBF_GPIO_PAD_CONTROL_3_FIRST_WORD); | ||
104 | gs->csave_regs.pin_dir_i = readq(gs->base + MLXBF_GPIO_PIN_DIR_I); | ||
105 | gs->csave_regs.pin_dir_o = readq(gs->base + MLXBF_GPIO_PIN_DIR_O); | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static int mlxbf_gpio_resume(struct platform_device *pdev) | ||
111 | { | ||
112 | struct mlxbf_gpio_state *gs = platform_get_drvdata(pdev); | ||
113 | |||
114 | writeq(gs->csave_regs.scratchpad, gs->base + MLXBF_GPIO_SCRATCHPAD); | ||
115 | writeq(gs->csave_regs.pad_control[0], | ||
116 | gs->base + MLXBF_GPIO_PAD_CONTROL_FIRST_WORD); | ||
117 | writeq(gs->csave_regs.pad_control[1], | ||
118 | gs->base + MLXBF_GPIO_PAD_CONTROL_1_FIRST_WORD); | ||
119 | writeq(gs->csave_regs.pad_control[2], | ||
120 | gs->base + MLXBF_GPIO_PAD_CONTROL_2_FIRST_WORD); | ||
121 | writeq(gs->csave_regs.pad_control[3], | ||
122 | gs->base + MLXBF_GPIO_PAD_CONTROL_3_FIRST_WORD); | ||
123 | writeq(gs->csave_regs.pin_dir_i, gs->base + MLXBF_GPIO_PIN_DIR_I); | ||
124 | writeq(gs->csave_regs.pin_dir_o, gs->base + MLXBF_GPIO_PIN_DIR_O); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | #endif | ||
129 | |||
130 | static const struct acpi_device_id mlxbf_gpio_acpi_match[] = { | ||
131 | { "MLNXBF02", 0 }, | ||
132 | {} | ||
133 | }; | ||
134 | MODULE_DEVICE_TABLE(acpi, mlxbf_gpio_acpi_match); | ||
135 | |||
136 | static struct platform_driver mlxbf_gpio_driver = { | ||
137 | .driver = { | ||
138 | .name = "mlxbf_gpio", | ||
139 | .acpi_match_table = ACPI_PTR(mlxbf_gpio_acpi_match), | ||
140 | }, | ||
141 | .probe = mlxbf_gpio_probe, | ||
142 | #ifdef CONFIG_PM | ||
143 | .suspend = mlxbf_gpio_suspend, | ||
144 | .resume = mlxbf_gpio_resume, | ||
145 | #endif | ||
146 | }; | ||
147 | |||
148 | module_platform_driver(mlxbf_gpio_driver); | ||
149 | |||
150 | MODULE_DESCRIPTION("Mellanox BlueField GPIO Driver"); | ||
151 | MODULE_AUTHOR("Mellanox Technologies"); | ||
152 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c index 50bdc29591c0..6f904c874678 100644 --- a/drivers/gpio/gpio-mmio.c +++ b/drivers/gpio/gpio-mmio.c | |||
@@ -134,17 +134,6 @@ static int bgpio_get_set(struct gpio_chip *gc, unsigned int gpio) | |||
134 | unsigned long pinmask = bgpio_line2mask(gc, gpio); | 134 | unsigned long pinmask = bgpio_line2mask(gc, gpio); |
135 | bool dir = !!(gc->bgpio_dir & pinmask); | 135 | bool dir = !!(gc->bgpio_dir & pinmask); |
136 | 136 | ||
137 | /* | ||
138 | * If the direction is OUT we read the value from the SET | ||
139 | * register, and if the direction is IN we read the value | ||
140 | * from the DAT register. | ||
141 | * | ||
142 | * If the direction bits are inverted, naturally this gets | ||
143 | * inverted too. | ||
144 | */ | ||
145 | if (gc->bgpio_dir_inverted) | ||
146 | dir = !dir; | ||
147 | |||
148 | if (dir) | 137 | if (dir) |
149 | return !!(gc->read_reg(gc->reg_set) & pinmask); | 138 | return !!(gc->read_reg(gc->reg_set) & pinmask); |
150 | else | 139 | else |
@@ -164,14 +153,8 @@ static int bgpio_get_set_multiple(struct gpio_chip *gc, unsigned long *mask, | |||
164 | /* Make sure we first clear any bits that are zero when we read the register */ | 153 | /* Make sure we first clear any bits that are zero when we read the register */ |
165 | *bits &= ~*mask; | 154 | *bits &= ~*mask; |
166 | 155 | ||
167 | /* Exploit the fact that we know which directions are set */ | 156 | set_mask = *mask & gc->bgpio_dir; |
168 | if (gc->bgpio_dir_inverted) { | 157 | get_mask = *mask & ~gc->bgpio_dir; |
169 | set_mask = *mask & ~gc->bgpio_dir; | ||
170 | get_mask = *mask & gc->bgpio_dir; | ||
171 | } else { | ||
172 | set_mask = *mask & gc->bgpio_dir; | ||
173 | get_mask = *mask & ~gc->bgpio_dir; | ||
174 | } | ||
175 | 158 | ||
176 | if (set_mask) | 159 | if (set_mask) |
177 | *bits |= gc->read_reg(gc->reg_set) & set_mask; | 160 | *bits |= gc->read_reg(gc->reg_set) & set_mask; |
@@ -372,11 +355,12 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) | |||
372 | 355 | ||
373 | spin_lock_irqsave(&gc->bgpio_lock, flags); | 356 | spin_lock_irqsave(&gc->bgpio_lock, flags); |
374 | 357 | ||
375 | if (gc->bgpio_dir_inverted) | 358 | gc->bgpio_dir &= ~bgpio_line2mask(gc, gpio); |
376 | gc->bgpio_dir |= bgpio_line2mask(gc, gpio); | 359 | |
377 | else | 360 | if (gc->reg_dir_in) |
378 | gc->bgpio_dir &= ~bgpio_line2mask(gc, gpio); | 361 | gc->write_reg(gc->reg_dir_in, ~gc->bgpio_dir); |
379 | gc->write_reg(gc->reg_dir, gc->bgpio_dir); | 362 | if (gc->reg_dir_out) |
363 | gc->write_reg(gc->reg_dir_out, gc->bgpio_dir); | ||
380 | 364 | ||
381 | spin_unlock_irqrestore(&gc->bgpio_lock, flags); | 365 | spin_unlock_irqrestore(&gc->bgpio_lock, flags); |
382 | 366 | ||
@@ -385,11 +369,16 @@ static int bgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) | |||
385 | 369 | ||
386 | static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio) | 370 | static int bgpio_get_dir(struct gpio_chip *gc, unsigned int gpio) |
387 | { | 371 | { |
388 | /* Return 0 if output, 1 of input */ | 372 | /* Return 0 if output, 1 if input */ |
389 | if (gc->bgpio_dir_inverted) | 373 | if (gc->bgpio_dir_unreadable) |
390 | return !!(gc->read_reg(gc->reg_dir) & bgpio_line2mask(gc, gpio)); | 374 | return !(gc->bgpio_dir & bgpio_line2mask(gc, gpio)); |
391 | else | 375 | if (gc->reg_dir_out) |
392 | return !(gc->read_reg(gc->reg_dir) & bgpio_line2mask(gc, gpio)); | 376 | return !(gc->read_reg(gc->reg_dir_out) & bgpio_line2mask(gc, gpio)); |
377 | if (gc->reg_dir_in) | ||
378 | return !!(gc->read_reg(gc->reg_dir_in) & bgpio_line2mask(gc, gpio)); | ||
379 | |||
380 | /* This should not happen */ | ||
381 | return 1; | ||
393 | } | 382 | } |
394 | 383 | ||
395 | static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | 384 | static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) |
@@ -400,11 +389,12 @@ static int bgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | |||
400 | 389 | ||
401 | spin_lock_irqsave(&gc->bgpio_lock, flags); | 390 | spin_lock_irqsave(&gc->bgpio_lock, flags); |
402 | 391 | ||
403 | if (gc->bgpio_dir_inverted) | 392 | gc->bgpio_dir |= bgpio_line2mask(gc, gpio); |
404 | gc->bgpio_dir &= ~bgpio_line2mask(gc, gpio); | 393 | |
405 | else | 394 | if (gc->reg_dir_in) |
406 | gc->bgpio_dir |= bgpio_line2mask(gc, gpio); | 395 | gc->write_reg(gc->reg_dir_in, ~gc->bgpio_dir); |
407 | gc->write_reg(gc->reg_dir, gc->bgpio_dir); | 396 | if (gc->reg_dir_out) |
397 | gc->write_reg(gc->reg_dir_out, gc->bgpio_dir); | ||
408 | 398 | ||
409 | spin_unlock_irqrestore(&gc->bgpio_lock, flags); | 399 | spin_unlock_irqrestore(&gc->bgpio_lock, flags); |
410 | 400 | ||
@@ -537,19 +527,12 @@ static int bgpio_setup_direction(struct gpio_chip *gc, | |||
537 | void __iomem *dirin, | 527 | void __iomem *dirin, |
538 | unsigned long flags) | 528 | unsigned long flags) |
539 | { | 529 | { |
540 | if (dirout && dirin) { | 530 | if (dirout || dirin) { |
541 | return -EINVAL; | 531 | gc->reg_dir_out = dirout; |
542 | } else if (dirout) { | 532 | gc->reg_dir_in = dirin; |
543 | gc->reg_dir = dirout; | ||
544 | gc->direction_output = bgpio_dir_out; | ||
545 | gc->direction_input = bgpio_dir_in; | ||
546 | gc->get_direction = bgpio_get_dir; | ||
547 | } else if (dirin) { | ||
548 | gc->reg_dir = dirin; | ||
549 | gc->direction_output = bgpio_dir_out; | 533 | gc->direction_output = bgpio_dir_out; |
550 | gc->direction_input = bgpio_dir_in; | 534 | gc->direction_input = bgpio_dir_in; |
551 | gc->get_direction = bgpio_get_dir; | 535 | gc->get_direction = bgpio_get_dir; |
552 | gc->bgpio_dir_inverted = true; | ||
553 | } else { | 536 | } else { |
554 | if (flags & BGPIOF_NO_OUTPUT) | 537 | if (flags & BGPIOF_NO_OUTPUT) |
555 | gc->direction_output = bgpio_dir_out_err; | 538 | gc->direction_output = bgpio_dir_out_err; |
@@ -588,11 +571,11 @@ static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin) | |||
588 | * @dirout: MMIO address for the register to set the line as OUTPUT. It is assumed | 571 | * @dirout: MMIO address for the register to set the line as OUTPUT. It is assumed |
589 | * that setting a line to 1 in this register will turn that line into an | 572 | * that setting a line to 1 in this register will turn that line into an |
590 | * output line. Conversely, setting the line to 0 will turn that line into | 573 | * output line. Conversely, setting the line to 0 will turn that line into |
591 | * an input. Either this or @dirin can be defined, but never both. | 574 | * an input. |
592 | * @dirin: MMIO address for the register to set this line as INPUT. It is assumed | 575 | * @dirin: MMIO address for the register to set this line as INPUT. It is assumed |
593 | * that setting a line to 1 in this register will turn that line into an | 576 | * that setting a line to 1 in this register will turn that line into an |
594 | * input line. Conversely, setting the line to 0 will turn that line into | 577 | * input line. Conversely, setting the line to 0 will turn that line into |
595 | * an output. Either this or @dirout can be defined, but never both. | 578 | * an output. |
596 | * @flags: Different flags that will affect the behaviour of the device, such as | 579 | * @flags: Different flags that will affect the behaviour of the device, such as |
597 | * endianness etc. | 580 | * endianness etc. |
598 | */ | 581 | */ |
@@ -634,8 +617,28 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev, | |||
634 | if (gc->set == bgpio_set_set && | 617 | if (gc->set == bgpio_set_set && |
635 | !(flags & BGPIOF_UNREADABLE_REG_SET)) | 618 | !(flags & BGPIOF_UNREADABLE_REG_SET)) |
636 | gc->bgpio_data = gc->read_reg(gc->reg_set); | 619 | gc->bgpio_data = gc->read_reg(gc->reg_set); |
637 | if (gc->reg_dir && !(flags & BGPIOF_UNREADABLE_REG_DIR)) | 620 | |
638 | gc->bgpio_dir = gc->read_reg(gc->reg_dir); | 621 | if (flags & BGPIOF_UNREADABLE_REG_DIR) |
622 | gc->bgpio_dir_unreadable = true; | ||
623 | |||
624 | /* | ||
625 | * Inspect hardware to find initial direction setting. | ||
626 | */ | ||
627 | if ((gc->reg_dir_out || gc->reg_dir_in) && | ||
628 | !(flags & BGPIOF_UNREADABLE_REG_DIR)) { | ||
629 | if (gc->reg_dir_out) | ||
630 | gc->bgpio_dir = gc->read_reg(gc->reg_dir_out); | ||
631 | else if (gc->reg_dir_in) | ||
632 | gc->bgpio_dir = ~gc->read_reg(gc->reg_dir_in); | ||
633 | /* | ||
634 | * If we have two direction registers, synchronise | ||
635 | * input setting to output setting, the library | ||
636 | * can not handle a line being input and output at | ||
637 | * the same time. | ||
638 | */ | ||
639 | if (gc->reg_dir_out && gc->reg_dir_in) | ||
640 | gc->write_reg(gc->reg_dir_in, ~gc->bgpio_dir); | ||
641 | } | ||
639 | 642 | ||
640 | return ret; | 643 | return ret; |
641 | } | 644 | } |
diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c index 74401e0adb29..79654fb2e50f 100644 --- a/drivers/gpio/gpio-mt7621.c +++ b/drivers/gpio/gpio-mt7621.c | |||
@@ -293,7 +293,6 @@ mediatek_gpio_bank_probe(struct device *dev, | |||
293 | static int | 293 | static int |
294 | mediatek_gpio_probe(struct platform_device *pdev) | 294 | mediatek_gpio_probe(struct platform_device *pdev) |
295 | { | 295 | { |
296 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
297 | struct device *dev = &pdev->dev; | 296 | struct device *dev = &pdev->dev; |
298 | struct device_node *np = dev->of_node; | 297 | struct device_node *np = dev->of_node; |
299 | struct mtk *mtk; | 298 | struct mtk *mtk; |
@@ -304,7 +303,7 @@ mediatek_gpio_probe(struct platform_device *pdev) | |||
304 | if (!mtk) | 303 | if (!mtk) |
305 | return -ENOMEM; | 304 | return -ENOMEM; |
306 | 305 | ||
307 | mtk->base = devm_ioremap_resource(dev, res); | 306 | mtk->base = devm_platform_ioremap_resource(pdev, 0); |
308 | if (IS_ERR(mtk->base)) | 307 | if (IS_ERR(mtk->base)) |
309 | return PTR_ERR(mtk->base); | 308 | return PTR_ERR(mtk->base); |
310 | 309 | ||
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index f97ed32b8beb..059094ac44cb 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c | |||
@@ -1038,11 +1038,9 @@ static const struct regmap_config mvebu_gpio_regmap_config = { | |||
1038 | static int mvebu_gpio_probe_raw(struct platform_device *pdev, | 1038 | static int mvebu_gpio_probe_raw(struct platform_device *pdev, |
1039 | struct mvebu_gpio_chip *mvchip) | 1039 | struct mvebu_gpio_chip *mvchip) |
1040 | { | 1040 | { |
1041 | struct resource *res; | ||
1042 | void __iomem *base; | 1041 | void __iomem *base; |
1043 | 1042 | ||
1044 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1043 | base = devm_platform_ioremap_resource(pdev, 0); |
1045 | base = devm_ioremap_resource(&pdev->dev, res); | ||
1046 | if (IS_ERR(base)) | 1044 | if (IS_ERR(base)) |
1047 | return PTR_ERR(base); | 1045 | return PTR_ERR(base); |
1048 | 1046 | ||
@@ -1062,8 +1060,7 @@ static int mvebu_gpio_probe_raw(struct platform_device *pdev, | |||
1062 | * per-CPU registers | 1060 | * per-CPU registers |
1063 | */ | 1061 | */ |
1064 | if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_ARMADAXP) { | 1062 | if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_ARMADAXP) { |
1065 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1063 | base = devm_platform_ioremap_resource(pdev, 1); |
1066 | base = devm_ioremap_resource(&pdev->dev, res); | ||
1067 | if (IS_ERR(base)) | 1064 | if (IS_ERR(base)) |
1068 | return PTR_ERR(base); | 1065 | return PTR_ERR(base); |
1069 | 1066 | ||
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index e86e61dda4b7..b2813580c582 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c | |||
@@ -411,7 +411,6 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
411 | { | 411 | { |
412 | struct device_node *np = pdev->dev.of_node; | 412 | struct device_node *np = pdev->dev.of_node; |
413 | struct mxc_gpio_port *port; | 413 | struct mxc_gpio_port *port; |
414 | struct resource *iores; | ||
415 | int irq_base; | 414 | int irq_base; |
416 | int err; | 415 | int err; |
417 | 416 | ||
@@ -423,8 +422,7 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
423 | 422 | ||
424 | port->dev = &pdev->dev; | 423 | port->dev = &pdev->dev; |
425 | 424 | ||
426 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 425 | port->base = devm_platform_ioremap_resource(pdev, 0); |
427 | port->base = devm_ioremap_resource(&pdev->dev, iores); | ||
428 | if (IS_ERR(port->base)) | 426 | if (IS_ERR(port->base)) |
429 | return PTR_ERR(port->base); | 427 | return PTR_ERR(port->base); |
430 | 428 | ||
diff --git a/drivers/gpio/gpio-octeon.c b/drivers/gpio/gpio-octeon.c index 1b19c88ea7bb..afb0e8a791e5 100644 --- a/drivers/gpio/gpio-octeon.c +++ b/drivers/gpio/gpio-octeon.c | |||
@@ -82,7 +82,6 @@ static int octeon_gpio_probe(struct platform_device *pdev) | |||
82 | { | 82 | { |
83 | struct octeon_gpio *gpio; | 83 | struct octeon_gpio *gpio; |
84 | struct gpio_chip *chip; | 84 | struct gpio_chip *chip; |
85 | struct resource *res_mem; | ||
86 | void __iomem *reg_base; | 85 | void __iomem *reg_base; |
87 | int err = 0; | 86 | int err = 0; |
88 | 87 | ||
@@ -91,8 +90,7 @@ static int octeon_gpio_probe(struct platform_device *pdev) | |||
91 | return -ENOMEM; | 90 | return -ENOMEM; |
92 | chip = &gpio->chip; | 91 | chip = &gpio->chip; |
93 | 92 | ||
94 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 93 | reg_base = devm_platform_ioremap_resource(pdev, 0); |
95 | reg_base = devm_ioremap_resource(&pdev->dev, res_mem); | ||
96 | if (IS_ERR(reg_base)) | 94 | if (IS_ERR(reg_base)) |
97 | return PTR_ERR(reg_base); | 95 | return PTR_ERR(reg_base); |
98 | 96 | ||
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 7f33024b6d83..16289bafa001 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -31,8 +31,6 @@ | |||
31 | 31 | ||
32 | #define OMAP4_GPIO_DEBOUNCINGTIME_MASK 0xFF | 32 | #define OMAP4_GPIO_DEBOUNCINGTIME_MASK 0xFF |
33 | 33 | ||
34 | #define OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER BIT(2) | ||
35 | |||
36 | struct gpio_regs { | 34 | struct gpio_regs { |
37 | u32 irqenable1; | 35 | u32 irqenable1; |
38 | u32 irqenable2; | 36 | u32 irqenable2; |
@@ -48,13 +46,6 @@ struct gpio_regs { | |||
48 | u32 debounce_en; | 46 | u32 debounce_en; |
49 | }; | 47 | }; |
50 | 48 | ||
51 | struct gpio_bank; | ||
52 | |||
53 | struct gpio_omap_funcs { | ||
54 | void (*idle_enable_level_quirk)(struct gpio_bank *bank); | ||
55 | void (*idle_disable_level_quirk)(struct gpio_bank *bank); | ||
56 | }; | ||
57 | |||
58 | struct gpio_bank { | 49 | struct gpio_bank { |
59 | struct list_head node; | 50 | struct list_head node; |
60 | void __iomem *base; | 51 | void __iomem *base; |
@@ -62,7 +53,6 @@ struct gpio_bank { | |||
62 | u32 non_wakeup_gpios; | 53 | u32 non_wakeup_gpios; |
63 | u32 enabled_non_wakeup_gpios; | 54 | u32 enabled_non_wakeup_gpios; |
64 | struct gpio_regs context; | 55 | struct gpio_regs context; |
65 | struct gpio_omap_funcs funcs; | ||
66 | u32 saved_datain; | 56 | u32 saved_datain; |
67 | u32 level_mask; | 57 | u32 level_mask; |
68 | u32 toggle_mask; | 58 | u32 toggle_mask; |
@@ -83,8 +73,6 @@ struct gpio_bank { | |||
83 | int stride; | 73 | int stride; |
84 | u32 width; | 74 | u32 width; |
85 | int context_loss_count; | 75 | int context_loss_count; |
86 | bool workaround_enabled; | ||
87 | u32 quirks; | ||
88 | 76 | ||
89 | void (*set_dataout)(struct gpio_bank *bank, unsigned gpio, int enable); | 77 | void (*set_dataout)(struct gpio_bank *bank, unsigned gpio, int enable); |
90 | void (*set_dataout_multiple)(struct gpio_bank *bank, | 78 | void (*set_dataout_multiple)(struct gpio_bank *bank, |
@@ -353,6 +341,22 @@ static void omap_clear_gpio_debounce(struct gpio_bank *bank, unsigned offset) | |||
353 | } | 341 | } |
354 | } | 342 | } |
355 | 343 | ||
344 | /* | ||
345 | * Off mode wake-up capable GPIOs in bank(s) that are in the wakeup domain. | ||
346 | * See TRM section for GPIO for "Wake-Up Generation" for the list of GPIOs | ||
347 | * in wakeup domain. If bank->non_wakeup_gpios is not configured, assume none | ||
348 | * are capable waking up the system from off mode. | ||
349 | */ | ||
350 | static bool omap_gpio_is_off_wakeup_capable(struct gpio_bank *bank, u32 gpio_mask) | ||
351 | { | ||
352 | u32 no_wake = bank->non_wakeup_gpios; | ||
353 | |||
354 | if (no_wake) | ||
355 | return !!(~no_wake & gpio_mask); | ||
356 | |||
357 | return false; | ||
358 | } | ||
359 | |||
356 | static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, | 360 | static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, |
357 | unsigned trigger) | 361 | unsigned trigger) |
358 | { | 362 | { |
@@ -363,10 +367,16 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, | |||
363 | trigger & IRQ_TYPE_LEVEL_LOW); | 367 | trigger & IRQ_TYPE_LEVEL_LOW); |
364 | omap_gpio_rmw(base, bank->regs->leveldetect1, gpio_bit, | 368 | omap_gpio_rmw(base, bank->regs->leveldetect1, gpio_bit, |
365 | trigger & IRQ_TYPE_LEVEL_HIGH); | 369 | trigger & IRQ_TYPE_LEVEL_HIGH); |
370 | |||
371 | /* | ||
372 | * We need the edge detection enabled for to allow the GPIO block | ||
373 | * to be woken from idle state. Set the appropriate edge detection | ||
374 | * in addition to the level detection. | ||
375 | */ | ||
366 | omap_gpio_rmw(base, bank->regs->risingdetect, gpio_bit, | 376 | omap_gpio_rmw(base, bank->regs->risingdetect, gpio_bit, |
367 | trigger & IRQ_TYPE_EDGE_RISING); | 377 | trigger & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)); |
368 | omap_gpio_rmw(base, bank->regs->fallingdetect, gpio_bit, | 378 | omap_gpio_rmw(base, bank->regs->fallingdetect, gpio_bit, |
369 | trigger & IRQ_TYPE_EDGE_FALLING); | 379 | trigger & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW)); |
370 | 380 | ||
371 | bank->context.leveldetect0 = | 381 | bank->context.leveldetect0 = |
372 | readl_relaxed(bank->base + bank->regs->leveldetect0); | 382 | readl_relaxed(bank->base + bank->regs->leveldetect0); |
@@ -384,13 +394,7 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, | |||
384 | } | 394 | } |
385 | 395 | ||
386 | /* This part needs to be executed always for OMAP{34xx, 44xx} */ | 396 | /* This part needs to be executed always for OMAP{34xx, 44xx} */ |
387 | if (!bank->regs->irqctrl) { | 397 | if (!bank->regs->irqctrl && !omap_gpio_is_off_wakeup_capable(bank, gpio)) { |
388 | /* On omap24xx proceed only when valid GPIO bit is set */ | ||
389 | if (bank->non_wakeup_gpios) { | ||
390 | if (!(bank->non_wakeup_gpios & gpio_bit)) | ||
391 | goto exit; | ||
392 | } | ||
393 | |||
394 | /* | 398 | /* |
395 | * Log the edge gpio and manually trigger the IRQ | 399 | * Log the edge gpio and manually trigger the IRQ |
396 | * after resume if the input level changes | 400 | * after resume if the input level changes |
@@ -403,7 +407,6 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, | |||
403 | bank->enabled_non_wakeup_gpios &= ~gpio_bit; | 407 | bank->enabled_non_wakeup_gpios &= ~gpio_bit; |
404 | } | 408 | } |
405 | 409 | ||
406 | exit: | ||
407 | bank->level_mask = | 410 | bank->level_mask = |
408 | readl_relaxed(bank->base + bank->regs->leveldetect0) | | 411 | readl_relaxed(bank->base + bank->regs->leveldetect0) | |
409 | readl_relaxed(bank->base + bank->regs->leveldetect1); | 412 | readl_relaxed(bank->base + bank->regs->leveldetect1); |
@@ -896,44 +899,6 @@ static void omap_gpio_unmask_irq(struct irq_data *d) | |||
896 | raw_spin_unlock_irqrestore(&bank->lock, flags); | 899 | raw_spin_unlock_irqrestore(&bank->lock, flags); |
897 | } | 900 | } |
898 | 901 | ||
899 | /* | ||
900 | * Only edges can generate a wakeup event to the PRCM. | ||
901 | * | ||
902 | * Therefore, ensure any wake-up capable GPIOs have | ||
903 | * edge-detection enabled before going idle to ensure a wakeup | ||
904 | * to the PRCM is generated on a GPIO transition. (c.f. 34xx | ||
905 | * NDA TRM 25.5.3.1) | ||
906 | * | ||
907 | * The normal values will be restored upon ->runtime_resume() | ||
908 | * by writing back the values saved in bank->context. | ||
909 | */ | ||
910 | static void __maybe_unused | ||
911 | omap2_gpio_enable_level_quirk(struct gpio_bank *bank) | ||
912 | { | ||
913 | u32 wake_low, wake_hi; | ||
914 | |||
915 | /* Enable additional edge detection for level gpios for idle */ | ||
916 | wake_low = bank->context.leveldetect0 & bank->context.wake_en; | ||
917 | if (wake_low) | ||
918 | writel_relaxed(wake_low | bank->context.fallingdetect, | ||
919 | bank->base + bank->regs->fallingdetect); | ||
920 | |||
921 | wake_hi = bank->context.leveldetect1 & bank->context.wake_en; | ||
922 | if (wake_hi) | ||
923 | writel_relaxed(wake_hi | bank->context.risingdetect, | ||
924 | bank->base + bank->regs->risingdetect); | ||
925 | } | ||
926 | |||
927 | static void __maybe_unused | ||
928 | omap2_gpio_disable_level_quirk(struct gpio_bank *bank) | ||
929 | { | ||
930 | /* Disable edge detection for level gpios after idle */ | ||
931 | writel_relaxed(bank->context.fallingdetect, | ||
932 | bank->base + bank->regs->fallingdetect); | ||
933 | writel_relaxed(bank->context.risingdetect, | ||
934 | bank->base + bank->regs->risingdetect); | ||
935 | } | ||
936 | |||
937 | /*---------------------------------------------------------------------*/ | 902 | /*---------------------------------------------------------------------*/ |
938 | 903 | ||
939 | static int omap_mpuio_suspend_noirq(struct device *dev) | 904 | static int omap_mpuio_suspend_noirq(struct device *dev) |
@@ -1251,203 +1216,70 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1251 | return ret; | 1216 | return ret; |
1252 | } | 1217 | } |
1253 | 1218 | ||
1254 | static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context); | 1219 | static void omap_gpio_init_context(struct gpio_bank *p) |
1255 | static void omap_gpio_unidle(struct gpio_bank *bank); | ||
1256 | |||
1257 | static int gpio_omap_cpu_notifier(struct notifier_block *nb, | ||
1258 | unsigned long cmd, void *v) | ||
1259 | { | 1220 | { |
1260 | struct gpio_bank *bank; | 1221 | struct omap_gpio_reg_offs *regs = p->regs; |
1261 | unsigned long flags; | 1222 | void __iomem *base = p->base; |
1262 | 1223 | ||
1263 | bank = container_of(nb, struct gpio_bank, nb); | 1224 | p->context.ctrl = readl_relaxed(base + regs->ctrl); |
1225 | p->context.oe = readl_relaxed(base + regs->direction); | ||
1226 | p->context.wake_en = readl_relaxed(base + regs->wkup_en); | ||
1227 | p->context.leveldetect0 = readl_relaxed(base + regs->leveldetect0); | ||
1228 | p->context.leveldetect1 = readl_relaxed(base + regs->leveldetect1); | ||
1229 | p->context.risingdetect = readl_relaxed(base + regs->risingdetect); | ||
1230 | p->context.fallingdetect = readl_relaxed(base + regs->fallingdetect); | ||
1231 | p->context.irqenable1 = readl_relaxed(base + regs->irqenable); | ||
1232 | p->context.irqenable2 = readl_relaxed(base + regs->irqenable2); | ||
1264 | 1233 | ||
1265 | raw_spin_lock_irqsave(&bank->lock, flags); | 1234 | if (regs->set_dataout && p->regs->clr_dataout) |
1266 | switch (cmd) { | 1235 | p->context.dataout = readl_relaxed(base + regs->set_dataout); |
1267 | case CPU_CLUSTER_PM_ENTER: | 1236 | else |
1268 | if (bank->is_suspended) | 1237 | p->context.dataout = readl_relaxed(base + regs->dataout); |
1269 | break; | ||
1270 | omap_gpio_idle(bank, true); | ||
1271 | break; | ||
1272 | case CPU_CLUSTER_PM_ENTER_FAILED: | ||
1273 | case CPU_CLUSTER_PM_EXIT: | ||
1274 | if (bank->is_suspended) | ||
1275 | break; | ||
1276 | omap_gpio_unidle(bank); | ||
1277 | break; | ||
1278 | } | ||
1279 | raw_spin_unlock_irqrestore(&bank->lock, flags); | ||
1280 | 1238 | ||
1281 | return NOTIFY_OK; | 1239 | p->context_valid = true; |
1282 | } | 1240 | } |
1283 | 1241 | ||
1284 | static const struct of_device_id omap_gpio_match[]; | 1242 | static void omap_gpio_restore_context(struct gpio_bank *bank) |
1285 | |||
1286 | static int omap_gpio_probe(struct platform_device *pdev) | ||
1287 | { | 1243 | { |
1288 | struct device *dev = &pdev->dev; | 1244 | writel_relaxed(bank->context.wake_en, |
1289 | struct device_node *node = dev->of_node; | 1245 | bank->base + bank->regs->wkup_en); |
1290 | const struct of_device_id *match; | 1246 | writel_relaxed(bank->context.ctrl, bank->base + bank->regs->ctrl); |
1291 | const struct omap_gpio_platform_data *pdata; | 1247 | writel_relaxed(bank->context.leveldetect0, |
1292 | struct resource *res; | 1248 | bank->base + bank->regs->leveldetect0); |
1293 | struct gpio_bank *bank; | 1249 | writel_relaxed(bank->context.leveldetect1, |
1294 | struct irq_chip *irqc; | 1250 | bank->base + bank->regs->leveldetect1); |
1295 | int ret; | 1251 | writel_relaxed(bank->context.risingdetect, |
1296 | 1252 | bank->base + bank->regs->risingdetect); | |
1297 | match = of_match_device(of_match_ptr(omap_gpio_match), dev); | 1253 | writel_relaxed(bank->context.fallingdetect, |
1298 | 1254 | bank->base + bank->regs->fallingdetect); | |
1299 | pdata = match ? match->data : dev_get_platdata(dev); | 1255 | if (bank->regs->set_dataout && bank->regs->clr_dataout) |
1300 | if (!pdata) | 1256 | writel_relaxed(bank->context.dataout, |
1301 | return -EINVAL; | 1257 | bank->base + bank->regs->set_dataout); |
1302 | 1258 | else | |
1303 | bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); | 1259 | writel_relaxed(bank->context.dataout, |
1304 | if (!bank) | 1260 | bank->base + bank->regs->dataout); |
1305 | return -ENOMEM; | 1261 | writel_relaxed(bank->context.oe, bank->base + bank->regs->direction); |
1306 | |||
1307 | irqc = devm_kzalloc(dev, sizeof(*irqc), GFP_KERNEL); | ||
1308 | if (!irqc) | ||
1309 | return -ENOMEM; | ||
1310 | |||
1311 | irqc->irq_startup = omap_gpio_irq_startup, | ||
1312 | irqc->irq_shutdown = omap_gpio_irq_shutdown, | ||
1313 | irqc->irq_ack = omap_gpio_ack_irq, | ||
1314 | irqc->irq_mask = omap_gpio_mask_irq, | ||
1315 | irqc->irq_unmask = omap_gpio_unmask_irq, | ||
1316 | irqc->irq_set_type = omap_gpio_irq_type, | ||
1317 | irqc->irq_set_wake = omap_gpio_wake_enable, | ||
1318 | irqc->irq_bus_lock = omap_gpio_irq_bus_lock, | ||
1319 | irqc->irq_bus_sync_unlock = gpio_irq_bus_sync_unlock, | ||
1320 | irqc->name = dev_name(&pdev->dev); | ||
1321 | irqc->flags = IRQCHIP_MASK_ON_SUSPEND; | ||
1322 | irqc->parent_device = dev; | ||
1323 | |||
1324 | bank->irq = platform_get_irq(pdev, 0); | ||
1325 | if (bank->irq <= 0) { | ||
1326 | if (!bank->irq) | ||
1327 | bank->irq = -ENXIO; | ||
1328 | if (bank->irq != -EPROBE_DEFER) | ||
1329 | dev_err(dev, | ||
1330 | "can't get irq resource ret=%d\n", bank->irq); | ||
1331 | return bank->irq; | ||
1332 | } | ||
1333 | |||
1334 | bank->chip.parent = dev; | ||
1335 | bank->chip.owner = THIS_MODULE; | ||
1336 | bank->dbck_flag = pdata->dbck_flag; | ||
1337 | bank->quirks = pdata->quirks; | ||
1338 | bank->stride = pdata->bank_stride; | ||
1339 | bank->width = pdata->bank_width; | ||
1340 | bank->is_mpuio = pdata->is_mpuio; | ||
1341 | bank->non_wakeup_gpios = pdata->non_wakeup_gpios; | ||
1342 | bank->regs = pdata->regs; | ||
1343 | #ifdef CONFIG_OF_GPIO | ||
1344 | bank->chip.of_node = of_node_get(node); | ||
1345 | #endif | ||
1346 | |||
1347 | if (node) { | ||
1348 | if (!of_property_read_bool(node, "ti,gpio-always-on")) | ||
1349 | bank->loses_context = true; | ||
1350 | } else { | ||
1351 | bank->loses_context = pdata->loses_context; | ||
1352 | |||
1353 | if (bank->loses_context) | ||
1354 | bank->get_context_loss_count = | ||
1355 | pdata->get_context_loss_count; | ||
1356 | } | ||
1357 | |||
1358 | if (bank->regs->set_dataout && bank->regs->clr_dataout) { | ||
1359 | bank->set_dataout = omap_set_gpio_dataout_reg; | ||
1360 | bank->set_dataout_multiple = omap_set_gpio_dataout_reg_multiple; | ||
1361 | } else { | ||
1362 | bank->set_dataout = omap_set_gpio_dataout_mask; | ||
1363 | bank->set_dataout_multiple = | ||
1364 | omap_set_gpio_dataout_mask_multiple; | ||
1365 | } | ||
1366 | |||
1367 | if (bank->quirks & OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER) { | ||
1368 | bank->funcs.idle_enable_level_quirk = | ||
1369 | omap2_gpio_enable_level_quirk; | ||
1370 | bank->funcs.idle_disable_level_quirk = | ||
1371 | omap2_gpio_disable_level_quirk; | ||
1372 | } | ||
1373 | |||
1374 | raw_spin_lock_init(&bank->lock); | ||
1375 | raw_spin_lock_init(&bank->wa_lock); | ||
1376 | |||
1377 | /* Static mapping, never released */ | ||
1378 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1379 | bank->base = devm_ioremap_resource(dev, res); | ||
1380 | if (IS_ERR(bank->base)) { | ||
1381 | return PTR_ERR(bank->base); | ||
1382 | } | ||
1383 | |||
1384 | if (bank->dbck_flag) { | ||
1385 | bank->dbck = devm_clk_get(dev, "dbclk"); | ||
1386 | if (IS_ERR(bank->dbck)) { | ||
1387 | dev_err(dev, | ||
1388 | "Could not get gpio dbck. Disable debounce\n"); | ||
1389 | bank->dbck_flag = false; | ||
1390 | } else { | ||
1391 | clk_prepare(bank->dbck); | ||
1392 | } | ||
1393 | } | ||
1394 | |||
1395 | platform_set_drvdata(pdev, bank); | ||
1396 | |||
1397 | pm_runtime_enable(dev); | ||
1398 | pm_runtime_get_sync(dev); | ||
1399 | |||
1400 | if (bank->is_mpuio) | ||
1401 | omap_mpuio_init(bank); | ||
1402 | |||
1403 | omap_gpio_mod_init(bank); | ||
1404 | |||
1405 | ret = omap_gpio_chip_init(bank, irqc); | ||
1406 | if (ret) { | ||
1407 | pm_runtime_put_sync(dev); | ||
1408 | pm_runtime_disable(dev); | ||
1409 | if (bank->dbck_flag) | ||
1410 | clk_unprepare(bank->dbck); | ||
1411 | return ret; | ||
1412 | } | ||
1413 | |||
1414 | omap_gpio_show_rev(bank); | ||
1415 | 1262 | ||
1416 | if (bank->funcs.idle_enable_level_quirk && | 1263 | if (bank->dbck_enable_mask) { |
1417 | bank->funcs.idle_disable_level_quirk) { | 1264 | writel_relaxed(bank->context.debounce, bank->base + |
1418 | bank->nb.notifier_call = gpio_omap_cpu_notifier; | 1265 | bank->regs->debounce); |
1419 | cpu_pm_register_notifier(&bank->nb); | 1266 | writel_relaxed(bank->context.debounce_en, |
1267 | bank->base + bank->regs->debounce_en); | ||
1420 | } | 1268 | } |
1421 | 1269 | ||
1422 | pm_runtime_put(dev); | 1270 | writel_relaxed(bank->context.irqenable1, |
1423 | 1271 | bank->base + bank->regs->irqenable); | |
1424 | return 0; | 1272 | writel_relaxed(bank->context.irqenable2, |
1425 | } | 1273 | bank->base + bank->regs->irqenable2); |
1426 | |||
1427 | static int omap_gpio_remove(struct platform_device *pdev) | ||
1428 | { | ||
1429 | struct gpio_bank *bank = platform_get_drvdata(pdev); | ||
1430 | |||
1431 | if (bank->nb.notifier_call) | ||
1432 | cpu_pm_unregister_notifier(&bank->nb); | ||
1433 | list_del(&bank->node); | ||
1434 | gpiochip_remove(&bank->chip); | ||
1435 | pm_runtime_disable(&pdev->dev); | ||
1436 | if (bank->dbck_flag) | ||
1437 | clk_unprepare(bank->dbck); | ||
1438 | |||
1439 | return 0; | ||
1440 | } | 1274 | } |
1441 | 1275 | ||
1442 | static void omap_gpio_restore_context(struct gpio_bank *bank); | ||
1443 | |||
1444 | static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context) | 1276 | static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context) |
1445 | { | 1277 | { |
1446 | struct device *dev = bank->chip.parent; | 1278 | struct device *dev = bank->chip.parent; |
1447 | u32 l1 = 0, l2 = 0; | 1279 | void __iomem *base = bank->base; |
1280 | u32 nowake; | ||
1448 | 1281 | ||
1449 | if (bank->funcs.idle_enable_level_quirk) | 1282 | bank->saved_datain = readl_relaxed(base + bank->regs->datain); |
1450 | bank->funcs.idle_enable_level_quirk(bank); | ||
1451 | 1283 | ||
1452 | if (!bank->enabled_non_wakeup_gpios) | 1284 | if (!bank->enabled_non_wakeup_gpios) |
1453 | goto update_gpio_context_count; | 1285 | goto update_gpio_context_count; |
@@ -1456,22 +1288,15 @@ static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context) | |||
1456 | goto update_gpio_context_count; | 1288 | goto update_gpio_context_count; |
1457 | 1289 | ||
1458 | /* | 1290 | /* |
1459 | * If going to OFF, remove triggering for all | 1291 | * If going to OFF, remove triggering for all wkup domain |
1460 | * non-wakeup GPIOs. Otherwise spurious IRQs will be | 1292 | * non-wakeup GPIOs. Otherwise spurious IRQs will be |
1461 | * generated. See OMAP2420 Errata item 1.101. | 1293 | * generated. See OMAP2420 Errata item 1.101. |
1462 | */ | 1294 | */ |
1463 | bank->saved_datain = readl_relaxed(bank->base + | 1295 | if (!bank->loses_context && bank->enabled_non_wakeup_gpios) { |
1464 | bank->regs->datain); | 1296 | nowake = bank->enabled_non_wakeup_gpios; |
1465 | l1 = bank->context.fallingdetect; | 1297 | omap_gpio_rmw(base, bank->regs->fallingdetect, nowake, ~nowake); |
1466 | l2 = bank->context.risingdetect; | 1298 | omap_gpio_rmw(base, bank->regs->risingdetect, nowake, ~nowake); |
1467 | 1299 | } | |
1468 | l1 &= ~bank->enabled_non_wakeup_gpios; | ||
1469 | l2 &= ~bank->enabled_non_wakeup_gpios; | ||
1470 | |||
1471 | writel_relaxed(l1, bank->base + bank->regs->fallingdetect); | ||
1472 | writel_relaxed(l2, bank->base + bank->regs->risingdetect); | ||
1473 | |||
1474 | bank->workaround_enabled = true; | ||
1475 | 1300 | ||
1476 | update_gpio_context_count: | 1301 | update_gpio_context_count: |
1477 | if (bank->get_context_loss_count) | 1302 | if (bank->get_context_loss_count) |
@@ -1481,8 +1306,6 @@ update_gpio_context_count: | |||
1481 | omap_gpio_dbck_disable(bank); | 1306 | omap_gpio_dbck_disable(bank); |
1482 | } | 1307 | } |
1483 | 1308 | ||
1484 | static void omap_gpio_init_context(struct gpio_bank *p); | ||
1485 | |||
1486 | static void omap_gpio_unidle(struct gpio_bank *bank) | 1309 | static void omap_gpio_unidle(struct gpio_bank *bank) |
1487 | { | 1310 | { |
1488 | struct device *dev = bank->chip.parent; | 1311 | struct device *dev = bank->chip.parent; |
@@ -1504,9 +1327,6 @@ static void omap_gpio_unidle(struct gpio_bank *bank) | |||
1504 | 1327 | ||
1505 | omap_gpio_dbck_enable(bank); | 1328 | omap_gpio_dbck_enable(bank); |
1506 | 1329 | ||
1507 | if (bank->funcs.idle_disable_level_quirk) | ||
1508 | bank->funcs.idle_disable_level_quirk(bank); | ||
1509 | |||
1510 | if (bank->loses_context) { | 1330 | if (bank->loses_context) { |
1511 | if (!bank->get_context_loss_count) { | 1331 | if (!bank->get_context_loss_count) { |
1512 | omap_gpio_restore_context(bank); | 1332 | omap_gpio_restore_context(bank); |
@@ -1518,11 +1338,14 @@ static void omap_gpio_unidle(struct gpio_bank *bank) | |||
1518 | return; | 1338 | return; |
1519 | } | 1339 | } |
1520 | } | 1340 | } |
1341 | } else { | ||
1342 | /* Restore changes done for OMAP2420 errata 1.101 */ | ||
1343 | writel_relaxed(bank->context.fallingdetect, | ||
1344 | bank->base + bank->regs->fallingdetect); | ||
1345 | writel_relaxed(bank->context.risingdetect, | ||
1346 | bank->base + bank->regs->risingdetect); | ||
1521 | } | 1347 | } |
1522 | 1348 | ||
1523 | if (!bank->workaround_enabled) | ||
1524 | return; | ||
1525 | |||
1526 | l = readl_relaxed(bank->base + bank->regs->datain); | 1349 | l = readl_relaxed(bank->base + bank->regs->datain); |
1527 | 1350 | ||
1528 | /* | 1351 | /* |
@@ -1572,117 +1395,35 @@ static void omap_gpio_unidle(struct gpio_bank *bank) | |||
1572 | writel_relaxed(old0, bank->base + bank->regs->leveldetect0); | 1395 | writel_relaxed(old0, bank->base + bank->regs->leveldetect0); |
1573 | writel_relaxed(old1, bank->base + bank->regs->leveldetect1); | 1396 | writel_relaxed(old1, bank->base + bank->regs->leveldetect1); |
1574 | } | 1397 | } |
1575 | |||
1576 | bank->workaround_enabled = false; | ||
1577 | } | ||
1578 | |||
1579 | static void omap_gpio_init_context(struct gpio_bank *p) | ||
1580 | { | ||
1581 | struct omap_gpio_reg_offs *regs = p->regs; | ||
1582 | void __iomem *base = p->base; | ||
1583 | |||
1584 | p->context.ctrl = readl_relaxed(base + regs->ctrl); | ||
1585 | p->context.oe = readl_relaxed(base + regs->direction); | ||
1586 | p->context.wake_en = readl_relaxed(base + regs->wkup_en); | ||
1587 | p->context.leveldetect0 = readl_relaxed(base + regs->leveldetect0); | ||
1588 | p->context.leveldetect1 = readl_relaxed(base + regs->leveldetect1); | ||
1589 | p->context.risingdetect = readl_relaxed(base + regs->risingdetect); | ||
1590 | p->context.fallingdetect = readl_relaxed(base + regs->fallingdetect); | ||
1591 | p->context.irqenable1 = readl_relaxed(base + regs->irqenable); | ||
1592 | p->context.irqenable2 = readl_relaxed(base + regs->irqenable2); | ||
1593 | |||
1594 | if (regs->set_dataout && p->regs->clr_dataout) | ||
1595 | p->context.dataout = readl_relaxed(base + regs->set_dataout); | ||
1596 | else | ||
1597 | p->context.dataout = readl_relaxed(base + regs->dataout); | ||
1598 | |||
1599 | p->context_valid = true; | ||
1600 | } | ||
1601 | |||
1602 | static void omap_gpio_restore_context(struct gpio_bank *bank) | ||
1603 | { | ||
1604 | writel_relaxed(bank->context.wake_en, | ||
1605 | bank->base + bank->regs->wkup_en); | ||
1606 | writel_relaxed(bank->context.ctrl, bank->base + bank->regs->ctrl); | ||
1607 | writel_relaxed(bank->context.leveldetect0, | ||
1608 | bank->base + bank->regs->leveldetect0); | ||
1609 | writel_relaxed(bank->context.leveldetect1, | ||
1610 | bank->base + bank->regs->leveldetect1); | ||
1611 | writel_relaxed(bank->context.risingdetect, | ||
1612 | bank->base + bank->regs->risingdetect); | ||
1613 | writel_relaxed(bank->context.fallingdetect, | ||
1614 | bank->base + bank->regs->fallingdetect); | ||
1615 | if (bank->regs->set_dataout && bank->regs->clr_dataout) | ||
1616 | writel_relaxed(bank->context.dataout, | ||
1617 | bank->base + bank->regs->set_dataout); | ||
1618 | else | ||
1619 | writel_relaxed(bank->context.dataout, | ||
1620 | bank->base + bank->regs->dataout); | ||
1621 | writel_relaxed(bank->context.oe, bank->base + bank->regs->direction); | ||
1622 | |||
1623 | if (bank->dbck_enable_mask) { | ||
1624 | writel_relaxed(bank->context.debounce, bank->base + | ||
1625 | bank->regs->debounce); | ||
1626 | writel_relaxed(bank->context.debounce_en, | ||
1627 | bank->base + bank->regs->debounce_en); | ||
1628 | } | ||
1629 | |||
1630 | writel_relaxed(bank->context.irqenable1, | ||
1631 | bank->base + bank->regs->irqenable); | ||
1632 | writel_relaxed(bank->context.irqenable2, | ||
1633 | bank->base + bank->regs->irqenable2); | ||
1634 | } | 1398 | } |
1635 | 1399 | ||
1636 | static int __maybe_unused omap_gpio_runtime_suspend(struct device *dev) | 1400 | static int gpio_omap_cpu_notifier(struct notifier_block *nb, |
1401 | unsigned long cmd, void *v) | ||
1637 | { | 1402 | { |
1638 | struct gpio_bank *bank = dev_get_drvdata(dev); | 1403 | struct gpio_bank *bank; |
1639 | unsigned long flags; | 1404 | unsigned long flags; |
1640 | int error = 0; | ||
1641 | |||
1642 | raw_spin_lock_irqsave(&bank->lock, flags); | ||
1643 | /* Must be idled only by CPU_CLUSTER_PM_ENTER? */ | ||
1644 | if (bank->irq_usage) { | ||
1645 | error = -EBUSY; | ||
1646 | goto unlock; | ||
1647 | } | ||
1648 | omap_gpio_idle(bank, true); | ||
1649 | bank->is_suspended = true; | ||
1650 | unlock: | ||
1651 | raw_spin_unlock_irqrestore(&bank->lock, flags); | ||
1652 | |||
1653 | return error; | ||
1654 | } | ||
1655 | 1405 | ||
1656 | static int __maybe_unused omap_gpio_runtime_resume(struct device *dev) | 1406 | bank = container_of(nb, struct gpio_bank, nb); |
1657 | { | ||
1658 | struct gpio_bank *bank = dev_get_drvdata(dev); | ||
1659 | unsigned long flags; | ||
1660 | int error = 0; | ||
1661 | 1407 | ||
1662 | raw_spin_lock_irqsave(&bank->lock, flags); | 1408 | raw_spin_lock_irqsave(&bank->lock, flags); |
1663 | /* Must be unidled only by CPU_CLUSTER_PM_ENTER? */ | 1409 | switch (cmd) { |
1664 | if (bank->irq_usage) { | 1410 | case CPU_CLUSTER_PM_ENTER: |
1665 | error = -EBUSY; | 1411 | if (bank->is_suspended) |
1666 | goto unlock; | 1412 | break; |
1413 | omap_gpio_idle(bank, true); | ||
1414 | break; | ||
1415 | case CPU_CLUSTER_PM_ENTER_FAILED: | ||
1416 | case CPU_CLUSTER_PM_EXIT: | ||
1417 | if (bank->is_suspended) | ||
1418 | break; | ||
1419 | omap_gpio_unidle(bank); | ||
1420 | break; | ||
1667 | } | 1421 | } |
1668 | omap_gpio_unidle(bank); | ||
1669 | bank->is_suspended = false; | ||
1670 | unlock: | ||
1671 | raw_spin_unlock_irqrestore(&bank->lock, flags); | 1422 | raw_spin_unlock_irqrestore(&bank->lock, flags); |
1672 | 1423 | ||
1673 | return error; | 1424 | return NOTIFY_OK; |
1674 | } | 1425 | } |
1675 | 1426 | ||
1676 | #ifdef CONFIG_ARCH_OMAP2PLUS | ||
1677 | static const struct dev_pm_ops gpio_pm_ops = { | ||
1678 | SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume, | ||
1679 | NULL) | ||
1680 | }; | ||
1681 | #else | ||
1682 | static const struct dev_pm_ops gpio_pm_ops; | ||
1683 | #endif /* CONFIG_ARCH_OMAP2PLUS */ | ||
1684 | |||
1685 | #if defined(CONFIG_OF) | ||
1686 | static struct omap_gpio_reg_offs omap2_gpio_regs = { | 1427 | static struct omap_gpio_reg_offs omap2_gpio_regs = { |
1687 | .revision = OMAP24XX_GPIO_REVISION, | 1428 | .revision = OMAP24XX_GPIO_REVISION, |
1688 | .direction = OMAP24XX_GPIO_OE, | 1429 | .direction = OMAP24XX_GPIO_OE, |
@@ -1729,11 +1470,6 @@ static struct omap_gpio_reg_offs omap4_gpio_regs = { | |||
1729 | .fallingdetect = OMAP4_GPIO_FALLINGDETECT, | 1470 | .fallingdetect = OMAP4_GPIO_FALLINGDETECT, |
1730 | }; | 1471 | }; |
1731 | 1472 | ||
1732 | /* | ||
1733 | * Note that omap2 does not currently support idle modes with context loss so | ||
1734 | * no need to add OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER quirk flag to save | ||
1735 | * and restore context. | ||
1736 | */ | ||
1737 | static const struct omap_gpio_platform_data omap2_pdata = { | 1473 | static const struct omap_gpio_platform_data omap2_pdata = { |
1738 | .regs = &omap2_gpio_regs, | 1474 | .regs = &omap2_gpio_regs, |
1739 | .bank_width = 32, | 1475 | .bank_width = 32, |
@@ -1744,14 +1480,12 @@ static const struct omap_gpio_platform_data omap3_pdata = { | |||
1744 | .regs = &omap2_gpio_regs, | 1480 | .regs = &omap2_gpio_regs, |
1745 | .bank_width = 32, | 1481 | .bank_width = 32, |
1746 | .dbck_flag = true, | 1482 | .dbck_flag = true, |
1747 | .quirks = OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER, | ||
1748 | }; | 1483 | }; |
1749 | 1484 | ||
1750 | static const struct omap_gpio_platform_data omap4_pdata = { | 1485 | static const struct omap_gpio_platform_data omap4_pdata = { |
1751 | .regs = &omap4_gpio_regs, | 1486 | .regs = &omap4_gpio_regs, |
1752 | .bank_width = 32, | 1487 | .bank_width = 32, |
1753 | .dbck_flag = true, | 1488 | .dbck_flag = true, |
1754 | .quirks = OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER, | ||
1755 | }; | 1489 | }; |
1756 | 1490 | ||
1757 | static const struct of_device_id omap_gpio_match[] = { | 1491 | static const struct of_device_id omap_gpio_match[] = { |
@@ -1770,15 +1504,187 @@ static const struct of_device_id omap_gpio_match[] = { | |||
1770 | { }, | 1504 | { }, |
1771 | }; | 1505 | }; |
1772 | MODULE_DEVICE_TABLE(of, omap_gpio_match); | 1506 | MODULE_DEVICE_TABLE(of, omap_gpio_match); |
1507 | |||
1508 | static int omap_gpio_probe(struct platform_device *pdev) | ||
1509 | { | ||
1510 | struct device *dev = &pdev->dev; | ||
1511 | struct device_node *node = dev->of_node; | ||
1512 | const struct of_device_id *match; | ||
1513 | const struct omap_gpio_platform_data *pdata; | ||
1514 | struct gpio_bank *bank; | ||
1515 | struct irq_chip *irqc; | ||
1516 | int ret; | ||
1517 | |||
1518 | match = of_match_device(of_match_ptr(omap_gpio_match), dev); | ||
1519 | |||
1520 | pdata = match ? match->data : dev_get_platdata(dev); | ||
1521 | if (!pdata) | ||
1522 | return -EINVAL; | ||
1523 | |||
1524 | bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); | ||
1525 | if (!bank) | ||
1526 | return -ENOMEM; | ||
1527 | |||
1528 | irqc = devm_kzalloc(dev, sizeof(*irqc), GFP_KERNEL); | ||
1529 | if (!irqc) | ||
1530 | return -ENOMEM; | ||
1531 | |||
1532 | irqc->irq_startup = omap_gpio_irq_startup, | ||
1533 | irqc->irq_shutdown = omap_gpio_irq_shutdown, | ||
1534 | irqc->irq_ack = omap_gpio_ack_irq, | ||
1535 | irqc->irq_mask = omap_gpio_mask_irq, | ||
1536 | irqc->irq_unmask = omap_gpio_unmask_irq, | ||
1537 | irqc->irq_set_type = omap_gpio_irq_type, | ||
1538 | irqc->irq_set_wake = omap_gpio_wake_enable, | ||
1539 | irqc->irq_bus_lock = omap_gpio_irq_bus_lock, | ||
1540 | irqc->irq_bus_sync_unlock = gpio_irq_bus_sync_unlock, | ||
1541 | irqc->name = dev_name(&pdev->dev); | ||
1542 | irqc->flags = IRQCHIP_MASK_ON_SUSPEND; | ||
1543 | irqc->parent_device = dev; | ||
1544 | |||
1545 | bank->irq = platform_get_irq(pdev, 0); | ||
1546 | if (bank->irq <= 0) { | ||
1547 | if (!bank->irq) | ||
1548 | bank->irq = -ENXIO; | ||
1549 | if (bank->irq != -EPROBE_DEFER) | ||
1550 | dev_err(dev, | ||
1551 | "can't get irq resource ret=%d\n", bank->irq); | ||
1552 | return bank->irq; | ||
1553 | } | ||
1554 | |||
1555 | bank->chip.parent = dev; | ||
1556 | bank->chip.owner = THIS_MODULE; | ||
1557 | bank->dbck_flag = pdata->dbck_flag; | ||
1558 | bank->stride = pdata->bank_stride; | ||
1559 | bank->width = pdata->bank_width; | ||
1560 | bank->is_mpuio = pdata->is_mpuio; | ||
1561 | bank->non_wakeup_gpios = pdata->non_wakeup_gpios; | ||
1562 | bank->regs = pdata->regs; | ||
1563 | #ifdef CONFIG_OF_GPIO | ||
1564 | bank->chip.of_node = of_node_get(node); | ||
1773 | #endif | 1565 | #endif |
1774 | 1566 | ||
1567 | if (node) { | ||
1568 | if (!of_property_read_bool(node, "ti,gpio-always-on")) | ||
1569 | bank->loses_context = true; | ||
1570 | } else { | ||
1571 | bank->loses_context = pdata->loses_context; | ||
1572 | |||
1573 | if (bank->loses_context) | ||
1574 | bank->get_context_loss_count = | ||
1575 | pdata->get_context_loss_count; | ||
1576 | } | ||
1577 | |||
1578 | if (bank->regs->set_dataout && bank->regs->clr_dataout) { | ||
1579 | bank->set_dataout = omap_set_gpio_dataout_reg; | ||
1580 | bank->set_dataout_multiple = omap_set_gpio_dataout_reg_multiple; | ||
1581 | } else { | ||
1582 | bank->set_dataout = omap_set_gpio_dataout_mask; | ||
1583 | bank->set_dataout_multiple = | ||
1584 | omap_set_gpio_dataout_mask_multiple; | ||
1585 | } | ||
1586 | |||
1587 | raw_spin_lock_init(&bank->lock); | ||
1588 | raw_spin_lock_init(&bank->wa_lock); | ||
1589 | |||
1590 | /* Static mapping, never released */ | ||
1591 | bank->base = devm_platform_ioremap_resource(pdev, 0); | ||
1592 | if (IS_ERR(bank->base)) { | ||
1593 | return PTR_ERR(bank->base); | ||
1594 | } | ||
1595 | |||
1596 | if (bank->dbck_flag) { | ||
1597 | bank->dbck = devm_clk_get(dev, "dbclk"); | ||
1598 | if (IS_ERR(bank->dbck)) { | ||
1599 | dev_err(dev, | ||
1600 | "Could not get gpio dbck. Disable debounce\n"); | ||
1601 | bank->dbck_flag = false; | ||
1602 | } else { | ||
1603 | clk_prepare(bank->dbck); | ||
1604 | } | ||
1605 | } | ||
1606 | |||
1607 | platform_set_drvdata(pdev, bank); | ||
1608 | |||
1609 | pm_runtime_enable(dev); | ||
1610 | pm_runtime_get_sync(dev); | ||
1611 | |||
1612 | if (bank->is_mpuio) | ||
1613 | omap_mpuio_init(bank); | ||
1614 | |||
1615 | omap_gpio_mod_init(bank); | ||
1616 | |||
1617 | ret = omap_gpio_chip_init(bank, irqc); | ||
1618 | if (ret) { | ||
1619 | pm_runtime_put_sync(dev); | ||
1620 | pm_runtime_disable(dev); | ||
1621 | if (bank->dbck_flag) | ||
1622 | clk_unprepare(bank->dbck); | ||
1623 | return ret; | ||
1624 | } | ||
1625 | |||
1626 | omap_gpio_show_rev(bank); | ||
1627 | |||
1628 | bank->nb.notifier_call = gpio_omap_cpu_notifier; | ||
1629 | cpu_pm_register_notifier(&bank->nb); | ||
1630 | |||
1631 | pm_runtime_put(dev); | ||
1632 | |||
1633 | return 0; | ||
1634 | } | ||
1635 | |||
1636 | static int omap_gpio_remove(struct platform_device *pdev) | ||
1637 | { | ||
1638 | struct gpio_bank *bank = platform_get_drvdata(pdev); | ||
1639 | |||
1640 | cpu_pm_unregister_notifier(&bank->nb); | ||
1641 | list_del(&bank->node); | ||
1642 | gpiochip_remove(&bank->chip); | ||
1643 | pm_runtime_disable(&pdev->dev); | ||
1644 | if (bank->dbck_flag) | ||
1645 | clk_unprepare(bank->dbck); | ||
1646 | |||
1647 | return 0; | ||
1648 | } | ||
1649 | |||
1650 | static int __maybe_unused omap_gpio_runtime_suspend(struct device *dev) | ||
1651 | { | ||
1652 | struct gpio_bank *bank = dev_get_drvdata(dev); | ||
1653 | unsigned long flags; | ||
1654 | |||
1655 | raw_spin_lock_irqsave(&bank->lock, flags); | ||
1656 | omap_gpio_idle(bank, true); | ||
1657 | bank->is_suspended = true; | ||
1658 | raw_spin_unlock_irqrestore(&bank->lock, flags); | ||
1659 | |||
1660 | return 0; | ||
1661 | } | ||
1662 | |||
1663 | static int __maybe_unused omap_gpio_runtime_resume(struct device *dev) | ||
1664 | { | ||
1665 | struct gpio_bank *bank = dev_get_drvdata(dev); | ||
1666 | unsigned long flags; | ||
1667 | |||
1668 | raw_spin_lock_irqsave(&bank->lock, flags); | ||
1669 | omap_gpio_unidle(bank); | ||
1670 | bank->is_suspended = false; | ||
1671 | raw_spin_unlock_irqrestore(&bank->lock, flags); | ||
1672 | |||
1673 | return 0; | ||
1674 | } | ||
1675 | |||
1676 | static const struct dev_pm_ops gpio_pm_ops = { | ||
1677 | SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume, | ||
1678 | NULL) | ||
1679 | }; | ||
1680 | |||
1775 | static struct platform_driver omap_gpio_driver = { | 1681 | static struct platform_driver omap_gpio_driver = { |
1776 | .probe = omap_gpio_probe, | 1682 | .probe = omap_gpio_probe, |
1777 | .remove = omap_gpio_remove, | 1683 | .remove = omap_gpio_remove, |
1778 | .driver = { | 1684 | .driver = { |
1779 | .name = "omap_gpio", | 1685 | .name = "omap_gpio", |
1780 | .pm = &gpio_pm_ops, | 1686 | .pm = &gpio_pm_ops, |
1781 | .of_match_table = of_match_ptr(omap_gpio_match), | 1687 | .of_match_table = omap_gpio_match, |
1782 | }, | 1688 | }, |
1783 | }; | 1689 | }; |
1784 | 1690 | ||
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 7e76830b3368..b7ef33f63392 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c | |||
@@ -73,6 +73,7 @@ | |||
73 | #define PCA_CHIP_TYPE(x) ((x) & PCA_TYPE_MASK) | 73 | #define PCA_CHIP_TYPE(x) ((x) & PCA_TYPE_MASK) |
74 | 74 | ||
75 | static const struct i2c_device_id pca953x_id[] = { | 75 | static const struct i2c_device_id pca953x_id[] = { |
76 | { "pca6416", 16 | PCA953X_TYPE | PCA_INT, }, | ||
76 | { "pca9505", 40 | PCA953X_TYPE | PCA_INT, }, | 77 | { "pca9505", 40 | PCA953X_TYPE | PCA_INT, }, |
77 | { "pca9534", 8 | PCA953X_TYPE | PCA_INT, }, | 78 | { "pca9534", 8 | PCA953X_TYPE | PCA_INT, }, |
78 | { "pca9535", 16 | PCA953X_TYPE | PCA_INT, }, | 79 | { "pca9535", 16 | PCA953X_TYPE | PCA_INT, }, |
@@ -153,6 +154,7 @@ struct pca953x_chip { | |||
153 | u8 irq_trig_fall[MAX_BANK]; | 154 | u8 irq_trig_fall[MAX_BANK]; |
154 | struct irq_chip irq_chip; | 155 | struct irq_chip irq_chip; |
155 | #endif | 156 | #endif |
157 | atomic_t wakeup_path; | ||
156 | 158 | ||
157 | struct i2c_client *client; | 159 | struct i2c_client *client; |
158 | struct gpio_chip gpio_chip; | 160 | struct gpio_chip gpio_chip; |
@@ -581,6 +583,11 @@ static int pca953x_irq_set_wake(struct irq_data *d, unsigned int on) | |||
581 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 583 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
582 | struct pca953x_chip *chip = gpiochip_get_data(gc); | 584 | struct pca953x_chip *chip = gpiochip_get_data(gc); |
583 | 585 | ||
586 | if (on) | ||
587 | atomic_inc(&chip->wakeup_path); | ||
588 | else | ||
589 | atomic_dec(&chip->wakeup_path); | ||
590 | |||
584 | return irq_set_irq_wake(chip->client->irq, on); | 591 | return irq_set_irq_wake(chip->client->irq, on); |
585 | } | 592 | } |
586 | 593 | ||
@@ -1100,7 +1107,10 @@ static int pca953x_suspend(struct device *dev) | |||
1100 | 1107 | ||
1101 | regcache_cache_only(chip->regmap, true); | 1108 | regcache_cache_only(chip->regmap, true); |
1102 | 1109 | ||
1103 | regulator_disable(chip->regulator); | 1110 | if (atomic_read(&chip->wakeup_path)) |
1111 | device_set_wakeup_path(dev); | ||
1112 | else | ||
1113 | regulator_disable(chip->regulator); | ||
1104 | 1114 | ||
1105 | return 0; | 1115 | return 0; |
1106 | } | 1116 | } |
@@ -1110,10 +1120,12 @@ static int pca953x_resume(struct device *dev) | |||
1110 | struct pca953x_chip *chip = dev_get_drvdata(dev); | 1120 | struct pca953x_chip *chip = dev_get_drvdata(dev); |
1111 | int ret; | 1121 | int ret; |
1112 | 1122 | ||
1113 | ret = regulator_enable(chip->regulator); | 1123 | if (!atomic_read(&chip->wakeup_path)) { |
1114 | if (ret != 0) { | 1124 | ret = regulator_enable(chip->regulator); |
1115 | dev_err(dev, "Failed to enable regulator: %d\n", ret); | 1125 | if (ret != 0) { |
1116 | return 0; | 1126 | dev_err(dev, "Failed to enable regulator: %d\n", ret); |
1127 | return 0; | ||
1128 | } | ||
1117 | } | 1129 | } |
1118 | 1130 | ||
1119 | regcache_cache_only(chip->regmap, false); | 1131 | regcache_cache_only(chip->regmap, false); |
@@ -1137,6 +1149,7 @@ static int pca953x_resume(struct device *dev) | |||
1137 | #define OF_957X(__nrgpio, __int) (void *)(__nrgpio | PCA957X_TYPE | __int) | 1149 | #define OF_957X(__nrgpio, __int) (void *)(__nrgpio | PCA957X_TYPE | __int) |
1138 | 1150 | ||
1139 | static const struct of_device_id pca953x_dt_ids[] = { | 1151 | static const struct of_device_id pca953x_dt_ids[] = { |
1152 | { .compatible = "nxp,pca6416", .data = OF_953X(16, PCA_INT), }, | ||
1140 | { .compatible = "nxp,pca9505", .data = OF_953X(40, PCA_INT), }, | 1153 | { .compatible = "nxp,pca9505", .data = OF_953X(40, PCA_INT), }, |
1141 | { .compatible = "nxp,pca9534", .data = OF_953X( 8, PCA_INT), }, | 1154 | { .compatible = "nxp,pca9534", .data = OF_953X( 8, PCA_INT), }, |
1142 | { .compatible = "nxp,pca9535", .data = OF_953X(16, PCA_INT), }, | 1155 | { .compatible = "nxp,pca9535", .data = OF_953X(16, PCA_INT), }, |
@@ -1152,6 +1165,7 @@ static const struct of_device_id pca953x_dt_ids[] = { | |||
1152 | { .compatible = "nxp,pca9575", .data = OF_957X(16, PCA_INT), }, | 1165 | { .compatible = "nxp,pca9575", .data = OF_957X(16, PCA_INT), }, |
1153 | { .compatible = "nxp,pca9698", .data = OF_953X(40, 0), }, | 1166 | { .compatible = "nxp,pca9698", .data = OF_953X(40, 0), }, |
1154 | 1167 | ||
1168 | { .compatible = "nxp,pcal6416", .data = OF_953X(16, PCA_LATCH_INT), }, | ||
1155 | { .compatible = "nxp,pcal6524", .data = OF_953X(24, PCA_LATCH_INT), }, | 1169 | { .compatible = "nxp,pcal6524", .data = OF_953X(24, PCA_LATCH_INT), }, |
1156 | { .compatible = "nxp,pcal9555a", .data = OF_953X(16, PCA_LATCH_INT), }, | 1170 | { .compatible = "nxp,pcal9555a", .data = OF_953X(16, PCA_LATCH_INT), }, |
1157 | 1171 | ||
@@ -1167,6 +1181,7 @@ static const struct of_device_id pca953x_dt_ids[] = { | |||
1167 | { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), }, | 1181 | { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), }, |
1168 | { .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), }, | 1182 | { .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), }, |
1169 | 1183 | ||
1184 | { .compatible = "onnn,cat9554", .data = OF_953X( 8, PCA_INT), }, | ||
1170 | { .compatible = "onnn,pca9654", .data = OF_953X( 8, PCA_INT), }, | 1185 | { .compatible = "onnn,pca9654", .data = OF_953X( 8, PCA_INT), }, |
1171 | 1186 | ||
1172 | { .compatible = "exar,xra1202", .data = OF_953X( 8, 0), }, | 1187 | { .compatible = "exar,xra1202", .data = OF_953X( 8, 0), }, |
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index bcc6be4a5cb2..26f77fdb217e 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c | |||
@@ -577,7 +577,7 @@ static int pxa_irq_domain_map(struct irq_domain *d, unsigned int irq, | |||
577 | return 0; | 577 | return 0; |
578 | } | 578 | } |
579 | 579 | ||
580 | const struct irq_domain_ops pxa_irq_domain_ops = { | 580 | static const struct irq_domain_ops pxa_irq_domain_ops = { |
581 | .map = pxa_irq_domain_map, | 581 | .map = pxa_irq_domain_map, |
582 | .xlate = irq_domain_xlate_twocell, | 582 | .xlate = irq_domain_xlate_twocell, |
583 | }; | 583 | }; |
@@ -622,7 +622,6 @@ static int pxa_gpio_probe(struct platform_device *pdev) | |||
622 | { | 622 | { |
623 | struct pxa_gpio_chip *pchip; | 623 | struct pxa_gpio_chip *pchip; |
624 | struct pxa_gpio_bank *c; | 624 | struct pxa_gpio_bank *c; |
625 | struct resource *res; | ||
626 | struct clk *clk; | 625 | struct clk *clk; |
627 | struct pxa_gpio_platform_data *info; | 626 | struct pxa_gpio_platform_data *info; |
628 | void __iomem *gpio_reg_base; | 627 | void __iomem *gpio_reg_base; |
@@ -665,11 +664,8 @@ static int pxa_gpio_probe(struct platform_device *pdev) | |||
665 | 664 | ||
666 | pchip->irq0 = irq0; | 665 | pchip->irq0 = irq0; |
667 | pchip->irq1 = irq1; | 666 | pchip->irq1 = irq1; |
668 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 667 | |
669 | if (!res) | 668 | gpio_reg_base = devm_platform_ioremap_resource(pdev, 0); |
670 | return -EINVAL; | ||
671 | gpio_reg_base = devm_ioremap(&pdev->dev, res->start, | ||
672 | resource_size(res)); | ||
673 | if (!gpio_reg_base) | 669 | if (!gpio_reg_base) |
674 | return -EINVAL; | 670 | return -EINVAL; |
675 | 671 | ||
@@ -816,7 +812,7 @@ static void pxa_gpio_resume(void) | |||
816 | #define pxa_gpio_resume NULL | 812 | #define pxa_gpio_resume NULL |
817 | #endif | 813 | #endif |
818 | 814 | ||
819 | struct syscore_ops pxa_gpio_syscore_ops = { | 815 | static struct syscore_ops pxa_gpio_syscore_ops = { |
820 | .suspend = pxa_gpio_suspend, | 816 | .suspend = pxa_gpio_suspend, |
821 | .resume = pxa_gpio_resume, | 817 | .resume = pxa_gpio_resume, |
822 | }; | 818 | }; |
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 500a3596aaf4..70e95fc4779f 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c | |||
@@ -430,7 +430,7 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) | |||
430 | static int gpio_rcar_probe(struct platform_device *pdev) | 430 | static int gpio_rcar_probe(struct platform_device *pdev) |
431 | { | 431 | { |
432 | struct gpio_rcar_priv *p; | 432 | struct gpio_rcar_priv *p; |
433 | struct resource *io, *irq; | 433 | struct resource *irq; |
434 | struct gpio_chip *gpio_chip; | 434 | struct gpio_chip *gpio_chip; |
435 | struct irq_chip *irq_chip; | 435 | struct irq_chip *irq_chip; |
436 | struct device *dev = &pdev->dev; | 436 | struct device *dev = &pdev->dev; |
@@ -461,8 +461,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) | |||
461 | goto err0; | 461 | goto err0; |
462 | } | 462 | } |
463 | 463 | ||
464 | io = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 464 | p->base = devm_platform_ioremap_resource(pdev, 0); |
465 | p->base = devm_ioremap_resource(dev, io); | ||
466 | if (IS_ERR(p->base)) { | 465 | if (IS_ERR(p->base)) { |
467 | ret = PTR_ERR(p->base); | 466 | ret = PTR_ERR(p->base); |
468 | goto err0; | 467 | goto err0; |
diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c index c333046d02b8..fb143f28c386 100644 --- a/drivers/gpio/gpio-sch.c +++ b/drivers/gpio/gpio-sch.c | |||
@@ -23,7 +23,6 @@ struct sch_gpio { | |||
23 | struct gpio_chip chip; | 23 | struct gpio_chip chip; |
24 | spinlock_t lock; | 24 | spinlock_t lock; |
25 | unsigned short iobase; | 25 | unsigned short iobase; |
26 | unsigned short core_base; | ||
27 | unsigned short resume_base; | 26 | unsigned short resume_base; |
28 | }; | 27 | }; |
29 | 28 | ||
@@ -166,7 +165,6 @@ static int sch_gpio_probe(struct platform_device *pdev) | |||
166 | 165 | ||
167 | switch (pdev->id) { | 166 | switch (pdev->id) { |
168 | case PCI_DEVICE_ID_INTEL_SCH_LPC: | 167 | case PCI_DEVICE_ID_INTEL_SCH_LPC: |
169 | sch->core_base = 0; | ||
170 | sch->resume_base = 10; | 168 | sch->resume_base = 10; |
171 | sch->chip.ngpio = 14; | 169 | sch->chip.ngpio = 14; |
172 | 170 | ||
@@ -185,19 +183,16 @@ static int sch_gpio_probe(struct platform_device *pdev) | |||
185 | break; | 183 | break; |
186 | 184 | ||
187 | case PCI_DEVICE_ID_INTEL_ITC_LPC: | 185 | case PCI_DEVICE_ID_INTEL_ITC_LPC: |
188 | sch->core_base = 0; | ||
189 | sch->resume_base = 5; | 186 | sch->resume_base = 5; |
190 | sch->chip.ngpio = 14; | 187 | sch->chip.ngpio = 14; |
191 | break; | 188 | break; |
192 | 189 | ||
193 | case PCI_DEVICE_ID_INTEL_CENTERTON_ILB: | 190 | case PCI_DEVICE_ID_INTEL_CENTERTON_ILB: |
194 | sch->core_base = 0; | ||
195 | sch->resume_base = 21; | 191 | sch->resume_base = 21; |
196 | sch->chip.ngpio = 30; | 192 | sch->chip.ngpio = 30; |
197 | break; | 193 | break; |
198 | 194 | ||
199 | case PCI_DEVICE_ID_INTEL_QUARK_X1000_ILB: | 195 | case PCI_DEVICE_ID_INTEL_QUARK_X1000_ILB: |
200 | sch->core_base = 0; | ||
201 | sch->resume_base = 2; | 196 | sch->resume_base = 2; |
202 | sch->chip.ngpio = 8; | 197 | sch->chip.ngpio = 8; |
203 | break; | 198 | break; |
diff --git a/drivers/gpio/gpio-spear-spics.c b/drivers/gpio/gpio-spear-spics.c index ee3039f091f4..6eca531b7d96 100644 --- a/drivers/gpio/gpio-spear-spics.c +++ b/drivers/gpio/gpio-spear-spics.c | |||
@@ -122,15 +122,13 @@ static int spics_gpio_probe(struct platform_device *pdev) | |||
122 | { | 122 | { |
123 | struct device_node *np = pdev->dev.of_node; | 123 | struct device_node *np = pdev->dev.of_node; |
124 | struct spear_spics *spics; | 124 | struct spear_spics *spics; |
125 | struct resource *res; | ||
126 | int ret; | 125 | int ret; |
127 | 126 | ||
128 | spics = devm_kzalloc(&pdev->dev, sizeof(*spics), GFP_KERNEL); | 127 | spics = devm_kzalloc(&pdev->dev, sizeof(*spics), GFP_KERNEL); |
129 | if (!spics) | 128 | if (!spics) |
130 | return -ENOMEM; | 129 | return -ENOMEM; |
131 | 130 | ||
132 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 131 | spics->base = devm_platform_ioremap_resource(pdev, 0); |
133 | spics->base = devm_ioremap_resource(&pdev->dev, res); | ||
134 | if (IS_ERR(spics->base)) | 132 | if (IS_ERR(spics->base)) |
135 | return PTR_ERR(spics->base); | 133 | return PTR_ERR(spics->base); |
136 | 134 | ||
diff --git a/drivers/gpio/gpio-sprd.c b/drivers/gpio/gpio-sprd.c index 55072d2b367f..f5c8b3a351d5 100644 --- a/drivers/gpio/gpio-sprd.c +++ b/drivers/gpio/gpio-sprd.c | |||
@@ -219,7 +219,6 @@ static int sprd_gpio_probe(struct platform_device *pdev) | |||
219 | { | 219 | { |
220 | struct gpio_irq_chip *irq; | 220 | struct gpio_irq_chip *irq; |
221 | struct sprd_gpio *sprd_gpio; | 221 | struct sprd_gpio *sprd_gpio; |
222 | struct resource *res; | ||
223 | int ret; | 222 | int ret; |
224 | 223 | ||
225 | sprd_gpio = devm_kzalloc(&pdev->dev, sizeof(*sprd_gpio), GFP_KERNEL); | 224 | sprd_gpio = devm_kzalloc(&pdev->dev, sizeof(*sprd_gpio), GFP_KERNEL); |
@@ -232,8 +231,7 @@ static int sprd_gpio_probe(struct platform_device *pdev) | |||
232 | return sprd_gpio->irq; | 231 | return sprd_gpio->irq; |
233 | } | 232 | } |
234 | 233 | ||
235 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 234 | sprd_gpio->base = devm_platform_ioremap_resource(pdev, 0); |
236 | sprd_gpio->base = devm_ioremap_resource(&pdev->dev, res); | ||
237 | if (IS_ERR(sprd_gpio->base)) | 235 | if (IS_ERR(sprd_gpio->base)) |
238 | return PTR_ERR(sprd_gpio->base); | 236 | return PTR_ERR(sprd_gpio->base); |
239 | 237 | ||
diff --git a/drivers/gpio/gpio-sta2x11.c b/drivers/gpio/gpio-sta2x11.c index 2283c869ad5d..a51c310708b8 100644 --- a/drivers/gpio/gpio-sta2x11.c +++ b/drivers/gpio/gpio-sta2x11.c | |||
@@ -360,7 +360,6 @@ static int gsta_probe(struct platform_device *dev) | |||
360 | struct pci_dev *pdev; | 360 | struct pci_dev *pdev; |
361 | struct sta2x11_gpio_pdata *gpio_pdata; | 361 | struct sta2x11_gpio_pdata *gpio_pdata; |
362 | struct gsta_gpio *chip; | 362 | struct gsta_gpio *chip; |
363 | struct resource *res; | ||
364 | 363 | ||
365 | pdev = *(struct pci_dev **)dev_get_platdata(&dev->dev); | 364 | pdev = *(struct pci_dev **)dev_get_platdata(&dev->dev); |
366 | gpio_pdata = dev_get_platdata(&pdev->dev); | 365 | gpio_pdata = dev_get_platdata(&pdev->dev); |
@@ -369,13 +368,11 @@ static int gsta_probe(struct platform_device *dev) | |||
369 | dev_err(&dev->dev, "no gpio config\n"); | 368 | dev_err(&dev->dev, "no gpio config\n"); |
370 | pr_debug("gpio config: %p\n", gpio_pdata); | 369 | pr_debug("gpio config: %p\n", gpio_pdata); |
371 | 370 | ||
372 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
373 | |||
374 | chip = devm_kzalloc(&dev->dev, sizeof(*chip), GFP_KERNEL); | 371 | chip = devm_kzalloc(&dev->dev, sizeof(*chip), GFP_KERNEL); |
375 | if (!chip) | 372 | if (!chip) |
376 | return -ENOMEM; | 373 | return -ENOMEM; |
377 | chip->dev = &dev->dev; | 374 | chip->dev = &dev->dev; |
378 | chip->reg_base = devm_ioremap_resource(&dev->dev, res); | 375 | chip->reg_base = devm_platform_ioremap_resource(dev, 0); |
379 | if (IS_ERR(chip->reg_base)) | 376 | if (IS_ERR(chip->reg_base)) |
380 | return PTR_ERR(chip->reg_base); | 377 | return PTR_ERR(chip->reg_base); |
381 | 378 | ||
diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c index 19972084c45b..8a319d56c5de 100644 --- a/drivers/gpio/gpio-stp-xway.c +++ b/drivers/gpio/gpio-stp-xway.c | |||
@@ -210,7 +210,6 @@ static int xway_stp_hw_init(struct xway_stp *chip) | |||
210 | 210 | ||
211 | static int xway_stp_probe(struct platform_device *pdev) | 211 | static int xway_stp_probe(struct platform_device *pdev) |
212 | { | 212 | { |
213 | struct resource *res; | ||
214 | u32 shadow, groups, dsl, phy; | 213 | u32 shadow, groups, dsl, phy; |
215 | struct xway_stp *chip; | 214 | struct xway_stp *chip; |
216 | struct clk *clk; | 215 | struct clk *clk; |
@@ -220,8 +219,7 @@ static int xway_stp_probe(struct platform_device *pdev) | |||
220 | if (!chip) | 219 | if (!chip) |
221 | return -ENOMEM; | 220 | return -ENOMEM; |
222 | 221 | ||
223 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 222 | chip->virt = devm_platform_ioremap_resource(pdev, 0); |
224 | chip->virt = devm_ioremap_resource(&pdev->dev, res); | ||
225 | if (IS_ERR(chip->virt)) | 223 | if (IS_ERR(chip->virt)) |
226 | return PTR_ERR(chip->virt); | 224 | return PTR_ERR(chip->virt); |
227 | 225 | ||
diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c index d5e5d19f4c0a..6bbac6c83f29 100644 --- a/drivers/gpio/gpio-tb10x.c +++ b/drivers/gpio/gpio-tb10x.c | |||
@@ -120,7 +120,6 @@ static irqreturn_t tb10x_gpio_irq_cascade(int irq, void *data) | |||
120 | static int tb10x_gpio_probe(struct platform_device *pdev) | 120 | static int tb10x_gpio_probe(struct platform_device *pdev) |
121 | { | 121 | { |
122 | struct tb10x_gpio *tb10x_gpio; | 122 | struct tb10x_gpio *tb10x_gpio; |
123 | struct resource *mem; | ||
124 | struct device *dev = &pdev->dev; | 123 | struct device *dev = &pdev->dev; |
125 | struct device_node *np = dev->of_node; | 124 | struct device_node *np = dev->of_node; |
126 | int ret = -EBUSY; | 125 | int ret = -EBUSY; |
@@ -136,8 +135,7 @@ static int tb10x_gpio_probe(struct platform_device *pdev) | |||
136 | if (tb10x_gpio == NULL) | 135 | if (tb10x_gpio == NULL) |
137 | return -ENOMEM; | 136 | return -ENOMEM; |
138 | 137 | ||
139 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 138 | tb10x_gpio->base = devm_platform_ioremap_resource(pdev, 0); |
140 | tb10x_gpio->base = devm_ioremap_resource(dev, mem); | ||
141 | if (IS_ERR(tb10x_gpio->base)) | 139 | if (IS_ERR(tb10x_gpio->base)) |
142 | return PTR_ERR(tb10x_gpio->base); | 140 | return PTR_ERR(tb10x_gpio->base); |
143 | 141 | ||
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 1ececf2c3282..6d9b6906b9d0 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c | |||
@@ -569,7 +569,6 @@ static const struct dev_pm_ops tegra_gpio_pm_ops = { | |||
569 | static int tegra_gpio_probe(struct platform_device *pdev) | 569 | static int tegra_gpio_probe(struct platform_device *pdev) |
570 | { | 570 | { |
571 | struct tegra_gpio_info *tgi; | 571 | struct tegra_gpio_info *tgi; |
572 | struct resource *res; | ||
573 | struct tegra_gpio_bank *bank; | 572 | struct tegra_gpio_bank *bank; |
574 | unsigned int gpio, i, j; | 573 | unsigned int gpio, i, j; |
575 | int ret; | 574 | int ret; |
@@ -645,8 +644,7 @@ static int tegra_gpio_probe(struct platform_device *pdev) | |||
645 | bank->tgi = tgi; | 644 | bank->tgi = tgi; |
646 | } | 645 | } |
647 | 646 | ||
648 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 647 | tgi->regs = devm_platform_ioremap_resource(pdev, 0); |
649 | tgi->regs = devm_ioremap_resource(&pdev->dev, res); | ||
650 | if (IS_ERR(tgi->regs)) | 648 | if (IS_ERR(tgi->regs)) |
651 | return PTR_ERR(tgi->regs); | 649 | return PTR_ERR(tgi->regs); |
652 | 650 | ||
diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c index 314e300d6ba3..1c70e831069c 100644 --- a/drivers/gpio/gpio-timberdale.c +++ b/drivers/gpio/gpio-timberdale.c | |||
@@ -229,7 +229,6 @@ static int timbgpio_probe(struct platform_device *pdev) | |||
229 | struct device *dev = &pdev->dev; | 229 | struct device *dev = &pdev->dev; |
230 | struct gpio_chip *gc; | 230 | struct gpio_chip *gc; |
231 | struct timbgpio *tgpio; | 231 | struct timbgpio *tgpio; |
232 | struct resource *iomem; | ||
233 | struct timbgpio_platform_data *pdata = dev_get_platdata(&pdev->dev); | 232 | struct timbgpio_platform_data *pdata = dev_get_platdata(&pdev->dev); |
234 | int irq = platform_get_irq(pdev, 0); | 233 | int irq = platform_get_irq(pdev, 0); |
235 | 234 | ||
@@ -246,8 +245,7 @@ static int timbgpio_probe(struct platform_device *pdev) | |||
246 | 245 | ||
247 | spin_lock_init(&tgpio->lock); | 246 | spin_lock_init(&tgpio->lock); |
248 | 247 | ||
249 | iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 248 | tgpio->membase = devm_platform_ioremap_resource(pdev, 0); |
250 | tgpio->membase = devm_ioremap_resource(dev, iomem); | ||
251 | if (IS_ERR(tgpio->membase)) | 249 | if (IS_ERR(tgpio->membase)) |
252 | return PTR_ERR(tgpio->membase); | 250 | return PTR_ERR(tgpio->membase); |
253 | 251 | ||
diff --git a/drivers/gpio/gpio-ts4800.c b/drivers/gpio/gpio-ts4800.c index c2a80b4cbf32..8c0d82d926dd 100644 --- a/drivers/gpio/gpio-ts4800.c +++ b/drivers/gpio/gpio-ts4800.c | |||
@@ -23,7 +23,6 @@ static int ts4800_gpio_probe(struct platform_device *pdev) | |||
23 | { | 23 | { |
24 | struct device_node *node; | 24 | struct device_node *node; |
25 | struct gpio_chip *chip; | 25 | struct gpio_chip *chip; |
26 | struct resource *res; | ||
27 | void __iomem *base_addr; | 26 | void __iomem *base_addr; |
28 | int retval; | 27 | int retval; |
29 | u32 ngpios; | 28 | u32 ngpios; |
@@ -32,8 +31,7 @@ static int ts4800_gpio_probe(struct platform_device *pdev) | |||
32 | if (!chip) | 31 | if (!chip) |
33 | return -ENOMEM; | 32 | return -ENOMEM; |
34 | 33 | ||
35 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 34 | base_addr = devm_platform_ioremap_resource(pdev, 0); |
36 | base_addr = devm_ioremap_resource(&pdev->dev, res); | ||
37 | if (IS_ERR(base_addr)) | 35 | if (IS_ERR(base_addr)) |
38 | return PTR_ERR(base_addr); | 36 | return PTR_ERR(base_addr); |
39 | 37 | ||
diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c index 0f662b297a95..93cdcc41e9fb 100644 --- a/drivers/gpio/gpio-uniphier.c +++ b/drivers/gpio/gpio-uniphier.c | |||
@@ -346,7 +346,6 @@ static int uniphier_gpio_probe(struct platform_device *pdev) | |||
346 | struct uniphier_gpio_priv *priv; | 346 | struct uniphier_gpio_priv *priv; |
347 | struct gpio_chip *chip; | 347 | struct gpio_chip *chip; |
348 | struct irq_chip *irq_chip; | 348 | struct irq_chip *irq_chip; |
349 | struct resource *regs; | ||
350 | unsigned int nregs; | 349 | unsigned int nregs; |
351 | u32 ngpios; | 350 | u32 ngpios; |
352 | int ret; | 351 | int ret; |
@@ -370,8 +369,7 @@ static int uniphier_gpio_probe(struct platform_device *pdev) | |||
370 | if (!priv) | 369 | if (!priv) |
371 | return -ENOMEM; | 370 | return -ENOMEM; |
372 | 371 | ||
373 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 372 | priv->regs = devm_platform_ioremap_resource(pdev, 0); |
374 | priv->regs = devm_ioremap_resource(dev, regs); | ||
375 | if (IS_ERR(priv->regs)) | 373 | if (IS_ERR(priv->regs)) |
376 | return PTR_ERR(priv->regs); | 374 | return PTR_ERR(priv->regs); |
377 | 375 | ||
diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index 541fa6ac399d..30aef41e3b7e 100644 --- a/drivers/gpio/gpio-vf610.c +++ b/drivers/gpio/gpio-vf610.c | |||
@@ -29,6 +29,7 @@ struct fsl_gpio_soc_data { | |||
29 | 29 | ||
30 | struct vf610_gpio_port { | 30 | struct vf610_gpio_port { |
31 | struct gpio_chip gc; | 31 | struct gpio_chip gc; |
32 | struct irq_chip ic; | ||
32 | void __iomem *base; | 33 | void __iomem *base; |
33 | void __iomem *gpio_base; | 34 | void __iomem *gpio_base; |
34 | const struct fsl_gpio_soc_data *sdata; | 35 | const struct fsl_gpio_soc_data *sdata; |
@@ -60,8 +61,6 @@ struct vf610_gpio_port { | |||
60 | #define PORT_INT_EITHER_EDGE 0xb | 61 | #define PORT_INT_EITHER_EDGE 0xb |
61 | #define PORT_INT_LOGIC_ONE 0xc | 62 | #define PORT_INT_LOGIC_ONE 0xc |
62 | 63 | ||
63 | static struct irq_chip vf610_gpio_irq_chip; | ||
64 | |||
65 | static const struct fsl_gpio_soc_data imx_data = { | 64 | static const struct fsl_gpio_soc_data imx_data = { |
66 | .have_paddr = true, | 65 | .have_paddr = true, |
67 | }; | 66 | }; |
@@ -86,28 +85,24 @@ static int vf610_gpio_get(struct gpio_chip *gc, unsigned int gpio) | |||
86 | { | 85 | { |
87 | struct vf610_gpio_port *port = gpiochip_get_data(gc); | 86 | struct vf610_gpio_port *port = gpiochip_get_data(gc); |
88 | unsigned long mask = BIT(gpio); | 87 | unsigned long mask = BIT(gpio); |
89 | void __iomem *addr; | 88 | unsigned long offset = GPIO_PDIR; |
90 | 89 | ||
91 | if (port->sdata && port->sdata->have_paddr) { | 90 | if (port->sdata && port->sdata->have_paddr) { |
92 | mask &= vf610_gpio_readl(port->gpio_base + GPIO_PDDR); | 91 | mask &= vf610_gpio_readl(port->gpio_base + GPIO_PDDR); |
93 | addr = mask ? port->gpio_base + GPIO_PDOR : | 92 | if (mask) |
94 | port->gpio_base + GPIO_PDIR; | 93 | offset = GPIO_PDOR; |
95 | return !!(vf610_gpio_readl(addr) & BIT(gpio)); | ||
96 | } else { | ||
97 | return !!(vf610_gpio_readl(port->gpio_base + GPIO_PDIR) | ||
98 | & BIT(gpio)); | ||
99 | } | 94 | } |
95 | |||
96 | return !!(vf610_gpio_readl(port->gpio_base + offset) & BIT(gpio)); | ||
100 | } | 97 | } |
101 | 98 | ||
102 | static void vf610_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | 99 | static void vf610_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) |
103 | { | 100 | { |
104 | struct vf610_gpio_port *port = gpiochip_get_data(gc); | 101 | struct vf610_gpio_port *port = gpiochip_get_data(gc); |
105 | unsigned long mask = BIT(gpio); | 102 | unsigned long mask = BIT(gpio); |
103 | unsigned long offset = val ? GPIO_PSOR : GPIO_PCOR; | ||
106 | 104 | ||
107 | if (val) | 105 | vf610_gpio_writel(mask, port->gpio_base + offset); |
108 | vf610_gpio_writel(mask, port->gpio_base + GPIO_PSOR); | ||
109 | else | ||
110 | vf610_gpio_writel(mask, port->gpio_base + GPIO_PCOR); | ||
111 | } | 106 | } |
112 | 107 | ||
113 | static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | 108 | static int vf610_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) |
@@ -237,37 +232,31 @@ static int vf610_gpio_irq_set_wake(struct irq_data *d, u32 enable) | |||
237 | return 0; | 232 | return 0; |
238 | } | 233 | } |
239 | 234 | ||
240 | static struct irq_chip vf610_gpio_irq_chip = { | 235 | static void vf610_gpio_disable_clk(void *data) |
241 | .name = "gpio-vf610", | 236 | { |
242 | .irq_ack = vf610_gpio_irq_ack, | 237 | clk_disable_unprepare(data); |
243 | .irq_mask = vf610_gpio_irq_mask, | 238 | } |
244 | .irq_unmask = vf610_gpio_irq_unmask, | ||
245 | .irq_set_type = vf610_gpio_irq_set_type, | ||
246 | .irq_set_wake = vf610_gpio_irq_set_wake, | ||
247 | }; | ||
248 | 239 | ||
249 | static int vf610_gpio_probe(struct platform_device *pdev) | 240 | static int vf610_gpio_probe(struct platform_device *pdev) |
250 | { | 241 | { |
251 | struct device *dev = &pdev->dev; | 242 | struct device *dev = &pdev->dev; |
252 | struct device_node *np = dev->of_node; | 243 | struct device_node *np = dev->of_node; |
253 | struct vf610_gpio_port *port; | 244 | struct vf610_gpio_port *port; |
254 | struct resource *iores; | ||
255 | struct gpio_chip *gc; | 245 | struct gpio_chip *gc; |
246 | struct irq_chip *ic; | ||
256 | int i; | 247 | int i; |
257 | int ret; | 248 | int ret; |
258 | 249 | ||
259 | port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL); | 250 | port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); |
260 | if (!port) | 251 | if (!port) |
261 | return -ENOMEM; | 252 | return -ENOMEM; |
262 | 253 | ||
263 | port->sdata = of_device_get_match_data(dev); | 254 | port->sdata = of_device_get_match_data(dev); |
264 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 255 | port->base = devm_platform_ioremap_resource(pdev, 0); |
265 | port->base = devm_ioremap_resource(dev, iores); | ||
266 | if (IS_ERR(port->base)) | 256 | if (IS_ERR(port->base)) |
267 | return PTR_ERR(port->base); | 257 | return PTR_ERR(port->base); |
268 | 258 | ||
269 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 259 | port->gpio_base = devm_platform_ioremap_resource(pdev, 1); |
270 | port->gpio_base = devm_ioremap_resource(dev, iores); | ||
271 | if (IS_ERR(port->gpio_base)) | 260 | if (IS_ERR(port->gpio_base)) |
272 | return PTR_ERR(port->gpio_base); | 261 | return PTR_ERR(port->gpio_base); |
273 | 262 | ||
@@ -275,11 +264,15 @@ static int vf610_gpio_probe(struct platform_device *pdev) | |||
275 | if (port->irq < 0) | 264 | if (port->irq < 0) |
276 | return port->irq; | 265 | return port->irq; |
277 | 266 | ||
278 | port->clk_port = devm_clk_get(&pdev->dev, "port"); | 267 | port->clk_port = devm_clk_get(dev, "port"); |
279 | if (!IS_ERR(port->clk_port)) { | 268 | if (!IS_ERR(port->clk_port)) { |
280 | ret = clk_prepare_enable(port->clk_port); | 269 | ret = clk_prepare_enable(port->clk_port); |
281 | if (ret) | 270 | if (ret) |
282 | return ret; | 271 | return ret; |
272 | ret = devm_add_action_or_reset(dev, vf610_gpio_disable_clk, | ||
273 | port->clk_port); | ||
274 | if (ret) | ||
275 | return ret; | ||
283 | } else if (port->clk_port == ERR_PTR(-EPROBE_DEFER)) { | 276 | } else if (port->clk_port == ERR_PTR(-EPROBE_DEFER)) { |
284 | /* | 277 | /* |
285 | * Percolate deferrals, for anything else, | 278 | * Percolate deferrals, for anything else, |
@@ -288,20 +281,19 @@ static int vf610_gpio_probe(struct platform_device *pdev) | |||
288 | return PTR_ERR(port->clk_port); | 281 | return PTR_ERR(port->clk_port); |
289 | } | 282 | } |
290 | 283 | ||
291 | port->clk_gpio = devm_clk_get(&pdev->dev, "gpio"); | 284 | port->clk_gpio = devm_clk_get(dev, "gpio"); |
292 | if (!IS_ERR(port->clk_gpio)) { | 285 | if (!IS_ERR(port->clk_gpio)) { |
293 | ret = clk_prepare_enable(port->clk_gpio); | 286 | ret = clk_prepare_enable(port->clk_gpio); |
294 | if (ret) { | 287 | if (ret) |
295 | clk_disable_unprepare(port->clk_port); | 288 | return ret; |
289 | ret = devm_add_action_or_reset(dev, vf610_gpio_disable_clk, | ||
290 | port->clk_gpio); | ||
291 | if (ret) | ||
296 | return ret; | 292 | return ret; |
297 | } | ||
298 | } else if (port->clk_gpio == ERR_PTR(-EPROBE_DEFER)) { | 293 | } else if (port->clk_gpio == ERR_PTR(-EPROBE_DEFER)) { |
299 | clk_disable_unprepare(port->clk_port); | ||
300 | return PTR_ERR(port->clk_gpio); | 294 | return PTR_ERR(port->clk_gpio); |
301 | } | 295 | } |
302 | 296 | ||
303 | platform_set_drvdata(pdev, port); | ||
304 | |||
305 | gc = &port->gc; | 297 | gc = &port->gc; |
306 | gc->of_node = np; | 298 | gc->of_node = np; |
307 | gc->parent = dev; | 299 | gc->parent = dev; |
@@ -316,7 +308,15 @@ static int vf610_gpio_probe(struct platform_device *pdev) | |||
316 | gc->direction_output = vf610_gpio_direction_output; | 308 | gc->direction_output = vf610_gpio_direction_output; |
317 | gc->set = vf610_gpio_set; | 309 | gc->set = vf610_gpio_set; |
318 | 310 | ||
319 | ret = gpiochip_add_data(gc, port); | 311 | ic = &port->ic; |
312 | ic->name = "gpio-vf610"; | ||
313 | ic->irq_ack = vf610_gpio_irq_ack; | ||
314 | ic->irq_mask = vf610_gpio_irq_mask; | ||
315 | ic->irq_unmask = vf610_gpio_irq_unmask; | ||
316 | ic->irq_set_type = vf610_gpio_irq_set_type; | ||
317 | ic->irq_set_wake = vf610_gpio_irq_set_wake; | ||
318 | |||
319 | ret = devm_gpiochip_add_data(dev, gc, port); | ||
320 | if (ret < 0) | 320 | if (ret < 0) |
321 | return ret; | 321 | return ret; |
322 | 322 | ||
@@ -327,39 +327,23 @@ static int vf610_gpio_probe(struct platform_device *pdev) | |||
327 | /* Clear the interrupt status register for all GPIO's */ | 327 | /* Clear the interrupt status register for all GPIO's */ |
328 | vf610_gpio_writel(~0, port->base + PORT_ISFR); | 328 | vf610_gpio_writel(~0, port->base + PORT_ISFR); |
329 | 329 | ||
330 | ret = gpiochip_irqchip_add(gc, &vf610_gpio_irq_chip, 0, | 330 | ret = gpiochip_irqchip_add(gc, ic, 0, handle_edge_irq, IRQ_TYPE_NONE); |
331 | handle_edge_irq, IRQ_TYPE_NONE); | ||
332 | if (ret) { | 331 | if (ret) { |
333 | dev_err(dev, "failed to add irqchip\n"); | 332 | dev_err(dev, "failed to add irqchip\n"); |
334 | gpiochip_remove(gc); | ||
335 | return ret; | 333 | return ret; |
336 | } | 334 | } |
337 | gpiochip_set_chained_irqchip(gc, &vf610_gpio_irq_chip, port->irq, | 335 | gpiochip_set_chained_irqchip(gc, ic, port->irq, |
338 | vf610_gpio_irq_handler); | 336 | vf610_gpio_irq_handler); |
339 | 337 | ||
340 | return 0; | 338 | return 0; |
341 | } | 339 | } |
342 | 340 | ||
343 | static int vf610_gpio_remove(struct platform_device *pdev) | ||
344 | { | ||
345 | struct vf610_gpio_port *port = platform_get_drvdata(pdev); | ||
346 | |||
347 | gpiochip_remove(&port->gc); | ||
348 | if (!IS_ERR(port->clk_port)) | ||
349 | clk_disable_unprepare(port->clk_port); | ||
350 | if (!IS_ERR(port->clk_gpio)) | ||
351 | clk_disable_unprepare(port->clk_gpio); | ||
352 | |||
353 | return 0; | ||
354 | } | ||
355 | |||
356 | static struct platform_driver vf610_gpio_driver = { | 341 | static struct platform_driver vf610_gpio_driver = { |
357 | .driver = { | 342 | .driver = { |
358 | .name = "gpio-vf610", | 343 | .name = "gpio-vf610", |
359 | .of_match_table = vf610_gpio_dt_ids, | 344 | .of_match_table = vf610_gpio_dt_ids, |
360 | }, | 345 | }, |
361 | .probe = vf610_gpio_probe, | 346 | .probe = vf610_gpio_probe, |
362 | .remove = vf610_gpio_remove, | ||
363 | }; | 347 | }; |
364 | 348 | ||
365 | builtin_platform_driver(vf610_gpio_driver); | 349 | builtin_platform_driver(vf610_gpio_driver); |
diff --git a/drivers/gpio/gpio-xgene-sb.c b/drivers/gpio/gpio-xgene-sb.c index 2eb76f35aa7e..641a05181017 100644 --- a/drivers/gpio/gpio-xgene-sb.c +++ b/drivers/gpio/gpio-xgene-sb.c | |||
@@ -229,7 +229,6 @@ static int xgene_gpio_sb_probe(struct platform_device *pdev) | |||
229 | { | 229 | { |
230 | struct xgene_gpio_sb *priv; | 230 | struct xgene_gpio_sb *priv; |
231 | int ret; | 231 | int ret; |
232 | struct resource *res; | ||
233 | void __iomem *regs; | 232 | void __iomem *regs; |
234 | struct irq_domain *parent_domain = NULL; | 233 | struct irq_domain *parent_domain = NULL; |
235 | u32 val32; | 234 | u32 val32; |
@@ -238,8 +237,7 @@ static int xgene_gpio_sb_probe(struct platform_device *pdev) | |||
238 | if (!priv) | 237 | if (!priv) |
239 | return -ENOMEM; | 238 | return -ENOMEM; |
240 | 239 | ||
241 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 240 | regs = devm_platform_ioremap_resource(pdev, 0); |
242 | regs = devm_ioremap_resource(&pdev->dev, res); | ||
243 | if (IS_ERR(regs)) | 241 | if (IS_ERR(regs)) |
244 | return PTR_ERR(regs); | 242 | return PTR_ERR(regs); |
245 | 243 | ||
diff --git a/drivers/gpio/gpio-xlp.c b/drivers/gpio/gpio-xlp.c index 0a3607fd21af..54d3359444f3 100644 --- a/drivers/gpio/gpio-xlp.c +++ b/drivers/gpio/gpio-xlp.c | |||
@@ -290,22 +290,17 @@ MODULE_DEVICE_TABLE(of, xlp_gpio_of_ids); | |||
290 | static int xlp_gpio_probe(struct platform_device *pdev) | 290 | static int xlp_gpio_probe(struct platform_device *pdev) |
291 | { | 291 | { |
292 | struct gpio_chip *gc; | 292 | struct gpio_chip *gc; |
293 | struct resource *iores; | ||
294 | struct xlp_gpio_priv *priv; | 293 | struct xlp_gpio_priv *priv; |
295 | void __iomem *gpio_base; | 294 | void __iomem *gpio_base; |
296 | int irq_base, irq, err; | 295 | int irq_base, irq, err; |
297 | int ngpio; | 296 | int ngpio; |
298 | u32 soc_type; | 297 | u32 soc_type; |
299 | 298 | ||
300 | iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
301 | if (!iores) | ||
302 | return -ENODEV; | ||
303 | |||
304 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); | 299 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
305 | if (!priv) | 300 | if (!priv) |
306 | return -ENOMEM; | 301 | return -ENOMEM; |
307 | 302 | ||
308 | gpio_base = devm_ioremap_resource(&pdev->dev, iores); | 303 | gpio_base = devm_platform_ioremap_resource(pdev, 0); |
309 | if (IS_ERR(gpio_base)) | 304 | if (IS_ERR(gpio_base)) |
310 | return PTR_ERR(gpio_base); | 305 | return PTR_ERR(gpio_base); |
311 | 306 | ||
diff --git a/drivers/gpio/gpio-zx.c b/drivers/gpio/gpio-zx.c index 5eacad9b2692..fb927559aefa 100644 --- a/drivers/gpio/gpio-zx.c +++ b/drivers/gpio/gpio-zx.c | |||
@@ -218,15 +218,13 @@ static int zx_gpio_probe(struct platform_device *pdev) | |||
218 | { | 218 | { |
219 | struct device *dev = &pdev->dev; | 219 | struct device *dev = &pdev->dev; |
220 | struct zx_gpio *chip; | 220 | struct zx_gpio *chip; |
221 | struct resource *res; | ||
222 | int irq, id, ret; | 221 | int irq, id, ret; |
223 | 222 | ||
224 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); | 223 | chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); |
225 | if (!chip) | 224 | if (!chip) |
226 | return -ENOMEM; | 225 | return -ENOMEM; |
227 | 226 | ||
228 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 227 | chip->base = devm_platform_ioremap_resource(pdev, 0); |
229 | chip->base = devm_ioremap_resource(dev, res); | ||
230 | if (IS_ERR(chip->base)) | 228 | if (IS_ERR(chip->base)) |
231 | return PTR_ERR(chip->base); | 229 | return PTR_ERR(chip->base); |
232 | 230 | ||
diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c index 00ff7b1fa8a1..9392edaeec3f 100644 --- a/drivers/gpio/gpio-zynq.c +++ b/drivers/gpio/gpio-zynq.c | |||
@@ -834,7 +834,6 @@ static int zynq_gpio_probe(struct platform_device *pdev) | |||
834 | int ret, bank_num; | 834 | int ret, bank_num; |
835 | struct zynq_gpio *gpio; | 835 | struct zynq_gpio *gpio; |
836 | struct gpio_chip *chip; | 836 | struct gpio_chip *chip; |
837 | struct resource *res; | ||
838 | const struct of_device_id *match; | 837 | const struct of_device_id *match; |
839 | 838 | ||
840 | gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); | 839 | gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); |
@@ -849,8 +848,7 @@ static int zynq_gpio_probe(struct platform_device *pdev) | |||
849 | gpio->p_data = match->data; | 848 | gpio->p_data = match->data; |
850 | platform_set_drvdata(pdev, gpio); | 849 | platform_set_drvdata(pdev, gpio); |
851 | 850 | ||
852 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 851 | gpio->base_addr = devm_platform_ioremap_resource(pdev, 0); |
853 | gpio->base_addr = devm_ioremap_resource(&pdev->dev, res); | ||
854 | if (IS_ERR(gpio->base_addr)) | 852 | if (IS_ERR(gpio->base_addr)) |
855 | return PTR_ERR(gpio->base_addr); | 853 | return PTR_ERR(gpio->base_addr); |
856 | 854 | ||
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 30d0baf7ddae..c9fc9e232aaf 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -24,13 +24,13 @@ | |||
24 | * | 24 | * |
25 | * @node: list-entry of the events list of the struct acpi_gpio_chip | 25 | * @node: list-entry of the events list of the struct acpi_gpio_chip |
26 | * @handle: handle of ACPI method to execute when the IRQ triggers | 26 | * @handle: handle of ACPI method to execute when the IRQ triggers |
27 | * @handler: irq_handler to pass to request_irq when requesting the IRQ | 27 | * @handler: handler function to pass to request_irq() when requesting the IRQ |
28 | * @pin: GPIO pin number on the gpio_chip | 28 | * @pin: GPIO pin number on the struct gpio_chip |
29 | * @irq: Linux IRQ number for the event, for request_ / free_irq | 29 | * @irq: Linux IRQ number for the event, for request_irq() / free_irq() |
30 | * @irqflags: flags to pass to request_irq when requesting the IRQ | 30 | * @irqflags: flags to pass to request_irq() when requesting the IRQ |
31 | * @irq_is_wake: If the ACPI flags indicate the IRQ is a wakeup source | 31 | * @irq_is_wake: If the ACPI flags indicate the IRQ is a wakeup source |
32 | * @irq_requested:True if request_irq has been done | 32 | * @irq_requested:True if request_irq() has been done |
33 | * @desc: gpio_desc for the GPIO pin for this event | 33 | * @desc: struct gpio_desc for the GPIO pin for this event |
34 | */ | 34 | */ |
35 | struct acpi_gpio_event { | 35 | struct acpi_gpio_event { |
36 | struct list_head node; | 36 | struct list_head node; |
@@ -65,10 +65,10 @@ struct acpi_gpio_chip { | |||
65 | }; | 65 | }; |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * For gpiochips which call acpi_gpiochip_request_interrupts() before late_init | 68 | * For GPIO chips which call acpi_gpiochip_request_interrupts() before late_init |
69 | * (so builtin drivers) we register the ACPI GpioInt IRQ handlers from a | 69 | * (so builtin drivers) we register the ACPI GpioInt IRQ handlers from a |
70 | * late_initcall_sync handler, so that other builtin drivers can register their | 70 | * late_initcall_sync() handler, so that other builtin drivers can register their |
71 | * OpRegions before the event handlers can run. This list contains gpiochips | 71 | * OpRegions before the event handlers can run. This list contains GPIO chips |
72 | * for which the acpi_gpiochip_request_irqs() call has been deferred. | 72 | * for which the acpi_gpiochip_request_irqs() call has been deferred. |
73 | */ | 73 | */ |
74 | static DEFINE_MUTEX(acpi_gpio_deferred_req_irqs_lock); | 74 | static DEFINE_MUTEX(acpi_gpio_deferred_req_irqs_lock); |
@@ -90,7 +90,7 @@ static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) | |||
90 | * | 90 | * |
91 | * Return: GPIO descriptor to use with Linux generic GPIO API, or ERR_PTR | 91 | * Return: GPIO descriptor to use with Linux generic GPIO API, or ERR_PTR |
92 | * error value. Specifically returns %-EPROBE_DEFER if the referenced GPIO | 92 | * error value. Specifically returns %-EPROBE_DEFER if the referenced GPIO |
93 | * controller does not have gpiochip registered at the moment. This is to | 93 | * controller does not have GPIO chip registered at the moment. This is to |
94 | * support probe deferral. | 94 | * support probe deferral. |
95 | */ | 95 | */ |
96 | static struct gpio_desc *acpi_get_gpiod(char *path, int pin) | 96 | static struct gpio_desc *acpi_get_gpiod(char *path, int pin) |
@@ -287,9 +287,9 @@ fail_free_desc: | |||
287 | * | 287 | * |
288 | * ACPI5 platforms can use GPIO signaled ACPI events. These GPIO interrupts are | 288 | * ACPI5 platforms can use GPIO signaled ACPI events. These GPIO interrupts are |
289 | * handled by ACPI event methods which need to be called from the GPIO | 289 | * handled by ACPI event methods which need to be called from the GPIO |
290 | * chip's interrupt handler. acpi_gpiochip_request_interrupts finds out which | 290 | * chip's interrupt handler. acpi_gpiochip_request_interrupts() finds out which |
291 | * gpio pins have acpi event methods and assigns interrupt handlers that calls | 291 | * GPIO pins have ACPI event methods and assigns interrupt handlers that calls |
292 | * the acpi event methods for those pins. | 292 | * the ACPI event methods for those pins. |
293 | */ | 293 | */ |
294 | void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) | 294 | void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) |
295 | { | 295 | { |
@@ -444,8 +444,6 @@ static bool acpi_get_driver_gpio_data(struct acpi_device *adev, | |||
444 | static enum gpiod_flags | 444 | static enum gpiod_flags |
445 | acpi_gpio_to_gpiod_flags(const struct acpi_resource_gpio *agpio) | 445 | acpi_gpio_to_gpiod_flags(const struct acpi_resource_gpio *agpio) |
446 | { | 446 | { |
447 | bool pull_up = agpio->pin_config == ACPI_PIN_CONFIG_PULLUP; | ||
448 | |||
449 | switch (agpio->io_restriction) { | 447 | switch (agpio->io_restriction) { |
450 | case ACPI_IO_RESTRICT_INPUT: | 448 | case ACPI_IO_RESTRICT_INPUT: |
451 | return GPIOD_IN; | 449 | return GPIOD_IN; |
@@ -454,16 +452,26 @@ acpi_gpio_to_gpiod_flags(const struct acpi_resource_gpio *agpio) | |||
454 | * ACPI GPIO resources don't contain an initial value for the | 452 | * ACPI GPIO resources don't contain an initial value for the |
455 | * GPIO. Therefore we deduce that value from the pull field | 453 | * GPIO. Therefore we deduce that value from the pull field |
456 | * instead. If the pin is pulled up we assume default to be | 454 | * instead. If the pin is pulled up we assume default to be |
457 | * high, otherwise low. | 455 | * high, if it is pulled down we assume default to be low, |
456 | * otherwise we leave pin untouched. | ||
458 | */ | 457 | */ |
459 | return pull_up ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; | 458 | switch (agpio->pin_config) { |
459 | case ACPI_PIN_CONFIG_PULLUP: | ||
460 | return GPIOD_OUT_HIGH; | ||
461 | case ACPI_PIN_CONFIG_PULLDOWN: | ||
462 | return GPIOD_OUT_LOW; | ||
463 | default: | ||
464 | break; | ||
465 | } | ||
460 | default: | 466 | default: |
461 | /* | 467 | break; |
462 | * Assume that the BIOS has configured the direction and pull | ||
463 | * accordingly. | ||
464 | */ | ||
465 | return GPIOD_ASIS; | ||
466 | } | 468 | } |
469 | |||
470 | /* | ||
471 | * Assume that the BIOS has configured the direction and pull | ||
472 | * accordingly. | ||
473 | */ | ||
474 | return GPIOD_ASIS; | ||
467 | } | 475 | } |
468 | 476 | ||
469 | static int | 477 | static int |
@@ -517,6 +525,26 @@ acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *inf | |||
517 | return ret; | 525 | return ret; |
518 | } | 526 | } |
519 | 527 | ||
528 | int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, | ||
529 | struct acpi_gpio_info *info) | ||
530 | { | ||
531 | switch (info->pin_config) { | ||
532 | case ACPI_PIN_CONFIG_PULLUP: | ||
533 | *lookupflags |= GPIO_PULL_UP; | ||
534 | break; | ||
535 | case ACPI_PIN_CONFIG_PULLDOWN: | ||
536 | *lookupflags |= GPIO_PULL_DOWN; | ||
537 | break; | ||
538 | default: | ||
539 | break; | ||
540 | } | ||
541 | |||
542 | if (info->polarity == GPIO_ACTIVE_LOW) | ||
543 | *lookupflags |= GPIO_ACTIVE_LOW; | ||
544 | |||
545 | return 0; | ||
546 | } | ||
547 | |||
520 | struct acpi_gpio_lookup { | 548 | struct acpi_gpio_lookup { |
521 | struct acpi_gpio_info info; | 549 | struct acpi_gpio_info info; |
522 | int index; | 550 | int index; |
@@ -550,6 +578,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) | |||
550 | 578 | ||
551 | lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr, | 579 | lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr, |
552 | agpio->pin_table[pin_index]); | 580 | agpio->pin_table[pin_index]); |
581 | lookup->info.pin_config = agpio->pin_config; | ||
553 | lookup->info.gpioint = gpioint; | 582 | lookup->info.gpioint = gpioint; |
554 | 583 | ||
555 | /* | 584 | /* |
@@ -653,7 +682,7 @@ static int acpi_gpio_property_lookup(struct fwnode_handle *fwnode, | |||
653 | * that case @index is used to select the GPIO entry in the property value | 682 | * that case @index is used to select the GPIO entry in the property value |
654 | * (in case of multiple). | 683 | * (in case of multiple). |
655 | * | 684 | * |
656 | * If the GPIO cannot be translated or there is an error an ERR_PTR is | 685 | * If the GPIO cannot be translated or there is an error, an ERR_PTR is |
657 | * returned. | 686 | * returned. |
658 | * | 687 | * |
659 | * Note: if the GPIO resource has multiple entries in the pin list, this | 688 | * Note: if the GPIO resource has multiple entries in the pin list, this |
@@ -696,7 +725,7 @@ struct gpio_desc *acpi_find_gpio(struct device *dev, | |||
696 | const char *con_id, | 725 | const char *con_id, |
697 | unsigned int idx, | 726 | unsigned int idx, |
698 | enum gpiod_flags *dflags, | 727 | enum gpiod_flags *dflags, |
699 | enum gpio_lookup_flags *lookupflags) | 728 | unsigned long *lookupflags) |
700 | { | 729 | { |
701 | struct acpi_device *adev = ACPI_COMPANION(dev); | 730 | struct acpi_device *adev = ACPI_COMPANION(dev); |
702 | struct acpi_gpio_info info; | 731 | struct acpi_gpio_info info; |
@@ -737,10 +766,8 @@ struct gpio_desc *acpi_find_gpio(struct device *dev, | |||
737 | return ERR_PTR(-ENOENT); | 766 | return ERR_PTR(-ENOENT); |
738 | } | 767 | } |
739 | 768 | ||
740 | if (info.polarity == GPIO_ACTIVE_LOW) | ||
741 | *lookupflags |= GPIO_ACTIVE_LOW; | ||
742 | |||
743 | acpi_gpio_update_gpiod_flags(dflags, &info); | 769 | acpi_gpio_update_gpiod_flags(dflags, &info); |
770 | acpi_gpio_update_gpiod_lookup_flags(lookupflags, &info); | ||
744 | return desc; | 771 | return desc; |
745 | } | 772 | } |
746 | 773 | ||
@@ -751,10 +778,13 @@ struct gpio_desc *acpi_find_gpio(struct device *dev, | |||
751 | * @index: index of GpioIo/GpioInt resource (starting from %0) | 778 | * @index: index of GpioIo/GpioInt resource (starting from %0) |
752 | * @info: info pointer to fill in (optional) | 779 | * @info: info pointer to fill in (optional) |
753 | * | 780 | * |
754 | * If @fwnode is an ACPI device object, call %acpi_get_gpiod_by_index() for it. | 781 | * If @fwnode is an ACPI device object, call acpi_get_gpiod_by_index() for it. |
755 | * Otherwise (ie. it is a data-only non-device object), use the property-based | 782 | * Otherwise (i.e. it is a data-only non-device object), use the property-based |
756 | * GPIO lookup to get to the GPIO resource with the relevant information and use | 783 | * GPIO lookup to get to the GPIO resource with the relevant information and use |
757 | * that to obtain the GPIO descriptor to return. | 784 | * that to obtain the GPIO descriptor to return. |
785 | * | ||
786 | * If the GPIO cannot be translated or there is an error an ERR_PTR is | ||
787 | * returned. | ||
758 | */ | 788 | */ |
759 | struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, | 789 | struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, |
760 | const char *propname, int index, | 790 | const char *propname, int index, |
@@ -816,6 +846,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) | |||
816 | return PTR_ERR(desc); | 846 | return PTR_ERR(desc); |
817 | 847 | ||
818 | if (info.gpioint && idx++ == index) { | 848 | if (info.gpioint && idx++ == index) { |
849 | unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; | ||
819 | char label[32]; | 850 | char label[32]; |
820 | int irq; | 851 | int irq; |
821 | 852 | ||
@@ -827,7 +858,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) | |||
827 | return irq; | 858 | return irq; |
828 | 859 | ||
829 | snprintf(label, sizeof(label), "GpioInt() %d", index); | 860 | snprintf(label, sizeof(label), "GpioInt() %d", index); |
830 | ret = gpiod_configure_flags(desc, label, 0, info.flags); | 861 | ret = gpiod_configure_flags(desc, label, lflags, info.flags); |
831 | if (ret < 0) | 862 | if (ret < 0) |
832 | return ret; | 863 | return ret; |
833 | 864 | ||
@@ -992,16 +1023,19 @@ static void acpi_gpiochip_free_regions(struct acpi_gpio_chip *achip) | |||
992 | } | 1023 | } |
993 | } | 1024 | } |
994 | 1025 | ||
995 | static struct gpio_desc *acpi_gpiochip_parse_own_gpio( | 1026 | static struct gpio_desc * |
996 | struct acpi_gpio_chip *achip, struct fwnode_handle *fwnode, | 1027 | acpi_gpiochip_parse_own_gpio(struct acpi_gpio_chip *achip, |
997 | const char **name, unsigned int *lflags, unsigned int *dflags) | 1028 | struct fwnode_handle *fwnode, |
1029 | const char **name, | ||
1030 | unsigned long *lflags, | ||
1031 | enum gpiod_flags *dflags) | ||
998 | { | 1032 | { |
999 | struct gpio_chip *chip = achip->chip; | 1033 | struct gpio_chip *chip = achip->chip; |
1000 | struct gpio_desc *desc; | 1034 | struct gpio_desc *desc; |
1001 | u32 gpios[2]; | 1035 | u32 gpios[2]; |
1002 | int ret; | 1036 | int ret; |
1003 | 1037 | ||
1004 | *lflags = 0; | 1038 | *lflags = GPIO_LOOKUP_FLAGS_DEFAULT; |
1005 | *dflags = 0; | 1039 | *dflags = 0; |
1006 | *name = NULL; | 1040 | *name = NULL; |
1007 | 1041 | ||
@@ -1037,7 +1071,8 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip) | |||
1037 | struct fwnode_handle *fwnode; | 1071 | struct fwnode_handle *fwnode; |
1038 | 1072 | ||
1039 | device_for_each_child_node(chip->parent, fwnode) { | 1073 | device_for_each_child_node(chip->parent, fwnode) { |
1040 | unsigned int lflags, dflags; | 1074 | unsigned long lflags; |
1075 | enum gpiod_flags dflags; | ||
1041 | struct gpio_desc *desc; | 1076 | struct gpio_desc *desc; |
1042 | const char *name; | 1077 | const char *name; |
1043 | int ret; | 1078 | int ret; |
@@ -1158,11 +1193,13 @@ static int acpi_find_gpio_count(struct acpi_resource *ares, void *data) | |||
1158 | } | 1193 | } |
1159 | 1194 | ||
1160 | /** | 1195 | /** |
1161 | * acpi_gpio_count - return the number of GPIOs associated with a | 1196 | * acpi_gpio_count - count the GPIOs associated with a device / function |
1162 | * device / function or -ENOENT if no GPIO has been | 1197 | * @dev: GPIO consumer, can be %NULL for system-global GPIOs |
1163 | * assigned to the requested function. | ||
1164 | * @dev: GPIO consumer, can be NULL for system-global GPIOs | ||
1165 | * @con_id: function within the GPIO consumer | 1198 | * @con_id: function within the GPIO consumer |
1199 | * | ||
1200 | * Return: | ||
1201 | * The number of GPIOs associated with a device / function or %-ENOENT, | ||
1202 | * if no GPIO has been assigned to the requested function. | ||
1166 | */ | 1203 | */ |
1167 | int acpi_gpio_count(struct device *dev, const char *con_id) | 1204 | int acpi_gpio_count(struct device *dev, const char *con_id) |
1168 | { | 1205 | { |
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 6a3ec575a404..aec7bd86ae7e 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c | |||
@@ -86,9 +86,9 @@ static void of_gpio_flags_quirks(struct device_node *np, | |||
86 | if (IS_ENABLED(CONFIG_REGULATOR) && | 86 | if (IS_ENABLED(CONFIG_REGULATOR) && |
87 | (of_device_is_compatible(np, "regulator-fixed") || | 87 | (of_device_is_compatible(np, "regulator-fixed") || |
88 | of_device_is_compatible(np, "reg-fixed-voltage") || | 88 | of_device_is_compatible(np, "reg-fixed-voltage") || |
89 | (of_device_is_compatible(np, "regulator-gpio") && | 89 | (!(strcmp(propname, "enable-gpio") && |
90 | !(strcmp(propname, "enable-gpio") && | 90 | strcmp(propname, "enable-gpios")) && |
91 | strcmp(propname, "enable-gpios"))))) { | 91 | of_device_is_compatible(np, "regulator-gpio")))) { |
92 | /* | 92 | /* |
93 | * The regulator GPIO handles are specified such that the | 93 | * The regulator GPIO handles are specified such that the |
94 | * presence or absence of "enable-active-high" solely controls | 94 | * presence or absence of "enable-active-high" solely controls |
@@ -119,9 +119,8 @@ static void of_gpio_flags_quirks(struct device_node *np, | |||
119 | * property named "cs-gpios" we need to inspect the child node | 119 | * property named "cs-gpios" we need to inspect the child node |
120 | * to determine if the flags should have inverted semantics. | 120 | * to determine if the flags should have inverted semantics. |
121 | */ | 121 | */ |
122 | if (IS_ENABLED(CONFIG_SPI_MASTER) && | 122 | if (IS_ENABLED(CONFIG_SPI_MASTER) && !strcmp(propname, "cs-gpios") && |
123 | of_property_read_bool(np, "cs-gpios") && | 123 | of_property_read_bool(np, "cs-gpios")) { |
124 | !strcmp(propname, "cs-gpios")) { | ||
125 | struct device_node *child; | 124 | struct device_node *child; |
126 | u32 cs; | 125 | u32 cs; |
127 | int ret; | 126 | int ret; |
@@ -288,8 +287,7 @@ static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char * | |||
288 | } | 287 | } |
289 | 288 | ||
290 | struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | 289 | struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, |
291 | unsigned int idx, | 290 | unsigned int idx, unsigned long *flags) |
292 | enum gpio_lookup_flags *flags) | ||
293 | { | 291 | { |
294 | char prop_name[32]; /* 32 is max size of property name */ | 292 | char prop_name[32]; /* 32 is max size of property name */ |
295 | enum of_gpio_flags of_flags; | 293 | enum of_gpio_flags of_flags; |
@@ -362,8 +360,8 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | |||
362 | * @chip: GPIO chip whose hog is parsed | 360 | * @chip: GPIO chip whose hog is parsed |
363 | * @idx: Index of the GPIO to parse | 361 | * @idx: Index of the GPIO to parse |
364 | * @name: GPIO line name | 362 | * @name: GPIO line name |
365 | * @lflags: gpio_lookup_flags - returned from of_find_gpio() or | 363 | * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from |
366 | * of_parse_own_gpio() | 364 | * of_find_gpio() or of_parse_own_gpio() |
367 | * @dflags: gpiod_flags - optional GPIO initialization flags | 365 | * @dflags: gpiod_flags - optional GPIO initialization flags |
368 | * | 366 | * |
369 | * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno | 367 | * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno |
@@ -372,7 +370,7 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | |||
372 | static struct gpio_desc *of_parse_own_gpio(struct device_node *np, | 370 | static struct gpio_desc *of_parse_own_gpio(struct device_node *np, |
373 | struct gpio_chip *chip, | 371 | struct gpio_chip *chip, |
374 | unsigned int idx, const char **name, | 372 | unsigned int idx, const char **name, |
375 | enum gpio_lookup_flags *lflags, | 373 | unsigned long *lflags, |
376 | enum gpiod_flags *dflags) | 374 | enum gpiod_flags *dflags) |
377 | { | 375 | { |
378 | struct device_node *chip_np; | 376 | struct device_node *chip_np; |
@@ -388,7 +386,7 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np, | |||
388 | return ERR_PTR(-EINVAL); | 386 | return ERR_PTR(-EINVAL); |
389 | 387 | ||
390 | xlate_flags = 0; | 388 | xlate_flags = 0; |
391 | *lflags = 0; | 389 | *lflags = GPIO_LOOKUP_FLAGS_DEFAULT; |
392 | *dflags = 0; | 390 | *dflags = 0; |
393 | 391 | ||
394 | ret = of_property_read_u32(chip_np, "#gpio-cells", &tmp); | 392 | ret = of_property_read_u32(chip_np, "#gpio-cells", &tmp); |
@@ -445,7 +443,7 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip) | |||
445 | struct gpio_desc *desc = NULL; | 443 | struct gpio_desc *desc = NULL; |
446 | struct device_node *np; | 444 | struct device_node *np; |
447 | const char *name; | 445 | const char *name; |
448 | enum gpio_lookup_flags lflags; | 446 | unsigned long lflags; |
449 | enum gpiod_flags dflags; | 447 | enum gpiod_flags dflags; |
450 | unsigned int i; | 448 | unsigned int i; |
451 | int ret; | 449 | int ret; |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bca3e7740ef6..e013d417a936 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -2519,6 +2519,7 @@ struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, | |||
2519 | const char *label, | 2519 | const char *label, |
2520 | enum gpiod_flags flags) | 2520 | enum gpiod_flags flags) |
2521 | { | 2521 | { |
2522 | unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; | ||
2522 | struct gpio_desc *desc = gpiochip_get_desc(chip, hwnum); | 2523 | struct gpio_desc *desc = gpiochip_get_desc(chip, hwnum); |
2523 | int err; | 2524 | int err; |
2524 | 2525 | ||
@@ -2531,7 +2532,7 @@ struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, | |||
2531 | if (err < 0) | 2532 | if (err < 0) |
2532 | return ERR_PTR(err); | 2533 | return ERR_PTR(err); |
2533 | 2534 | ||
2534 | err = gpiod_configure_flags(desc, label, 0, flags); | 2535 | err = gpiod_configure_flags(desc, label, lflags, flags); |
2535 | if (err) { | 2536 | if (err) { |
2536 | chip_err(chip, "setup of own GPIO %s failed\n", label); | 2537 | chip_err(chip, "setup of own GPIO %s failed\n", label); |
2537 | gpiod_free_commit(desc); | 2538 | gpiod_free_commit(desc); |
@@ -2569,8 +2570,20 @@ EXPORT_SYMBOL_GPL(gpiochip_free_own_desc); | |||
2569 | static int gpio_set_config(struct gpio_chip *gc, unsigned offset, | 2570 | static int gpio_set_config(struct gpio_chip *gc, unsigned offset, |
2570 | enum pin_config_param mode) | 2571 | enum pin_config_param mode) |
2571 | { | 2572 | { |
2572 | unsigned long config = { PIN_CONF_PACKED(mode, 0) }; | 2573 | unsigned long config; |
2574 | unsigned arg; | ||
2573 | 2575 | ||
2576 | switch (mode) { | ||
2577 | case PIN_CONFIG_BIAS_PULL_DOWN: | ||
2578 | case PIN_CONFIG_BIAS_PULL_UP: | ||
2579 | arg = 1; | ||
2580 | break; | ||
2581 | |||
2582 | default: | ||
2583 | arg = 0; | ||
2584 | } | ||
2585 | |||
2586 | config = PIN_CONF_PACKED(mode, arg); | ||
2574 | return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP; | 2587 | return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP; |
2575 | } | 2588 | } |
2576 | 2589 | ||
@@ -3915,8 +3928,7 @@ found: | |||
3915 | } | 3928 | } |
3916 | 3929 | ||
3917 | static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, | 3930 | static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, |
3918 | unsigned int idx, | 3931 | unsigned int idx, unsigned long *flags) |
3919 | enum gpio_lookup_flags *flags) | ||
3920 | { | 3932 | { |
3921 | struct gpio_desc *desc = ERR_PTR(-ENOENT); | 3933 | struct gpio_desc *desc = ERR_PTR(-ENOENT); |
3922 | struct gpiod_lookup_table *table; | 3934 | struct gpiod_lookup_table *table; |
@@ -4072,8 +4084,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_optional); | |||
4072 | * gpiod_configure_flags - helper function to configure a given GPIO | 4084 | * gpiod_configure_flags - helper function to configure a given GPIO |
4073 | * @desc: gpio whose value will be assigned | 4085 | * @desc: gpio whose value will be assigned |
4074 | * @con_id: function within the GPIO consumer | 4086 | * @con_id: function within the GPIO consumer |
4075 | * @lflags: gpio_lookup_flags - returned from of_find_gpio() or | 4087 | * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from |
4076 | * of_get_gpio_hog() | 4088 | * of_find_gpio() or of_get_gpio_hog() |
4077 | * @dflags: gpiod_flags - optional GPIO initialization flags | 4089 | * @dflags: gpiod_flags - optional GPIO initialization flags |
4078 | * | 4090 | * |
4079 | * Return 0 on success, -ENOENT if no GPIO has been assigned to the | 4091 | * Return 0 on success, -ENOENT if no GPIO has been assigned to the |
@@ -4155,9 +4167,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, | |||
4155 | unsigned int idx, | 4167 | unsigned int idx, |
4156 | enum gpiod_flags flags) | 4168 | enum gpiod_flags flags) |
4157 | { | 4169 | { |
4170 | unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT; | ||
4158 | struct gpio_desc *desc = NULL; | 4171 | struct gpio_desc *desc = NULL; |
4159 | int status; | 4172 | int status; |
4160 | enum gpio_lookup_flags lookupflags = 0; | ||
4161 | /* Maybe we have a device name, maybe not */ | 4173 | /* Maybe we have a device name, maybe not */ |
4162 | const char *devname = dev ? dev_name(dev) : "?"; | 4174 | const char *devname = dev ? dev_name(dev) : "?"; |
4163 | 4175 | ||
@@ -4242,8 +4254,8 @@ struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, | |||
4242 | enum gpiod_flags dflags, | 4254 | enum gpiod_flags dflags, |
4243 | const char *label) | 4255 | const char *label) |
4244 | { | 4256 | { |
4257 | unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; | ||
4245 | struct gpio_desc *desc; | 4258 | struct gpio_desc *desc; |
4246 | unsigned long lflags = 0; | ||
4247 | enum of_gpio_flags flags; | 4259 | enum of_gpio_flags flags; |
4248 | bool active_low = false; | 4260 | bool active_low = false; |
4249 | bool single_ended = false; | 4261 | bool single_ended = false; |
@@ -4321,8 +4333,8 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | |||
4321 | enum gpiod_flags dflags, | 4333 | enum gpiod_flags dflags, |
4322 | const char *label) | 4334 | const char *label) |
4323 | { | 4335 | { |
4336 | unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; | ||
4324 | struct gpio_desc *desc = ERR_PTR(-ENODEV); | 4337 | struct gpio_desc *desc = ERR_PTR(-ENODEV); |
4325 | unsigned long lflags = 0; | ||
4326 | int ret; | 4338 | int ret; |
4327 | 4339 | ||
4328 | if (!fwnode) | 4340 | if (!fwnode) |
@@ -4342,9 +4354,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | |||
4342 | return desc; | 4354 | return desc; |
4343 | 4355 | ||
4344 | acpi_gpio_update_gpiod_flags(&dflags, &info); | 4356 | acpi_gpio_update_gpiod_flags(&dflags, &info); |
4345 | 4357 | acpi_gpio_update_gpiod_lookup_flags(&lflags, &info); | |
4346 | if (info.polarity == GPIO_ACTIVE_LOW) | ||
4347 | lflags |= GPIO_ACTIVE_LOW; | ||
4348 | } | 4358 | } |
4349 | 4359 | ||
4350 | /* Currently only ACPI takes this path */ | 4360 | /* Currently only ACPI takes this path */ |
@@ -4395,8 +4405,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_index_optional); | |||
4395 | * gpiod_hog - Hog the specified GPIO desc given the provided flags | 4405 | * gpiod_hog - Hog the specified GPIO desc given the provided flags |
4396 | * @desc: gpio whose value will be assigned | 4406 | * @desc: gpio whose value will be assigned |
4397 | * @name: gpio line name | 4407 | * @name: gpio line name |
4398 | * @lflags: gpio_lookup_flags - returned from of_find_gpio() or | 4408 | * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from |
4399 | * of_get_gpio_hog() | 4409 | * of_find_gpio() or of_get_gpio_hog() |
4400 | * @dflags: gpiod_flags - optional GPIO initialization flags | 4410 | * @dflags: gpiod_flags - optional GPIO initialization flags |
4401 | */ | 4411 | */ |
4402 | int gpiod_hog(struct gpio_desc *desc, const char *name, | 4412 | int gpiod_hog(struct gpio_desc *desc, const char *name, |
@@ -4449,8 +4459,6 @@ int gpiod_hog(struct gpio_desc *desc, const char *name, | |||
4449 | /** | 4459 | /** |
4450 | * gpiochip_free_hogs - Scan gpio-controller chip and release GPIO hog | 4460 | * gpiochip_free_hogs - Scan gpio-controller chip and release GPIO hog |
4451 | * @chip: gpio chip to act on | 4461 | * @chip: gpio chip to act on |
4452 | * | ||
4453 | * This is only used by of_gpiochip_remove to free hogged gpios | ||
4454 | */ | 4462 | */ |
4455 | static void gpiochip_free_hogs(struct gpio_chip *chip) | 4463 | static void gpiochip_free_hogs(struct gpio_chip *chip) |
4456 | { | 4464 | { |
@@ -4620,7 +4628,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_optional); | |||
4620 | */ | 4628 | */ |
4621 | void gpiod_put(struct gpio_desc *desc) | 4629 | void gpiod_put(struct gpio_desc *desc) |
4622 | { | 4630 | { |
4623 | gpiod_free(desc); | 4631 | if (desc) |
4632 | gpiod_free(desc); | ||
4624 | } | 4633 | } |
4625 | EXPORT_SYMBOL_GPL(gpiod_put); | 4634 | EXPORT_SYMBOL_GPL(gpiod_put); |
4626 | 4635 | ||
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 3243c1eb5c88..7a65dad43932 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/cdev.h> | 17 | #include <linux/cdev.h> |
18 | 18 | ||
19 | enum of_gpio_flags; | 19 | enum of_gpio_flags; |
20 | enum gpio_lookup_flags; | ||
21 | struct acpi_device; | 20 | struct acpi_device; |
22 | 21 | ||
23 | /** | 22 | /** |
@@ -75,6 +74,7 @@ struct gpio_device { | |||
75 | * @adev: reference to ACPI device which consumes GPIO resource | 74 | * @adev: reference to ACPI device which consumes GPIO resource |
76 | * @flags: GPIO initialization flags | 75 | * @flags: GPIO initialization flags |
77 | * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo | 76 | * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo |
77 | * @pin_config: pin bias as provided by ACPI | ||
78 | * @polarity: interrupt polarity as provided by ACPI | 78 | * @polarity: interrupt polarity as provided by ACPI |
79 | * @triggering: triggering type as provided by ACPI | 79 | * @triggering: triggering type as provided by ACPI |
80 | * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping | 80 | * @quirks: Linux specific quirks as provided by struct acpi_gpio_mapping |
@@ -83,6 +83,7 @@ struct acpi_gpio_info { | |||
83 | struct acpi_device *adev; | 83 | struct acpi_device *adev; |
84 | enum gpiod_flags flags; | 84 | enum gpiod_flags flags; |
85 | bool gpioint; | 85 | bool gpioint; |
86 | int pin_config; | ||
86 | int polarity; | 87 | int polarity; |
87 | int triggering; | 88 | int triggering; |
88 | unsigned int quirks; | 89 | unsigned int quirks; |
@@ -95,7 +96,7 @@ static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" }; | |||
95 | struct gpio_desc *of_find_gpio(struct device *dev, | 96 | struct gpio_desc *of_find_gpio(struct device *dev, |
96 | const char *con_id, | 97 | const char *con_id, |
97 | unsigned int idx, | 98 | unsigned int idx, |
98 | enum gpio_lookup_flags *flags); | 99 | unsigned long *lookupflags); |
99 | struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, | 100 | struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, |
100 | const char *list_name, int index, enum of_gpio_flags *flags); | 101 | const char *list_name, int index, enum of_gpio_flags *flags); |
101 | int of_gpiochip_add(struct gpio_chip *gc); | 102 | int of_gpiochip_add(struct gpio_chip *gc); |
@@ -104,7 +105,7 @@ void of_gpiochip_remove(struct gpio_chip *gc); | |||
104 | static inline struct gpio_desc *of_find_gpio(struct device *dev, | 105 | static inline struct gpio_desc *of_find_gpio(struct device *dev, |
105 | const char *con_id, | 106 | const char *con_id, |
106 | unsigned int idx, | 107 | unsigned int idx, |
107 | enum gpio_lookup_flags *flags) | 108 | unsigned long *lookupflags) |
108 | { | 109 | { |
109 | return ERR_PTR(-ENOENT); | 110 | return ERR_PTR(-ENOENT); |
110 | } | 111 | } |
@@ -126,12 +127,14 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); | |||
126 | 127 | ||
127 | int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, | 128 | int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, |
128 | struct acpi_gpio_info *info); | 129 | struct acpi_gpio_info *info); |
130 | int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, | ||
131 | struct acpi_gpio_info *info); | ||
129 | 132 | ||
130 | struct gpio_desc *acpi_find_gpio(struct device *dev, | 133 | struct gpio_desc *acpi_find_gpio(struct device *dev, |
131 | const char *con_id, | 134 | const char *con_id, |
132 | unsigned int idx, | 135 | unsigned int idx, |
133 | enum gpiod_flags *dflags, | 136 | enum gpiod_flags *dflags, |
134 | enum gpio_lookup_flags *lookupflags); | 137 | unsigned long *lookupflags); |
135 | struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, | 138 | struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, |
136 | const char *propname, int index, | 139 | const char *propname, int index, |
137 | struct acpi_gpio_info *info); | 140 | struct acpi_gpio_info *info); |
@@ -154,11 +157,17 @@ acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *inf | |||
154 | { | 157 | { |
155 | return 0; | 158 | return 0; |
156 | } | 159 | } |
160 | static inline int | ||
161 | acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags, | ||
162 | struct acpi_gpio_info *info) | ||
163 | { | ||
164 | return 0; | ||
165 | } | ||
157 | 166 | ||
158 | static inline struct gpio_desc * | 167 | static inline struct gpio_desc * |
159 | acpi_find_gpio(struct device *dev, const char *con_id, | 168 | acpi_find_gpio(struct device *dev, const char *con_id, |
160 | unsigned int idx, enum gpiod_flags *dflags, | 169 | unsigned int idx, enum gpiod_flags *dflags, |
161 | enum gpio_lookup_flags *lookupflags) | 170 | unsigned long *lookupflags) |
162 | { | 171 | { |
163 | return ERR_PTR(-ENOENT); | 172 | return ERR_PTR(-ENOENT); |
164 | } | 173 | } |
diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c index fd9d6f026d70..f0cdb5234e49 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08.c +++ b/drivers/pinctrl/pinctrl-mcp23s08.c | |||
@@ -655,115 +655,6 @@ static int mcp23s08_irqchip_setup(struct mcp23s08 *mcp) | |||
655 | 655 | ||
656 | /*----------------------------------------------------------------------*/ | 656 | /*----------------------------------------------------------------------*/ |
657 | 657 | ||
658 | #ifdef CONFIG_DEBUG_FS | ||
659 | |||
660 | #include <linux/seq_file.h> | ||
661 | |||
662 | /* | ||
663 | * This compares the chip's registers with the register | ||
664 | * cache and corrects any incorrectly set register. This | ||
665 | * can be used to fix state for MCP23xxx, that temporary | ||
666 | * lost its power supply. | ||
667 | */ | ||
668 | #define MCP23S08_CONFIG_REGS 7 | ||
669 | static int __check_mcp23s08_reg_cache(struct mcp23s08 *mcp) | ||
670 | { | ||
671 | int cached[MCP23S08_CONFIG_REGS]; | ||
672 | int err = 0, i; | ||
673 | |||
674 | /* read cached config registers */ | ||
675 | for (i = 0; i < MCP23S08_CONFIG_REGS; i++) { | ||
676 | err = mcp_read(mcp, i, &cached[i]); | ||
677 | if (err) | ||
678 | goto out; | ||
679 | } | ||
680 | |||
681 | regcache_cache_bypass(mcp->regmap, true); | ||
682 | |||
683 | for (i = 0; i < MCP23S08_CONFIG_REGS; i++) { | ||
684 | int uncached; | ||
685 | err = mcp_read(mcp, i, &uncached); | ||
686 | if (err) | ||
687 | goto out; | ||
688 | |||
689 | if (uncached != cached[i]) { | ||
690 | dev_err(mcp->dev, "restoring reg 0x%02x from 0x%04x to 0x%04x (power-loss?)\n", | ||
691 | i, uncached, cached[i]); | ||
692 | mcp_write(mcp, i, cached[i]); | ||
693 | } | ||
694 | } | ||
695 | |||
696 | out: | ||
697 | if (err) | ||
698 | dev_err(mcp->dev, "read error: reg=%02x, err=%d", i, err); | ||
699 | regcache_cache_bypass(mcp->regmap, false); | ||
700 | return err; | ||
701 | } | ||
702 | |||
703 | /* | ||
704 | * This shows more info than the generic gpio dump code: | ||
705 | * pullups, deglitching, open drain drive. | ||
706 | */ | ||
707 | static void mcp23s08_dbg_show(struct seq_file *s, struct gpio_chip *chip) | ||
708 | { | ||
709 | struct mcp23s08 *mcp; | ||
710 | char bank; | ||
711 | int t; | ||
712 | unsigned mask; | ||
713 | int iodir, gpio, gppu; | ||
714 | |||
715 | mcp = gpiochip_get_data(chip); | ||
716 | |||
717 | /* NOTE: we only handle one bank for now ... */ | ||
718 | bank = '0' + ((mcp->addr >> 1) & 0x7); | ||
719 | |||
720 | mutex_lock(&mcp->lock); | ||
721 | |||
722 | t = __check_mcp23s08_reg_cache(mcp); | ||
723 | if (t) { | ||
724 | seq_printf(s, " I/O Error\n"); | ||
725 | goto done; | ||
726 | } | ||
727 | t = mcp_read(mcp, MCP_IODIR, &iodir); | ||
728 | if (t) { | ||
729 | seq_printf(s, " I/O Error\n"); | ||
730 | goto done; | ||
731 | } | ||
732 | t = mcp_read(mcp, MCP_GPIO, &gpio); | ||
733 | if (t) { | ||
734 | seq_printf(s, " I/O Error\n"); | ||
735 | goto done; | ||
736 | } | ||
737 | t = mcp_read(mcp, MCP_GPPU, &gppu); | ||
738 | if (t) { | ||
739 | seq_printf(s, " I/O Error\n"); | ||
740 | goto done; | ||
741 | } | ||
742 | |||
743 | for (t = 0, mask = BIT(0); t < chip->ngpio; t++, mask <<= 1) { | ||
744 | const char *label; | ||
745 | |||
746 | label = gpiochip_is_requested(chip, t); | ||
747 | if (!label) | ||
748 | continue; | ||
749 | |||
750 | seq_printf(s, " gpio-%-3d P%c.%d (%-12s) %s %s %s\n", | ||
751 | chip->base + t, bank, t, label, | ||
752 | (iodir & mask) ? "in " : "out", | ||
753 | (gpio & mask) ? "hi" : "lo", | ||
754 | (gppu & mask) ? "up" : " "); | ||
755 | /* NOTE: ignoring the irq-related registers */ | ||
756 | } | ||
757 | done: | ||
758 | mutex_unlock(&mcp->lock); | ||
759 | } | ||
760 | |||
761 | #else | ||
762 | #define mcp23s08_dbg_show NULL | ||
763 | #endif | ||
764 | |||
765 | /*----------------------------------------------------------------------*/ | ||
766 | |||
767 | static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, | 658 | static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, |
768 | void *data, unsigned addr, unsigned type, | 659 | void *data, unsigned addr, unsigned type, |
769 | unsigned int base, int cs) | 660 | unsigned int base, int cs) |
@@ -784,7 +675,6 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev, | |||
784 | mcp->chip.get = mcp23s08_get; | 675 | mcp->chip.get = mcp23s08_get; |
785 | mcp->chip.direction_output = mcp23s08_direction_output; | 676 | mcp->chip.direction_output = mcp23s08_direction_output; |
786 | mcp->chip.set = mcp23s08_set; | 677 | mcp->chip.set = mcp23s08_set; |
787 | mcp->chip.dbg_show = mcp23s08_dbg_show; | ||
788 | #ifdef CONFIG_OF_GPIO | 678 | #ifdef CONFIG_OF_GPIO |
789 | mcp->chip.of_gpio_n_cells = 2; | 679 | mcp->chip.of_gpio_n_cells = 2; |
790 | mcp->chip.of_node = dev->of_node; | 680 | mcp->chip.of_node = dev->of_node; |