Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'gpio-updates-for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio updates from Bartosz Golaszewski:
"We have some new drivers, significant refactoring of existing intel
platforms, lots of improvements all around, mass conversion to using
immutable irqchips by drivers that had not been converted individually
yet and some changes in the core library code.

Summary:

New drivers:
- add a driver for the Loongson GPIO controller
- add a driver for the fxl6408 I2C GPIO expander
- add a GPIO module containing code common for Intel Elkhart Lake and
Merrifield platforms
- add a driver for the Intel Elkhart Lake platform reusing the code
from the intel tangier library

GPIOLIB core:
- GPIO ACPI improvements
- simplify gpiochip_add_data_with_keys() fwnode handling
- cleanup header inclusions (remove unneeded ones, order the rest
alphabetically)
- remove duplicate code (reuse krealloc() instead of open-coding it,
drop a duplicated check in gpiod_find_and_request())
- reshuffle the code to remove unnecessary forward declarations
- coding style cleanups and improvements
- add a helper for accessing device fwnodes
- small updates in docs

Driver improvements:
- convert all remaining GPIO irqchip drivers to using immutable
irqchips
- drop unnecessary of_match_ptr() macro expansions
- shrink the code in gpio-merrifield significantly by reusing the
code from gpio-tangier + minor tweaks to the driver code
- remove MODULE_LICENSE() from drivers that can only be built-in
- add device-tree support to gpio-loongson1
- use new regmap features in gpio-104-dio-48e and gpio-pcie-idio-24
- minor tweaks and fixes to gpio-xra1403, gpio-sim, gpio-tegra194,
gpio-omap, gpio-aspeed, gpio-raspberrypi-exp
- shrink code in gpio-ich and gpio-pxa
- Kconfig tweak for gpio-pmic-eic-sprd"

* tag 'gpio-updates-for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (99 commits)
gpio: gpiolib: Simplify gpiochip_add_data_with_key() fwnode
gpiolib: Add gpiochip_set_data() helper
gpiolib: Move gpiochip_get_data() higher in the code
gpiolib: Check array_info for NULL only once in gpiod_get_array()
gpiolib: Replace open coded krealloc()
gpiolib: acpi: Add a ignore wakeup quirk for Clevo NL5xNU
gpiolib: acpi: Move ACPI device NULL check to acpi_get_driver_gpio_data()
gpiolib: acpi: use the fwnode in acpi_gpiochip_find()
gpio: mm-lantiq: Fix typo in the newly added header filename
sh: mach-x3proto: Add missing #include <linux/gpio/driver.h>
powerpc/40x: Add missing select OF_GPIO_MM_GPIOCHIP
gpio: xlp: Convert to immutable irq_chip
gpio: xilinx: Convert to immutable irq_chip
gpio: xgs-iproc: Convert to immutable irq_chip
gpio: visconti: Convert to immutable irq_chip
gpio: tqmx86: Convert to immutable irq_chip
gpio: thunderx: Convert to immutable irq_chip
gpio: stmpe: Convert to immutable irq_chip
gpio: siox: Convert to immutable irq_chip
gpio: rda: Convert to immutable irq_chip
...

