diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-04 15:05:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-04 15:05:32 -0400 |
commit | 2bd80401743568ced7d303b008ae5298ce77e695 (patch) | |
tree | d70278682fca619f7d842faa7c5a5bdce5016cfa /drivers/gpio | |
parent | 99a7583de5ffd5cd82c407aad32bcbdeea09155b (diff) | |
parent | b86c86aa9805b25ee70071d084e618b2c40641b5 (diff) |
Merge tag 'gpio-v4.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij:
"This is the bulk of GPIO changes for the v4.12 kernel cycle.
Core changes:
- Return NULL from gpiod_get_optional() when GPIOLIB is disabled.
This was a much discussed change. It affects use cases where people
write drivers that might or might not be using GPIO resources. I
have decided that this is the lesser evil right now.
- Make gpiod_count() behave consistently across different hardware
descriptions.
- Fix the syntax around open drain/open source to not infer active
high/low semantics.
New drivers:
- A new single-register fixed-direction framework driver for hardware
that have lines controlled by a single register that just work in
one direction (out or in), including IRQ support.
- Support the Fintek F71889A GPIO SuperIO controller.
- Support the National NI 169445 MMIO GPIO.
- Support for the X-Gene derivative of the DWC GPIO controller
- Support for the Rohm BD9571MWV-M PMIC GPIO controller.
- Refactor the Gemini GPIO driver to a generic Faraday FTGPIO driver
and replace both the Gemini and the Moxa ART custom drivers with
this driver.
Driver improvements:
- A whole slew of drivers have their spinlocks chaned to raw
spinlocks as they provide irqchips, and thus we are progressing on
realtime compliance.
- Use devm_irq_alloc_descs() in a slew of drivers, getting managed
resources.
- Support for the embedded PWM controller inside the MVEBU driver.
- Debounce, open source and open drain support for the Aspeed driver.
- Misc smaller fixes like spelling and syntax and whatnot"
* tag 'gpio-v4.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (77 commits)
gpio: f7188x: Add a missing break
gpio: omap: return error if requested debounce time is not possible
gpio: Add ROHM BD9571MWV-M PMIC GPIO driver
gpio: gpio-wcove: fix GPIO IRQ status mask
gpio: DT bindings, move tca9554 from pcf857x to pca953x
gpio: move tca9554 from pcf857x to pca953x
gpio: arizona: Correct check whether the pin is an input
gpio: Add XRA1403 DTS binding documentation
dt-bindings: add exar to vendor prefixes list
gpio: gpio-wcove: fix irq pending status bit width
gpio: dwapb: use dwapb_read instead of readl_relaxed
gpio: aspeed: Add open-source and open-drain support
gpio: aspeed: Add debounce support
gpio: aspeed: dt: Add optional clocks property
gpio: aspeed: dt: Fix description alignment in bindings document
gpio: mvebu: Add limited PWM support
gpio: Use unsigned int for interrupt numbers
gpio: f7188x: Add F71889A GPIO support.
gpio: core: Decouple open drain/source flag with active low/high
gpio: arizona: Correct handling for reading input GPIOs
...
Diffstat (limited to 'drivers/gpio')
45 files changed, 1648 insertions, 605 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 9b1bcb4d0df7..23ca51ee6b28 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -204,14 +204,15 @@ config GPIO_GE_FPGA | |||
204 | and write pin state) for GPIO implemented in a number of GE single | 204 | and write pin state) for GPIO implemented in a number of GE single |
205 | board computers. | 205 | board computers. |
206 | 206 | ||
207 | config GPIO_GEMINI | 207 | config GPIO_FTGPIO010 |
208 | bool "Gemini GPIO" | 208 | bool "Faraday FTGPIO010 GPIO" |
209 | depends on ARCH_GEMINI | ||
210 | depends on OF_GPIO | 209 | depends on OF_GPIO |
211 | select GPIO_GENERIC | 210 | select GPIO_GENERIC |
212 | select GPIOLIB_IRQCHIP | 211 | select GPIOLIB_IRQCHIP |
212 | default (ARCH_GEMINI || ARCH_MOXART) | ||
213 | help | 213 | help |
214 | Support for common GPIOs found in Cortina systems Gemini platforms. | 214 | Support for common GPIOs from the Faraday FTGPIO010 IP core, found in |
215 | Cortina systems Gemini platforms, Moxa ART and others. | ||
215 | 216 | ||
216 | config GPIO_GENERIC_PLATFORM | 217 | config GPIO_GENERIC_PLATFORM |
217 | tristate "Generic memory-mapped GPIO controller support (MMIO platform device)" | 218 | tristate "Generic memory-mapped GPIO controller support (MMIO platform device)" |
@@ -308,14 +309,6 @@ config GPIO_MOCKUP | |||
308 | tools/testing/selftests/gpio/gpio-mockup.sh. Reference the usage in | 309 | tools/testing/selftests/gpio/gpio-mockup.sh. Reference the usage in |
309 | it. | 310 | it. |
310 | 311 | ||
311 | config GPIO_MOXART | ||
312 | bool "MOXART GPIO support" | ||
313 | depends on ARCH_MOXART || COMPILE_TEST | ||
314 | select GPIO_GENERIC | ||
315 | help | ||
316 | Select this option to enable GPIO driver for | ||
317 | MOXA ART SoC devices. | ||
318 | |||
319 | config GPIO_MPC5200 | 312 | config GPIO_MPC5200 |
320 | def_bool y | 313 | def_bool y |
321 | depends on PPC_MPC52xx | 314 | depends on PPC_MPC52xx |
@@ -387,6 +380,12 @@ config GPIO_RCAR | |||
387 | help | 380 | help |
388 | Say yes here to support GPIO on Renesas R-Car SoCs. | 381 | Say yes here to support GPIO on Renesas R-Car SoCs. |
389 | 382 | ||
383 | config GPIO_REG | ||
384 | bool | ||
385 | help | ||
386 | A 32-bit single register GPIO fixed in/out implementation. This | ||
387 | can be used to represent any register as a set of GPIO signals. | ||
388 | |||
390 | config GPIO_SPEAR_SPICS | 389 | config GPIO_SPEAR_SPICS |
391 | bool "ST SPEAr13xx SPI Chip Select as GPIO support" | 390 | bool "ST SPEAr13xx SPI Chip Select as GPIO support" |
392 | depends on PLAT_SPEAR | 391 | depends on PLAT_SPEAR |
@@ -505,7 +504,7 @@ config GPIO_XILINX | |||
505 | 504 | ||
506 | config GPIO_XLP | 505 | config GPIO_XLP |
507 | tristate "Netlogic XLP GPIO support" | 506 | tristate "Netlogic XLP GPIO support" |
508 | depends on OF_GPIO && (CPU_XLP || ARCH_VULCAN || COMPILE_TEST) | 507 | depends on OF_GPIO && (CPU_XLP || ARCH_VULCAN || ARCH_THUNDER2 || COMPILE_TEST) |
509 | select GPIOLIB_IRQCHIP | 508 | select GPIOLIB_IRQCHIP |
510 | help | 509 | help |
511 | This driver provides support for GPIO interface on Netlogic XLP MIPS64 | 510 | This driver provides support for GPIO interface on Netlogic XLP MIPS64 |
@@ -557,7 +556,7 @@ menu "Port-mapped I/O GPIO drivers" | |||
557 | 556 | ||
558 | config GPIO_104_DIO_48E | 557 | config GPIO_104_DIO_48E |
559 | tristate "ACCES 104-DIO-48E GPIO support" | 558 | tristate "ACCES 104-DIO-48E GPIO support" |
560 | depends on ISA_BUS_API | 559 | depends on PC104 && ISA_BUS_API |
561 | select GPIOLIB_IRQCHIP | 560 | select GPIOLIB_IRQCHIP |
562 | help | 561 | help |
563 | Enables GPIO support for the ACCES 104-DIO-48E series (104-DIO-48E, | 562 | Enables GPIO support for the ACCES 104-DIO-48E series (104-DIO-48E, |
@@ -567,7 +566,7 @@ config GPIO_104_DIO_48E | |||
567 | 566 | ||
568 | config GPIO_104_IDIO_16 | 567 | config GPIO_104_IDIO_16 |
569 | tristate "ACCES 104-IDIO-16 GPIO support" | 568 | tristate "ACCES 104-IDIO-16 GPIO support" |
570 | depends on ISA_BUS_API | 569 | depends on PC104 && ISA_BUS_API |
571 | select GPIOLIB_IRQCHIP | 570 | select GPIOLIB_IRQCHIP |
572 | help | 571 | help |
573 | Enables GPIO support for the ACCES 104-IDIO-16 family (104-IDIO-16, | 572 | Enables GPIO support for the ACCES 104-IDIO-16 family (104-IDIO-16, |
@@ -578,7 +577,7 @@ config GPIO_104_IDIO_16 | |||
578 | 577 | ||
579 | config GPIO_104_IDI_48 | 578 | config GPIO_104_IDI_48 |
580 | tristate "ACCES 104-IDI-48 GPIO support" | 579 | tristate "ACCES 104-IDI-48 GPIO support" |
581 | depends on ISA_BUS_API | 580 | depends on PC104 && ISA_BUS_API |
582 | select GPIOLIB_IRQCHIP | 581 | select GPIOLIB_IRQCHIP |
583 | help | 582 | help |
584 | Enables GPIO support for the ACCES 104-IDI-48 family (104-IDI-48A, | 583 | Enables GPIO support for the ACCES 104-IDI-48 family (104-IDI-48A, |
@@ -598,7 +597,7 @@ config GPIO_F7188X | |||
598 | 597 | ||
599 | config GPIO_GPIO_MM | 598 | config GPIO_GPIO_MM |
600 | tristate "Diamond Systems GPIO-MM GPIO support" | 599 | tristate "Diamond Systems GPIO-MM GPIO support" |
601 | depends on ISA_BUS_API | 600 | depends on PC104 && ISA_BUS_API |
602 | help | 601 | help |
603 | Enables GPIO support for the Diamond Systems GPIO-MM and GPIO-MM-12. | 602 | Enables GPIO support for the Diamond Systems GPIO-MM and GPIO-MM-12. |
604 | 603 | ||
@@ -753,7 +752,7 @@ config GPIO_PCA953X | |||
753 | 4 bits: pca9536, pca9537 | 752 | 4 bits: pca9536, pca9537 |
754 | 753 | ||
755 | 8 bits: max7310, max7315, pca6107, pca9534, pca9538, pca9554, | 754 | 8 bits: max7310, max7315, pca6107, pca9534, pca9538, pca9554, |
756 | pca9556, pca9557, pca9574, tca6408, xra1202 | 755 | pca9556, pca9557, pca9574, tca6408, tca9554, xra1202 |
757 | 756 | ||
758 | 16 bits: max7312, max7313, pca9535, pca9539, pca9555, pca9575, | 757 | 16 bits: max7312, max7313, pca9535, pca9539, pca9555, pca9575, |
759 | tca6416 | 758 | tca6416 |
@@ -845,6 +844,17 @@ config GPIO_ARIZONA | |||
845 | help | 844 | help |
846 | Support for GPIOs on Wolfson Arizona class devices. | 845 | Support for GPIOs on Wolfson Arizona class devices. |
847 | 846 | ||
847 | config GPIO_BD9571MWV | ||
848 | tristate "ROHM BD9571 GPIO support" | ||
849 | depends on MFD_BD9571MWV | ||
850 | help | ||
851 | Support for GPIOs on ROHM BD9571 PMIC. There are two GPIOs | ||
852 | available on the ROHM PMIC in total, both of which can also | ||
853 | generate interrupts. | ||
854 | |||
855 | This driver can also be built as a module. If so, the module | ||
856 | will be called gpio-bd9571mwv. | ||
857 | |||
848 | config GPIO_CRYSTAL_COVE | 858 | config GPIO_CRYSTAL_COVE |
849 | tristate "GPIO support for Crystal Cove PMIC" | 859 | tristate "GPIO support for Crystal Cove PMIC" |
850 | depends on (X86 || COMPILE_TEST) && INTEL_SOC_PMIC | 860 | depends on (X86 || COMPILE_TEST) && INTEL_SOC_PMIC |
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index becb96c724fe..68b96277d9fa 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile | |||
@@ -33,6 +33,7 @@ obj-$(CONFIG_GPIO_ATH79) += gpio-ath79.o | |||
33 | obj-$(CONFIG_GPIO_ASPEED) += gpio-aspeed.o | 33 | obj-$(CONFIG_GPIO_ASPEED) += gpio-aspeed.o |
34 | obj-$(CONFIG_GPIO_AXP209) += gpio-axp209.o | 34 | obj-$(CONFIG_GPIO_AXP209) += gpio-axp209.o |
35 | obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o | 35 | obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o |
36 | obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o | ||
36 | obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o | 37 | obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o |
37 | obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o | 38 | obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o |
38 | obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o | 39 | obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o |
@@ -48,8 +49,8 @@ obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o | |||
48 | obj-$(CONFIG_GPIO_ETRAXFS) += gpio-etraxfs.o | 49 | obj-$(CONFIG_GPIO_ETRAXFS) += gpio-etraxfs.o |
49 | obj-$(CONFIG_GPIO_EXAR) += gpio-exar.o | 50 | obj-$(CONFIG_GPIO_EXAR) += gpio-exar.o |
50 | obj-$(CONFIG_GPIO_F7188X) += gpio-f7188x.o | 51 | obj-$(CONFIG_GPIO_F7188X) += gpio-f7188x.o |
52 | obj-$(CONFIG_GPIO_FTGPIO010) += gpio-ftgpio010.o | ||
51 | obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o | 53 | obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o |
52 | obj-$(CONFIG_GPIO_GEMINI) += gpio-gemini.o | ||
53 | obj-$(CONFIG_GPIO_GPIO_MM) += gpio-gpio-mm.o | 54 | obj-$(CONFIG_GPIO_GPIO_MM) += gpio-gpio-mm.o |
54 | obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o | 55 | obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o |
55 | obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o | 56 | obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o |
@@ -80,7 +81,6 @@ obj-$(CONFIG_GPIO_MCP23S08) += gpio-mcp23s08.o | |||
80 | obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o | 81 | obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o |
81 | obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o | 82 | obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o |
82 | obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o | 83 | obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o |
83 | obj-$(CONFIG_GPIO_MOXART) += gpio-moxart.o | ||
84 | obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o | 84 | obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o |
85 | obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o | 85 | obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o |
86 | obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o | 86 | obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o |
@@ -99,6 +99,7 @@ obj-$(CONFIG_GPIO_PXA) += gpio-pxa.o | |||
99 | obj-$(CONFIG_GPIO_RC5T583) += gpio-rc5t583.o | 99 | obj-$(CONFIG_GPIO_RC5T583) += gpio-rc5t583.o |
100 | obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o | 100 | obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o |
101 | obj-$(CONFIG_GPIO_RCAR) += gpio-rcar.o | 101 | obj-$(CONFIG_GPIO_RCAR) += gpio-rcar.o |
102 | obj-$(CONFIG_GPIO_REG) += gpio-reg.o | ||
102 | obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o | 103 | obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o |
103 | obj-$(CONFIG_GPIO_SCH) += gpio-sch.o | 104 | obj-$(CONFIG_GPIO_SCH) += gpio-sch.o |
104 | obj-$(CONFIG_GPIO_SCH311X) += gpio-sch311x.o | 105 | obj-$(CONFIG_GPIO_SCH311X) += gpio-sch311x.o |
diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c index 7031eea165c9..a75511d1ea5d 100644 --- a/drivers/gpio/devres.c +++ b/drivers/gpio/devres.c | |||
@@ -136,7 +136,7 @@ EXPORT_SYMBOL(devm_gpiod_get_index); | |||
136 | * GPIO descriptors returned from this function are automatically disposed on | 136 | * GPIO descriptors returned from this function are automatically disposed on |
137 | * driver detach. | 137 | * driver detach. |
138 | * | 138 | * |
139 | * On successfull request the GPIO pin is configured in accordance with | 139 | * On successful request the GPIO pin is configured in accordance with |
140 | * provided @flags. | 140 | * provided @flags. |
141 | */ | 141 | */ |
142 | struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, | 142 | struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, |
diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c index 17bd2ab4ebe2..61b50c40b87b 100644 --- a/drivers/gpio/gpio-104-dio-48e.c +++ b/drivers/gpio/gpio-104-dio-48e.c | |||
@@ -55,7 +55,7 @@ struct dio48e_gpio { | |||
55 | unsigned char io_state[6]; | 55 | unsigned char io_state[6]; |
56 | unsigned char out_state[6]; | 56 | unsigned char out_state[6]; |
57 | unsigned char control[2]; | 57 | unsigned char control[2]; |
58 | spinlock_t lock; | 58 | raw_spinlock_t lock; |
59 | unsigned base; | 59 | unsigned base; |
60 | unsigned char irq_mask; | 60 | unsigned char irq_mask; |
61 | }; | 61 | }; |
@@ -78,7 +78,7 @@ static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | |||
78 | unsigned long flags; | 78 | unsigned long flags; |
79 | unsigned control; | 79 | unsigned control; |
80 | 80 | ||
81 | spin_lock_irqsave(&dio48egpio->lock, flags); | 81 | raw_spin_lock_irqsave(&dio48egpio->lock, flags); |
82 | 82 | ||
83 | /* Check if configuring Port C */ | 83 | /* Check if configuring Port C */ |
84 | if (io_port == 2 || io_port == 5) { | 84 | if (io_port == 2 || io_port == 5) { |
@@ -103,7 +103,7 @@ static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | |||
103 | control &= ~BIT(7); | 103 | control &= ~BIT(7); |
104 | outb(control, control_addr); | 104 | outb(control, control_addr); |
105 | 105 | ||
106 | spin_unlock_irqrestore(&dio48egpio->lock, flags); | 106 | raw_spin_unlock_irqrestore(&dio48egpio->lock, flags); |
107 | 107 | ||
108 | return 0; | 108 | return 0; |
109 | } | 109 | } |
@@ -120,7 +120,7 @@ static int dio48e_gpio_direction_output(struct gpio_chip *chip, unsigned offset, | |||
120 | unsigned long flags; | 120 | unsigned long flags; |
121 | unsigned control; | 121 | unsigned control; |
122 | 122 | ||
123 | spin_lock_irqsave(&dio48egpio->lock, flags); | 123 | raw_spin_lock_irqsave(&dio48egpio->lock, flags); |
124 | 124 | ||
125 | /* Check if configuring Port C */ | 125 | /* Check if configuring Port C */ |
126 | if (io_port == 2 || io_port == 5) { | 126 | if (io_port == 2 || io_port == 5) { |
@@ -153,7 +153,7 @@ static int dio48e_gpio_direction_output(struct gpio_chip *chip, unsigned offset, | |||
153 | control &= ~BIT(7); | 153 | control &= ~BIT(7); |
154 | outb(control, control_addr); | 154 | outb(control, control_addr); |
155 | 155 | ||
156 | spin_unlock_irqrestore(&dio48egpio->lock, flags); | 156 | raw_spin_unlock_irqrestore(&dio48egpio->lock, flags); |
157 | 157 | ||
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
@@ -167,17 +167,17 @@ static int dio48e_gpio_get(struct gpio_chip *chip, unsigned offset) | |||
167 | unsigned long flags; | 167 | unsigned long flags; |
168 | unsigned port_state; | 168 | unsigned port_state; |
169 | 169 | ||
170 | spin_lock_irqsave(&dio48egpio->lock, flags); | 170 | raw_spin_lock_irqsave(&dio48egpio->lock, flags); |
171 | 171 | ||
172 | /* ensure that GPIO is set for input */ | 172 | /* ensure that GPIO is set for input */ |
173 | if (!(dio48egpio->io_state[port] & mask)) { | 173 | if (!(dio48egpio->io_state[port] & mask)) { |
174 | spin_unlock_irqrestore(&dio48egpio->lock, flags); | 174 | raw_spin_unlock_irqrestore(&dio48egpio->lock, flags); |
175 | return -EINVAL; | 175 | return -EINVAL; |
176 | } | 176 | } |
177 | 177 | ||
178 | port_state = inb(dio48egpio->base + in_port); | 178 | port_state = inb(dio48egpio->base + in_port); |
179 | 179 | ||
180 | spin_unlock_irqrestore(&dio48egpio->lock, flags); | 180 | raw_spin_unlock_irqrestore(&dio48egpio->lock, flags); |
181 | 181 | ||
182 | return !!(port_state & mask); | 182 | return !!(port_state & mask); |
183 | } | 183 | } |
@@ -190,7 +190,7 @@ static void dio48e_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
190 | const unsigned out_port = (port > 2) ? port + 1 : port; | 190 | const unsigned out_port = (port > 2) ? port + 1 : port; |
191 | unsigned long flags; | 191 | unsigned long flags; |
192 | 192 | ||
193 | spin_lock_irqsave(&dio48egpio->lock, flags); | 193 | raw_spin_lock_irqsave(&dio48egpio->lock, flags); |
194 | 194 | ||
195 | if (value) | 195 | if (value) |
196 | dio48egpio->out_state[port] |= mask; | 196 | dio48egpio->out_state[port] |= mask; |
@@ -199,7 +199,7 @@ static void dio48e_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
199 | 199 | ||
200 | outb(dio48egpio->out_state[port], dio48egpio->base + out_port); | 200 | outb(dio48egpio->out_state[port], dio48egpio->base + out_port); |
201 | 201 | ||
202 | spin_unlock_irqrestore(&dio48egpio->lock, flags); | 202 | raw_spin_unlock_irqrestore(&dio48egpio->lock, flags); |
203 | } | 203 | } |
204 | 204 | ||
205 | static void dio48e_gpio_set_multiple(struct gpio_chip *chip, | 205 | static void dio48e_gpio_set_multiple(struct gpio_chip *chip, |
@@ -225,14 +225,14 @@ static void dio48e_gpio_set_multiple(struct gpio_chip *chip, | |||
225 | out_port = (port > 2) ? port + 1 : port; | 225 | out_port = (port > 2) ? port + 1 : port; |
226 | bitmask = mask[BIT_WORD(i)] & bits[BIT_WORD(i)]; | 226 | bitmask = mask[BIT_WORD(i)] & bits[BIT_WORD(i)]; |
227 | 227 | ||
228 | spin_lock_irqsave(&dio48egpio->lock, flags); | 228 | raw_spin_lock_irqsave(&dio48egpio->lock, flags); |
229 | 229 | ||
230 | /* update output state data and set device gpio register */ | 230 | /* update output state data and set device gpio register */ |
231 | dio48egpio->out_state[port] &= ~mask[BIT_WORD(i)]; | 231 | dio48egpio->out_state[port] &= ~mask[BIT_WORD(i)]; |
232 | dio48egpio->out_state[port] |= bitmask; | 232 | dio48egpio->out_state[port] |= bitmask; |
233 | outb(dio48egpio->out_state[port], dio48egpio->base + out_port); | 233 | outb(dio48egpio->out_state[port], dio48egpio->base + out_port); |
234 | 234 | ||
235 | spin_unlock_irqrestore(&dio48egpio->lock, flags); | 235 | raw_spin_unlock_irqrestore(&dio48egpio->lock, flags); |
236 | 236 | ||
237 | /* prepare for next gpio register set */ | 237 | /* prepare for next gpio register set */ |
238 | mask[BIT_WORD(i)] >>= gpio_reg_size; | 238 | mask[BIT_WORD(i)] >>= gpio_reg_size; |
@@ -255,7 +255,7 @@ static void dio48e_irq_mask(struct irq_data *data) | |||
255 | if (offset != 19 && offset != 43) | 255 | if (offset != 19 && offset != 43) |
256 | return; | 256 | return; |
257 | 257 | ||
258 | spin_lock_irqsave(&dio48egpio->lock, flags); | 258 | raw_spin_lock_irqsave(&dio48egpio->lock, flags); |
259 | 259 | ||
260 | if (offset == 19) | 260 | if (offset == 19) |
261 | dio48egpio->irq_mask &= ~BIT(0); | 261 | dio48egpio->irq_mask &= ~BIT(0); |
@@ -266,7 +266,7 @@ static void dio48e_irq_mask(struct irq_data *data) | |||
266 | /* disable interrupts */ | 266 | /* disable interrupts */ |
267 | inb(dio48egpio->base + 0xB); | 267 | inb(dio48egpio->base + 0xB); |
268 | 268 | ||
269 | spin_unlock_irqrestore(&dio48egpio->lock, flags); | 269 | raw_spin_unlock_irqrestore(&dio48egpio->lock, flags); |
270 | } | 270 | } |
271 | 271 | ||
272 | static void dio48e_irq_unmask(struct irq_data *data) | 272 | static void dio48e_irq_unmask(struct irq_data *data) |
@@ -280,7 +280,7 @@ static void dio48e_irq_unmask(struct irq_data *data) | |||
280 | if (offset != 19 && offset != 43) | 280 | if (offset != 19 && offset != 43) |
281 | return; | 281 | return; |
282 | 282 | ||
283 | spin_lock_irqsave(&dio48egpio->lock, flags); | 283 | raw_spin_lock_irqsave(&dio48egpio->lock, flags); |
284 | 284 | ||
285 | if (!dio48egpio->irq_mask) { | 285 | if (!dio48egpio->irq_mask) { |
286 | /* enable interrupts */ | 286 | /* enable interrupts */ |
@@ -293,7 +293,7 @@ static void dio48e_irq_unmask(struct irq_data *data) | |||
293 | else | 293 | else |
294 | dio48egpio->irq_mask |= BIT(1); | 294 | dio48egpio->irq_mask |= BIT(1); |
295 | 295 | ||
296 | spin_unlock_irqrestore(&dio48egpio->lock, flags); | 296 | raw_spin_unlock_irqrestore(&dio48egpio->lock, flags); |
297 | } | 297 | } |
298 | 298 | ||
299 | static int dio48e_irq_set_type(struct irq_data *data, unsigned flow_type) | 299 | static int dio48e_irq_set_type(struct irq_data *data, unsigned flow_type) |
@@ -329,11 +329,11 @@ static irqreturn_t dio48e_irq_handler(int irq, void *dev_id) | |||
329 | generic_handle_irq(irq_find_mapping(chip->irqdomain, | 329 | generic_handle_irq(irq_find_mapping(chip->irqdomain, |
330 | 19 + gpio*24)); | 330 | 19 + gpio*24)); |
331 | 331 | ||
332 | spin_lock(&dio48egpio->lock); | 332 | raw_spin_lock(&dio48egpio->lock); |
333 | 333 | ||
334 | outb(0x00, dio48egpio->base + 0xF); | 334 | outb(0x00, dio48egpio->base + 0xF); |
335 | 335 | ||
336 | spin_unlock(&dio48egpio->lock); | 336 | raw_spin_unlock(&dio48egpio->lock); |
337 | 337 | ||
338 | return IRQ_HANDLED; | 338 | return IRQ_HANDLED; |
339 | } | 339 | } |
@@ -388,7 +388,7 @@ static int dio48e_probe(struct device *dev, unsigned int id) | |||
388 | dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple; | 388 | dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple; |
389 | dio48egpio->base = base[id]; | 389 | dio48egpio->base = base[id]; |
390 | 390 | ||
391 | spin_lock_init(&dio48egpio->lock); | 391 | raw_spin_lock_init(&dio48egpio->lock); |
392 | 392 | ||
393 | err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio); | 393 | err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio); |
394 | if (err) { | 394 | if (err) { |
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index 568375a7ebc2..337c048168d8 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c | |||
@@ -51,7 +51,7 @@ MODULE_PARM_DESC(irq, "ACCES 104-IDI-48 interrupt line numbers"); | |||
51 | */ | 51 | */ |
52 | struct idi_48_gpio { | 52 | struct idi_48_gpio { |
53 | struct gpio_chip chip; | 53 | struct gpio_chip chip; |
54 | spinlock_t lock; | 54 | raw_spinlock_t lock; |
55 | spinlock_t ack_lock; | 55 | spinlock_t ack_lock; |
56 | unsigned char irq_mask[6]; | 56 | unsigned char irq_mask[6]; |
57 | unsigned base; | 57 | unsigned base; |
@@ -112,11 +112,12 @@ static void idi_48_irq_mask(struct irq_data *data) | |||
112 | if (!idi48gpio->irq_mask[boundary]) { | 112 | if (!idi48gpio->irq_mask[boundary]) { |
113 | idi48gpio->cos_enb &= ~BIT(boundary); | 113 | idi48gpio->cos_enb &= ~BIT(boundary); |
114 | 114 | ||
115 | spin_lock_irqsave(&idi48gpio->lock, flags); | 115 | raw_spin_lock_irqsave(&idi48gpio->lock, flags); |
116 | 116 | ||
117 | outb(idi48gpio->cos_enb, idi48gpio->base + 7); | 117 | outb(idi48gpio->cos_enb, idi48gpio->base + 7); |
118 | 118 | ||
119 | spin_unlock_irqrestore(&idi48gpio->lock, flags); | 119 | raw_spin_unlock_irqrestore(&idi48gpio->lock, |
120 | flags); | ||
120 | } | 121 | } |
121 | 122 | ||
122 | return; | 123 | return; |
@@ -145,11 +146,12 @@ static void idi_48_irq_unmask(struct irq_data *data) | |||
145 | if (!prev_irq_mask) { | 146 | if (!prev_irq_mask) { |
146 | idi48gpio->cos_enb |= BIT(boundary); | 147 | idi48gpio->cos_enb |= BIT(boundary); |
147 | 148 | ||
148 | spin_lock_irqsave(&idi48gpio->lock, flags); | 149 | raw_spin_lock_irqsave(&idi48gpio->lock, flags); |
149 | 150 | ||
150 | outb(idi48gpio->cos_enb, idi48gpio->base + 7); | 151 | outb(idi48gpio->cos_enb, idi48gpio->base + 7); |
151 | 152 | ||
152 | spin_unlock_irqrestore(&idi48gpio->lock, flags); | 153 | raw_spin_unlock_irqrestore(&idi48gpio->lock, |
154 | flags); | ||
153 | } | 155 | } |
154 | 156 | ||
155 | return; | 157 | return; |
@@ -186,11 +188,11 @@ static irqreturn_t idi_48_irq_handler(int irq, void *dev_id) | |||
186 | 188 | ||
187 | spin_lock(&idi48gpio->ack_lock); | 189 | spin_lock(&idi48gpio->ack_lock); |
188 | 190 | ||
189 | spin_lock(&idi48gpio->lock); | 191 | raw_spin_lock(&idi48gpio->lock); |
190 | 192 | ||
191 | cos_status = inb(idi48gpio->base + 7); | 193 | cos_status = inb(idi48gpio->base + 7); |
192 | 194 | ||
193 | spin_unlock(&idi48gpio->lock); | 195 | raw_spin_unlock(&idi48gpio->lock); |
194 | 196 | ||
195 | /* IRQ Status (bit 6) is active low (0 = IRQ generated by device) */ | 197 | /* IRQ Status (bit 6) is active low (0 = IRQ generated by device) */ |
196 | if (cos_status & BIT(6)) { | 198 | if (cos_status & BIT(6)) { |
@@ -256,7 +258,7 @@ static int idi_48_probe(struct device *dev, unsigned int id) | |||
256 | idi48gpio->chip.get = idi_48_gpio_get; | 258 | idi48gpio->chip.get = idi_48_gpio_get; |
257 | idi48gpio->base = base[id]; | 259 | idi48gpio->base = base[id]; |
258 | 260 | ||
259 | spin_lock_init(&idi48gpio->lock); | 261 | raw_spin_lock_init(&idi48gpio->lock); |
260 | spin_lock_init(&idi48gpio->ack_lock); | 262 | spin_lock_init(&idi48gpio->ack_lock); |
261 | 263 | ||
262 | err = devm_gpiochip_add_data(dev, &idi48gpio->chip, idi48gpio); | 264 | err = devm_gpiochip_add_data(dev, &idi48gpio->chip, idi48gpio); |
diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index 7053cf736648..5281e1cedb01 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c | |||
@@ -50,7 +50,7 @@ MODULE_PARM_DESC(irq, "ACCES 104-IDIO-16 interrupt line numbers"); | |||
50 | */ | 50 | */ |
51 | struct idio_16_gpio { | 51 | struct idio_16_gpio { |
52 | struct gpio_chip chip; | 52 | struct gpio_chip chip; |
53 | spinlock_t lock; | 53 | raw_spinlock_t lock; |
54 | unsigned long irq_mask; | 54 | unsigned long irq_mask; |
55 | unsigned base; | 55 | unsigned base; |
56 | unsigned out_state; | 56 | unsigned out_state; |
@@ -99,7 +99,7 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
99 | if (offset > 15) | 99 | if (offset > 15) |
100 | return; | 100 | return; |
101 | 101 | ||
102 | spin_lock_irqsave(&idio16gpio->lock, flags); | 102 | raw_spin_lock_irqsave(&idio16gpio->lock, flags); |
103 | 103 | ||
104 | if (value) | 104 | if (value) |
105 | idio16gpio->out_state |= mask; | 105 | idio16gpio->out_state |= mask; |
@@ -111,7 +111,7 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
111 | else | 111 | else |
112 | outb(idio16gpio->out_state, idio16gpio->base); | 112 | outb(idio16gpio->out_state, idio16gpio->base); |
113 | 113 | ||
114 | spin_unlock_irqrestore(&idio16gpio->lock, flags); | 114 | raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); |
115 | } | 115 | } |
116 | 116 | ||
117 | static void idio_16_gpio_set_multiple(struct gpio_chip *chip, | 117 | static void idio_16_gpio_set_multiple(struct gpio_chip *chip, |
@@ -120,7 +120,7 @@ static void idio_16_gpio_set_multiple(struct gpio_chip *chip, | |||
120 | struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); | 120 | struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); |
121 | unsigned long flags; | 121 | unsigned long flags; |
122 | 122 | ||
123 | spin_lock_irqsave(&idio16gpio->lock, flags); | 123 | raw_spin_lock_irqsave(&idio16gpio->lock, flags); |
124 | 124 | ||
125 | idio16gpio->out_state &= ~*mask; | 125 | idio16gpio->out_state &= ~*mask; |
126 | idio16gpio->out_state |= *mask & *bits; | 126 | idio16gpio->out_state |= *mask & *bits; |
@@ -130,7 +130,7 @@ static void idio_16_gpio_set_multiple(struct gpio_chip *chip, | |||
130 | if ((*mask >> 8) & 0xFF) | 130 | if ((*mask >> 8) & 0xFF) |
131 | outb(idio16gpio->out_state >> 8, idio16gpio->base + 4); | 131 | outb(idio16gpio->out_state >> 8, idio16gpio->base + 4); |
132 | 132 | ||
133 | spin_unlock_irqrestore(&idio16gpio->lock, flags); | 133 | raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); |
134 | } | 134 | } |
135 | 135 | ||
136 | static void idio_16_irq_ack(struct irq_data *data) | 136 | static void idio_16_irq_ack(struct irq_data *data) |
@@ -147,11 +147,11 @@ static void idio_16_irq_mask(struct irq_data *data) | |||
147 | idio16gpio->irq_mask &= ~mask; | 147 | idio16gpio->irq_mask &= ~mask; |
148 | 148 | ||
149 | if (!idio16gpio->irq_mask) { | 149 | if (!idio16gpio->irq_mask) { |
150 | spin_lock_irqsave(&idio16gpio->lock, flags); | 150 | raw_spin_lock_irqsave(&idio16gpio->lock, flags); |
151 | 151 | ||
152 | outb(0, idio16gpio->base + 2); | 152 | outb(0, idio16gpio->base + 2); |
153 | 153 | ||
154 | spin_unlock_irqrestore(&idio16gpio->lock, flags); | 154 | raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
@@ -166,11 +166,11 @@ static void idio_16_irq_unmask(struct irq_data *data) | |||
166 | idio16gpio->irq_mask |= mask; | 166 | idio16gpio->irq_mask |= mask; |
167 | 167 | ||
168 | if (!prev_irq_mask) { | 168 | if (!prev_irq_mask) { |
169 | spin_lock_irqsave(&idio16gpio->lock, flags); | 169 | raw_spin_lock_irqsave(&idio16gpio->lock, flags); |
170 | 170 | ||
171 | inb(idio16gpio->base + 2); | 171 | inb(idio16gpio->base + 2); |
172 | 172 | ||
173 | spin_unlock_irqrestore(&idio16gpio->lock, flags); | 173 | raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
@@ -201,11 +201,11 @@ static irqreturn_t idio_16_irq_handler(int irq, void *dev_id) | |||
201 | for_each_set_bit(gpio, &idio16gpio->irq_mask, chip->ngpio) | 201 | for_each_set_bit(gpio, &idio16gpio->irq_mask, chip->ngpio) |
202 | generic_handle_irq(irq_find_mapping(chip->irqdomain, gpio)); | 202 | generic_handle_irq(irq_find_mapping(chip->irqdomain, gpio)); |
203 | 203 | ||
204 | spin_lock(&idio16gpio->lock); | 204 | raw_spin_lock(&idio16gpio->lock); |
205 | 205 | ||
206 | outb(0, idio16gpio->base + 1); | 206 | outb(0, idio16gpio->base + 1); |
207 | 207 | ||
208 | spin_unlock(&idio16gpio->lock); | 208 | raw_spin_unlock(&idio16gpio->lock); |
209 | 209 | ||
210 | return IRQ_HANDLED; | 210 | return IRQ_HANDLED; |
211 | } | 211 | } |
@@ -249,7 +249,7 @@ static int idio_16_probe(struct device *dev, unsigned int id) | |||
249 | idio16gpio->base = base[id]; | 249 | idio16gpio->base = base[id]; |
250 | idio16gpio->out_state = 0xFFFF; | 250 | idio16gpio->out_state = 0xFFFF; |
251 | 251 | ||
252 | spin_lock_init(&idio16gpio->lock); | 252 | raw_spin_lock_init(&idio16gpio->lock); |
253 | 253 | ||
254 | err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio); | 254 | err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio); |
255 | if (err) { | 255 | if (err) { |
diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index 3fe6a21e05a5..17485dc20384 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c | |||
@@ -38,7 +38,7 @@ | |||
38 | */ | 38 | */ |
39 | struct altera_gpio_chip { | 39 | struct altera_gpio_chip { |
40 | struct of_mm_gpio_chip mmchip; | 40 | struct of_mm_gpio_chip mmchip; |
41 | spinlock_t gpio_lock; | 41 | raw_spinlock_t gpio_lock; |
42 | int interrupt_trigger; | 42 | int interrupt_trigger; |
43 | int mapped_irq; | 43 | int mapped_irq; |
44 | }; | 44 | }; |
@@ -53,12 +53,12 @@ static void altera_gpio_irq_unmask(struct irq_data *d) | |||
53 | altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); | 53 | altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); |
54 | mm_gc = &altera_gc->mmchip; | 54 | mm_gc = &altera_gc->mmchip; |
55 | 55 | ||
56 | spin_lock_irqsave(&altera_gc->gpio_lock, flags); | 56 | raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags); |
57 | intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK); | 57 | intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK); |
58 | /* Set ALTERA_GPIO_IRQ_MASK bit to unmask */ | 58 | /* Set ALTERA_GPIO_IRQ_MASK bit to unmask */ |
59 | intmask |= BIT(irqd_to_hwirq(d)); | 59 | intmask |= BIT(irqd_to_hwirq(d)); |
60 | writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK); | 60 | writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK); |
61 | spin_unlock_irqrestore(&altera_gc->gpio_lock, flags); | 61 | raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags); |
62 | } | 62 | } |
63 | 63 | ||
64 | static void altera_gpio_irq_mask(struct irq_data *d) | 64 | static void altera_gpio_irq_mask(struct irq_data *d) |
@@ -71,12 +71,12 @@ static void altera_gpio_irq_mask(struct irq_data *d) | |||
71 | altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); | 71 | altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); |
72 | mm_gc = &altera_gc->mmchip; | 72 | mm_gc = &altera_gc->mmchip; |
73 | 73 | ||
74 | spin_lock_irqsave(&altera_gc->gpio_lock, flags); | 74 | raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags); |
75 | intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK); | 75 | intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK); |
76 | /* Clear ALTERA_GPIO_IRQ_MASK bit to mask */ | 76 | /* Clear ALTERA_GPIO_IRQ_MASK bit to mask */ |
77 | intmask &= ~BIT(irqd_to_hwirq(d)); | 77 | intmask &= ~BIT(irqd_to_hwirq(d)); |
78 | writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK); | 78 | writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK); |
79 | spin_unlock_irqrestore(&altera_gc->gpio_lock, flags); | 79 | raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags); |
80 | } | 80 | } |
81 | 81 | ||
82 | /** | 82 | /** |
@@ -140,14 +140,14 @@ static void altera_gpio_set(struct gpio_chip *gc, unsigned offset, int value) | |||
140 | mm_gc = to_of_mm_gpio_chip(gc); | 140 | mm_gc = to_of_mm_gpio_chip(gc); |
141 | chip = gpiochip_get_data(gc); | 141 | chip = gpiochip_get_data(gc); |
142 | 142 | ||
143 | spin_lock_irqsave(&chip->gpio_lock, flags); | 143 | raw_spin_lock_irqsave(&chip->gpio_lock, flags); |
144 | data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); | 144 | data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); |
145 | if (value) | 145 | if (value) |
146 | data_reg |= BIT(offset); | 146 | data_reg |= BIT(offset); |
147 | else | 147 | else |
148 | data_reg &= ~BIT(offset); | 148 | data_reg &= ~BIT(offset); |
149 | writel(data_reg, mm_gc->regs + ALTERA_GPIO_DATA); | 149 | writel(data_reg, mm_gc->regs + ALTERA_GPIO_DATA); |
150 | spin_unlock_irqrestore(&chip->gpio_lock, flags); | 150 | raw_spin_unlock_irqrestore(&chip->gpio_lock, flags); |
151 | } | 151 | } |
152 | 152 | ||
153 | static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset) | 153 | static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset) |
@@ -160,12 +160,12 @@ static int altera_gpio_direction_input(struct gpio_chip *gc, unsigned offset) | |||
160 | mm_gc = to_of_mm_gpio_chip(gc); | 160 | mm_gc = to_of_mm_gpio_chip(gc); |
161 | chip = gpiochip_get_data(gc); | 161 | chip = gpiochip_get_data(gc); |
162 | 162 | ||
163 | spin_lock_irqsave(&chip->gpio_lock, flags); | 163 | raw_spin_lock_irqsave(&chip->gpio_lock, flags); |
164 | /* Set pin as input, assumes software controlled IP */ | 164 | /* Set pin as input, assumes software controlled IP */ |
165 | gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR); | 165 | gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR); |
166 | gpio_ddr &= ~BIT(offset); | 166 | gpio_ddr &= ~BIT(offset); |
167 | writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR); | 167 | writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR); |
168 | spin_unlock_irqrestore(&chip->gpio_lock, flags); | 168 | raw_spin_unlock_irqrestore(&chip->gpio_lock, flags); |
169 | 169 | ||
170 | return 0; | 170 | return 0; |
171 | } | 171 | } |
@@ -181,7 +181,7 @@ static int altera_gpio_direction_output(struct gpio_chip *gc, | |||
181 | mm_gc = to_of_mm_gpio_chip(gc); | 181 | mm_gc = to_of_mm_gpio_chip(gc); |
182 | chip = gpiochip_get_data(gc); | 182 | chip = gpiochip_get_data(gc); |
183 | 183 | ||
184 | spin_lock_irqsave(&chip->gpio_lock, flags); | 184 | raw_spin_lock_irqsave(&chip->gpio_lock, flags); |
185 | /* Sets the GPIO value */ | 185 | /* Sets the GPIO value */ |
186 | data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); | 186 | data_reg = readl(mm_gc->regs + ALTERA_GPIO_DATA); |
187 | if (value) | 187 | if (value) |
@@ -194,7 +194,7 @@ static int altera_gpio_direction_output(struct gpio_chip *gc, | |||
194 | gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR); | 194 | gpio_ddr = readl(mm_gc->regs + ALTERA_GPIO_DIR); |
195 | gpio_ddr |= BIT(offset); | 195 | gpio_ddr |= BIT(offset); |
196 | writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR); | 196 | writel(gpio_ddr, mm_gc->regs + ALTERA_GPIO_DIR); |
197 | spin_unlock_irqrestore(&chip->gpio_lock, flags); | 197 | raw_spin_unlock_irqrestore(&chip->gpio_lock, flags); |
198 | 198 | ||
199 | return 0; | 199 | return 0; |
200 | } | 200 | } |
@@ -262,7 +262,7 @@ static int altera_gpio_probe(struct platform_device *pdev) | |||
262 | if (!altera_gc) | 262 | if (!altera_gc) |
263 | return -ENOMEM; | 263 | return -ENOMEM; |
264 | 264 | ||
265 | spin_lock_init(&altera_gc->gpio_lock); | 265 | raw_spin_lock_init(&altera_gc->gpio_lock); |
266 | 266 | ||
267 | if (of_property_read_u32(node, "altr,ngpio", ®)) | 267 | if (of_property_read_u32(node, "altr,ngpio", ®)) |
268 | /* By default assume maximum ngpio */ | 268 | /* By default assume maximum ngpio */ |
diff --git a/drivers/gpio/gpio-arizona.c b/drivers/gpio/gpio-arizona.c index 1f91557717a6..cd23fd727f95 100644 --- a/drivers/gpio/gpio-arizona.c +++ b/drivers/gpio/gpio-arizona.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/gpio.h> | 18 | #include <linux/gpio.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/pm_runtime.h> | ||
20 | #include <linux/seq_file.h> | 21 | #include <linux/seq_file.h> |
21 | 22 | ||
22 | #include <linux/mfd/arizona/core.h> | 23 | #include <linux/mfd/arizona/core.h> |
@@ -41,13 +42,38 @@ static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset) | |||
41 | { | 42 | { |
42 | struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip); | 43 | struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip); |
43 | struct arizona *arizona = arizona_gpio->arizona; | 44 | struct arizona *arizona = arizona_gpio->arizona; |
44 | unsigned int val; | 45 | unsigned int reg, val; |
45 | int ret; | 46 | int ret; |
46 | 47 | ||
47 | ret = regmap_read(arizona->regmap, ARIZONA_GPIO1_CTRL + offset, &val); | 48 | reg = ARIZONA_GPIO1_CTRL + offset; |
49 | ret = regmap_read(arizona->regmap, reg, &val); | ||
48 | if (ret < 0) | 50 | if (ret < 0) |
49 | return ret; | 51 | return ret; |
50 | 52 | ||
53 | /* Resume to read actual registers for input pins */ | ||
54 | if (val & ARIZONA_GPN_DIR) { | ||
55 | ret = pm_runtime_get_sync(chip->parent); | ||
56 | if (ret < 0) { | ||
57 | dev_err(chip->parent, "Failed to resume: %d\n", ret); | ||
58 | return ret; | ||
59 | } | ||
60 | |||
61 | /* Register is cached, drop it to ensure a physical read */ | ||
62 | ret = regcache_drop_region(arizona->regmap, reg, reg); | ||
63 | if (ret < 0) { | ||
64 | dev_err(chip->parent, "Failed to drop cache: %d\n", | ||
65 | ret); | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | ret = regmap_read(arizona->regmap, reg, &val); | ||
70 | if (ret < 0) | ||
71 | return ret; | ||
72 | |||
73 | pm_runtime_mark_last_busy(chip->parent); | ||
74 | pm_runtime_put_autosuspend(chip->parent); | ||
75 | } | ||
76 | |||
51 | if (val & ARIZONA_GPN_LVL) | 77 | if (val & ARIZONA_GPN_LVL) |
52 | return 1; | 78 | return 1; |
53 | else | 79 | else |
diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c index fb16cc771c0d..ccea609676ee 100644 --- a/drivers/gpio/gpio-aspeed.c +++ b/drivers/gpio/gpio-aspeed.c | |||
@@ -9,14 +9,18 @@ | |||
9 | * 2 of the License, or (at your option) any later version. | 9 | * 2 of the License, or (at your option) any later version. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/module.h> | 12 | #include <asm/div64.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/clk.h> |
14 | #include <linux/gpio/driver.h> | ||
15 | #include <linux/hashtable.h> | ||
14 | #include <linux/init.h> | 16 | #include <linux/init.h> |
15 | #include <linux/io.h> | 17 | #include <linux/io.h> |
16 | #include <linux/spinlock.h> | 18 | #include <linux/kernel.h> |
17 | #include <linux/platform_device.h> | 19 | #include <linux/module.h> |
18 | #include <linux/gpio/driver.h> | ||
19 | #include <linux/pinctrl/consumer.h> | 20 | #include <linux/pinctrl/consumer.h> |
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/spinlock.h> | ||
23 | #include <linux/string.h> | ||
20 | 24 | ||
21 | struct aspeed_bank_props { | 25 | struct aspeed_bank_props { |
22 | unsigned int bank; | 26 | unsigned int bank; |
@@ -29,59 +33,85 @@ struct aspeed_gpio_config { | |||
29 | const struct aspeed_bank_props *props; | 33 | const struct aspeed_bank_props *props; |
30 | }; | 34 | }; |
31 | 35 | ||
36 | /* | ||
37 | * @offset_timer: Maps an offset to an @timer_users index, or zero if disabled | ||
38 | * @timer_users: Tracks the number of users for each timer | ||
39 | * | ||
40 | * The @timer_users has four elements but the first element is unused. This is | ||
41 | * to simplify accounting and indexing, as a zero value in @offset_timer | ||
42 | * represents disabled debouncing for the GPIO. Any other value for an element | ||
43 | * of @offset_timer is used as an index into @timer_users. This behaviour of | ||
44 | * the zero value aligns with the behaviour of zero built from the timer | ||
45 | * configuration registers (i.e. debouncing is disabled). | ||
46 | */ | ||
32 | struct aspeed_gpio { | 47 | struct aspeed_gpio { |
33 | struct gpio_chip chip; | 48 | struct gpio_chip chip; |
34 | spinlock_t lock; | 49 | spinlock_t lock; |
35 | void __iomem *base; | 50 | void __iomem *base; |
36 | int irq; | 51 | int irq; |
37 | const struct aspeed_gpio_config *config; | 52 | const struct aspeed_gpio_config *config; |
53 | |||
54 | u8 *offset_timer; | ||
55 | unsigned int timer_users[4]; | ||
56 | struct clk *clk; | ||
38 | }; | 57 | }; |
39 | 58 | ||
40 | struct aspeed_gpio_bank { | 59 | struct aspeed_gpio_bank { |
41 | uint16_t val_regs; | 60 | uint16_t val_regs; |
42 | uint16_t irq_regs; | 61 | uint16_t irq_regs; |
62 | uint16_t debounce_regs; | ||
43 | const char names[4][3]; | 63 | const char names[4][3]; |
44 | }; | 64 | }; |
45 | 65 | ||
66 | static const int debounce_timers[4] = { 0x00, 0x50, 0x54, 0x58 }; | ||
67 | |||
46 | static const struct aspeed_gpio_bank aspeed_gpio_banks[] = { | 68 | static const struct aspeed_gpio_bank aspeed_gpio_banks[] = { |
47 | { | 69 | { |
48 | .val_regs = 0x0000, | 70 | .val_regs = 0x0000, |
49 | .irq_regs = 0x0008, | 71 | .irq_regs = 0x0008, |
72 | .debounce_regs = 0x0040, | ||
50 | .names = { "A", "B", "C", "D" }, | 73 | .names = { "A", "B", "C", "D" }, |
51 | }, | 74 | }, |
52 | { | 75 | { |
53 | .val_regs = 0x0020, | 76 | .val_regs = 0x0020, |
54 | .irq_regs = 0x0028, | 77 | .irq_regs = 0x0028, |
78 | .debounce_regs = 0x0048, | ||
55 | .names = { "E", "F", "G", "H" }, | 79 | .names = { "E", "F", "G", "H" }, |
56 | }, | 80 | }, |
57 | { | 81 | { |
58 | .val_regs = 0x0070, | 82 | .val_regs = 0x0070, |
59 | .irq_regs = 0x0098, | 83 | .irq_regs = 0x0098, |
84 | .debounce_regs = 0x00b0, | ||
60 | .names = { "I", "J", "K", "L" }, | 85 | .names = { "I", "J", "K", "L" }, |
61 | }, | 86 | }, |
62 | { | 87 | { |
63 | .val_regs = 0x0078, | 88 | .val_regs = 0x0078, |
64 | .irq_regs = 0x00e8, | 89 | .irq_regs = 0x00e8, |
90 | .debounce_regs = 0x0100, | ||
65 | .names = { "M", "N", "O", "P" }, | 91 | .names = { "M", "N", "O", "P" }, |
66 | }, | 92 | }, |
67 | { | 93 | { |
68 | .val_regs = 0x0080, | 94 | .val_regs = 0x0080, |
69 | .irq_regs = 0x0118, | 95 | .irq_regs = 0x0118, |
96 | .debounce_regs = 0x0130, | ||
70 | .names = { "Q", "R", "S", "T" }, | 97 | .names = { "Q", "R", "S", "T" }, |
71 | }, | 98 | }, |
72 | { | 99 | { |
73 | .val_regs = 0x0088, | 100 | .val_regs = 0x0088, |
74 | .irq_regs = 0x0148, | 101 | .irq_regs = 0x0148, |
102 | .debounce_regs = 0x0160, | ||
75 | .names = { "U", "V", "W", "X" }, | 103 | .names = { "U", "V", "W", "X" }, |
76 | }, | 104 | }, |
77 | { | 105 | { |
78 | .val_regs = 0x01E0, | 106 | .val_regs = 0x01E0, |
79 | .irq_regs = 0x0178, | 107 | .irq_regs = 0x0178, |
108 | .debounce_regs = 0x0190, | ||
80 | .names = { "Y", "Z", "AA", "AB" }, | 109 | .names = { "Y", "Z", "AA", "AB" }, |
81 | }, | 110 | }, |
82 | { | 111 | { |
83 | .val_regs = 0x01E8, | 112 | .val_regs = 0x01E8, |
84 | .irq_regs = 0x01A8, | 113 | .irq_regs = 0x01A8, |
114 | .debounce_regs = 0x01c0, | ||
85 | .names = { "AC", "", "", "" }, | 115 | .names = { "AC", "", "", "" }, |
86 | }, | 116 | }, |
87 | }; | 117 | }; |
@@ -99,6 +129,13 @@ static const struct aspeed_gpio_bank aspeed_gpio_banks[] = { | |||
99 | #define GPIO_IRQ_TYPE2 0x0c | 129 | #define GPIO_IRQ_TYPE2 0x0c |
100 | #define GPIO_IRQ_STATUS 0x10 | 130 | #define GPIO_IRQ_STATUS 0x10 |
101 | 131 | ||
132 | #define GPIO_DEBOUNCE_SEL1 0x00 | ||
133 | #define GPIO_DEBOUNCE_SEL2 0x04 | ||
134 | |||
135 | #define _GPIO_SET_DEBOUNCE(t, o, i) ((!!((t) & BIT(i))) << GPIO_OFFSET(o)) | ||
136 | #define GPIO_SET_DEBOUNCE1(t, o) _GPIO_SET_DEBOUNCE(t, o, 1) | ||
137 | #define GPIO_SET_DEBOUNCE2(t, o) _GPIO_SET_DEBOUNCE(t, o, 0) | ||
138 | |||
102 | static const struct aspeed_gpio_bank *to_bank(unsigned int offset) | 139 | static const struct aspeed_gpio_bank *to_bank(unsigned int offset) |
103 | { | 140 | { |
104 | unsigned int bank = GPIO_BANK(offset); | 141 | unsigned int bank = GPIO_BANK(offset); |
@@ -144,6 +181,7 @@ static inline bool have_input(struct aspeed_gpio *gpio, unsigned int offset) | |||
144 | } | 181 | } |
145 | 182 | ||
146 | #define have_irq(g, o) have_input((g), (o)) | 183 | #define have_irq(g, o) have_input((g), (o)) |
184 | #define have_debounce(g, o) have_input((g), (o)) | ||
147 | 185 | ||
148 | static inline bool have_output(struct aspeed_gpio *gpio, unsigned int offset) | 186 | static inline bool have_output(struct aspeed_gpio *gpio, unsigned int offset) |
149 | { | 187 | { |
@@ -506,6 +544,231 @@ static void aspeed_gpio_free(struct gpio_chip *chip, unsigned int offset) | |||
506 | pinctrl_free_gpio(chip->base + offset); | 544 | pinctrl_free_gpio(chip->base + offset); |
507 | } | 545 | } |
508 | 546 | ||
547 | static inline void __iomem *bank_debounce_reg(struct aspeed_gpio *gpio, | ||
548 | const struct aspeed_gpio_bank *bank, | ||
549 | unsigned int reg) | ||
550 | { | ||
551 | return gpio->base + bank->debounce_regs + reg; | ||
552 | } | ||
553 | |||
554 | static int usecs_to_cycles(struct aspeed_gpio *gpio, unsigned long usecs, | ||
555 | u32 *cycles) | ||
556 | { | ||
557 | u64 rate; | ||
558 | u64 n; | ||
559 | u32 r; | ||
560 | |||
561 | rate = clk_get_rate(gpio->clk); | ||
562 | if (!rate) | ||
563 | return -ENOTSUPP; | ||
564 | |||
565 | n = rate * usecs; | ||
566 | r = do_div(n, 1000000); | ||
567 | |||
568 | if (n >= U32_MAX) | ||
569 | return -ERANGE; | ||
570 | |||
571 | /* At least as long as the requested time */ | ||
572 | *cycles = n + (!!r); | ||
573 | |||
574 | return 0; | ||
575 | } | ||
576 | |||
577 | /* Call under gpio->lock */ | ||
578 | static int register_allocated_timer(struct aspeed_gpio *gpio, | ||
579 | unsigned int offset, unsigned int timer) | ||
580 | { | ||
581 | if (WARN(gpio->offset_timer[offset] != 0, | ||
582 | "Offset %d already allocated timer %d\n", | ||
583 | offset, gpio->offset_timer[offset])) | ||
584 | return -EINVAL; | ||
585 | |||
586 | if (WARN(gpio->timer_users[timer] == UINT_MAX, | ||
587 | "Timer user count would overflow\n")) | ||
588 | return -EPERM; | ||
589 | |||
590 | gpio->offset_timer[offset] = timer; | ||
591 | gpio->timer_users[timer]++; | ||
592 | |||
593 | return 0; | ||
594 | } | ||
595 | |||
596 | /* Call under gpio->lock */ | ||
597 | static int unregister_allocated_timer(struct aspeed_gpio *gpio, | ||
598 | unsigned int offset) | ||
599 | { | ||
600 | if (WARN(gpio->offset_timer[offset] == 0, | ||
601 | "No timer allocated to offset %d\n", offset)) | ||
602 | return -EINVAL; | ||
603 | |||
604 | if (WARN(gpio->timer_users[gpio->offset_timer[offset]] == 0, | ||
605 | "No users recorded for timer %d\n", | ||
606 | gpio->offset_timer[offset])) | ||
607 | return -EINVAL; | ||
608 | |||
609 | gpio->timer_users[gpio->offset_timer[offset]]--; | ||
610 | gpio->offset_timer[offset] = 0; | ||
611 | |||
612 | return 0; | ||
613 | } | ||
614 | |||
615 | /* Call under gpio->lock */ | ||
616 | static inline bool timer_allocation_registered(struct aspeed_gpio *gpio, | ||
617 | unsigned int offset) | ||
618 | { | ||
619 | return gpio->offset_timer[offset] > 0; | ||
620 | } | ||
621 | |||
622 | /* Call under gpio->lock */ | ||
623 | static void configure_timer(struct aspeed_gpio *gpio, unsigned int offset, | ||
624 | unsigned int timer) | ||
625 | { | ||
626 | const struct aspeed_gpio_bank *bank = to_bank(offset); | ||
627 | const u32 mask = GPIO_BIT(offset); | ||
628 | void __iomem *addr; | ||
629 | u32 val; | ||
630 | |||
631 | addr = bank_debounce_reg(gpio, bank, GPIO_DEBOUNCE_SEL1); | ||
632 | val = ioread32(addr); | ||
633 | iowrite32((val & ~mask) | GPIO_SET_DEBOUNCE1(timer, offset), addr); | ||
634 | |||
635 | addr = bank_debounce_reg(gpio, bank, GPIO_DEBOUNCE_SEL2); | ||
636 | val = ioread32(addr); | ||
637 | iowrite32((val & ~mask) | GPIO_SET_DEBOUNCE2(timer, offset), addr); | ||
638 | } | ||
639 | |||
640 | static int enable_debounce(struct gpio_chip *chip, unsigned int offset, | ||
641 | unsigned long usecs) | ||
642 | { | ||
643 | struct aspeed_gpio *gpio = gpiochip_get_data(chip); | ||
644 | u32 requested_cycles; | ||
645 | unsigned long flags; | ||
646 | int rc; | ||
647 | int i; | ||
648 | |||
649 | rc = usecs_to_cycles(gpio, usecs, &requested_cycles); | ||
650 | if (rc < 0) { | ||
651 | dev_warn(chip->parent, "Failed to convert %luus to cycles at %luHz: %d\n", | ||
652 | usecs, clk_get_rate(gpio->clk), rc); | ||
653 | return rc; | ||
654 | } | ||
655 | |||
656 | spin_lock_irqsave(&gpio->lock, flags); | ||
657 | |||
658 | if (timer_allocation_registered(gpio, offset)) { | ||
659 | rc = unregister_allocated_timer(gpio, offset); | ||
660 | if (rc < 0) | ||
661 | goto out; | ||
662 | } | ||
663 | |||
664 | /* Try to find a timer already configured for the debounce period */ | ||
665 | for (i = 1; i < ARRAY_SIZE(debounce_timers); i++) { | ||
666 | u32 cycles; | ||
667 | |||
668 | cycles = ioread32(gpio->base + debounce_timers[i]); | ||
669 | if (requested_cycles == cycles) | ||
670 | break; | ||
671 | } | ||
672 | |||
673 | if (i == ARRAY_SIZE(debounce_timers)) { | ||
674 | int j; | ||
675 | |||
676 | /* | ||
677 | * As there are no timers configured for the requested debounce | ||
678 | * period, find an unused timer instead | ||
679 | */ | ||
680 | for (j = 1; j < ARRAY_SIZE(gpio->timer_users); j++) { | ||
681 | if (gpio->timer_users[j] == 0) | ||
682 | break; | ||
683 | } | ||
684 | |||
685 | if (j == ARRAY_SIZE(gpio->timer_users)) { | ||
686 | dev_warn(chip->parent, | ||
687 | "Debounce timers exhausted, cannot debounce for period %luus\n", | ||
688 | usecs); | ||
689 | |||
690 | rc = -EPERM; | ||
691 | |||
692 | /* | ||
693 | * We already adjusted the accounting to remove @offset | ||
694 | * as a user of its previous timer, so also configure | ||
695 | * the hardware so @offset has timers disabled for | ||
696 | * consistency. | ||
697 | */ | ||
698 | configure_timer(gpio, offset, 0); | ||
699 | goto out; | ||
700 | } | ||
701 | |||
702 | i = j; | ||
703 | |||
704 | iowrite32(requested_cycles, gpio->base + debounce_timers[i]); | ||
705 | } | ||
706 | |||
707 | if (WARN(i == 0, "Cannot register index of disabled timer\n")) { | ||
708 | rc = -EINVAL; | ||
709 | goto out; | ||
710 | } | ||
711 | |||
712 | register_allocated_timer(gpio, offset, i); | ||
713 | configure_timer(gpio, offset, i); | ||
714 | |||
715 | out: | ||
716 | spin_unlock_irqrestore(&gpio->lock, flags); | ||
717 | |||
718 | return rc; | ||
719 | } | ||
720 | |||
721 | static int disable_debounce(struct gpio_chip *chip, unsigned int offset) | ||
722 | { | ||
723 | struct aspeed_gpio *gpio = gpiochip_get_data(chip); | ||
724 | unsigned long flags; | ||
725 | int rc; | ||
726 | |||
727 | spin_lock_irqsave(&gpio->lock, flags); | ||
728 | |||
729 | rc = unregister_allocated_timer(gpio, offset); | ||
730 | if (!rc) | ||
731 | configure_timer(gpio, offset, 0); | ||
732 | |||
733 | spin_unlock_irqrestore(&gpio->lock, flags); | ||
734 | |||
735 | return rc; | ||
736 | } | ||
737 | |||
738 | static int set_debounce(struct gpio_chip *chip, unsigned int offset, | ||
739 | unsigned long usecs) | ||
740 | { | ||
741 | struct aspeed_gpio *gpio = gpiochip_get_data(chip); | ||
742 | |||
743 | if (!have_debounce(gpio, offset)) | ||
744 | return -ENOTSUPP; | ||
745 | |||
746 | if (usecs) | ||
747 | return enable_debounce(chip, offset, usecs); | ||
748 | |||
749 | return disable_debounce(chip, offset); | ||
750 | } | ||
751 | |||
752 | static int aspeed_gpio_set_config(struct gpio_chip *chip, unsigned int offset, | ||
753 | unsigned long config) | ||
754 | { | ||
755 | unsigned long param = pinconf_to_config_param(config); | ||
756 | u32 arg = pinconf_to_config_argument(config); | ||
757 | |||
758 | if (param == PIN_CONFIG_INPUT_DEBOUNCE) | ||
759 | return set_debounce(chip, offset, arg); | ||
760 | else if (param == PIN_CONFIG_BIAS_DISABLE || | ||
761 | param == PIN_CONFIG_BIAS_PULL_DOWN || | ||
762 | param == PIN_CONFIG_DRIVE_STRENGTH) | ||
763 | return pinctrl_gpio_set_config(offset, config); | ||
764 | else if (param == PIN_CONFIG_DRIVE_OPEN_DRAIN || | ||
765 | param == PIN_CONFIG_DRIVE_OPEN_SOURCE) | ||
766 | /* Return -ENOTSUPP to trigger emulation, as per datasheet */ | ||
767 | return -ENOTSUPP; | ||
768 | |||
769 | return -ENOTSUPP; | ||
770 | } | ||
771 | |||
509 | /* | 772 | /* |
510 | * Any banks not specified in a struct aspeed_bank_props array are assumed to | 773 | * Any banks not specified in a struct aspeed_bank_props array are assumed to |
511 | * have the properties: | 774 | * have the properties: |
@@ -565,8 +828,16 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) | |||
565 | if (!gpio_id) | 828 | if (!gpio_id) |
566 | return -EINVAL; | 829 | return -EINVAL; |
567 | 830 | ||
831 | gpio->clk = of_clk_get(pdev->dev.of_node, 0); | ||
832 | if (IS_ERR(gpio->clk)) { | ||
833 | dev_warn(&pdev->dev, | ||
834 | "No HPLL clock phandle provided, debouncing disabled\n"); | ||
835 | gpio->clk = NULL; | ||
836 | } | ||
837 | |||
568 | gpio->config = gpio_id->data; | 838 | gpio->config = gpio_id->data; |
569 | 839 | ||
840 | gpio->chip.parent = &pdev->dev; | ||
570 | gpio->chip.ngpio = gpio->config->nr_gpios; | 841 | gpio->chip.ngpio = gpio->config->nr_gpios; |
571 | gpio->chip.parent = &pdev->dev; | 842 | gpio->chip.parent = &pdev->dev; |
572 | gpio->chip.direction_input = aspeed_gpio_dir_in; | 843 | gpio->chip.direction_input = aspeed_gpio_dir_in; |
@@ -576,6 +847,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) | |||
576 | gpio->chip.free = aspeed_gpio_free; | 847 | gpio->chip.free = aspeed_gpio_free; |
577 | gpio->chip.get = aspeed_gpio_get; | 848 | gpio->chip.get = aspeed_gpio_get; |
578 | gpio->chip.set = aspeed_gpio_set; | 849 | gpio->chip.set = aspeed_gpio_set; |
850 | gpio->chip.set_config = aspeed_gpio_set_config; | ||
579 | gpio->chip.label = dev_name(&pdev->dev); | 851 | gpio->chip.label = dev_name(&pdev->dev); |
580 | gpio->chip.base = -1; | 852 | gpio->chip.base = -1; |
581 | gpio->chip.irq_need_valid_mask = true; | 853 | gpio->chip.irq_need_valid_mask = true; |
@@ -584,6 +856,9 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) | |||
584 | if (rc < 0) | 856 | if (rc < 0) |
585 | return rc; | 857 | return rc; |
586 | 858 | ||
859 | gpio->offset_timer = | ||
860 | devm_kzalloc(&pdev->dev, gpio->chip.ngpio, GFP_KERNEL); | ||
861 | |||
587 | return aspeed_gpio_setup_irqs(gpio, pdev); | 862 | return aspeed_gpio_setup_irqs(gpio, pdev); |
588 | } | 863 | } |
589 | 864 | ||
diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c index dc37dbe4b46d..f33d4a5fe671 100644 --- a/drivers/gpio/gpio-ath79.c +++ b/drivers/gpio/gpio-ath79.c | |||
@@ -32,7 +32,7 @@ | |||
32 | struct ath79_gpio_ctrl { | 32 | struct ath79_gpio_ctrl { |
33 | struct gpio_chip gc; | 33 | struct gpio_chip gc; |
34 | void __iomem *base; | 34 | void __iomem *base; |
35 | spinlock_t lock; | 35 | raw_spinlock_t lock; |
36 | unsigned long both_edges; | 36 | unsigned long both_edges; |
37 | }; | 37 | }; |
38 | 38 | ||
@@ -74,9 +74,9 @@ static void ath79_gpio_irq_unmask(struct irq_data *data) | |||
74 | u32 mask = BIT(irqd_to_hwirq(data)); | 74 | u32 mask = BIT(irqd_to_hwirq(data)); |
75 | unsigned long flags; | 75 | unsigned long flags; |
76 | 76 | ||
77 | spin_lock_irqsave(&ctrl->lock, flags); | 77 | raw_spin_lock_irqsave(&ctrl->lock, flags); |
78 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); | 78 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); |
79 | spin_unlock_irqrestore(&ctrl->lock, flags); | 79 | raw_spin_unlock_irqrestore(&ctrl->lock, flags); |
80 | } | 80 | } |
81 | 81 | ||
82 | static void ath79_gpio_irq_mask(struct irq_data *data) | 82 | static void ath79_gpio_irq_mask(struct irq_data *data) |
@@ -85,9 +85,9 @@ static void ath79_gpio_irq_mask(struct irq_data *data) | |||
85 | u32 mask = BIT(irqd_to_hwirq(data)); | 85 | u32 mask = BIT(irqd_to_hwirq(data)); |
86 | unsigned long flags; | 86 | unsigned long flags; |
87 | 87 | ||
88 | spin_lock_irqsave(&ctrl->lock, flags); | 88 | raw_spin_lock_irqsave(&ctrl->lock, flags); |
89 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0); | 89 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0); |
90 | spin_unlock_irqrestore(&ctrl->lock, flags); | 90 | raw_spin_unlock_irqrestore(&ctrl->lock, flags); |
91 | } | 91 | } |
92 | 92 | ||
93 | static void ath79_gpio_irq_enable(struct irq_data *data) | 93 | static void ath79_gpio_irq_enable(struct irq_data *data) |
@@ -96,10 +96,10 @@ static void ath79_gpio_irq_enable(struct irq_data *data) | |||
96 | u32 mask = BIT(irqd_to_hwirq(data)); | 96 | u32 mask = BIT(irqd_to_hwirq(data)); |
97 | unsigned long flags; | 97 | unsigned long flags; |
98 | 98 | ||
99 | spin_lock_irqsave(&ctrl->lock, flags); | 99 | raw_spin_lock_irqsave(&ctrl->lock, flags); |
100 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, mask); | 100 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, mask); |
101 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); | 101 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); |
102 | spin_unlock_irqrestore(&ctrl->lock, flags); | 102 | raw_spin_unlock_irqrestore(&ctrl->lock, flags); |
103 | } | 103 | } |
104 | 104 | ||
105 | static void ath79_gpio_irq_disable(struct irq_data *data) | 105 | static void ath79_gpio_irq_disable(struct irq_data *data) |
@@ -108,10 +108,10 @@ static void ath79_gpio_irq_disable(struct irq_data *data) | |||
108 | u32 mask = BIT(irqd_to_hwirq(data)); | 108 | u32 mask = BIT(irqd_to_hwirq(data)); |
109 | unsigned long flags; | 109 | unsigned long flags; |
110 | 110 | ||
111 | spin_lock_irqsave(&ctrl->lock, flags); | 111 | raw_spin_lock_irqsave(&ctrl->lock, flags); |
112 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0); | 112 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0); |
113 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, 0); | 113 | ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, 0); |
114 | spin_unlock_irqrestore(&ctrl->lock, flags); | 114 | raw_spin_unlock_irqrestore(&ctrl->lock, flags); |
115 | } | 115 | } |
116 | 116 | ||
117 | static int ath79_gpio_irq_set_type(struct irq_data *data, | 117 | static int ath79_gpio_irq_set_type(struct irq_data *data, |
@@ -140,7 +140,7 @@ static int ath79_gpio_irq_set_type(struct irq_data *data, | |||
140 | return -EINVAL; | 140 | return -EINVAL; |
141 | } | 141 | } |
142 | 142 | ||
143 | spin_lock_irqsave(&ctrl->lock, flags); | 143 | raw_spin_lock_irqsave(&ctrl->lock, flags); |
144 | 144 | ||
145 | if (flow_type == IRQ_TYPE_EDGE_BOTH) { | 145 | if (flow_type == IRQ_TYPE_EDGE_BOTH) { |
146 | ctrl->both_edges |= mask; | 146 | ctrl->both_edges |= mask; |
@@ -165,7 +165,7 @@ static int ath79_gpio_irq_set_type(struct irq_data *data, | |||
165 | ath79_gpio_update_bits( | 165 | ath79_gpio_update_bits( |
166 | ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, mask); | 166 | ctrl, AR71XX_GPIO_REG_INT_ENABLE, mask, mask); |
167 | 167 | ||
168 | spin_unlock_irqrestore(&ctrl->lock, flags); | 168 | raw_spin_unlock_irqrestore(&ctrl->lock, flags); |
169 | 169 | ||
170 | return 0; | 170 | return 0; |
171 | } | 171 | } |
@@ -191,7 +191,7 @@ static void ath79_gpio_irq_handler(struct irq_desc *desc) | |||
191 | 191 | ||
192 | chained_irq_enter(irqchip, desc); | 192 | chained_irq_enter(irqchip, desc); |
193 | 193 | ||
194 | spin_lock_irqsave(&ctrl->lock, flags); | 194 | raw_spin_lock_irqsave(&ctrl->lock, flags); |
195 | 195 | ||
196 | pending = ath79_gpio_read(ctrl, AR71XX_GPIO_REG_INT_PENDING); | 196 | pending = ath79_gpio_read(ctrl, AR71XX_GPIO_REG_INT_PENDING); |
197 | 197 | ||
@@ -203,7 +203,7 @@ static void ath79_gpio_irq_handler(struct irq_desc *desc) | |||
203 | both_edges, ~state); | 203 | both_edges, ~state); |
204 | } | 204 | } |
205 | 205 | ||
206 | spin_unlock_irqrestore(&ctrl->lock, flags); | 206 | raw_spin_unlock_irqrestore(&ctrl->lock, flags); |
207 | 207 | ||
208 | if (pending) { | 208 | if (pending) { |
209 | for_each_set_bit(irq, &pending, gc->ngpio) | 209 | for_each_set_bit(irq, &pending, gc->ngpio) |
@@ -262,7 +262,7 @@ static int ath79_gpio_probe(struct platform_device *pdev) | |||
262 | if (!ctrl->base) | 262 | if (!ctrl->base) |
263 | return -ENOMEM; | 263 | return -ENOMEM; |
264 | 264 | ||
265 | spin_lock_init(&ctrl->lock); | 265 | raw_spin_lock_init(&ctrl->lock); |
266 | err = bgpio_init(&ctrl->gc, &pdev->dev, 4, | 266 | err = bgpio_init(&ctrl->gc, &pdev->dev, 4, |
267 | ctrl->base + AR71XX_GPIO_REG_IN, | 267 | ctrl->base + AR71XX_GPIO_REG_IN, |
268 | ctrl->base + AR71XX_GPIO_REG_SET, | 268 | ctrl->base + AR71XX_GPIO_REG_SET, |
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index 41d0ac142580..dfcf56ee3c61 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c | |||
@@ -67,7 +67,7 @@ | |||
67 | struct bcm_kona_gpio { | 67 | struct bcm_kona_gpio { |
68 | void __iomem *reg_base; | 68 | void __iomem *reg_base; |
69 | int num_bank; | 69 | int num_bank; |
70 | spinlock_t lock; | 70 | raw_spinlock_t lock; |
71 | struct gpio_chip gpio_chip; | 71 | struct gpio_chip gpio_chip; |
72 | struct irq_domain *irq_domain; | 72 | struct irq_domain *irq_domain; |
73 | struct bcm_kona_gpio_bank *banks; | 73 | struct bcm_kona_gpio_bank *banks; |
@@ -95,13 +95,13 @@ static void bcm_kona_gpio_lock_gpio(struct bcm_kona_gpio *kona_gpio, | |||
95 | unsigned long flags; | 95 | unsigned long flags; |
96 | int bank_id = GPIO_BANK(gpio); | 96 | int bank_id = GPIO_BANK(gpio); |
97 | 97 | ||
98 | spin_lock_irqsave(&kona_gpio->lock, flags); | 98 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
99 | 99 | ||
100 | val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id)); | 100 | val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id)); |
101 | val |= BIT(gpio); | 101 | val |= BIT(gpio); |
102 | bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val); | 102 | bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val); |
103 | 103 | ||
104 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 104 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
105 | } | 105 | } |
106 | 106 | ||
107 | static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio, | 107 | static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio, |
@@ -111,13 +111,13 @@ static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio, | |||
111 | unsigned long flags; | 111 | unsigned long flags; |
112 | int bank_id = GPIO_BANK(gpio); | 112 | int bank_id = GPIO_BANK(gpio); |
113 | 113 | ||
114 | spin_lock_irqsave(&kona_gpio->lock, flags); | 114 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
115 | 115 | ||
116 | val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id)); | 116 | val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id)); |
117 | val &= ~BIT(gpio); | 117 | val &= ~BIT(gpio); |
118 | bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val); | 118 | bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val); |
119 | 119 | ||
120 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 120 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
121 | } | 121 | } |
122 | 122 | ||
123 | static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio) | 123 | static int bcm_kona_gpio_get_dir(struct gpio_chip *chip, unsigned gpio) |
@@ -141,7 +141,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) | |||
141 | 141 | ||
142 | kona_gpio = gpiochip_get_data(chip); | 142 | kona_gpio = gpiochip_get_data(chip); |
143 | reg_base = kona_gpio->reg_base; | 143 | reg_base = kona_gpio->reg_base; |
144 | spin_lock_irqsave(&kona_gpio->lock, flags); | 144 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
145 | 145 | ||
146 | /* this function only applies to output pin */ | 146 | /* this function only applies to output pin */ |
147 | if (bcm_kona_gpio_get_dir(chip, gpio) == GPIOF_DIR_IN) | 147 | if (bcm_kona_gpio_get_dir(chip, gpio) == GPIOF_DIR_IN) |
@@ -154,7 +154,7 @@ static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value) | |||
154 | writel(val, reg_base + reg_offset); | 154 | writel(val, reg_base + reg_offset); |
155 | 155 | ||
156 | out: | 156 | out: |
157 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 157 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
158 | } | 158 | } |
159 | 159 | ||
160 | static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) | 160 | static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) |
@@ -168,7 +168,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) | |||
168 | 168 | ||
169 | kona_gpio = gpiochip_get_data(chip); | 169 | kona_gpio = gpiochip_get_data(chip); |
170 | reg_base = kona_gpio->reg_base; | 170 | reg_base = kona_gpio->reg_base; |
171 | spin_lock_irqsave(&kona_gpio->lock, flags); | 171 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
172 | 172 | ||
173 | if (bcm_kona_gpio_get_dir(chip, gpio) == GPIOF_DIR_IN) | 173 | if (bcm_kona_gpio_get_dir(chip, gpio) == GPIOF_DIR_IN) |
174 | reg_offset = GPIO_IN_STATUS(bank_id); | 174 | reg_offset = GPIO_IN_STATUS(bank_id); |
@@ -178,7 +178,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio) | |||
178 | /* read the GPIO bank status */ | 178 | /* read the GPIO bank status */ |
179 | val = readl(reg_base + reg_offset); | 179 | val = readl(reg_base + reg_offset); |
180 | 180 | ||
181 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 181 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
182 | 182 | ||
183 | /* return the specified bit status */ | 183 | /* return the specified bit status */ |
184 | return !!(val & BIT(bit)); | 184 | return !!(val & BIT(bit)); |
@@ -208,14 +208,14 @@ static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | |||
208 | 208 | ||
209 | kona_gpio = gpiochip_get_data(chip); | 209 | kona_gpio = gpiochip_get_data(chip); |
210 | reg_base = kona_gpio->reg_base; | 210 | reg_base = kona_gpio->reg_base; |
211 | spin_lock_irqsave(&kona_gpio->lock, flags); | 211 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
212 | 212 | ||
213 | val = readl(reg_base + GPIO_CONTROL(gpio)); | 213 | val = readl(reg_base + GPIO_CONTROL(gpio)); |
214 | val &= ~GPIO_GPCTR0_IOTR_MASK; | 214 | val &= ~GPIO_GPCTR0_IOTR_MASK; |
215 | val |= GPIO_GPCTR0_IOTR_CMD_INPUT; | 215 | val |= GPIO_GPCTR0_IOTR_CMD_INPUT; |
216 | writel(val, reg_base + GPIO_CONTROL(gpio)); | 216 | writel(val, reg_base + GPIO_CONTROL(gpio)); |
217 | 217 | ||
218 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 218 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
219 | 219 | ||
220 | return 0; | 220 | return 0; |
221 | } | 221 | } |
@@ -232,7 +232,7 @@ static int bcm_kona_gpio_direction_output(struct gpio_chip *chip, | |||
232 | 232 | ||
233 | kona_gpio = gpiochip_get_data(chip); | 233 | kona_gpio = gpiochip_get_data(chip); |
234 | reg_base = kona_gpio->reg_base; | 234 | reg_base = kona_gpio->reg_base; |
235 | spin_lock_irqsave(&kona_gpio->lock, flags); | 235 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
236 | 236 | ||
237 | val = readl(reg_base + GPIO_CONTROL(gpio)); | 237 | val = readl(reg_base + GPIO_CONTROL(gpio)); |
238 | val &= ~GPIO_GPCTR0_IOTR_MASK; | 238 | val &= ~GPIO_GPCTR0_IOTR_MASK; |
@@ -244,7 +244,7 @@ static int bcm_kona_gpio_direction_output(struct gpio_chip *chip, | |||
244 | val |= BIT(bit); | 244 | val |= BIT(bit); |
245 | writel(val, reg_base + reg_offset); | 245 | writel(val, reg_base + reg_offset); |
246 | 246 | ||
247 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 247 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
248 | 248 | ||
249 | return 0; | 249 | return 0; |
250 | } | 250 | } |
@@ -288,7 +288,7 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio, | |||
288 | } | 288 | } |
289 | 289 | ||
290 | /* spin lock for read-modify-write of the GPIO register */ | 290 | /* spin lock for read-modify-write of the GPIO register */ |
291 | spin_lock_irqsave(&kona_gpio->lock, flags); | 291 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
292 | 292 | ||
293 | val = readl(reg_base + GPIO_CONTROL(gpio)); | 293 | val = readl(reg_base + GPIO_CONTROL(gpio)); |
294 | val &= ~GPIO_GPCTR0_DBR_MASK; | 294 | val &= ~GPIO_GPCTR0_DBR_MASK; |
@@ -303,7 +303,7 @@ static int bcm_kona_gpio_set_debounce(struct gpio_chip *chip, unsigned gpio, | |||
303 | 303 | ||
304 | writel(val, reg_base + GPIO_CONTROL(gpio)); | 304 | writel(val, reg_base + GPIO_CONTROL(gpio)); |
305 | 305 | ||
306 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 306 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
307 | 307 | ||
308 | return 0; | 308 | return 0; |
309 | } | 309 | } |
@@ -347,13 +347,13 @@ static void bcm_kona_gpio_irq_ack(struct irq_data *d) | |||
347 | 347 | ||
348 | kona_gpio = irq_data_get_irq_chip_data(d); | 348 | kona_gpio = irq_data_get_irq_chip_data(d); |
349 | reg_base = kona_gpio->reg_base; | 349 | reg_base = kona_gpio->reg_base; |
350 | spin_lock_irqsave(&kona_gpio->lock, flags); | 350 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
351 | 351 | ||
352 | val = readl(reg_base + GPIO_INT_STATUS(bank_id)); | 352 | val = readl(reg_base + GPIO_INT_STATUS(bank_id)); |
353 | val |= BIT(bit); | 353 | val |= BIT(bit); |
354 | writel(val, reg_base + GPIO_INT_STATUS(bank_id)); | 354 | writel(val, reg_base + GPIO_INT_STATUS(bank_id)); |
355 | 355 | ||
356 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 356 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
357 | } | 357 | } |
358 | 358 | ||
359 | static void bcm_kona_gpio_irq_mask(struct irq_data *d) | 359 | static void bcm_kona_gpio_irq_mask(struct irq_data *d) |
@@ -368,13 +368,13 @@ static void bcm_kona_gpio_irq_mask(struct irq_data *d) | |||
368 | 368 | ||
369 | kona_gpio = irq_data_get_irq_chip_data(d); | 369 | kona_gpio = irq_data_get_irq_chip_data(d); |
370 | reg_base = kona_gpio->reg_base; | 370 | reg_base = kona_gpio->reg_base; |
371 | spin_lock_irqsave(&kona_gpio->lock, flags); | 371 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
372 | 372 | ||
373 | val = readl(reg_base + GPIO_INT_MASK(bank_id)); | 373 | val = readl(reg_base + GPIO_INT_MASK(bank_id)); |
374 | val |= BIT(bit); | 374 | val |= BIT(bit); |
375 | writel(val, reg_base + GPIO_INT_MASK(bank_id)); | 375 | writel(val, reg_base + GPIO_INT_MASK(bank_id)); |
376 | 376 | ||
377 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 377 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
378 | } | 378 | } |
379 | 379 | ||
380 | static void bcm_kona_gpio_irq_unmask(struct irq_data *d) | 380 | static void bcm_kona_gpio_irq_unmask(struct irq_data *d) |
@@ -389,13 +389,13 @@ static void bcm_kona_gpio_irq_unmask(struct irq_data *d) | |||
389 | 389 | ||
390 | kona_gpio = irq_data_get_irq_chip_data(d); | 390 | kona_gpio = irq_data_get_irq_chip_data(d); |
391 | reg_base = kona_gpio->reg_base; | 391 | reg_base = kona_gpio->reg_base; |
392 | spin_lock_irqsave(&kona_gpio->lock, flags); | 392 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
393 | 393 | ||
394 | val = readl(reg_base + GPIO_INT_MSKCLR(bank_id)); | 394 | val = readl(reg_base + GPIO_INT_MSKCLR(bank_id)); |
395 | val |= BIT(bit); | 395 | val |= BIT(bit); |
396 | writel(val, reg_base + GPIO_INT_MSKCLR(bank_id)); | 396 | writel(val, reg_base + GPIO_INT_MSKCLR(bank_id)); |
397 | 397 | ||
398 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 398 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
399 | } | 399 | } |
400 | 400 | ||
401 | static int bcm_kona_gpio_irq_set_type(struct irq_data *d, unsigned int type) | 401 | static int bcm_kona_gpio_irq_set_type(struct irq_data *d, unsigned int type) |
@@ -431,14 +431,14 @@ static int bcm_kona_gpio_irq_set_type(struct irq_data *d, unsigned int type) | |||
431 | return -EINVAL; | 431 | return -EINVAL; |
432 | } | 432 | } |
433 | 433 | ||
434 | spin_lock_irqsave(&kona_gpio->lock, flags); | 434 | raw_spin_lock_irqsave(&kona_gpio->lock, flags); |
435 | 435 | ||
436 | val = readl(reg_base + GPIO_CONTROL(gpio)); | 436 | val = readl(reg_base + GPIO_CONTROL(gpio)); |
437 | val &= ~GPIO_GPCTR0_ITR_MASK; | 437 | val &= ~GPIO_GPCTR0_ITR_MASK; |
438 | val |= lvl_type << GPIO_GPCTR0_ITR_SHIFT; | 438 | val |= lvl_type << GPIO_GPCTR0_ITR_SHIFT; |
439 | writel(val, reg_base + GPIO_CONTROL(gpio)); | 439 | writel(val, reg_base + GPIO_CONTROL(gpio)); |
440 | 440 | ||
441 | spin_unlock_irqrestore(&kona_gpio->lock, flags); | 441 | raw_spin_unlock_irqrestore(&kona_gpio->lock, flags); |
442 | 442 | ||
443 | return 0; | 443 | return 0; |
444 | } | 444 | } |
@@ -655,7 +655,7 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) | |||
655 | bank); | 655 | bank); |
656 | } | 656 | } |
657 | 657 | ||
658 | spin_lock_init(&kona_gpio->lock); | 658 | raw_spin_lock_init(&kona_gpio->lock); |
659 | 659 | ||
660 | return 0; | 660 | return 0; |
661 | 661 | ||
diff --git a/drivers/gpio/gpio-bd9571mwv.c b/drivers/gpio/gpio-bd9571mwv.c new file mode 100644 index 000000000000..5224a946e8ab --- /dev/null +++ b/drivers/gpio/gpio-bd9571mwv.c | |||
@@ -0,0 +1,144 @@ | |||
1 | /* | ||
2 | * ROHM BD9571MWV-M GPIO driver | ||
3 | * | ||
4 | * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
11 | * kind, whether expressed or implied; without even the implied warranty | ||
12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License version 2 for more details. | ||
14 | * | ||
15 | * Based on the TPS65086 driver | ||
16 | * | ||
17 | * NOTE: Interrupts are not supported yet. | ||
18 | */ | ||
19 | |||
20 | #include <linux/gpio/driver.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | |||
24 | #include <linux/mfd/bd9571mwv.h> | ||
25 | |||
26 | struct bd9571mwv_gpio { | ||
27 | struct gpio_chip chip; | ||
28 | struct bd9571mwv *bd; | ||
29 | }; | ||
30 | |||
31 | static int bd9571mwv_gpio_get_direction(struct gpio_chip *chip, | ||
32 | unsigned int offset) | ||
33 | { | ||
34 | struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); | ||
35 | int ret, val; | ||
36 | |||
37 | ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_DIR, &val); | ||
38 | if (ret < 0) | ||
39 | return ret; | ||
40 | |||
41 | return val & BIT(offset); | ||
42 | } | ||
43 | |||
44 | static int bd9571mwv_gpio_direction_input(struct gpio_chip *chip, | ||
45 | unsigned int offset) | ||
46 | { | ||
47 | struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); | ||
48 | |||
49 | regmap_update_bits(gpio->bd->regmap, BD9571MWV_GPIO_DIR, | ||
50 | BIT(offset), 0); | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static int bd9571mwv_gpio_direction_output(struct gpio_chip *chip, | ||
56 | unsigned int offset, int value) | ||
57 | { | ||
58 | struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); | ||
59 | |||
60 | /* Set the initial value */ | ||
61 | regmap_update_bits(gpio->bd->regmap, BD9571MWV_GPIO_OUT, | ||
62 | BIT(offset), value ? BIT(offset) : 0); | ||
63 | regmap_update_bits(gpio->bd->regmap, BD9571MWV_GPIO_DIR, | ||
64 | BIT(offset), BIT(offset)); | ||
65 | |||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | static int bd9571mwv_gpio_get(struct gpio_chip *chip, unsigned int offset) | ||
70 | { | ||
71 | struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); | ||
72 | int ret, val; | ||
73 | |||
74 | ret = regmap_read(gpio->bd->regmap, BD9571MWV_GPIO_IN, &val); | ||
75 | if (ret < 0) | ||
76 | return ret; | ||
77 | |||
78 | return val & BIT(offset); | ||
79 | } | ||
80 | |||
81 | static void bd9571mwv_gpio_set(struct gpio_chip *chip, unsigned int offset, | ||
82 | int value) | ||
83 | { | ||
84 | struct bd9571mwv_gpio *gpio = gpiochip_get_data(chip); | ||
85 | |||
86 | regmap_update_bits(gpio->bd->regmap, BD9571MWV_GPIO_OUT, | ||
87 | BIT(offset), value ? BIT(offset) : 0); | ||
88 | } | ||
89 | |||
90 | static const struct gpio_chip template_chip = { | ||
91 | .label = "bd9571mwv-gpio", | ||
92 | .owner = THIS_MODULE, | ||
93 | .get_direction = bd9571mwv_gpio_get_direction, | ||
94 | .direction_input = bd9571mwv_gpio_direction_input, | ||
95 | .direction_output = bd9571mwv_gpio_direction_output, | ||
96 | .get = bd9571mwv_gpio_get, | ||
97 | .set = bd9571mwv_gpio_set, | ||
98 | .base = -1, | ||
99 | .ngpio = 2, | ||
100 | .can_sleep = true, | ||
101 | }; | ||
102 | |||
103 | static int bd9571mwv_gpio_probe(struct platform_device *pdev) | ||
104 | { | ||
105 | struct bd9571mwv_gpio *gpio; | ||
106 | int ret; | ||
107 | |||
108 | gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); | ||
109 | if (!gpio) | ||
110 | return -ENOMEM; | ||
111 | |||
112 | platform_set_drvdata(pdev, gpio); | ||
113 | |||
114 | gpio->bd = dev_get_drvdata(pdev->dev.parent); | ||
115 | gpio->chip = template_chip; | ||
116 | gpio->chip.parent = gpio->bd->dev; | ||
117 | |||
118 | ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); | ||
119 | if (ret < 0) { | ||
120 | dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); | ||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static const struct platform_device_id bd9571mwv_gpio_id_table[] = { | ||
128 | { "bd9571mwv-gpio", }, | ||
129 | { /* sentinel */ } | ||
130 | }; | ||
131 | MODULE_DEVICE_TABLE(platform, bd9571mwv_gpio_id_table); | ||
132 | |||
133 | static struct platform_driver bd9571mwv_gpio_driver = { | ||
134 | .driver = { | ||
135 | .name = "bd9571mwv-gpio", | ||
136 | }, | ||
137 | .probe = bd9571mwv_gpio_probe, | ||
138 | .id_table = bd9571mwv_gpio_id_table, | ||
139 | }; | ||
140 | module_platform_driver(bd9571mwv_gpio_driver); | ||
141 | |||
142 | MODULE_AUTHOR("Marek Vasut <marek.vasut+renesas@gmail.com>"); | ||
143 | MODULE_DESCRIPTION("BD9571MWV GPIO driver"); | ||
144 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 72f49d1e110d..ac173575d3f6 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c | |||
@@ -483,7 +483,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) | |||
483 | clk_prepare_enable(clk); | 483 | clk_prepare_enable(clk); |
484 | 484 | ||
485 | if (!pdata->gpio_unbanked) { | 485 | if (!pdata->gpio_unbanked) { |
486 | irq = irq_alloc_descs(-1, 0, ngpio, 0); | 486 | irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0); |
487 | if (irq < 0) { | 487 | if (irq < 0) { |
488 | dev_err(dev, "Couldn't allocate IRQ numbers\n"); | 488 | dev_err(dev, "Couldn't allocate IRQ numbers\n"); |
489 | return irq; | 489 | return irq; |
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 9c15ee4ef4e9..f051c4552af5 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/of.h> | 22 | #include <linux/of.h> |
23 | #include <linux/of_address.h> | 23 | #include <linux/of_address.h> |
24 | #include <linux/of_device.h> | ||
24 | #include <linux/of_irq.h> | 25 | #include <linux/of_irq.h> |
25 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
26 | #include <linux/property.h> | 27 | #include <linux/property.h> |
@@ -55,6 +56,14 @@ | |||
55 | #define GPIO_SWPORT_DR_SIZE (GPIO_SWPORTB_DR - GPIO_SWPORTA_DR) | 56 | #define GPIO_SWPORT_DR_SIZE (GPIO_SWPORTB_DR - GPIO_SWPORTA_DR) |
56 | #define GPIO_SWPORT_DDR_SIZE (GPIO_SWPORTB_DDR - GPIO_SWPORTA_DDR) | 57 | #define GPIO_SWPORT_DDR_SIZE (GPIO_SWPORTB_DDR - GPIO_SWPORTA_DDR) |
57 | 58 | ||
59 | #define GPIO_REG_OFFSET_V2 1 | ||
60 | |||
61 | #define GPIO_INTMASK_V2 0x44 | ||
62 | #define GPIO_INTTYPE_LEVEL_V2 0x34 | ||
63 | #define GPIO_INT_POLARITY_V2 0x38 | ||
64 | #define GPIO_INTSTATUS_V2 0x3c | ||
65 | #define GPIO_PORTA_EOI_V2 0x40 | ||
66 | |||
58 | struct dwapb_gpio; | 67 | struct dwapb_gpio; |
59 | 68 | ||
60 | #ifdef CONFIG_PM_SLEEP | 69 | #ifdef CONFIG_PM_SLEEP |
@@ -87,14 +96,41 @@ struct dwapb_gpio { | |||
87 | struct dwapb_gpio_port *ports; | 96 | struct dwapb_gpio_port *ports; |
88 | unsigned int nr_ports; | 97 | unsigned int nr_ports; |
89 | struct irq_domain *domain; | 98 | struct irq_domain *domain; |
99 | unsigned int flags; | ||
90 | }; | 100 | }; |
91 | 101 | ||
102 | static inline u32 gpio_reg_v2_convert(unsigned int offset) | ||
103 | { | ||
104 | switch (offset) { | ||
105 | case GPIO_INTMASK: | ||
106 | return GPIO_INTMASK_V2; | ||
107 | case GPIO_INTTYPE_LEVEL: | ||
108 | return GPIO_INTTYPE_LEVEL_V2; | ||
109 | case GPIO_INT_POLARITY: | ||
110 | return GPIO_INT_POLARITY_V2; | ||
111 | case GPIO_INTSTATUS: | ||
112 | return GPIO_INTSTATUS_V2; | ||
113 | case GPIO_PORTA_EOI: | ||
114 | return GPIO_PORTA_EOI_V2; | ||
115 | } | ||
116 | |||
117 | return offset; | ||
118 | } | ||
119 | |||
120 | static inline u32 gpio_reg_convert(struct dwapb_gpio *gpio, unsigned int offset) | ||
121 | { | ||
122 | if (gpio->flags & GPIO_REG_OFFSET_V2) | ||
123 | return gpio_reg_v2_convert(offset); | ||
124 | |||
125 | return offset; | ||
126 | } | ||
127 | |||
92 | static inline u32 dwapb_read(struct dwapb_gpio *gpio, unsigned int offset) | 128 | static inline u32 dwapb_read(struct dwapb_gpio *gpio, unsigned int offset) |
93 | { | 129 | { |
94 | struct gpio_chip *gc = &gpio->ports[0].gc; | 130 | struct gpio_chip *gc = &gpio->ports[0].gc; |
95 | void __iomem *reg_base = gpio->regs; | 131 | void __iomem *reg_base = gpio->regs; |
96 | 132 | ||
97 | return gc->read_reg(reg_base + offset); | 133 | return gc->read_reg(reg_base + gpio_reg_convert(gpio, offset)); |
98 | } | 134 | } |
99 | 135 | ||
100 | static inline void dwapb_write(struct dwapb_gpio *gpio, unsigned int offset, | 136 | static inline void dwapb_write(struct dwapb_gpio *gpio, unsigned int offset, |
@@ -103,7 +139,7 @@ static inline void dwapb_write(struct dwapb_gpio *gpio, unsigned int offset, | |||
103 | struct gpio_chip *gc = &gpio->ports[0].gc; | 139 | struct gpio_chip *gc = &gpio->ports[0].gc; |
104 | void __iomem *reg_base = gpio->regs; | 140 | void __iomem *reg_base = gpio->regs; |
105 | 141 | ||
106 | gc->write_reg(reg_base + offset, val); | 142 | gc->write_reg(reg_base + gpio_reg_convert(gpio, offset), val); |
107 | } | 143 | } |
108 | 144 | ||
109 | static int dwapb_gpio_to_irq(struct gpio_chip *gc, unsigned offset) | 145 | static int dwapb_gpio_to_irq(struct gpio_chip *gc, unsigned offset) |
@@ -128,7 +164,7 @@ static void dwapb_toggle_trigger(struct dwapb_gpio *gpio, unsigned int offs) | |||
128 | 164 | ||
129 | static u32 dwapb_do_irq(struct dwapb_gpio *gpio) | 165 | static u32 dwapb_do_irq(struct dwapb_gpio *gpio) |
130 | { | 166 | { |
131 | u32 irq_status = readl_relaxed(gpio->regs + GPIO_INTSTATUS); | 167 | u32 irq_status = dwapb_read(gpio, GPIO_INTSTATUS); |
132 | u32 ret = irq_status; | 168 | u32 ret = irq_status; |
133 | 169 | ||
134 | while (irq_status) { | 170 | while (irq_status) { |
@@ -348,8 +384,8 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio, | |||
348 | ct->chip.irq_disable = dwapb_irq_disable; | 384 | ct->chip.irq_disable = dwapb_irq_disable; |
349 | ct->chip.irq_request_resources = dwapb_irq_reqres; | 385 | ct->chip.irq_request_resources = dwapb_irq_reqres; |
350 | ct->chip.irq_release_resources = dwapb_irq_relres; | 386 | ct->chip.irq_release_resources = dwapb_irq_relres; |
351 | ct->regs.ack = GPIO_PORTA_EOI; | 387 | ct->regs.ack = gpio_reg_convert(gpio, GPIO_PORTA_EOI); |
352 | ct->regs.mask = GPIO_INTMASK; | 388 | ct->regs.mask = gpio_reg_convert(gpio, GPIO_INTMASK); |
353 | ct->type = IRQ_TYPE_LEVEL_MASK; | 389 | ct->type = IRQ_TYPE_LEVEL_MASK; |
354 | } | 390 | } |
355 | 391 | ||
@@ -532,6 +568,21 @@ dwapb_gpio_get_pdata(struct device *dev) | |||
532 | return pdata; | 568 | return pdata; |
533 | } | 569 | } |
534 | 570 | ||
571 | static const struct of_device_id dwapb_of_match[] = { | ||
572 | { .compatible = "snps,dw-apb-gpio", .data = (void *)0}, | ||
573 | { .compatible = "apm,xgene-gpio-v2", .data = (void *)GPIO_REG_OFFSET_V2}, | ||
574 | { /* Sentinel */ } | ||
575 | }; | ||
576 | MODULE_DEVICE_TABLE(of, dwapb_of_match); | ||
577 | |||
578 | static const struct acpi_device_id dwapb_acpi_match[] = { | ||
579 | {"HISI0181", 0}, | ||
580 | {"APMC0D07", 0}, | ||
581 | {"APMC0D81", GPIO_REG_OFFSET_V2}, | ||
582 | { } | ||
583 | }; | ||
584 | MODULE_DEVICE_TABLE(acpi, dwapb_acpi_match); | ||
585 | |||
535 | static int dwapb_gpio_probe(struct platform_device *pdev) | 586 | static int dwapb_gpio_probe(struct platform_device *pdev) |
536 | { | 587 | { |
537 | unsigned int i; | 588 | unsigned int i; |
@@ -567,6 +618,25 @@ static int dwapb_gpio_probe(struct platform_device *pdev) | |||
567 | if (IS_ERR(gpio->regs)) | 618 | if (IS_ERR(gpio->regs)) |
568 | return PTR_ERR(gpio->regs); | 619 | return PTR_ERR(gpio->regs); |
569 | 620 | ||
621 | gpio->flags = 0; | ||
622 | if (dev->of_node) { | ||
623 | const struct of_device_id *of_devid; | ||
624 | |||
625 | of_devid = of_match_device(dwapb_of_match, dev); | ||
626 | if (of_devid) { | ||
627 | if (of_devid->data) | ||
628 | gpio->flags = (uintptr_t)of_devid->data; | ||
629 | } | ||
630 | } else if (has_acpi_companion(dev)) { | ||
631 | const struct acpi_device_id *acpi_id; | ||
632 | |||
633 | acpi_id = acpi_match_device(dwapb_acpi_match, dev); | ||
634 | if (acpi_id) { | ||
635 | if (acpi_id->driver_data) | ||
636 | gpio->flags = acpi_id->driver_data; | ||
637 | } | ||
638 | } | ||
639 | |||
570 | for (i = 0; i < gpio->nr_ports; i++) { | 640 | for (i = 0; i < gpio->nr_ports; i++) { |
571 | err = dwapb_gpio_add_port(gpio, &pdata->properties[i], i); | 641 | err = dwapb_gpio_add_port(gpio, &pdata->properties[i], i); |
572 | if (err) | 642 | if (err) |
@@ -593,19 +663,6 @@ static int dwapb_gpio_remove(struct platform_device *pdev) | |||
593 | return 0; | 663 | return 0; |
594 | } | 664 | } |
595 | 665 | ||
596 | static const struct of_device_id dwapb_of_match[] = { | ||
597 | { .compatible = "snps,dw-apb-gpio" }, | ||
598 | { /* Sentinel */ } | ||
599 | }; | ||
600 | MODULE_DEVICE_TABLE(of, dwapb_of_match); | ||
601 | |||
602 | static const struct acpi_device_id dwapb_acpi_match[] = { | ||
603 | {"HISI0181", 0}, | ||
604 | {"APMC0D07", 0}, | ||
605 | { } | ||
606 | }; | ||
607 | MODULE_DEVICE_TABLE(acpi, dwapb_acpi_match); | ||
608 | |||
609 | #ifdef CONFIG_PM_SLEEP | 666 | #ifdef CONFIG_PM_SLEEP |
610 | static int dwapb_gpio_suspend(struct device *dev) | 667 | static int dwapb_gpio_suspend(struct device *dev) |
611 | { | 668 | { |
diff --git a/drivers/gpio/gpio-etraxfs.c b/drivers/gpio/gpio-etraxfs.c index a254d5b07b94..14c6aac26780 100644 --- a/drivers/gpio/gpio-etraxfs.c +++ b/drivers/gpio/gpio-etraxfs.c | |||
@@ -54,7 +54,7 @@ | |||
54 | struct etraxfs_gpio_info; | 54 | struct etraxfs_gpio_info; |
55 | 55 | ||
56 | struct etraxfs_gpio_block { | 56 | struct etraxfs_gpio_block { |
57 | spinlock_t lock; | 57 | raw_spinlock_t lock; |
58 | u32 mask; | 58 | u32 mask; |
59 | u32 cfg; | 59 | u32 cfg; |
60 | u32 pins; | 60 | u32 pins; |
@@ -233,10 +233,10 @@ static void etraxfs_gpio_irq_mask(struct irq_data *d) | |||
233 | struct etraxfs_gpio_block *block = chip->block; | 233 | struct etraxfs_gpio_block *block = chip->block; |
234 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 234 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
235 | 235 | ||
236 | spin_lock(&block->lock); | 236 | raw_spin_lock(&block->lock); |
237 | block->mask &= ~BIT(grpirq); | 237 | block->mask &= ~BIT(grpirq); |
238 | writel(block->mask, block->regs + block->info->rw_intr_mask); | 238 | writel(block->mask, block->regs + block->info->rw_intr_mask); |
239 | spin_unlock(&block->lock); | 239 | raw_spin_unlock(&block->lock); |
240 | } | 240 | } |
241 | 241 | ||
242 | static void etraxfs_gpio_irq_unmask(struct irq_data *d) | 242 | static void etraxfs_gpio_irq_unmask(struct irq_data *d) |
@@ -246,10 +246,10 @@ static void etraxfs_gpio_irq_unmask(struct irq_data *d) | |||
246 | struct etraxfs_gpio_block *block = chip->block; | 246 | struct etraxfs_gpio_block *block = chip->block; |
247 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 247 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
248 | 248 | ||
249 | spin_lock(&block->lock); | 249 | raw_spin_lock(&block->lock); |
250 | block->mask |= BIT(grpirq); | 250 | block->mask |= BIT(grpirq); |
251 | writel(block->mask, block->regs + block->info->rw_intr_mask); | 251 | writel(block->mask, block->regs + block->info->rw_intr_mask); |
252 | spin_unlock(&block->lock); | 252 | raw_spin_unlock(&block->lock); |
253 | } | 253 | } |
254 | 254 | ||
255 | static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) | 255 | static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) |
@@ -280,11 +280,11 @@ static int etraxfs_gpio_irq_set_type(struct irq_data *d, u32 type) | |||
280 | return -EINVAL; | 280 | return -EINVAL; |
281 | } | 281 | } |
282 | 282 | ||
283 | spin_lock(&block->lock); | 283 | raw_spin_lock(&block->lock); |
284 | block->cfg &= ~(0x7 << (grpirq * 3)); | 284 | block->cfg &= ~(0x7 << (grpirq * 3)); |
285 | block->cfg |= (cfg << (grpirq * 3)); | 285 | block->cfg |= (cfg << (grpirq * 3)); |
286 | writel(block->cfg, block->regs + block->info->rw_intr_cfg); | 286 | writel(block->cfg, block->regs + block->info->rw_intr_cfg); |
287 | spin_unlock(&block->lock); | 287 | raw_spin_unlock(&block->lock); |
288 | 288 | ||
289 | return 0; | 289 | return 0; |
290 | } | 290 | } |
@@ -297,7 +297,7 @@ static int etraxfs_gpio_irq_request_resources(struct irq_data *d) | |||
297 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 297 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
298 | int ret = -EBUSY; | 298 | int ret = -EBUSY; |
299 | 299 | ||
300 | spin_lock(&block->lock); | 300 | raw_spin_lock(&block->lock); |
301 | if (block->group[grpirq]) | 301 | if (block->group[grpirq]) |
302 | goto out; | 302 | goto out; |
303 | 303 | ||
@@ -316,7 +316,7 @@ static int etraxfs_gpio_irq_request_resources(struct irq_data *d) | |||
316 | } | 316 | } |
317 | 317 | ||
318 | out: | 318 | out: |
319 | spin_unlock(&block->lock); | 319 | raw_spin_unlock(&block->lock); |
320 | return ret; | 320 | return ret; |
321 | } | 321 | } |
322 | 322 | ||
@@ -327,10 +327,10 @@ static void etraxfs_gpio_irq_release_resources(struct irq_data *d) | |||
327 | struct etraxfs_gpio_block *block = chip->block; | 327 | struct etraxfs_gpio_block *block = chip->block; |
328 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); | 328 | unsigned int grpirq = etraxfs_gpio_to_group_irq(d->hwirq); |
329 | 329 | ||
330 | spin_lock(&block->lock); | 330 | raw_spin_lock(&block->lock); |
331 | block->group[grpirq] = 0; | 331 | block->group[grpirq] = 0; |
332 | gpiochip_unlock_as_irq(&chip->gc, d->hwirq); | 332 | gpiochip_unlock_as_irq(&chip->gc, d->hwirq); |
333 | spin_unlock(&block->lock); | 333 | raw_spin_unlock(&block->lock); |
334 | } | 334 | } |
335 | 335 | ||
336 | static struct irq_chip etraxfs_gpio_irq_chip = { | 336 | static struct irq_chip etraxfs_gpio_irq_chip = { |
@@ -391,7 +391,7 @@ static int etraxfs_gpio_probe(struct platform_device *pdev) | |||
391 | if (!block) | 391 | if (!block) |
392 | return -ENOMEM; | 392 | return -ENOMEM; |
393 | 393 | ||
394 | spin_lock_init(&block->lock); | 394 | raw_spin_lock_init(&block->lock); |
395 | 395 | ||
396 | block->regs = regs; | 396 | block->regs = regs; |
397 | block->info = info; | 397 | block->info = info; |
diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c index 05c8946d6446..081076771217 100644 --- a/drivers/gpio/gpio-exar.c +++ b/drivers/gpio/gpio-exar.c | |||
@@ -59,17 +59,6 @@ static int exar_set_direction(struct gpio_chip *chip, int direction, | |||
59 | return 0; | 59 | return 0; |
60 | } | 60 | } |
61 | 61 | ||
62 | static int exar_direction_output(struct gpio_chip *chip, unsigned int offset, | ||
63 | int value) | ||
64 | { | ||
65 | return exar_set_direction(chip, 0, offset); | ||
66 | } | ||
67 | |||
68 | static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) | ||
69 | { | ||
70 | return exar_set_direction(chip, 1, offset); | ||
71 | } | ||
72 | |||
73 | static int exar_get(struct gpio_chip *chip, unsigned int reg) | 62 | static int exar_get(struct gpio_chip *chip, unsigned int reg) |
74 | { | 63 | { |
75 | struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); | 64 | struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); |
@@ -116,6 +105,18 @@ static void exar_set_value(struct gpio_chip *chip, unsigned int offset, | |||
116 | exar_update(chip, addr, value, offset % 8); | 105 | exar_update(chip, addr, value, offset % 8); |
117 | } | 106 | } |
118 | 107 | ||
108 | static int exar_direction_output(struct gpio_chip *chip, unsigned int offset, | ||
109 | int value) | ||
110 | { | ||
111 | exar_set_value(chip, offset, value); | ||
112 | return exar_set_direction(chip, 0, offset); | ||
113 | } | ||
114 | |||
115 | static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) | ||
116 | { | ||
117 | return exar_set_direction(chip, 1, offset); | ||
118 | } | ||
119 | |||
119 | static int gpio_exar_probe(struct platform_device *pdev) | 120 | static int gpio_exar_probe(struct platform_device *pdev) |
120 | { | 121 | { |
121 | struct pci_dev *pcidev = platform_get_drvdata(pdev); | 122 | struct pci_dev *pcidev = platform_get_drvdata(pdev); |
diff --git a/drivers/gpio/gpio-f7188x.c b/drivers/gpio/gpio-f7188x.c index 56bd76c33767..13350c9d7f5e 100644 --- a/drivers/gpio/gpio-f7188x.c +++ b/drivers/gpio/gpio-f7188x.c | |||
@@ -37,14 +37,16 @@ | |||
37 | #define SIO_F71869A_ID 0x1007 /* F71869A chipset ID */ | 37 | #define SIO_F71869A_ID 0x1007 /* F71869A chipset ID */ |
38 | #define SIO_F71882_ID 0x0541 /* F71882 chipset ID */ | 38 | #define SIO_F71882_ID 0x0541 /* F71882 chipset ID */ |
39 | #define SIO_F71889_ID 0x0909 /* F71889 chipset ID */ | 39 | #define SIO_F71889_ID 0x0909 /* F71889 chipset ID */ |
40 | #define SIO_F71889A_ID 0x1005 /* F71889A chipset ID */ | ||
40 | #define SIO_F81866_ID 0x1010 /* F81866 chipset ID */ | 41 | #define SIO_F81866_ID 0x1010 /* F81866 chipset ID */ |
41 | 42 | ||
42 | enum chips { f71869, f71869a, f71882fg, f71889f, f81866 }; | 43 | enum chips { f71869, f71869a, f71882fg, f71889a, f71889f, f81866 }; |
43 | 44 | ||
44 | static const char * const f7188x_names[] = { | 45 | static const char * const f7188x_names[] = { |
45 | "f71869", | 46 | "f71869", |
46 | "f71869a", | 47 | "f71869a", |
47 | "f71882fg", | 48 | "f71882fg", |
49 | "f71889a", | ||
48 | "f71889f", | 50 | "f71889f", |
49 | "f81866", | 51 | "f81866", |
50 | }; | 52 | }; |
@@ -187,6 +189,17 @@ static struct f7188x_gpio_bank f71882_gpio_bank[] = { | |||
187 | F7188X_GPIO_BANK(40, 4, 0xB0), | 189 | F7188X_GPIO_BANK(40, 4, 0xB0), |
188 | }; | 190 | }; |
189 | 191 | ||
192 | static struct f7188x_gpio_bank f71889a_gpio_bank[] = { | ||
193 | F7188X_GPIO_BANK(0, 7, 0xF0), | ||
194 | F7188X_GPIO_BANK(10, 7, 0xE0), | ||
195 | F7188X_GPIO_BANK(20, 8, 0xD0), | ||
196 | F7188X_GPIO_BANK(30, 8, 0xC0), | ||
197 | F7188X_GPIO_BANK(40, 8, 0xB0), | ||
198 | F7188X_GPIO_BANK(50, 5, 0xA0), | ||
199 | F7188X_GPIO_BANK(60, 8, 0x90), | ||
200 | F7188X_GPIO_BANK(70, 8, 0x80), | ||
201 | }; | ||
202 | |||
190 | static struct f7188x_gpio_bank f71889_gpio_bank[] = { | 203 | static struct f7188x_gpio_bank f71889_gpio_bank[] = { |
191 | F7188X_GPIO_BANK(0, 7, 0xF0), | 204 | F7188X_GPIO_BANK(0, 7, 0xF0), |
192 | F7188X_GPIO_BANK(10, 7, 0xE0), | 205 | F7188X_GPIO_BANK(10, 7, 0xE0), |
@@ -382,6 +395,10 @@ static int f7188x_gpio_probe(struct platform_device *pdev) | |||
382 | data->nr_bank = ARRAY_SIZE(f71882_gpio_bank); | 395 | data->nr_bank = ARRAY_SIZE(f71882_gpio_bank); |
383 | data->bank = f71882_gpio_bank; | 396 | data->bank = f71882_gpio_bank; |
384 | break; | 397 | break; |
398 | case f71889a: | ||
399 | data->nr_bank = ARRAY_SIZE(f71889a_gpio_bank); | ||
400 | data->bank = f71889a_gpio_bank; | ||
401 | break; | ||
385 | case f71889f: | 402 | case f71889f: |
386 | data->nr_bank = ARRAY_SIZE(f71889_gpio_bank); | 403 | data->nr_bank = ARRAY_SIZE(f71889_gpio_bank); |
387 | data->bank = f71889_gpio_bank; | 404 | data->bank = f71889_gpio_bank; |
@@ -443,6 +460,9 @@ static int __init f7188x_find(int addr, struct f7188x_sio *sio) | |||
443 | case SIO_F71882_ID: | 460 | case SIO_F71882_ID: |
444 | sio->type = f71882fg; | 461 | sio->type = f71882fg; |
445 | break; | 462 | break; |
463 | case SIO_F71889A_ID: | ||
464 | sio->type = f71889a; | ||
465 | break; | ||
446 | case SIO_F71889_ID: | 466 | case SIO_F71889_ID: |
447 | sio->type = f71889f; | 467 | sio->type = f71889f; |
448 | break; | 468 | break; |
@@ -538,6 +558,6 @@ static void __exit f7188x_gpio_exit(void) | |||
538 | } | 558 | } |
539 | module_exit(f7188x_gpio_exit); | 559 | module_exit(f7188x_gpio_exit); |
540 | 560 | ||
541 | MODULE_DESCRIPTION("GPIO driver for Super-I/O chips F71869, F71869A, F71882FG, F71889F and F81866"); | 561 | MODULE_DESCRIPTION("GPIO driver for Super-I/O chips F71869, F71869A, F71882FG, F71889A, F71889F and F81866"); |
542 | MODULE_AUTHOR("Simon Guinot <simon.guinot@sequanux.org>"); | 562 | MODULE_AUTHOR("Simon Guinot <simon.guinot@sequanux.org>"); |
543 | MODULE_LICENSE("GPL"); | 563 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/gpio/gpio-gemini.c b/drivers/gpio/gpio-ftgpio010.c index 962485163b7f..e9386f8b67f5 100644 --- a/drivers/gpio/gpio-gemini.c +++ b/drivers/gpio/gpio-ftgpio010.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Gemini gpiochip and interrupt routines | 2 | * Faraday Technolog FTGPIO010 gpiochip and interrupt routines |
3 | * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org> | 3 | * Copyright (C) 2017 Linus Walleij <linus.walleij@linaro.org> |
4 | * | 4 | * |
5 | * Based on arch/arm/mach-gemini/gpio.c: | 5 | * Based on arch/arm/mach-gemini/gpio.c: |
@@ -35,28 +35,28 @@ | |||
35 | #define GPIO_DEBOUNCE_PRESCALE 0x44 | 35 | #define GPIO_DEBOUNCE_PRESCALE 0x44 |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * struct gemini_gpio - Gemini GPIO state container | 38 | * struct ftgpio_gpio - Gemini GPIO state container |
39 | * @dev: containing device for this instance | 39 | * @dev: containing device for this instance |
40 | * @gc: gpiochip for this instance | 40 | * @gc: gpiochip for this instance |
41 | */ | 41 | */ |
42 | struct gemini_gpio { | 42 | struct ftgpio_gpio { |
43 | struct device *dev; | 43 | struct device *dev; |
44 | struct gpio_chip gc; | 44 | struct gpio_chip gc; |
45 | void __iomem *base; | 45 | void __iomem *base; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | static void gemini_gpio_ack_irq(struct irq_data *d) | 48 | static void ftgpio_gpio_ack_irq(struct irq_data *d) |
49 | { | 49 | { |
50 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 50 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
51 | struct gemini_gpio *g = gpiochip_get_data(gc); | 51 | struct ftgpio_gpio *g = gpiochip_get_data(gc); |
52 | 52 | ||
53 | writel(BIT(irqd_to_hwirq(d)), g->base + GPIO_INT_CLR); | 53 | writel(BIT(irqd_to_hwirq(d)), g->base + GPIO_INT_CLR); |
54 | } | 54 | } |
55 | 55 | ||
56 | static void gemini_gpio_mask_irq(struct irq_data *d) | 56 | static void ftgpio_gpio_mask_irq(struct irq_data *d) |
57 | { | 57 | { |
58 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 58 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
59 | struct gemini_gpio *g = gpiochip_get_data(gc); | 59 | struct ftgpio_gpio *g = gpiochip_get_data(gc); |
60 | u32 val; | 60 | u32 val; |
61 | 61 | ||
62 | val = readl(g->base + GPIO_INT_EN); | 62 | val = readl(g->base + GPIO_INT_EN); |
@@ -64,10 +64,10 @@ static void gemini_gpio_mask_irq(struct irq_data *d) | |||
64 | writel(val, g->base + GPIO_INT_EN); | 64 | writel(val, g->base + GPIO_INT_EN); |
65 | } | 65 | } |
66 | 66 | ||
67 | static void gemini_gpio_unmask_irq(struct irq_data *d) | 67 | static void ftgpio_gpio_unmask_irq(struct irq_data *d) |
68 | { | 68 | { |
69 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 69 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
70 | struct gemini_gpio *g = gpiochip_get_data(gc); | 70 | struct ftgpio_gpio *g = gpiochip_get_data(gc); |
71 | u32 val; | 71 | u32 val; |
72 | 72 | ||
73 | val = readl(g->base + GPIO_INT_EN); | 73 | val = readl(g->base + GPIO_INT_EN); |
@@ -75,10 +75,10 @@ static void gemini_gpio_unmask_irq(struct irq_data *d) | |||
75 | writel(val, g->base + GPIO_INT_EN); | 75 | writel(val, g->base + GPIO_INT_EN); |
76 | } | 76 | } |
77 | 77 | ||
78 | static int gemini_gpio_set_irq_type(struct irq_data *d, unsigned int type) | 78 | static int ftgpio_gpio_set_irq_type(struct irq_data *d, unsigned int type) |
79 | { | 79 | { |
80 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 80 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
81 | struct gemini_gpio *g = gpiochip_get_data(gc); | 81 | struct ftgpio_gpio *g = gpiochip_get_data(gc); |
82 | u32 mask = BIT(irqd_to_hwirq(d)); | 82 | u32 mask = BIT(irqd_to_hwirq(d)); |
83 | u32 reg_both, reg_level, reg_type; | 83 | u32 reg_both, reg_level, reg_type; |
84 | 84 | ||
@@ -123,23 +123,23 @@ static int gemini_gpio_set_irq_type(struct irq_data *d, unsigned int type) | |||
123 | writel(reg_level, g->base + GPIO_INT_LEVEL); | 123 | writel(reg_level, g->base + GPIO_INT_LEVEL); |
124 | writel(reg_both, g->base + GPIO_INT_BOTH_EDGE); | 124 | writel(reg_both, g->base + GPIO_INT_BOTH_EDGE); |
125 | 125 | ||
126 | gemini_gpio_ack_irq(d); | 126 | ftgpio_gpio_ack_irq(d); |
127 | 127 | ||
128 | return 0; | 128 | return 0; |
129 | } | 129 | } |
130 | 130 | ||
131 | static struct irq_chip gemini_gpio_irqchip = { | 131 | static struct irq_chip ftgpio_gpio_irqchip = { |
132 | .name = "GPIO", | 132 | .name = "FTGPIO010", |
133 | .irq_ack = gemini_gpio_ack_irq, | 133 | .irq_ack = ftgpio_gpio_ack_irq, |
134 | .irq_mask = gemini_gpio_mask_irq, | 134 | .irq_mask = ftgpio_gpio_mask_irq, |
135 | .irq_unmask = gemini_gpio_unmask_irq, | 135 | .irq_unmask = ftgpio_gpio_unmask_irq, |
136 | .irq_set_type = gemini_gpio_set_irq_type, | 136 | .irq_set_type = ftgpio_gpio_set_irq_type, |
137 | }; | 137 | }; |
138 | 138 | ||
139 | static void gemini_gpio_irq_handler(struct irq_desc *desc) | 139 | static void ftgpio_gpio_irq_handler(struct irq_desc *desc) |
140 | { | 140 | { |
141 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); | 141 | struct gpio_chip *gc = irq_desc_get_handler_data(desc); |
142 | struct gemini_gpio *g = gpiochip_get_data(gc); | 142 | struct ftgpio_gpio *g = gpiochip_get_data(gc); |
143 | struct irq_chip *irqchip = irq_desc_get_chip(desc); | 143 | struct irq_chip *irqchip = irq_desc_get_chip(desc); |
144 | int offset; | 144 | int offset; |
145 | unsigned long stat; | 145 | unsigned long stat; |
@@ -155,11 +155,11 @@ static void gemini_gpio_irq_handler(struct irq_desc *desc) | |||
155 | chained_irq_exit(irqchip, desc); | 155 | chained_irq_exit(irqchip, desc); |
156 | } | 156 | } |
157 | 157 | ||
158 | static int gemini_gpio_probe(struct platform_device *pdev) | 158 | static int ftgpio_gpio_probe(struct platform_device *pdev) |
159 | { | 159 | { |
160 | struct device *dev = &pdev->dev; | 160 | struct device *dev = &pdev->dev; |
161 | struct resource *res; | 161 | struct resource *res; |
162 | struct gemini_gpio *g; | 162 | struct ftgpio_gpio *g; |
163 | int irq; | 163 | int irq; |
164 | int ret; | 164 | int ret; |
165 | 165 | ||
@@ -189,7 +189,7 @@ static int gemini_gpio_probe(struct platform_device *pdev) | |||
189 | dev_err(dev, "unable to init generic GPIO\n"); | 189 | dev_err(dev, "unable to init generic GPIO\n"); |
190 | return ret; | 190 | return ret; |
191 | } | 191 | } |
192 | g->gc.label = "Gemini"; | 192 | g->gc.label = "FTGPIO010"; |
193 | g->gc.base = -1; | 193 | g->gc.base = -1; |
194 | g->gc.parent = dev; | 194 | g->gc.parent = dev; |
195 | g->gc.owner = THIS_MODULE; | 195 | g->gc.owner = THIS_MODULE; |
@@ -204,33 +204,39 @@ static int gemini_gpio_probe(struct platform_device *pdev) | |||
204 | writel(0x0, g->base + GPIO_INT_MASK); | 204 | writel(0x0, g->base + GPIO_INT_MASK); |
205 | writel(~0x0, g->base + GPIO_INT_CLR); | 205 | writel(~0x0, g->base + GPIO_INT_CLR); |
206 | 206 | ||
207 | ret = gpiochip_irqchip_add(&g->gc, &gemini_gpio_irqchip, | 207 | ret = gpiochip_irqchip_add(&g->gc, &ftgpio_gpio_irqchip, |
208 | 0, handle_bad_irq, | 208 | 0, handle_bad_irq, |
209 | IRQ_TYPE_NONE); | 209 | IRQ_TYPE_NONE); |
210 | if (ret) { | 210 | if (ret) { |
211 | dev_info(dev, "could not add irqchip\n"); | 211 | dev_info(dev, "could not add irqchip\n"); |
212 | return ret; | 212 | return ret; |
213 | } | 213 | } |
214 | gpiochip_set_chained_irqchip(&g->gc, &gemini_gpio_irqchip, | 214 | gpiochip_set_chained_irqchip(&g->gc, &ftgpio_gpio_irqchip, |
215 | irq, gemini_gpio_irq_handler); | 215 | irq, ftgpio_gpio_irq_handler); |
216 | 216 | ||
217 | dev_info(dev, "Gemini GPIO @%p registered\n", g->base); | 217 | dev_info(dev, "FTGPIO010 @%p registered\n", g->base); |
218 | 218 | ||
219 | return 0; | 219 | return 0; |
220 | } | 220 | } |
221 | 221 | ||
222 | static const struct of_device_id gemini_gpio_of_match[] = { | 222 | static const struct of_device_id ftgpio_gpio_of_match[] = { |
223 | { | 223 | { |
224 | .compatible = "cortina,gemini-gpio", | 224 | .compatible = "cortina,gemini-gpio", |
225 | }, | 225 | }, |
226 | { | ||
227 | .compatible = "moxa,moxart-gpio", | ||
228 | }, | ||
229 | { | ||
230 | .compatible = "faraday,ftgpio010", | ||
231 | }, | ||
226 | {}, | 232 | {}, |
227 | }; | 233 | }; |
228 | 234 | ||
229 | static struct platform_driver gemini_gpio_driver = { | 235 | static struct platform_driver ftgpio_gpio_driver = { |
230 | .driver = { | 236 | .driver = { |
231 | .name = "gemini-gpio", | 237 | .name = "ftgpio010-gpio", |
232 | .of_match_table = of_match_ptr(gemini_gpio_of_match), | 238 | .of_match_table = of_match_ptr(ftgpio_gpio_of_match), |
233 | }, | 239 | }, |
234 | .probe = gemini_gpio_probe, | 240 | .probe = ftgpio_gpio_probe, |
235 | }; | 241 | }; |
236 | builtin_platform_driver(gemini_gpio_driver); | 242 | builtin_platform_driver(ftgpio_gpio_driver); |
diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c index f40088d268c1..9dbdc3672f5e 100644 --- a/drivers/gpio/gpio-merrifield.c +++ b/drivers/gpio/gpio-merrifield.c | |||
@@ -166,7 +166,7 @@ static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) | |||
166 | { | 166 | { |
167 | void __iomem *gpdr = gpio_reg(chip, offset, GPDR); | 167 | void __iomem *gpdr = gpio_reg(chip, offset, GPDR); |
168 | 168 | ||
169 | return (readl(gpdr) & BIT(offset % 32)) ? GPIOF_DIR_OUT : GPIOF_DIR_IN; | 169 | return !(readl(gpdr) & BIT(offset % 32)); |
170 | } | 170 | } |
171 | 171 | ||
172 | static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset, | 172 | static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset, |
diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c index 796a5a4bc4f5..78896a869fd9 100644 --- a/drivers/gpio/gpio-ml-ioh.c +++ b/drivers/gpio/gpio-ml-ioh.c | |||
@@ -459,41 +459,31 @@ static int ioh_gpio_probe(struct pci_dev *pdev, | |||
459 | 459 | ||
460 | chip = chip_save; | 460 | chip = chip_save; |
461 | for (j = 0; j < 8; j++, chip++) { | 461 | for (j = 0; j < 8; j++, chip++) { |
462 | irq_base = irq_alloc_descs(-1, IOH_IRQ_BASE, num_ports[j], | 462 | irq_base = devm_irq_alloc_descs(&pdev->dev, -1, IOH_IRQ_BASE, |
463 | NUMA_NO_NODE); | 463 | num_ports[j], NUMA_NO_NODE); |
464 | if (irq_base < 0) { | 464 | if (irq_base < 0) { |
465 | dev_warn(&pdev->dev, | 465 | dev_warn(&pdev->dev, |
466 | "ml_ioh_gpio: Failed to get IRQ base num\n"); | 466 | "ml_ioh_gpio: Failed to get IRQ base num\n"); |
467 | chip->irq_base = -1; | ||
468 | ret = irq_base; | 467 | ret = irq_base; |
469 | goto err_irq_alloc_descs; | 468 | goto err_gpiochip_add; |
470 | } | 469 | } |
471 | chip->irq_base = irq_base; | 470 | chip->irq_base = irq_base; |
472 | ioh_gpio_alloc_generic_chip(chip, irq_base, num_ports[j]); | 471 | ioh_gpio_alloc_generic_chip(chip, irq_base, num_ports[j]); |
473 | } | 472 | } |
474 | 473 | ||
475 | chip = chip_save; | 474 | chip = chip_save; |
476 | ret = request_irq(pdev->irq, ioh_gpio_handler, | 475 | ret = devm_request_irq(&pdev->dev, pdev->irq, ioh_gpio_handler, |
477 | IRQF_SHARED, KBUILD_MODNAME, chip); | 476 | IRQF_SHARED, KBUILD_MODNAME, chip); |
478 | if (ret != 0) { | 477 | if (ret != 0) { |
479 | dev_err(&pdev->dev, | 478 | dev_err(&pdev->dev, |
480 | "%s request_irq failed\n", __func__); | 479 | "%s request_irq failed\n", __func__); |
481 | goto err_request_irq; | 480 | goto err_gpiochip_add; |
482 | } | 481 | } |
483 | 482 | ||
484 | pci_set_drvdata(pdev, chip); | 483 | pci_set_drvdata(pdev, chip); |
485 | 484 | ||
486 | return 0; | 485 | return 0; |
487 | 486 | ||
488 | err_request_irq: | ||
489 | chip = chip_save; | ||
490 | err_irq_alloc_descs: | ||
491 | while (--j >= 0) { | ||
492 | chip--; | ||
493 | irq_free_descs(chip->irq_base, num_ports[j]); | ||
494 | } | ||
495 | |||
496 | chip = chip_save; | ||
497 | err_gpiochip_add: | 487 | err_gpiochip_add: |
498 | while (--i >= 0) { | 488 | while (--i >= 0) { |
499 | chip--; | 489 | chip--; |
@@ -524,12 +514,8 @@ static void ioh_gpio_remove(struct pci_dev *pdev) | |||
524 | 514 | ||
525 | chip_save = chip; | 515 | chip_save = chip; |
526 | 516 | ||
527 | free_irq(pdev->irq, chip); | 517 | for (i = 0; i < 8; i++, chip++) |
528 | |||
529 | for (i = 0; i < 8; i++, chip++) { | ||
530 | irq_free_descs(chip->irq_base, num_ports[i]); | ||
531 | gpiochip_remove(&chip->gpio); | 518 | gpiochip_remove(&chip->gpio); |
532 | } | ||
533 | 519 | ||
534 | chip = chip_save; | 520 | chip = chip_save; |
535 | pci_iounmap(pdev, chip->base); | 521 | pci_iounmap(pdev, chip->base); |
diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c index d7d03ad052d0..f7da40e46c55 100644 --- a/drivers/gpio/gpio-mmio.c +++ b/drivers/gpio/gpio-mmio.c | |||
@@ -575,6 +575,7 @@ static void __iomem *bgpio_map(struct platform_device *pdev, | |||
575 | static const struct of_device_id bgpio_of_match[] = { | 575 | static const struct of_device_id bgpio_of_match[] = { |
576 | { .compatible = "brcm,bcm6345-gpio" }, | 576 | { .compatible = "brcm,bcm6345-gpio" }, |
577 | { .compatible = "wd,mbl-gpio" }, | 577 | { .compatible = "wd,mbl-gpio" }, |
578 | { .compatible = "ni,169445-nand-gpio" }, | ||
578 | { } | 579 | { } |
579 | }; | 580 | }; |
580 | MODULE_DEVICE_TABLE(of, bgpio_of_match); | 581 | MODULE_DEVICE_TABLE(of, bgpio_of_match); |
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index d99338689213..c6dadac70593 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c | |||
@@ -169,7 +169,7 @@ static int gpio_mockup_irqchip_setup(struct device *dev, | |||
169 | struct gpio_chip *gc = &chip->gc; | 169 | struct gpio_chip *gc = &chip->gc; |
170 | int irq_base, i; | 170 | int irq_base, i; |
171 | 171 | ||
172 | irq_base = irq_alloc_descs(-1, 0, gc->ngpio, 0); | 172 | irq_base = devm_irq_alloc_descs(dev, -1, 0, gc->ngpio, 0); |
173 | if (irq_base < 0) | 173 | if (irq_base < 0) |
174 | return irq_base; | 174 | return irq_base; |
175 | 175 | ||
@@ -372,25 +372,11 @@ static int gpio_mockup_probe(struct platform_device *pdev) | |||
372 | return 0; | 372 | return 0; |
373 | } | 373 | } |
374 | 374 | ||
375 | static int gpio_mockup_remove(struct platform_device *pdev) | ||
376 | { | ||
377 | struct gpio_mockup_chip *chips; | ||
378 | int i; | ||
379 | |||
380 | chips = platform_get_drvdata(pdev); | ||
381 | |||
382 | for (i = 0; i < gpio_mockup_params_nr >> 1; i++) | ||
383 | irq_free_descs(chips[i].gc.irq_base, chips[i].gc.ngpio); | ||
384 | |||
385 | return 0; | ||
386 | } | ||
387 | |||
388 | static struct platform_driver gpio_mockup_driver = { | 375 | static struct platform_driver gpio_mockup_driver = { |
389 | .driver = { | 376 | .driver = { |
390 | .name = GPIO_MOCKUP_NAME, | 377 | .name = GPIO_MOCKUP_NAME, |
391 | }, | 378 | }, |
392 | .probe = gpio_mockup_probe, | 379 | .probe = gpio_mockup_probe, |
393 | .remove = gpio_mockup_remove, | ||
394 | }; | 380 | }; |
395 | 381 | ||
396 | static struct platform_device *pdev; | 382 | static struct platform_device *pdev; |
diff --git a/drivers/gpio/gpio-moxart.c b/drivers/gpio/gpio-moxart.c deleted file mode 100644 index d58d38906ba6..000000000000 --- a/drivers/gpio/gpio-moxart.c +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* | ||
2 | * MOXA ART SoCs GPIO driver. | ||
3 | * | ||
4 | * Copyright (C) 2013 Jonas Jensen | ||
5 | * | ||
6 | * Jonas Jensen <jonas.jensen@gmail.com> | ||
7 | * | ||
8 | * This file is licensed under the terms of the GNU General Public | ||
9 | * License version 2. This program is licensed "as is" without any | ||
10 | * warranty of any kind, whether express or implied. | ||
11 | */ | ||
12 | |||
13 | #include <linux/err.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/irq.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/of_address.h> | ||
19 | #include <linux/of_gpio.h> | ||
20 | #include <linux/pinctrl/consumer.h> | ||
21 | #include <linux/delay.h> | ||
22 | #include <linux/timer.h> | ||
23 | #include <linux/bitops.h> | ||
24 | #include <linux/gpio/driver.h> | ||
25 | |||
26 | #define GPIO_DATA_OUT 0x00 | ||
27 | #define GPIO_DATA_IN 0x04 | ||
28 | #define GPIO_PIN_DIRECTION 0x08 | ||
29 | |||
30 | static int moxart_gpio_probe(struct platform_device *pdev) | ||
31 | { | ||
32 | struct device *dev = &pdev->dev; | ||
33 | struct resource *res; | ||
34 | struct gpio_chip *gc; | ||
35 | void __iomem *base; | ||
36 | int ret; | ||
37 | |||
38 | gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL); | ||
39 | if (!gc) | ||
40 | return -ENOMEM; | ||
41 | |||
42 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
43 | base = devm_ioremap_resource(dev, res); | ||
44 | if (IS_ERR(base)) | ||
45 | return PTR_ERR(base); | ||
46 | |||
47 | ret = bgpio_init(gc, dev, 4, base + GPIO_DATA_IN, | ||
48 | base + GPIO_DATA_OUT, NULL, | ||
49 | base + GPIO_PIN_DIRECTION, NULL, | ||
50 | BGPIOF_READ_OUTPUT_REG_SET); | ||
51 | if (ret) { | ||
52 | dev_err(&pdev->dev, "bgpio_init failed\n"); | ||
53 | return ret; | ||
54 | } | ||
55 | |||
56 | gc->label = "moxart-gpio"; | ||
57 | gc->request = gpiochip_generic_request; | ||
58 | gc->free = gpiochip_generic_free; | ||
59 | gc->base = 0; | ||
60 | gc->owner = THIS_MODULE; | ||
61 | |||
62 | ret = devm_gpiochip_add_data(dev, gc, NULL); | ||
63 | if (ret) { | ||
64 | dev_err(dev, "%s: gpiochip_add failed\n", | ||
65 | dev->of_node->full_name); | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | static const struct of_device_id moxart_gpio_match[] = { | ||
73 | { .compatible = "moxa,moxart-gpio" }, | ||
74 | { } | ||
75 | }; | ||
76 | |||
77 | static struct platform_driver moxart_gpio_driver = { | ||
78 | .driver = { | ||
79 | .name = "moxart-gpio", | ||
80 | .of_match_table = moxart_gpio_match, | ||
81 | }, | ||
82 | .probe = moxart_gpio_probe, | ||
83 | }; | ||
84 | builtin_platform_driver(moxart_gpio_driver); | ||
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index a649556ac3ca..19a92efabbef 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c | |||
@@ -42,29 +42,44 @@ | |||
42 | #include <linux/io.h> | 42 | #include <linux/io.h> |
43 | #include <linux/of_irq.h> | 43 | #include <linux/of_irq.h> |
44 | #include <linux/of_device.h> | 44 | #include <linux/of_device.h> |
45 | #include <linux/pwm.h> | ||
45 | #include <linux/clk.h> | 46 | #include <linux/clk.h> |
46 | #include <linux/pinctrl/consumer.h> | 47 | #include <linux/pinctrl/consumer.h> |
47 | #include <linux/irqchip/chained_irq.h> | 48 | #include <linux/irqchip/chained_irq.h> |
49 | #include <linux/platform_device.h> | ||
50 | #include <linux/bitops.h> | ||
51 | |||
52 | #include "gpiolib.h" | ||
48 | 53 | ||
49 | /* | 54 | /* |
50 | * GPIO unit register offsets. | 55 | * GPIO unit register offsets. |
51 | */ | 56 | */ |
52 | #define GPIO_OUT_OFF 0x0000 | 57 | #define GPIO_OUT_OFF 0x0000 |
53 | #define GPIO_IO_CONF_OFF 0x0004 | 58 | #define GPIO_IO_CONF_OFF 0x0004 |
54 | #define GPIO_BLINK_EN_OFF 0x0008 | 59 | #define GPIO_BLINK_EN_OFF 0x0008 |
55 | #define GPIO_IN_POL_OFF 0x000c | 60 | #define GPIO_IN_POL_OFF 0x000c |
56 | #define GPIO_DATA_IN_OFF 0x0010 | 61 | #define GPIO_DATA_IN_OFF 0x0010 |
57 | #define GPIO_EDGE_CAUSE_OFF 0x0014 | 62 | #define GPIO_EDGE_CAUSE_OFF 0x0014 |
58 | #define GPIO_EDGE_MASK_OFF 0x0018 | 63 | #define GPIO_EDGE_MASK_OFF 0x0018 |
59 | #define GPIO_LEVEL_MASK_OFF 0x001c | 64 | #define GPIO_LEVEL_MASK_OFF 0x001c |
65 | #define GPIO_BLINK_CNT_SELECT_OFF 0x0020 | ||
66 | |||
67 | /* | ||
68 | * PWM register offsets. | ||
69 | */ | ||
70 | #define PWM_BLINK_ON_DURATION_OFF 0x0 | ||
71 | #define PWM_BLINK_OFF_DURATION_OFF 0x4 | ||
72 | |||
60 | 73 | ||
61 | /* The MV78200 has per-CPU registers for edge mask and level mask */ | 74 | /* The MV78200 has per-CPU registers for edge mask and level mask */ |
62 | #define GPIO_EDGE_MASK_MV78200_OFF(cpu) ((cpu) ? 0x30 : 0x18) | 75 | #define GPIO_EDGE_MASK_MV78200_OFF(cpu) ((cpu) ? 0x30 : 0x18) |
63 | #define GPIO_LEVEL_MASK_MV78200_OFF(cpu) ((cpu) ? 0x34 : 0x1C) | 76 | #define GPIO_LEVEL_MASK_MV78200_OFF(cpu) ((cpu) ? 0x34 : 0x1C) |
64 | 77 | ||
65 | /* The Armada XP has per-CPU registers for interrupt cause, interrupt | 78 | /* |
79 | * The Armada XP has per-CPU registers for interrupt cause, interrupt | ||
66 | * mask and interrupt level mask. Those are relative to the | 80 | * mask and interrupt level mask. Those are relative to the |
67 | * percpu_membase. */ | 81 | * percpu_membase. |
82 | */ | ||
68 | #define GPIO_EDGE_CAUSE_ARMADAXP_OFF(cpu) ((cpu) * 0x4) | 83 | #define GPIO_EDGE_CAUSE_ARMADAXP_OFF(cpu) ((cpu) * 0x4) |
69 | #define GPIO_EDGE_MASK_ARMADAXP_OFF(cpu) (0x10 + (cpu) * 0x4) | 84 | #define GPIO_EDGE_MASK_ARMADAXP_OFF(cpu) (0x10 + (cpu) * 0x4) |
70 | #define GPIO_LEVEL_MASK_ARMADAXP_OFF(cpu) (0x20 + (cpu) * 0x4) | 85 | #define GPIO_LEVEL_MASK_ARMADAXP_OFF(cpu) (0x20 + (cpu) * 0x4) |
@@ -75,6 +90,20 @@ | |||
75 | 90 | ||
76 | #define MVEBU_MAX_GPIO_PER_BANK 32 | 91 | #define MVEBU_MAX_GPIO_PER_BANK 32 |
77 | 92 | ||
93 | struct mvebu_pwm { | ||
94 | void __iomem *membase; | ||
95 | unsigned long clk_rate; | ||
96 | struct gpio_desc *gpiod; | ||
97 | struct pwm_chip chip; | ||
98 | spinlock_t lock; | ||
99 | struct mvebu_gpio_chip *mvchip; | ||
100 | |||
101 | /* Used to preserve GPIO/PWM registers across suspend/resume */ | ||
102 | u32 blink_select; | ||
103 | u32 blink_on_duration; | ||
104 | u32 blink_off_duration; | ||
105 | }; | ||
106 | |||
78 | struct mvebu_gpio_chip { | 107 | struct mvebu_gpio_chip { |
79 | struct gpio_chip chip; | 108 | struct gpio_chip chip; |
80 | spinlock_t lock; | 109 | spinlock_t lock; |
@@ -84,48 +113,55 @@ struct mvebu_gpio_chip { | |||
84 | struct irq_domain *domain; | 113 | struct irq_domain *domain; |
85 | int soc_variant; | 114 | int soc_variant; |
86 | 115 | ||
116 | /* Used for PWM support */ | ||
117 | struct clk *clk; | ||
118 | struct mvebu_pwm *mvpwm; | ||
119 | |||
87 | /* Used to preserve GPIO registers across suspend/resume */ | 120 | /* Used to preserve GPIO registers across suspend/resume */ |
88 | u32 out_reg; | 121 | u32 out_reg; |
89 | u32 io_conf_reg; | 122 | u32 io_conf_reg; |
90 | u32 blink_en_reg; | 123 | u32 blink_en_reg; |
91 | u32 in_pol_reg; | 124 | u32 in_pol_reg; |
92 | u32 edge_mask_regs[4]; | 125 | u32 edge_mask_regs[4]; |
93 | u32 level_mask_regs[4]; | 126 | u32 level_mask_regs[4]; |
94 | }; | 127 | }; |
95 | 128 | ||
96 | /* | 129 | /* |
97 | * Functions returning addresses of individual registers for a given | 130 | * Functions returning addresses of individual registers for a given |
98 | * GPIO controller. | 131 | * GPIO controller. |
99 | */ | 132 | */ |
100 | static inline void __iomem *mvebu_gpioreg_out(struct mvebu_gpio_chip *mvchip) | 133 | static void __iomem *mvebu_gpioreg_out(struct mvebu_gpio_chip *mvchip) |
101 | { | 134 | { |
102 | return mvchip->membase + GPIO_OUT_OFF; | 135 | return mvchip->membase + GPIO_OUT_OFF; |
103 | } | 136 | } |
104 | 137 | ||
105 | static inline void __iomem *mvebu_gpioreg_blink(struct mvebu_gpio_chip *mvchip) | 138 | static void __iomem *mvebu_gpioreg_blink(struct mvebu_gpio_chip *mvchip) |
106 | { | 139 | { |
107 | return mvchip->membase + GPIO_BLINK_EN_OFF; | 140 | return mvchip->membase + GPIO_BLINK_EN_OFF; |
108 | } | 141 | } |
109 | 142 | ||
110 | static inline void __iomem * | 143 | static void __iomem *mvebu_gpioreg_blink_counter_select(struct mvebu_gpio_chip |
111 | mvebu_gpioreg_io_conf(struct mvebu_gpio_chip *mvchip) | 144 | *mvchip) |
145 | { | ||
146 | return mvchip->membase + GPIO_BLINK_CNT_SELECT_OFF; | ||
147 | } | ||
148 | |||
149 | static void __iomem *mvebu_gpioreg_io_conf(struct mvebu_gpio_chip *mvchip) | ||
112 | { | 150 | { |
113 | return mvchip->membase + GPIO_IO_CONF_OFF; | 151 | return mvchip->membase + GPIO_IO_CONF_OFF; |
114 | } | 152 | } |
115 | 153 | ||
116 | static inline void __iomem *mvebu_gpioreg_in_pol(struct mvebu_gpio_chip *mvchip) | 154 | static void __iomem *mvebu_gpioreg_in_pol(struct mvebu_gpio_chip *mvchip) |
117 | { | 155 | { |
118 | return mvchip->membase + GPIO_IN_POL_OFF; | 156 | return mvchip->membase + GPIO_IN_POL_OFF; |
119 | } | 157 | } |
120 | 158 | ||
121 | static inline void __iomem * | 159 | static void __iomem *mvebu_gpioreg_data_in(struct mvebu_gpio_chip *mvchip) |
122 | mvebu_gpioreg_data_in(struct mvebu_gpio_chip *mvchip) | ||
123 | { | 160 | { |
124 | return mvchip->membase + GPIO_DATA_IN_OFF; | 161 | return mvchip->membase + GPIO_DATA_IN_OFF; |
125 | } | 162 | } |
126 | 163 | ||
127 | static inline void __iomem * | 164 | static void __iomem *mvebu_gpioreg_edge_cause(struct mvebu_gpio_chip *mvchip) |
128 | mvebu_gpioreg_edge_cause(struct mvebu_gpio_chip *mvchip) | ||
129 | { | 165 | { |
130 | int cpu; | 166 | int cpu; |
131 | 167 | ||
@@ -142,8 +178,7 @@ mvebu_gpioreg_edge_cause(struct mvebu_gpio_chip *mvchip) | |||
142 | } | 178 | } |
143 | } | 179 | } |
144 | 180 | ||
145 | static inline void __iomem * | 181 | static void __iomem *mvebu_gpioreg_edge_mask(struct mvebu_gpio_chip *mvchip) |
146 | mvebu_gpioreg_edge_mask(struct mvebu_gpio_chip *mvchip) | ||
147 | { | 182 | { |
148 | int cpu; | 183 | int cpu; |
149 | 184 | ||
@@ -182,10 +217,23 @@ static void __iomem *mvebu_gpioreg_level_mask(struct mvebu_gpio_chip *mvchip) | |||
182 | } | 217 | } |
183 | 218 | ||
184 | /* | 219 | /* |
185 | * Functions implementing the gpio_chip methods | 220 | * Functions returning addresses of individual registers for a given |
221 | * PWM controller. | ||
186 | */ | 222 | */ |
223 | static void __iomem *mvebu_pwmreg_blink_on_duration(struct mvebu_pwm *mvpwm) | ||
224 | { | ||
225 | return mvpwm->membase + PWM_BLINK_ON_DURATION_OFF; | ||
226 | } | ||
227 | |||
228 | static void __iomem *mvebu_pwmreg_blink_off_duration(struct mvebu_pwm *mvpwm) | ||
229 | { | ||
230 | return mvpwm->membase + PWM_BLINK_OFF_DURATION_OFF; | ||
231 | } | ||
187 | 232 | ||
188 | static void mvebu_gpio_set(struct gpio_chip *chip, unsigned pin, int value) | 233 | /* |
234 | * Functions implementing the gpio_chip methods | ||
235 | */ | ||
236 | static void mvebu_gpio_set(struct gpio_chip *chip, unsigned int pin, int value) | ||
189 | { | 237 | { |
190 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); | 238 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); |
191 | unsigned long flags; | 239 | unsigned long flags; |
@@ -194,19 +242,19 @@ static void mvebu_gpio_set(struct gpio_chip *chip, unsigned pin, int value) | |||
194 | spin_lock_irqsave(&mvchip->lock, flags); | 242 | spin_lock_irqsave(&mvchip->lock, flags); |
195 | u = readl_relaxed(mvebu_gpioreg_out(mvchip)); | 243 | u = readl_relaxed(mvebu_gpioreg_out(mvchip)); |
196 | if (value) | 244 | if (value) |
197 | u |= 1 << pin; | 245 | u |= BIT(pin); |
198 | else | 246 | else |
199 | u &= ~(1 << pin); | 247 | u &= ~BIT(pin); |
200 | writel_relaxed(u, mvebu_gpioreg_out(mvchip)); | 248 | writel_relaxed(u, mvebu_gpioreg_out(mvchip)); |
201 | spin_unlock_irqrestore(&mvchip->lock, flags); | 249 | spin_unlock_irqrestore(&mvchip->lock, flags); |
202 | } | 250 | } |
203 | 251 | ||
204 | static int mvebu_gpio_get(struct gpio_chip *chip, unsigned pin) | 252 | static int mvebu_gpio_get(struct gpio_chip *chip, unsigned int pin) |
205 | { | 253 | { |
206 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); | 254 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); |
207 | u32 u; | 255 | u32 u; |
208 | 256 | ||
209 | if (readl_relaxed(mvebu_gpioreg_io_conf(mvchip)) & (1 << pin)) { | 257 | if (readl_relaxed(mvebu_gpioreg_io_conf(mvchip)) & BIT(pin)) { |
210 | u = readl_relaxed(mvebu_gpioreg_data_in(mvchip)) ^ | 258 | u = readl_relaxed(mvebu_gpioreg_data_in(mvchip)) ^ |
211 | readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); | 259 | readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); |
212 | } else { | 260 | } else { |
@@ -216,7 +264,8 @@ static int mvebu_gpio_get(struct gpio_chip *chip, unsigned pin) | |||
216 | return (u >> pin) & 1; | 264 | return (u >> pin) & 1; |
217 | } | 265 | } |
218 | 266 | ||
219 | static void mvebu_gpio_blink(struct gpio_chip *chip, unsigned pin, int value) | 267 | static void mvebu_gpio_blink(struct gpio_chip *chip, unsigned int pin, |
268 | int value) | ||
220 | { | 269 | { |
221 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); | 270 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); |
222 | unsigned long flags; | 271 | unsigned long flags; |
@@ -225,36 +274,38 @@ static void mvebu_gpio_blink(struct gpio_chip *chip, unsigned pin, int value) | |||
225 | spin_lock_irqsave(&mvchip->lock, flags); | 274 | spin_lock_irqsave(&mvchip->lock, flags); |
226 | u = readl_relaxed(mvebu_gpioreg_blink(mvchip)); | 275 | u = readl_relaxed(mvebu_gpioreg_blink(mvchip)); |
227 | if (value) | 276 | if (value) |
228 | u |= 1 << pin; | 277 | u |= BIT(pin); |
229 | else | 278 | else |
230 | u &= ~(1 << pin); | 279 | u &= ~BIT(pin); |
231 | writel_relaxed(u, mvebu_gpioreg_blink(mvchip)); | 280 | writel_relaxed(u, mvebu_gpioreg_blink(mvchip)); |
232 | spin_unlock_irqrestore(&mvchip->lock, flags); | 281 | spin_unlock_irqrestore(&mvchip->lock, flags); |
233 | } | 282 | } |
234 | 283 | ||
235 | static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned pin) | 284 | static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned int pin) |
236 | { | 285 | { |
237 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); | 286 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); |
238 | unsigned long flags; | 287 | unsigned long flags; |
239 | int ret; | 288 | int ret; |
240 | u32 u; | 289 | u32 u; |
241 | 290 | ||
242 | /* Check with the pinctrl driver whether this pin is usable as | 291 | /* |
243 | * an input GPIO */ | 292 | * Check with the pinctrl driver whether this pin is usable as |
293 | * an input GPIO | ||
294 | */ | ||
244 | ret = pinctrl_gpio_direction_input(chip->base + pin); | 295 | ret = pinctrl_gpio_direction_input(chip->base + pin); |
245 | if (ret) | 296 | if (ret) |
246 | return ret; | 297 | return ret; |
247 | 298 | ||
248 | spin_lock_irqsave(&mvchip->lock, flags); | 299 | spin_lock_irqsave(&mvchip->lock, flags); |
249 | u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)); | 300 | u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)); |
250 | u |= 1 << pin; | 301 | u |= BIT(pin); |
251 | writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip)); | 302 | writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip)); |
252 | spin_unlock_irqrestore(&mvchip->lock, flags); | 303 | spin_unlock_irqrestore(&mvchip->lock, flags); |
253 | 304 | ||
254 | return 0; | 305 | return 0; |
255 | } | 306 | } |
256 | 307 | ||
257 | static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned pin, | 308 | static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned int pin, |
258 | int value) | 309 | int value) |
259 | { | 310 | { |
260 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); | 311 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); |
@@ -262,8 +313,10 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned pin, | |||
262 | int ret; | 313 | int ret; |
263 | u32 u; | 314 | u32 u; |
264 | 315 | ||
265 | /* Check with the pinctrl driver whether this pin is usable as | 316 | /* |
266 | * an output GPIO */ | 317 | * Check with the pinctrl driver whether this pin is usable as |
318 | * an output GPIO | ||
319 | */ | ||
267 | ret = pinctrl_gpio_direction_output(chip->base + pin); | 320 | ret = pinctrl_gpio_direction_output(chip->base + pin); |
268 | if (ret) | 321 | if (ret) |
269 | return ret; | 322 | return ret; |
@@ -273,16 +326,17 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned pin, | |||
273 | 326 | ||
274 | spin_lock_irqsave(&mvchip->lock, flags); | 327 | spin_lock_irqsave(&mvchip->lock, flags); |
275 | u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)); | 328 | u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)); |
276 | u &= ~(1 << pin); | 329 | u &= ~BIT(pin); |
277 | writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip)); | 330 | writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip)); |
278 | spin_unlock_irqrestore(&mvchip->lock, flags); | 331 | spin_unlock_irqrestore(&mvchip->lock, flags); |
279 | 332 | ||
280 | return 0; | 333 | return 0; |
281 | } | 334 | } |
282 | 335 | ||
283 | static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned pin) | 336 | static int mvebu_gpio_to_irq(struct gpio_chip *chip, unsigned int pin) |
284 | { | 337 | { |
285 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); | 338 | struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); |
339 | |||
286 | return irq_create_mapping(mvchip->domain, pin); | 340 | return irq_create_mapping(mvchip->domain, pin); |
287 | } | 341 | } |
288 | 342 | ||
@@ -389,7 +443,7 @@ static int mvebu_gpio_irq_set_type(struct irq_data *d, unsigned int type) | |||
389 | 443 | ||
390 | pin = d->hwirq; | 444 | pin = d->hwirq; |
391 | 445 | ||
392 | u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)) & (1 << pin); | 446 | u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)) & BIT(pin); |
393 | if (!u) | 447 | if (!u) |
394 | return -EINVAL; | 448 | return -EINVAL; |
395 | 449 | ||
@@ -409,13 +463,13 @@ static int mvebu_gpio_irq_set_type(struct irq_data *d, unsigned int type) | |||
409 | case IRQ_TYPE_EDGE_RISING: | 463 | case IRQ_TYPE_EDGE_RISING: |
410 | case IRQ_TYPE_LEVEL_HIGH: | 464 | case IRQ_TYPE_LEVEL_HIGH: |
411 | u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); | 465 | u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); |
412 | u &= ~(1 << pin); | 466 | u &= ~BIT(pin); |
413 | writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); | 467 | writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); |
414 | break; | 468 | break; |
415 | case IRQ_TYPE_EDGE_FALLING: | 469 | case IRQ_TYPE_EDGE_FALLING: |
416 | case IRQ_TYPE_LEVEL_LOW: | 470 | case IRQ_TYPE_LEVEL_LOW: |
417 | u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); | 471 | u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); |
418 | u |= 1 << pin; | 472 | u |= BIT(pin); |
419 | writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); | 473 | writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); |
420 | break; | 474 | break; |
421 | case IRQ_TYPE_EDGE_BOTH: { | 475 | case IRQ_TYPE_EDGE_BOTH: { |
@@ -428,10 +482,10 @@ static int mvebu_gpio_irq_set_type(struct irq_data *d, unsigned int type) | |||
428 | * set initial polarity based on current input level | 482 | * set initial polarity based on current input level |
429 | */ | 483 | */ |
430 | u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); | 484 | u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); |
431 | if (v & (1 << pin)) | 485 | if (v & BIT(pin)) |
432 | u |= 1 << pin; /* falling */ | 486 | u |= BIT(pin); /* falling */ |
433 | else | 487 | else |
434 | u &= ~(1 << pin); /* rising */ | 488 | u &= ~BIT(pin); /* rising */ |
435 | writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); | 489 | writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); |
436 | break; | 490 | break; |
437 | } | 491 | } |
@@ -461,7 +515,7 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc) | |||
461 | 515 | ||
462 | irq = irq_find_mapping(mvchip->domain, i); | 516 | irq = irq_find_mapping(mvchip->domain, i); |
463 | 517 | ||
464 | if (!(cause & (1 << i))) | 518 | if (!(cause & BIT(i))) |
465 | continue; | 519 | continue; |
466 | 520 | ||
467 | type = irq_get_trigger_type(irq); | 521 | type = irq_get_trigger_type(irq); |
@@ -470,7 +524,7 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc) | |||
470 | u32 polarity; | 524 | u32 polarity; |
471 | 525 | ||
472 | polarity = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); | 526 | polarity = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); |
473 | polarity ^= 1 << i; | 527 | polarity ^= BIT(i); |
474 | writel_relaxed(polarity, mvebu_gpioreg_in_pol(mvchip)); | 528 | writel_relaxed(polarity, mvebu_gpioreg_in_pol(mvchip)); |
475 | } | 529 | } |
476 | 530 | ||
@@ -480,6 +534,246 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc) | |||
480 | chained_irq_exit(chip, desc); | 534 | chained_irq_exit(chip, desc); |
481 | } | 535 | } |
482 | 536 | ||
537 | /* | ||
538 | * Functions implementing the pwm_chip methods | ||
539 | */ | ||
540 | static struct mvebu_pwm *to_mvebu_pwm(struct pwm_chip *chip) | ||
541 | { | ||
542 | return container_of(chip, struct mvebu_pwm, chip); | ||
543 | } | ||
544 | |||
545 | static int mvebu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) | ||
546 | { | ||
547 | struct mvebu_pwm *mvpwm = to_mvebu_pwm(chip); | ||
548 | struct mvebu_gpio_chip *mvchip = mvpwm->mvchip; | ||
549 | struct gpio_desc *desc; | ||
550 | unsigned long flags; | ||
551 | int ret = 0; | ||
552 | |||
553 | spin_lock_irqsave(&mvpwm->lock, flags); | ||
554 | |||
555 | if (mvpwm->gpiod) { | ||
556 | ret = -EBUSY; | ||
557 | } else { | ||
558 | desc = gpio_to_desc(mvchip->chip.base + pwm->hwpwm); | ||
559 | if (!desc) { | ||
560 | ret = -ENODEV; | ||
561 | goto out; | ||
562 | } | ||
563 | |||
564 | ret = gpiod_request(desc, "mvebu-pwm"); | ||
565 | if (ret) | ||
566 | goto out; | ||
567 | |||
568 | ret = gpiod_direction_output(desc, 0); | ||
569 | if (ret) { | ||
570 | gpiod_free(desc); | ||
571 | goto out; | ||
572 | } | ||
573 | |||
574 | mvpwm->gpiod = desc; | ||
575 | } | ||
576 | out: | ||
577 | spin_unlock_irqrestore(&mvpwm->lock, flags); | ||
578 | return ret; | ||
579 | } | ||
580 | |||
581 | static void mvebu_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) | ||
582 | { | ||
583 | struct mvebu_pwm *mvpwm = to_mvebu_pwm(chip); | ||
584 | unsigned long flags; | ||
585 | |||
586 | spin_lock_irqsave(&mvpwm->lock, flags); | ||
587 | gpiod_free(mvpwm->gpiod); | ||
588 | mvpwm->gpiod = NULL; | ||
589 | spin_unlock_irqrestore(&mvpwm->lock, flags); | ||
590 | } | ||
591 | |||
592 | static void mvebu_pwm_get_state(struct pwm_chip *chip, | ||
593 | struct pwm_device *pwm, | ||
594 | struct pwm_state *state) { | ||
595 | |||
596 | struct mvebu_pwm *mvpwm = to_mvebu_pwm(chip); | ||
597 | struct mvebu_gpio_chip *mvchip = mvpwm->mvchip; | ||
598 | unsigned long long val; | ||
599 | unsigned long flags; | ||
600 | u32 u; | ||
601 | |||
602 | spin_lock_irqsave(&mvpwm->lock, flags); | ||
603 | |||
604 | val = (unsigned long long) | ||
605 | readl_relaxed(mvebu_pwmreg_blink_on_duration(mvpwm)); | ||
606 | val *= NSEC_PER_SEC; | ||
607 | do_div(val, mvpwm->clk_rate); | ||
608 | if (val > UINT_MAX) | ||
609 | state->duty_cycle = UINT_MAX; | ||
610 | else if (val) | ||
611 | state->duty_cycle = val; | ||
612 | else | ||
613 | state->duty_cycle = 1; | ||
614 | |||
615 | val = (unsigned long long) | ||
616 | readl_relaxed(mvebu_pwmreg_blink_off_duration(mvpwm)); | ||
617 | val *= NSEC_PER_SEC; | ||
618 | do_div(val, mvpwm->clk_rate); | ||
619 | if (val < state->duty_cycle) { | ||
620 | state->period = 1; | ||
621 | } else { | ||
622 | val -= state->duty_cycle; | ||
623 | if (val > UINT_MAX) | ||
624 | state->period = UINT_MAX; | ||
625 | else if (val) | ||
626 | state->period = val; | ||
627 | else | ||
628 | state->period = 1; | ||
629 | } | ||
630 | |||
631 | u = readl_relaxed(mvebu_gpioreg_blink(mvchip)); | ||
632 | if (u) | ||
633 | state->enabled = true; | ||
634 | else | ||
635 | state->enabled = false; | ||
636 | |||
637 | spin_unlock_irqrestore(&mvpwm->lock, flags); | ||
638 | } | ||
639 | |||
640 | static int mvebu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, | ||
641 | struct pwm_state *state) | ||
642 | { | ||
643 | struct mvebu_pwm *mvpwm = to_mvebu_pwm(chip); | ||
644 | struct mvebu_gpio_chip *mvchip = mvpwm->mvchip; | ||
645 | unsigned long long val; | ||
646 | unsigned long flags; | ||
647 | unsigned int on, off; | ||
648 | |||
649 | val = (unsigned long long) mvpwm->clk_rate * state->duty_cycle; | ||
650 | do_div(val, NSEC_PER_SEC); | ||
651 | if (val > UINT_MAX) | ||
652 | return -EINVAL; | ||
653 | if (val) | ||
654 | on = val; | ||
655 | else | ||
656 | on = 1; | ||
657 | |||
658 | val = (unsigned long long) mvpwm->clk_rate * | ||
659 | (state->period - state->duty_cycle); | ||
660 | do_div(val, NSEC_PER_SEC); | ||
661 | if (val > UINT_MAX) | ||
662 | return -EINVAL; | ||
663 | if (val) | ||
664 | off = val; | ||
665 | else | ||
666 | off = 1; | ||
667 | |||
668 | spin_lock_irqsave(&mvpwm->lock, flags); | ||
669 | |||
670 | writel_relaxed(on, mvebu_pwmreg_blink_on_duration(mvpwm)); | ||
671 | writel_relaxed(off, mvebu_pwmreg_blink_off_duration(mvpwm)); | ||
672 | if (state->enabled) | ||
673 | mvebu_gpio_blink(&mvchip->chip, pwm->hwpwm, 1); | ||
674 | else | ||
675 | mvebu_gpio_blink(&mvchip->chip, pwm->hwpwm, 0); | ||
676 | |||
677 | spin_unlock_irqrestore(&mvpwm->lock, flags); | ||
678 | |||
679 | return 0; | ||
680 | } | ||
681 | |||
682 | static const struct pwm_ops mvebu_pwm_ops = { | ||
683 | .request = mvebu_pwm_request, | ||
684 | .free = mvebu_pwm_free, | ||
685 | .get_state = mvebu_pwm_get_state, | ||
686 | .apply = mvebu_pwm_apply, | ||
687 | .owner = THIS_MODULE, | ||
688 | }; | ||
689 | |||
690 | static void __maybe_unused mvebu_pwm_suspend(struct mvebu_gpio_chip *mvchip) | ||
691 | { | ||
692 | struct mvebu_pwm *mvpwm = mvchip->mvpwm; | ||
693 | |||
694 | mvpwm->blink_select = | ||
695 | readl_relaxed(mvebu_gpioreg_blink_counter_select(mvchip)); | ||
696 | mvpwm->blink_on_duration = | ||
697 | readl_relaxed(mvebu_pwmreg_blink_on_duration(mvpwm)); | ||
698 | mvpwm->blink_off_duration = | ||
699 | readl_relaxed(mvebu_pwmreg_blink_off_duration(mvpwm)); | ||
700 | } | ||
701 | |||
702 | static void __maybe_unused mvebu_pwm_resume(struct mvebu_gpio_chip *mvchip) | ||
703 | { | ||
704 | struct mvebu_pwm *mvpwm = mvchip->mvpwm; | ||
705 | |||
706 | writel_relaxed(mvpwm->blink_select, | ||
707 | mvebu_gpioreg_blink_counter_select(mvchip)); | ||
708 | writel_relaxed(mvpwm->blink_on_duration, | ||
709 | mvebu_pwmreg_blink_on_duration(mvpwm)); | ||
710 | writel_relaxed(mvpwm->blink_off_duration, | ||
711 | mvebu_pwmreg_blink_off_duration(mvpwm)); | ||
712 | } | ||
713 | |||
714 | static int mvebu_pwm_probe(struct platform_device *pdev, | ||
715 | struct mvebu_gpio_chip *mvchip, | ||
716 | int id) | ||
717 | { | ||
718 | struct device *dev = &pdev->dev; | ||
719 | struct mvebu_pwm *mvpwm; | ||
720 | struct resource *res; | ||
721 | u32 set; | ||
722 | |||
723 | if (!of_device_is_compatible(mvchip->chip.of_node, | ||
724 | "marvell,armada-370-xp-gpio")) | ||
725 | return 0; | ||
726 | |||
727 | if (IS_ERR(mvchip->clk)) | ||
728 | return PTR_ERR(mvchip->clk); | ||
729 | |||
730 | /* | ||
731 | * There are only two sets of PWM configuration registers for | ||
732 | * all the GPIO lines on those SoCs which this driver reserves | ||
733 | * for the first two GPIO chips. So if the resource is missing | ||
734 | * we can't treat it as an error. | ||
735 | */ | ||
736 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm"); | ||
737 | if (!res) | ||
738 | return 0; | ||
739 | |||
740 | /* | ||
741 | * Use set A for lines of GPIO chip with id 0, B for GPIO chip | ||
742 | * with id 1. Don't allow further GPIO chips to be used for PWM. | ||
743 | */ | ||
744 | if (id == 0) | ||
745 | set = 0; | ||
746 | else if (id == 1) | ||
747 | set = U32_MAX; | ||
748 | else | ||
749 | return -EINVAL; | ||
750 | writel_relaxed(0, mvebu_gpioreg_blink_counter_select(mvchip)); | ||
751 | |||
752 | mvpwm = devm_kzalloc(dev, sizeof(struct mvebu_pwm), GFP_KERNEL); | ||
753 | if (!mvpwm) | ||
754 | return -ENOMEM; | ||
755 | mvchip->mvpwm = mvpwm; | ||
756 | mvpwm->mvchip = mvchip; | ||
757 | |||
758 | mvpwm->membase = devm_ioremap_resource(dev, res); | ||
759 | if (IS_ERR(mvpwm->membase)) | ||
760 | return PTR_ERR(mvpwm->membase); | ||
761 | |||
762 | mvpwm->clk_rate = clk_get_rate(mvchip->clk); | ||
763 | if (!mvpwm->clk_rate) { | ||
764 | dev_err(dev, "failed to get clock rate\n"); | ||
765 | return -EINVAL; | ||
766 | } | ||
767 | |||
768 | mvpwm->chip.dev = dev; | ||
769 | mvpwm->chip.ops = &mvebu_pwm_ops; | ||
770 | mvpwm->chip.npwm = mvchip->chip.ngpio; | ||
771 | |||
772 | spin_lock_init(&mvpwm->lock); | ||
773 | |||
774 | return pwmchip_add(&mvpwm->chip); | ||
775 | } | ||
776 | |||
483 | #ifdef CONFIG_DEBUG_FS | 777 | #ifdef CONFIG_DEBUG_FS |
484 | #include <linux/seq_file.h> | 778 | #include <linux/seq_file.h> |
485 | 779 | ||
@@ -507,7 +801,7 @@ static void mvebu_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | |||
507 | if (!label) | 801 | if (!label) |
508 | continue; | 802 | continue; |
509 | 803 | ||
510 | msk = 1 << i; | 804 | msk = BIT(i); |
511 | is_out = !(io_conf & msk); | 805 | is_out = !(io_conf & msk); |
512 | 806 | ||
513 | seq_printf(s, " gpio-%-3d (%-20.20s)", chip->base + i, label); | 807 | seq_printf(s, " gpio-%-3d (%-20.20s)", chip->base + i, label); |
@@ -551,6 +845,10 @@ static const struct of_device_id mvebu_gpio_of_match[] = { | |||
551 | .data = (void *) MVEBU_GPIO_SOC_VARIANT_ARMADAXP, | 845 | .data = (void *) MVEBU_GPIO_SOC_VARIANT_ARMADAXP, |
552 | }, | 846 | }, |
553 | { | 847 | { |
848 | .compatible = "marvell,armada-370-xp-gpio", | ||
849 | .data = (void *) MVEBU_GPIO_SOC_VARIANT_ORION, | ||
850 | }, | ||
851 | { | ||
554 | /* sentinel */ | 852 | /* sentinel */ |
555 | }, | 853 | }, |
556 | }; | 854 | }; |
@@ -596,6 +894,9 @@ static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state) | |||
596 | BUG(); | 894 | BUG(); |
597 | } | 895 | } |
598 | 896 | ||
897 | if (IS_ENABLED(CONFIG_PWM)) | ||
898 | mvebu_pwm_suspend(mvchip); | ||
899 | |||
599 | return 0; | 900 | return 0; |
600 | } | 901 | } |
601 | 902 | ||
@@ -639,6 +940,9 @@ static int mvebu_gpio_resume(struct platform_device *pdev) | |||
639 | BUG(); | 940 | BUG(); |
640 | } | 941 | } |
641 | 942 | ||
943 | if (IS_ENABLED(CONFIG_PWM)) | ||
944 | mvebu_pwm_resume(mvchip); | ||
945 | |||
642 | return 0; | 946 | return 0; |
643 | } | 947 | } |
644 | 948 | ||
@@ -650,7 +954,6 @@ static int mvebu_gpio_probe(struct platform_device *pdev) | |||
650 | struct resource *res; | 954 | struct resource *res; |
651 | struct irq_chip_generic *gc; | 955 | struct irq_chip_generic *gc; |
652 | struct irq_chip_type *ct; | 956 | struct irq_chip_type *ct; |
653 | struct clk *clk; | ||
654 | unsigned int ngpios; | 957 | unsigned int ngpios; |
655 | bool have_irqs; | 958 | bool have_irqs; |
656 | int soc_variant; | 959 | int soc_variant; |
@@ -684,10 +987,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev) | |||
684 | return id; | 987 | return id; |
685 | } | 988 | } |
686 | 989 | ||
687 | clk = devm_clk_get(&pdev->dev, NULL); | 990 | mvchip->clk = devm_clk_get(&pdev->dev, NULL); |
688 | /* Not all SoCs require a clock.*/ | 991 | /* Not all SoCs require a clock.*/ |
689 | if (!IS_ERR(clk)) | 992 | if (!IS_ERR(mvchip->clk)) |
690 | clk_prepare_enable(clk); | 993 | clk_prepare_enable(mvchip->clk); |
691 | 994 | ||
692 | mvchip->soc_variant = soc_variant; | 995 | mvchip->soc_variant = soc_variant; |
693 | mvchip->chip.label = dev_name(&pdev->dev); | 996 | mvchip->chip.label = dev_name(&pdev->dev); |
@@ -712,8 +1015,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev) | |||
712 | if (IS_ERR(mvchip->membase)) | 1015 | if (IS_ERR(mvchip->membase)) |
713 | return PTR_ERR(mvchip->membase); | 1016 | return PTR_ERR(mvchip->membase); |
714 | 1017 | ||
715 | /* The Armada XP has a second range of registers for the | 1018 | /* |
716 | * per-CPU registers */ | 1019 | * The Armada XP has a second range of registers for the |
1020 | * per-CPU registers | ||
1021 | */ | ||
717 | if (soc_variant == MVEBU_GPIO_SOC_VARIANT_ARMADAXP) { | 1022 | if (soc_variant == MVEBU_GPIO_SOC_VARIANT_ARMADAXP) { |
718 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 1023 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
719 | mvchip->percpu_membase = devm_ioremap_resource(&pdev->dev, | 1024 | mvchip->percpu_membase = devm_ioremap_resource(&pdev->dev, |
@@ -780,7 +1085,8 @@ static int mvebu_gpio_probe(struct platform_device *pdev) | |||
780 | goto err_domain; | 1085 | goto err_domain; |
781 | } | 1086 | } |
782 | 1087 | ||
783 | /* NOTE: The common accessors cannot be used because of the percpu | 1088 | /* |
1089 | * NOTE: The common accessors cannot be used because of the percpu | ||
784 | * access to the mask registers | 1090 | * access to the mask registers |
785 | */ | 1091 | */ |
786 | gc = irq_get_domain_generic_chip(mvchip->domain, 0); | 1092 | gc = irq_get_domain_generic_chip(mvchip->domain, 0); |
@@ -801,7 +1107,8 @@ static int mvebu_gpio_probe(struct platform_device *pdev) | |||
801 | ct->handler = handle_edge_irq; | 1107 | ct->handler = handle_edge_irq; |
802 | ct->chip.name = mvchip->chip.label; | 1108 | ct->chip.name = mvchip->chip.label; |
803 | 1109 | ||
804 | /* Setup the interrupt handlers. Each chip can have up to 4 | 1110 | /* |
1111 | * Setup the interrupt handlers. Each chip can have up to 4 | ||
805 | * interrupt handlers, with each handler dealing with 8 GPIO | 1112 | * interrupt handlers, with each handler dealing with 8 GPIO |
806 | * pins. | 1113 | * pins. |
807 | */ | 1114 | */ |
@@ -814,6 +1121,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev) | |||
814 | mvchip); | 1121 | mvchip); |
815 | } | 1122 | } |
816 | 1123 | ||
1124 | /* Armada 370/XP has simple PWM support for GPIO lines */ | ||
1125 | if (IS_ENABLED(CONFIG_PWM)) | ||
1126 | return mvebu_pwm_probe(pdev, mvchip, id); | ||
1127 | |||
817 | return 0; | 1128 | return 0; |
818 | 1129 | ||
819 | err_domain: | 1130 | err_domain: |
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index c1a1e00b8cb0..3abea3f0b307 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c | |||
@@ -471,7 +471,7 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
471 | if (err) | 471 | if (err) |
472 | goto out_bgio; | 472 | goto out_bgio; |
473 | 473 | ||
474 | irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id()); | 474 | irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0, 32, numa_node_id()); |
475 | if (irq_base < 0) { | 475 | if (irq_base < 0) { |
476 | err = irq_base; | 476 | err = irq_base; |
477 | goto out_bgio; | 477 | goto out_bgio; |
@@ -481,7 +481,7 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
481 | &irq_domain_simple_ops, NULL); | 481 | &irq_domain_simple_ops, NULL); |
482 | if (!port->domain) { | 482 | if (!port->domain) { |
483 | err = -ENODEV; | 483 | err = -ENODEV; |
484 | goto out_irqdesc_free; | 484 | goto out_bgio; |
485 | } | 485 | } |
486 | 486 | ||
487 | /* gpio-mxc can be a generic irq chip */ | 487 | /* gpio-mxc can be a generic irq chip */ |
@@ -495,8 +495,6 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
495 | 495 | ||
496 | out_irqdomain_remove: | 496 | out_irqdomain_remove: |
497 | irq_domain_remove(port->domain); | 497 | irq_domain_remove(port->domain); |
498 | out_irqdesc_free: | ||
499 | irq_free_descs(irq_base, 32); | ||
500 | out_bgio: | 498 | out_bgio: |
501 | dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err); | 499 | dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err); |
502 | return err; | 500 | return err; |
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c index 2292742eac8f..6ae583f36733 100644 --- a/drivers/gpio/gpio-mxs.c +++ b/drivers/gpio/gpio-mxs.c | |||
@@ -328,7 +328,7 @@ static int mxs_gpio_probe(struct platform_device *pdev) | |||
328 | /* clear address has to be used to clear IRQSTAT bits */ | 328 | /* clear address has to be used to clear IRQSTAT bits */ |
329 | writel(~0U, port->base + PINCTRL_IRQSTAT(port) + MXS_CLR); | 329 | writel(~0U, port->base + PINCTRL_IRQSTAT(port) + MXS_CLR); |
330 | 330 | ||
331 | irq_base = irq_alloc_descs(-1, 0, 32, numa_node_id()); | 331 | irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0, 32, numa_node_id()); |
332 | if (irq_base < 0) { | 332 | if (irq_base < 0) { |
333 | err = irq_base; | 333 | err = irq_base; |
334 | goto out_iounmap; | 334 | goto out_iounmap; |
@@ -338,7 +338,7 @@ static int mxs_gpio_probe(struct platform_device *pdev) | |||
338 | &irq_domain_simple_ops, NULL); | 338 | &irq_domain_simple_ops, NULL); |
339 | if (!port->domain) { | 339 | if (!port->domain) { |
340 | err = -ENODEV; | 340 | err = -ENODEV; |
341 | goto out_irqdesc_free; | 341 | goto out_iounmap; |
342 | } | 342 | } |
343 | 343 | ||
344 | /* gpio-mxs can be a generic irq chip */ | 344 | /* gpio-mxs can be a generic irq chip */ |
@@ -370,8 +370,6 @@ static int mxs_gpio_probe(struct platform_device *pdev) | |||
370 | 370 | ||
371 | out_irqdomain_remove: | 371 | out_irqdomain_remove: |
372 | irq_domain_remove(port->domain); | 372 | irq_domain_remove(port->domain); |
373 | out_irqdesc_free: | ||
374 | irq_free_descs(irq_base, 32); | ||
375 | out_iounmap: | 373 | out_iounmap: |
376 | iounmap(port->base); | 374 | iounmap(port->base); |
377 | return err; | 375 | return err; |
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index efc85a279d54..f8c550de6c72 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -208,9 +208,11 @@ static inline void omap_gpio_dbck_disable(struct gpio_bank *bank) | |||
208 | * OMAP's debounce time is in 31us steps | 208 | * OMAP's debounce time is in 31us steps |
209 | * <debounce time> = (GPIO_DEBOUNCINGTIME[7:0].DEBOUNCETIME + 1) x 31 | 209 | * <debounce time> = (GPIO_DEBOUNCINGTIME[7:0].DEBOUNCETIME + 1) x 31 |
210 | * so we need to convert and round up to the closest unit. | 210 | * so we need to convert and round up to the closest unit. |
211 | * | ||
212 | * Return: 0 on success, negative error otherwise. | ||
211 | */ | 213 | */ |
212 | static void omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset, | 214 | static int omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset, |
213 | unsigned debounce) | 215 | unsigned debounce) |
214 | { | 216 | { |
215 | void __iomem *reg; | 217 | void __iomem *reg; |
216 | u32 val; | 218 | u32 val; |
@@ -218,11 +220,12 @@ static void omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset, | |||
218 | bool enable = !!debounce; | 220 | bool enable = !!debounce; |
219 | 221 | ||
220 | if (!bank->dbck_flag) | 222 | if (!bank->dbck_flag) |
221 | return; | 223 | return -ENOTSUPP; |
222 | 224 | ||
223 | if (enable) { | 225 | if (enable) { |
224 | debounce = DIV_ROUND_UP(debounce, 31) - 1; | 226 | debounce = DIV_ROUND_UP(debounce, 31) - 1; |
225 | debounce &= OMAP4_GPIO_DEBOUNCINGTIME_MASK; | 227 | if ((debounce & OMAP4_GPIO_DEBOUNCINGTIME_MASK) != debounce) |
228 | return -EINVAL; | ||
226 | } | 229 | } |
227 | 230 | ||
228 | l = BIT(offset); | 231 | l = BIT(offset); |
@@ -255,6 +258,8 @@ static void omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset, | |||
255 | bank->context.debounce = debounce; | 258 | bank->context.debounce = debounce; |
256 | bank->context.debounce_en = val; | 259 | bank->context.debounce_en = val; |
257 | } | 260 | } |
261 | |||
262 | return 0; | ||
258 | } | 263 | } |
259 | 264 | ||
260 | /** | 265 | /** |
@@ -964,14 +969,20 @@ static int omap_gpio_debounce(struct gpio_chip *chip, unsigned offset, | |||
964 | { | 969 | { |
965 | struct gpio_bank *bank; | 970 | struct gpio_bank *bank; |
966 | unsigned long flags; | 971 | unsigned long flags; |
972 | int ret; | ||
967 | 973 | ||
968 | bank = gpiochip_get_data(chip); | 974 | bank = gpiochip_get_data(chip); |
969 | 975 | ||
970 | raw_spin_lock_irqsave(&bank->lock, flags); | 976 | raw_spin_lock_irqsave(&bank->lock, flags); |
971 | omap2_set_gpio_debounce(bank, offset, debounce); | 977 | ret = omap2_set_gpio_debounce(bank, offset, debounce); |
972 | raw_spin_unlock_irqrestore(&bank->lock, flags); | 978 | raw_spin_unlock_irqrestore(&bank->lock, flags); |
973 | 979 | ||
974 | return 0; | 980 | if (ret) |
981 | dev_info(chip->parent, | ||
982 | "Could not set line %u debounce to %u microseconds (%d)", | ||
983 | offset, debounce, ret); | ||
984 | |||
985 | return ret; | ||
975 | } | 986 | } |
976 | 987 | ||
977 | static int omap_gpio_set_config(struct gpio_chip *chip, unsigned offset, | 988 | static int omap_gpio_set_config(struct gpio_chip *chip, unsigned offset, |
@@ -1085,7 +1096,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1085 | * REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop | 1096 | * REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop |
1086 | * irq_alloc_descs() since a base IRQ offset will no longer be needed. | 1097 | * irq_alloc_descs() since a base IRQ offset will no longer be needed. |
1087 | */ | 1098 | */ |
1088 | irq_base = irq_alloc_descs(-1, 0, bank->width, 0); | 1099 | irq_base = devm_irq_alloc_descs(bank->chip.parent, |
1100 | -1, 0, bank->width, 0); | ||
1089 | if (irq_base < 0) { | 1101 | if (irq_base < 0) { |
1090 | dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n"); | 1102 | dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n"); |
1091 | return -ENODEV; | 1103 | return -ENODEV; |
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index d44232aadb6c..4c9e21300a26 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c | |||
@@ -11,18 +11,19 @@ | |||
11 | * the Free Software Foundation; version 2 of the License. | 11 | * the Free Software Foundation; version 2 of the License. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/module.h> | 14 | #include <linux/acpi.h> |
15 | #include <linux/init.h> | ||
16 | #include <linux/gpio.h> | 15 | #include <linux/gpio.h> |
17 | #include <linux/gpio/consumer.h> | 16 | #include <linux/gpio/consumer.h> |
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/init.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/of_platform.h> | ||
20 | #include <linux/platform_data/pca953x.h> | 22 | #include <linux/platform_data/pca953x.h> |
23 | #include <linux/regulator/consumer.h> | ||
21 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | |||
22 | #include <asm/unaligned.h> | 26 | #include <asm/unaligned.h> |
23 | #include <linux/of_platform.h> | ||
24 | #include <linux/acpi.h> | ||
25 | #include <linux/regulator/consumer.h> | ||
26 | 27 | ||
27 | #define PCA953X_INPUT 0 | 28 | #define PCA953X_INPUT 0 |
28 | #define PCA953X_OUTPUT 1 | 29 | #define PCA953X_OUTPUT 1 |
@@ -81,6 +82,7 @@ static const struct i2c_device_id pca953x_id[] = { | |||
81 | { "tca6416", 16 | PCA953X_TYPE | PCA_INT, }, | 82 | { "tca6416", 16 | PCA953X_TYPE | PCA_INT, }, |
82 | { "tca6424", 24 | PCA953X_TYPE | PCA_INT, }, | 83 | { "tca6424", 24 | PCA953X_TYPE | PCA_INT, }, |
83 | { "tca9539", 16 | PCA953X_TYPE | PCA_INT, }, | 84 | { "tca9539", 16 | PCA953X_TYPE | PCA_INT, }, |
85 | { "tca9554", 8 | PCA953X_TYPE | PCA_INT, }, | ||
84 | { "xra1202", 8 | PCA953X_TYPE }, | 86 | { "xra1202", 8 | PCA953X_TYPE }, |
85 | { } | 87 | { } |
86 | }; | 88 | }; |
@@ -363,6 +365,21 @@ exit: | |||
363 | mutex_unlock(&chip->i2c_lock); | 365 | mutex_unlock(&chip->i2c_lock); |
364 | } | 366 | } |
365 | 367 | ||
368 | static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off) | ||
369 | { | ||
370 | struct pca953x_chip *chip = gpiochip_get_data(gc); | ||
371 | u32 reg_val; | ||
372 | int ret; | ||
373 | |||
374 | mutex_lock(&chip->i2c_lock); | ||
375 | ret = pca953x_read_single(chip, chip->regs->direction, ®_val, off); | ||
376 | mutex_unlock(&chip->i2c_lock); | ||
377 | if (ret < 0) | ||
378 | return ret; | ||
379 | |||
380 | return !!(reg_val & (1u << (off % BANK_SZ))); | ||
381 | } | ||
382 | |||
366 | static void pca953x_gpio_set_multiple(struct gpio_chip *gc, | 383 | static void pca953x_gpio_set_multiple(struct gpio_chip *gc, |
367 | unsigned long *mask, unsigned long *bits) | 384 | unsigned long *mask, unsigned long *bits) |
368 | { | 385 | { |
@@ -408,6 +425,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios) | |||
408 | gc->direction_output = pca953x_gpio_direction_output; | 425 | gc->direction_output = pca953x_gpio_direction_output; |
409 | gc->get = pca953x_gpio_get_value; | 426 | gc->get = pca953x_gpio_get_value; |
410 | gc->set = pca953x_gpio_set_value; | 427 | gc->set = pca953x_gpio_set_value; |
428 | gc->get_direction = pca953x_gpio_get_direction; | ||
411 | gc->set_multiple = pca953x_gpio_set_multiple; | 429 | gc->set_multiple = pca953x_gpio_set_multiple; |
412 | gc->can_sleep = true; | 430 | gc->can_sleep = true; |
413 | 431 | ||
@@ -760,7 +778,13 @@ static int pca953x_probe(struct i2c_client *client, | |||
760 | chip->gpio_start = -1; | 778 | chip->gpio_start = -1; |
761 | irq_base = 0; | 779 | irq_base = 0; |
762 | 780 | ||
763 | /* See if we need to de-assert a reset pin */ | 781 | /* |
782 | * See if we need to de-assert a reset pin. | ||
783 | * | ||
784 | * There is no known ACPI-enabled platforms that are | ||
785 | * using "reset" GPIO. Otherwise any of those platform | ||
786 | * must use _DSD method with corresponding property. | ||
787 | */ | ||
764 | reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", | 788 | reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", |
765 | GPIOD_OUT_LOW); | 789 | GPIOD_OUT_LOW); |
766 | if (IS_ERR(reset_gpio)) | 790 | if (IS_ERR(reset_gpio)) |
diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c index 895af42a4513..8ddf9302ce3b 100644 --- a/drivers/gpio/gpio-pcf857x.c +++ b/drivers/gpio/gpio-pcf857x.c | |||
@@ -46,7 +46,6 @@ static const struct i2c_device_id pcf857x_id[] = { | |||
46 | { "pca9675", 16 }, | 46 | { "pca9675", 16 }, |
47 | { "max7328", 8 }, | 47 | { "max7328", 8 }, |
48 | { "max7329", 8 }, | 48 | { "max7329", 8 }, |
49 | { "tca9554", 8 }, | ||
50 | { } | 49 | { } |
51 | }; | 50 | }; |
52 | MODULE_DEVICE_TABLE(i2c, pcf857x_id); | 51 | MODULE_DEVICE_TABLE(i2c, pcf857x_id); |
@@ -66,7 +65,6 @@ static const struct of_device_id pcf857x_of_table[] = { | |||
66 | { .compatible = "nxp,pca9675" }, | 65 | { .compatible = "nxp,pca9675" }, |
67 | { .compatible = "maxim,max7328" }, | 66 | { .compatible = "maxim,max7328" }, |
68 | { .compatible = "maxim,max7329" }, | 67 | { .compatible = "maxim,max7329" }, |
69 | { .compatible = "ti,tca9554" }, | ||
70 | { } | 68 | { } |
71 | }; | 69 | }; |
72 | MODULE_DEVICE_TABLE(of, pcf857x_of_table); | 70 | MODULE_DEVICE_TABLE(of, pcf857x_of_table); |
diff --git a/drivers/gpio/gpio-pch.c b/drivers/gpio/gpio-pch.c index 7c7135da5d4a..71bc6da11337 100644 --- a/drivers/gpio/gpio-pch.c +++ b/drivers/gpio/gpio-pch.c | |||
@@ -403,7 +403,8 @@ static int pch_gpio_probe(struct pci_dev *pdev, | |||
403 | goto err_gpiochip_add; | 403 | goto err_gpiochip_add; |
404 | } | 404 | } |
405 | 405 | ||
406 | irq_base = irq_alloc_descs(-1, 0, gpio_pins[chip->ioh], NUMA_NO_NODE); | 406 | irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0, |
407 | gpio_pins[chip->ioh], NUMA_NO_NODE); | ||
407 | if (irq_base < 0) { | 408 | if (irq_base < 0) { |
408 | dev_warn(&pdev->dev, "PCH gpio: Failed to get IRQ base num\n"); | 409 | dev_warn(&pdev->dev, "PCH gpio: Failed to get IRQ base num\n"); |
409 | chip->irq_base = -1; | 410 | chip->irq_base = -1; |
@@ -416,8 +417,8 @@ static int pch_gpio_probe(struct pci_dev *pdev, | |||
416 | iowrite32(msk, &chip->reg->imask); | 417 | iowrite32(msk, &chip->reg->imask); |
417 | iowrite32(msk, &chip->reg->ien); | 418 | iowrite32(msk, &chip->reg->ien); |
418 | 419 | ||
419 | ret = request_irq(pdev->irq, pch_gpio_handler, | 420 | ret = devm_request_irq(&pdev->dev, pdev->irq, pch_gpio_handler, |
420 | IRQF_SHARED, KBUILD_MODNAME, chip); | 421 | IRQF_SHARED, KBUILD_MODNAME, chip); |
421 | if (ret != 0) { | 422 | if (ret != 0) { |
422 | dev_err(&pdev->dev, | 423 | dev_err(&pdev->dev, |
423 | "%s request_irq failed\n", __func__); | 424 | "%s request_irq failed\n", __func__); |
@@ -430,7 +431,6 @@ end: | |||
430 | return 0; | 431 | return 0; |
431 | 432 | ||
432 | err_request_irq: | 433 | err_request_irq: |
433 | irq_free_descs(irq_base, gpio_pins[chip->ioh]); | ||
434 | gpiochip_remove(&chip->gpio); | 434 | gpiochip_remove(&chip->gpio); |
435 | 435 | ||
436 | err_gpiochip_add: | 436 | err_gpiochip_add: |
@@ -452,12 +452,6 @@ static void pch_gpio_remove(struct pci_dev *pdev) | |||
452 | { | 452 | { |
453 | struct pch_gpio *chip = pci_get_drvdata(pdev); | 453 | struct pch_gpio *chip = pci_get_drvdata(pdev); |
454 | 454 | ||
455 | if (chip->irq_base != -1) { | ||
456 | free_irq(pdev->irq, chip); | ||
457 | |||
458 | irq_free_descs(chip->irq_base, gpio_pins[chip->ioh]); | ||
459 | } | ||
460 | |||
461 | gpiochip_remove(&chip->gpio); | 455 | gpiochip_remove(&chip->gpio); |
462 | pci_iounmap(pdev, chip->base); | 456 | pci_iounmap(pdev, chip->base); |
463 | pci_release_regions(pdev); | 457 | pci_release_regions(pdev); |
diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c index 269ab628634b..7de4f6a2cb49 100644 --- a/drivers/gpio/gpio-pci-idio-16.c +++ b/drivers/gpio/gpio-pci-idio-16.c | |||
@@ -59,7 +59,7 @@ struct idio_16_gpio_reg { | |||
59 | */ | 59 | */ |
60 | struct idio_16_gpio { | 60 | struct idio_16_gpio { |
61 | struct gpio_chip chip; | 61 | struct gpio_chip chip; |
62 | spinlock_t lock; | 62 | raw_spinlock_t lock; |
63 | struct idio_16_gpio_reg __iomem *reg; | 63 | struct idio_16_gpio_reg __iomem *reg; |
64 | unsigned long irq_mask; | 64 | unsigned long irq_mask; |
65 | }; | 65 | }; |
@@ -121,7 +121,7 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned int offset, | |||
121 | } else | 121 | } else |
122 | base = &idio16gpio->reg->out0_7; | 122 | base = &idio16gpio->reg->out0_7; |
123 | 123 | ||
124 | spin_lock_irqsave(&idio16gpio->lock, flags); | 124 | raw_spin_lock_irqsave(&idio16gpio->lock, flags); |
125 | 125 | ||
126 | if (value) | 126 | if (value) |
127 | out_state = ioread8(base) | mask; | 127 | out_state = ioread8(base) | mask; |
@@ -130,7 +130,7 @@ static void idio_16_gpio_set(struct gpio_chip *chip, unsigned int offset, | |||
130 | 130 | ||
131 | iowrite8(out_state, base); | 131 | iowrite8(out_state, base); |
132 | 132 | ||
133 | spin_unlock_irqrestore(&idio16gpio->lock, flags); | 133 | raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); |
134 | } | 134 | } |
135 | 135 | ||
136 | static void idio_16_gpio_set_multiple(struct gpio_chip *chip, | 136 | static void idio_16_gpio_set_multiple(struct gpio_chip *chip, |
@@ -140,7 +140,7 @@ static void idio_16_gpio_set_multiple(struct gpio_chip *chip, | |||
140 | unsigned long flags; | 140 | unsigned long flags; |
141 | unsigned int out_state; | 141 | unsigned int out_state; |
142 | 142 | ||
143 | spin_lock_irqsave(&idio16gpio->lock, flags); | 143 | raw_spin_lock_irqsave(&idio16gpio->lock, flags); |
144 | 144 | ||
145 | /* process output lines 0-7 */ | 145 | /* process output lines 0-7 */ |
146 | if (*mask & 0xFF) { | 146 | if (*mask & 0xFF) { |
@@ -160,7 +160,7 @@ static void idio_16_gpio_set_multiple(struct gpio_chip *chip, | |||
160 | iowrite8(out_state, &idio16gpio->reg->out8_15); | 160 | iowrite8(out_state, &idio16gpio->reg->out8_15); |
161 | } | 161 | } |
162 | 162 | ||
163 | spin_unlock_irqrestore(&idio16gpio->lock, flags); | 163 | raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); |
164 | } | 164 | } |
165 | 165 | ||
166 | static void idio_16_irq_ack(struct irq_data *data) | 166 | static void idio_16_irq_ack(struct irq_data *data) |
@@ -177,11 +177,11 @@ static void idio_16_irq_mask(struct irq_data *data) | |||
177 | idio16gpio->irq_mask &= ~mask; | 177 | idio16gpio->irq_mask &= ~mask; |
178 | 178 | ||
179 | if (!idio16gpio->irq_mask) { | 179 | if (!idio16gpio->irq_mask) { |
180 | spin_lock_irqsave(&idio16gpio->lock, flags); | 180 | raw_spin_lock_irqsave(&idio16gpio->lock, flags); |
181 | 181 | ||
182 | iowrite8(0, &idio16gpio->reg->irq_ctl); | 182 | iowrite8(0, &idio16gpio->reg->irq_ctl); |
183 | 183 | ||
184 | spin_unlock_irqrestore(&idio16gpio->lock, flags); | 184 | raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
@@ -196,11 +196,11 @@ static void idio_16_irq_unmask(struct irq_data *data) | |||
196 | idio16gpio->irq_mask |= mask; | 196 | idio16gpio->irq_mask |= mask; |
197 | 197 | ||
198 | if (!prev_irq_mask) { | 198 | if (!prev_irq_mask) { |
199 | spin_lock_irqsave(&idio16gpio->lock, flags); | 199 | raw_spin_lock_irqsave(&idio16gpio->lock, flags); |
200 | 200 | ||
201 | ioread8(&idio16gpio->reg->irq_ctl); | 201 | ioread8(&idio16gpio->reg->irq_ctl); |
202 | 202 | ||
203 | spin_unlock_irqrestore(&idio16gpio->lock, flags); | 203 | raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
@@ -229,11 +229,11 @@ static irqreturn_t idio_16_irq_handler(int irq, void *dev_id) | |||
229 | struct gpio_chip *const chip = &idio16gpio->chip; | 229 | struct gpio_chip *const chip = &idio16gpio->chip; |
230 | int gpio; | 230 | int gpio; |
231 | 231 | ||
232 | spin_lock(&idio16gpio->lock); | 232 | raw_spin_lock(&idio16gpio->lock); |
233 | 233 | ||
234 | irq_status = ioread8(&idio16gpio->reg->irq_status); | 234 | irq_status = ioread8(&idio16gpio->reg->irq_status); |
235 | 235 | ||
236 | spin_unlock(&idio16gpio->lock); | 236 | raw_spin_unlock(&idio16gpio->lock); |
237 | 237 | ||
238 | /* Make sure our device generated IRQ */ | 238 | /* Make sure our device generated IRQ */ |
239 | if (!(irq_status & 0x3) || !(irq_status & 0x4)) | 239 | if (!(irq_status & 0x3) || !(irq_status & 0x4)) |
@@ -242,12 +242,12 @@ static irqreturn_t idio_16_irq_handler(int irq, void *dev_id) | |||
242 | for_each_set_bit(gpio, &idio16gpio->irq_mask, chip->ngpio) | 242 | for_each_set_bit(gpio, &idio16gpio->irq_mask, chip->ngpio) |
243 | generic_handle_irq(irq_find_mapping(chip->irqdomain, gpio)); | 243 | generic_handle_irq(irq_find_mapping(chip->irqdomain, gpio)); |
244 | 244 | ||
245 | spin_lock(&idio16gpio->lock); | 245 | raw_spin_lock(&idio16gpio->lock); |
246 | 246 | ||
247 | /* Clear interrupt */ | 247 | /* Clear interrupt */ |
248 | iowrite8(0, &idio16gpio->reg->in0_7); | 248 | iowrite8(0, &idio16gpio->reg->in0_7); |
249 | 249 | ||
250 | spin_unlock(&idio16gpio->lock); | 250 | raw_spin_unlock(&idio16gpio->lock); |
251 | 251 | ||
252 | return IRQ_HANDLED; | 252 | return IRQ_HANDLED; |
253 | } | 253 | } |
@@ -302,7 +302,7 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
302 | idio16gpio->chip.set = idio_16_gpio_set; | 302 | idio16gpio->chip.set = idio_16_gpio_set; |
303 | idio16gpio->chip.set_multiple = idio_16_gpio_set_multiple; | 303 | idio16gpio->chip.set_multiple = idio_16_gpio_set_multiple; |
304 | 304 | ||
305 | spin_lock_init(&idio16gpio->lock); | 305 | raw_spin_lock_init(&idio16gpio->lock); |
306 | 306 | ||
307 | err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio); | 307 | err = devm_gpiochip_add_data(dev, &idio16gpio->chip, idio16gpio); |
308 | if (err) { | 308 | if (err) { |
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 0a6bfd2b06e5..3d3d6b6645a7 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
@@ -50,7 +50,7 @@ struct pl061_context_save_regs { | |||
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | struct pl061 { | 52 | struct pl061 { |
53 | spinlock_t lock; | 53 | raw_spinlock_t lock; |
54 | 54 | ||
55 | void __iomem *base; | 55 | void __iomem *base; |
56 | struct gpio_chip gc; | 56 | struct gpio_chip gc; |
@@ -74,11 +74,11 @@ static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) | |||
74 | unsigned long flags; | 74 | unsigned long flags; |
75 | unsigned char gpiodir; | 75 | unsigned char gpiodir; |
76 | 76 | ||
77 | spin_lock_irqsave(&pl061->lock, flags); | 77 | raw_spin_lock_irqsave(&pl061->lock, flags); |
78 | gpiodir = readb(pl061->base + GPIODIR); | 78 | gpiodir = readb(pl061->base + GPIODIR); |
79 | gpiodir &= ~(BIT(offset)); | 79 | gpiodir &= ~(BIT(offset)); |
80 | writeb(gpiodir, pl061->base + GPIODIR); | 80 | writeb(gpiodir, pl061->base + GPIODIR); |
81 | spin_unlock_irqrestore(&pl061->lock, flags); | 81 | raw_spin_unlock_irqrestore(&pl061->lock, flags); |
82 | 82 | ||
83 | return 0; | 83 | return 0; |
84 | } | 84 | } |
@@ -90,7 +90,7 @@ static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, | |||
90 | unsigned long flags; | 90 | unsigned long flags; |
91 | unsigned char gpiodir; | 91 | unsigned char gpiodir; |
92 | 92 | ||
93 | spin_lock_irqsave(&pl061->lock, flags); | 93 | raw_spin_lock_irqsave(&pl061->lock, flags); |
94 | writeb(!!value << offset, pl061->base + (BIT(offset + 2))); | 94 | writeb(!!value << offset, pl061->base + (BIT(offset + 2))); |
95 | gpiodir = readb(pl061->base + GPIODIR); | 95 | gpiodir = readb(pl061->base + GPIODIR); |
96 | gpiodir |= BIT(offset); | 96 | gpiodir |= BIT(offset); |
@@ -101,7 +101,7 @@ static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, | |||
101 | * a gpio pin before configuring it in OUT mode. | 101 | * a gpio pin before configuring it in OUT mode. |
102 | */ | 102 | */ |
103 | writeb(!!value << offset, pl061->base + (BIT(offset + 2))); | 103 | writeb(!!value << offset, pl061->base + (BIT(offset + 2))); |
104 | spin_unlock_irqrestore(&pl061->lock, flags); | 104 | raw_spin_unlock_irqrestore(&pl061->lock, flags); |
105 | 105 | ||
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
@@ -143,7 +143,7 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger) | |||
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | spin_lock_irqsave(&pl061->lock, flags); | 146 | raw_spin_lock_irqsave(&pl061->lock, flags); |
147 | 147 | ||
148 | gpioiev = readb(pl061->base + GPIOIEV); | 148 | gpioiev = readb(pl061->base + GPIOIEV); |
149 | gpiois = readb(pl061->base + GPIOIS); | 149 | gpiois = readb(pl061->base + GPIOIS); |
@@ -203,7 +203,7 @@ static int pl061_irq_type(struct irq_data *d, unsigned trigger) | |||
203 | writeb(gpioibe, pl061->base + GPIOIBE); | 203 | writeb(gpioibe, pl061->base + GPIOIBE); |
204 | writeb(gpioiev, pl061->base + GPIOIEV); | 204 | writeb(gpioiev, pl061->base + GPIOIEV); |
205 | 205 | ||
206 | spin_unlock_irqrestore(&pl061->lock, flags); | 206 | raw_spin_unlock_irqrestore(&pl061->lock, flags); |
207 | 207 | ||
208 | return 0; | 208 | return 0; |
209 | } | 209 | } |
@@ -235,10 +235,10 @@ static void pl061_irq_mask(struct irq_data *d) | |||
235 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); | 235 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); |
236 | u8 gpioie; | 236 | u8 gpioie; |
237 | 237 | ||
238 | spin_lock(&pl061->lock); | 238 | raw_spin_lock(&pl061->lock); |
239 | gpioie = readb(pl061->base + GPIOIE) & ~mask; | 239 | gpioie = readb(pl061->base + GPIOIE) & ~mask; |
240 | writeb(gpioie, pl061->base + GPIOIE); | 240 | writeb(gpioie, pl061->base + GPIOIE); |
241 | spin_unlock(&pl061->lock); | 241 | raw_spin_unlock(&pl061->lock); |
242 | } | 242 | } |
243 | 243 | ||
244 | static void pl061_irq_unmask(struct irq_data *d) | 244 | static void pl061_irq_unmask(struct irq_data *d) |
@@ -248,10 +248,10 @@ static void pl061_irq_unmask(struct irq_data *d) | |||
248 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); | 248 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); |
249 | u8 gpioie; | 249 | u8 gpioie; |
250 | 250 | ||
251 | spin_lock(&pl061->lock); | 251 | raw_spin_lock(&pl061->lock); |
252 | gpioie = readb(pl061->base + GPIOIE) | mask; | 252 | gpioie = readb(pl061->base + GPIOIE) | mask; |
253 | writeb(gpioie, pl061->base + GPIOIE); | 253 | writeb(gpioie, pl061->base + GPIOIE); |
254 | spin_unlock(&pl061->lock); | 254 | raw_spin_unlock(&pl061->lock); |
255 | } | 255 | } |
256 | 256 | ||
257 | /** | 257 | /** |
@@ -268,9 +268,9 @@ static void pl061_irq_ack(struct irq_data *d) | |||
268 | struct pl061 *pl061 = gpiochip_get_data(gc); | 268 | struct pl061 *pl061 = gpiochip_get_data(gc); |
269 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); | 269 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); |
270 | 270 | ||
271 | spin_lock(&pl061->lock); | 271 | raw_spin_lock(&pl061->lock); |
272 | writeb(mask, pl061->base + GPIOIC); | 272 | writeb(mask, pl061->base + GPIOIC); |
273 | spin_unlock(&pl061->lock); | 273 | raw_spin_unlock(&pl061->lock); |
274 | } | 274 | } |
275 | 275 | ||
276 | static int pl061_irq_set_wake(struct irq_data *d, unsigned int state) | 276 | static int pl061_irq_set_wake(struct irq_data *d, unsigned int state) |
@@ -304,7 +304,7 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | |||
304 | if (IS_ERR(pl061->base)) | 304 | if (IS_ERR(pl061->base)) |
305 | return PTR_ERR(pl061->base); | 305 | return PTR_ERR(pl061->base); |
306 | 306 | ||
307 | spin_lock_init(&pl061->lock); | 307 | raw_spin_lock_init(&pl061->lock); |
308 | if (of_property_read_bool(dev->of_node, "gpio-ranges")) { | 308 | if (of_property_read_bool(dev->of_node, "gpio-ranges")) { |
309 | pl061->gc.request = gpiochip_generic_request; | 309 | pl061->gc.request = gpiochip_generic_request; |
310 | pl061->gc.free = gpiochip_generic_free; | 310 | pl061->gc.free = gpiochip_generic_free; |
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 76ac906b4d78..832f3e46ba9f 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c | |||
@@ -601,7 +601,7 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev, | |||
601 | nr_gpios = gpio_id->gpio_nums; | 601 | nr_gpios = gpio_id->gpio_nums; |
602 | pxa_last_gpio = nr_gpios - 1; | 602 | pxa_last_gpio = nr_gpios - 1; |
603 | 603 | ||
604 | irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0); | 604 | irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0, nr_gpios, 0); |
605 | if (irq_base < 0) { | 605 | if (irq_base < 0) { |
606 | dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); | 606 | dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); |
607 | return irq_base; | 607 | return irq_base; |
diff --git a/drivers/gpio/gpio-reg.c b/drivers/gpio/gpio-reg.c new file mode 100644 index 000000000000..e85903eddc68 --- /dev/null +++ b/drivers/gpio/gpio-reg.c | |||
@@ -0,0 +1,185 @@ | |||
1 | /* | ||
2 | * gpio-reg: single register individually fixed-direction GPIOs | ||
3 | * | ||
4 | * Copyright (C) 2016 Russell King | ||
5 | * | ||
6 | * This software is licensed under the terms of the GNU General Public | ||
7 | * License version 2, as published by the Free Software Foundation, and | ||
8 | * may be copied, distributed, and modified under those terms. | ||
9 | */ | ||
10 | #include <linux/gpio/driver.h> | ||
11 | #include <linux/gpio/gpio-reg.h> | ||
12 | #include <linux/io.h> | ||
13 | #include <linux/slab.h> | ||
14 | #include <linux/spinlock.h> | ||
15 | |||
16 | struct gpio_reg { | ||
17 | struct gpio_chip gc; | ||
18 | spinlock_t lock; | ||
19 | u32 direction; | ||
20 | u32 out; | ||
21 | void __iomem *reg; | ||
22 | struct irq_domain *irqdomain; | ||
23 | const int *irqs; | ||
24 | }; | ||
25 | |||
26 | #define to_gpio_reg(x) container_of(x, struct gpio_reg, gc) | ||
27 | |||
28 | static int gpio_reg_get_direction(struct gpio_chip *gc, unsigned offset) | ||
29 | { | ||
30 | struct gpio_reg *r = to_gpio_reg(gc); | ||
31 | |||
32 | return r->direction & BIT(offset) ? 1 : 0; | ||
33 | } | ||
34 | |||
35 | static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset, | ||
36 | int value) | ||
37 | { | ||
38 | struct gpio_reg *r = to_gpio_reg(gc); | ||
39 | |||
40 | if (r->direction & BIT(offset)) | ||
41 | return -ENOTSUPP; | ||
42 | |||
43 | gc->set(gc, offset, value); | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | static int gpio_reg_direction_input(struct gpio_chip *gc, unsigned offset) | ||
48 | { | ||
49 | struct gpio_reg *r = to_gpio_reg(gc); | ||
50 | |||
51 | return r->direction & BIT(offset) ? 0 : -ENOTSUPP; | ||
52 | } | ||
53 | |||
54 | static void gpio_reg_set(struct gpio_chip *gc, unsigned offset, int value) | ||
55 | { | ||
56 | struct gpio_reg *r = to_gpio_reg(gc); | ||
57 | unsigned long flags; | ||
58 | u32 val, mask = BIT(offset); | ||
59 | |||
60 | spin_lock_irqsave(&r->lock, flags); | ||
61 | val = r->out; | ||
62 | if (value) | ||
63 | val |= mask; | ||
64 | else | ||
65 | val &= ~mask; | ||
66 | r->out = val; | ||
67 | writel_relaxed(val, r->reg); | ||
68 | spin_unlock_irqrestore(&r->lock, flags); | ||
69 | } | ||
70 | |||
71 | static int gpio_reg_get(struct gpio_chip *gc, unsigned offset) | ||
72 | { | ||
73 | struct gpio_reg *r = to_gpio_reg(gc); | ||
74 | u32 val, mask = BIT(offset); | ||
75 | |||
76 | if (r->direction & mask) { | ||
77 | /* | ||
78 | * double-read the value, some registers latch after the | ||
79 | * first read. | ||
80 | */ | ||
81 | readl_relaxed(r->reg); | ||
82 | val = readl_relaxed(r->reg); | ||
83 | } else { | ||
84 | val = r->out; | ||
85 | } | ||
86 | return !!(val & mask); | ||
87 | } | ||
88 | |||
89 | static void gpio_reg_set_multiple(struct gpio_chip *gc, unsigned long *mask, | ||
90 | unsigned long *bits) | ||
91 | { | ||
92 | struct gpio_reg *r = to_gpio_reg(gc); | ||
93 | unsigned long flags; | ||
94 | |||
95 | spin_lock_irqsave(&r->lock, flags); | ||
96 | r->out = (r->out & ~*mask) | (*bits & *mask); | ||
97 | writel_relaxed(r->out, r->reg); | ||
98 | spin_unlock_irqrestore(&r->lock, flags); | ||
99 | } | ||
100 | |||
101 | static int gpio_reg_to_irq(struct gpio_chip *gc, unsigned offset) | ||
102 | { | ||
103 | struct gpio_reg *r = to_gpio_reg(gc); | ||
104 | int irq = r->irqs[offset]; | ||
105 | |||
106 | if (irq >= 0 && r->irqdomain) | ||
107 | irq = irq_find_mapping(r->irqdomain, irq); | ||
108 | |||
109 | return irq; | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * gpio_reg_init - add a fixed in/out register as gpio | ||
114 | * @dev: optional struct device associated with this register | ||
115 | * @base: start gpio number, or -1 to allocate | ||
116 | * @num: number of GPIOs, maximum 32 | ||
117 | * @label: GPIO chip label | ||
118 | * @direction: bitmask of fixed direction, one per GPIO signal, 1 = in | ||
119 | * @def_out: initial GPIO output value | ||
120 | * @names: array of %num strings describing each GPIO signal or %NULL | ||
121 | * @irqdom: irq domain or %NULL | ||
122 | * @irqs: array of %num ints describing the interrupt mapping for each | ||
123 | * GPIO signal, or %NULL. If @irqdom is %NULL, then this | ||
124 | * describes the Linux interrupt number, otherwise it describes | ||
125 | * the hardware interrupt number in the specified irq domain. | ||
126 | * | ||
127 | * Add a single-register GPIO device containing up to 32 GPIO signals, | ||
128 | * where each GPIO has a fixed input or output configuration. Only | ||
129 | * input GPIOs are assumed to be readable from the register, and only | ||
130 | * then after a double-read. Output values are assumed not to be | ||
131 | * readable. | ||
132 | */ | ||
133 | struct gpio_chip *gpio_reg_init(struct device *dev, void __iomem *reg, | ||
134 | int base, int num, const char *label, u32 direction, u32 def_out, | ||
135 | const char *const *names, struct irq_domain *irqdom, const int *irqs) | ||
136 | { | ||
137 | struct gpio_reg *r; | ||
138 | int ret; | ||
139 | |||
140 | if (dev) | ||
141 | r = devm_kzalloc(dev, sizeof(*r), GFP_KERNEL); | ||
142 | else | ||
143 | r = kzalloc(sizeof(*r), GFP_KERNEL); | ||
144 | |||
145 | if (!r) | ||
146 | return ERR_PTR(-ENOMEM); | ||
147 | |||
148 | spin_lock_init(&r->lock); | ||
149 | |||
150 | r->gc.label = label; | ||
151 | r->gc.get_direction = gpio_reg_get_direction; | ||
152 | r->gc.direction_input = gpio_reg_direction_input; | ||
153 | r->gc.direction_output = gpio_reg_direction_output; | ||
154 | r->gc.set = gpio_reg_set; | ||
155 | r->gc.get = gpio_reg_get; | ||
156 | r->gc.set_multiple = gpio_reg_set_multiple; | ||
157 | if (irqs) | ||
158 | r->gc.to_irq = gpio_reg_to_irq; | ||
159 | r->gc.base = base; | ||
160 | r->gc.ngpio = num; | ||
161 | r->gc.names = names; | ||
162 | r->direction = direction; | ||
163 | r->out = def_out; | ||
164 | r->reg = reg; | ||
165 | r->irqs = irqs; | ||
166 | |||
167 | if (dev) | ||
168 | ret = devm_gpiochip_add_data(dev, &r->gc, r); | ||
169 | else | ||
170 | ret = gpiochip_add_data(&r->gc, r); | ||
171 | |||
172 | return ret ? ERR_PTR(ret) : &r->gc; | ||
173 | } | ||
174 | |||
175 | int gpio_reg_resume(struct gpio_chip *gc) | ||
176 | { | ||
177 | struct gpio_reg *r = to_gpio_reg(gc); | ||
178 | unsigned long flags; | ||
179 | |||
180 | spin_lock_irqsave(&r->lock, flags); | ||
181 | writel_relaxed(r->out, r->reg); | ||
182 | spin_unlock_irqrestore(&r->lock, flags); | ||
183 | |||
184 | return 0; | ||
185 | } | ||
diff --git a/drivers/gpio/gpio-sa1100.c b/drivers/gpio/gpio-sa1100.c index 8d8ee0ebf14c..249f433aa62d 100644 --- a/drivers/gpio/gpio-sa1100.c +++ b/drivers/gpio/gpio-sa1100.c | |||
@@ -12,57 +12,97 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
14 | #include <linux/syscore_ops.h> | 14 | #include <linux/syscore_ops.h> |
15 | #include <soc/sa1100/pwer.h> | ||
15 | #include <mach/hardware.h> | 16 | #include <mach/hardware.h> |
16 | #include <mach/irqs.h> | 17 | #include <mach/irqs.h> |
17 | 18 | ||
19 | struct sa1100_gpio_chip { | ||
20 | struct gpio_chip chip; | ||
21 | void __iomem *membase; | ||
22 | int irqbase; | ||
23 | u32 irqmask; | ||
24 | u32 irqrising; | ||
25 | u32 irqfalling; | ||
26 | u32 irqwake; | ||
27 | }; | ||
28 | |||
29 | #define sa1100_gpio_chip(x) container_of(x, struct sa1100_gpio_chip, chip) | ||
30 | |||
31 | enum { | ||
32 | R_GPLR = 0x00, | ||
33 | R_GPDR = 0x04, | ||
34 | R_GPSR = 0x08, | ||
35 | R_GPCR = 0x0c, | ||
36 | R_GRER = 0x10, | ||
37 | R_GFER = 0x14, | ||
38 | R_GEDR = 0x18, | ||
39 | R_GAFR = 0x1c, | ||
40 | }; | ||
41 | |||
18 | static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset) | 42 | static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset) |
19 | { | 43 | { |
20 | return !!(GPLR & GPIO_GPIO(offset)); | 44 | return readl_relaxed(sa1100_gpio_chip(chip)->membase + R_GPLR) & |
45 | BIT(offset); | ||
21 | } | 46 | } |
22 | 47 | ||
23 | static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | 48 | static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) |
24 | { | 49 | { |
25 | if (value) | 50 | int reg = value ? R_GPSR : R_GPCR; |
26 | GPSR = GPIO_GPIO(offset); | 51 | |
27 | else | 52 | writel_relaxed(BIT(offset), sa1100_gpio_chip(chip)->membase + reg); |
28 | GPCR = GPIO_GPIO(offset); | 53 | } |
54 | |||
55 | static int sa1100_get_direction(struct gpio_chip *chip, unsigned offset) | ||
56 | { | ||
57 | void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR; | ||
58 | |||
59 | return !(readl_relaxed(gpdr) & BIT(offset)); | ||
29 | } | 60 | } |
30 | 61 | ||
31 | static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset) | 62 | static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset) |
32 | { | 63 | { |
64 | void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR; | ||
33 | unsigned long flags; | 65 | unsigned long flags; |
34 | 66 | ||
35 | local_irq_save(flags); | 67 | local_irq_save(flags); |
36 | GPDR &= ~GPIO_GPIO(offset); | 68 | writel_relaxed(readl_relaxed(gpdr) & ~BIT(offset), gpdr); |
37 | local_irq_restore(flags); | 69 | local_irq_restore(flags); |
70 | |||
38 | return 0; | 71 | return 0; |
39 | } | 72 | } |
40 | 73 | ||
41 | static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value) | 74 | static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value) |
42 | { | 75 | { |
76 | void __iomem *gpdr = sa1100_gpio_chip(chip)->membase + R_GPDR; | ||
43 | unsigned long flags; | 77 | unsigned long flags; |
44 | 78 | ||
45 | local_irq_save(flags); | 79 | local_irq_save(flags); |
46 | sa1100_gpio_set(chip, offset, value); | 80 | sa1100_gpio_set(chip, offset, value); |
47 | GPDR |= GPIO_GPIO(offset); | 81 | writel_relaxed(readl_relaxed(gpdr) | BIT(offset), gpdr); |
48 | local_irq_restore(flags); | 82 | local_irq_restore(flags); |
83 | |||
49 | return 0; | 84 | return 0; |
50 | } | 85 | } |
51 | 86 | ||
52 | static int sa1100_to_irq(struct gpio_chip *chip, unsigned offset) | 87 | static int sa1100_to_irq(struct gpio_chip *chip, unsigned offset) |
53 | { | 88 | { |
54 | return IRQ_GPIO0 + offset; | 89 | return sa1100_gpio_chip(chip)->irqbase + offset; |
55 | } | 90 | } |
56 | 91 | ||
57 | static struct gpio_chip sa1100_gpio_chip = { | 92 | static struct sa1100_gpio_chip sa1100_gpio_chip = { |
58 | .label = "gpio", | 93 | .chip = { |
59 | .direction_input = sa1100_direction_input, | 94 | .label = "gpio", |
60 | .direction_output = sa1100_direction_output, | 95 | .get_direction = sa1100_get_direction, |
61 | .set = sa1100_gpio_set, | 96 | .direction_input = sa1100_direction_input, |
62 | .get = sa1100_gpio_get, | 97 | .direction_output = sa1100_direction_output, |
63 | .to_irq = sa1100_to_irq, | 98 | .set = sa1100_gpio_set, |
64 | .base = 0, | 99 | .get = sa1100_gpio_get, |
65 | .ngpio = GPIO_MAX + 1, | 100 | .to_irq = sa1100_to_irq, |
101 | .base = 0, | ||
102 | .ngpio = GPIO_MAX + 1, | ||
103 | }, | ||
104 | .membase = (void *)&GPLR, | ||
105 | .irqbase = IRQ_GPIO0, | ||
66 | }; | 106 | }; |
67 | 107 | ||
68 | /* | 108 | /* |
@@ -70,33 +110,39 @@ static struct gpio_chip sa1100_gpio_chip = { | |||
70 | * IRQs are generated on Falling-Edge, Rising-Edge, or both. | 110 | * IRQs are generated on Falling-Edge, Rising-Edge, or both. |
71 | * Use this instead of directly setting GRER/GFER. | 111 | * Use this instead of directly setting GRER/GFER. |
72 | */ | 112 | */ |
73 | static int GPIO_IRQ_rising_edge; | 113 | static void sa1100_update_edge_regs(struct sa1100_gpio_chip *sgc) |
74 | static int GPIO_IRQ_falling_edge; | 114 | { |
75 | static int GPIO_IRQ_mask; | 115 | void *base = sgc->membase; |
116 | u32 grer, gfer; | ||
117 | |||
118 | grer = sgc->irqrising & sgc->irqmask; | ||
119 | gfer = sgc->irqfalling & sgc->irqmask; | ||
120 | |||
121 | writel_relaxed(grer, base + R_GRER); | ||
122 | writel_relaxed(gfer, base + R_GFER); | ||
123 | } | ||
76 | 124 | ||
77 | static int sa1100_gpio_type(struct irq_data *d, unsigned int type) | 125 | static int sa1100_gpio_type(struct irq_data *d, unsigned int type) |
78 | { | 126 | { |
79 | unsigned int mask; | 127 | struct sa1100_gpio_chip *sgc = irq_data_get_irq_chip_data(d); |
80 | 128 | unsigned int mask = BIT(d->hwirq); | |
81 | mask = BIT(d->hwirq); | ||
82 | 129 | ||
83 | if (type == IRQ_TYPE_PROBE) { | 130 | if (type == IRQ_TYPE_PROBE) { |
84 | if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask) | 131 | if ((sgc->irqrising | sgc->irqfalling) & mask) |
85 | return 0; | 132 | return 0; |
86 | type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; | 133 | type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; |
87 | } | 134 | } |
88 | 135 | ||
89 | if (type & IRQ_TYPE_EDGE_RISING) | 136 | if (type & IRQ_TYPE_EDGE_RISING) |
90 | GPIO_IRQ_rising_edge |= mask; | 137 | sgc->irqrising |= mask; |
91 | else | 138 | else |
92 | GPIO_IRQ_rising_edge &= ~mask; | 139 | sgc->irqrising &= ~mask; |
93 | if (type & IRQ_TYPE_EDGE_FALLING) | 140 | if (type & IRQ_TYPE_EDGE_FALLING) |
94 | GPIO_IRQ_falling_edge |= mask; | 141 | sgc->irqfalling |= mask; |
95 | else | 142 | else |
96 | GPIO_IRQ_falling_edge &= ~mask; | 143 | sgc->irqfalling &= ~mask; |
97 | 144 | ||
98 | GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask; | 145 | sa1100_update_edge_regs(sgc); |
99 | GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask; | ||
100 | 146 | ||
101 | return 0; | 147 | return 0; |
102 | } | 148 | } |
@@ -106,36 +152,42 @@ static int sa1100_gpio_type(struct irq_data *d, unsigned int type) | |||
106 | */ | 152 | */ |
107 | static void sa1100_gpio_ack(struct irq_data *d) | 153 | static void sa1100_gpio_ack(struct irq_data *d) |
108 | { | 154 | { |
109 | GEDR = BIT(d->hwirq); | 155 | struct sa1100_gpio_chip *sgc = irq_data_get_irq_chip_data(d); |
156 | |||
157 | writel_relaxed(BIT(d->hwirq), sgc->membase + R_GEDR); | ||
110 | } | 158 | } |
111 | 159 | ||
112 | static void sa1100_gpio_mask(struct irq_data *d) | 160 | static void sa1100_gpio_mask(struct irq_data *d) |
113 | { | 161 | { |
162 | struct sa1100_gpio_chip *sgc = irq_data_get_irq_chip_data(d); | ||
114 | unsigned int mask = BIT(d->hwirq); | 163 | unsigned int mask = BIT(d->hwirq); |
115 | 164 | ||
116 | GPIO_IRQ_mask &= ~mask; | 165 | sgc->irqmask &= ~mask; |
117 | 166 | ||
118 | GRER &= ~mask; | 167 | sa1100_update_edge_regs(sgc); |
119 | GFER &= ~mask; | ||
120 | } | 168 | } |
121 | 169 | ||
122 | static void sa1100_gpio_unmask(struct irq_data *d) | 170 | static void sa1100_gpio_unmask(struct irq_data *d) |
123 | { | 171 | { |
172 | struct sa1100_gpio_chip *sgc = irq_data_get_irq_chip_data(d); | ||
124 | unsigned int mask = BIT(d->hwirq); | 173 | unsigned int mask = BIT(d->hwirq); |
125 | 174 | ||
126 | GPIO_IRQ_mask |= mask; | 175 | sgc->irqmask |= mask; |
127 | 176 | ||
128 | GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask; | 177 | sa1100_update_edge_regs(sgc); |
129 | GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask; | ||
130 | } | 178 | } |
131 | 179 | ||
132 | static int sa1100_gpio_wake(struct irq_data *d, unsigned int on) | 180 | static int sa1100_gpio_wake(struct irq_data *d, unsigned int on) |
133 | { | 181 | { |
134 | if (on) | 182 | struct sa1100_gpio_chip *sgc = irq_data_get_irq_chip_data(d); |
135 | PWER |= BIT(d->hwirq); | 183 | int ret = sa11x0_gpio_set_wake(d->hwirq, on); |
136 | else | 184 | if (!ret) { |
137 | PWER &= ~BIT(d->hwirq); | 185 | if (on) |
138 | return 0; | 186 | sgc->irqwake |= BIT(d->hwirq); |
187 | else | ||
188 | sgc->irqwake &= ~BIT(d->hwirq); | ||
189 | } | ||
190 | return ret; | ||
139 | } | 191 | } |
140 | 192 | ||
141 | /* | 193 | /* |
@@ -153,8 +205,10 @@ static struct irq_chip sa1100_gpio_irq_chip = { | |||
153 | static int sa1100_gpio_irqdomain_map(struct irq_domain *d, | 205 | static int sa1100_gpio_irqdomain_map(struct irq_domain *d, |
154 | unsigned int irq, irq_hw_number_t hwirq) | 206 | unsigned int irq, irq_hw_number_t hwirq) |
155 | { | 207 | { |
156 | irq_set_chip_and_handler(irq, &sa1100_gpio_irq_chip, | 208 | struct sa1100_gpio_chip *sgc = d->host_data; |
157 | handle_edge_irq); | 209 | |
210 | irq_set_chip_data(irq, sgc); | ||
211 | irq_set_chip_and_handler(irq, &sa1100_gpio_irq_chip, handle_edge_irq); | ||
158 | irq_set_probe(irq); | 212 | irq_set_probe(irq); |
159 | 213 | ||
160 | return 0; | 214 | return 0; |
@@ -174,17 +228,19 @@ static struct irq_domain *sa1100_gpio_irqdomain; | |||
174 | */ | 228 | */ |
175 | static void sa1100_gpio_handler(struct irq_desc *desc) | 229 | static void sa1100_gpio_handler(struct irq_desc *desc) |
176 | { | 230 | { |
231 | struct sa1100_gpio_chip *sgc = irq_desc_get_handler_data(desc); | ||
177 | unsigned int irq, mask; | 232 | unsigned int irq, mask; |
233 | void __iomem *gedr = sgc->membase + R_GEDR; | ||
178 | 234 | ||
179 | mask = GEDR; | 235 | mask = readl_relaxed(gedr); |
180 | do { | 236 | do { |
181 | /* | 237 | /* |
182 | * clear down all currently active IRQ sources. | 238 | * clear down all currently active IRQ sources. |
183 | * We will be processing them all. | 239 | * We will be processing them all. |
184 | */ | 240 | */ |
185 | GEDR = mask; | 241 | writel_relaxed(mask, gedr); |
186 | 242 | ||
187 | irq = IRQ_GPIO0; | 243 | irq = sgc->irqbase; |
188 | do { | 244 | do { |
189 | if (mask & 1) | 245 | if (mask & 1) |
190 | generic_handle_irq(irq); | 246 | generic_handle_irq(irq); |
@@ -192,30 +248,32 @@ static void sa1100_gpio_handler(struct irq_desc *desc) | |||
192 | irq++; | 248 | irq++; |
193 | } while (mask); | 249 | } while (mask); |
194 | 250 | ||
195 | mask = GEDR; | 251 | mask = readl_relaxed(gedr); |
196 | } while (mask); | 252 | } while (mask); |
197 | } | 253 | } |
198 | 254 | ||
199 | static int sa1100_gpio_suspend(void) | 255 | static int sa1100_gpio_suspend(void) |
200 | { | 256 | { |
257 | struct sa1100_gpio_chip *sgc = &sa1100_gpio_chip; | ||
258 | |||
201 | /* | 259 | /* |
202 | * Set the appropriate edges for wakeup. | 260 | * Set the appropriate edges for wakeup. |
203 | */ | 261 | */ |
204 | GRER = PWER & GPIO_IRQ_rising_edge; | 262 | writel_relaxed(sgc->irqwake & sgc->irqrising, sgc->membase + R_GRER); |
205 | GFER = PWER & GPIO_IRQ_falling_edge; | 263 | writel_relaxed(sgc->irqwake & sgc->irqfalling, sgc->membase + R_GFER); |
206 | 264 | ||
207 | /* | 265 | /* |
208 | * Clear any pending GPIO interrupts. | 266 | * Clear any pending GPIO interrupts. |
209 | */ | 267 | */ |
210 | GEDR = GEDR; | 268 | writel_relaxed(readl_relaxed(sgc->membase + R_GEDR), |
269 | sgc->membase + R_GEDR); | ||
211 | 270 | ||
212 | return 0; | 271 | return 0; |
213 | } | 272 | } |
214 | 273 | ||
215 | static void sa1100_gpio_resume(void) | 274 | static void sa1100_gpio_resume(void) |
216 | { | 275 | { |
217 | GRER = GPIO_IRQ_rising_edge & GPIO_IRQ_mask; | 276 | sa1100_update_edge_regs(&sa1100_gpio_chip); |
218 | GFER = GPIO_IRQ_falling_edge & GPIO_IRQ_mask; | ||
219 | } | 277 | } |
220 | 278 | ||
221 | static struct syscore_ops sa1100_gpio_syscore_ops = { | 279 | static struct syscore_ops sa1100_gpio_syscore_ops = { |
@@ -231,36 +289,40 @@ static int __init sa1100_gpio_init_devicefs(void) | |||
231 | 289 | ||
232 | device_initcall(sa1100_gpio_init_devicefs); | 290 | device_initcall(sa1100_gpio_init_devicefs); |
233 | 291 | ||
292 | static const int sa1100_gpio_irqs[] __initconst = { | ||
293 | /* Install handlers for GPIO 0-10 edge detect interrupts */ | ||
294 | IRQ_GPIO0_SC, | ||
295 | IRQ_GPIO1_SC, | ||
296 | IRQ_GPIO2_SC, | ||
297 | IRQ_GPIO3_SC, | ||
298 | IRQ_GPIO4_SC, | ||
299 | IRQ_GPIO5_SC, | ||
300 | IRQ_GPIO6_SC, | ||
301 | IRQ_GPIO7_SC, | ||
302 | IRQ_GPIO8_SC, | ||
303 | IRQ_GPIO9_SC, | ||
304 | IRQ_GPIO10_SC, | ||
305 | /* Install handler for GPIO 11-27 edge detect interrupts */ | ||
306 | IRQ_GPIO11_27, | ||
307 | }; | ||
308 | |||
234 | void __init sa1100_init_gpio(void) | 309 | void __init sa1100_init_gpio(void) |
235 | { | 310 | { |
311 | struct sa1100_gpio_chip *sgc = &sa1100_gpio_chip; | ||
312 | int i; | ||
313 | |||
236 | /* clear all GPIO edge detects */ | 314 | /* clear all GPIO edge detects */ |
237 | GFER = 0; | 315 | writel_relaxed(0, sgc->membase + R_GFER); |
238 | GRER = 0; | 316 | writel_relaxed(0, sgc->membase + R_GRER); |
239 | GEDR = -1; | 317 | writel_relaxed(-1, sgc->membase + R_GEDR); |
240 | 318 | ||
241 | gpiochip_add_data(&sa1100_gpio_chip, NULL); | 319 | gpiochip_add_data(&sa1100_gpio_chip.chip, NULL); |
242 | 320 | ||
243 | sa1100_gpio_irqdomain = irq_domain_add_simple(NULL, | 321 | sa1100_gpio_irqdomain = irq_domain_add_simple(NULL, |
244 | 28, IRQ_GPIO0, | 322 | 28, IRQ_GPIO0, |
245 | &sa1100_gpio_irqdomain_ops, NULL); | 323 | &sa1100_gpio_irqdomain_ops, sgc); |
246 | |||
247 | /* | ||
248 | * Install handlers for GPIO 0-10 edge detect interrupts | ||
249 | */ | ||
250 | irq_set_chained_handler(IRQ_GPIO0_SC, sa1100_gpio_handler); | ||
251 | irq_set_chained_handler(IRQ_GPIO1_SC, sa1100_gpio_handler); | ||
252 | irq_set_chained_handler(IRQ_GPIO2_SC, sa1100_gpio_handler); | ||
253 | irq_set_chained_handler(IRQ_GPIO3_SC, sa1100_gpio_handler); | ||
254 | irq_set_chained_handler(IRQ_GPIO4_SC, sa1100_gpio_handler); | ||
255 | irq_set_chained_handler(IRQ_GPIO5_SC, sa1100_gpio_handler); | ||
256 | irq_set_chained_handler(IRQ_GPIO6_SC, sa1100_gpio_handler); | ||
257 | irq_set_chained_handler(IRQ_GPIO7_SC, sa1100_gpio_handler); | ||
258 | irq_set_chained_handler(IRQ_GPIO8_SC, sa1100_gpio_handler); | ||
259 | irq_set_chained_handler(IRQ_GPIO9_SC, sa1100_gpio_handler); | ||
260 | irq_set_chained_handler(IRQ_GPIO10_SC, sa1100_gpio_handler); | ||
261 | /* | ||
262 | * Install handler for GPIO 11-27 edge detect interrupts | ||
263 | */ | ||
264 | irq_set_chained_handler(IRQ_GPIO11_27, sa1100_gpio_handler); | ||
265 | 324 | ||
325 | for (i = 0; i < ARRAY_SIZE(sa1100_gpio_irqs); i++) | ||
326 | irq_set_chained_handler_and_data(sa1100_gpio_irqs[i], | ||
327 | sa1100_gpio_handler, sgc); | ||
266 | } | 328 | } |
diff --git a/drivers/gpio/gpio-sodaville.c b/drivers/gpio/gpio-sodaville.c index 7da9e6c4546a..f60da83349ef 100644 --- a/drivers/gpio/gpio-sodaville.c +++ b/drivers/gpio/gpio-sodaville.c | |||
@@ -135,7 +135,8 @@ static int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd, | |||
135 | struct irq_chip_type *ct; | 135 | struct irq_chip_type *ct; |
136 | int ret; | 136 | int ret; |
137 | 137 | ||
138 | sd->irq_base = irq_alloc_descs(-1, 0, SDV_NUM_PUB_GPIOS, -1); | 138 | sd->irq_base = devm_irq_alloc_descs(&pdev->dev, -1, 0, |
139 | SDV_NUM_PUB_GPIOS, -1); | ||
139 | if (sd->irq_base < 0) | 140 | if (sd->irq_base < 0) |
140 | return sd->irq_base; | 141 | return sd->irq_base; |
141 | 142 | ||
@@ -143,10 +144,11 @@ static int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd, | |||
143 | writel(0, sd->gpio_pub_base + GPIO_INT); | 144 | writel(0, sd->gpio_pub_base + GPIO_INT); |
144 | writel((1 << 11) - 1, sd->gpio_pub_base + GPSTR); | 145 | writel((1 << 11) - 1, sd->gpio_pub_base + GPSTR); |
145 | 146 | ||
146 | ret = request_irq(pdev->irq, sdv_gpio_pub_irq_handler, IRQF_SHARED, | 147 | ret = devm_request_irq(&pdev->dev, pdev->irq, |
147 | "sdv_gpio", sd); | 148 | sdv_gpio_pub_irq_handler, IRQF_SHARED, |
149 | "sdv_gpio", sd); | ||
148 | if (ret) | 150 | if (ret) |
149 | goto out_free_desc; | 151 | return ret; |
150 | 152 | ||
151 | /* | 153 | /* |
152 | * This gpio irq controller latches level irqs. Testing shows that if | 154 | * This gpio irq controller latches level irqs. Testing shows that if |
@@ -155,10 +157,8 @@ static int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd, | |||
155 | */ | 157 | */ |
156 | sd->gc = irq_alloc_generic_chip("sdv-gpio", 1, sd->irq_base, | 158 | sd->gc = irq_alloc_generic_chip("sdv-gpio", 1, sd->irq_base, |
157 | sd->gpio_pub_base, handle_fasteoi_irq); | 159 | sd->gpio_pub_base, handle_fasteoi_irq); |
158 | if (!sd->gc) { | 160 | if (!sd->gc) |
159 | ret = -ENOMEM; | 161 | return -ENOMEM; |
160 | goto out_free_irq; | ||
161 | } | ||
162 | 162 | ||
163 | sd->gc->private = sd; | 163 | sd->gc->private = sd; |
164 | ct = sd->gc->chip_types; | 164 | ct = sd->gc->chip_types; |
@@ -176,16 +176,10 @@ static int sdv_register_irqsupport(struct sdv_gpio_chip_data *sd, | |||
176 | 176 | ||
177 | sd->id = irq_domain_add_legacy(pdev->dev.of_node, SDV_NUM_PUB_GPIOS, | 177 | sd->id = irq_domain_add_legacy(pdev->dev.of_node, SDV_NUM_PUB_GPIOS, |
178 | sd->irq_base, 0, &irq_domain_sdv_ops, sd); | 178 | sd->irq_base, 0, &irq_domain_sdv_ops, sd); |
179 | if (!sd->id) { | 179 | if (!sd->id) |
180 | ret = -ENODEV; | 180 | return -ENODEV; |
181 | goto out_free_irq; | 181 | |
182 | } | ||
183 | return 0; | 182 | return 0; |
184 | out_free_irq: | ||
185 | free_irq(pdev->irq, sd); | ||
186 | out_free_desc: | ||
187 | irq_free_descs(sd->irq_base, SDV_NUM_PUB_GPIOS); | ||
188 | return ret; | ||
189 | } | 183 | } |
190 | 184 | ||
191 | static int sdv_gpio_probe(struct pci_dev *pdev, | 185 | static int sdv_gpio_probe(struct pci_dev *pdev, |
diff --git a/drivers/gpio/gpio-sta2x11.c b/drivers/gpio/gpio-sta2x11.c index 853ca23cad88..39df0620fa38 100644 --- a/drivers/gpio/gpio-sta2x11.c +++ b/drivers/gpio/gpio-sta2x11.c | |||
@@ -392,7 +392,8 @@ static int gsta_probe(struct platform_device *dev) | |||
392 | gsta_set_config(chip, i, gpio_pdata->pinconfig[i]); | 392 | gsta_set_config(chip, i, gpio_pdata->pinconfig[i]); |
393 | 393 | ||
394 | /* 384 was used in previous code: be compatible for other drivers */ | 394 | /* 384 was used in previous code: be compatible for other drivers */ |
395 | err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE); | 395 | err = devm_irq_alloc_descs(&dev->dev, -1, 384, |
396 | GSTA_NR_GPIO, NUMA_NO_NODE); | ||
396 | if (err < 0) { | 397 | if (err < 0) { |
397 | dev_warn(&dev->dev, "sta2x11 gpio: Can't get irq base (%i)\n", | 398 | dev_warn(&dev->dev, "sta2x11 gpio: Can't get irq base (%i)\n", |
398 | -err); | 399 | -err); |
@@ -401,29 +402,23 @@ static int gsta_probe(struct platform_device *dev) | |||
401 | chip->irq_base = err; | 402 | chip->irq_base = err; |
402 | gsta_alloc_irq_chip(chip); | 403 | gsta_alloc_irq_chip(chip); |
403 | 404 | ||
404 | err = request_irq(pdev->irq, gsta_gpio_handler, | 405 | err = devm_request_irq(&dev->dev, pdev->irq, gsta_gpio_handler, |
405 | IRQF_SHARED, KBUILD_MODNAME, chip); | 406 | IRQF_SHARED, KBUILD_MODNAME, chip); |
406 | if (err < 0) { | 407 | if (err < 0) { |
407 | dev_err(&dev->dev, "sta2x11 gpio: Can't request irq (%i)\n", | 408 | dev_err(&dev->dev, "sta2x11 gpio: Can't request irq (%i)\n", |
408 | -err); | 409 | -err); |
409 | goto err_free_descs; | 410 | return err; |
410 | } | 411 | } |
411 | 412 | ||
412 | err = devm_gpiochip_add_data(&dev->dev, &chip->gpio, chip); | 413 | err = devm_gpiochip_add_data(&dev->dev, &chip->gpio, chip); |
413 | if (err < 0) { | 414 | if (err < 0) { |
414 | dev_err(&dev->dev, "sta2x11 gpio: Can't register (%i)\n", | 415 | dev_err(&dev->dev, "sta2x11 gpio: Can't register (%i)\n", |
415 | -err); | 416 | -err); |
416 | goto err_free_irq; | 417 | return err; |
417 | } | 418 | } |
418 | 419 | ||
419 | platform_set_drvdata(dev, chip); | 420 | platform_set_drvdata(dev, chip); |
420 | return 0; | 421 | return 0; |
421 | |||
422 | err_free_irq: | ||
423 | free_irq(pdev->irq, chip); | ||
424 | err_free_descs: | ||
425 | irq_free_descs(chip->irq_base, GSTA_NR_GPIO); | ||
426 | return err; | ||
427 | } | 422 | } |
428 | 423 | ||
429 | static struct platform_driver sta2x11_gpio_platform_driver = { | 424 | static struct platform_driver sta2x11_gpio_platform_driver = { |
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c index dfcfbba74416..24f388ed46d4 100644 --- a/drivers/gpio/gpio-twl4030.c +++ b/drivers/gpio/gpio-twl4030.c | |||
@@ -485,7 +485,8 @@ static int gpio_twl4030_probe(struct platform_device *pdev) | |||
485 | goto no_irqs; | 485 | goto no_irqs; |
486 | } | 486 | } |
487 | 487 | ||
488 | irq_base = irq_alloc_descs(-1, 0, TWL4030_GPIO_MAX, 0); | 488 | irq_base = devm_irq_alloc_descs(&pdev->dev, -1, |
489 | 0, TWL4030_GPIO_MAX, 0); | ||
489 | if (irq_base < 0) { | 490 | if (irq_base < 0) { |
490 | dev_err(&pdev->dev, "Failed to alloc irq_descs\n"); | 491 | dev_err(&pdev->dev, "Failed to alloc irq_descs\n"); |
491 | return irq_base; | 492 | return irq_base; |
diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c index 97613de5304e..7b1bc20be209 100644 --- a/drivers/gpio/gpio-wcove.c +++ b/drivers/gpio/gpio-wcove.c | |||
@@ -51,6 +51,8 @@ | |||
51 | #define GROUP1_NR_IRQS 6 | 51 | #define GROUP1_NR_IRQS 6 |
52 | #define IRQ_MASK_BASE 0x4e19 | 52 | #define IRQ_MASK_BASE 0x4e19 |
53 | #define IRQ_STATUS_BASE 0x4e0b | 53 | #define IRQ_STATUS_BASE 0x4e0b |
54 | #define GPIO_IRQ0_MASK GENMASK(6, 0) | ||
55 | #define GPIO_IRQ1_MASK GENMASK(5, 0) | ||
54 | #define UPDATE_IRQ_TYPE BIT(0) | 56 | #define UPDATE_IRQ_TYPE BIT(0) |
55 | #define UPDATE_IRQ_MASK BIT(1) | 57 | #define UPDATE_IRQ_MASK BIT(1) |
56 | 58 | ||
@@ -309,7 +311,7 @@ static irqreturn_t wcove_gpio_irq_handler(int irq, void *data) | |||
309 | return IRQ_NONE; | 311 | return IRQ_NONE; |
310 | } | 312 | } |
311 | 313 | ||
312 | pending = p[0] | (p[1] << 8); | 314 | pending = (p[0] & GPIO_IRQ0_MASK) | ((p[1] & GPIO_IRQ1_MASK) << 7); |
313 | if (!pending) | 315 | if (!pending) |
314 | return IRQ_NONE; | 316 | return IRQ_NONE; |
315 | 317 | ||
@@ -317,7 +319,7 @@ static irqreturn_t wcove_gpio_irq_handler(int irq, void *data) | |||
317 | while (pending) { | 319 | while (pending) { |
318 | /* One iteration is for all pending bits */ | 320 | /* One iteration is for all pending bits */ |
319 | for_each_set_bit(gpio, (const unsigned long *)&pending, | 321 | for_each_set_bit(gpio, (const unsigned long *)&pending, |
320 | GROUP0_NR_IRQS) { | 322 | WCOVE_GPIO_NUM) { |
321 | offset = (gpio > GROUP0_NR_IRQS) ? 1 : 0; | 323 | offset = (gpio > GROUP0_NR_IRQS) ? 1 : 0; |
322 | mask = (offset == 1) ? BIT(gpio - GROUP0_NR_IRQS) : | 324 | mask = (offset == 1) ? BIT(gpio - GROUP0_NR_IRQS) : |
323 | BIT(gpio); | 325 | BIT(gpio); |
@@ -333,7 +335,7 @@ static irqreturn_t wcove_gpio_irq_handler(int irq, void *data) | |||
333 | break; | 335 | break; |
334 | } | 336 | } |
335 | 337 | ||
336 | pending = p[0] | (p[1] << 8); | 338 | pending = (p[0] & GPIO_IRQ0_MASK) | ((p[1] & GPIO_IRQ1_MASK) << 7); |
337 | } | 339 | } |
338 | 340 | ||
339 | return IRQ_HANDLED; | 341 | return IRQ_HANDLED; |
diff --git a/drivers/gpio/gpio-ws16c48.c b/drivers/gpio/gpio-ws16c48.c index 901b5ccb032d..87d63695dfcf 100644 --- a/drivers/gpio/gpio-ws16c48.c +++ b/drivers/gpio/gpio-ws16c48.c | |||
@@ -51,7 +51,7 @@ struct ws16c48_gpio { | |||
51 | struct gpio_chip chip; | 51 | struct gpio_chip chip; |
52 | unsigned char io_state[6]; | 52 | unsigned char io_state[6]; |
53 | unsigned char out_state[6]; | 53 | unsigned char out_state[6]; |
54 | spinlock_t lock; | 54 | raw_spinlock_t lock; |
55 | unsigned long irq_mask; | 55 | unsigned long irq_mask; |
56 | unsigned long flow_mask; | 56 | unsigned long flow_mask; |
57 | unsigned base; | 57 | unsigned base; |
@@ -73,13 +73,13 @@ static int ws16c48_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | |||
73 | const unsigned mask = BIT(offset % 8); | 73 | const unsigned mask = BIT(offset % 8); |
74 | unsigned long flags; | 74 | unsigned long flags; |
75 | 75 | ||
76 | spin_lock_irqsave(&ws16c48gpio->lock, flags); | 76 | raw_spin_lock_irqsave(&ws16c48gpio->lock, flags); |
77 | 77 | ||
78 | ws16c48gpio->io_state[port] |= mask; | 78 | ws16c48gpio->io_state[port] |= mask; |
79 | ws16c48gpio->out_state[port] &= ~mask; | 79 | ws16c48gpio->out_state[port] &= ~mask; |
80 | outb(ws16c48gpio->out_state[port], ws16c48gpio->base + port); | 80 | outb(ws16c48gpio->out_state[port], ws16c48gpio->base + port); |
81 | 81 | ||
82 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 82 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
83 | 83 | ||
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
@@ -92,7 +92,7 @@ static int ws16c48_gpio_direction_output(struct gpio_chip *chip, | |||
92 | const unsigned mask = BIT(offset % 8); | 92 | const unsigned mask = BIT(offset % 8); |
93 | unsigned long flags; | 93 | unsigned long flags; |
94 | 94 | ||
95 | spin_lock_irqsave(&ws16c48gpio->lock, flags); | 95 | raw_spin_lock_irqsave(&ws16c48gpio->lock, flags); |
96 | 96 | ||
97 | ws16c48gpio->io_state[port] &= ~mask; | 97 | ws16c48gpio->io_state[port] &= ~mask; |
98 | if (value) | 98 | if (value) |
@@ -101,7 +101,7 @@ static int ws16c48_gpio_direction_output(struct gpio_chip *chip, | |||
101 | ws16c48gpio->out_state[port] &= ~mask; | 101 | ws16c48gpio->out_state[port] &= ~mask; |
102 | outb(ws16c48gpio->out_state[port], ws16c48gpio->base + port); | 102 | outb(ws16c48gpio->out_state[port], ws16c48gpio->base + port); |
103 | 103 | ||
104 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 104 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
105 | 105 | ||
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
@@ -114,17 +114,17 @@ static int ws16c48_gpio_get(struct gpio_chip *chip, unsigned offset) | |||
114 | unsigned long flags; | 114 | unsigned long flags; |
115 | unsigned port_state; | 115 | unsigned port_state; |
116 | 116 | ||
117 | spin_lock_irqsave(&ws16c48gpio->lock, flags); | 117 | raw_spin_lock_irqsave(&ws16c48gpio->lock, flags); |
118 | 118 | ||
119 | /* ensure that GPIO is set for input */ | 119 | /* ensure that GPIO is set for input */ |
120 | if (!(ws16c48gpio->io_state[port] & mask)) { | 120 | if (!(ws16c48gpio->io_state[port] & mask)) { |
121 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 121 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
122 | return -EINVAL; | 122 | return -EINVAL; |
123 | } | 123 | } |
124 | 124 | ||
125 | port_state = inb(ws16c48gpio->base + port); | 125 | port_state = inb(ws16c48gpio->base + port); |
126 | 126 | ||
127 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 127 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
128 | 128 | ||
129 | return !!(port_state & mask); | 129 | return !!(port_state & mask); |
130 | } | 130 | } |
@@ -136,11 +136,11 @@ static void ws16c48_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
136 | const unsigned mask = BIT(offset % 8); | 136 | const unsigned mask = BIT(offset % 8); |
137 | unsigned long flags; | 137 | unsigned long flags; |
138 | 138 | ||
139 | spin_lock_irqsave(&ws16c48gpio->lock, flags); | 139 | raw_spin_lock_irqsave(&ws16c48gpio->lock, flags); |
140 | 140 | ||
141 | /* ensure that GPIO is set for output */ | 141 | /* ensure that GPIO is set for output */ |
142 | if (ws16c48gpio->io_state[port] & mask) { | 142 | if (ws16c48gpio->io_state[port] & mask) { |
143 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 143 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | 146 | ||
@@ -150,7 +150,7 @@ static void ws16c48_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | |||
150 | ws16c48gpio->out_state[port] &= ~mask; | 150 | ws16c48gpio->out_state[port] &= ~mask; |
151 | outb(ws16c48gpio->out_state[port], ws16c48gpio->base + port); | 151 | outb(ws16c48gpio->out_state[port], ws16c48gpio->base + port); |
152 | 152 | ||
153 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 153 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
154 | } | 154 | } |
155 | 155 | ||
156 | static void ws16c48_gpio_set_multiple(struct gpio_chip *chip, | 156 | static void ws16c48_gpio_set_multiple(struct gpio_chip *chip, |
@@ -178,14 +178,14 @@ static void ws16c48_gpio_set_multiple(struct gpio_chip *chip, | |||
178 | iomask = mask[BIT_WORD(i)] & ~ws16c48gpio->io_state[port]; | 178 | iomask = mask[BIT_WORD(i)] & ~ws16c48gpio->io_state[port]; |
179 | bitmask = iomask & bits[BIT_WORD(i)]; | 179 | bitmask = iomask & bits[BIT_WORD(i)]; |
180 | 180 | ||
181 | spin_lock_irqsave(&ws16c48gpio->lock, flags); | 181 | raw_spin_lock_irqsave(&ws16c48gpio->lock, flags); |
182 | 182 | ||
183 | /* update output state data and set device gpio register */ | 183 | /* update output state data and set device gpio register */ |
184 | ws16c48gpio->out_state[port] &= ~iomask; | 184 | ws16c48gpio->out_state[port] &= ~iomask; |
185 | ws16c48gpio->out_state[port] |= bitmask; | 185 | ws16c48gpio->out_state[port] |= bitmask; |
186 | outb(ws16c48gpio->out_state[port], ws16c48gpio->base + port); | 186 | outb(ws16c48gpio->out_state[port], ws16c48gpio->base + port); |
187 | 187 | ||
188 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 188 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
189 | 189 | ||
190 | /* prepare for next gpio register set */ | 190 | /* prepare for next gpio register set */ |
191 | mask[BIT_WORD(i)] >>= gpio_reg_size; | 191 | mask[BIT_WORD(i)] >>= gpio_reg_size; |
@@ -207,7 +207,7 @@ static void ws16c48_irq_ack(struct irq_data *data) | |||
207 | if (port > 2) | 207 | if (port > 2) |
208 | return; | 208 | return; |
209 | 209 | ||
210 | spin_lock_irqsave(&ws16c48gpio->lock, flags); | 210 | raw_spin_lock_irqsave(&ws16c48gpio->lock, flags); |
211 | 211 | ||
212 | port_state = ws16c48gpio->irq_mask >> (8*port); | 212 | port_state = ws16c48gpio->irq_mask >> (8*port); |
213 | 213 | ||
@@ -216,7 +216,7 @@ static void ws16c48_irq_ack(struct irq_data *data) | |||
216 | outb(port_state | mask, ws16c48gpio->base + 8 + port); | 216 | outb(port_state | mask, ws16c48gpio->base + 8 + port); |
217 | outb(0xC0, ws16c48gpio->base + 7); | 217 | outb(0xC0, ws16c48gpio->base + 7); |
218 | 218 | ||
219 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 219 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
220 | } | 220 | } |
221 | 221 | ||
222 | static void ws16c48_irq_mask(struct irq_data *data) | 222 | static void ws16c48_irq_mask(struct irq_data *data) |
@@ -232,7 +232,7 @@ static void ws16c48_irq_mask(struct irq_data *data) | |||
232 | if (port > 2) | 232 | if (port > 2) |
233 | return; | 233 | return; |
234 | 234 | ||
235 | spin_lock_irqsave(&ws16c48gpio->lock, flags); | 235 | raw_spin_lock_irqsave(&ws16c48gpio->lock, flags); |
236 | 236 | ||
237 | ws16c48gpio->irq_mask &= ~mask; | 237 | ws16c48gpio->irq_mask &= ~mask; |
238 | 238 | ||
@@ -240,7 +240,7 @@ static void ws16c48_irq_mask(struct irq_data *data) | |||
240 | outb(ws16c48gpio->irq_mask >> (8*port), ws16c48gpio->base + 8 + port); | 240 | outb(ws16c48gpio->irq_mask >> (8*port), ws16c48gpio->base + 8 + port); |
241 | outb(0xC0, ws16c48gpio->base + 7); | 241 | outb(0xC0, ws16c48gpio->base + 7); |
242 | 242 | ||
243 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 243 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
244 | } | 244 | } |
245 | 245 | ||
246 | static void ws16c48_irq_unmask(struct irq_data *data) | 246 | static void ws16c48_irq_unmask(struct irq_data *data) |
@@ -256,7 +256,7 @@ static void ws16c48_irq_unmask(struct irq_data *data) | |||
256 | if (port > 2) | 256 | if (port > 2) |
257 | return; | 257 | return; |
258 | 258 | ||
259 | spin_lock_irqsave(&ws16c48gpio->lock, flags); | 259 | raw_spin_lock_irqsave(&ws16c48gpio->lock, flags); |
260 | 260 | ||
261 | ws16c48gpio->irq_mask |= mask; | 261 | ws16c48gpio->irq_mask |= mask; |
262 | 262 | ||
@@ -264,7 +264,7 @@ static void ws16c48_irq_unmask(struct irq_data *data) | |||
264 | outb(ws16c48gpio->irq_mask >> (8*port), ws16c48gpio->base + 8 + port); | 264 | outb(ws16c48gpio->irq_mask >> (8*port), ws16c48gpio->base + 8 + port); |
265 | outb(0xC0, ws16c48gpio->base + 7); | 265 | outb(0xC0, ws16c48gpio->base + 7); |
266 | 266 | ||
267 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 267 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
268 | } | 268 | } |
269 | 269 | ||
270 | static int ws16c48_irq_set_type(struct irq_data *data, unsigned flow_type) | 270 | static int ws16c48_irq_set_type(struct irq_data *data, unsigned flow_type) |
@@ -280,7 +280,7 @@ static int ws16c48_irq_set_type(struct irq_data *data, unsigned flow_type) | |||
280 | if (port > 2) | 280 | if (port > 2) |
281 | return -EINVAL; | 281 | return -EINVAL; |
282 | 282 | ||
283 | spin_lock_irqsave(&ws16c48gpio->lock, flags); | 283 | raw_spin_lock_irqsave(&ws16c48gpio->lock, flags); |
284 | 284 | ||
285 | switch (flow_type) { | 285 | switch (flow_type) { |
286 | case IRQ_TYPE_NONE: | 286 | case IRQ_TYPE_NONE: |
@@ -292,7 +292,7 @@ static int ws16c48_irq_set_type(struct irq_data *data, unsigned flow_type) | |||
292 | ws16c48gpio->flow_mask &= ~mask; | 292 | ws16c48gpio->flow_mask &= ~mask; |
293 | break; | 293 | break; |
294 | default: | 294 | default: |
295 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 295 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
296 | return -EINVAL; | 296 | return -EINVAL; |
297 | } | 297 | } |
298 | 298 | ||
@@ -300,7 +300,7 @@ static int ws16c48_irq_set_type(struct irq_data *data, unsigned flow_type) | |||
300 | outb(ws16c48gpio->flow_mask >> (8*port), ws16c48gpio->base + 8 + port); | 300 | outb(ws16c48gpio->flow_mask >> (8*port), ws16c48gpio->base + 8 + port); |
301 | outb(0xC0, ws16c48gpio->base + 7); | 301 | outb(0xC0, ws16c48gpio->base + 7); |
302 | 302 | ||
303 | spin_unlock_irqrestore(&ws16c48gpio->lock, flags); | 303 | raw_spin_unlock_irqrestore(&ws16c48gpio->lock, flags); |
304 | 304 | ||
305 | return 0; | 305 | return 0; |
306 | } | 306 | } |
@@ -387,7 +387,7 @@ static int ws16c48_probe(struct device *dev, unsigned int id) | |||
387 | ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple; | 387 | ws16c48gpio->chip.set_multiple = ws16c48_gpio_set_multiple; |
388 | ws16c48gpio->base = base[id]; | 388 | ws16c48gpio->base = base[id]; |
389 | 389 | ||
390 | spin_lock_init(&ws16c48gpio->lock); | 390 | raw_spin_lock_init(&ws16c48gpio->lock); |
391 | 391 | ||
392 | err = devm_gpiochip_add_data(dev, &ws16c48gpio->chip, ws16c48gpio); | 392 | err = devm_gpiochip_add_data(dev, &ws16c48gpio->chip, ws16c48gpio); |
393 | if (err) { | 393 | if (err) { |
diff --git a/drivers/gpio/gpio-xlp.c b/drivers/gpio/gpio-xlp.c index 4620d050e5a8..d857e1d8e731 100644 --- a/drivers/gpio/gpio-xlp.c +++ b/drivers/gpio/gpio-xlp.c | |||
@@ -404,7 +404,9 @@ static int xlp_gpio_probe(struct platform_device *pdev) | |||
404 | 404 | ||
405 | /* XLP(MIPS) has fixed range for GPIO IRQs, Vulcan(ARM64) does not */ | 405 | /* XLP(MIPS) has fixed range for GPIO IRQs, Vulcan(ARM64) does not */ |
406 | if (soc_type != GPIO_VARIANT_VULCAN) { | 406 | if (soc_type != GPIO_VARIANT_VULCAN) { |
407 | irq_base = irq_alloc_descs(-1, XLP_GPIO_IRQ_BASE, gc->ngpio, 0); | 407 | irq_base = devm_irq_alloc_descs(&pdev->dev, -1, |
408 | XLP_GPIO_IRQ_BASE, | ||
409 | gc->ngpio, 0); | ||
408 | if (irq_base < 0) { | 410 | if (irq_base < 0) { |
409 | dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); | 411 | dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); |
410 | return irq_base; | 412 | return irq_base; |
@@ -415,7 +417,7 @@ static int xlp_gpio_probe(struct platform_device *pdev) | |||
415 | 417 | ||
416 | err = gpiochip_add_data(gc, priv); | 418 | err = gpiochip_add_data(gc, priv); |
417 | if (err < 0) | 419 | if (err < 0) |
418 | goto out_free_desc; | 420 | return err; |
419 | 421 | ||
420 | err = gpiochip_irqchip_add(gc, &xlp_gpio_irq_chip, irq_base, | 422 | err = gpiochip_irqchip_add(gc, &xlp_gpio_irq_chip, irq_base, |
421 | handle_level_irq, IRQ_TYPE_NONE); | 423 | handle_level_irq, IRQ_TYPE_NONE); |
@@ -433,14 +435,13 @@ static int xlp_gpio_probe(struct platform_device *pdev) | |||
433 | 435 | ||
434 | out_gpio_remove: | 436 | out_gpio_remove: |
435 | gpiochip_remove(gc); | 437 | gpiochip_remove(gc); |
436 | out_free_desc: | ||
437 | irq_free_descs(irq_base, gc->ngpio); | ||
438 | return err; | 438 | return err; |
439 | } | 439 | } |
440 | 440 | ||
441 | #ifdef CONFIG_ACPI | 441 | #ifdef CONFIG_ACPI |
442 | static const struct acpi_device_id xlp_gpio_acpi_match[] = { | 442 | static const struct acpi_device_id xlp_gpio_acpi_match[] = { |
443 | { "BRCM9006", GPIO_VARIANT_VULCAN }, | 443 | { "BRCM9006", GPIO_VARIANT_VULCAN }, |
444 | { "CAV9006", GPIO_VARIANT_VULCAN }, | ||
444 | {}, | 445 | {}, |
445 | }; | 446 | }; |
446 | MODULE_DEVICE_TABLE(acpi, xlp_gpio_acpi_match); | 447 | MODULE_DEVICE_TABLE(acpi, xlp_gpio_acpi_match); |
diff --git a/drivers/gpio/gpio-zx.c b/drivers/gpio/gpio-zx.c index 93de8be0d885..be3a87da8438 100644 --- a/drivers/gpio/gpio-zx.c +++ b/drivers/gpio/gpio-zx.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #define ZX_GPIO_NR 16 | 41 | #define ZX_GPIO_NR 16 |
42 | 42 | ||
43 | struct zx_gpio { | 43 | struct zx_gpio { |
44 | spinlock_t lock; | 44 | raw_spinlock_t lock; |
45 | 45 | ||
46 | void __iomem *base; | 46 | void __iomem *base; |
47 | struct gpio_chip gc; | 47 | struct gpio_chip gc; |
@@ -56,11 +56,11 @@ static int zx_direction_input(struct gpio_chip *gc, unsigned offset) | |||
56 | if (offset >= gc->ngpio) | 56 | if (offset >= gc->ngpio) |
57 | return -EINVAL; | 57 | return -EINVAL; |
58 | 58 | ||
59 | spin_lock_irqsave(&chip->lock, flags); | 59 | raw_spin_lock_irqsave(&chip->lock, flags); |
60 | gpiodir = readw_relaxed(chip->base + ZX_GPIO_DIR); | 60 | gpiodir = readw_relaxed(chip->base + ZX_GPIO_DIR); |
61 | gpiodir &= ~BIT(offset); | 61 | gpiodir &= ~BIT(offset); |
62 | writew_relaxed(gpiodir, chip->base + ZX_GPIO_DIR); | 62 | writew_relaxed(gpiodir, chip->base + ZX_GPIO_DIR); |
63 | spin_unlock_irqrestore(&chip->lock, flags); | 63 | raw_spin_unlock_irqrestore(&chip->lock, flags); |
64 | 64 | ||
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
@@ -75,7 +75,7 @@ static int zx_direction_output(struct gpio_chip *gc, unsigned offset, | |||
75 | if (offset >= gc->ngpio) | 75 | if (offset >= gc->ngpio) |
76 | return -EINVAL; | 76 | return -EINVAL; |
77 | 77 | ||
78 | spin_lock_irqsave(&chip->lock, flags); | 78 | raw_spin_lock_irqsave(&chip->lock, flags); |
79 | gpiodir = readw_relaxed(chip->base + ZX_GPIO_DIR); | 79 | gpiodir = readw_relaxed(chip->base + ZX_GPIO_DIR); |
80 | gpiodir |= BIT(offset); | 80 | gpiodir |= BIT(offset); |
81 | writew_relaxed(gpiodir, chip->base + ZX_GPIO_DIR); | 81 | writew_relaxed(gpiodir, chip->base + ZX_GPIO_DIR); |
@@ -84,7 +84,7 @@ static int zx_direction_output(struct gpio_chip *gc, unsigned offset, | |||
84 | writew_relaxed(BIT(offset), chip->base + ZX_GPIO_DO1); | 84 | writew_relaxed(BIT(offset), chip->base + ZX_GPIO_DO1); |
85 | else | 85 | else |
86 | writew_relaxed(BIT(offset), chip->base + ZX_GPIO_DO0); | 86 | writew_relaxed(BIT(offset), chip->base + ZX_GPIO_DO0); |
87 | spin_unlock_irqrestore(&chip->lock, flags); | 87 | raw_spin_unlock_irqrestore(&chip->lock, flags); |
88 | 88 | ||
89 | return 0; | 89 | return 0; |
90 | } | 90 | } |
@@ -118,7 +118,7 @@ static int zx_irq_type(struct irq_data *d, unsigned trigger) | |||
118 | if (offset < 0 || offset >= ZX_GPIO_NR) | 118 | if (offset < 0 || offset >= ZX_GPIO_NR) |
119 | return -EINVAL; | 119 | return -EINVAL; |
120 | 120 | ||
121 | spin_lock_irqsave(&chip->lock, flags); | 121 | raw_spin_lock_irqsave(&chip->lock, flags); |
122 | 122 | ||
123 | gpioiev = readw_relaxed(chip->base + ZX_GPIO_IV); | 123 | gpioiev = readw_relaxed(chip->base + ZX_GPIO_IV); |
124 | gpiois = readw_relaxed(chip->base + ZX_GPIO_IVE); | 124 | gpiois = readw_relaxed(chip->base + ZX_GPIO_IVE); |
@@ -151,7 +151,7 @@ static int zx_irq_type(struct irq_data *d, unsigned trigger) | |||
151 | writew_relaxed(gpioi_epos, chip->base + ZX_GPIO_IEP); | 151 | writew_relaxed(gpioi_epos, chip->base + ZX_GPIO_IEP); |
152 | writew_relaxed(gpioi_eneg, chip->base + ZX_GPIO_IEN); | 152 | writew_relaxed(gpioi_eneg, chip->base + ZX_GPIO_IEN); |
153 | writew_relaxed(gpioiev, chip->base + ZX_GPIO_IV); | 153 | writew_relaxed(gpioiev, chip->base + ZX_GPIO_IV); |
154 | spin_unlock_irqrestore(&chip->lock, flags); | 154 | raw_spin_unlock_irqrestore(&chip->lock, flags); |
155 | 155 | ||
156 | return 0; | 156 | return 0; |
157 | } | 157 | } |
@@ -184,12 +184,12 @@ static void zx_irq_mask(struct irq_data *d) | |||
184 | u16 mask = BIT(irqd_to_hwirq(d) % ZX_GPIO_NR); | 184 | u16 mask = BIT(irqd_to_hwirq(d) % ZX_GPIO_NR); |
185 | u16 gpioie; | 185 | u16 gpioie; |
186 | 186 | ||
187 | spin_lock(&chip->lock); | 187 | raw_spin_lock(&chip->lock); |
188 | gpioie = readw_relaxed(chip->base + ZX_GPIO_IM) | mask; | 188 | gpioie = readw_relaxed(chip->base + ZX_GPIO_IM) | mask; |
189 | writew_relaxed(gpioie, chip->base + ZX_GPIO_IM); | 189 | writew_relaxed(gpioie, chip->base + ZX_GPIO_IM); |
190 | gpioie = readw_relaxed(chip->base + ZX_GPIO_IE) & ~mask; | 190 | gpioie = readw_relaxed(chip->base + ZX_GPIO_IE) & ~mask; |
191 | writew_relaxed(gpioie, chip->base + ZX_GPIO_IE); | 191 | writew_relaxed(gpioie, chip->base + ZX_GPIO_IE); |
192 | spin_unlock(&chip->lock); | 192 | raw_spin_unlock(&chip->lock); |
193 | } | 193 | } |
194 | 194 | ||
195 | static void zx_irq_unmask(struct irq_data *d) | 195 | static void zx_irq_unmask(struct irq_data *d) |
@@ -199,12 +199,12 @@ static void zx_irq_unmask(struct irq_data *d) | |||
199 | u16 mask = BIT(irqd_to_hwirq(d) % ZX_GPIO_NR); | 199 | u16 mask = BIT(irqd_to_hwirq(d) % ZX_GPIO_NR); |
200 | u16 gpioie; | 200 | u16 gpioie; |
201 | 201 | ||
202 | spin_lock(&chip->lock); | 202 | raw_spin_lock(&chip->lock); |
203 | gpioie = readw_relaxed(chip->base + ZX_GPIO_IM) & ~mask; | 203 | gpioie = readw_relaxed(chip->base + ZX_GPIO_IM) & ~mask; |
204 | writew_relaxed(gpioie, chip->base + ZX_GPIO_IM); | 204 | writew_relaxed(gpioie, chip->base + ZX_GPIO_IM); |
205 | gpioie = readw_relaxed(chip->base + ZX_GPIO_IE) | mask; | 205 | gpioie = readw_relaxed(chip->base + ZX_GPIO_IE) | mask; |
206 | writew_relaxed(gpioie, chip->base + ZX_GPIO_IE); | 206 | writew_relaxed(gpioie, chip->base + ZX_GPIO_IE); |
207 | spin_unlock(&chip->lock); | 207 | raw_spin_unlock(&chip->lock); |
208 | } | 208 | } |
209 | 209 | ||
210 | static struct irq_chip zx_irqchip = { | 210 | static struct irq_chip zx_irqchip = { |
@@ -230,7 +230,7 @@ static int zx_gpio_probe(struct platform_device *pdev) | |||
230 | if (IS_ERR(chip->base)) | 230 | if (IS_ERR(chip->base)) |
231 | return PTR_ERR(chip->base); | 231 | return PTR_ERR(chip->base); |
232 | 232 | ||
233 | spin_lock_init(&chip->lock); | 233 | raw_spin_lock_init(&chip->lock); |
234 | if (of_property_read_bool(dev->of_node, "gpio-ranges")) { | 234 | if (of_property_read_bool(dev->of_node, "gpio-ranges")) { |
235 | chip->gc.request = gpiochip_generic_request; | 235 | chip->gc.request = gpiochip_generic_request; |
236 | chip->gc.free = gpiochip_generic_free; | 236 | chip->gc.free = gpiochip_generic_free; |
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 2bd683e2be02..2185232da823 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -368,6 +368,37 @@ int acpi_dev_add_driver_gpios(struct acpi_device *adev, | |||
368 | } | 368 | } |
369 | EXPORT_SYMBOL_GPL(acpi_dev_add_driver_gpios); | 369 | EXPORT_SYMBOL_GPL(acpi_dev_add_driver_gpios); |
370 | 370 | ||
371 | static void devm_acpi_dev_release_driver_gpios(struct device *dev, void *res) | ||
372 | { | ||
373 | acpi_dev_remove_driver_gpios(ACPI_COMPANION(dev)); | ||
374 | } | ||
375 | |||
376 | int devm_acpi_dev_add_driver_gpios(struct device *dev, | ||
377 | const struct acpi_gpio_mapping *gpios) | ||
378 | { | ||
379 | void *res; | ||
380 | int ret; | ||
381 | |||
382 | res = devres_alloc(devm_acpi_dev_release_driver_gpios, 0, GFP_KERNEL); | ||
383 | if (!res) | ||
384 | return -ENOMEM; | ||
385 | |||
386 | ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), gpios); | ||
387 | if (ret) { | ||
388 | devres_free(res); | ||
389 | return ret; | ||
390 | } | ||
391 | devres_add(dev, res); | ||
392 | return 0; | ||
393 | } | ||
394 | EXPORT_SYMBOL_GPL(devm_acpi_dev_add_driver_gpios); | ||
395 | |||
396 | void devm_acpi_dev_remove_driver_gpios(struct device *dev) | ||
397 | { | ||
398 | WARN_ON(devres_release(dev, devm_acpi_dev_release_driver_gpios, NULL, NULL)); | ||
399 | } | ||
400 | EXPORT_SYMBOL_GPL(devm_acpi_dev_remove_driver_gpios); | ||
401 | |||
371 | static bool acpi_get_driver_gpio_data(struct acpi_device *adev, | 402 | static bool acpi_get_driver_gpio_data(struct acpi_device *adev, |
372 | const char *name, int index, | 403 | const char *name, int index, |
373 | struct acpi_reference_args *args) | 404 | struct acpi_reference_args *args) |
@@ -661,20 +692,24 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) | |||
661 | { | 692 | { |
662 | int idx, i; | 693 | int idx, i; |
663 | unsigned int irq_flags; | 694 | unsigned int irq_flags; |
664 | int ret = -ENOENT; | ||
665 | 695 | ||
666 | for (i = 0, idx = 0; idx <= index; i++) { | 696 | for (i = 0, idx = 0; idx <= index; i++) { |
667 | struct acpi_gpio_info info; | 697 | struct acpi_gpio_info info; |
668 | struct gpio_desc *desc; | 698 | struct gpio_desc *desc; |
669 | 699 | ||
670 | desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); | 700 | desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); |
671 | if (IS_ERR(desc)) { | 701 | |
672 | ret = PTR_ERR(desc); | 702 | /* Ignore -EPROBE_DEFER, it only matters if idx matches */ |
673 | break; | 703 | if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) |
674 | } | 704 | return PTR_ERR(desc); |
705 | |||
675 | if (info.gpioint && idx++ == index) { | 706 | if (info.gpioint && idx++ == index) { |
676 | int irq = gpiod_to_irq(desc); | 707 | int irq; |
677 | 708 | ||
709 | if (IS_ERR(desc)) | ||
710 | return PTR_ERR(desc); | ||
711 | |||
712 | irq = gpiod_to_irq(desc); | ||
678 | if (irq < 0) | 713 | if (irq < 0) |
679 | return irq; | 714 | return irq; |
680 | 715 | ||
@@ -690,7 +725,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) | |||
690 | } | 725 | } |
691 | 726 | ||
692 | } | 727 | } |
693 | return ret; | 728 | return -ENOENT; |
694 | } | 729 | } |
695 | EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get); | 730 | EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get); |
696 | 731 | ||
@@ -1075,7 +1110,7 @@ int acpi_gpio_count(struct device *dev, const char *con_id) | |||
1075 | break; | 1110 | break; |
1076 | } | 1111 | } |
1077 | } | 1112 | } |
1078 | if (count >= 0) | 1113 | if (count > 0) |
1079 | break; | 1114 | break; |
1080 | } | 1115 | } |
1081 | 1116 | ||
@@ -1091,7 +1126,7 @@ int acpi_gpio_count(struct device *dev, const char *con_id) | |||
1091 | if (crs_count > 0) | 1126 | if (crs_count > 0) |
1092 | count = crs_count; | 1127 | count = crs_count; |
1093 | } | 1128 | } |
1094 | return count; | 1129 | return count ? count : -ENOENT; |
1095 | } | 1130 | } |
1096 | 1131 | ||
1097 | struct acpi_crs_lookup { | 1132 | struct acpi_crs_lookup { |
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 975b9f6cf408..b13b7c7c335f 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c | |||
@@ -147,7 +147,7 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | |||
147 | *flags |= GPIO_ACTIVE_LOW; | 147 | *flags |= GPIO_ACTIVE_LOW; |
148 | 148 | ||
149 | if (of_flags & OF_GPIO_SINGLE_ENDED) { | 149 | if (of_flags & OF_GPIO_SINGLE_ENDED) { |
150 | if (of_flags & OF_GPIO_ACTIVE_LOW) | 150 | if (of_flags & OF_GPIO_OPEN_DRAIN) |
151 | *flags |= GPIO_OPEN_DRAIN; | 151 | *flags |= GPIO_OPEN_DRAIN; |
152 | else | 152 | else |
153 | *flags |= GPIO_OPEN_SOURCE; | 153 | *flags |= GPIO_OPEN_SOURCE; |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 8b4d721d6d63..1d1fa7248d63 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1522,7 +1522,7 @@ static bool gpiochip_irqchip_irq_valid(const struct gpio_chip *gpiochip, | |||
1522 | */ | 1522 | */ |
1523 | static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gpiochip, | 1523 | static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gpiochip, |
1524 | struct irq_chip *irqchip, | 1524 | struct irq_chip *irqchip, |
1525 | int parent_irq, | 1525 | unsigned int parent_irq, |
1526 | irq_flow_handler_t parent_handler) | 1526 | irq_flow_handler_t parent_handler) |
1527 | { | 1527 | { |
1528 | unsigned int offset; | 1528 | unsigned int offset; |
@@ -1571,7 +1571,7 @@ static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gpiochip, | |||
1571 | */ | 1571 | */ |
1572 | void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, | 1572 | void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, |
1573 | struct irq_chip *irqchip, | 1573 | struct irq_chip *irqchip, |
1574 | int parent_irq, | 1574 | unsigned int parent_irq, |
1575 | irq_flow_handler_t parent_handler) | 1575 | irq_flow_handler_t parent_handler) |
1576 | { | 1576 | { |
1577 | gpiochip_set_cascaded_irqchip(gpiochip, irqchip, parent_irq, | 1577 | gpiochip_set_cascaded_irqchip(gpiochip, irqchip, parent_irq, |
@@ -1588,7 +1588,7 @@ EXPORT_SYMBOL_GPL(gpiochip_set_chained_irqchip); | |||
1588 | */ | 1588 | */ |
1589 | void gpiochip_set_nested_irqchip(struct gpio_chip *gpiochip, | 1589 | void gpiochip_set_nested_irqchip(struct gpio_chip *gpiochip, |
1590 | struct irq_chip *irqchip, | 1590 | struct irq_chip *irqchip, |
1591 | int parent_irq) | 1591 | unsigned int parent_irq) |
1592 | { | 1592 | { |
1593 | if (!gpiochip->irq_nested) { | 1593 | if (!gpiochip->irq_nested) { |
1594 | chip_err(gpiochip, "tried to nest a chained gpiochip\n"); | 1594 | chip_err(gpiochip, "tried to nest a chained gpiochip\n"); |
@@ -3122,10 +3122,10 @@ static int dt_gpio_count(struct device *dev, const char *con_id) | |||
3122 | gpio_suffixes[i]); | 3122 | gpio_suffixes[i]); |
3123 | 3123 | ||
3124 | ret = of_gpio_named_count(dev->of_node, propname); | 3124 | ret = of_gpio_named_count(dev->of_node, propname); |
3125 | if (ret >= 0) | 3125 | if (ret > 0) |
3126 | break; | 3126 | break; |
3127 | } | 3127 | } |
3128 | return ret; | 3128 | return ret ? ret : -ENOENT; |
3129 | } | 3129 | } |
3130 | 3130 | ||
3131 | static int platform_gpio_count(struct device *dev, const char *con_id) | 3131 | static int platform_gpio_count(struct device *dev, const char *con_id) |
@@ -3326,7 +3326,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index); | |||
3326 | * underlying firmware interface and then makes sure that the GPIO | 3326 | * underlying firmware interface and then makes sure that the GPIO |
3327 | * descriptor is requested before it is returned to the caller. | 3327 | * descriptor is requested before it is returned to the caller. |
3328 | * | 3328 | * |
3329 | * On successfull request the GPIO pin is configured in accordance with | 3329 | * On successful request the GPIO pin is configured in accordance with |
3330 | * provided @dflags. | 3330 | * provided @dflags. |
3331 | * | 3331 | * |
3332 | * In case of error an ERR_PTR() is returned. | 3332 | * In case of error an ERR_PTR() is returned. |
@@ -3340,6 +3340,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | |||
3340 | unsigned long lflags = 0; | 3340 | unsigned long lflags = 0; |
3341 | bool active_low = false; | 3341 | bool active_low = false; |
3342 | bool single_ended = false; | 3342 | bool single_ended = false; |
3343 | bool open_drain = false; | ||
3343 | int ret; | 3344 | int ret; |
3344 | 3345 | ||
3345 | if (!fwnode) | 3346 | if (!fwnode) |
@@ -3353,6 +3354,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | |||
3353 | if (!IS_ERR(desc)) { | 3354 | if (!IS_ERR(desc)) { |
3354 | active_low = flags & OF_GPIO_ACTIVE_LOW; | 3355 | active_low = flags & OF_GPIO_ACTIVE_LOW; |
3355 | single_ended = flags & OF_GPIO_SINGLE_ENDED; | 3356 | single_ended = flags & OF_GPIO_SINGLE_ENDED; |
3357 | open_drain = flags & OF_GPIO_OPEN_DRAIN; | ||
3356 | } | 3358 | } |
3357 | } else if (is_acpi_node(fwnode)) { | 3359 | } else if (is_acpi_node(fwnode)) { |
3358 | struct acpi_gpio_info info; | 3360 | struct acpi_gpio_info info; |
@@ -3373,7 +3375,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | |||
3373 | lflags |= GPIO_ACTIVE_LOW; | 3375 | lflags |= GPIO_ACTIVE_LOW; |
3374 | 3376 | ||
3375 | if (single_ended) { | 3377 | if (single_ended) { |
3376 | if (active_low) | 3378 | if (open_drain) |
3377 | lflags |= GPIO_OPEN_DRAIN; | 3379 | lflags |= GPIO_OPEN_DRAIN; |
3378 | else | 3380 | else |
3379 | lflags |= GPIO_OPEN_SOURCE; | 3381 | lflags |= GPIO_OPEN_SOURCE; |