+2415 -1367
+1 -1
Documentation/admin-guide/gpio/sysfs.rst
··· 145 145 /* export the GPIO to userspace */ 146 146 int gpiod_export(struct gpio_desc *desc, bool direction_may_change); 147 147 148 - /* reverse gpio_export() */ 148 + /* reverse gpiod_export() */ 149 149 void gpiod_unexport(struct gpio_desc *desc); 150 150 151 151 /* create a sysfs link to an exported GPIO node */
+58
Documentation/devicetree/bindings/gpio/fcs,fxl6408.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/fcs,fxl6408.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Fairchild FXL6408 I2C GPIO Expander 8 + 9 + maintainers: 10 + - Emanuele Ghidoli <emanuele.ghidoli@toradex.com> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - fcs,fxl6408 16 + 17 + reg: 18 + maxItems: 1 19 + 20 + "#gpio-cells": 21 + const: 2 22 + 23 + gpio-controller: true 24 + 25 + gpio-line-names: 26 + minItems: 1 27 + maxItems: 8 28 + 29 + patternProperties: 30 + "^(hog-[0-9]+|.+-hog(-[0-9]+)?)$": 31 + required: 32 + - gpio-hog 33 + 34 + required: 35 + - compatible 36 + - reg 37 + - gpio-controller 38 + - "#gpio-cells" 39 + 40 + additionalProperties: false 41 + 42 + examples: 43 + - | 44 + i2c { 45 + #address-cells = <1>; 46 + #size-cells = <0>; 47 + 48 + gpio_expander_43: gpio-expander@43 { 49 + compatible = "fcs,fxl6408"; 50 + reg = <0x43>; 51 + gpio-controller; 52 + #gpio-cells = <2>; 53 + gpio-line-names = "Wi-Fi_W_DISABLE", "Wi-Fi_WKUP_WLAN", 54 + "PWR_EN_+V3.3_WiFi_N", "PCIe_REF_CLK_EN", 55 + "USB_RESET_N", "USB_BYPASS_N", "Wi-Fi_PDn", 56 + "Wi-Fi_WKUP_BT"; 57 + }; 58 + };
+29 -12
Documentation/devicetree/bindings/gpio/gpio.txt
··· 154 154 155 155 Optionally, a GPIO controller may have a "gpio-line-names" property. This is 156 156 an array of strings defining the names of the GPIO lines going out of the 157 - GPIO controller. This name should be the most meaningful producer name 158 - for the system, such as a rail name indicating the usage. Package names 159 - such as pin name are discouraged: such lines have opaque names (since they 160 - are by definition generic purpose) and such names are usually not very 161 - helpful. For example "MMC-CD", "Red LED Vdd" and "ethernet reset" are 162 - reasonable line names as they describe what the line is used for. "GPIO0" 163 - is not a good name to give to a GPIO line. Placeholders are discouraged: 164 - rather use the "" (blank string) if the use of the GPIO line is undefined 165 - in your design. The names are assigned starting from line offset 0 from 166 - left to right from the passed array. An incomplete array (where the number 167 - of passed named are less than ngpios) will still be used up until the last 168 - provided valid line index. 157 + GPIO controller. 158 + 159 + For lines which are routed to on-board devices, this name should be 160 + the most meaningful producer name for the system, such as a rail name 161 + indicating the usage. Package names, such as a pin name, are discouraged: 162 + such lines have opaque names (since they are by definition general-purpose) 163 + and such names are usually not very helpful. For example "MMC-CD", "Red LED 164 + Vdd" and "ethernet reset" are reasonable line names as they describe what 165 + the line is used for. "GPIO0" is not a good name to give to a GPIO line 166 + that is hard-wired to a specific device. 167 + 168 + However, in the case of lines that are routed to a general purpose header 169 + (e.g. the Raspberry Pi 40-pin header), and therefore are not hard-wired to 170 + specific devices, using a pin number or the names on the header is fine 171 + provided these are real (preferably unique) names. Using an SoC's pad name 172 + or package name, or names made up from kernel-internal software constructs, 173 + are strongly discouraged. For example "pin8 [gpio14/uart0_txd]" is fine 174 + if the board's documentation labels pin 8 as such. However "PortB_24" (an 175 + example of a name from an SoC's reference manual) would not be desirable. 176 + 177 + In either case placeholders are discouraged: rather use the "" (blank 178 + string) if the use of the GPIO line is undefined in your design. Ideally, 179 + try to add comments to the dts file describing the naming the convention 180 + you have chosen, and specifying from where the names are derived. 181 + 182 + The names are assigned starting from line offset 0, from left to right, 183 + from the passed array. An incomplete array (where the number of passed 184 + names is less than ngpios) will be used up until the last provided valid 185 + line index. 169 186 170 187 Example: 171 188
+126
Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/loongson,ls-gpio.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Loongson GPIO controller. 8 + 9 + maintainers: 10 + - Yinbo Zhu <zhuyinbo@loongson.cn> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - loongson,ls2k-gpio 16 + - loongson,ls7a-gpio 17 + 18 + reg: 19 + maxItems: 1 20 + 21 + ngpios: 22 + minimum: 1 23 + maximum: 64 24 + 25 + "#gpio-cells": 26 + const: 2 27 + 28 + gpio-controller: true 29 + 30 + gpio-ranges: true 31 + 32 + interrupts: 33 + minItems: 1 34 + maxItems: 64 35 + 36 + required: 37 + - compatible 38 + - reg 39 + - ngpios 40 + - "#gpio-cells" 41 + - gpio-controller 42 + - gpio-ranges 43 + - interrupts 44 + 45 + additionalProperties: false 46 + 47 + examples: 48 + - | 49 + #include <dt-bindings/interrupt-controller/irq.h> 50 + 51 + gpio0: gpio@1fe00500 { 52 + compatible = "loongson,ls2k-gpio"; 53 + reg = <0x1fe00500 0x38>; 54 + ngpios = <64>; 55 + #gpio-cells = <2>; 56 + gpio-controller; 57 + gpio-ranges = <&pctrl 0 0 15>, 58 + <&pctrl 16 16 15>, 59 + <&pctrl 32 32 10>, 60 + <&pctrl 44 44 20>; 61 + interrupt-parent = <&liointc1>; 62 + interrupts = <28 IRQ_TYPE_LEVEL_LOW>, 63 + <29 IRQ_TYPE_LEVEL_LOW>, 64 + <30 IRQ_TYPE_LEVEL_LOW>, 65 + <30 IRQ_TYPE_LEVEL_LOW>, 66 + <26 IRQ_TYPE_LEVEL_LOW>, 67 + <26 IRQ_TYPE_LEVEL_LOW>, 68 + <26 IRQ_TYPE_LEVEL_LOW>, 69 + <26 IRQ_TYPE_LEVEL_LOW>, 70 + <26 IRQ_TYPE_LEVEL_LOW>, 71 + <26 IRQ_TYPE_LEVEL_LOW>, 72 + <26 IRQ_TYPE_LEVEL_LOW>, 73 + <26 IRQ_TYPE_LEVEL_LOW>, 74 + <26 IRQ_TYPE_LEVEL_LOW>, 75 + <26 IRQ_TYPE_LEVEL_LOW>, 76 + <26 IRQ_TYPE_LEVEL_LOW>, 77 + <>, 78 + <26 IRQ_TYPE_LEVEL_LOW>, 79 + <26 IRQ_TYPE_LEVEL_LOW>, 80 + <26 IRQ_TYPE_LEVEL_LOW>, 81 + <26 IRQ_TYPE_LEVEL_LOW>, 82 + <26 IRQ_TYPE_LEVEL_LOW>, 83 + <26 IRQ_TYPE_LEVEL_LOW>, 84 + <26 IRQ_TYPE_LEVEL_LOW>, 85 + <26 IRQ_TYPE_LEVEL_LOW>, 86 + <26 IRQ_TYPE_LEVEL_LOW>, 87 + <26 IRQ_TYPE_LEVEL_LOW>, 88 + <26 IRQ_TYPE_LEVEL_LOW>, 89 + <26 IRQ_TYPE_LEVEL_LOW>, 90 + <26 IRQ_TYPE_LEVEL_LOW>, 91 + <26 IRQ_TYPE_LEVEL_LOW>, 92 + <26 IRQ_TYPE_LEVEL_LOW>, 93 + <26 IRQ_TYPE_LEVEL_LOW>, 94 + <27 IRQ_TYPE_LEVEL_LOW>, 95 + <27 IRQ_TYPE_LEVEL_LOW>, 96 + <27 IRQ_TYPE_LEVEL_LOW>, 97 + <27 IRQ_TYPE_LEVEL_LOW>, 98 + <27 IRQ_TYPE_LEVEL_LOW>, 99 + <>, 100 + <27 IRQ_TYPE_LEVEL_LOW>, 101 + <27 IRQ_TYPE_LEVEL_LOW>, 102 + <27 IRQ_TYPE_LEVEL_LOW>, 103 + <27 IRQ_TYPE_LEVEL_LOW>, 104 + <>, 105 + <>, 106 + <27 IRQ_TYPE_LEVEL_LOW>, 107 + <27 IRQ_TYPE_LEVEL_LOW>, 108 + <27 IRQ_TYPE_LEVEL_LOW>, 109 + <27 IRQ_TYPE_LEVEL_LOW>, 110 + <27 IRQ_TYPE_LEVEL_LOW>, 111 + <27 IRQ_TYPE_LEVEL_LOW>, 112 + <27 IRQ_TYPE_LEVEL_LOW>, 113 + <27 IRQ_TYPE_LEVEL_LOW>, 114 + <27 IRQ_TYPE_LEVEL_LOW>, 115 + <27 IRQ_TYPE_LEVEL_LOW>, 116 + <27 IRQ_TYPE_LEVEL_LOW>, 117 + <27 IRQ_TYPE_LEVEL_LOW>, 118 + <27 IRQ_TYPE_LEVEL_LOW>, 119 + <27 IRQ_TYPE_LEVEL_LOW>, 120 + <27 IRQ_TYPE_LEVEL_LOW>, 121 + <27 IRQ_TYPE_LEVEL_LOW>, 122 + <27 IRQ_TYPE_LEVEL_LOW>, 123 + <27 IRQ_TYPE_LEVEL_LOW>, 124 + <27 IRQ_TYPE_LEVEL_LOW>, 125 + <27 IRQ_TYPE_LEVEL_LOW>; 126 + };
+49
Documentation/devicetree/bindings/gpio/loongson,ls1x-gpio.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/loongson,ls1x-gpio.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Loongson-1 GPIO controller 8 + 9 + maintainers: 10 + - Keguang Zhang <keguang.zhang@gmail.com> 11 + 12 + properties: 13 + compatible: 14 + const: loongson,ls1x-gpio 15 + 16 + reg: 17 + maxItems: 1 18 + 19 + gpio-controller: true 20 + 21 + "#gpio-cells": 22 + const: 2 23 + 24 + ngpios: 25 + minimum: 1 26 + maximum: 32 27 + 28 + required: 29 + - compatible 30 + - reg 31 + - gpio-controller 32 + - "#gpio-cells" 33 + - ngpios 34 + 35 + additionalProperties: false 36 + 37 + examples: 38 + - | 39 + gpio0: gpio@1fd010c0 { 40 + compatible = "loongson,ls1x-gpio"; 41 + reg = <0x1fd010c0 0x4>; 42 + 43 + gpio-controller; 44 + #gpio-cells = <2>; 45 + 46 + ngpios = <32>; 47 + }; 48 + 49 + ...
+4 -4
Documentation/driver-api/gpio/driver.rst
··· 218 218 use a trick: when a line is set as output, if the line is flagged as open 219 219 drain, and the IN output value is low, it will be driven low as usual. But 220 220 if the IN output value is set to high, it will instead *NOT* be driven high, 221 - instead it will be switched to input, as input mode is high impedance, thus 222 - achieving an "open drain emulation" of sorts: electrically the behaviour will 223 - be identical, with the exception of possible hardware glitches when switching 224 - the mode of the line. 221 + instead it will be switched to input, as input mode is an equivalent to 222 + high impedance, thus achieving an "open drain emulation" of sorts: electrically 223 + the behaviour will be identical, with the exception of possible hardware glitches 224 + when switching the mode of the line. 225 225 226 226 For open source configuration the same principle is used, just that instead 227 227 of actively driving the line low, it is set to input.
-23
Documentation/driver-api/gpio/legacy.rst
··· 238 238 ## gpio_free_array() 239 239 240 240 gpio_free() 241 - gpio_set_debounce() 242 - 243 241 244 242 245 243 Claiming and Releasing GPIOs ··· 712 714 or other cards in the stack. In such cases, you may need to use the 713 715 gpiochip nodes (possibly in conjunction with schematics) to determine 714 716 the correct GPIO number to use for a given signal. 715 - 716 - 717 - Exporting from Kernel code 718 - -------------------------- 719 - Kernel code can explicitly manage exports of GPIOs which have already been 720 - requested using gpio_request():: 721 - 722 - /* export the GPIO to userspace */ 723 - int gpio_export(unsigned gpio, bool direction_may_change); 724 - 725 - /* reverse gpio_export() */ 726 - void gpio_unexport(); 727 - 728 - After a kernel driver requests a GPIO, it may only be made available in 729 - the sysfs interface by gpio_export(). The driver can control whether the 730 - signal direction may change. This helps drivers prevent userspace code 731 - from accidentally clobbering important system state. 732 - 733 - This explicit exporting can help with debugging (by making some kinds 734 - of experiments easier), or can provide an always-there interface that's 735 - suitable for documenting as part of a board support package. 736 717 737 718 738 719 API Reference
-20
Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
··· 219 219 ## gpio_free_array() 220 220 221 221 gpio_free() 222 - gpio_set_debounce() 223 222 224 223 225 224 ··· 651 652 固定的,例如在扩展卡上的 GPIO会根据所使用的主板或所在堆叠架构中其他的板子而 652 653 有所不同。在这种情况下,你可能需要使用 gpiochip 节点(尽可能地结合电路图)来 653 654 确定给定信号所用的 GPIO 编号。 654 - 655 - 656 - 从内核代码中导出 657 - ---------------- 658 - 659 - 内核代码可以明确地管理那些已通过 gpio_request()申请的 GPIO 的导出:: 660 - 661 - /* 导出 GPIO 到用户空间 */ 662 - int gpio_export(unsigned gpio, bool direction_may_change); 663 - 664 - /* gpio_export()的逆操作 */ 665 - void gpio_unexport(); 666 - 667 - 在一个内核驱动申请一个 GPIO 之后,它可以通过 gpio_export()使其在 sysfs 668 - 接口中可见。该驱动可以控制信号方向是否可修改。这有助于防止用户空间代码无意间 669 - 破坏重要的系统状态。 670 - 671 - 这个明确的导出有助于(通过使某些实验更容易来)调试,也可以提供一个始终存在的接口, 672 - 与文档配合作为板级支持包的一部分。 673 655 674 656 675 657 API参考
-19
Documentation/translations/zh_TW/gpio.txt
··· 226 226 ## gpio_free_array() 227 227 228 228 gpio_free() 229 - gpio_set_debounce() 230 229 231 230 232 231 ··· 614 615 固定的,例如在擴展卡上的 GPIO會根據所使用的主板或所在堆疊架構中其他的板子而 615 616 有所不同。在這種情況下,你可能需要使用 gpiochip 節點(儘可能地結合電路圖)來 616 617 確定給定信號所用的 GPIO 編號。 617 - 618 - 619 - 從內核代碼中導出 620 - ------------- 621 - 內核代碼可以明確地管理那些已通過 gpio_request()申請的 GPIO 的導出: 622 - 623 - /* 導出 GPIO 到用戶空間 */ 624 - int gpio_export(unsigned gpio, bool direction_may_change); 625 - 626 - /* gpio_export()的逆操作 */ 627 - void gpio_unexport(); 628 - 629 - 在一個內核驅動申請一個 GPIO 之後,它可以通過 gpio_export()使其在 sysfs 630 - 接口中可見。該驅動可以控制信號方向是否可修改。這有助於防止用戶空間代碼無意間 631 - 破壞重要的系統狀態。 632 - 633 - 這個明確的導出有助於(通過使某些實驗更容易來)調試,也可以提供一個始終存在的接口, 634 - 與文檔配合作爲板級支持包的一部分。
+9 -2
MAINTAINERS
··· 8762 8762 F: Documentation/devicetree/bindings/gpio/ 8763 8763 F: Documentation/driver-api/gpio/ 8764 8764 F: drivers/gpio/ 8765 - F: include/asm-generic/gpio.h 8766 8765 F: include/dt-bindings/gpio/ 8767 8766 F: include/linux/gpio.h 8768 8767 F: include/linux/gpio/ ··· 10291 10292 L: linux-gpio@vger.kernel.org 10292 10293 S: Supported 10293 10294 T: git git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel.git 10295 + F: drivers/gpio/gpio-elkhartlake.c 10294 10296 F: drivers/gpio/gpio-ich.c 10295 10297 F: drivers/gpio/gpio-merrifield.c 10296 10298 F: drivers/gpio/gpio-ml-ioh.c 10297 10299 F: drivers/gpio/gpio-pch.c 10298 10300 F: drivers/gpio/gpio-sch.c 10299 10301 F: drivers/gpio/gpio-sodaville.c 10302 + F: drivers/gpio/gpio-tangier.c 10300 10303 10301 10304 INTEL GVT-g DRIVERS (Intel GPU Virtualization) 10302 10305 M: Zhenyu Wang <zhenyuw@linux.intel.com> ··· 12126 12125 S: Maintained 12127 12126 F: Documentation/devicetree/bindings/pinctrl/loongson,ls2k-pinctrl.yaml 12128 12127 F: drivers/pinctrl/pinctrl-loongson2.c 12128 + 12129 + LOONGSON GPIO DRIVER 12130 + M: Yinbo Zhu <zhuyinbo@loongson.cn> 12131 + L: linux-gpio@vger.kernel.org 12132 + S: Maintained 12133 + F: Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml 12134 + F: drivers/gpio/gpio-loongson-64bit.c 12129 12135 12130 12136 LOONGSON-2 SOC SERIES CLOCK DRIVER 12131 12137 M: Yinbo Zhu <zhuyinbo@loongson.cn> ··· 23083 23075 23084 23076 XRA1403 GPIO EXPANDER 23085 23077 M: Nandor Han <nandor.han@ge.com> 23086 - M: Semi Malinen <semi.malinen@ge.com> 23087 23078 L: linux-gpio@vger.kernel.org 23088 23079 S: Maintained 23089 23080 F: Documentation/devicetree/bindings/gpio/gpio-xra1403.txt
-1
arch/arm/Kconfig
··· 24 24 select ARCH_HAS_SYNC_DMA_FOR_CPU 25 25 select ARCH_HAS_TEARDOWN_DMA_OPS if MMU 26 26 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST 27 - select ARCH_HAVE_CUSTOM_GPIO_H 28 27 select ARCH_HAVE_NMI_SAFE_CMPXCHG if CPU_V7 || CPU_V7M || CPU_V6K 29 28 select ARCH_HAS_GCOV_PROFILE_ALL 30 29 select ARCH_KEEP_MEMBLOCK
-21
arch/arm/include/asm/gpio.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ARCH_ARM_GPIO_H 3 - #define _ARCH_ARM_GPIO_H 4 - 5 - #include <asm-generic/gpio.h> 6 - 7 - /* The trivial gpiolib dispatchers */ 8 - #define gpio_get_value __gpio_get_value 9 - #define gpio_set_value __gpio_set_value 10 - #define gpio_cansleep __gpio_cansleep 11 - 12 - /* 13 - * Provide a default gpio_to_irq() which should satisfy every case. 14 - * However, some platforms want to do this differently, so allow them 15 - * to override it. 16 - */ 17 - #ifndef gpio_to_irq 18 - #define gpio_to_irq __gpio_to_irq 19 - #endif 20 - 21 - #endif /* _ARCH_ARM_GPIO_H */
+1
arch/arm/mach-omap1/irq.c
··· 41 41 #include <linux/sched.h> 42 42 #include <linux/interrupt.h> 43 43 #include <linux/io.h> 44 + #include <linux/irqdomain.h> 44 45 45 46 #include <asm/irq.h> 46 47 #include <asm/exception.h>
+5 -4
arch/arm/mach-omap2/pdata-quirks.c
··· 6 6 */ 7 7 #include <linux/clk.h> 8 8 #include <linux/davinci_emac.h> 9 + #include <linux/gpio/consumer.h> 9 10 #include <linux/gpio.h> 10 11 #include <linux/init.h> 11 12 #include <linux/kernel.h> ··· 109 108 if (res) 110 109 return res; 111 110 112 - gpio_export(gpio, 0); 111 + gpiod_export(gpio_to_desc(gpio), 0); 113 112 114 113 return 0; 115 114 } ··· 124 123 return; 125 124 } 126 125 127 - gpio_export(gpio, 0); 126 + gpiod_export(gpio_to_desc(gpio), 0); 128 127 129 128 udelay(10); 130 129 gpio_set_value(gpio, 1); ··· 201 200 return; 202 201 } 203 202 204 - gpio_export(cm_t3517_wlan_gpios[0].gpio, 0); 205 - gpio_export(cm_t3517_wlan_gpios[1].gpio, 0); 203 + gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[0].gpio), 0); 204 + gpiod_export(gpio_to_desc(cm_t3517_wlan_gpios[1].gpio), 0); 206 205 207 206 msleep(100); 208 207 gpio_set_value(cm_t3517_wlan_gpios[1].gpio, 0);
+1
arch/arm/mach-orion5x/board-rd88f5182.c
··· 9 9 #include <linux/gpio.h> 10 10 #include <linux/kernel.h> 11 11 #include <linux/init.h> 12 + #include <linux/of.h> 12 13 #include <linux/platform_device.h> 13 14 #include <linux/pci.h> 14 15 #include <linux/irq.h>
+1 -1
arch/arm/mach-s3c/s3c64xx.c
··· 21 21 #include <linux/ioport.h> 22 22 #include <linux/serial_core.h> 23 23 #include <linux/serial_s3c.h> 24 + #include <linux/of.h> 24 25 #include <linux/platform_device.h> 25 26 #include <linux/reboot.h> 26 27 #include <linux/io.h> 27 28 #include <linux/clk/samsung.h> 28 29 #include <linux/dma-mapping.h> 29 30 #include <linux/irq.h> 30 - #include <linux/gpio.h> 31 31 #include <linux/irqchip/arm-vic.h> 32 32 #include <clocksource/samsung_pwm.h> 33 33
+1
arch/arm/mach-sa1100/assabet.c
··· 10 10 #include <linux/kernel.h> 11 11 #include <linux/module.h> 12 12 #include <linux/errno.h> 13 + #include <linux/gpio/driver.h> 13 14 #include <linux/gpio/gpio-reg.h> 14 15 #include <linux/gpio/machine.h> 15 16 #include <linux/gpio_keys.h>
+3 -2
arch/arm/plat-orion/gpio.c
··· 18 18 #include <linux/spinlock.h> 19 19 #include <linux/bitops.h> 20 20 #include <linux/io.h> 21 - #include <linux/gpio.h> 21 + #include <linux/gpio/driver.h> 22 + #include <linux/gpio/consumer.h> 22 23 #include <linux/leds.h> 23 24 #include <linux/of.h> 24 25 #include <linux/of_irq.h> ··· 313 312 case GPIO_LED_NO_BLINK_LOW: 314 313 case GPIO_LED_NO_BLINK_HIGH: 315 314 orion_gpio_set_blink(gpio, 0); 316 - gpio_set_value(gpio, state); 315 + gpiod_set_raw_value(desc, state); 317 316 break; 318 317 case GPIO_LED_BLINK: 319 318 orion_gpio_set_blink(gpio, 1);
-1
arch/m68k/Kconfig.cpu
··· 24 24 25 25 config COLDFIRE 26 26 bool "Coldfire CPU family support" 27 - select ARCH_HAVE_CUSTOM_GPIO_H 28 27 select CPU_HAS_NO_BITFIELDS 29 28 select CPU_HAS_NO_CAS 30 29 select CPU_HAS_NO_MULDIV64
-95
arch/m68k/include/asm/gpio.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * Coldfire generic GPIO support 4 - * 5 - * (C) Copyright 2009, Steven King <sfking@fdwdc.com> 6 - */ 7 - 8 - #ifndef coldfire_gpio_h 9 - #define coldfire_gpio_h 10 - 11 - #include <linux/io.h> 12 - #include <asm/coldfire.h> 13 - #include <asm/mcfsim.h> 14 - #include <asm/mcfgpio.h> 15 - /* 16 - * The Generic GPIO functions 17 - * 18 - * If the gpio is a compile time constant and is one of the Coldfire gpios, 19 - * use the inline version, otherwise dispatch thru gpiolib. 20 - */ 21 - 22 - static inline int gpio_get_value(unsigned gpio) 23 - { 24 - if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX) 25 - return mcfgpio_read(__mcfgpio_ppdr(gpio)) & mcfgpio_bit(gpio); 26 - else 27 - return __gpio_get_value(gpio); 28 - } 29 - 30 - static inline void gpio_set_value(unsigned gpio, int value) 31 - { 32 - if (__builtin_constant_p(gpio) && gpio < MCFGPIO_PIN_MAX) { 33 - if (gpio < MCFGPIO_SCR_START) { 34 - unsigned long flags; 35 - MCFGPIO_PORTTYPE data; 36 - 37 - local_irq_save(flags); 38 - data = mcfgpio_read(__mcfgpio_podr(gpio)); 39 - if (value) 40 - data |= mcfgpio_bit(gpio); 41 - else 42 - data &= ~mcfgpio_bit(gpio); 43 - mcfgpio_write(data, __mcfgpio_podr(gpio)); 44 - local_irq_restore(flags); 45 - } else { 46 - if (value) 47 - mcfgpio_write(mcfgpio_bit(gpio), 48 - MCFGPIO_SETR_PORT(gpio)); 49 - else 50 - mcfgpio_write(~mcfgpio_bit(gpio), 51 - MCFGPIO_CLRR_PORT(gpio)); 52 - } 53 - } else 54 - __gpio_set_value(gpio, value); 55 - } 56 - 57 - static inline int gpio_to_irq(unsigned gpio) 58 - { 59 - #if defined(MCFGPIO_IRQ_MIN) 60 - if ((gpio >= MCFGPIO_IRQ_MIN) && (gpio < MCFGPIO_IRQ_MAX)) 61 - #else 62 - if (gpio < MCFGPIO_IRQ_MAX) 63 - #endif 64 - return gpio + MCFGPIO_IRQ_VECBASE; 65 - else 66 - return __gpio_to_irq(gpio); 67 - } 68 - 69 - static inline int gpio_cansleep(unsigned gpio) 70 - { 71 - return gpio < MCFGPIO_PIN_MAX ? 0 : __gpio_cansleep(gpio); 72 - } 73 - 74 - #ifndef CONFIG_GPIOLIB 75 - static inline int gpio_request_one(unsigned gpio, unsigned long flags, const char *label) 76 - { 77 - int err; 78 - 79 - err = gpio_request(gpio, label); 80 - if (err) 81 - return err; 82 - 83 - if (flags & GPIOF_DIR_IN) 84 - err = gpio_direction_input(gpio); 85 - else 86 - err = gpio_direction_output(gpio, 87 - (flags & GPIOF_INIT_HIGH) ? 1 : 0); 88 - 89 - if (err) 90 - gpio_free(gpio); 91 - 92 - return err; 93 - } 94 - #endif /* !CONFIG_GPIOLIB */ 95 - #endif
+1 -1
arch/m68k/include/asm/mcfgpio.h
··· 9 9 #define mcfgpio_h 10 10 11 11 #ifdef CONFIG_GPIOLIB 12 - #include <asm-generic/gpio.h> 12 + #include <linux/gpio.h> 13 13 #else 14 14 15 15 int __mcfgpio_get_value(unsigned gpio);
+1 -1
arch/mips/ar7/gpio.c
··· 7 7 8 8 #include <linux/init.h> 9 9 #include <linux/export.h> 10 - #include <linux/gpio.h> 10 + #include <linux/gpio/driver.h> 11 11 12 12 #include <asm/mach-ar7/ar7.h> 13 13
+1
arch/powerpc/platforms/40x/Kconfig
··· 65 65 bool "PPC4xx GPIO support" 66 66 depends on 40x 67 67 select GPIOLIB 68 + select OF_GPIO_MM_GPIOCHIP 68 69 help 69 70 Enable gpiolib support for ppc40x based boards 70 71
+1
arch/powerpc/platforms/44x/Kconfig
··· 230 230 bool "PPC4xx GPIO support" 231 231 depends on 44x 232 232 select GPIOLIB 233 + select OF_GPIO_MM_GPIOCHIP 233 234 help 234 235 Enable gpiolib support for ppc440 based boards 235 236
+1 -1
arch/powerpc/platforms/4xx/gpio.c
··· 14 14 #include <linux/spinlock.h> 15 15 #include <linux/io.h> 16 16 #include <linux/of.h> 17 - #include <linux/of_gpio.h> 17 + #include <linux/gpio/legacy-of-mm-gpiochip.h> 18 18 #include <linux/gpio/driver.h> 19 19 #include <linux/types.h> 20 20 #include <linux/slab.h>
+1
arch/powerpc/platforms/8xx/Kconfig
··· 101 101 config 8xx_GPIO 102 102 bool "GPIO API Support" 103 103 select GPIOLIB 104 + select OF_GPIO_MM_GPIOCHIP 104 105 help 105 106 Saying Y here will cause the ports on an MPC8xx processor to be used 106 107 with the GPIO API. If you say N here, the kernel needs less memory.
+1 -1
arch/powerpc/platforms/8xx/cpm1.c
··· 44 44 #include <asm/fs_pd.h> 45 45 46 46 #ifdef CONFIG_8xx_GPIO 47 - #include <linux/of_gpio.h> 47 + #include <linux/gpio/legacy-of-mm-gpiochip.h> 48 48 #endif 49 49 50 50 #define CPM_MAP_SIZE (0x4000)
+2
arch/powerpc/platforms/Kconfig
··· 244 244 bool "QE GPIO support" 245 245 depends on QUICC_ENGINE 246 246 select GPIOLIB 247 + select OF_GPIO_MM_GPIOCHIP 247 248 help 248 249 Say Y here if you're going to use hardware that connects to the 249 250 QE GPIOs. ··· 255 254 select CPM 256 255 select HAVE_PCI 257 256 select GPIOLIB 257 + select OF_GPIO_MM_GPIOCHIP 258 258 help 259 259 The CPM2 (Communications Processor Module) is a coprocessor on 260 260 embedded CPUs made by Freescale. Selecting this option means that
+1 -1
arch/powerpc/sysdev/cpm_common.c
··· 31 31 #include <mm/mmu_decl.h> 32 32 33 33 #if defined(CONFIG_CPM2) || defined(CONFIG_8xx_GPIO) 34 - #include <linux/of_gpio.h> 34 + #include <linux/gpio/legacy-of-mm-gpiochip.h> 35 35 #endif 36 36 37 37 static int __init cpm_init(void)
-1
arch/sh/Kconfig
··· 4 4 select ARCH_32BIT_OFF_T 5 5 select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM && MMU 6 6 select ARCH_ENABLE_MEMORY_HOTREMOVE if SPARSEMEM && MMU 7 - select ARCH_HAVE_CUSTOM_GPIO_H 8 7 select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A) 9 8 select ARCH_HAS_BINFMT_FLAT if !MMU 10 9 select ARCH_HAS_CURRENT_STACK_POINTER
+1
arch/sh/boards/board-magicpanelr2.c
··· 21 21 #include <linux/sh_intc.h> 22 22 #include <mach/magicpanelr2.h> 23 23 #include <asm/heartbeat.h> 24 + #include <cpu/gpio.h> 24 25 #include <cpu/sh7720.h> 25 26 26 27 /* Dummy supplies, where voltage doesn't matter */
+4 -3
arch/sh/boards/mach-ap325rxa/setup.c
··· 18 18 #include <linux/delay.h> 19 19 #include <linux/device.h> 20 20 #include <linux/gpio.h> 21 + #include <linux/gpio/consumer.h> 21 22 #include <linux/gpio/machine.h> 22 23 #include <linux/i2c.h> 23 24 #include <linux/init.h> ··· 412 411 /* LD3 and LD4 LEDs */ 413 412 gpio_request(GPIO_PTX5, NULL); /* RUN */ 414 413 gpio_direction_output(GPIO_PTX5, 1); 415 - gpio_export(GPIO_PTX5, 0); 414 + gpiod_export(gpio_to_desc(GPIO_PTX5), 0); 416 415 417 416 gpio_request(GPIO_PTX4, NULL); /* INDICATOR */ 418 417 gpio_direction_output(GPIO_PTX4, 0); 419 - gpio_export(GPIO_PTX4, 0); 418 + gpiod_export(gpio_to_desc(GPIO_PTX4), 0); 420 419 421 420 /* SW1 input */ 422 421 gpio_request(GPIO_PTF7, NULL); /* MODE */ 423 422 gpio_direction_input(GPIO_PTF7); 424 - gpio_export(GPIO_PTF7, 0); 423 + gpiod_export(gpio_to_desc(GPIO_PTF7), 0); 425 424 426 425 /* LCDC */ 427 426 gpio_request(GPIO_FN_LCDD15, NULL);
+1 -1
arch/sh/boards/mach-x3proto/setup.c
··· 16 16 #include <linux/input.h> 17 17 #include <linux/usb/r8a66597.h> 18 18 #include <linux/usb/m66592.h> 19 - #include <linux/gpio.h> 19 + #include <linux/gpio/driver.h> 20 20 #include <linux/gpio_keys.h> 21 21 #include <mach/ilsel.h> 22 22 #include <mach/hardware.h>
-45
arch/sh/include/asm/gpio.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 2 - * 3 - * include/asm-sh/gpio.h 4 - * 5 - * Generic GPIO API and pinmux table support for SuperH. 6 - * 7 - * Copyright (c) 2008 Magnus Damm 8 - */ 9 - #ifndef __ASM_SH_GPIO_H 10 - #define __ASM_SH_GPIO_H 11 - 12 - #include <linux/kernel.h> 13 - #include <linux/errno.h> 14 - 15 - #if defined(CONFIG_CPU_SH3) 16 - #include <cpu/gpio.h> 17 - #endif 18 - 19 - #include <asm-generic/gpio.h> 20 - 21 - #ifdef CONFIG_GPIOLIB 22 - 23 - static inline int gpio_get_value(unsigned gpio) 24 - { 25 - return __gpio_get_value(gpio); 26 - } 27 - 28 - static inline void gpio_set_value(unsigned gpio, int value) 29 - { 30 - __gpio_set_value(gpio, value); 31 - } 32 - 33 - static inline int gpio_cansleep(unsigned gpio) 34 - { 35 - return __gpio_cansleep(gpio); 36 - } 37 - 38 - static inline int gpio_to_irq(unsigned gpio) 39 - { 40 - return __gpio_to_irq(gpio); 41 - } 42 - 43 - #endif /* CONFIG_GPIOLIB */ 44 - 45 - #endif /* __ASM_SH_GPIO_H */
+64 -17
drivers/gpio/Kconfig
··· 3 3 # GPIO infrastructure and drivers 4 4 # 5 5 6 - config ARCH_HAVE_CUSTOM_GPIO_H 7 - bool 8 - help 9 - Selecting this config option from the architecture Kconfig allows 10 - the architecture to provide a custom asm/gpio.h implementation 11 - overriding the default implementations. New uses of this are 12 - strongly discouraged. 13 - 14 6 menuconfig GPIOLIB 15 7 bool "GPIO Support" 16 8 help ··· 38 46 config GPIOLIB_IRQCHIP 39 47 select IRQ_DOMAIN 40 48 bool 49 + 50 + config OF_GPIO_MM_GPIOCHIP 51 + bool 52 + help 53 + This adds support for the legacy 'struct of_mm_gpio_chip' interface 54 + from PowerPC. Existing drivers using this interface need to select 55 + this symbol, but new drivers should use the generic gpio-regmap 56 + infrastructure instead. 41 57 42 58 config DEBUG_GPIO 43 59 bool "Debug GPIO calls" ··· 139 139 tristate "Altera GPIO" 140 140 depends on OF_GPIO 141 141 select GPIOLIB_IRQCHIP 142 + select OF_GPIO_MM_GPIOCHIP 142 143 help 143 144 Say Y or M here to build support for the Altera PIO device. 144 145 ··· 381 380 help 382 381 Driver for GPIO functionality on Loongson-2F/3A/3B processors. 383 382 383 + config GPIO_LOONGSON_64BIT 384 + tristate "Loongson 64 bit GPIO support" 385 + depends on LOONGARCH || COMPILE_TEST 386 + depends on OF_GPIO 387 + select GPIO_GENERIC 388 + help 389 + Say yes here to support the GPIO functionality of a number of 390 + Loongson series of chips. The Loongson GPIO controller supports 391 + up to 60 GPIOS in total, 4 of which are dedicated GPIO pins, and 392 + the remaining 56 are reused with other functions, with edge or 393 + level triggered interrupts. 394 + 384 395 config GPIO_LPC18XX 385 396 tristate "NXP LPC18XX/43XX GPIO support" 386 397 default y if ARCH_LPC18XX ··· 424 411 config GPIO_MM_LANTIQ 425 412 bool "Lantiq Memory mapped GPIOs" 426 413 depends on LANTIQ && SOC_XWAY 414 + select OF_GPIO_MM_GPIOCHIP 427 415 help 428 416 This enables support for memory mapped GPIOs on the External Bus Unit 429 417 (EBU) found on Lantiq SoCs. The GPIOs are output only as they are ··· 433 419 config GPIO_MPC5200 434 420 def_bool y 435 421 depends on PPC_MPC52xx 422 + select OF_GPIO_MM_GPIOCHIP 436 423 437 424 config GPIO_MPC8XXX 438 425 bool "MPC512x/MPC8xxx/QorIQ GPIO support" ··· 499 484 select GPIOLIB_IRQCHIP 500 485 help 501 486 Say yes here to support the PrimeCell PL061 GPIO device. 502 - 503 - config GPIO_PMIC_EIC_SPRD 504 - tristate "Spreadtrum PMIC EIC support" 505 - depends on MFD_SC27XX_PMIC || COMPILE_TEST 506 - depends on OF_GPIO 507 - select GPIOLIB_IRQCHIP 508 - help 509 - Say yes here to support Spreadtrum PMIC EIC device. 510 487 511 488 config GPIO_PXA 512 489 bool "PXA GPIO support" ··· 622 615 depends on MFD_SYSCON && OF 623 616 help 624 617 Say yes here to support GPIO functionality though SYSCON driver. 618 + 619 + config GPIO_TANGIER 620 + tristate 621 + select GPIOLIB_IRQCHIP 622 + help 623 + GPIO support for Intel Tangier and compatible platforms. 624 + Currently supported: 625 + - Elkhart Lake 626 + - Merrifield 627 + 628 + If built as a module its name will be gpio-tangier. 625 629 626 630 config GPIO_TB10X 627 631 bool ··· 1018 1000 enough to represent all pins, but the driver will assume a 1019 1001 register layout for 64 pins (8 registers). 1020 1002 1003 + config GPIO_FXL6408 1004 + tristate "FXL6408 I2C GPIO expander" 1005 + select GPIO_REGMAP 1006 + select REGMAP_I2C 1007 + help 1008 + GPIO driver for Fairchild Semiconductor FXL6408 GPIO expander. 1009 + 1010 + To compile this driver as a module, choose M here: the module will 1011 + be called gpio-fxl6408. 1012 + 1021 1013 config GPIO_GW_PLD 1022 1014 tristate "Gateworks PLD GPIO Expander" 1023 1015 depends on OF_GPIO ··· 1263 1235 several HTC phones. It provides basic support for input 1264 1236 pins, output pins, and IRQs. 1265 1237 1238 + config GPIO_ELKHARTLAKE 1239 + tristate "Intel Elkhart Lake PSE GPIO support" 1240 + depends on X86 || COMPILE_TEST 1241 + select GPIO_TANGIER 1242 + help 1243 + Select this option to enable GPIO support for Intel Elkhart Lake 1244 + PSE GPIO IP. 1245 + 1246 + To compile this driver as a module, choose M here: the module will 1247 + be called gpio-elkhartlake. 1248 + 1266 1249 config GPIO_JANZ_TTL 1267 1250 tristate "Janz VMOD-TTL Digital IO Module" 1268 1251 depends on MFD_JANZ_CMODIO ··· 1349 1310 help 1350 1311 Select this option to enable GPIO driver for the TI PALMAS 1351 1312 series chip family. 1313 + 1314 + config GPIO_PMIC_EIC_SPRD 1315 + tristate "Spreadtrum PMIC EIC support" 1316 + depends on MFD_SC27XX_PMIC || COMPILE_TEST 1317 + depends on OF_GPIO 1318 + select GPIOLIB_IRQCHIP 1319 + help 1320 + Say yes here to support Spreadtrum PMIC EIC device. 1352 1321 1353 1322 config GPIO_RC5T583 1354 1323 bool "RICOH RC5T583 GPIO" ··· 1552 1505 config GPIO_MERRIFIELD 1553 1506 tristate "Intel Merrifield GPIO support" 1554 1507 depends on X86_INTEL_MID 1555 - select GPIOLIB_IRQCHIP 1508 + select GPIO_TANGIER 1556 1509 help 1557 1510 Say Y here to support Intel Merrifield GPIO. 1558 1511
+4
drivers/gpio/Makefile
··· 54 54 obj-$(CONFIG_GPIO_DLN2) += gpio-dln2.o 55 55 obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o 56 56 obj-$(CONFIG_GPIO_EIC_SPRD) += gpio-eic-sprd.o 57 + obj-$(CONFIG_GPIO_ELKHARTLAKE) += gpio-elkhartlake.o 57 58 obj-$(CONFIG_GPIO_EM) += gpio-em.o 58 59 obj-$(CONFIG_GPIO_EN7523) += gpio-en7523.o 59 60 obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o 60 61 obj-$(CONFIG_GPIO_EXAR) += gpio-exar.o 61 62 obj-$(CONFIG_GPIO_F7188X) += gpio-f7188x.o 62 63 obj-$(CONFIG_GPIO_FTGPIO010) += gpio-ftgpio010.o 64 + obj-$(CONFIG_GPIO_FXL6408) += gpio-fxl6408.o 63 65 obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o 64 66 obj-$(CONFIG_GPIO_GPIO_MM) += gpio-gpio-mm.o 65 67 obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o ··· 82 80 obj-$(CONFIG_GPIO_LOGICVC) += gpio-logicvc.o 83 81 obj-$(CONFIG_GPIO_LOONGSON1) += gpio-loongson1.o 84 82 obj-$(CONFIG_GPIO_LOONGSON) += gpio-loongson.o 83 + obj-$(CONFIG_GPIO_LOONGSON_64BIT) += gpio-loongson-64bit.o 85 84 obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o 86 85 obj-$(CONFIG_GPIO_LP873X) += gpio-lp873x.o 87 86 obj-$(CONFIG_GPIO_LP87565) += gpio-lp87565.o ··· 148 145 obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o 149 146 obj-$(CONFIG_GPIO_STP_XWAY) += gpio-stp-xway.o 150 147 obj-$(CONFIG_GPIO_SYSCON) += gpio-syscon.o 148 + obj-$(CONFIG_GPIO_TANGIER) += gpio-tangier.o 151 149 obj-$(CONFIG_GPIO_TB10X) += gpio-tb10x.o 152 150 obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o 153 151 obj-$(CONFIG_GPIO_TEGRA186) += gpio-tegra186.o
+10 -5
drivers/gpio/TODO
··· 59 59 60 60 Work items: 61 61 62 - - Get rid of struct of_mm_gpio_chip altogether: use the generic MMIO 63 - GPIO for all current users (see below). Delete struct of_mm_gpio_chip, 64 - to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove() 65 - from the kernel. 66 - 67 62 - Change all consumer drivers that #include <linux/of_gpio.h> to 68 63 #include <linux/gpio/consumer.h> and stop doing custom parsing of the 69 64 GPIO lines from the device tree. This can be tricky and often ivolves ··· 74 79 75 80 - Delete <linux/of_gpio.h> when all the above is complete and everything 76 81 uses <linux/gpio/consumer.h> or <linux/gpio/driver.h> instead. 82 + 83 + 84 + Get rid of <linux/gpio/legacy-of-mm-gpiochip.h> 85 + 86 + Work items: 87 + 88 + - Get rid of struct of_mm_gpio_chip altogether: use the generic MMIO 89 + GPIO for all current users (see below). Delete struct of_mm_gpio_chip, 90 + to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove(), 91 + CONFIG_OF_GPIO_MM_GPIOCHIP from the kernel. 77 92 78 93 79 94 Get rid of <linux/gpio.h>
+3 -8
drivers/gpio/gpio-104-dio-48e.c
··· 107 107 { 108 108 unsigned int *const irq_mask = irq_drv_data; 109 109 const unsigned int prev_mask = *irq_mask; 110 - const unsigned int all_masked = GENMASK(1, 0); 111 110 int err; 112 111 unsigned int val; 113 112 ··· 118 119 *irq_mask = mask_buf; 119 120 120 121 /* if all previously masked, enable interrupts when unmasking */ 121 - if (prev_mask == all_masked) { 122 + if (prev_mask == mask_buf_def) { 122 123 err = regmap_write(map, DIO48E_CLEAR_INTERRUPT, 0x00); 123 124 if (err) 124 125 return err; ··· 126 127 } 127 128 128 129 /* if all are currently masked, disable interrupts */ 129 - if (mask_buf == all_masked) 130 + if (mask_buf == mask_buf_def) 130 131 return regmap_read(map, DIO48E_DISABLE_INTERRUPT, &val); 131 132 132 133 return 0; ··· 195 196 return -ENOMEM; 196 197 197 198 chip->name = name; 198 - /* No IRQ status register so use CLEAR_INTERRUPT register instead */ 199 - chip->status_base = DIO48E_CLEAR_INTERRUPT; 200 199 chip->mask_base = DIO48E_ENABLE_INTERRUPT; 201 200 chip->ack_base = DIO48E_CLEAR_INTERRUPT; 202 - /* CLEAR_INTERRUPT doubles as status register so we need it cleared */ 203 - chip->clear_ack = true; 204 - chip->status_invert = true; 201 + chip->no_status = true; 205 202 chip->num_regs = 1; 206 203 chip->irqs = dio48e_regmap_irqs; 207 204 chip->num_irqs = ARRAY_SIZE(dio48e_regmap_irqs);
+7 -2
drivers/gpio/gpio-adnp.c
··· 307 307 unsigned int pos = d->hwirq & 7; 308 308 309 309 adnp->irq_enable[reg] &= ~BIT(pos); 310 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 310 311 } 311 312 312 313 static void adnp_irq_unmask(struct irq_data *d) ··· 317 316 unsigned int reg = d->hwirq >> adnp->reg_shift; 318 317 unsigned int pos = d->hwirq & 7; 319 318 319 + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 320 320 adnp->irq_enable[reg] |= BIT(pos); 321 321 } 322 322 ··· 374 372 mutex_unlock(&adnp->irq_lock); 375 373 } 376 374 377 - static struct irq_chip adnp_irq_chip = { 375 + static const struct irq_chip adnp_irq_chip = { 378 376 .name = "gpio-adnp", 379 377 .irq_mask = adnp_irq_mask, 380 378 .irq_unmask = adnp_irq_unmask, 381 379 .irq_set_type = adnp_irq_set_type, 382 380 .irq_bus_lock = adnp_irq_bus_lock, 383 381 .irq_bus_sync_unlock = adnp_irq_bus_unlock, 382 + .flags = IRQCHIP_IMMUTABLE, 383 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 384 384 }; 385 385 386 386 static int adnp_irq_setup(struct adnp *adnp) ··· 473 469 return err; 474 470 475 471 girq = &chip->irq; 476 - girq->chip = &adnp_irq_chip; 472 + gpio_irq_chip_set_chip(girq, &adnp_irq_chip); 473 + 477 474 /* This will let us handle the parent IRQ in the driver */ 478 475 girq->parent_handler = NULL; 479 476 girq->num_parents = 0;
+5 -4
drivers/gpio/gpio-aggregator.c
··· 10 10 #include <linux/bitmap.h> 11 11 #include <linux/bitops.h> 12 12 #include <linux/ctype.h> 13 - #include <linux/gpio.h> 14 - #include <linux/gpio/consumer.h> 15 - #include <linux/gpio/driver.h> 16 - #include <linux/gpio/machine.h> 17 13 #include <linux/idr.h> 18 14 #include <linux/kernel.h> 19 15 #include <linux/module.h> 20 16 #include <linux/mutex.h> 21 17 #include <linux/overflow.h> 22 18 #include <linux/platform_device.h> 19 + #include <linux/slab.h> 23 20 #include <linux/spinlock.h> 24 21 #include <linux/string.h> 22 + 23 + #include <linux/gpio/consumer.h> 24 + #include <linux/gpio/driver.h> 25 + #include <linux/gpio/machine.h> 25 26 26 27 #define AGGREGATOR_MAX_GPIOS 512 27 28
+17 -12
drivers/gpio/gpio-altera.c
··· 7 7 #include <linux/io.h> 8 8 #include <linux/module.h> 9 9 #include <linux/gpio/driver.h> 10 - #include <linux/of_gpio.h> /* For of_mm_gpio_chip */ 10 + #include <linux/gpio/legacy-of-mm-gpiochip.h> 11 11 #include <linux/platform_device.h> 12 12 13 13 #define ALTERA_GPIO_MAX_NGPIO 32 ··· 24 24 * @interrupt_trigger : specifies the hardware configured IRQ trigger type 25 25 * (rising, falling, both, high) 26 26 * @mapped_irq : kernel mapped irq number. 27 - * @irq_chip : IRQ chip configuration 28 27 */ 29 28 struct altera_gpio_chip { 30 29 struct of_mm_gpio_chip mmchip; 31 30 raw_spinlock_t gpio_lock; 32 31 int interrupt_trigger; 33 32 int mapped_irq; 34 - struct irq_chip irq_chip; 35 33 }; 36 34 37 35 static void altera_gpio_irq_unmask(struct irq_data *d) ··· 41 43 42 44 altera_gc = gpiochip_get_data(irq_data_get_irq_chip_data(d)); 43 45 mm_gc = &altera_gc->mmchip; 46 + gpiochip_enable_irq(&mm_gc->gc, irqd_to_hwirq(d)); 44 47 45 48 raw_spin_lock_irqsave(&altera_gc->gpio_lock, flags); 46 49 intmask = readl(mm_gc->regs + ALTERA_GPIO_IRQ_MASK); ··· 67 68 intmask &= ~BIT(irqd_to_hwirq(d)); 68 69 writel(intmask, mm_gc->regs + ALTERA_GPIO_IRQ_MASK); 69 70 raw_spin_unlock_irqrestore(&altera_gc->gpio_lock, flags); 71 + gpiochip_disable_irq(&mm_gc->gc, irqd_to_hwirq(d)); 70 72 } 71 73 72 74 /* ··· 233 233 chained_irq_exit(chip, desc); 234 234 } 235 235 236 + static const struct irq_chip altera_gpio_irq_chip = { 237 + .name = "altera-gpio", 238 + .irq_mask = altera_gpio_irq_mask, 239 + .irq_unmask = altera_gpio_irq_unmask, 240 + .irq_set_type = altera_gpio_irq_set_type, 241 + .irq_startup = altera_gpio_irq_startup, 242 + .irq_shutdown = altera_gpio_irq_mask, 243 + .flags = IRQCHIP_IMMUTABLE, 244 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 245 + }; 246 + 236 247 static int altera_gpio_probe(struct platform_device *pdev) 237 248 { 238 249 struct device_node *node = pdev->dev.of_node; ··· 289 278 } 290 279 altera_gc->interrupt_trigger = reg; 291 280 292 - altera_gc->irq_chip.name = "altera-gpio"; 293 - altera_gc->irq_chip.irq_mask = altera_gpio_irq_mask; 294 - altera_gc->irq_chip.irq_unmask = altera_gpio_irq_unmask; 295 - altera_gc->irq_chip.irq_set_type = altera_gpio_irq_set_type; 296 - altera_gc->irq_chip.irq_startup = altera_gpio_irq_startup; 297 - altera_gc->irq_chip.irq_shutdown = altera_gpio_irq_mask; 298 - 299 281 girq = &altera_gc->mmchip.gc.irq; 300 - girq->chip = &altera_gc->irq_chip; 282 + gpio_irq_chip_set_chip(girq, &altera_gpio_irq_chip); 283 + 301 284 if (altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH) 302 285 girq->parent_handler = altera_gpio_irq_leveL_high_handler; 303 286 else ··· 335 330 static struct platform_driver altera_gpio_driver = { 336 331 .driver = { 337 332 .name = "altera_gpio", 338 - .of_match_table = of_match_ptr(altera_gpio_of_match), 333 + .of_match_table = altera_gpio_of_match, 339 334 }, 340 335 .probe = altera_gpio_probe, 341 336 .remove = altera_gpio_remove,
+36 -9
drivers/gpio/gpio-aspeed-sgpio.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/module.h> 16 16 #include <linux/platform_device.h> 17 + #include <linux/seq_file.h> 17 18 #include <linux/spinlock.h> 18 19 #include <linux/string.h> 19 20 ··· 30 29 31 30 struct aspeed_sgpio { 32 31 struct gpio_chip chip; 33 - struct irq_chip intc; 32 + struct device *dev; 34 33 struct clk *pclk; 35 34 raw_spinlock_t lock; 36 35 void __iomem *base; ··· 297 296 irqd_to_aspeed_sgpio_data(d, &gpio, &bank, &bit, &offset); 298 297 addr = bank_reg(gpio, bank, reg_irq_enable); 299 298 299 + /* Unmasking the IRQ */ 300 + if (set) 301 + gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(d)); 302 + 300 303 raw_spin_lock_irqsave(&gpio->lock, flags); 301 304 302 305 reg = ioread32(addr); ··· 312 307 iowrite32(reg, addr); 313 308 314 309 raw_spin_unlock_irqrestore(&gpio->lock, flags); 310 + 311 + /* Masking the IRQ */ 312 + if (!set) 313 + gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(d)); 314 + 315 + 315 316 } 316 317 317 318 static void aspeed_sgpio_irq_mask(struct irq_data *d) ··· 412 401 chained_irq_exit(ic, desc); 413 402 } 414 403 404 + static void aspeed_sgpio_irq_print_chip(struct irq_data *d, struct seq_file *p) 405 + { 406 + const struct aspeed_sgpio_bank *bank; 407 + struct aspeed_sgpio *gpio; 408 + u32 bit; 409 + int offset; 410 + 411 + irqd_to_aspeed_sgpio_data(d, &gpio, &bank, &bit, &offset); 412 + seq_printf(p, dev_name(gpio->dev)); 413 + } 414 + 415 + static const struct irq_chip aspeed_sgpio_irq_chip = { 416 + .irq_ack = aspeed_sgpio_irq_ack, 417 + .irq_mask = aspeed_sgpio_irq_mask, 418 + .irq_unmask = aspeed_sgpio_irq_unmask, 419 + .irq_set_type = aspeed_sgpio_set_type, 420 + .irq_print_chip = aspeed_sgpio_irq_print_chip, 421 + .flags = IRQCHIP_IMMUTABLE, 422 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 423 + }; 424 + 415 425 static int aspeed_sgpio_setup_irqs(struct aspeed_sgpio *gpio, 416 426 struct platform_device *pdev) 417 427 { ··· 455 423 iowrite32(0xffffffff, bank_reg(gpio, bank, reg_irq_status)); 456 424 } 457 425 458 - gpio->intc.name = dev_name(&pdev->dev); 459 - gpio->intc.irq_ack = aspeed_sgpio_irq_ack; 460 - gpio->intc.irq_mask = aspeed_sgpio_irq_mask; 461 - gpio->intc.irq_unmask = aspeed_sgpio_irq_unmask; 462 - gpio->intc.irq_set_type = aspeed_sgpio_set_type; 463 - 464 426 irq = &gpio->chip.irq; 465 - irq->chip = &gpio->intc; 427 + gpio_irq_chip_set_chip(irq, &aspeed_sgpio_irq_chip); 466 428 irq->init_valid_mask = aspeed_sgpio_irq_init_valid_mask; 467 429 irq->handler = handle_bad_irq; 468 430 irq->default_type = IRQ_TYPE_NONE; ··· 550 524 if (IS_ERR(gpio->base)) 551 525 return PTR_ERR(gpio->base); 552 526 527 + gpio->dev = &pdev->dev; 528 + 553 529 pdata = device_get_match_data(&pdev->dev); 554 530 if (!pdata) 555 531 return -EINVAL; ··· 637 609 638 610 module_platform_driver_probe(aspeed_sgpio_driver, aspeed_sgpio_probe); 639 611 MODULE_DESCRIPTION("Aspeed Serial GPIO Driver"); 640 - MODULE_LICENSE("GPL");
+54 -26
drivers/gpio/gpio-aspeed.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/pinctrl/consumer.h> 17 17 #include <linux/platform_device.h> 18 + #include <linux/seq_file.h> 18 19 #include <linux/spinlock.h> 19 20 #include <linux/string.h> 20 21 ··· 54 53 */ 55 54 struct aspeed_gpio { 56 55 struct gpio_chip chip; 57 - struct irq_chip irqc; 56 + struct device *dev; 58 57 raw_spinlock_t lock; 59 58 void __iomem *base; 60 59 int irq; ··· 567 566 568 567 addr = bank_reg(gpio, bank, reg_irq_enable); 569 568 569 + /* Unmasking the IRQ */ 570 + if (set) 571 + gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(d)); 572 + 570 573 raw_spin_lock_irqsave(&gpio->lock, flags); 571 574 copro = aspeed_gpio_copro_request(gpio, offset); 572 575 ··· 584 579 if (copro) 585 580 aspeed_gpio_copro_release(gpio, offset); 586 581 raw_spin_unlock_irqrestore(&gpio->lock, flags); 582 + 583 + /* Masking the IRQ */ 584 + if (!set) 585 + gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(d)); 587 586 } 588 587 589 588 static void aspeed_gpio_irq_mask(struct irq_data *d) ··· 1089 1080 } 1090 1081 EXPORT_SYMBOL_GPL(aspeed_gpio_copro_release_gpio); 1091 1082 1083 + static void aspeed_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) 1084 + { 1085 + const struct aspeed_gpio_bank *bank; 1086 + struct aspeed_gpio *gpio; 1087 + u32 bit; 1088 + int rc, offset; 1089 + 1090 + rc = irqd_to_aspeed_gpio_data(d, &gpio, &bank, &bit, &offset); 1091 + if (rc) 1092 + return; 1093 + 1094 + seq_printf(p, dev_name(gpio->dev)); 1095 + } 1096 + 1097 + static const struct irq_chip aspeed_gpio_irq_chip = { 1098 + .irq_ack = aspeed_gpio_irq_ack, 1099 + .irq_mask = aspeed_gpio_irq_mask, 1100 + .irq_unmask = aspeed_gpio_irq_unmask, 1101 + .irq_set_type = aspeed_gpio_set_type, 1102 + .irq_print_chip = aspeed_gpio_irq_print_chip, 1103 + .flags = IRQCHIP_IMMUTABLE, 1104 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 1105 + }; 1106 + 1092 1107 /* 1093 1108 * Any banks not specified in a struct aspeed_bank_props array are assumed to 1094 1109 * have the properties: ··· 1170 1137 static int __init aspeed_gpio_probe(struct platform_device *pdev) 1171 1138 { 1172 1139 const struct of_device_id *gpio_id; 1140 + struct gpio_irq_chip *girq; 1173 1141 struct aspeed_gpio *gpio; 1174 - int rc, i, banks, err; 1142 + int rc, irq, i, banks, err; 1175 1143 u32 ngpio; 1176 1144 1177 1145 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); ··· 1182 1148 gpio->base = devm_platform_ioremap_resource(pdev, 0); 1183 1149 if (IS_ERR(gpio->base)) 1184 1150 return PTR_ERR(gpio->base); 1151 + 1152 + gpio->dev = &pdev->dev; 1185 1153 1186 1154 raw_spin_lock_init(&gpio->lock); 1187 1155 ··· 1237 1201 aspeed_gpio_change_cmd_source(gpio, bank, 3, GPIO_CMDSRC_ARM); 1238 1202 } 1239 1203 1240 - /* Optionally set up an irqchip if there is an IRQ */ 1241 - rc = platform_get_irq(pdev, 0); 1242 - if (rc > 0) { 1243 - struct gpio_irq_chip *girq; 1204 + /* Set up an irqchip */ 1205 + irq = platform_get_irq(pdev, 0); 1206 + if (irq < 0) 1207 + return irq; 1208 + gpio->irq = irq; 1209 + girq = &gpio->chip.irq; 1210 + gpio_irq_chip_set_chip(girq, &aspeed_gpio_irq_chip); 1244 1211 1245 - gpio->irq = rc; 1246 - girq = &gpio->chip.irq; 1247 - girq->chip = &gpio->irqc; 1248 - girq->chip->name = dev_name(&pdev->dev); 1249 - girq->chip->irq_ack = aspeed_gpio_irq_ack; 1250 - girq->chip->irq_mask = aspeed_gpio_irq_mask; 1251 - girq->chip->irq_unmask = aspeed_gpio_irq_unmask; 1252 - girq->chip->irq_set_type = aspeed_gpio_set_type; 1253 - girq->parent_handler = aspeed_gpio_irq_handler; 1254 - girq->num_parents = 1; 1255 - girq->parents = devm_kcalloc(&pdev->dev, 1, 1256 - sizeof(*girq->parents), 1257 - GFP_KERNEL); 1258 - if (!girq->parents) 1259 - return -ENOMEM; 1260 - girq->parents[0] = gpio->irq; 1261 - girq->default_type = IRQ_TYPE_NONE; 1262 - girq->handler = handle_bad_irq; 1263 - girq->init_valid_mask = aspeed_init_irq_valid_mask; 1264 - } 1212 + girq->parent_handler = aspeed_gpio_irq_handler; 1213 + girq->num_parents = 1; 1214 + girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents), GFP_KERNEL); 1215 + if (!girq->parents) 1216 + return -ENOMEM; 1217 + girq->parents[0] = gpio->irq; 1218 + girq->default_type = IRQ_TYPE_NONE; 1219 + girq->handler = handle_bad_irq; 1220 + girq->init_valid_mask = aspeed_init_irq_valid_mask; 1265 1221 1266 1222 gpio->offset_timer = 1267 1223 devm_kzalloc(&pdev->dev, gpio->chip.ngpio, GFP_KERNEL);
+6 -2
drivers/gpio/gpio-ath79.c
··· 71 71 u32 mask = BIT(irqd_to_hwirq(data)); 72 72 unsigned long flags; 73 73 74 + gpiochip_enable_irq(&ctrl->gc, irqd_to_hwirq(data)); 74 75 raw_spin_lock_irqsave(&ctrl->lock, flags); 75 76 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask); 76 77 raw_spin_unlock_irqrestore(&ctrl->lock, flags); ··· 86 85 raw_spin_lock_irqsave(&ctrl->lock, flags); 87 86 ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0); 88 87 raw_spin_unlock_irqrestore(&ctrl->lock, flags); 88 + gpiochip_disable_irq(&ctrl->gc, irqd_to_hwirq(data)); 89 89 } 90 90 91 91 static void ath79_gpio_irq_enable(struct irq_data *data) ··· 171 169 return 0; 172 170 } 173 171 174 - static struct irq_chip ath79_gpio_irqchip = { 172 + static const struct irq_chip ath79_gpio_irqchip = { 175 173 .name = "gpio-ath79", 176 174 .irq_enable = ath79_gpio_irq_enable, 177 175 .irq_disable = ath79_gpio_irq_disable, 178 176 .irq_mask = ath79_gpio_irq_mask, 179 177 .irq_unmask = ath79_gpio_irq_unmask, 180 178 .irq_set_type = ath79_gpio_irq_set_type, 179 + .flags = IRQCHIP_IMMUTABLE, 180 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 181 181 }; 182 182 183 183 static void ath79_gpio_irq_handler(struct irq_desc *desc) ··· 278 274 /* Optional interrupt setup */ 279 275 if (!np || of_property_read_bool(np, "interrupt-controller")) { 280 276 girq = &ctrl->gc.irq; 281 - girq->chip = &ath79_gpio_irqchip; 277 + gpio_irq_chip_set_chip(girq, &ath79_gpio_irqchip); 282 278 girq->parent_handler = ath79_gpio_irq_handler; 283 279 girq->num_parents = 1; 284 280 girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
+7 -3
drivers/gpio/gpio-cadence.c
··· 70 70 struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip); 71 71 72 72 iowrite32(BIT(d->hwirq), cgpio->regs + CDNS_GPIO_IRQ_DIS); 73 + gpiochip_disable_irq(chip, irqd_to_hwirq(d)); 73 74 } 74 75 75 76 static void cdns_gpio_irq_unmask(struct irq_data *d) ··· 78 77 struct gpio_chip *chip = irq_data_get_irq_chip_data(d); 79 78 struct cdns_gpio_chip *cgpio = gpiochip_get_data(chip); 80 79 80 + gpiochip_enable_irq(chip, irqd_to_hwirq(d)); 81 81 iowrite32(BIT(d->hwirq), cgpio->regs + CDNS_GPIO_IRQ_EN); 82 82 } 83 83 ··· 140 138 chained_irq_exit(irqchip, desc); 141 139 } 142 140 143 - static struct irq_chip cdns_gpio_irqchip = { 141 + static const struct irq_chip cdns_gpio_irqchip = { 144 142 .name = "cdns-gpio", 145 143 .irq_mask = cdns_gpio_irq_mask, 146 144 .irq_unmask = cdns_gpio_irq_unmask, 147 - .irq_set_type = cdns_gpio_irq_set_type 145 + .irq_set_type = cdns_gpio_irq_set_type, 146 + .flags = IRQCHIP_IMMUTABLE, 147 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 148 148 }; 149 149 150 150 static int cdns_gpio_probe(struct platform_device *pdev) ··· 226 222 struct gpio_irq_chip *girq; 227 223 228 224 girq = &cgpio->gc.irq; 229 - girq->chip = &cdns_gpio_irqchip; 225 + gpio_irq_chip_set_chip(girq, &cdns_gpio_irqchip); 230 226 girq->parent_handler = cdns_gpio_irq_handler; 231 227 girq->num_parents = 1; 232 228 girq->parents = devm_kcalloc(&pdev->dev, 1,
-2
drivers/gpio/gpio-davinci.c
··· 24 24 #include <linux/spinlock.h> 25 25 #include <linux/pm_runtime.h> 26 26 27 - #include <asm-generic/gpio.h> 28 - 29 27 #define MAX_REGS_BANKS 5 30 28 #define MAX_INT_PER_BANK 32 31 29
+90
drivers/gpio/gpio-elkhartlake.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Intel Elkhart Lake PSE GPIO driver 4 + * 5 + * Copyright (c) 2023 Intel Corporation. 6 + * 7 + * Authors: Pandith N <pandith.n@intel.com> 8 + * Raag Jadav <raag.jadav@intel.com> 9 + */ 10 + 11 + #include <linux/device.h> 12 + #include <linux/err.h> 13 + #include <linux/module.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/pm.h> 16 + 17 + #include "gpio-tangier.h" 18 + 19 + /* Each Intel EHL PSE GPIO Controller has 30 GPIO pins */ 20 + #define EHL_PSE_NGPIO 30 21 + 22 + static int ehl_gpio_probe(struct platform_device *pdev) 23 + { 24 + struct device *dev = &pdev->dev; 25 + struct tng_gpio *priv; 26 + int irq, ret; 27 + 28 + irq = platform_get_irq(pdev, 0); 29 + if (irq < 0) 30 + return irq; 31 + 32 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 33 + if (!priv) 34 + return -ENOMEM; 35 + 36 + priv->reg_base = devm_platform_ioremap_resource(pdev, 0); 37 + if (IS_ERR(priv->reg_base)) 38 + return PTR_ERR(priv->reg_base); 39 + 40 + priv->dev = dev; 41 + priv->irq = irq; 42 + 43 + priv->info.base = -1; 44 + priv->info.ngpio = EHL_PSE_NGPIO; 45 + 46 + priv->wake_regs.gwmr = GWMR_EHL; 47 + priv->wake_regs.gwsr = GWSR_EHL; 48 + priv->wake_regs.gsir = GSIR_EHL; 49 + 50 + ret = devm_tng_gpio_probe(dev, priv); 51 + if (ret) 52 + return dev_err_probe(dev, ret, "tng_gpio_probe error\n"); 53 + 54 + platform_set_drvdata(pdev, priv); 55 + return 0; 56 + } 57 + 58 + static int ehl_gpio_suspend(struct device *dev) 59 + { 60 + return tng_gpio_suspend(dev); 61 + } 62 + 63 + static int ehl_gpio_resume(struct device *dev) 64 + { 65 + return tng_gpio_resume(dev); 66 + } 67 + 68 + static DEFINE_SIMPLE_DEV_PM_OPS(ehl_gpio_pm_ops, ehl_gpio_suspend, ehl_gpio_resume); 69 + 70 + static const struct platform_device_id ehl_gpio_ids[] = { 71 + { "gpio-elkhartlake" }, 72 + { } 73 + }; 74 + MODULE_DEVICE_TABLE(platform, ehl_gpio_ids); 75 + 76 + static struct platform_driver ehl_gpio_driver = { 77 + .driver = { 78 + .name = "gpio-elkhartlake", 79 + .pm = pm_sleep_ptr(&ehl_gpio_pm_ops), 80 + }, 81 + .probe = ehl_gpio_probe, 82 + .id_table = ehl_gpio_ids, 83 + }; 84 + module_platform_driver(ehl_gpio_driver); 85 + 86 + MODULE_AUTHOR("Pandith N <pandith.n@intel.com>"); 87 + MODULE_AUTHOR("Raag Jadav <raag.jadav@intel.com>"); 88 + MODULE_DESCRIPTION("Intel Elkhart Lake PSE GPIO driver"); 89 + MODULE_LICENSE("GPL"); 90 + MODULE_IMPORT_NS(GPIO_TANGIER);
+1 -1
drivers/gpio/gpio-ftgpio010.c
··· 349 349 static struct platform_driver ftgpio_gpio_driver = { 350 350 .driver = { 351 351 .name = "ftgpio010-gpio", 352 - .of_match_table = of_match_ptr(ftgpio_gpio_of_match), 352 + .of_match_table = ftgpio_gpio_of_match, 353 353 }, 354 354 .probe = ftgpio_gpio_probe, 355 355 .remove = ftgpio_gpio_remove,
+158
drivers/gpio/gpio-fxl6408.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * FXL6408 GPIO driver 4 + * 5 + * Copyright 2023 Toradex 6 + * 7 + * Author: Emanuele Ghidoli <emanuele.ghidoli@toradex.com> 8 + */ 9 + 10 + #include <linux/err.h> 11 + #include <linux/gpio/regmap.h> 12 + #include <linux/i2c.h> 13 + #include <linux/kernel.h> 14 + #include <linux/module.h> 15 + #include <linux/regmap.h> 16 + 17 + #define FXL6408_REG_DEVICE_ID 0x01 18 + #define FXL6408_MF_FAIRCHILD 0b101 19 + #define FXL6408_MF_SHIFT 5 20 + 21 + /* Bits set here indicate that the GPIO is an output. */ 22 + #define FXL6408_REG_IO_DIR 0x03 23 + 24 + /* 25 + * Bits set here, when the corresponding bit of IO_DIR is set, drive 26 + * the output high instead of low. 27 + */ 28 + #define FXL6408_REG_OUTPUT 0x05 29 + 30 + /* Bits here make the output High-Z, instead of the OUTPUT value. */ 31 + #define FXL6408_REG_OUTPUT_HIGH_Z 0x07 32 + 33 + /* Returns the current status (1 = HIGH) of the input pins. */ 34 + #define FXL6408_REG_INPUT_STATUS 0x0f 35 + 36 + /* 37 + * Return the current interrupt status 38 + * This bit is HIGH if input GPIO != default state (register 09h). 39 + * The flag is cleared after being read (bit returns to 0). 40 + * The input must go back to default state and change again before this flag is raised again. 41 + */ 42 + #define FXL6408_REG_INT_STS 0x13 43 + 44 + #define FXL6408_NGPIO 8 45 + 46 + static const struct regmap_range rd_range[] = { 47 + { FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID }, 48 + { FXL6408_REG_IO_DIR, FXL6408_REG_OUTPUT }, 49 + { FXL6408_REG_INPUT_STATUS, FXL6408_REG_INPUT_STATUS }, 50 + }; 51 + 52 + static const struct regmap_range wr_range[] = { 53 + { FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID }, 54 + { FXL6408_REG_IO_DIR, FXL6408_REG_OUTPUT }, 55 + { FXL6408_REG_OUTPUT_HIGH_Z, FXL6408_REG_OUTPUT_HIGH_Z }, 56 + }; 57 + 58 + static const struct regmap_range volatile_range[] = { 59 + { FXL6408_REG_DEVICE_ID, FXL6408_REG_DEVICE_ID }, 60 + { FXL6408_REG_INPUT_STATUS, FXL6408_REG_INPUT_STATUS }, 61 + }; 62 + 63 + static const struct regmap_access_table rd_table = { 64 + .yes_ranges = rd_range, 65 + .n_yes_ranges = ARRAY_SIZE(rd_range), 66 + }; 67 + 68 + static const struct regmap_access_table wr_table = { 69 + .yes_ranges = wr_range, 70 + .n_yes_ranges = ARRAY_SIZE(wr_range), 71 + }; 72 + 73 + static const struct regmap_access_table volatile_table = { 74 + .yes_ranges = volatile_range, 75 + .n_yes_ranges = ARRAY_SIZE(volatile_range), 76 + }; 77 + 78 + static const struct regmap_config regmap = { 79 + .reg_bits = 8, 80 + .val_bits = 8, 81 + 82 + .max_register = FXL6408_REG_INT_STS, 83 + .wr_table = &wr_table, 84 + .rd_table = &rd_table, 85 + .volatile_table = &volatile_table, 86 + 87 + .cache_type = REGCACHE_RBTREE, 88 + .num_reg_defaults_raw = FXL6408_REG_INT_STS + 1, 89 + }; 90 + 91 + static int fxl6408_identify(struct device *dev, struct regmap *regmap) 92 + { 93 + int val, ret; 94 + 95 + ret = regmap_read(regmap, FXL6408_REG_DEVICE_ID, &val); 96 + if (ret) 97 + return dev_err_probe(dev, ret, "error reading DEVICE_ID\n"); 98 + if (val >> FXL6408_MF_SHIFT != FXL6408_MF_FAIRCHILD) 99 + return dev_err_probe(dev, -ENODEV, "invalid device id 0x%02x\n", val); 100 + 101 + return 0; 102 + } 103 + 104 + static int fxl6408_probe(struct i2c_client *client) 105 + { 106 + struct device *dev = &client->dev; 107 + int ret; 108 + struct gpio_regmap_config gpio_config = { 109 + .parent = dev, 110 + .ngpio = FXL6408_NGPIO, 111 + .reg_dat_base = GPIO_REGMAP_ADDR(FXL6408_REG_INPUT_STATUS), 112 + .reg_set_base = GPIO_REGMAP_ADDR(FXL6408_REG_OUTPUT), 113 + .reg_dir_out_base = GPIO_REGMAP_ADDR(FXL6408_REG_IO_DIR), 114 + .ngpio_per_reg = FXL6408_NGPIO, 115 + }; 116 + 117 + gpio_config.regmap = devm_regmap_init_i2c(client, &regmap); 118 + if (IS_ERR(gpio_config.regmap)) 119 + return dev_err_probe(dev, PTR_ERR(gpio_config.regmap), 120 + "failed to allocate register map\n"); 121 + 122 + ret = fxl6408_identify(dev, gpio_config.regmap); 123 + if (ret) 124 + return ret; 125 + 126 + /* Disable High-Z of outputs, so that our OUTPUT updates actually take effect. */ 127 + ret = regmap_write(gpio_config.regmap, FXL6408_REG_OUTPUT_HIGH_Z, 0); 128 + if (ret) 129 + return dev_err_probe(dev, ret, "failed to write 'output high Z' register\n"); 130 + 131 + return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config)); 132 + } 133 + 134 + static const __maybe_unused struct of_device_id fxl6408_dt_ids[] = { 135 + { .compatible = "fcs,fxl6408" }, 136 + { } 137 + }; 138 + MODULE_DEVICE_TABLE(of, fxl6408_dt_ids); 139 + 140 + static const struct i2c_device_id fxl6408_id[] = { 141 + { "fxl6408", 0 }, 142 + { } 143 + }; 144 + MODULE_DEVICE_TABLE(i2c, fxl6408_id); 145 + 146 + static struct i2c_driver fxl6408_driver = { 147 + .driver = { 148 + .name = "fxl6408", 149 + .of_match_table = fxl6408_dt_ids, 150 + }, 151 + .probe_new = fxl6408_probe, 152 + .id_table = fxl6408_id, 153 + }; 154 + module_i2c_driver(fxl6408_driver); 155 + 156 + MODULE_AUTHOR("Emanuele Ghidoli <emanuele.ghidoli@toradex.com>"); 157 + MODULE_DESCRIPTION("FXL6408 GPIO driver"); 158 + MODULE_LICENSE("GPL");
+15 -10
drivers/gpio/gpio-hisi.c
··· 37 37 struct device *dev; 38 38 void __iomem *reg_base; 39 39 unsigned int line_num; 40 - struct irq_chip irq_chip; 41 40 int irq; 42 41 }; 43 42 ··· 99 100 struct gpio_chip *chip = irq_data_get_irq_chip_data(d); 100 101 101 102 hisi_gpio_write_reg(chip, HISI_GPIO_INTMASK_SET_WX, BIT(irqd_to_hwirq(d))); 103 + gpiochip_disable_irq(chip, irqd_to_hwirq(d)); 102 104 } 103 105 104 106 static void hisi_gpio_irq_clr_mask(struct irq_data *d) 105 107 { 106 108 struct gpio_chip *chip = irq_data_get_irq_chip_data(d); 107 109 110 + gpiochip_enable_irq(chip, irqd_to_hwirq(d)); 108 111 hisi_gpio_write_reg(chip, HISI_GPIO_INTMASK_CLR_WX, BIT(irqd_to_hwirq(d))); 109 112 } 110 113 ··· 192 191 chained_irq_exit(irq_c, desc); 193 192 } 194 193 194 + static const struct irq_chip hisi_gpio_irq_chip = { 195 + .name = "HISI-GPIO", 196 + .irq_ack = hisi_gpio_set_ack, 197 + .irq_mask = hisi_gpio_irq_set_mask, 198 + .irq_unmask = hisi_gpio_irq_clr_mask, 199 + .irq_set_type = hisi_gpio_irq_set_type, 200 + .irq_enable = hisi_gpio_irq_enable, 201 + .irq_disable = hisi_gpio_irq_disable, 202 + .flags = IRQCHIP_IMMUTABLE, 203 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 204 + }; 205 + 195 206 static void hisi_gpio_init_irq(struct hisi_gpio *hisi_gpio) 196 207 { 197 208 struct gpio_chip *chip = &hisi_gpio->chip; 198 209 struct gpio_irq_chip *girq_chip = &chip->irq; 199 210 200 - /* Set hooks for irq_chip */ 201 - hisi_gpio->irq_chip.irq_ack = hisi_gpio_set_ack; 202 - hisi_gpio->irq_chip.irq_mask = hisi_gpio_irq_set_mask; 203 - hisi_gpio->irq_chip.irq_unmask = hisi_gpio_irq_clr_mask; 204 - hisi_gpio->irq_chip.irq_set_type = hisi_gpio_irq_set_type; 205 - hisi_gpio->irq_chip.irq_enable = hisi_gpio_irq_enable; 206 - hisi_gpio->irq_chip.irq_disable = hisi_gpio_irq_disable; 207 - 208 - girq_chip->chip = &hisi_gpio->irq_chip; 211 + gpio_irq_chip_set_chip(girq_chip, &hisi_gpio_irq_chip); 209 212 girq_chip->default_type = IRQ_TYPE_NONE; 210 213 girq_chip->num_parents = 1; 211 214 girq_chip->parents = &hisi_gpio->irq;
+25 -8
drivers/gpio/gpio-hlwd.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/of.h> 13 13 #include <linux/of_platform.h> 14 + #include <linux/seq_file.h> 14 15 #include <linux/slab.h> 15 16 16 17 /* ··· 49 48 50 49 struct hlwd_gpio { 51 50 struct gpio_chip gpioc; 52 - struct irq_chip irqc; 51 + struct device *dev; 53 52 void __iomem *regs; 54 53 int irq; 55 54 u32 edge_emulation; ··· 124 123 mask &= ~BIT(data->hwirq); 125 124 iowrite32be(mask, hlwd->regs + HW_GPIOB_INTMASK); 126 125 raw_spin_unlock_irqrestore(&hlwd->gpioc.bgpio_lock, flags); 126 + gpiochip_disable_irq(&hlwd->gpioc, irqd_to_hwirq(data)); 127 127 } 128 128 129 129 static void hlwd_gpio_irq_unmask(struct irq_data *data) ··· 134 132 unsigned long flags; 135 133 u32 mask; 136 134 135 + gpiochip_enable_irq(&hlwd->gpioc, irqd_to_hwirq(data)); 137 136 raw_spin_lock_irqsave(&hlwd->gpioc.bgpio_lock, flags); 138 137 mask = ioread32be(hlwd->regs + HW_GPIOB_INTMASK); 139 138 mask |= BIT(data->hwirq); ··· 205 202 return 0; 206 203 } 207 204 205 + static void hlwd_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p) 206 + { 207 + struct hlwd_gpio *hlwd = 208 + gpiochip_get_data(irq_data_get_irq_chip_data(data)); 209 + 210 + seq_printf(p, dev_name(hlwd->dev)); 211 + } 212 + 213 + static const struct irq_chip hlwd_gpio_irq_chip = { 214 + .irq_mask = hlwd_gpio_irq_mask, 215 + .irq_unmask = hlwd_gpio_irq_unmask, 216 + .irq_enable = hlwd_gpio_irq_enable, 217 + .irq_set_type = hlwd_gpio_irq_set_type, 218 + .irq_print_chip = hlwd_gpio_irq_print_chip, 219 + .flags = IRQCHIP_IMMUTABLE, 220 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 221 + }; 222 + 208 223 static int hlwd_gpio_probe(struct platform_device *pdev) 209 224 { 210 225 struct hlwd_gpio *hlwd; ··· 236 215 hlwd->regs = devm_platform_ioremap_resource(pdev, 0); 237 216 if (IS_ERR(hlwd->regs)) 238 217 return PTR_ERR(hlwd->regs); 218 + 219 + hlwd->dev = &pdev->dev; 239 220 240 221 /* 241 222 * Claim all GPIOs using the OWNER register. This will not work on ··· 282 259 return hlwd->irq; 283 260 } 284 261 285 - hlwd->irqc.name = dev_name(&pdev->dev); 286 - hlwd->irqc.irq_mask = hlwd_gpio_irq_mask; 287 - hlwd->irqc.irq_unmask = hlwd_gpio_irq_unmask; 288 - hlwd->irqc.irq_enable = hlwd_gpio_irq_enable; 289 - hlwd->irqc.irq_set_type = hlwd_gpio_irq_set_type; 290 - 291 262 girq = &hlwd->gpioc.irq; 292 - girq->chip = &hlwd->irqc; 263 + gpio_irq_chip_set_chip(girq, &hlwd_gpio_irq_chip); 293 264 girq->parent_handler = hlwd_gpio_irqhandler; 294 265 girq->num_parents = 1; 295 266 girq->parents = devm_kcalloc(&pdev->dev, 1,
+1 -9
drivers/gpio/gpio-ich.c
··· 457 457 458 458 init: 459 459 ichx_gpiolib_setup(&ichx_priv.chip); 460 - err = gpiochip_add_data(&ichx_priv.chip, NULL); 460 + err = devm_gpiochip_add_data(dev, &ichx_priv.chip, NULL); 461 461 if (err) { 462 462 dev_err(dev, "Failed to register GPIOs\n"); 463 463 return err; ··· 469 469 return 0; 470 470 } 471 471 472 - static int ichx_gpio_remove(struct platform_device *pdev) 473 - { 474 - gpiochip_remove(&ichx_priv.chip); 475 - 476 - return 0; 477 - } 478 - 479 472 static struct platform_driver ichx_gpio_driver = { 480 473 .driver = { 481 474 .name = DRV_NAME, 482 475 }, 483 476 .probe = ichx_gpio_probe, 484 - .remove = ichx_gpio_remove, 485 477 }; 486 478 487 479 module_platform_driver(ichx_gpio_driver);
+8 -3
drivers/gpio/gpio-idt3243x.c
··· 92 92 writel(ctrl->mask_cache, ctrl->pic + IDT_PIC_IRQ_MASK); 93 93 94 94 raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); 95 + 96 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 95 97 } 96 98 97 99 static void idt_gpio_unmask(struct irq_data *d) ··· 102 100 struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); 103 101 unsigned long flags; 104 102 103 + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 105 104 raw_spin_lock_irqsave(&gc->bgpio_lock, flags); 106 105 107 106 ctrl->mask_cache &= ~BIT(d->hwirq); ··· 122 119 return 0; 123 120 } 124 121 125 - static struct irq_chip idt_gpio_irqchip = { 122 + static const struct irq_chip idt_gpio_irqchip = { 126 123 .name = "IDTGPIO", 127 124 .irq_mask = idt_gpio_mask, 128 125 .irq_ack = idt_gpio_ack, 129 126 .irq_unmask = idt_gpio_unmask, 130 - .irq_set_type = idt_gpio_irq_set_type 127 + .irq_set_type = idt_gpio_irq_set_type, 128 + .flags = IRQCHIP_IMMUTABLE, 129 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 131 130 }; 132 131 133 132 static int idt_gpio_probe(struct platform_device *pdev) ··· 173 168 return parent_irq; 174 169 175 170 girq = &ctrl->gc.irq; 176 - girq->chip = &idt_gpio_irqchip; 171 + gpio_irq_chip_set_chip(girq, &idt_gpio_irqchip); 177 172 girq->init_hw = idt_gpio_irq_init_hw; 178 173 girq->parent_handler = idt_gpio_dispatch; 179 174 girq->num_parents = 1;
-1
drivers/gpio/gpio-imx-scu.c
··· 136 136 137 137 MODULE_AUTHOR("Shenwei Wang <shenwei.wang@nxp.com>"); 138 138 MODULE_DESCRIPTION("NXP GPIO over IMX SCU API"); 139 - MODULE_LICENSE("GPL");
+238
drivers/gpio/gpio-loongson-64bit.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Loongson GPIO Support 4 + * 5 + * Copyright (C) 2022-2023 Loongson Technology Corporation Limited 6 + */ 7 + 8 + #include <linux/kernel.h> 9 + #include <linux/init.h> 10 + #include <linux/module.h> 11 + #include <linux/spinlock.h> 12 + #include <linux/err.h> 13 + #include <linux/gpio/driver.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/bitops.h> 16 + #include <asm/types.h> 17 + 18 + enum loongson_gpio_mode { 19 + BIT_CTRL_MODE, 20 + BYTE_CTRL_MODE, 21 + }; 22 + 23 + struct loongson_gpio_chip_data { 24 + const char *label; 25 + enum loongson_gpio_mode mode; 26 + unsigned int conf_offset; 27 + unsigned int out_offset; 28 + unsigned int in_offset; 29 + }; 30 + 31 + struct loongson_gpio_chip { 32 + struct gpio_chip chip; 33 + struct fwnode_handle *fwnode; 34 + spinlock_t lock; 35 + void __iomem *reg_base; 36 + const struct loongson_gpio_chip_data *chip_data; 37 + }; 38 + 39 + static inline struct loongson_gpio_chip *to_loongson_gpio_chip(struct gpio_chip *chip) 40 + { 41 + return container_of(chip, struct loongson_gpio_chip, chip); 42 + } 43 + 44 + static inline void loongson_commit_direction(struct loongson_gpio_chip *lgpio, unsigned int pin, 45 + int input) 46 + { 47 + u8 bval = input ? 1 : 0; 48 + 49 + writeb(bval, lgpio->reg_base + lgpio->chip_data->conf_offset + pin); 50 + } 51 + 52 + static void loongson_commit_level(struct loongson_gpio_chip *lgpio, unsigned int pin, int high) 53 + { 54 + u8 bval = high ? 1 : 0; 55 + 56 + writeb(bval, lgpio->reg_base + lgpio->chip_data->out_offset + pin); 57 + } 58 + 59 + static int loongson_gpio_direction_input(struct gpio_chip *chip, unsigned int pin) 60 + { 61 + unsigned long flags; 62 + struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); 63 + 64 + spin_lock_irqsave(&lgpio->lock, flags); 65 + loongson_commit_direction(lgpio, pin, 1); 66 + spin_unlock_irqrestore(&lgpio->lock, flags); 67 + 68 + return 0; 69 + } 70 + 71 + static int loongson_gpio_direction_output(struct gpio_chip *chip, unsigned int pin, int value) 72 + { 73 + unsigned long flags; 74 + struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); 75 + 76 + spin_lock_irqsave(&lgpio->lock, flags); 77 + loongson_commit_level(lgpio, pin, value); 78 + loongson_commit_direction(lgpio, pin, 0); 79 + spin_unlock_irqrestore(&lgpio->lock, flags); 80 + 81 + return 0; 82 + } 83 + 84 + static int loongson_gpio_get(struct gpio_chip *chip, unsigned int pin) 85 + { 86 + u8 bval; 87 + int val; 88 + struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); 89 + 90 + bval = readb(lgpio->reg_base + lgpio->chip_data->in_offset + pin); 91 + val = bval & 1; 92 + 93 + return val; 94 + } 95 + 96 + static int loongson_gpio_get_direction(struct gpio_chip *chip, unsigned int pin) 97 + { 98 + u8 bval; 99 + struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); 100 + 101 + bval = readb(lgpio->reg_base + lgpio->chip_data->conf_offset + pin); 102 + if (bval & 1) 103 + return GPIO_LINE_DIRECTION_IN; 104 + 105 + return GPIO_LINE_DIRECTION_OUT; 106 + } 107 + 108 + static void loongson_gpio_set(struct gpio_chip *chip, unsigned int pin, int value) 109 + { 110 + unsigned long flags; 111 + struct loongson_gpio_chip *lgpio = to_loongson_gpio_chip(chip); 112 + 113 + spin_lock_irqsave(&lgpio->lock, flags); 114 + loongson_commit_level(lgpio, pin, value); 115 + spin_unlock_irqrestore(&lgpio->lock, flags); 116 + } 117 + 118 + static int loongson_gpio_to_irq(struct gpio_chip *chip, unsigned int offset) 119 + { 120 + struct platform_device *pdev = to_platform_device(chip->parent); 121 + 122 + return platform_get_irq(pdev, offset); 123 + } 124 + 125 + static int loongson_gpio_init(struct device *dev, struct loongson_gpio_chip *lgpio, 126 + struct device_node *np, void __iomem *reg_base) 127 + { 128 + int ret; 129 + u32 ngpios; 130 + 131 + lgpio->reg_base = reg_base; 132 + 133 + if (lgpio->chip_data->mode == BIT_CTRL_MODE) { 134 + ret = bgpio_init(&lgpio->chip, dev, 8, 135 + lgpio->reg_base + lgpio->chip_data->in_offset, 136 + lgpio->reg_base + lgpio->chip_data->out_offset, 137 + NULL, NULL, 138 + lgpio->reg_base + lgpio->chip_data->conf_offset, 139 + 0); 140 + if (ret) { 141 + dev_err(dev, "unable to init generic GPIO\n"); 142 + return ret; 143 + } 144 + } else { 145 + lgpio->chip.direction_input = loongson_gpio_direction_input; 146 + lgpio->chip.get = loongson_gpio_get; 147 + lgpio->chip.get_direction = loongson_gpio_get_direction; 148 + lgpio->chip.direction_output = loongson_gpio_direction_output; 149 + lgpio->chip.set = loongson_gpio_set; 150 + lgpio->chip.parent = dev; 151 + spin_lock_init(&lgpio->lock); 152 + } 153 + 154 + device_property_read_u32(dev, "ngpios", &ngpios); 155 + 156 + lgpio->chip.can_sleep = 0; 157 + lgpio->chip.ngpio = ngpios; 158 + lgpio->chip.label = lgpio->chip_data->label; 159 + lgpio->chip.to_irq = loongson_gpio_to_irq; 160 + 161 + return devm_gpiochip_add_data(dev, &lgpio->chip, lgpio); 162 + } 163 + 164 + static int loongson_gpio_probe(struct platform_device *pdev) 165 + { 166 + void __iomem *reg_base; 167 + struct loongson_gpio_chip *lgpio; 168 + struct device_node *np = pdev->dev.of_node; 169 + struct device *dev = &pdev->dev; 170 + 171 + lgpio = devm_kzalloc(dev, sizeof(*lgpio), GFP_KERNEL); 172 + if (!lgpio) 173 + return -ENOMEM; 174 + 175 + lgpio->chip_data = device_get_match_data(dev); 176 + 177 + reg_base = devm_platform_ioremap_resource(pdev, 0); 178 + if (IS_ERR(reg_base)) 179 + return PTR_ERR(reg_base); 180 + 181 + return loongson_gpio_init(dev, lgpio, np, reg_base); 182 + } 183 + 184 + static const struct loongson_gpio_chip_data loongson_gpio_ls2k_data = { 185 + .label = "ls2k_gpio", 186 + .mode = BIT_CTRL_MODE, 187 + .conf_offset = 0x0, 188 + .in_offset = 0x20, 189 + .out_offset = 0x10, 190 + }; 191 + 192 + static const struct loongson_gpio_chip_data loongson_gpio_ls7a_data = { 193 + .label = "ls7a_gpio", 194 + .mode = BYTE_CTRL_MODE, 195 + .conf_offset = 0x800, 196 + .in_offset = 0xa00, 197 + .out_offset = 0x900, 198 + }; 199 + 200 + static const struct of_device_id loongson_gpio_of_match[] = { 201 + { 202 + .compatible = "loongson,ls2k-gpio", 203 + .data = &loongson_gpio_ls2k_data, 204 + }, 205 + { 206 + .compatible = "loongson,ls7a-gpio", 207 + .data = &loongson_gpio_ls7a_data, 208 + }, 209 + {} 210 + }; 211 + MODULE_DEVICE_TABLE(of, loongson_gpio_of_match); 212 + 213 + static const struct acpi_device_id loongson_gpio_acpi_match[] = { 214 + { 215 + .id = "LOON0002", 216 + .driver_data = (kernel_ulong_t)&loongson_gpio_ls7a_data, 217 + }, 218 + {} 219 + }; 220 + MODULE_DEVICE_TABLE(acpi, loongson_gpio_acpi_match); 221 + 222 + static struct platform_driver loongson_gpio_driver = { 223 + .driver = { 224 + .name = "loongson-gpio", 225 + .of_match_table = loongson_gpio_of_match, 226 + .acpi_match_table = loongson_gpio_acpi_match, 227 + }, 228 + .probe = loongson_gpio_probe, 229 + }; 230 + 231 + static int __init loongson_gpio_setup(void) 232 + { 233 + return platform_driver_register(&loongson_gpio_driver); 234 + } 235 + postcore_initcall(loongson_gpio_setup); 236 + 237 + MODULE_DESCRIPTION("Loongson gpio driver"); 238 + MODULE_LICENSE("GPL");
+43 -28
drivers/gpio/gpio-loongson1.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 1 2 /* 2 3 * GPIO Driver for Loongson 1 SoC 3 4 * 4 - * Copyright (C) 2015-2016 Zhang, Keguang <keguang.zhang@gmail.com> 5 - * 6 - * This file is licensed under the terms of the GNU General Public 7 - * License version 2. This program is licensed "as is" without any 8 - * warranty of any kind, whether express or implied. 5 + * Copyright (C) 2015-2023 Keguang Zhang <keguang.zhang@gmail.com> 9 6 */ 10 7 11 8 #include <linux/module.h> ··· 16 19 #define GPIO_DATA 0x20 17 20 #define GPIO_OUTPUT 0x30 18 21 19 - static void __iomem *gpio_reg_base; 22 + struct ls1x_gpio_chip { 23 + struct gpio_chip gc; 24 + void __iomem *reg_base; 25 + }; 20 26 21 27 static int ls1x_gpio_request(struct gpio_chip *gc, unsigned int offset) 22 28 { 29 + struct ls1x_gpio_chip *ls1x_gc = gpiochip_get_data(gc); 23 30 unsigned long flags; 24 31 25 32 raw_spin_lock_irqsave(&gc->bgpio_lock, flags); 26 - __raw_writel(__raw_readl(gpio_reg_base + GPIO_CFG) | BIT(offset), 27 - gpio_reg_base + GPIO_CFG); 33 + __raw_writel(__raw_readl(ls1x_gc->reg_base + GPIO_CFG) | BIT(offset), 34 + ls1x_gc->reg_base + GPIO_CFG); 28 35 raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); 29 36 30 37 return 0; ··· 36 35 37 36 static void ls1x_gpio_free(struct gpio_chip *gc, unsigned int offset) 38 37 { 38 + struct ls1x_gpio_chip *ls1x_gc = gpiochip_get_data(gc); 39 39 unsigned long flags; 40 40 41 41 raw_spin_lock_irqsave(&gc->bgpio_lock, flags); 42 - __raw_writel(__raw_readl(gpio_reg_base + GPIO_CFG) & ~BIT(offset), 43 - gpio_reg_base + GPIO_CFG); 42 + __raw_writel(__raw_readl(ls1x_gc->reg_base + GPIO_CFG) & ~BIT(offset), 43 + ls1x_gc->reg_base + GPIO_CFG); 44 44 raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); 45 45 } 46 46 47 47 static int ls1x_gpio_probe(struct platform_device *pdev) 48 48 { 49 49 struct device *dev = &pdev->dev; 50 - struct gpio_chip *gc; 50 + struct ls1x_gpio_chip *ls1x_gc; 51 51 int ret; 52 52 53 - gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL); 54 - if (!gc) 53 + ls1x_gc = devm_kzalloc(dev, sizeof(*ls1x_gc), GFP_KERNEL); 54 + if (!ls1x_gc) 55 55 return -ENOMEM; 56 56 57 - gpio_reg_base = devm_platform_ioremap_resource(pdev, 0); 58 - if (IS_ERR(gpio_reg_base)) 59 - return PTR_ERR(gpio_reg_base); 57 + ls1x_gc->reg_base = devm_platform_ioremap_resource(pdev, 0); 58 + if (IS_ERR(ls1x_gc->reg_base)) 59 + return PTR_ERR(ls1x_gc->reg_base); 60 60 61 - ret = bgpio_init(gc, dev, 4, gpio_reg_base + GPIO_DATA, 62 - gpio_reg_base + GPIO_OUTPUT, NULL, 63 - NULL, gpio_reg_base + GPIO_DIR, 0); 61 + ret = bgpio_init(&ls1x_gc->gc, dev, 4, ls1x_gc->reg_base + GPIO_DATA, 62 + ls1x_gc->reg_base + GPIO_OUTPUT, NULL, 63 + NULL, ls1x_gc->reg_base + GPIO_DIR, 0); 64 64 if (ret) 65 65 goto err; 66 66 67 - gc->owner = THIS_MODULE; 68 - gc->request = ls1x_gpio_request; 69 - gc->free = ls1x_gpio_free; 70 - gc->base = pdev->id * 32; 67 + ls1x_gc->gc.owner = THIS_MODULE; 68 + ls1x_gc->gc.request = ls1x_gpio_request; 69 + ls1x_gc->gc.free = ls1x_gpio_free; 70 + /* 71 + * Clear ngpio to let gpiolib get the correct number 72 + * by reading ngpios property 73 + */ 74 + ls1x_gc->gc.ngpio = 0; 71 75 72 - ret = devm_gpiochip_add_data(dev, gc, NULL); 76 + ret = devm_gpiochip_add_data(dev, &ls1x_gc->gc, ls1x_gc); 73 77 if (ret) 74 78 goto err; 75 79 76 - platform_set_drvdata(pdev, gc); 77 - dev_info(dev, "Loongson1 GPIO driver registered\n"); 80 + platform_set_drvdata(pdev, ls1x_gc); 81 + 82 + dev_info(dev, "GPIO controller registered with %d pins\n", 83 + ls1x_gc->gc.ngpio); 78 84 79 85 return 0; 80 86 err: 81 - dev_err(dev, "failed to register GPIO device\n"); 87 + dev_err(dev, "failed to register GPIO controller\n"); 82 88 return ret; 83 89 } 90 + 91 + static const struct of_device_id ls1x_gpio_dt_ids[] = { 92 + { .compatible = "loongson,ls1x-gpio" }, 93 + { /* sentinel */ } 94 + }; 95 + MODULE_DEVICE_TABLE(of, ls1x_gpio_dt_ids); 84 96 85 97 static struct platform_driver ls1x_gpio_driver = { 86 98 .probe = ls1x_gpio_probe, 87 99 .driver = { 88 100 .name = "ls1x-gpio", 101 + .of_match_table = ls1x_gpio_dt_ids, 89 102 }, 90 103 }; 91 104 92 105 module_platform_driver(ls1x_gpio_driver); 93 106 94 - MODULE_AUTHOR("Kelvin Cheung <keguang.zhang@gmail.com>"); 107 + MODULE_AUTHOR("Keguang Zhang <keguang.zhang@gmail.com>"); 95 108 MODULE_DESCRIPTION("Loongson1 GPIO driver"); 96 109 MODULE_LICENSE("GPL");
+6 -2
drivers/gpio/gpio-max732x.c
··· 351 351 struct max732x_chip *chip = gpiochip_get_data(gc); 352 352 353 353 chip->irq_mask_cur &= ~(1 << d->hwirq); 354 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 354 355 } 355 356 356 357 static void max732x_irq_unmask(struct irq_data *d) ··· 359 358 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 360 359 struct max732x_chip *chip = gpiochip_get_data(gc); 361 360 361 + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 362 362 chip->irq_mask_cur |= 1 << d->hwirq; 363 363 } 364 364 ··· 431 429 return 0; 432 430 } 433 431 434 - static struct irq_chip max732x_irq_chip = { 432 + static const struct irq_chip max732x_irq_chip = { 435 433 .name = "max732x", 436 434 .irq_mask = max732x_irq_mask, 437 435 .irq_unmask = max732x_irq_unmask, ··· 439 437 .irq_bus_sync_unlock = max732x_irq_bus_sync_unlock, 440 438 .irq_set_type = max732x_irq_set_type, 441 439 .irq_set_wake = max732x_irq_set_wake, 440 + .flags = IRQCHIP_IMMUTABLE, 441 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 442 442 }; 443 443 444 444 static uint8_t max732x_irq_pending(struct max732x_chip *chip) ··· 521 517 } 522 518 523 519 girq = &chip->gpio_chip.irq; 524 - girq->chip = &max732x_irq_chip; 520 + gpio_irq_chip_set_chip(girq, &max732x_irq_chip); 525 521 /* This will let us handle the parent IRQ in the driver */ 526 522 girq->parent_handler = NULL; 527 523 girq->num_parents = 0;
+32 -421
drivers/gpio/gpio-merrifield.c
··· 2 2 /* 3 3 * Intel Merrifield SoC GPIO driver 4 4 * 5 - * Copyright (c) 2016 Intel Corporation. 5 + * Copyright (c) 2016, 2023 Intel Corporation. 6 6 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 7 7 */ 8 8 9 9 #include <linux/acpi.h> 10 10 #include <linux/bitops.h> 11 - #include <linux/gpio/driver.h> 12 - #include <linux/interrupt.h> 11 + #include <linux/device.h> 12 + #include <linux/err.h> 13 13 #include <linux/io.h> 14 14 #include <linux/module.h> 15 15 #include <linux/pci.h> 16 - #include <linux/pinctrl/consumer.h> 17 - #include <linux/string_helpers.h> 16 + #include <linux/types.h> 18 17 19 - #define GCCR 0x000 /* controller configuration */ 20 - #define GPLR 0x004 /* pin level r/o */ 21 - #define GPDR 0x01c /* pin direction */ 22 - #define GPSR 0x034 /* pin set w/o */ 23 - #define GPCR 0x04c /* pin clear w/o */ 24 - #define GRER 0x064 /* rising edge detect */ 25 - #define GFER 0x07c /* falling edge detect */ 26 - #define GFBR 0x094 /* glitch filter bypass */ 27 - #define GIMR 0x0ac /* interrupt mask */ 28 - #define GISR 0x0c4 /* interrupt source */ 29 - #define GITR 0x300 /* input type */ 30 - #define GLPR 0x318 /* level input polarity */ 31 - #define GWMR 0x400 /* wake mask */ 32 - #define GWSR 0x418 /* wake source */ 33 - #define GSIR 0xc00 /* secure input */ 18 + #include "gpio-tangier.h" 34 19 35 20 /* Intel Merrifield has 192 GPIO pins */ 36 21 #define MRFLD_NGPIO 192 37 22 38 - struct mrfld_gpio_pinrange { 39 - unsigned int gpio_base; 40 - unsigned int pin_base; 41 - unsigned int npins; 42 - }; 43 - 44 - #define GPIO_PINRANGE(gstart, gend, pstart) \ 45 - { \ 46 - .gpio_base = (gstart), \ 47 - .pin_base = (pstart), \ 48 - .npins = (gend) - (gstart) + 1, \ 49 - } 50 - 51 - struct mrfld_gpio { 52 - struct gpio_chip chip; 53 - void __iomem *reg_base; 54 - raw_spinlock_t lock; 55 - struct device *dev; 56 - }; 57 - 58 - static const struct mrfld_gpio_pinrange mrfld_gpio_ranges[] = { 23 + static const struct tng_gpio_pinrange mrfld_gpio_ranges[] = { 59 24 GPIO_PINRANGE(0, 11, 146), 60 25 GPIO_PINRANGE(12, 13, 144), 61 26 GPIO_PINRANGE(14, 15, 35), ··· 49 84 GPIO_PINRANGE(190, 191, 178), 50 85 }; 51 86 52 - static void __iomem *gpio_reg(struct gpio_chip *chip, unsigned int offset, 53 - unsigned int reg_type_offset) 87 + static const char *mrfld_gpio_get_pinctrl_dev_name(struct tng_gpio *priv) 54 88 { 55 - struct mrfld_gpio *priv = gpiochip_get_data(chip); 56 - u8 reg = offset / 32; 57 - 58 - return priv->reg_base + reg_type_offset + reg * 4; 59 - } 60 - 61 - static int mrfld_gpio_get(struct gpio_chip *chip, unsigned int offset) 62 - { 63 - void __iomem *gplr = gpio_reg(chip, offset, GPLR); 64 - 65 - return !!(readl(gplr) & BIT(offset % 32)); 66 - } 67 - 68 - static void mrfld_gpio_set(struct gpio_chip *chip, unsigned int offset, 69 - int value) 70 - { 71 - struct mrfld_gpio *priv = gpiochip_get_data(chip); 72 - void __iomem *gpsr, *gpcr; 73 - unsigned long flags; 74 - 75 - raw_spin_lock_irqsave(&priv->lock, flags); 76 - 77 - if (value) { 78 - gpsr = gpio_reg(chip, offset, GPSR); 79 - writel(BIT(offset % 32), gpsr); 80 - } else { 81 - gpcr = gpio_reg(chip, offset, GPCR); 82 - writel(BIT(offset % 32), gpcr); 83 - } 84 - 85 - raw_spin_unlock_irqrestore(&priv->lock, flags); 86 - } 87 - 88 - static int mrfld_gpio_direction_input(struct gpio_chip *chip, 89 - unsigned int offset) 90 - { 91 - struct mrfld_gpio *priv = gpiochip_get_data(chip); 92 - void __iomem *gpdr = gpio_reg(chip, offset, GPDR); 93 - unsigned long flags; 94 - u32 value; 95 - 96 - raw_spin_lock_irqsave(&priv->lock, flags); 97 - 98 - value = readl(gpdr); 99 - value &= ~BIT(offset % 32); 100 - writel(value, gpdr); 101 - 102 - raw_spin_unlock_irqrestore(&priv->lock, flags); 103 - 104 - return 0; 105 - } 106 - 107 - static int mrfld_gpio_direction_output(struct gpio_chip *chip, 108 - unsigned int offset, int value) 109 - { 110 - struct mrfld_gpio *priv = gpiochip_get_data(chip); 111 - void __iomem *gpdr = gpio_reg(chip, offset, GPDR); 112 - unsigned long flags; 113 - 114 - mrfld_gpio_set(chip, offset, value); 115 - 116 - raw_spin_lock_irqsave(&priv->lock, flags); 117 - 118 - value = readl(gpdr); 119 - value |= BIT(offset % 32); 120 - writel(value, gpdr); 121 - 122 - raw_spin_unlock_irqrestore(&priv->lock, flags); 123 - 124 - return 0; 125 - } 126 - 127 - static int mrfld_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) 128 - { 129 - void __iomem *gpdr = gpio_reg(chip, offset, GPDR); 130 - 131 - if (readl(gpdr) & BIT(offset % 32)) 132 - return GPIO_LINE_DIRECTION_OUT; 133 - 134 - return GPIO_LINE_DIRECTION_IN; 135 - } 136 - 137 - static int mrfld_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset, 138 - unsigned int debounce) 139 - { 140 - struct mrfld_gpio *priv = gpiochip_get_data(chip); 141 - void __iomem *gfbr = gpio_reg(chip, offset, GFBR); 142 - unsigned long flags; 143 - u32 value; 144 - 145 - raw_spin_lock_irqsave(&priv->lock, flags); 146 - 147 - if (debounce) 148 - value = readl(gfbr) & ~BIT(offset % 32); 149 - else 150 - value = readl(gfbr) | BIT(offset % 32); 151 - writel(value, gfbr); 152 - 153 - raw_spin_unlock_irqrestore(&priv->lock, flags); 154 - 155 - return 0; 156 - } 157 - 158 - static int mrfld_gpio_set_config(struct gpio_chip *chip, unsigned int offset, 159 - unsigned long config) 160 - { 161 - u32 debounce; 162 - 163 - if ((pinconf_to_config_param(config) == PIN_CONFIG_BIAS_DISABLE) || 164 - (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_UP) || 165 - (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_DOWN)) 166 - return gpiochip_generic_config(chip, offset, config); 167 - 168 - if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE) 169 - return -ENOTSUPP; 170 - 171 - debounce = pinconf_to_config_argument(config); 172 - return mrfld_gpio_set_debounce(chip, offset, debounce); 173 - } 174 - 175 - static void mrfld_irq_ack(struct irq_data *d) 176 - { 177 - struct mrfld_gpio *priv = irq_data_get_irq_chip_data(d); 178 - u32 gpio = irqd_to_hwirq(d); 179 - void __iomem *gisr = gpio_reg(&priv->chip, gpio, GISR); 180 - unsigned long flags; 181 - 182 - raw_spin_lock_irqsave(&priv->lock, flags); 183 - 184 - writel(BIT(gpio % 32), gisr); 185 - 186 - raw_spin_unlock_irqrestore(&priv->lock, flags); 187 - } 188 - 189 - static void mrfld_irq_unmask_mask(struct mrfld_gpio *priv, u32 gpio, bool unmask) 190 - { 191 - void __iomem *gimr = gpio_reg(&priv->chip, gpio, GIMR); 192 - unsigned long flags; 193 - u32 value; 194 - 195 - raw_spin_lock_irqsave(&priv->lock, flags); 196 - 197 - if (unmask) 198 - value = readl(gimr) | BIT(gpio % 32); 199 - else 200 - value = readl(gimr) & ~BIT(gpio % 32); 201 - writel(value, gimr); 202 - 203 - raw_spin_unlock_irqrestore(&priv->lock, flags); 204 - } 205 - 206 - static void mrfld_irq_mask(struct irq_data *d) 207 - { 208 - struct mrfld_gpio *priv = irq_data_get_irq_chip_data(d); 209 - u32 gpio = irqd_to_hwirq(d); 210 - 211 - mrfld_irq_unmask_mask(priv, gpio, false); 212 - gpiochip_disable_irq(&priv->chip, gpio); 213 - } 214 - 215 - static void mrfld_irq_unmask(struct irq_data *d) 216 - { 217 - struct mrfld_gpio *priv = irq_data_get_irq_chip_data(d); 218 - u32 gpio = irqd_to_hwirq(d); 219 - 220 - gpiochip_enable_irq(&priv->chip, gpio); 221 - mrfld_irq_unmask_mask(priv, gpio, true); 222 - } 223 - 224 - static int mrfld_irq_set_type(struct irq_data *d, unsigned int type) 225 - { 226 - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 227 - struct mrfld_gpio *priv = gpiochip_get_data(gc); 228 - u32 gpio = irqd_to_hwirq(d); 229 - void __iomem *grer = gpio_reg(&priv->chip, gpio, GRER); 230 - void __iomem *gfer = gpio_reg(&priv->chip, gpio, GFER); 231 - void __iomem *gitr = gpio_reg(&priv->chip, gpio, GITR); 232 - void __iomem *glpr = gpio_reg(&priv->chip, gpio, GLPR); 233 - unsigned long flags; 234 - u32 value; 235 - 236 - raw_spin_lock_irqsave(&priv->lock, flags); 237 - 238 - if (type & IRQ_TYPE_EDGE_RISING) 239 - value = readl(grer) | BIT(gpio % 32); 240 - else 241 - value = readl(grer) & ~BIT(gpio % 32); 242 - writel(value, grer); 243 - 244 - if (type & IRQ_TYPE_EDGE_FALLING) 245 - value = readl(gfer) | BIT(gpio % 32); 246 - else 247 - value = readl(gfer) & ~BIT(gpio % 32); 248 - writel(value, gfer); 249 - 250 - /* 251 - * To prevent glitches from triggering an unintended level interrupt, 252 - * configure GLPR register first and then configure GITR. 253 - */ 254 - if (type & IRQ_TYPE_LEVEL_LOW) 255 - value = readl(glpr) | BIT(gpio % 32); 256 - else 257 - value = readl(glpr) & ~BIT(gpio % 32); 258 - writel(value, glpr); 259 - 260 - if (type & IRQ_TYPE_LEVEL_MASK) { 261 - value = readl(gitr) | BIT(gpio % 32); 262 - writel(value, gitr); 263 - 264 - irq_set_handler_locked(d, handle_level_irq); 265 - } else if (type & IRQ_TYPE_EDGE_BOTH) { 266 - value = readl(gitr) & ~BIT(gpio % 32); 267 - writel(value, gitr); 268 - 269 - irq_set_handler_locked(d, handle_edge_irq); 270 - } 271 - 272 - raw_spin_unlock_irqrestore(&priv->lock, flags); 273 - 274 - return 0; 275 - } 276 - 277 - static int mrfld_irq_set_wake(struct irq_data *d, unsigned int on) 278 - { 279 - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 280 - struct mrfld_gpio *priv = gpiochip_get_data(gc); 281 - u32 gpio = irqd_to_hwirq(d); 282 - void __iomem *gwmr = gpio_reg(&priv->chip, gpio, GWMR); 283 - void __iomem *gwsr = gpio_reg(&priv->chip, gpio, GWSR); 284 - unsigned long flags; 285 - u32 value; 286 - 287 - raw_spin_lock_irqsave(&priv->lock, flags); 288 - 289 - /* Clear the existing wake status */ 290 - writel(BIT(gpio % 32), gwsr); 291 - 292 - if (on) 293 - value = readl(gwmr) | BIT(gpio % 32); 294 - else 295 - value = readl(gwmr) & ~BIT(gpio % 32); 296 - writel(value, gwmr); 297 - 298 - raw_spin_unlock_irqrestore(&priv->lock, flags); 299 - 300 - dev_dbg(priv->dev, "%s wake for gpio %u\n", str_enable_disable(on), gpio); 301 - return 0; 302 - } 303 - 304 - static const struct irq_chip mrfld_irqchip = { 305 - .name = "gpio-merrifield", 306 - .irq_ack = mrfld_irq_ack, 307 - .irq_mask = mrfld_irq_mask, 308 - .irq_unmask = mrfld_irq_unmask, 309 - .irq_set_type = mrfld_irq_set_type, 310 - .irq_set_wake = mrfld_irq_set_wake, 311 - .flags = IRQCHIP_IMMUTABLE, 312 - GPIOCHIP_IRQ_RESOURCE_HELPERS, 313 - }; 314 - 315 - static void mrfld_irq_handler(struct irq_desc *desc) 316 - { 317 - struct gpio_chip *gc = irq_desc_get_handler_data(desc); 318 - struct mrfld_gpio *priv = gpiochip_get_data(gc); 319 - struct irq_chip *irqchip = irq_desc_get_chip(desc); 320 - unsigned long base, gpio; 321 - 322 - chained_irq_enter(irqchip, desc); 323 - 324 - /* Check GPIO controller to check which pin triggered the interrupt */ 325 - for (base = 0; base < priv->chip.ngpio; base += 32) { 326 - void __iomem *gisr = gpio_reg(&priv->chip, base, GISR); 327 - void __iomem *gimr = gpio_reg(&priv->chip, base, GIMR); 328 - unsigned long pending, enabled; 329 - 330 - pending = readl(gisr); 331 - enabled = readl(gimr); 332 - 333 - /* Only interrupts that are enabled */ 334 - pending &= enabled; 335 - 336 - for_each_set_bit(gpio, &pending, 32) 337 - generic_handle_domain_irq(gc->irq.domain, base + gpio); 338 - } 339 - 340 - chained_irq_exit(irqchip, desc); 341 - } 342 - 343 - static int mrfld_irq_init_hw(struct gpio_chip *chip) 344 - { 345 - struct mrfld_gpio *priv = gpiochip_get_data(chip); 346 - void __iomem *reg; 347 - unsigned int base; 348 - 349 - for (base = 0; base < priv->chip.ngpio; base += 32) { 350 - /* Clear the rising-edge detect register */ 351 - reg = gpio_reg(&priv->chip, base, GRER); 352 - writel(0, reg); 353 - /* Clear the falling-edge detect register */ 354 - reg = gpio_reg(&priv->chip, base, GFER); 355 - writel(0, reg); 356 - } 357 - 358 - return 0; 359 - } 360 - 361 - static const char *mrfld_gpio_get_pinctrl_dev_name(struct mrfld_gpio *priv) 362 - { 89 + struct device *dev = priv->dev; 363 90 struct acpi_device *adev; 364 91 const char *name; 365 92 366 93 adev = acpi_dev_get_first_match_dev("INTC1002", NULL, -1); 367 94 if (adev) { 368 - name = devm_kstrdup(priv->dev, acpi_dev_name(adev), GFP_KERNEL); 95 + name = devm_kstrdup(dev, acpi_dev_name(adev), GFP_KERNEL); 369 96 acpi_dev_put(adev); 370 97 } else { 371 98 name = "pinctrl-merrifield"; ··· 66 409 return name; 67 410 } 68 411 69 - static int mrfld_gpio_add_pin_ranges(struct gpio_chip *chip) 70 - { 71 - struct mrfld_gpio *priv = gpiochip_get_data(chip); 72 - const struct mrfld_gpio_pinrange *range; 73 - const char *pinctrl_dev_name; 74 - unsigned int i; 75 - int retval; 76 - 77 - pinctrl_dev_name = mrfld_gpio_get_pinctrl_dev_name(priv); 78 - if (!pinctrl_dev_name) 79 - return -ENOMEM; 80 - 81 - for (i = 0; i < ARRAY_SIZE(mrfld_gpio_ranges); i++) { 82 - range = &mrfld_gpio_ranges[i]; 83 - retval = gpiochip_add_pin_range(&priv->chip, pinctrl_dev_name, 84 - range->gpio_base, 85 - range->pin_base, 86 - range->npins); 87 - if (retval) { 88 - dev_err(priv->dev, "failed to add GPIO pin range\n"); 89 - return retval; 90 - } 91 - } 92 - 93 - return 0; 94 - } 95 - 96 412 static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id) 97 413 { 98 - struct gpio_irq_chip *girq; 99 - struct mrfld_gpio *priv; 414 + struct device *dev = &pdev->dev; 415 + struct tng_gpio *priv; 100 416 u32 gpio_base, irq_base; 101 417 void __iomem *base; 102 418 int retval; ··· 79 449 return retval; 80 450 81 451 retval = pcim_iomap_regions(pdev, BIT(1) | BIT(0), pci_name(pdev)); 82 - if (retval) { 83 - dev_err(&pdev->dev, "I/O memory mapping error\n"); 84 - return retval; 85 - } 452 + if (retval) 453 + return dev_err_probe(dev, retval, "I/O memory mapping error\n"); 86 454 87 455 base = pcim_iomap_table(pdev)[1]; 88 456 ··· 90 462 /* Release the IO mapping, since we already get the info from BAR1 */ 91 463 pcim_iounmap_regions(pdev, BIT(1)); 92 464 93 - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 465 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 94 466 if (!priv) 95 467 return -ENOMEM; 96 468 97 - priv->dev = &pdev->dev; 469 + priv->dev = dev; 98 470 priv->reg_base = pcim_iomap_table(pdev)[0]; 99 471 100 - priv->chip.label = dev_name(&pdev->dev); 101 - priv->chip.parent = &pdev->dev; 102 - priv->chip.request = gpiochip_generic_request; 103 - priv->chip.free = gpiochip_generic_free; 104 - priv->chip.direction_input = mrfld_gpio_direction_input; 105 - priv->chip.direction_output = mrfld_gpio_direction_output; 106 - priv->chip.get = mrfld_gpio_get; 107 - priv->chip.set = mrfld_gpio_set; 108 - priv->chip.get_direction = mrfld_gpio_get_direction; 109 - priv->chip.set_config = mrfld_gpio_set_config; 110 - priv->chip.base = gpio_base; 111 - priv->chip.ngpio = MRFLD_NGPIO; 112 - priv->chip.can_sleep = false; 113 - priv->chip.add_pin_ranges = mrfld_gpio_add_pin_ranges; 472 + priv->pin_info.pin_ranges = mrfld_gpio_ranges; 473 + priv->pin_info.nranges = ARRAY_SIZE(mrfld_gpio_ranges); 474 + priv->pin_info.name = mrfld_gpio_get_pinctrl_dev_name(priv); 475 + if (!priv->pin_info.name) 476 + return -ENOMEM; 114 477 115 - raw_spin_lock_init(&priv->lock); 478 + priv->info.base = gpio_base; 479 + priv->info.ngpio = MRFLD_NGPIO; 480 + priv->info.first = irq_base; 116 481 117 482 retval = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); 118 483 if (retval < 0) 119 484 return retval; 120 485 121 - girq = &priv->chip.irq; 122 - gpio_irq_chip_set_chip(girq, &mrfld_irqchip); 123 - girq->init_hw = mrfld_irq_init_hw; 124 - girq->parent_handler = mrfld_irq_handler; 125 - girq->num_parents = 1; 126 - girq->parents = devm_kcalloc(&pdev->dev, girq->num_parents, 127 - sizeof(*girq->parents), GFP_KERNEL); 128 - if (!girq->parents) 129 - return -ENOMEM; 130 - girq->parents[0] = pci_irq_vector(pdev, 0); 131 - girq->first = irq_base; 132 - girq->default_type = IRQ_TYPE_NONE; 133 - girq->handler = handle_bad_irq; 486 + priv->irq = pci_irq_vector(pdev, 0); 134 487 135 - retval = devm_gpiochip_add_data(&pdev->dev, &priv->chip, priv); 136 - if (retval) { 137 - dev_err(&pdev->dev, "gpiochip_add error %d\n", retval); 138 - return retval; 139 - } 488 + priv->wake_regs.gwmr = GWMR_MRFLD; 489 + priv->wake_regs.gwsr = GWSR_MRFLD; 490 + priv->wake_regs.gsir = GSIR_MRFLD; 491 + 492 + retval = devm_tng_gpio_probe(dev, priv); 493 + if (retval) 494 + return dev_err_probe(dev, retval, "tng_gpio_probe error\n"); 140 495 141 496 pci_set_drvdata(pdev, priv); 142 497 return 0; ··· 136 525 .id_table = mrfld_gpio_ids, 137 526 .probe = mrfld_gpio_probe, 138 527 }; 139 - 140 528 module_pci_driver(mrfld_gpio_driver); 141 529 142 530 MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>"); 143 531 MODULE_DESCRIPTION("Intel Merrifield SoC GPIO driver"); 144 532 MODULE_LICENSE("GPL v2"); 533 + MODULE_IMPORT_NS(GPIO_TANGIER);
+25 -7
drivers/gpio/gpio-mlxbf2.c
··· 17 17 #include <linux/platform_device.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/resource.h> 20 + #include <linux/seq_file.h> 20 21 #include <linux/spinlock.h> 21 22 #include <linux/types.h> 22 23 ··· 66 65 /* BlueField-2 gpio block context structure. */ 67 66 struct mlxbf2_gpio_context { 68 67 struct gpio_chip gc; 69 - struct irq_chip irq_chip; 70 68 71 69 /* YU GPIO blocks address */ 72 70 void __iomem *gpio_io; 71 + struct device *dev; 73 72 74 73 struct mlxbf2_gpio_context_save_regs *csave_regs; 75 74 }; ··· 238 237 unsigned long flags; 239 238 u32 val; 240 239 240 + gpiochip_enable_irq(gc, irqd_to_hwirq(irqd)); 241 241 raw_spin_lock_irqsave(&gs->gc.bgpio_lock, flags); 242 242 val = readl(gs->gpio_io + YU_GPIO_CAUSE_OR_CLRCAUSE); 243 243 val |= BIT(offset); ··· 263 261 val &= ~BIT(offset); 264 262 writel(val, gs->gpio_io + YU_GPIO_CAUSE_OR_EVTEN0); 265 263 raw_spin_unlock_irqrestore(&gs->gc.bgpio_lock, flags); 264 + gpiochip_disable_irq(gc, irqd_to_hwirq(irqd)); 266 265 } 267 266 268 267 static irqreturn_t mlxbf2_gpio_irq_handler(int irq, void *ptr) ··· 325 322 return 0; 326 323 } 327 324 325 + static void mlxbf2_gpio_irq_print_chip(struct irq_data *irqd, 326 + struct seq_file *p) 327 + { 328 + struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); 329 + struct mlxbf2_gpio_context *gs = gpiochip_get_data(gc); 330 + 331 + seq_printf(p, dev_name(gs->dev)); 332 + } 333 + 334 + static const struct irq_chip mlxbf2_gpio_irq_chip = { 335 + .irq_set_type = mlxbf2_gpio_irq_set_type, 336 + .irq_enable = mlxbf2_gpio_irq_enable, 337 + .irq_disable = mlxbf2_gpio_irq_disable, 338 + .irq_print_chip = mlxbf2_gpio_irq_print_chip, 339 + .flags = IRQCHIP_IMMUTABLE, 340 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 341 + }; 342 + 328 343 /* BlueField-2 GPIO driver initialization routine. */ 329 344 static int 330 345 mlxbf2_gpio_probe(struct platform_device *pdev) ··· 360 339 gs = devm_kzalloc(dev, sizeof(*gs), GFP_KERNEL); 361 340 if (!gs) 362 341 return -ENOMEM; 342 + 343 + gs->dev = dev; 363 344 364 345 /* YU GPIO block address */ 365 346 gs->gpio_io = devm_platform_ioremap_resource(pdev, 0); ··· 399 376 400 377 irq = platform_get_irq(pdev, 0); 401 378 if (irq >= 0) { 402 - gs->irq_chip.name = name; 403 - gs->irq_chip.irq_set_type = mlxbf2_gpio_irq_set_type; 404 - gs->irq_chip.irq_enable = mlxbf2_gpio_irq_enable; 405 - gs->irq_chip.irq_disable = mlxbf2_gpio_irq_disable; 406 - 407 379 girq = &gs->gc.irq; 408 - girq->chip = &gs->irq_chip; 380 + gpio_irq_chip_set_chip(girq, &mlxbf2_gpio_irq_chip); 409 381 girq->handler = handle_simple_irq; 410 382 girq->default_type = IRQ_TYPE_NONE; 411 383 /* This will let us handle the parent IRQ in the driver */
+1 -1
drivers/gpio/gpio-mm-lantiq.c
··· 10 10 #include <linux/platform_device.h> 11 11 #include <linux/mutex.h> 12 12 #include <linux/gpio/driver.h> 13 + #include <linux/gpio/legacy-of-mm-gpiochip.h> 13 14 #include <linux/of.h> 14 - #include <linux/of_gpio.h> 15 15 #include <linux/io.h> 16 16 #include <linux/slab.h> 17 17
+1 -1
drivers/gpio/gpio-mpc5200.c
··· 8 8 #include <linux/of.h> 9 9 #include <linux/kernel.h> 10 10 #include <linux/slab.h> 11 - #include <linux/of_gpio.h> 11 + #include <linux/gpio/legacy-of-mm-gpiochip.h> 12 12 #include <linux/io.h> 13 13 #include <linux/of_platform.h> 14 14 #include <linux/module.h>
+22 -4
drivers/gpio/gpio-msc313.c
··· 532 532 return 0; 533 533 } 534 534 535 + static void msc313_gpio_irq_mask(struct irq_data *d) 536 + { 537 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 538 + 539 + irq_chip_mask_parent(d); 540 + gpiochip_disable_irq(gc, d->hwirq); 541 + } 542 + 543 + static void msc313_gpio_irq_unmask(struct irq_data *d) 544 + { 545 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 546 + 547 + gpiochip_enable_irq(gc, d->hwirq); 548 + irq_chip_unmask_parent(d); 549 + } 550 + 535 551 /* 536 552 * The interrupt handling happens in the parent interrupt controller, 537 553 * we don't do anything here. 538 554 */ 539 - static struct irq_chip msc313_gpio_irqchip = { 555 + static const struct irq_chip msc313_gpio_irqchip = { 540 556 .name = "GPIO", 541 557 .irq_eoi = irq_chip_eoi_parent, 542 - .irq_mask = irq_chip_mask_parent, 543 - .irq_unmask = irq_chip_unmask_parent, 558 + .irq_mask = msc313_gpio_irq_mask, 559 + .irq_unmask = msc313_gpio_irq_unmask, 544 560 .irq_set_type = irq_chip_set_type_parent, 545 561 .irq_set_affinity = irq_chip_set_affinity_parent, 562 + .flags = IRQCHIP_IMMUTABLE, 563 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 546 564 }; 547 565 548 566 /* ··· 662 644 gpiochip->names = gpio->gpio_data->names; 663 645 664 646 gpioirqchip = &gpiochip->irq; 665 - gpioirqchip->chip = &msc313_gpio_irqchip; 647 + gpio_irq_chip_set_chip(gpioirqchip, &msc313_gpio_irqchip); 666 648 gpioirqchip->fwnode = of_node_to_fwnode(dev->of_node); 667 649 gpioirqchip->parent_domain = parent_domain; 668 650 gpioirqchip->child_to_parent_hwirq = msc313e_gpio_child_to_parent_hwirq;
-1
drivers/gpio/gpio-mxs.c
··· 364 364 "Daniel Mack <danielncaiaq.de>, " 365 365 "Juergen Beisert <kernel@pengutronix.de>"); 366 366 MODULE_DESCRIPTION("Freescale MXS GPIO"); 367 - MODULE_LICENSE("GPL");
+45 -38
drivers/gpio/gpio-omap.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/module.h> 14 14 #include <linux/interrupt.h> 15 + #include <linux/seq_file.h> 15 16 #include <linux/syscore_ops.h> 16 17 #include <linux/err.h> 17 18 #include <linux/clk.h> ··· 48 47 struct gpio_bank { 49 48 void __iomem *base; 50 49 const struct omap_gpio_reg_offs *regs; 50 + struct device *dev; 51 51 52 52 int irq; 53 53 u32 non_wakeup_gpios; ··· 683 681 omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); 684 682 omap_set_gpio_irqenable(bank, offset, 0); 685 683 raw_spin_unlock_irqrestore(&bank->lock, flags); 684 + gpiochip_disable_irq(&bank->chip, offset); 686 685 } 687 686 688 687 static void omap_gpio_unmask_irq(struct irq_data *d) ··· 693 690 u32 trigger = irqd_get_trigger_type(d); 694 691 unsigned long flags; 695 692 693 + gpiochip_enable_irq(&bank->chip, offset); 696 694 raw_spin_lock_irqsave(&bank->lock, flags); 697 695 omap_set_gpio_irqenable(bank, offset, 1); 698 696 ··· 711 707 712 708 raw_spin_unlock_irqrestore(&bank->lock, flags); 713 709 } 710 + 711 + static void omap_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) 712 + { 713 + struct gpio_bank *bank = omap_irq_data_get_bank(d); 714 + 715 + seq_printf(p, dev_name(bank->dev)); 716 + } 717 + 718 + static const struct irq_chip omap_gpio_irq_chip = { 719 + .irq_startup = omap_gpio_irq_startup, 720 + .irq_shutdown = omap_gpio_irq_shutdown, 721 + .irq_mask = omap_gpio_mask_irq, 722 + .irq_unmask = omap_gpio_unmask_irq, 723 + .irq_set_type = omap_gpio_irq_type, 724 + .irq_set_wake = omap_gpio_wake_enable, 725 + .irq_bus_lock = omap_gpio_irq_bus_lock, 726 + .irq_bus_sync_unlock = gpio_irq_bus_sync_unlock, 727 + .irq_print_chip = omap_gpio_irq_print_chip, 728 + .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE, 729 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 730 + }; 731 + 732 + static const struct irq_chip omap_gpio_irq_chip_nowake = { 733 + .irq_startup = omap_gpio_irq_startup, 734 + .irq_shutdown = omap_gpio_irq_shutdown, 735 + .irq_mask = omap_gpio_mask_irq, 736 + .irq_unmask = omap_gpio_unmask_irq, 737 + .irq_set_type = omap_gpio_irq_type, 738 + .irq_bus_lock = omap_gpio_irq_bus_lock, 739 + .irq_bus_sync_unlock = gpio_irq_bus_sync_unlock, 740 + .irq_print_chip = omap_gpio_irq_print_chip, 741 + .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE, 742 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 743 + }; 714 744 715 745 /*---------------------------------------------------------------------*/ 716 746 ··· 1024 986 writel_relaxed(0, base + bank->regs->ctrl); 1025 987 } 1026 988 1027 - static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc, 1028 - struct device *pm_dev) 989 + static int omap_gpio_chip_init(struct gpio_bank *bank, struct device *pm_dev) 1029 990 { 1030 991 struct gpio_irq_chip *irq; 1031 992 static int gpio; 1032 993 const char *label; 1033 - int irq_base = 0; 1034 994 int ret; 1035 995 1036 996 /* ··· 1060 1024 } 1061 1025 bank->chip.ngpio = bank->width; 1062 1026 1063 - #ifdef CONFIG_ARCH_OMAP1 1064 - /* 1065 - * REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop 1066 - * irq_alloc_descs() since a base IRQ offset will no longer be needed. 1067 - */ 1068 - irq_base = devm_irq_alloc_descs(bank->chip.parent, 1069 - -1, 0, bank->width, 0); 1070 - if (irq_base < 0) { 1071 - dev_err(bank->chip.parent, "Couldn't allocate IRQ numbers\n"); 1072 - return -ENODEV; 1073 - } 1074 - #endif 1075 - 1027 + irq = &bank->chip.irq; 1076 1028 /* MPUIO is a bit different, reading IRQ status clears it */ 1077 1029 if (bank->is_mpuio && !bank->regs->wkup_en) 1078 - irqc->irq_set_wake = NULL; 1079 - 1080 - irq = &bank->chip.irq; 1081 - irq->chip = irqc; 1030 + gpio_irq_chip_set_chip(irq, &omap_gpio_irq_chip_nowake); 1031 + else 1032 + gpio_irq_chip_set_chip(irq, &omap_gpio_irq_chip); 1082 1033 irq->handler = handle_bad_irq; 1083 1034 irq->default_type = IRQ_TYPE_NONE; 1084 1035 irq->num_parents = 1; 1085 1036 irq->parents = &bank->irq; 1086 - irq->first = irq_base; 1087 1037 1088 1038 ret = gpiochip_add_data(&bank->chip, bank); 1089 1039 if (ret) ··· 1398 1376 struct device_node *node = dev->of_node; 1399 1377 const struct omap_gpio_platform_data *pdata; 1400 1378 struct gpio_bank *bank; 1401 - struct irq_chip *irqc; 1402 1379 int ret; 1403 1380 1404 1381 pdata = device_get_match_data(dev); ··· 1410 1389 if (!bank) 1411 1390 return -ENOMEM; 1412 1391 1413 - irqc = devm_kzalloc(dev, sizeof(*irqc), GFP_KERNEL); 1414 - if (!irqc) 1415 - return -ENOMEM; 1416 - 1417 - irqc->irq_startup = omap_gpio_irq_startup, 1418 - irqc->irq_shutdown = omap_gpio_irq_shutdown, 1419 - irqc->irq_ack = dummy_irq_chip.irq_ack, 1420 - irqc->irq_mask = omap_gpio_mask_irq, 1421 - irqc->irq_unmask = omap_gpio_unmask_irq, 1422 - irqc->irq_set_type = omap_gpio_irq_type, 1423 - irqc->irq_set_wake = omap_gpio_wake_enable, 1424 - irqc->irq_bus_lock = omap_gpio_irq_bus_lock, 1425 - irqc->irq_bus_sync_unlock = gpio_irq_bus_sync_unlock, 1426 - irqc->name = dev_name(&pdev->dev); 1427 - irqc->flags = IRQCHIP_MASK_ON_SUSPEND; 1392 + bank->dev = dev; 1428 1393 1429 1394 bank->irq = platform_get_irq(pdev, 0); 1430 1395 if (bank->irq <= 0) { ··· 1474 1467 1475 1468 omap_gpio_mod_init(bank); 1476 1469 1477 - ret = omap_gpio_chip_init(bank, irqc, dev); 1470 + ret = omap_gpio_chip_init(bank, dev); 1478 1471 if (ret) { 1479 1472 pm_runtime_put_sync(dev); 1480 1473 pm_runtime_disable(dev);
+9 -3
drivers/gpio/gpio-pci-idio-16.c
··· 107 107 108 108 raw_spin_unlock_irqrestore(&idio16gpio->lock, flags); 109 109 } 110 + 111 + gpiochip_disable_irq(chip, irqd_to_hwirq(data)); 110 112 } 111 113 112 114 static void idio_16_irq_unmask(struct irq_data *data) ··· 118 116 const unsigned long mask = BIT(irqd_to_hwirq(data)); 119 117 const unsigned long prev_irq_mask = idio16gpio->irq_mask; 120 118 unsigned long flags; 119 + 120 + gpiochip_enable_irq(chip, irqd_to_hwirq(data)); 121 121 122 122 idio16gpio->irq_mask |= mask; 123 123 ··· 142 138 return 0; 143 139 } 144 140 145 - static struct irq_chip idio_16_irqchip = { 141 + static const struct irq_chip idio_16_irqchip = { 146 142 .name = "pci-idio-16", 147 143 .irq_ack = idio_16_irq_ack, 148 144 .irq_mask = idio_16_irq_mask, 149 145 .irq_unmask = idio_16_irq_unmask, 150 - .irq_set_type = idio_16_irq_set_type 146 + .irq_set_type = idio_16_irq_set_type, 147 + .flags = IRQCHIP_IMMUTABLE, 148 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 151 149 }; 152 150 153 151 static irqreturn_t idio_16_irq_handler(int irq, void *dev_id) ··· 248 242 idio_16_state_init(&idio16gpio->state); 249 243 250 244 girq = &idio16gpio->chip.irq; 251 - girq->chip = &idio_16_irqchip; 245 + gpio_irq_chip_set_chip(girq, &idio_16_irqchip); 252 246 /* This will let us handle the parent IRQ in the driver */ 253 247 girq->parent_handler = NULL; 254 248 girq->num_parents = 0;
+9 -12
drivers/gpio/gpio-pcie-idio-24.c
··· 3 3 * GPIO driver for the ACCES PCIe-IDIO-24 family 4 4 * Copyright (C) 2018 William Breathitt Gray 5 5 * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License, version 2, as 8 - * published by the Free Software Foundation. 9 - * 10 - * This program is distributed in the hope that it will be useful, but 11 - * WITHOUT ANY WARRANTY; without even the implied warranty of 12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 - * General Public License for more details. 14 - * 15 6 * This driver supports the following ACCES devices: PCIe-IDIO-24, 16 7 * PCIe-IDI-24, PCIe-IDO-24, and PCIe-IDIO-12. 17 8 */ ··· 387 396 } 388 397 389 398 raw_spin_unlock_irqrestore(&idio24gpio->lock, flags); 399 + 400 + gpiochip_disable_irq(chip, irqd_to_hwirq(data)); 390 401 } 391 402 392 403 static void idio_24_irq_unmask(struct irq_data *data) ··· 400 407 const unsigned long bit_offset = irqd_to_hwirq(data) - 24; 401 408 const unsigned long bank_offset = bit_offset / 8; 402 409 unsigned char cos_enable_state; 410 + 411 + gpiochip_enable_irq(chip, irqd_to_hwirq(data)); 403 412 404 413 raw_spin_lock_irqsave(&idio24gpio->lock, flags); 405 414 ··· 432 437 return 0; 433 438 } 434 439 435 - static struct irq_chip idio_24_irqchip = { 440 + static const struct irq_chip idio_24_irqchip = { 436 441 .name = "pcie-idio-24", 437 442 .irq_ack = idio_24_irq_ack, 438 443 .irq_mask = idio_24_irq_mask, 439 444 .irq_unmask = idio_24_irq_unmask, 440 - .irq_set_type = idio_24_irq_set_type 445 + .irq_set_type = idio_24_irq_set_type, 446 + .flags = IRQCHIP_IMMUTABLE, 447 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 441 448 }; 442 449 443 450 static irqreturn_t idio_24_irq_handler(int irq, void *dev_id) ··· 532 535 idio24gpio->chip.set_multiple = idio_24_gpio_set_multiple; 533 536 534 537 girq = &idio24gpio->chip.irq; 535 - girq->chip = &idio_24_irqchip; 538 + gpio_irq_chip_set_chip(girq, &idio_24_irqchip); 536 539 /* This will let us handle the parent IRQ in the driver */ 537 540 girq->parent_handler = NULL; 538 541 girq->num_parents = 0;
-5
drivers/gpio/gpio-pxa.c
··· 171 171 return chip_to_pxachip(c)->banks + gpio / 32; 172 172 } 173 173 174 - static inline int gpio_is_pxa_type(int type) 175 - { 176 - return (type & MMP_GPIO) == 0; 177 - } 178 - 179 174 static inline int gpio_is_mmp_type(int type) 180 175 { 181 176 return (type & MMP_GPIO) != 0;
+1 -1
drivers/gpio/gpio-raspberrypi-exp.c
··· 234 234 return devm_gpiochip_add_data(dev, &rpi_gpio->gc, rpi_gpio); 235 235 } 236 236 237 - static const struct of_device_id rpi_exp_gpio_ids[] = { 237 + static const struct of_device_id rpi_exp_gpio_ids[] __maybe_unused = { 238 238 { .compatible = "raspberrypi,firmware-gpio" }, 239 239 { } 240 240 };
+1 -1
drivers/gpio/gpio-rcar.c
··· 663 663 .driver = { 664 664 .name = "gpio_rcar", 665 665 .pm = &gpio_rcar_pm_ops, 666 - .of_match_table = of_match_ptr(gpio_rcar_of_table), 666 + .of_match_table = gpio_rcar_of_table, 667 667 } 668 668 }; 669 669
+13 -10
drivers/gpio/gpio-rda.c
··· 38 38 struct gpio_chip chip; 39 39 void __iomem *base; 40 40 spinlock_t lock; 41 - struct irq_chip irq_chip; 42 41 int irq; 43 42 }; 44 43 ··· 73 74 value |= BIT(offset) << RDA_GPIO_IRQ_FALL_SHIFT; 74 75 75 76 writel_relaxed(value, base + RDA_GPIO_INT_CTRL_CLR); 77 + gpiochip_disable_irq(chip, offset); 76 78 } 77 79 78 80 static void rda_gpio_irq_ack(struct irq_data *data) ··· 154 154 u32 offset = irqd_to_hwirq(data); 155 155 u32 trigger = irqd_get_trigger_type(data); 156 156 157 + gpiochip_enable_irq(chip, offset); 157 158 rda_gpio_set_irq(chip, offset, trigger); 158 159 } 159 160 ··· 195 194 196 195 chained_irq_exit(ic, desc); 197 196 } 197 + 198 + static const struct irq_chip rda_gpio_irq_chip = { 199 + .name = "rda-gpio", 200 + .irq_ack = rda_gpio_irq_ack, 201 + .irq_mask = rda_gpio_irq_mask, 202 + .irq_unmask = rda_gpio_irq_unmask, 203 + .irq_set_type = rda_gpio_irq_set_type, 204 + .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_IMMUTABLE, 205 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 206 + }; 198 207 199 208 static int rda_gpio_probe(struct platform_device *pdev) 200 209 { ··· 252 241 rda_gpio->chip.base = -1; 253 242 254 243 if (rda_gpio->irq >= 0) { 255 - rda_gpio->irq_chip.name = "rda-gpio", 256 - rda_gpio->irq_chip.irq_ack = rda_gpio_irq_ack, 257 - rda_gpio->irq_chip.irq_mask = rda_gpio_irq_mask, 258 - rda_gpio->irq_chip.irq_unmask = rda_gpio_irq_unmask, 259 - rda_gpio->irq_chip.irq_set_type = rda_gpio_irq_set_type, 260 - rda_gpio->irq_chip.flags = IRQCHIP_SKIP_SET_WAKE, 261 - 262 244 girq = &rda_gpio->chip.irq; 263 - girq->chip = &rda_gpio->irq_chip; 245 + gpio_irq_chip_set_chip(girq, &rda_gpio_irq_chip); 264 246 girq->handler = handle_bad_irq; 265 247 girq->default_type = IRQ_TYPE_NONE; 266 248 girq->parent_handler = rda_gpio_irq_handler; ··· 290 286 291 287 MODULE_DESCRIPTION("RDA Micro GPIO driver"); 292 288 MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>"); 293 - MODULE_LICENSE("GPL v2");
+10 -2
drivers/gpio/gpio-reg.c
··· 4 4 * 5 5 * Copyright (C) 2016 Russell King 6 6 */ 7 - #include <linux/gpio/driver.h> 8 - #include <linux/gpio/gpio-reg.h> 7 + #include <linux/bits.h> 8 + #include <linux/container_of.h> 9 + #include <linux/device.h> 10 + #include <linux/err.h> 11 + #include <linux/errno.h> 9 12 #include <linux/io.h> 13 + #include <linux/irqdomain.h> 10 14 #include <linux/slab.h> 11 15 #include <linux/spinlock.h> 16 + #include <linux/types.h> 17 + 18 + #include <linux/gpio/driver.h> 19 + #include <linux/gpio/gpio-reg.h> 12 20 13 21 struct gpio_reg { 14 22 struct gpio_chip gc;
+9 -3
drivers/gpio/gpio-regmap.c
··· 5 5 * Copyright 2020 Michael Walle <michael@walle.cc> 6 6 */ 7 7 8 - #include <linux/gpio/driver.h> 9 - #include <linux/gpio/regmap.h> 10 - #include <linux/kernel.h> 8 + #include <linux/bits.h> 9 + #include <linux/device.h> 10 + #include <linux/err.h> 11 + #include <linux/io.h> 11 12 #include <linux/module.h> 12 13 #include <linux/regmap.h> 14 + #include <linux/slab.h> 15 + #include <linux/types.h> 16 + 17 + #include <linux/gpio/driver.h> 18 + #include <linux/gpio/regmap.h> 13 19 14 20 struct gpio_regmap { 15 21 struct device *parent;
+1 -1
drivers/gpio/gpio-sama5d2-piobu.c
··· 236 236 static struct platform_driver sama5d2_piobu_driver = { 237 237 .driver = { 238 238 .name = "sama5d2-piobu", 239 - .of_match_table = of_match_ptr(sama5d2_piobu_ids) 239 + .of_match_table = sama5d2_piobu_ids, 240 240 }, 241 241 .probe = sama5d2_piobu_probe, 242 242 };
+1 -1
drivers/gpio/gpio-sifive.c
··· 270 270 .probe = sifive_gpio_probe, 271 271 .driver = { 272 272 .name = "sifive_gpio", 273 - .of_match_table = of_match_ptr(sifive_gpio_match), 273 + .of_match_table = sifive_gpio_match, 274 274 }, 275 275 }; 276 276 builtin_platform_driver(sifive_gpio_driver)
+1 -1
drivers/gpio/gpio-sim.c
··· 953 953 954 954 swnode = dev_fwnode(&dev->pdev->dev); 955 955 platform_device_unregister(dev->pdev); 956 + gpio_sim_remove_hogs(dev); 956 957 gpio_sim_remove_swnode_recursive(swnode); 957 958 dev->pdev = NULL; 958 - gpio_sim_remove_hogs(dev); 959 959 } 960 960 961 961 static ssize_t
+37 -36
drivers/gpio/gpio-siox.c
··· 10 10 11 11 struct gpio_siox_ddata { 12 12 struct gpio_chip gchip; 13 - struct irq_chip ichip; 14 13 struct mutex lock; 15 14 u8 setdata[1]; 16 15 u8 getdata[3]; ··· 96 97 97 98 static void gpio_siox_irq_ack(struct irq_data *d) 98 99 { 99 - struct irq_chip *ic = irq_data_get_irq_chip(d); 100 - struct gpio_siox_ddata *ddata = 101 - container_of(ic, struct gpio_siox_ddata, ichip); 100 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 101 + struct gpio_siox_ddata *ddata = gpiochip_get_data(gc); 102 102 103 103 raw_spin_lock(&ddata->irqlock); 104 104 ddata->irq_status &= ~(1 << d->hwirq); ··· 106 108 107 109 static void gpio_siox_irq_mask(struct irq_data *d) 108 110 { 109 - struct irq_chip *ic = irq_data_get_irq_chip(d); 110 - struct gpio_siox_ddata *ddata = 111 - container_of(ic, struct gpio_siox_ddata, ichip); 111 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 112 + struct gpio_siox_ddata *ddata = gpiochip_get_data(gc); 112 113 113 114 raw_spin_lock(&ddata->irqlock); 114 115 ddata->irq_enable &= ~(1 << d->hwirq); 115 116 raw_spin_unlock(&ddata->irqlock); 117 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 116 118 } 117 119 118 120 static void gpio_siox_irq_unmask(struct irq_data *d) 119 121 { 120 - struct irq_chip *ic = irq_data_get_irq_chip(d); 121 - struct gpio_siox_ddata *ddata = 122 - container_of(ic, struct gpio_siox_ddata, ichip); 122 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 123 + struct gpio_siox_ddata *ddata = gpiochip_get_data(gc); 123 124 125 + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 124 126 raw_spin_lock(&ddata->irqlock); 125 127 ddata->irq_enable |= 1 << d->hwirq; 126 128 raw_spin_unlock(&ddata->irqlock); ··· 128 130 129 131 static int gpio_siox_irq_set_type(struct irq_data *d, u32 type) 130 132 { 131 - struct irq_chip *ic = irq_data_get_irq_chip(d); 132 - struct gpio_siox_ddata *ddata = 133 - container_of(ic, struct gpio_siox_ddata, ichip); 133 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 134 + struct gpio_siox_ddata *ddata = gpiochip_get_data(gc); 134 135 135 136 raw_spin_lock(&ddata->irqlock); 136 137 ddata->irq_type[d->hwirq] = type; ··· 140 143 141 144 static int gpio_siox_get(struct gpio_chip *chip, unsigned int offset) 142 145 { 143 - struct gpio_siox_ddata *ddata = 144 - container_of(chip, struct gpio_siox_ddata, gchip); 146 + struct gpio_siox_ddata *ddata = gpiochip_get_data(chip); 145 147 int ret; 146 148 147 149 mutex_lock(&ddata->lock); ··· 163 167 static void gpio_siox_set(struct gpio_chip *chip, 164 168 unsigned int offset, int value) 165 169 { 166 - struct gpio_siox_ddata *ddata = 167 - container_of(chip, struct gpio_siox_ddata, gchip); 170 + struct gpio_siox_ddata *ddata = gpiochip_get_data(chip); 168 171 u8 mask = 1 << (19 - offset); 169 172 170 173 mutex_lock(&ddata->lock); ··· 203 208 return GPIO_LINE_DIRECTION_OUT; 204 209 } 205 210 211 + static const struct irq_chip gpio_siox_irq_chip = { 212 + .name = "siox-gpio", 213 + .irq_ack = gpio_siox_irq_ack, 214 + .irq_mask = gpio_siox_irq_mask, 215 + .irq_unmask = gpio_siox_irq_unmask, 216 + .irq_set_type = gpio_siox_irq_set_type, 217 + .flags = IRQCHIP_IMMUTABLE, 218 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 219 + }; 220 + 206 221 static int gpio_siox_probe(struct siox_device *sdevice) 207 222 { 208 223 struct gpio_siox_ddata *ddata; 209 224 struct gpio_irq_chip *girq; 210 225 struct device *dev = &sdevice->dev; 226 + struct gpio_chip *gc; 211 227 int ret; 212 228 213 229 ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); ··· 230 224 mutex_init(&ddata->lock); 231 225 raw_spin_lock_init(&ddata->irqlock); 232 226 233 - ddata->gchip.base = -1; 234 - ddata->gchip.can_sleep = 1; 235 - ddata->gchip.parent = dev; 236 - ddata->gchip.owner = THIS_MODULE; 237 - ddata->gchip.get = gpio_siox_get; 238 - ddata->gchip.set = gpio_siox_set; 239 - ddata->gchip.direction_input = gpio_siox_direction_input; 240 - ddata->gchip.direction_output = gpio_siox_direction_output; 241 - ddata->gchip.get_direction = gpio_siox_get_direction; 242 - ddata->gchip.ngpio = 20; 227 + gc = &ddata->gchip; 228 + gc->base = -1; 229 + gc->can_sleep = 1; 230 + gc->parent = dev; 231 + gc->owner = THIS_MODULE; 232 + gc->get = gpio_siox_get; 233 + gc->set = gpio_siox_set; 234 + gc->direction_input = gpio_siox_direction_input; 235 + gc->direction_output = gpio_siox_direction_output; 236 + gc->get_direction = gpio_siox_get_direction; 237 + gc->ngpio = 20; 243 238 244 - ddata->ichip.name = "siox-gpio"; 245 - ddata->ichip.irq_ack = gpio_siox_irq_ack; 246 - ddata->ichip.irq_mask = gpio_siox_irq_mask; 247 - ddata->ichip.irq_unmask = gpio_siox_irq_unmask; 248 - ddata->ichip.irq_set_type = gpio_siox_irq_set_type; 249 - 250 - girq = &ddata->gchip.irq; 251 - girq->chip = &ddata->ichip; 239 + girq = &gc->irq; 240 + gpio_irq_chip_set_chip(girq, &gpio_siox_irq_chip); 252 241 girq->default_type = IRQ_TYPE_NONE; 253 242 girq->handler = handle_level_irq; 254 243 girq->threaded = true; 255 244 256 - ret = devm_gpiochip_add_data(dev, &ddata->gchip, NULL); 245 + ret = devm_gpiochip_add_data(dev, gc, ddata); 257 246 if (ret) 258 247 dev_err(dev, "Failed to register gpio chip (%d)\n", ret); 259 248
+6 -2
drivers/gpio/gpio-stmpe.c
··· 234 234 int mask = BIT(offset % 8); 235 235 236 236 stmpe_gpio->regs[REG_IE][regoffset] &= ~mask; 237 + gpiochip_disable_irq(gc, offset); 237 238 } 238 239 239 240 static void stmpe_gpio_irq_unmask(struct irq_data *d) ··· 245 244 int regoffset = offset / 8; 246 245 int mask = BIT(offset % 8); 247 246 247 + gpiochip_enable_irq(gc, offset); 248 248 stmpe_gpio->regs[REG_IE][regoffset] |= mask; 249 249 } 250 250 ··· 359 357 } 360 358 } 361 359 362 - static struct irq_chip stmpe_gpio_irq_chip = { 360 + static const struct irq_chip stmpe_gpio_irq_chip = { 363 361 .name = "stmpe-gpio", 364 362 .irq_bus_lock = stmpe_gpio_irq_lock, 365 363 .irq_bus_sync_unlock = stmpe_gpio_irq_sync_unlock, 366 364 .irq_mask = stmpe_gpio_irq_mask, 367 365 .irq_unmask = stmpe_gpio_irq_unmask, 368 366 .irq_set_type = stmpe_gpio_irq_set_type, 367 + .flags = IRQCHIP_IMMUTABLE, 368 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 369 369 }; 370 370 371 371 #define MAX_GPIOS 24 ··· 515 511 } 516 512 517 513 girq = &stmpe_gpio->chip.irq; 518 - girq->chip = &stmpe_gpio_irq_chip; 514 + gpio_irq_chip_set_chip(girq, &stmpe_gpio_irq_chip); 519 515 /* This will let us handle the parent IRQ in the driver */ 520 516 girq->parent_handler = NULL; 521 517 girq->num_parents = 0;
+1 -1
drivers/gpio/gpio-stp-xway.c
··· 292 292 } 293 293 294 294 /* check which edge trigger we should use, default to a falling edge */ 295 - if (!of_find_property(pdev->dev.of_node, "lantiq,rising", NULL)) 295 + if (!of_property_read_bool(pdev->dev.of_node, "lantiq,rising")) 296 296 chip->edge = XWAY_STP_FALLING; 297 297 298 298 clk = devm_clk_get(&pdev->dev, NULL);
+536
drivers/gpio/gpio-tangier.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Intel Tangier GPIO driver 4 + * 5 + * Copyright (c) 2016, 2021, 2023 Intel Corporation. 6 + * 7 + * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 8 + * Pandith N <pandith.n@intel.com> 9 + * Raag Jadav <raag.jadav@intel.com> 10 + */ 11 + 12 + #include <linux/bitops.h> 13 + #include <linux/device.h> 14 + #include <linux/errno.h> 15 + #include <linux/export.h> 16 + #include <linux/interrupt.h> 17 + #include <linux/io.h> 18 + #include <linux/irq.h> 19 + #include <linux/module.h> 20 + #include <linux/pinctrl/pinconf-generic.h> 21 + #include <linux/spinlock.h> 22 + #include <linux/string_helpers.h> 23 + #include <linux/types.h> 24 + 25 + #include <linux/gpio/driver.h> 26 + 27 + #include "gpio-tangier.h" 28 + 29 + #define GCCR 0x000 /* Controller configuration */ 30 + #define GPLR 0x004 /* Pin level r/o */ 31 + #define GPDR 0x01c /* Pin direction */ 32 + #define GPSR 0x034 /* Pin set w/o */ 33 + #define GPCR 0x04c /* Pin clear w/o */ 34 + #define GRER 0x064 /* Rising edge detect */ 35 + #define GFER 0x07c /* Falling edge detect */ 36 + #define GFBR 0x094 /* Glitch filter bypass */ 37 + #define GIMR 0x0ac /* Interrupt mask */ 38 + #define GISR 0x0c4 /* Interrupt source */ 39 + #define GITR 0x300 /* Input type */ 40 + #define GLPR 0x318 /* Level input polarity */ 41 + 42 + /** 43 + * struct tng_gpio_context - Context to be saved during suspend-resume 44 + * @level: Pin level 45 + * @gpdr: Pin direction 46 + * @grer: Rising edge detect enable 47 + * @gfer: Falling edge detect enable 48 + * @gimr: Interrupt mask 49 + * @gwmr: Wake mask 50 + */ 51 + struct tng_gpio_context { 52 + u32 level; 53 + u32 gpdr; 54 + u32 grer; 55 + u32 gfer; 56 + u32 gimr; 57 + u32 gwmr; 58 + }; 59 + 60 + static void __iomem *gpio_reg(struct gpio_chip *chip, unsigned int offset, 61 + unsigned int reg) 62 + { 63 + struct tng_gpio *priv = gpiochip_get_data(chip); 64 + u8 reg_offset = offset / 32; 65 + 66 + return priv->reg_base + reg + reg_offset * 4; 67 + } 68 + 69 + static void __iomem *gpio_reg_and_bit(struct gpio_chip *chip, unsigned int offset, 70 + unsigned int reg, u8 *bit) 71 + { 72 + struct tng_gpio *priv = gpiochip_get_data(chip); 73 + u8 reg_offset = offset / 32; 74 + u8 shift = offset % 32; 75 + 76 + *bit = shift; 77 + return priv->reg_base + reg + reg_offset * 4; 78 + } 79 + 80 + static int tng_gpio_get(struct gpio_chip *chip, unsigned int offset) 81 + { 82 + void __iomem *gplr; 83 + u8 shift; 84 + 85 + gplr = gpio_reg_and_bit(chip, offset, GPLR, &shift); 86 + 87 + return !!(readl(gplr) & BIT(shift)); 88 + } 89 + 90 + static void tng_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) 91 + { 92 + struct tng_gpio *priv = gpiochip_get_data(chip); 93 + unsigned long flags; 94 + void __iomem *reg; 95 + u8 shift; 96 + 97 + reg = gpio_reg_and_bit(chip, offset, value ? GPSR : GPCR, &shift); 98 + 99 + raw_spin_lock_irqsave(&priv->lock, flags); 100 + 101 + writel(BIT(shift), reg); 102 + 103 + raw_spin_unlock_irqrestore(&priv->lock, flags); 104 + } 105 + 106 + static int tng_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) 107 + { 108 + struct tng_gpio *priv = gpiochip_get_data(chip); 109 + unsigned long flags; 110 + void __iomem *gpdr; 111 + u32 value; 112 + u8 shift; 113 + 114 + gpdr = gpio_reg_and_bit(chip, offset, GPDR, &shift); 115 + 116 + raw_spin_lock_irqsave(&priv->lock, flags); 117 + 118 + value = readl(gpdr); 119 + value &= ~BIT(shift); 120 + writel(value, gpdr); 121 + 122 + raw_spin_unlock_irqrestore(&priv->lock, flags); 123 + 124 + return 0; 125 + } 126 + 127 + static int tng_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, 128 + int value) 129 + { 130 + struct tng_gpio *priv = gpiochip_get_data(chip); 131 + unsigned long flags; 132 + void __iomem *gpdr; 133 + u8 shift; 134 + 135 + gpdr = gpio_reg_and_bit(chip, offset, GPDR, &shift); 136 + tng_gpio_set(chip, offset, value); 137 + 138 + raw_spin_lock_irqsave(&priv->lock, flags); 139 + 140 + value = readl(gpdr); 141 + value |= BIT(shift); 142 + writel(value, gpdr); 143 + 144 + raw_spin_unlock_irqrestore(&priv->lock, flags); 145 + 146 + return 0; 147 + } 148 + 149 + static int tng_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) 150 + { 151 + void __iomem *gpdr; 152 + u8 shift; 153 + 154 + gpdr = gpio_reg_and_bit(chip, offset, GPDR, &shift); 155 + 156 + if (readl(gpdr) & BIT(shift)) 157 + return GPIO_LINE_DIRECTION_OUT; 158 + 159 + return GPIO_LINE_DIRECTION_IN; 160 + } 161 + 162 + static int tng_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset, 163 + unsigned int debounce) 164 + { 165 + struct tng_gpio *priv = gpiochip_get_data(chip); 166 + unsigned long flags; 167 + void __iomem *gfbr; 168 + u32 value; 169 + u8 shift; 170 + 171 + gfbr = gpio_reg_and_bit(chip, offset, GFBR, &shift); 172 + 173 + raw_spin_lock_irqsave(&priv->lock, flags); 174 + 175 + value = readl(gfbr); 176 + if (debounce) 177 + value &= ~BIT(shift); 178 + else 179 + value |= BIT(shift); 180 + writel(value, gfbr); 181 + 182 + raw_spin_unlock_irqrestore(&priv->lock, flags); 183 + 184 + return 0; 185 + } 186 + 187 + static int tng_gpio_set_config(struct gpio_chip *chip, unsigned int offset, 188 + unsigned long config) 189 + { 190 + u32 debounce; 191 + 192 + switch (pinconf_to_config_param(config)) { 193 + case PIN_CONFIG_BIAS_DISABLE: 194 + case PIN_CONFIG_BIAS_PULL_UP: 195 + case PIN_CONFIG_BIAS_PULL_DOWN: 196 + return gpiochip_generic_config(chip, offset, config); 197 + case PIN_CONFIG_INPUT_DEBOUNCE: 198 + debounce = pinconf_to_config_argument(config); 199 + return tng_gpio_set_debounce(chip, offset, debounce); 200 + default: 201 + return -ENOTSUPP; 202 + } 203 + } 204 + 205 + static void tng_irq_ack(struct irq_data *d) 206 + { 207 + struct tng_gpio *priv = irq_data_get_irq_chip_data(d); 208 + irq_hw_number_t gpio = irqd_to_hwirq(d); 209 + unsigned long flags; 210 + void __iomem *gisr; 211 + u8 shift; 212 + 213 + gisr = gpio_reg_and_bit(&priv->chip, gpio, GISR, &shift); 214 + 215 + raw_spin_lock_irqsave(&priv->lock, flags); 216 + writel(BIT(shift), gisr); 217 + raw_spin_unlock_irqrestore(&priv->lock, flags); 218 + } 219 + 220 + static void tng_irq_unmask_mask(struct tng_gpio *priv, u32 gpio, bool unmask) 221 + { 222 + unsigned long flags; 223 + void __iomem *gimr; 224 + u32 value; 225 + u8 shift; 226 + 227 + gimr = gpio_reg_and_bit(&priv->chip, gpio, GIMR, &shift); 228 + 229 + raw_spin_lock_irqsave(&priv->lock, flags); 230 + 231 + value = readl(gimr); 232 + if (unmask) 233 + value |= BIT(shift); 234 + else 235 + value &= ~BIT(shift); 236 + writel(value, gimr); 237 + 238 + raw_spin_unlock_irqrestore(&priv->lock, flags); 239 + } 240 + 241 + static void tng_irq_mask(struct irq_data *d) 242 + { 243 + struct tng_gpio *priv = irq_data_get_irq_chip_data(d); 244 + irq_hw_number_t gpio = irqd_to_hwirq(d); 245 + 246 + tng_irq_unmask_mask(priv, gpio, false); 247 + gpiochip_disable_irq(&priv->chip, gpio); 248 + } 249 + 250 + static void tng_irq_unmask(struct irq_data *d) 251 + { 252 + struct tng_gpio *priv = irq_data_get_irq_chip_data(d); 253 + irq_hw_number_t gpio = irqd_to_hwirq(d); 254 + 255 + gpiochip_enable_irq(&priv->chip, gpio); 256 + tng_irq_unmask_mask(priv, gpio, true); 257 + } 258 + 259 + static int tng_irq_set_type(struct irq_data *d, unsigned int type) 260 + { 261 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 262 + struct tng_gpio *priv = gpiochip_get_data(gc); 263 + irq_hw_number_t gpio = irqd_to_hwirq(d); 264 + void __iomem *grer = gpio_reg(&priv->chip, gpio, GRER); 265 + void __iomem *gfer = gpio_reg(&priv->chip, gpio, GFER); 266 + void __iomem *gitr = gpio_reg(&priv->chip, gpio, GITR); 267 + void __iomem *glpr = gpio_reg(&priv->chip, gpio, GLPR); 268 + u8 shift = gpio % 32; 269 + unsigned long flags; 270 + u32 value; 271 + 272 + raw_spin_lock_irqsave(&priv->lock, flags); 273 + 274 + value = readl(grer); 275 + if (type & IRQ_TYPE_EDGE_RISING) 276 + value |= BIT(shift); 277 + else 278 + value &= ~BIT(shift); 279 + writel(value, grer); 280 + 281 + value = readl(gfer); 282 + if (type & IRQ_TYPE_EDGE_FALLING) 283 + value |= BIT(shift); 284 + else 285 + value &= ~BIT(shift); 286 + writel(value, gfer); 287 + 288 + /* 289 + * To prevent glitches from triggering an unintended level interrupt, 290 + * configure GLPR register first and then configure GITR. 291 + */ 292 + value = readl(glpr); 293 + if (type & IRQ_TYPE_LEVEL_LOW) 294 + value |= BIT(shift); 295 + else 296 + value &= ~BIT(shift); 297 + writel(value, glpr); 298 + 299 + if (type & IRQ_TYPE_LEVEL_MASK) { 300 + value = readl(gitr); 301 + value |= BIT(shift); 302 + writel(value, gitr); 303 + 304 + irq_set_handler_locked(d, handle_level_irq); 305 + } else if (type & IRQ_TYPE_EDGE_BOTH) { 306 + value = readl(gitr); 307 + value &= ~BIT(shift); 308 + writel(value, gitr); 309 + 310 + irq_set_handler_locked(d, handle_edge_irq); 311 + } 312 + 313 + raw_spin_unlock_irqrestore(&priv->lock, flags); 314 + 315 + return 0; 316 + } 317 + 318 + static int tng_irq_set_wake(struct irq_data *d, unsigned int on) 319 + { 320 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 321 + struct tng_gpio *priv = gpiochip_get_data(gc); 322 + irq_hw_number_t gpio = irqd_to_hwirq(d); 323 + void __iomem *gwmr = gpio_reg(&priv->chip, gpio, priv->wake_regs.gwmr); 324 + void __iomem *gwsr = gpio_reg(&priv->chip, gpio, priv->wake_regs.gwsr); 325 + u8 shift = gpio % 32; 326 + unsigned long flags; 327 + u32 value; 328 + 329 + raw_spin_lock_irqsave(&priv->lock, flags); 330 + 331 + /* Clear the existing wake status */ 332 + writel(BIT(shift), gwsr); 333 + 334 + value = readl(gwmr); 335 + if (on) 336 + value |= BIT(shift); 337 + else 338 + value &= ~BIT(shift); 339 + writel(value, gwmr); 340 + 341 + raw_spin_unlock_irqrestore(&priv->lock, flags); 342 + 343 + dev_dbg(priv->dev, "%s wake for gpio %lu\n", str_enable_disable(on), gpio); 344 + return 0; 345 + } 346 + 347 + static const struct irq_chip tng_irqchip = { 348 + .name = "gpio-tangier", 349 + .irq_ack = tng_irq_ack, 350 + .irq_mask = tng_irq_mask, 351 + .irq_unmask = tng_irq_unmask, 352 + .irq_set_type = tng_irq_set_type, 353 + .irq_set_wake = tng_irq_set_wake, 354 + .flags = IRQCHIP_IMMUTABLE, 355 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 356 + }; 357 + 358 + static void tng_irq_handler(struct irq_desc *desc) 359 + { 360 + struct gpio_chip *gc = irq_desc_get_handler_data(desc); 361 + struct tng_gpio *priv = gpiochip_get_data(gc); 362 + struct irq_chip *irqchip = irq_desc_get_chip(desc); 363 + unsigned long base, gpio; 364 + 365 + chained_irq_enter(irqchip, desc); 366 + 367 + /* Check GPIO controller to check which pin triggered the interrupt */ 368 + for (base = 0; base < priv->chip.ngpio; base += 32) { 369 + void __iomem *gisr = gpio_reg(&priv->chip, base, GISR); 370 + void __iomem *gimr = gpio_reg(&priv->chip, base, GIMR); 371 + unsigned long pending, enabled; 372 + 373 + pending = readl(gisr); 374 + enabled = readl(gimr); 375 + 376 + /* Only interrupts that are enabled */ 377 + pending &= enabled; 378 + 379 + for_each_set_bit(gpio, &pending, 32) 380 + generic_handle_domain_irq(gc->irq.domain, base + gpio); 381 + } 382 + 383 + chained_irq_exit(irqchip, desc); 384 + } 385 + 386 + static int tng_irq_init_hw(struct gpio_chip *chip) 387 + { 388 + struct tng_gpio *priv = gpiochip_get_data(chip); 389 + void __iomem *reg; 390 + unsigned int base; 391 + 392 + for (base = 0; base < priv->chip.ngpio; base += 32) { 393 + /* Clear the rising-edge detect register */ 394 + reg = gpio_reg(&priv->chip, base, GRER); 395 + writel(0, reg); 396 + 397 + /* Clear the falling-edge detect register */ 398 + reg = gpio_reg(&priv->chip, base, GFER); 399 + writel(0, reg); 400 + } 401 + 402 + return 0; 403 + } 404 + 405 + static int tng_gpio_add_pin_ranges(struct gpio_chip *chip) 406 + { 407 + struct tng_gpio *priv = gpiochip_get_data(chip); 408 + const struct tng_gpio_pinrange *range; 409 + unsigned int i; 410 + int ret; 411 + 412 + for (i = 0; i < priv->pin_info.nranges; i++) { 413 + range = &priv->pin_info.pin_ranges[i]; 414 + ret = gpiochip_add_pin_range(&priv->chip, 415 + priv->pin_info.name, 416 + range->gpio_base, 417 + range->pin_base, 418 + range->npins); 419 + if (ret) { 420 + dev_err(priv->dev, "failed to add GPIO pin range\n"); 421 + return ret; 422 + } 423 + } 424 + 425 + return 0; 426 + } 427 + 428 + int devm_tng_gpio_probe(struct device *dev, struct tng_gpio *gpio) 429 + { 430 + const struct tng_gpio_info *info = &gpio->info; 431 + struct gpio_irq_chip *girq; 432 + int ret; 433 + 434 + gpio->ctx = devm_kcalloc(dev, DIV_ROUND_UP(info->ngpio, 32), sizeof(*gpio->ctx), GFP_KERNEL); 435 + if (!gpio->ctx) 436 + return -ENOMEM; 437 + 438 + gpio->chip.label = dev_name(dev); 439 + gpio->chip.parent = dev; 440 + gpio->chip.request = gpiochip_generic_request; 441 + gpio->chip.free = gpiochip_generic_free; 442 + gpio->chip.direction_input = tng_gpio_direction_input; 443 + gpio->chip.direction_output = tng_gpio_direction_output; 444 + gpio->chip.get = tng_gpio_get; 445 + gpio->chip.set = tng_gpio_set; 446 + gpio->chip.get_direction = tng_gpio_get_direction; 447 + gpio->chip.set_config = tng_gpio_set_config; 448 + gpio->chip.base = info->base; 449 + gpio->chip.ngpio = info->ngpio; 450 + gpio->chip.can_sleep = false; 451 + gpio->chip.add_pin_ranges = tng_gpio_add_pin_ranges; 452 + 453 + raw_spin_lock_init(&gpio->lock); 454 + 455 + girq = &gpio->chip.irq; 456 + gpio_irq_chip_set_chip(girq, &tng_irqchip); 457 + girq->init_hw = tng_irq_init_hw; 458 + girq->parent_handler = tng_irq_handler; 459 + girq->num_parents = 1; 460 + girq->parents = devm_kcalloc(dev, girq->num_parents, 461 + sizeof(*girq->parents), GFP_KERNEL); 462 + if (!girq->parents) 463 + return -ENOMEM; 464 + 465 + girq->parents[0] = gpio->irq; 466 + girq->first = info->first; 467 + girq->default_type = IRQ_TYPE_NONE; 468 + girq->handler = handle_bad_irq; 469 + 470 + ret = devm_gpiochip_add_data(dev, &gpio->chip, gpio); 471 + if (ret) 472 + return dev_err_probe(dev, ret, "gpiochip_add error\n"); 473 + 474 + return 0; 475 + } 476 + EXPORT_SYMBOL_NS_GPL(devm_tng_gpio_probe, GPIO_TANGIER); 477 + 478 + int tng_gpio_suspend(struct device *dev) 479 + { 480 + struct tng_gpio *priv = dev_get_drvdata(dev); 481 + struct tng_gpio_context *ctx = priv->ctx; 482 + unsigned long flags; 483 + unsigned int base; 484 + 485 + raw_spin_lock_irqsave(&priv->lock, flags); 486 + 487 + for (base = 0; base < priv->chip.ngpio; base += 32, ctx++) { 488 + /* GPLR is RO, values read will be restored using GPSR */ 489 + ctx->level = readl(gpio_reg(&priv->chip, base, GPLR)); 490 + 491 + ctx->gpdr = readl(gpio_reg(&priv->chip, base, GPDR)); 492 + ctx->grer = readl(gpio_reg(&priv->chip, base, GRER)); 493 + ctx->gfer = readl(gpio_reg(&priv->chip, base, GFER)); 494 + ctx->gimr = readl(gpio_reg(&priv->chip, base, GIMR)); 495 + 496 + ctx->gwmr = readl(gpio_reg(&priv->chip, base, priv->wake_regs.gwmr)); 497 + } 498 + 499 + raw_spin_unlock_irqrestore(&priv->lock, flags); 500 + 501 + return 0; 502 + } 503 + EXPORT_SYMBOL_NS_GPL(tng_gpio_suspend, GPIO_TANGIER); 504 + 505 + int tng_gpio_resume(struct device *dev) 506 + { 507 + struct tng_gpio *priv = dev_get_drvdata(dev); 508 + struct tng_gpio_context *ctx = priv->ctx; 509 + unsigned long flags; 510 + unsigned int base; 511 + 512 + raw_spin_lock_irqsave(&priv->lock, flags); 513 + 514 + for (base = 0; base < priv->chip.ngpio; base += 32, ctx++) { 515 + /* GPLR is RO, values read will be restored using GPSR */ 516 + writel(ctx->level, gpio_reg(&priv->chip, base, GPSR)); 517 + 518 + writel(ctx->gpdr, gpio_reg(&priv->chip, base, GPDR)); 519 + writel(ctx->grer, gpio_reg(&priv->chip, base, GRER)); 520 + writel(ctx->gfer, gpio_reg(&priv->chip, base, GFER)); 521 + writel(ctx->gimr, gpio_reg(&priv->chip, base, GIMR)); 522 + 523 + writel(ctx->gwmr, gpio_reg(&priv->chip, base, priv->wake_regs.gwmr)); 524 + } 525 + 526 + raw_spin_unlock_irqrestore(&priv->lock, flags); 527 + 528 + return 0; 529 + } 530 + EXPORT_SYMBOL_NS_GPL(tng_gpio_resume, GPIO_TANGIER); 531 + 532 + MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>"); 533 + MODULE_AUTHOR("Pandith N <pandith.n@intel.com>"); 534 + MODULE_AUTHOR("Raag Jadav <raag.jadav@intel.com>"); 535 + MODULE_DESCRIPTION("Intel Tangier GPIO driver"); 536 + MODULE_LICENSE("GPL");
+117
drivers/gpio/gpio-tangier.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * Intel Tangier GPIO functions 4 + * 5 + * Copyright (c) 2016, 2021, 2023 Intel Corporation. 6 + * 7 + * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 8 + * Pandith N <pandith.n@intel.com> 9 + * Raag Jadav <raag.jadav@intel.com> 10 + */ 11 + 12 + #ifndef _GPIO_TANGIER_H_ 13 + #define _GPIO_TANGIER_H_ 14 + 15 + #include <linux/gpio/driver.h> 16 + #include <linux/spinlock_types.h> 17 + #include <linux/types.h> 18 + 19 + struct device; 20 + 21 + struct tng_gpio_context; 22 + 23 + /* Elkhart Lake specific wake registers */ 24 + #define GWMR_EHL 0x100 /* Wake mask */ 25 + #define GWSR_EHL 0x118 /* Wake source */ 26 + #define GSIR_EHL 0x130 /* Secure input */ 27 + 28 + /* Merrifield specific wake registers */ 29 + #define GWMR_MRFLD 0x400 /* Wake mask */ 30 + #define GWSR_MRFLD 0x418 /* Wake source */ 31 + #define GSIR_MRFLD 0xc00 /* Secure input */ 32 + 33 + /** 34 + * struct tng_wake_regs - Platform specific wake registers 35 + * @gwmr: Wake mask 36 + * @gwsr: Wake source 37 + * @gsir: Secure input 38 + */ 39 + struct tng_wake_regs { 40 + u32 gwmr; 41 + u32 gwsr; 42 + u32 gsir; 43 + }; 44 + 45 + /** 46 + * struct tng_gpio_pinrange - Map pin numbers to gpio numbers 47 + * @gpio_base: Starting GPIO number of this range 48 + * @pin_base: Starting pin number of this range 49 + * @npins: Number of pins in this range 50 + */ 51 + struct tng_gpio_pinrange { 52 + unsigned int gpio_base; 53 + unsigned int pin_base; 54 + unsigned int npins; 55 + }; 56 + 57 + #define GPIO_PINRANGE(gstart, gend, pstart) \ 58 + (struct tng_gpio_pinrange) { \ 59 + .gpio_base = (gstart), \ 60 + .pin_base = (pstart), \ 61 + .npins = (gend) - (gstart) + 1, \ 62 + } 63 + 64 + /** 65 + * struct tng_gpio_pin_info - Platform specific pinout information 66 + * @pin_ranges: Pin to GPIO mapping 67 + * @nranges: Number of pin ranges 68 + * @name: Respective pinctrl device name 69 + */ 70 + struct tng_gpio_pin_info { 71 + const struct tng_gpio_pinrange *pin_ranges; 72 + unsigned int nranges; 73 + const char *name; 74 + }; 75 + 76 + /** 77 + * struct tng_gpio_info - Platform specific GPIO and IRQ information 78 + * @base: GPIO base to start numbering with 79 + * @ngpio: Amount of GPIOs supported by the controller 80 + * @first: First IRQ to start numbering with 81 + */ 82 + struct tng_gpio_info { 83 + int base; 84 + u16 ngpio; 85 + unsigned int first; 86 + }; 87 + 88 + /** 89 + * struct tng_gpio - Platform specific private data 90 + * @chip: Instance of the struct gpio_chip 91 + * @reg_base: Base address of MMIO registers 92 + * @irq: Interrupt for the GPIO device 93 + * @lock: Synchronization lock to prevent I/O race conditions 94 + * @dev: The GPIO device 95 + * @ctx: Context to be saved during suspend-resume 96 + * @wake_regs: Platform specific wake registers 97 + * @pin_info: Platform specific pinout information 98 + * @info: Platform specific GPIO and IRQ information 99 + */ 100 + struct tng_gpio { 101 + struct gpio_chip chip; 102 + void __iomem *reg_base; 103 + int irq; 104 + raw_spinlock_t lock; 105 + struct device *dev; 106 + struct tng_gpio_context *ctx; 107 + struct tng_wake_regs wake_regs; 108 + struct tng_gpio_pin_info pin_info; 109 + struct tng_gpio_info info; 110 + }; 111 + 112 + int devm_tng_gpio_probe(struct device *dev, struct tng_gpio *gpio); 113 + 114 + int tng_gpio_suspend(struct device *dev); 115 + int tng_gpio_resume(struct device *dev); 116 + 117 + #endif /* _GPIO_TANGIER_H_ */
+1 -1
drivers/gpio/gpio-tb10x.c
··· 167 167 168 168 platform_set_drvdata(pdev, tb10x_gpio); 169 169 170 - if (of_find_property(np, "interrupt-controller", NULL)) { 170 + if (of_property_read_bool(np, "interrupt-controller")) { 171 171 struct irq_chip_generic *gc; 172 172 173 173 ret = platform_get_irq(pdev, 0);
+16 -10
drivers/gpio/gpio-thunderx.c
··· 354 354 return IRQ_SET_MASK_OK; 355 355 } 356 356 357 - static void thunderx_gpio_irq_enable(struct irq_data *data) 357 + static void thunderx_gpio_irq_enable(struct irq_data *d) 358 358 { 359 - irq_chip_enable_parent(data); 360 - thunderx_gpio_irq_unmask(data); 359 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 360 + 361 + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 362 + irq_chip_enable_parent(d); 363 + thunderx_gpio_irq_unmask(d); 361 364 } 362 365 363 - static void thunderx_gpio_irq_disable(struct irq_data *data) 366 + static void thunderx_gpio_irq_disable(struct irq_data *d) 364 367 { 365 - thunderx_gpio_irq_mask(data); 366 - irq_chip_disable_parent(data); 368 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 369 + 370 + thunderx_gpio_irq_mask(d); 371 + irq_chip_disable_parent(d); 372 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 367 373 } 368 374 369 375 /* ··· 378 372 * semantics and other acknowledgment tasks associated with the GPIO 379 373 * mechanism. 380 374 */ 381 - static struct irq_chip thunderx_gpio_irq_chip = { 375 + static const struct irq_chip thunderx_gpio_irq_chip = { 382 376 .name = "GPIO", 383 377 .irq_enable = thunderx_gpio_irq_enable, 384 378 .irq_disable = thunderx_gpio_irq_disable, ··· 389 383 .irq_eoi = irq_chip_eoi_parent, 390 384 .irq_set_affinity = irq_chip_set_affinity_parent, 391 385 .irq_set_type = thunderx_gpio_irq_set_type, 392 - 393 - .flags = IRQCHIP_SET_TYPE_MASKED 386 + .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_IMMUTABLE, 387 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 394 388 }; 395 389 396 390 static int thunderx_gpio_child_to_parent_hwirq(struct gpio_chip *gc, ··· 532 526 chip->set_multiple = thunderx_gpio_set_multiple; 533 527 chip->set_config = thunderx_gpio_set_config; 534 528 girq = &chip->irq; 535 - girq->chip = &thunderx_gpio_irq_chip; 529 + gpio_irq_chip_set_chip(girq, &thunderx_gpio_irq_chip); 536 530 girq->fwnode = of_node_to_fwnode(dev->of_node); 537 531 girq->parent_domain = 538 532 irq_get_irq_data(txgpio->msix_entries[0].vector)->domain;
+20 -8
drivers/gpio/gpio-tqmx86.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/platform_device.h> 17 17 #include <linux/pm_runtime.h> 18 + #include <linux/seq_file.h> 18 19 #include <linux/slab.h> 19 20 20 21 #define TQMX86_NGPIO 8 ··· 35 34 36 35 struct tqmx86_gpio_data { 37 36 struct gpio_chip chip; 38 - struct irq_chip irq_chip; 39 37 void __iomem *io_base; 40 38 int irq; 41 39 raw_spinlock_t spinlock; ··· 122 122 gpiic &= ~mask; 123 123 tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC); 124 124 raw_spin_unlock_irqrestore(&gpio->spinlock, flags); 125 + gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(data)); 125 126 } 126 127 127 128 static void tqmx86_gpio_irq_unmask(struct irq_data *data) ··· 135 134 136 135 mask = TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS); 137 136 137 + gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(data)); 138 138 raw_spin_lock_irqsave(&gpio->spinlock, flags); 139 139 gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC); 140 140 gpiic &= ~mask; ··· 228 226 clear_bit(3, valid_mask); 229 227 } 230 228 229 + static void tqmx86_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) 230 + { 231 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 232 + 233 + seq_printf(p, gc->label); 234 + } 235 + 236 + static const struct irq_chip tqmx86_gpio_irq_chip = { 237 + .irq_mask = tqmx86_gpio_irq_mask, 238 + .irq_unmask = tqmx86_gpio_irq_unmask, 239 + .irq_set_type = tqmx86_gpio_irq_set_type, 240 + .irq_print_chip = tqmx86_gpio_irq_print_chip, 241 + .flags = IRQCHIP_IMMUTABLE, 242 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 243 + }; 244 + 231 245 static int tqmx86_gpio_probe(struct platform_device *pdev) 232 246 { 233 247 struct device *dev = &pdev->dev; ··· 295 277 pm_runtime_enable(&pdev->dev); 296 278 297 279 if (irq > 0) { 298 - struct irq_chip *irq_chip = &gpio->irq_chip; 299 280 u8 irq_status; 300 - 301 - irq_chip->name = chip->label; 302 - irq_chip->irq_mask = tqmx86_gpio_irq_mask; 303 - irq_chip->irq_unmask = tqmx86_gpio_irq_unmask; 304 - irq_chip->irq_set_type = tqmx86_gpio_irq_set_type; 305 281 306 282 /* Mask all interrupts */ 307 283 tqmx86_gpio_write(gpio, 0, TQMX86_GPIIC); ··· 305 293 tqmx86_gpio_write(gpio, irq_status, TQMX86_GPIIS); 306 294 307 295 girq = &chip->irq; 308 - girq->chip = irq_chip; 296 + gpio_irq_chip_set_chip(girq, &tqmx86_gpio_irq_chip); 309 297 girq->parent_handler = tqmx86_gpio_irq_handler; 310 298 girq->num_parents = 1; 311 299 girq->parents = devm_kcalloc(&pdev->dev, 1,
+40 -12
drivers/gpio/gpio-visconti.c
··· 15 15 #include <linux/io.h> 16 16 #include <linux/of_irq.h> 17 17 #include <linux/platform_device.h> 18 + #include <linux/seq_file.h> 18 19 #include <linux/bitops.h> 19 20 20 21 /* register offset */ ··· 32 31 void __iomem *base; 33 32 spinlock_t lock; /* protect gpio register */ 34 33 struct gpio_chip gpio_chip; 35 - struct irq_chip irq_chip; 34 + struct device *dev; 36 35 }; 37 36 38 37 static int visconti_gpio_irq_set_type(struct irq_data *d, unsigned int type) ··· 120 119 return 0; 121 120 } 122 121 122 + static void visconti_gpio_mask_irq(struct irq_data *d) 123 + { 124 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 125 + 126 + irq_chip_mask_parent(d); 127 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 128 + } 129 + 130 + static void visconti_gpio_unmask_irq(struct irq_data *d) 131 + { 132 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 133 + 134 + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 135 + irq_chip_unmask_parent(d); 136 + } 137 + 138 + static void visconti_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) 139 + { 140 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 141 + struct visconti_gpio *priv = gpiochip_get_data(gc); 142 + 143 + seq_printf(p, dev_name(priv->dev)); 144 + } 145 + 146 + static const struct irq_chip visconti_gpio_irq_chip = { 147 + .irq_mask = visconti_gpio_mask_irq, 148 + .irq_unmask = visconti_gpio_unmask_irq, 149 + .irq_eoi = irq_chip_eoi_parent, 150 + .irq_set_type = visconti_gpio_irq_set_type, 151 + .irq_print_chip = visconti_gpio_irq_print_chip, 152 + .flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND | 153 + IRQCHIP_IMMUTABLE, 154 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 155 + }; 156 + 123 157 static int visconti_gpio_probe(struct platform_device *pdev) 124 158 { 125 159 struct device *dev = &pdev->dev; 126 160 struct visconti_gpio *priv; 127 - struct irq_chip *irq_chip; 128 161 struct gpio_irq_chip *girq; 129 162 struct irq_domain *parent; 130 163 struct device_node *irq_parent; ··· 169 134 return -ENOMEM; 170 135 171 136 spin_lock_init(&priv->lock); 137 + priv->dev = dev; 172 138 173 139 priv->base = devm_platform_ioremap_resource(pdev, 0); 174 140 if (IS_ERR(priv->base)) ··· 200 164 return ret; 201 165 } 202 166 203 - irq_chip = &priv->irq_chip; 204 - irq_chip->name = dev_name(dev); 205 - irq_chip->irq_mask = irq_chip_mask_parent; 206 - irq_chip->irq_unmask = irq_chip_unmask_parent; 207 - irq_chip->irq_eoi = irq_chip_eoi_parent; 208 - irq_chip->irq_set_type = visconti_gpio_irq_set_type; 209 - irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; 210 - 211 167 girq = &priv->gpio_chip.irq; 212 - girq->chip = irq_chip; 168 + gpio_irq_chip_set_chip(girq, &visconti_gpio_irq_chip); 213 169 girq->fwnode = of_node_to_fwnode(dev->of_node); 214 170 girq->parent_domain = parent; 215 171 girq->child_to_parent_hwirq = visconti_gpio_child_to_parent_hwirq; ··· 222 194 .probe = visconti_gpio_probe, 223 195 .driver = { 224 196 .name = "visconti_gpio", 225 - .of_match_table = of_match_ptr(visconti_gpio_of_match), 197 + .of_match_table = visconti_gpio_of_match, 226 198 } 227 199 }; 228 200 module_platform_driver(visconti_gpio_driver);
+22 -10
drivers/gpio/gpio-xgs-iproc.c
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/module.h> 13 13 #include <linux/platform_device.h> 14 + #include <linux/seq_file.h> 14 15 #include <linux/spinlock.h> 15 16 16 17 #define IPROC_CCA_INT_F_GPIOINT BIT(0) ··· 28 27 #define IPROC_GPIO_CCA_INT_EDGE 0x24 29 28 30 29 struct iproc_gpio_chip { 31 - struct irq_chip irqchip; 32 30 struct gpio_chip gc; 33 31 spinlock_t lock; 34 32 struct device *dev; ··· 69 69 u32 irq = d->irq; 70 70 u32 int_mask, irq_type, event_mask; 71 71 72 + gpiochip_enable_irq(gc, pin); 72 73 spin_lock_irqsave(&chip->lock, flags); 73 74 irq_type = irq_get_trigger_type(irq); 74 75 event_mask = readl_relaxed(chip->base + IPROC_GPIO_CCA_INT_EVENT_MASK); ··· 111 110 chip->base + IPROC_GPIO_CCA_INT_LEVEL_MASK); 112 111 } 113 112 spin_unlock_irqrestore(&chip->lock, flags); 113 + gpiochip_disable_irq(gc, pin); 114 114 } 115 115 116 116 static int iproc_gpio_irq_set_type(struct irq_data *d, u32 type) ··· 193 191 return int_bits ? IRQ_HANDLED : IRQ_NONE; 194 192 } 195 193 194 + static void iproc_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p) 195 + { 196 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 197 + struct iproc_gpio_chip *chip = to_iproc_gpio(gc); 198 + 199 + seq_printf(p, dev_name(chip->dev)); 200 + } 201 + 202 + static const struct irq_chip iproc_gpio_irq_chip = { 203 + .irq_ack = iproc_gpio_irq_ack, 204 + .irq_mask = iproc_gpio_irq_mask, 205 + .irq_unmask = iproc_gpio_irq_unmask, 206 + .irq_set_type = iproc_gpio_irq_set_type, 207 + .irq_print_chip = iproc_gpio_irq_print_chip, 208 + .flags = IRQCHIP_IMMUTABLE, 209 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 210 + }; 211 + 196 212 static int iproc_gpio_probe(struct platform_device *pdev) 197 213 { 198 214 struct device *dev = &pdev->dev; ··· 250 230 irq = platform_get_irq(pdev, 0); 251 231 if (irq > 0) { 252 232 struct gpio_irq_chip *girq; 253 - struct irq_chip *irqc; 254 233 u32 val; 255 - 256 - irqc = &chip->irqchip; 257 - irqc->name = dev_name(dev); 258 - irqc->irq_ack = iproc_gpio_irq_ack; 259 - irqc->irq_mask = iproc_gpio_irq_mask; 260 - irqc->irq_unmask = iproc_gpio_irq_unmask; 261 - irqc->irq_set_type = iproc_gpio_irq_set_type; 262 234 263 235 chip->intr = devm_platform_ioremap_resource(pdev, 1); 264 236 if (IS_ERR(chip->intr)) ··· 273 261 } 274 262 275 263 girq = &chip->gc.irq; 276 - girq->chip = irqc; 264 + gpio_irq_chip_set_chip(girq, &iproc_gpio_irq_chip); 277 265 /* This will let us handle the parent IRQ in the driver */ 278 266 girq->parent_handler = NULL; 279 267 girq->num_parents = 0;
+15 -8
drivers/gpio/gpio-xilinx.c
··· 68 68 DECLARE_BITMAP(dir, 64); 69 69 spinlock_t gpio_lock; /* For serializing operations */ 70 70 int irq; 71 - struct irq_chip irqchip; 72 71 DECLARE_BITMAP(enable, 64); 73 72 DECLARE_BITMAP(rising_edge, 64); 74 73 DECLARE_BITMAP(falling_edge, 64); ··· 415 416 xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp); 416 417 } 417 418 spin_unlock_irqrestore(&chip->gpio_lock, flags); 419 + 420 + gpiochip_disable_irq(&chip->gc, irq_offset); 418 421 } 419 422 420 423 /** ··· 431 430 int bit = xgpio_to_bit(chip, irq_offset); 432 431 u32 old_enable = xgpio_get_value32(chip->enable, bit); 433 432 u32 mask = BIT(bit / 32), val; 433 + 434 + gpiochip_enable_irq(&chip->gc, irq_offset); 434 435 435 436 spin_lock_irqsave(&chip->gpio_lock, flags); 436 437 ··· 547 544 chained_irq_exit(irqchip, desc); 548 545 } 549 546 547 + static const struct irq_chip xgpio_irq_chip = { 548 + .name = "gpio-xilinx", 549 + .irq_ack = xgpio_irq_ack, 550 + .irq_mask = xgpio_irq_mask, 551 + .irq_unmask = xgpio_irq_unmask, 552 + .irq_set_type = xgpio_set_irq_type, 553 + .flags = IRQCHIP_IMMUTABLE, 554 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 555 + }; 556 + 550 557 /** 551 558 * xgpio_probe - Probe method for the GPIO device. 552 559 * @pdev: pointer to the platform device ··· 666 653 if (chip->irq <= 0) 667 654 goto skip_irq; 668 655 669 - chip->irqchip.name = "gpio-xilinx"; 670 - chip->irqchip.irq_ack = xgpio_irq_ack; 671 - chip->irqchip.irq_mask = xgpio_irq_mask; 672 - chip->irqchip.irq_unmask = xgpio_irq_unmask; 673 - chip->irqchip.irq_set_type = xgpio_set_irq_type; 674 - 675 656 /* Disable per-channel interrupts */ 676 657 xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, 0); 677 658 /* Clear any existing per-channel interrupts */ ··· 675 668 xgpio_writereg(chip->regs + XGPIO_GIER_OFFSET, XGPIO_GIER_IE); 676 669 677 670 girq = &chip->gc.irq; 678 - girq->chip = &chip->irqchip; 671 + gpio_irq_chip_set_chip(girq, &xgpio_irq_chip); 679 672 girq->parent_handler = xgpio_irqhandler; 680 673 girq->num_parents = 1; 681 674 girq->parents = devm_kcalloc(&pdev->dev, 1,
+12 -2
drivers/gpio/gpio-xlp.c
··· 90 90 writel(value, addr + regset); 91 91 } 92 92 93 + static void xlp_gpio_irq_enable(struct irq_data *d) 94 + { 95 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 96 + 97 + gpiochip_enable_irq(gc, irqd_to_hwirq(d)); 98 + } 99 + 93 100 static void xlp_gpio_irq_disable(struct irq_data *d) 94 101 { 95 102 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); ··· 107 100 xlp_gpio_set_reg(priv->gpio_intr_en, d->hwirq, 0x0); 108 101 __clear_bit(d->hwirq, priv->gpio_enabled_mask); 109 102 spin_unlock_irqrestore(&priv->lock, flags); 103 + gpiochip_disable_irq(gc, irqd_to_hwirq(d)); 110 104 } 111 105 112 106 static void xlp_gpio_irq_mask_ack(struct irq_data *d) ··· 171 163 static struct irq_chip xlp_gpio_irq_chip = { 172 164 .name = "XLP-GPIO", 173 165 .irq_mask_ack = xlp_gpio_irq_mask_ack, 166 + .irq_enable = xlp_gpio_irq_enable, 174 167 .irq_disable = xlp_gpio_irq_disable, 175 168 .irq_set_type = xlp_gpio_set_irq_type, 176 169 .irq_unmask = xlp_gpio_irq_unmask, 177 - .flags = IRQCHIP_ONESHOT_SAFE, 170 + .flags = IRQCHIP_ONESHOT_SAFE | IRQCHIP_IMMUTABLE, 171 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 178 172 }; 179 173 180 174 static void xlp_gpio_generic_handler(struct irq_desc *desc) ··· 282 272 spin_lock_init(&priv->lock); 283 273 284 274 girq = &gc->irq; 285 - girq->chip = &xlp_gpio_irq_chip; 275 + gpio_irq_chip_set_chip(girq, &xlp_gpio_irq_chip); 286 276 girq->parent_handler = xlp_gpio_generic_handler; 287 277 girq->num_parents = 1; 288 278 girq->parents = devm_kcalloc(&pdev->dev, 1,
+1 -1
drivers/gpio/gpio-xra1403.c
··· 195 195 }; 196 196 MODULE_DEVICE_TABLE(spi, xra1403_ids); 197 197 198 - static const struct of_device_id xra1403_spi_of_match[] = { 198 + static const struct of_device_id xra1403_spi_of_match[] __maybe_unused = { 199 199 { .compatible = "exar,xra1403" }, 200 200 {}, 201 201 };
+25 -13
drivers/gpio/gpiolib-acpi.c
··· 7 7 * Mika Westerberg <mika.westerberg@linux.intel.com> 8 8 */ 9 9 10 + #include <linux/acpi.h> 10 11 #include <linux/dmi.h> 11 12 #include <linux/errno.h> 13 + #include <linux/export.h> 14 + #include <linux/interrupt.h> 15 + #include <linux/irq.h> 16 + #include <linux/mutex.h> 17 + #include <linux/pinctrl/pinctrl.h> 18 + 12 19 #include <linux/gpio/consumer.h> 13 20 #include <linux/gpio/driver.h> 14 21 #include <linux/gpio/machine.h> 15 - #include <linux/export.h> 16 - #include <linux/acpi.h> 17 - #include <linux/interrupt.h> 18 - #include <linux/mutex.h> 19 - #include <linux/pinctrl/pinctrl.h> 20 22 21 23 #include "gpiolib.h" 22 24 #include "gpiolib-acpi.h" ··· 128 126 129 127 static int acpi_gpiochip_find(struct gpio_chip *gc, void *data) 130 128 { 131 - return gc->parent && device_match_acpi_handle(gc->parent, data); 129 + return ACPI_HANDLE_FWNODE(gc->fwnode) == data; 132 130 } 133 131 134 132 /** ··· 648 646 { 649 647 const struct acpi_gpio_mapping *gm; 650 648 651 - if (!adev->driver_gpios) 649 + if (!adev || !adev->driver_gpios) 652 650 return false; 653 651 654 652 for (gm = adev->driver_gpios; gm->name; gm++) ··· 842 840 ret = __acpi_node_get_property_reference(fwnode, propname, index, 3, 843 841 &args); 844 842 if (ret) { 845 - struct acpi_device *adev = to_acpi_device_node(fwnode); 843 + struct acpi_device *adev; 846 844 847 - if (!adev) 848 - return ret; 849 - 850 - if (!acpi_get_driver_gpio_data(adev, propname, index, &args, 851 - &quirks)) 845 + adev = to_acpi_device_node(fwnode); 846 + if (!acpi_get_driver_gpio_data(adev, propname, index, &args, &quirks)) 852 847 return ret; 853 848 } 854 849 /* ··· 1614 1615 }, 1615 1616 .driver_data = &(struct acpi_gpiolib_dmi_quirk) { 1616 1617 .ignore_interrupt = "AMDI0030:00@18", 1618 + }, 1619 + }, 1620 + { 1621 + /* 1622 + * Spurious wakeups from TP_ATTN# pin 1623 + * Found in BIOS 1.7.8 1624 + * https://gitlab.freedesktop.org/drm/amd/-/issues/1722#note_1720627 1625 + */ 1626 + .matches = { 1627 + DMI_MATCH(DMI_BOARD_NAME, "NL5xNU"), 1628 + }, 1629 + .driver_data = &(struct acpi_gpiolib_dmi_quirk) { 1630 + .ignore_wake = "ELAN0415:00@9", 1617 1631 }, 1618 1632 }, 1619 1633 {
-1
drivers/gpio/gpiolib-acpi.h
··· 9 9 #define GPIOLIB_ACPI_H 10 10 11 11 #include <linux/err.h> 12 - #include <linux/errno.h> 13 12 #include <linux/types.h> 14 13 15 14 #include <linux/gpio/consumer.h>
+7 -2
drivers/gpio/gpiolib-of.c
··· 10 10 #include <linux/device.h> 11 11 #include <linux/err.h> 12 12 #include <linux/errno.h> 13 - #include <linux/module.h> 14 13 #include <linux/io.h> 15 - #include <linux/gpio/consumer.h> 14 + #include <linux/module.h> 16 15 #include <linux/of.h> 17 16 #include <linux/of_address.h> 18 17 #include <linux/of_gpio.h> 19 18 #include <linux/pinctrl/pinctrl.h> 20 19 #include <linux/slab.h> 20 + #include <linux/string.h> 21 + 22 + #include <linux/gpio/consumer.h> 21 23 #include <linux/gpio/machine.h> 22 24 23 25 #include "gpiolib.h" ··· 894 892 return gpiospec->args[0]; 895 893 } 896 894 895 + #if IS_ENABLED(CONFIG_OF_GPIO_MM_GPIOCHIP) 896 + #include <linux/gpio/legacy-of-mm-gpiochip.h> 897 897 /** 898 898 * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank) 899 899 * @np: device node of the GPIO chip ··· 968 964 kfree(gc->label); 969 965 } 970 966 EXPORT_SYMBOL_GPL(of_mm_gpiochip_remove); 967 + #endif 971 968 972 969 #ifdef CONFIG_PINCTRL 973 970 static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
-1
drivers/gpio/gpiolib-of.h
··· 4 4 #define GPIOLIB_OF_H 5 5 6 6 #include <linux/err.h> 7 - #include <linux/errno.h> 8 7 #include <linux/types.h> 9 8 10 9 #include <linux/notifier.h>
+3 -2
drivers/gpio/gpiolib-swnode.c
··· 6 6 */ 7 7 #include <linux/err.h> 8 8 #include <linux/errno.h> 9 - #include <linux/gpio/consumer.h> 10 - #include <linux/gpio/driver.h> 11 9 #include <linux/kernel.h> 12 10 #include <linux/printk.h> 13 11 #include <linux/property.h> 14 12 #include <linux/string.h> 13 + 14 + #include <linux/gpio/consumer.h> 15 + #include <linux/gpio/driver.h> 15 16 16 17 #include "gpiolib.h" 17 18 #include "gpiolib-swnode.h"
+19 -8
drivers/gpio/gpiolib-sysfs.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - #include <linux/idr.h> 3 - #include <linux/mutex.h> 2 + 3 + #include <linux/bitops.h> 4 4 #include <linux/device.h> 5 - #include <linux/sysfs.h> 6 - #include <linux/gpio/consumer.h> 7 - #include <linux/gpio/driver.h> 5 + #include <linux/idr.h> 6 + #include <linux/init.h> 8 7 #include <linux/interrupt.h> 9 8 #include <linux/kdev_t.h> 9 + #include <linux/kstrtox.h> 10 + #include <linux/list.h> 11 + #include <linux/mutex.h> 12 + #include <linux/printk.h> 10 13 #include <linux/slab.h> 11 - #include <linux/ctype.h> 14 + #include <linux/spinlock.h> 15 + #include <linux/string.h> 16 + #include <linux/sysfs.h> 17 + #include <linux/types.h> 18 + 19 + #include <linux/gpio/consumer.h> 20 + #include <linux/gpio/driver.h> 12 21 13 22 #include "gpiolib.h" 14 23 #include "gpiolib-sysfs.h" 24 + 25 + struct kernfs_node; 15 26 16 27 #define GPIO_IRQF_TRIGGER_NONE 0 17 28 #define GPIO_IRQF_TRIGGER_FALLING BIT(0) ··· 502 491 goto done; 503 492 504 493 desc = gpio_to_desc(gpio); 505 - /* reject bogus commands (gpio_unexport ignores them) */ 494 + /* reject bogus commands (gpiod_unexport() ignores them) */ 506 495 if (!desc) { 507 496 pr_warn("%s: invalid GPIO %ld\n", __func__, gpio); 508 497 return -EINVAL; ··· 801 790 * early (e.g. before the class_register above was called). 802 791 * 803 792 * We run before arch_initcall() so chip->dev nodes can have 804 - * registered, and so arch_initcall() can always gpio_export(). 793 + * registered, and so arch_initcall() can always gpiod_export(). 805 794 */ 806 795 spin_lock_irqsave(&gpio_lock, flags); 807 796 list_for_each_entry(gdev, &gpio_devices, list) {
+93 -80
drivers/gpio/gpiolib.c
··· 6 6 #include <linux/debugfs.h> 7 7 #include <linux/device.h> 8 8 #include <linux/err.h> 9 + #include <linux/errno.h> 9 10 #include <linux/file.h> 10 11 #include <linux/fs.h> 11 - #include <linux/gpio.h> 12 - #include <linux/gpio/driver.h> 13 - #include <linux/gpio/machine.h> 14 12 #include <linux/idr.h> 15 13 #include <linux/interrupt.h> 16 14 #include <linux/irq.h> 17 15 #include <linux/kernel.h> 18 16 #include <linux/list.h> 19 17 #include <linux/module.h> 18 + #include <linux/of.h> 20 19 #include <linux/pinctrl/consumer.h> 21 20 #include <linux/seq_file.h> 22 21 #include <linux/slab.h> 23 22 #include <linux/spinlock.h> 23 + 24 + #include <linux/gpio.h> 25 + #include <linux/gpio/driver.h> 26 + #include <linux/gpio/machine.h> 24 27 25 28 #include <uapi/linux/gpio.h> 26 29 ··· 61 58 static DEFINE_IDA(gpio_ida); 62 59 static dev_t gpio_devt; 63 60 #define GPIO_DEV_MAX 256 /* 256 GPIO chip devices supported */ 64 - static int gpio_bus_match(struct device *dev, struct device_driver *drv); 61 + 62 + static int gpio_bus_match(struct device *dev, struct device_driver *drv) 63 + { 64 + struct fwnode_handle *fwnode = dev_fwnode(dev); 65 + 66 + /* 67 + * Only match if the fwnode doesn't already have a proper struct device 68 + * created for it. 69 + */ 70 + if (fwnode && fwnode->dev != dev) 71 + return 0; 72 + return 1; 73 + } 74 + 65 75 static struct bus_type gpio_bus_type = { 66 76 .name = "gpio", 67 77 .match = gpio_bus_match, ··· 373 357 } 374 358 375 359 /* 376 - * devprop_gpiochip_set_names - Set GPIO line names using device properties 360 + * gpiochip_set_names - Set GPIO line names using device properties 377 361 * @chip: GPIO chip whose lines should be named, if possible 378 362 * 379 363 * Looks for device property "gpio-line-names" and if it exists assigns ··· 381 365 * names belong to the underlying firmware node and should not be released 382 366 * by the caller. 383 367 */ 384 - static int devprop_gpiochip_set_names(struct gpio_chip *chip) 368 + static int gpiochip_set_names(struct gpio_chip *chip) 385 369 { 386 370 struct gpio_device *gdev = chip->gpiodev; 387 371 struct device *dev = &gdev->dev; ··· 572 556 } 573 557 EXPORT_SYMBOL_GPL(gpiochip_line_is_valid); 574 558 575 - static void gpiodevice_release(struct device *dev) 559 + static void gpiodev_release(struct device *dev) 576 560 { 577 561 struct gpio_device *gdev = to_gpio_device(dev); 578 562 unsigned long flags; ··· 601 585 602 586 static int gpiochip_setup_dev(struct gpio_device *gdev) 603 587 { 588 + struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); 604 589 int ret; 605 590 606 591 /* 607 592 * If fwnode doesn't belong to another device, it's safe to clear its 608 593 * initialized flag. 609 594 */ 610 - if (gdev->dev.fwnode && !gdev->dev.fwnode->dev) 611 - fwnode_dev_initialized(gdev->dev.fwnode, false); 595 + if (fwnode && !fwnode->dev) 596 + fwnode_dev_initialized(fwnode, false); 612 597 613 598 ret = gcdev_register(gdev, gpio_devt); 614 599 if (ret) 615 600 return ret; 616 601 617 602 /* From this point, the .release() function cleans up gpio_device */ 618 - gdev->dev.release = gpiodevice_release; 603 + gdev->dev.release = gpiodev_release; 619 604 620 605 ret = gpiochip_sysfs_register(gdev); 621 606 if (ret) ··· 680 663 } 681 664 } 682 665 666 + static void gpiochip_set_data(struct gpio_chip *gc, void *data) 667 + { 668 + gc->gpiodev->data = data; 669 + } 670 + 671 + /** 672 + * gpiochip_get_data() - get per-subdriver data for the chip 673 + * @gc: GPIO chip 674 + * 675 + * Returns: 676 + * The per-subdriver data for the chip. 677 + */ 678 + void *gpiochip_get_data(struct gpio_chip *gc) 679 + { 680 + return gc->gpiodev->data; 681 + } 682 + EXPORT_SYMBOL_GPL(gpiochip_get_data); 683 + 683 684 int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, 684 685 struct lock_class_key *lock_key, 685 686 struct lock_class_key *request_key) 686 687 { 687 - struct fwnode_handle *fwnode = NULL; 688 688 struct gpio_device *gdev; 689 689 unsigned long flags; 690 690 unsigned int i; ··· 709 675 int base = 0; 710 676 int ret = 0; 711 677 712 - /* If the calling driver did not initialize firmware node, do it here */ 713 - if (gc->fwnode) 714 - fwnode = gc->fwnode; 715 - else if (gc->parent) 716 - fwnode = dev_fwnode(gc->parent); 717 - gc->fwnode = fwnode; 678 + /* 679 + * If the calling driver did not initialize firmware node, do it here 680 + * using the parent device, if any. 681 + */ 682 + if (!gc->fwnode && gc->parent) 683 + gc->fwnode = dev_fwnode(gc->parent); 718 684 719 685 /* 720 686 * First: allocate and populate the internal stat container, and ··· 726 692 gdev->dev.bus = &gpio_bus_type; 727 693 gdev->dev.parent = gc->parent; 728 694 gdev->chip = gc; 695 + 729 696 gc->gpiodev = gdev; 697 + gpiochip_set_data(gc, data); 730 698 731 699 device_set_node(&gdev->dev, gc->fwnode); 732 700 ··· 795 759 } 796 760 797 761 gdev->ngpio = gc->ngpio; 798 - gdev->data = data; 799 762 800 763 spin_lock_irqsave(&gpio_lock, flags); 801 764 ··· 851 816 if (ret) 852 817 goto err_remove_from_list; 853 818 } 854 - ret = devprop_gpiochip_set_names(gc); 819 + ret = gpiochip_set_names(gc); 855 820 if (ret) 856 821 goto err_remove_from_list; 857 822 ··· 957 922 EXPORT_SYMBOL_GPL(gpiochip_add_data_with_key); 958 923 959 924 /** 960 - * gpiochip_get_data() - get per-subdriver data for the chip 961 - * @gc: GPIO chip 962 - * 963 - * Returns: 964 - * The per-subdriver data for the chip. 965 - */ 966 - void *gpiochip_get_data(struct gpio_chip *gc) 967 - { 968 - return gc->gpiodev->data; 969 - } 970 - EXPORT_SYMBOL_GPL(gpiochip_get_data); 971 - 972 - /** 973 925 * gpiochip_remove() - unregister a gpio_chip 974 926 * @gc: the chip to unregister 975 927 * ··· 982 960 gpiochip_free_valid_mask(gc); 983 961 /* 984 962 * We accept no more calls into the driver from this point, so 985 - * NULL the driver data pointer 963 + * NULL the driver data pointer. 986 964 */ 987 - gdev->data = NULL; 965 + gpiochip_set_data(gc, NULL); 988 966 989 967 spin_lock_irqsave(&gpio_lock, flags); 990 968 for (i = 0; i < gdev->ngpio; i++) { ··· 1223 1201 if (ret) 1224 1202 return ret; 1225 1203 1226 - chip_dbg(gc, "allocate IRQ %d, hwirq %lu\n", irq, hwirq); 1204 + chip_dbg(gc, "allocate IRQ %d, hwirq %lu\n", irq, hwirq); 1227 1205 1228 1206 ret = girq->child_to_parent_hwirq(gc, hwirq, type, 1229 1207 &parent_hwirq, &parent_type); ··· 1391 1369 * gpiochip by assigning the gpiochip as chip data, and using the irqchip 1392 1370 * stored inside the gpiochip. 1393 1371 */ 1394 - int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, 1395 - irq_hw_number_t hwirq) 1372 + int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hwirq) 1396 1373 { 1397 1374 struct gpio_chip *gc = d->host_data; 1398 1375 int ret = 0; ··· 1467 1446 struct irq_data *data, bool reserve) 1468 1447 { 1469 1448 struct gpio_chip *gc = domain->host_data; 1449 + unsigned int hwirq = irqd_to_hwirq(data); 1470 1450 1471 - return gpiochip_lock_as_irq(gc, data->hwirq); 1451 + return gpiochip_lock_as_irq(gc, hwirq); 1472 1452 } 1473 1453 EXPORT_SYMBOL_GPL(gpiochip_irq_domain_activate); 1474 1454 ··· 1486 1464 struct irq_data *data) 1487 1465 { 1488 1466 struct gpio_chip *gc = domain->host_data; 1467 + unsigned int hwirq = irqd_to_hwirq(data); 1489 1468 1490 - return gpiochip_unlock_as_irq(gc, data->hwirq); 1469 + return gpiochip_unlock_as_irq(gc, hwirq); 1491 1470 } 1492 1471 EXPORT_SYMBOL_GPL(gpiochip_irq_domain_deactivate); 1493 1472 ··· 1528 1505 int gpiochip_irq_reqres(struct irq_data *d) 1529 1506 { 1530 1507 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1508 + unsigned int hwirq = irqd_to_hwirq(d); 1531 1509 1532 - return gpiochip_reqres_irq(gc, d->hwirq); 1510 + return gpiochip_reqres_irq(gc, hwirq); 1533 1511 } 1534 1512 EXPORT_SYMBOL(gpiochip_irq_reqres); 1535 1513 1536 1514 void gpiochip_irq_relres(struct irq_data *d) 1537 1515 { 1538 1516 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1517 + unsigned int hwirq = irqd_to_hwirq(d); 1539 1518 1540 - gpiochip_relres_irq(gc, d->hwirq); 1519 + gpiochip_relres_irq(gc, hwirq); 1541 1520 } 1542 1521 EXPORT_SYMBOL(gpiochip_irq_relres); 1543 1522 1544 1523 static void gpiochip_irq_mask(struct irq_data *d) 1545 1524 { 1546 1525 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1526 + unsigned int hwirq = irqd_to_hwirq(d); 1547 1527 1548 1528 if (gc->irq.irq_mask) 1549 1529 gc->irq.irq_mask(d); 1550 - gpiochip_disable_irq(gc, d->hwirq); 1530 + gpiochip_disable_irq(gc, hwirq); 1551 1531 } 1552 1532 1553 1533 static void gpiochip_irq_unmask(struct irq_data *d) 1554 1534 { 1555 1535 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1536 + unsigned int hwirq = irqd_to_hwirq(d); 1556 1537 1557 - gpiochip_enable_irq(gc, d->hwirq); 1538 + gpiochip_enable_irq(gc, hwirq); 1558 1539 if (gc->irq.irq_unmask) 1559 1540 gc->irq.irq_unmask(d); 1560 1541 } ··· 1566 1539 static void gpiochip_irq_enable(struct irq_data *d) 1567 1540 { 1568 1541 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1542 + unsigned int hwirq = irqd_to_hwirq(d); 1569 1543 1570 - gpiochip_enable_irq(gc, d->hwirq); 1544 + gpiochip_enable_irq(gc, hwirq); 1571 1545 gc->irq.irq_enable(d); 1572 1546 } 1573 1547 1574 1548 static void gpiochip_irq_disable(struct irq_data *d) 1575 1549 { 1576 1550 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1551 + unsigned int hwirq = irqd_to_hwirq(d); 1577 1552 1578 1553 gc->irq.irq_disable(d); 1579 - gpiochip_disable_irq(gc, d->hwirq); 1554 + gpiochip_disable_irq(gc, hwirq); 1580 1555 } 1581 1556 1582 1557 static void gpiochip_set_irq_hooks(struct gpio_chip *gc) ··· 3938 3909 bool platform_lookup_allowed) 3939 3910 { 3940 3911 unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT; 3941 - struct gpio_desc *desc = ERR_PTR(-ENOENT); 3912 + struct gpio_desc *desc; 3942 3913 int ret; 3943 3914 3944 - if (!IS_ERR_OR_NULL(fwnode)) 3945 - desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx, 3946 - &flags, &lookupflags); 3947 - 3915 + desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx, &flags, &lookupflags); 3948 3916 if (gpiod_not_found(desc) && platform_lookup_allowed) { 3949 3917 /* 3950 3918 * Either we are not using DT or ACPI, or their lookup did not ··· 4282 4256 struct gpio_array *array_info = NULL; 4283 4257 struct gpio_chip *gc; 4284 4258 int count, bitmap_size; 4259 + size_t descs_size; 4285 4260 4286 4261 count = gpiod_count(dev, con_id); 4287 4262 if (count < 0) 4288 4263 return ERR_PTR(count); 4289 4264 4290 - descs = kzalloc(struct_size(descs, desc, count), GFP_KERNEL); 4265 + descs_size = struct_size(descs, desc, count); 4266 + descs = kzalloc(descs_size, GFP_KERNEL); 4291 4267 if (!descs) 4292 4268 return ERR_PTR(-ENOMEM); 4293 4269 4294 - for (descs->ndescs = 0; descs->ndescs < count; ) { 4270 + for (descs->ndescs = 0; descs->ndescs < count; descs->ndescs++) { 4295 4271 desc = gpiod_get_index(dev, con_id, descs->ndescs, flags); 4296 4272 if (IS_ERR(desc)) { 4297 4273 gpiod_put_array(descs); ··· 4313 4285 bitmap_size = BITS_TO_LONGS(gc->ngpio > count ? 4314 4286 gc->ngpio : count); 4315 4287 4316 - array = kzalloc(struct_size(descs, desc, count) + 4317 - struct_size(array_info, invert_mask, 4318 - 3 * bitmap_size), GFP_KERNEL); 4288 + array = krealloc(descs, descs_size + 4289 + struct_size(array_info, invert_mask, 3 * bitmap_size), 4290 + GFP_KERNEL | __GFP_ZERO); 4319 4291 if (!array) { 4320 4292 gpiod_put_array(descs); 4321 4293 return ERR_PTR(-ENOMEM); 4322 4294 } 4323 4295 4324 - memcpy(array, descs, 4325 - struct_size(descs, desc, descs->ndescs + 1)); 4326 - kfree(descs); 4327 - 4328 4296 descs = array; 4329 - array_info = (void *)(descs->desc + count); 4297 + 4298 + array_info = (void *)descs + descs_size; 4330 4299 array_info->get_mask = array_info->invert_mask + 4331 4300 bitmap_size; 4332 4301 array_info->set_mask = array_info->get_mask + ··· 4338 4313 count - descs->ndescs); 4339 4314 descs->info = array_info; 4340 4315 } 4316 + 4317 + /* If there is no cache for fast bitmap processing path, continue */ 4318 + if (!array_info) 4319 + continue; 4320 + 4341 4321 /* Unmark array members which don't belong to the 'fast' chip */ 4342 - if (array_info && array_info->chip != gc) { 4322 + if (array_info->chip != gc) { 4343 4323 __clear_bit(descs->ndescs, array_info->get_mask); 4344 4324 __clear_bit(descs->ndescs, array_info->set_mask); 4345 4325 } ··· 4352 4322 * Detect array members which belong to the 'fast' chip 4353 4323 * but their pins are not in hardware order. 4354 4324 */ 4355 - else if (array_info && 4356 - gpio_chip_hwgpio(desc) != descs->ndescs) { 4325 + else if (gpio_chip_hwgpio(desc) != descs->ndescs) { 4357 4326 /* 4358 4327 * Don't use fast path if all array members processed so 4359 4328 * far belong to the same chip as this one but its pin ··· 4366 4337 __clear_bit(descs->ndescs, 4367 4338 array_info->set_mask); 4368 4339 } 4369 - } else if (array_info) { 4340 + } else { 4370 4341 /* Exclude open drain or open source from fast output */ 4371 4342 if (gpiochip_line_is_open_drain(gc, descs->ndescs) || 4372 4343 gpiochip_line_is_open_source(gc, descs->ndescs)) ··· 4377 4348 __set_bit(descs->ndescs, 4378 4349 array_info->invert_mask); 4379 4350 } 4380 - 4381 - descs->ndescs++; 4382 4351 } 4383 4352 if (array_info) 4384 4353 dev_dbg(dev, ··· 4439 4412 kfree(descs); 4440 4413 } 4441 4414 EXPORT_SYMBOL_GPL(gpiod_put_array); 4442 - 4443 - 4444 - static int gpio_bus_match(struct device *dev, struct device_driver *drv) 4445 - { 4446 - struct fwnode_handle *fwnode = dev_fwnode(dev); 4447 - 4448 - /* 4449 - * Only match if the fwnode doesn't already have a proper struct device 4450 - * created for it. 4451 - */ 4452 - if (fwnode && fwnode->dev != dev) 4453 - return 0; 4454 - return 1; 4455 - } 4456 4415 4457 4416 static int gpio_stub_drv_probe(struct device *dev) 4458 4417 {
+7 -7
drivers/hte/hte-tegra194-test.c
··· 6 6 */ 7 7 8 8 #include <linux/err.h> 9 - #include <linux/module.h> 10 - #include <linux/moduleparam.h> 11 - #include <linux/interrupt.h> 12 - #include <linux/gpio.h> 13 - #include <linux/timer.h> 14 - #include <linux/platform_device.h> 15 - #include <linux/workqueue.h> 9 + #include <linux/gpio/consumer.h> 16 10 #include <linux/hte.h> 11 + #include <linux/interrupt.h> 12 + #include <linux/mod_devicetable.h> 13 + #include <linux/module.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/timer.h> 16 + #include <linux/workqueue.h> 17 17 18 18 /* 19 19 * This sample HTE GPIO test driver demonstrates HTE API usage by enabling
+3 -2
drivers/input/touchscreen/ads7846.c
··· 27 27 #include <linux/of.h> 28 28 #include <linux/of_gpio.h> 29 29 #include <linux/of_device.h> 30 + #include <linux/gpio/consumer.h> 30 31 #include <linux/gpio.h> 31 32 #include <linux/spi/spi.h> 32 33 #include <linux/spi/ads7846.h> ··· 1013 1012 ts->gpio_pendown = pdata->gpio_pendown; 1014 1013 1015 1014 if (pdata->gpio_pendown_debounce) 1016 - gpio_set_debounce(pdata->gpio_pendown, 1017 - pdata->gpio_pendown_debounce); 1015 + gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown), 1016 + pdata->gpio_pendown_debounce); 1018 1017 } else { 1019 1018 dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); 1020 1019 return -EINVAL;
+7 -3
drivers/media/pci/sta2x11/sta2x11_vip.c
··· 18 18 #include <linux/pci.h> 19 19 #include <linux/interrupt.h> 20 20 #include <linux/io.h> 21 + #include <linux/gpio/consumer.h> 21 22 #include <linux/gpio.h> 22 23 #include <linux/i2c.h> 23 24 #include <linux/delay.h> ··· 890 889 static int vip_gpio_reserve(struct device *dev, int pin, int dir, 891 890 const char *name) 892 891 { 892 + struct gpio_desc *desc = gpio_to_desc(pin); 893 893 int ret = -ENODEV; 894 894 895 895 if (!gpio_is_valid(pin)) ··· 902 900 return ret; 903 901 } 904 902 905 - ret = gpio_direction_output(pin, dir); 903 + ret = gpiod_direction_output(desc, dir); 906 904 if (ret) { 907 905 dev_err(dev, "Failed to set direction for pin %d (%s)\n", 908 906 pin, name); ··· 910 908 return ret; 911 909 } 912 910 913 - ret = gpio_export(pin, false); 911 + ret = gpiod_export(desc, false); 914 912 if (ret) { 915 913 dev_err(dev, "Failed to export pin %d (%s)\n", pin, name); 916 914 gpio_free(pin); ··· 930 928 static void vip_gpio_release(struct device *dev, int pin, const char *name) 931 929 { 932 930 if (gpio_is_valid(pin)) { 931 + struct gpio_desc *desc = gpio_to_desc(pin); 932 + 933 933 dev_dbg(dev, "releasing pin %d (%s)\n", pin, name); 934 - gpio_unexport(pin); 934 + gpiod_unexport(desc); 935 935 gpio_free(pin); 936 936 } 937 937 }
+2 -1
drivers/net/ieee802154/ca8210.c
··· 51 51 #include <linux/clk-provider.h> 52 52 #include <linux/debugfs.h> 53 53 #include <linux/delay.h> 54 + #include <linux/gpio/consumer.h> 54 55 #include <linux/gpio.h> 55 56 #include <linux/ieee802154.h> 56 57 #include <linux/io.h> ··· 2855 2854 ); 2856 2855 if (ret) { 2857 2856 dev_crit(&spi->dev, "request_irq %d failed\n", pdata->irq_id); 2858 - gpio_unexport(pdata->gpio_irq); 2857 + gpiod_unexport(gpio_to_desc(pdata->gpio_irq)); 2859 2858 gpio_free(pdata->gpio_irq); 2860 2859 } 2861 2860
+1
drivers/net/wireless/broadcom/brcm80211/brcmsmac/led.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <net/mac80211.h> 3 3 #include <linux/bcma/bcma_driver_chipcommon.h> 4 + #include <linux/gpio.h> 4 5 #include <linux/gpio/driver.h> 5 6 #include <linux/gpio/machine.h> 6 7 #include <linux/gpio/consumer.h>
-1
drivers/pinctrl/core.c
··· 30 30 31 31 #ifdef CONFIG_GPIOLIB 32 32 #include "../gpio/gpiolib.h" 33 - #include <asm-generic/gpio.h> 34 33 #endif 35 34 36 35 #include "core.h"
+1 -1
drivers/soc/fsl/qe/gpio.c
··· 13 13 #include <linux/err.h> 14 14 #include <linux/io.h> 15 15 #include <linux/of.h> 16 - #include <linux/of_gpio.h> /* for of_mm_gpio_chip */ 16 + #include <linux/gpio/legacy-of-mm-gpiochip.h> 17 17 #include <linux/gpio/consumer.h> 18 18 #include <linux/gpio/driver.h> 19 19 #include <linux/slab.h>
-147
include/asm-generic/gpio.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _ASM_GENERIC_GPIO_H 3 - #define _ASM_GENERIC_GPIO_H 4 - 5 - #include <linux/types.h> 6 - #include <linux/errno.h> 7 - 8 - #ifdef CONFIG_GPIOLIB 9 - 10 - #include <linux/compiler.h> 11 - #include <linux/gpio/driver.h> 12 - #include <linux/gpio/consumer.h> 13 - 14 - /* 15 - * Platforms may implement their GPIO interface with library code, 16 - * at a small performance cost for non-inlined operations and some 17 - * extra memory (for code and for per-GPIO table entries). 18 - */ 19 - 20 - /* 21 - * At the end we want all GPIOs to be dynamically allocated from 0. 22 - * However, some legacy drivers still perform fixed allocation. 23 - * Until they are all fixed, leave 0-512 space for them. 24 - */ 25 - #define GPIO_DYNAMIC_BASE 512 26 - 27 - struct device; 28 - struct gpio; 29 - struct seq_file; 30 - struct module; 31 - struct device_node; 32 - struct gpio_desc; 33 - 34 - /* Always use the library code for GPIO management calls, 35 - * or when sleeping may be involved. 36 - */ 37 - extern int gpio_request(unsigned gpio, const char *label); 38 - extern void gpio_free(unsigned gpio); 39 - 40 - static inline int gpio_direction_input(unsigned gpio) 41 - { 42 - return gpiod_direction_input(gpio_to_desc(gpio)); 43 - } 44 - static inline int gpio_direction_output(unsigned gpio, int value) 45 - { 46 - return gpiod_direction_output_raw(gpio_to_desc(gpio), value); 47 - } 48 - 49 - static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) 50 - { 51 - return gpiod_set_debounce(gpio_to_desc(gpio), debounce); 52 - } 53 - 54 - static inline int gpio_get_value_cansleep(unsigned gpio) 55 - { 56 - return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio)); 57 - } 58 - static inline void gpio_set_value_cansleep(unsigned gpio, int value) 59 - { 60 - return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value); 61 - } 62 - 63 - 64 - /* A platform's <asm/gpio.h> code may want to inline the I/O calls when 65 - * the GPIO is constant and refers to some always-present controller, 66 - * giving direct access to chip registers and tight bitbanging loops. 67 - */ 68 - static inline int __gpio_get_value(unsigned gpio) 69 - { 70 - return gpiod_get_raw_value(gpio_to_desc(gpio)); 71 - } 72 - static inline void __gpio_set_value(unsigned gpio, int value) 73 - { 74 - return gpiod_set_raw_value(gpio_to_desc(gpio), value); 75 - } 76 - 77 - static inline int __gpio_cansleep(unsigned gpio) 78 - { 79 - return gpiod_cansleep(gpio_to_desc(gpio)); 80 - } 81 - 82 - static inline int __gpio_to_irq(unsigned gpio) 83 - { 84 - return gpiod_to_irq(gpio_to_desc(gpio)); 85 - } 86 - 87 - extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); 88 - extern int gpio_request_array(const struct gpio *array, size_t num); 89 - extern void gpio_free_array(const struct gpio *array, size_t num); 90 - 91 - /* 92 - * A sysfs interface can be exported by individual drivers if they want, 93 - * but more typically is configured entirely from userspace. 94 - */ 95 - static inline int gpio_export(unsigned gpio, bool direction_may_change) 96 - { 97 - return gpiod_export(gpio_to_desc(gpio), direction_may_change); 98 - } 99 - 100 - static inline void gpio_unexport(unsigned gpio) 101 - { 102 - gpiod_unexport(gpio_to_desc(gpio)); 103 - } 104 - 105 - #else /* !CONFIG_GPIOLIB */ 106 - 107 - #include <linux/kernel.h> 108 - 109 - /* platforms that don't directly support access to GPIOs through I2C, SPI, 110 - * or other blocking infrastructure can use these wrappers. 111 - */ 112 - 113 - static inline int gpio_cansleep(unsigned gpio) 114 - { 115 - return 0; 116 - } 117 - 118 - static inline int gpio_get_value_cansleep(unsigned gpio) 119 - { 120 - might_sleep(); 121 - return __gpio_get_value(gpio); 122 - } 123 - 124 - static inline void gpio_set_value_cansleep(unsigned gpio, int value) 125 - { 126 - might_sleep(); 127 - __gpio_set_value(gpio, value); 128 - } 129 - 130 - #endif /* !CONFIG_GPIOLIB */ 131 - 132 - /* 133 - * "valid" GPIO numbers are nonnegative and may be passed to 134 - * setup routines like gpio_request(). only some valid numbers 135 - * can successfully be requested and used. 136 - * 137 - * Invalid GPIO numbers are useful for indicating no-such-GPIO in 138 - * platform data and other tables. 139 - */ 140 - 141 - static inline bool gpio_is_valid(int number) 142 - { 143 - /* only non-negative numbers are valid */ 144 - return number >= 0; 145 - } 146 - 147 - #endif /* _ASM_GENERIC_GPIO_H */
+67 -39
include/linux/gpio.h
··· 12 12 #ifndef __LINUX_GPIO_H 13 13 #define __LINUX_GPIO_H 14 14 15 - #include <linux/errno.h> 15 + #include <linux/types.h> 16 + 17 + struct device; 16 18 17 19 /* see Documentation/driver-api/gpio/legacy.rst */ 18 20 ··· 57 55 58 56 #ifdef CONFIG_GPIOLIB 59 57 60 - #ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H 61 - #include <asm/gpio.h> 62 - #else 58 + #include <linux/gpio/consumer.h> 63 59 64 - #include <asm-generic/gpio.h> 65 - 66 - static inline int gpio_get_value(unsigned int gpio) 60 + /* 61 + * "valid" GPIO numbers are nonnegative and may be passed to 62 + * setup routines like gpio_request(). Only some valid numbers 63 + * can successfully be requested and used. 64 + * 65 + * Invalid GPIO numbers are useful for indicating no-such-GPIO in 66 + * platform data and other tables. 67 + */ 68 + static inline bool gpio_is_valid(int number) 67 69 { 68 - return __gpio_get_value(gpio); 70 + /* only non-negative numbers are valid */ 71 + return number >= 0; 69 72 } 70 73 71 - static inline void gpio_set_value(unsigned int gpio, int value) 74 + /* 75 + * Platforms may implement their GPIO interface with library code, 76 + * at a small performance cost for non-inlined operations and some 77 + * extra memory (for code and for per-GPIO table entries). 78 + */ 79 + 80 + /* 81 + * At the end we want all GPIOs to be dynamically allocated from 0. 82 + * However, some legacy drivers still perform fixed allocation. 83 + * Until they are all fixed, leave 0-512 space for them. 84 + */ 85 + #define GPIO_DYNAMIC_BASE 512 86 + 87 + /* Always use the library code for GPIO management calls, 88 + * or when sleeping may be involved. 89 + */ 90 + int gpio_request(unsigned gpio, const char *label); 91 + void gpio_free(unsigned gpio); 92 + 93 + static inline int gpio_direction_input(unsigned gpio) 72 94 { 73 - __gpio_set_value(gpio, value); 95 + return gpiod_direction_input(gpio_to_desc(gpio)); 96 + } 97 + static inline int gpio_direction_output(unsigned gpio, int value) 98 + { 99 + return gpiod_direction_output_raw(gpio_to_desc(gpio), value); 74 100 } 75 101 76 - static inline int gpio_cansleep(unsigned int gpio) 102 + static inline int gpio_get_value_cansleep(unsigned gpio) 77 103 { 78 - return __gpio_cansleep(gpio); 104 + return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio)); 105 + } 106 + static inline void gpio_set_value_cansleep(unsigned gpio, int value) 107 + { 108 + return gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value); 79 109 } 80 110 81 - static inline int gpio_to_irq(unsigned int gpio) 111 + static inline int gpio_get_value(unsigned gpio) 82 112 { 83 - return __gpio_to_irq(gpio); 113 + return gpiod_get_raw_value(gpio_to_desc(gpio)); 114 + } 115 + static inline void gpio_set_value(unsigned gpio, int value) 116 + { 117 + return gpiod_set_raw_value(gpio_to_desc(gpio), value); 84 118 } 85 119 86 - #endif /* ! CONFIG_ARCH_HAVE_CUSTOM_GPIO_H */ 120 + static inline int gpio_cansleep(unsigned gpio) 121 + { 122 + return gpiod_cansleep(gpio_to_desc(gpio)); 123 + } 124 + 125 + static inline int gpio_to_irq(unsigned gpio) 126 + { 127 + return gpiod_to_irq(gpio_to_desc(gpio)); 128 + } 129 + 130 + int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); 131 + int gpio_request_array(const struct gpio *array, size_t num); 132 + void gpio_free_array(const struct gpio *array, size_t num); 87 133 88 134 /* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ 89 - 90 - struct device; 91 135 92 136 int devm_gpio_request(struct device *dev, unsigned gpio, const char *label); 93 137 int devm_gpio_request_one(struct device *dev, unsigned gpio, ··· 141 93 142 94 #else /* ! CONFIG_GPIOLIB */ 143 95 144 - #include <linux/bug.h> 145 96 #include <linux/kernel.h> 146 - #include <linux/types.h> 147 97 148 - struct device; 149 - struct gpio_chip; 98 + #include <asm/bug.h> 99 + #include <asm/errno.h> 150 100 151 101 static inline bool gpio_is_valid(int number) 152 102 { ··· 193 147 return -ENOSYS; 194 148 } 195 149 196 - static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) 197 - { 198 - return -ENOSYS; 199 - } 200 - 201 150 static inline int gpio_get_value(unsigned gpio) 202 151 { 203 152 /* GPIO can never have been requested or set as {in,out}put */ ··· 223 182 static inline void gpio_set_value_cansleep(unsigned gpio, int value) 224 183 { 225 184 /* GPIO can never have been requested or set as output */ 226 - WARN_ON(1); 227 - } 228 - 229 - static inline int gpio_export(unsigned gpio, bool direction_may_change) 230 - { 231 - /* GPIO can never have been requested or set as {in,out}put */ 232 - WARN_ON(1); 233 - return -EINVAL; 234 - } 235 - 236 - static inline void gpio_unexport(unsigned gpio) 237 - { 238 - /* GPIO can never have been exported */ 239 185 WARN_ON(1); 240 186 } 241 187
+12 -12
include/linux/gpio/consumer.h
··· 3 3 #define __LINUX_GPIO_CONSUMER_H 4 4 5 5 #include <linux/bits.h> 6 - #include <linux/bug.h> 7 - #include <linux/compiler_types.h> 8 - #include <linux/err.h> 6 + #include <linux/types.h> 9 7 8 + struct acpi_device; 10 9 struct device; 11 - struct gpio_desc; 10 + struct fwnode_handle; 11 + 12 12 struct gpio_array; 13 + struct gpio_desc; 13 14 14 15 /** 15 16 * struct gpio_descs - Struct containing an array of descriptors that can be ··· 172 171 struct gpio_desc *gpio_to_desc(unsigned gpio); 173 172 int desc_to_gpio(const struct gpio_desc *desc); 174 173 175 - /* Child properties interface */ 176 - struct fwnode_handle; 177 - 178 174 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, 179 175 const char *con_id, int index, 180 176 enum gpiod_flags flags, ··· 184 186 185 187 #else /* CONFIG_GPIOLIB */ 186 188 189 + #include <linux/err.h> 187 190 #include <linux/kernel.h> 191 + 192 + #include <asm/bug.h> 188 193 189 194 static inline int gpiod_count(struct device *dev, const char *con_id) 190 195 { ··· 547 546 return -EINVAL; 548 547 } 549 548 550 - /* Child properties interface */ 551 - struct fwnode_handle; 552 - 553 549 static inline 554 550 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, 555 551 const char *con_id, int index, ··· 605 607 unsigned int quirks; 606 608 }; 607 609 608 - struct acpi_device; 609 - 610 610 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_ACPI) 611 611 612 612 int acpi_dev_add_driver_gpios(struct acpi_device *adev, ··· 617 621 struct gpio_desc *acpi_get_and_request_gpiod(char *path, unsigned int pin, char *label); 618 622 619 623 #else /* CONFIG_GPIOLIB && CONFIG_ACPI */ 624 + 625 + #include <linux/err.h> 620 626 621 627 static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev, 622 628 const struct acpi_gpio_mapping *gpios) ··· 650 652 void gpiod_unexport(struct gpio_desc *desc); 651 653 652 654 #else /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */ 655 + 656 + #include <asm/errno.h> 653 657 654 658 static inline int gpiod_export(struct gpio_desc *desc, 655 659 bool direction_may_change)
+24 -9
include/linux/gpio/driver.h
··· 2 2 #ifndef __LINUX_GPIO_DRIVER_H 3 3 #define __LINUX_GPIO_DRIVER_H 4 4 5 - #include <linux/device.h> 6 - #include <linux/irq.h> 5 + #include <linux/bits.h> 7 6 #include <linux/irqchip/chained_irq.h> 8 7 #include <linux/irqdomain.h> 8 + #include <linux/irqhandler.h> 9 9 #include <linux/lockdep.h> 10 10 #include <linux/pinctrl/pinconf-generic.h> 11 11 #include <linux/pinctrl/pinctrl.h> 12 12 #include <linux/property.h> 13 + #include <linux/spinlock_types.h> 13 14 #include <linux/types.h> 14 15 16 + #ifdef CONFIG_GENERIC_MSI_IRQ 15 17 #include <asm/msi.h> 18 + #endif 16 19 17 - struct gpio_desc; 18 - struct of_phandle_args; 19 - struct device_node; 20 - struct seq_file; 21 - struct gpio_device; 20 + struct device; 21 + struct irq_chip; 22 + struct irq_data; 22 23 struct module; 23 - enum gpiod_flags; 24 - enum gpio_lookup_flags; 24 + struct of_phandle_args; 25 + struct pinctrl_dev; 26 + struct seq_file; 25 27 26 28 struct gpio_chip; 29 + struct gpio_desc; 30 + struct gpio_device; 31 + 32 + enum gpio_lookup_flags; 33 + enum gpiod_flags; 27 34 28 35 union gpio_irq_fwspec { 29 36 struct irq_fwspec fwspec; ··· 687 680 int gpiochip_irqchip_add_domain(struct gpio_chip *gc, 688 681 struct irq_domain *domain); 689 682 #else 683 + 684 + #include <asm/bug.h> 685 + #include <asm/errno.h> 686 + 690 687 static inline int gpiochip_irqchip_add_domain(struct gpio_chip *gc, 691 688 struct irq_domain *domain) 692 689 { ··· 767 756 struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc); 768 757 769 758 #else /* CONFIG_GPIOLIB */ 759 + 760 + #include <linux/err.h> 761 + 762 + #include <asm/bug.h> 770 763 771 764 static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) 772 765 {
+36
include/linux/gpio/legacy-of-mm-gpiochip.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 + /* 3 + * OF helpers for the old of_mm_gpio_chip, used on ppc32 and nios2, 4 + * do not use in new code. 5 + * 6 + * Copyright (c) 2007-2008 MontaVista Software, Inc. 7 + * 8 + * Author: Anton Vorontsov <avorontsov@ru.mvista.com> 9 + */ 10 + 11 + #ifndef __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H 12 + #define __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H 13 + 14 + #include <linux/gpio/driver.h> 15 + #include <linux/of.h> 16 + 17 + /* 18 + * OF GPIO chip for memory mapped banks 19 + */ 20 + struct of_mm_gpio_chip { 21 + struct gpio_chip gc; 22 + void (*save_regs)(struct of_mm_gpio_chip *mm_gc); 23 + void __iomem *regs; 24 + }; 25 + 26 + static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) 27 + { 28 + return container_of(gc, struct of_mm_gpio_chip, gc); 29 + } 30 + 31 + extern int of_mm_gpiochip_add_data(struct device_node *np, 32 + struct of_mm_gpio_chip *mm_gc, 33 + void *data); 34 + extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); 35 + 36 + #endif /* __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H */
+1
include/linux/mfd/ucb1x00.h
··· 10 10 #include <linux/device.h> 11 11 #include <linux/mfd/mcp.h> 12 12 #include <linux/gpio.h> 13 + #include <linux/gpio/driver.h> 13 14 #include <linux/mutex.h> 14 15 15 16 #define UCB_IO_DATA 0x00
-21
include/linux/of_gpio.h
··· 19 19 20 20 #ifdef CONFIG_OF_GPIO 21 21 22 - #include <linux/container_of.h> 23 - 24 - /* 25 - * OF GPIO chip for memory mapped banks 26 - */ 27 - struct of_mm_gpio_chip { 28 - struct gpio_chip gc; 29 - void (*save_regs)(struct of_mm_gpio_chip *mm_gc); 30 - void __iomem *regs; 31 - }; 32 - 33 - static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) 34 - { 35 - return container_of(gc, struct of_mm_gpio_chip, gc); 36 - } 37 - 38 22 extern int of_get_named_gpio(const struct device_node *np, 39 23 const char *list_name, int index); 40 - 41 - extern int of_mm_gpiochip_add_data(struct device_node *np, 42 - struct of_mm_gpio_chip *mm_gc, 43 - void *data); 44 - extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); 45 24 46 25 #else /* CONFIG_OF_GPIO */ 47 26