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

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

Pull gpio updates from Bartosz Golaszewski:
"One new driver, support for new models in existing ones, dt-bindings
conversions for several modules and improvements all over the place.

Summary:

- new driver for the IDT 79RC3243x GPIO controller

- device tree bindings coversion to YAML for the following drivers:
gpio-rk3328-grf, gpio-omap, gpio-davinci, gpio-zynq, gpio-stp,
gpio-pcf857x

- cleanup of probe functions in many drivers from Alexandru Ardelean,
mostly dropping unnecessary calls to platform_set_drvdata() and
removing error messages where none are needed (handled by the
subsystem already)

- several improvements to the core gpiolib and the sysfs interface
code from Andy Shevchenko

- conversion of the gpio-xilinx driver to using the bitmap API +
improvements of suspend/resume handling + minor tweaks

- convert the gpio-stmpe to using devres helpers exclusively in probe
for improved robustness

- updates for the generic gpio-regmap driver

- updates for the gpio-dwapb driver

- support for a new model in gpio-pca953x

- cleanups in gpio-tegra186, gpio-104-idio-16, gpio-mxs & gpio-xgene

- slight code refactoring of the gpio-zynq driver

- documentation fixes from Mauro Carvalho Chehab

- a bunch of minor tweaks and improvements all over the place"

* tag 'gpio-updates-for-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (57 commits)
docs: driver-api: gpio: using-gpio.rst: avoid using ReST :doc:`foo` markup
dt-bindings: gpio: pcf857x: Convert to json-schema
gpio: mxs: Prefer unsigned int to bare use of unsigned
dt-bindings: gpio: stp: convert to json-schema
dt-bindings: gpio: zynq: convert bindings to YAML
dt-bindings: gpio: gpio-davinci: Convert to json-schema
gpio: pca953x: Add support for the On Semi pca9655
gpio: gpio-xilinx: update on suspend and resume calls
gpio: zynq: Check return value of irq_get_irq_data
gpio: zynq: Check return value of pm_runtime_get_sync
gpio: zynq: use module_platform_driver to simplify the code
gpio: idt3243x: Fix return value check in idt_gpio_probe()
MAINTAINERS: update ti,omap-gpio.yaml reference
dt-bindings: gpio: Add devicetree binding for IDT 79RC32434 GPIO controller
gpio: Add support for IDT 79RC3243x GPIO controller
gpio: regmap: move drvdata to config data
gpio-dwapb: Drop unused headers and sort the rest
gpio: gpio-regmap: Use devm_add_action_or_reset()
gpio: dwapb: Switch to use fwnode_irq_get()
gpio: dwapb: Drop redundant check in dwapb_irq_set_type()
...

+1242 -944
-167
Documentation/devicetree/bindings/gpio/gpio-davinci.txt
··· 1 - Davinci/Keystone GPIO controller bindings 2 - 3 - Required Properties: 4 - - compatible: should be "ti,dm6441-gpio": for Davinci da850 SoCs 5 - "ti,keystone-gpio": for Keystone 2 66AK2H/K, 66AK2L, 6 - 66AK2E SoCs 7 - "ti,k2g-gpio", "ti,keystone-gpio": for 66AK2G 8 - "ti,am654-gpio", "ti,keystone-gpio": for TI K3 AM654 9 - "ti,j721e-gpio", "ti,keystone-gpio": for J721E SoCs 10 - "ti,am64-gpio", "ti,keystone-gpio": for AM64 SoCs 11 - 12 - - reg: Physical base address of the controller and the size of memory mapped 13 - registers. 14 - 15 - - gpio-controller : Marks the device node as a gpio controller. 16 - 17 - - #gpio-cells : Should be two. 18 - - first cell is the pin number 19 - - second cell is used to specify optional parameters (unused) 20 - 21 - - interrupts: Array of GPIO interrupt number. Only banked or unbanked IRQs are 22 - supported at a time. 23 - 24 - - ti,ngpio: The number of GPIO pins supported. 25 - 26 - - ti,davinci-gpio-unbanked: The number of GPIOs that have an individual interrupt 27 - line to processor. 28 - 29 - - clocks: Should contain the device's input clock, and should be defined as per 30 - the appropriate clock bindings consumer usage in, 31 - 32 - Documentation/devicetree/bindings/clock/keystone-gate.txt 33 - for 66AK2HK/66AK2L/66AK2E SoCs or, 34 - 35 - Documentation/devicetree/bindings/clock/ti,sci-clk.yaml 36 - for 66AK2G SoCs 37 - 38 - - clock-names: Name should be "gpio"; 39 - 40 - Currently clock-names and clocks are needed for all keystone 2 platforms 41 - Davinci platforms do not have DT clocks as of now. 42 - 43 - The GPIO controller also acts as an interrupt controller. It uses the default 44 - two cells specifier as described in Documentation/devicetree/bindings/ 45 - interrupt-controller/interrupts.txt. 46 - 47 - Example: 48 - 49 - gpio: gpio@1e26000 { 50 - compatible = "ti,dm6441-gpio"; 51 - gpio-controller; 52 - #gpio-cells = <2>; 53 - reg = <0x226000 0x1000>; 54 - interrupt-parent = <&intc>; 55 - interrupts = <42 IRQ_TYPE_EDGE_BOTH 43 IRQ_TYPE_EDGE_BOTH 56 - 44 IRQ_TYPE_EDGE_BOTH 45 IRQ_TYPE_EDGE_BOTH 57 - 46 IRQ_TYPE_EDGE_BOTH 47 IRQ_TYPE_EDGE_BOTH 58 - 48 IRQ_TYPE_EDGE_BOTH 49 IRQ_TYPE_EDGE_BOTH 59 - 50 IRQ_TYPE_EDGE_BOTH>; 60 - ti,ngpio = <144>; 61 - ti,davinci-gpio-unbanked = <0>; 62 - interrupt-controller; 63 - #interrupt-cells = <2>; 64 - }; 65 - 66 - leds { 67 - compatible = "gpio-leds"; 68 - 69 - led1 { 70 - label = "davinci:green:usr1"; 71 - gpios = <&gpio 10 GPIO_ACTIVE_HIGH>; 72 - ... 73 - }; 74 - 75 - led2 { 76 - label = "davinci:red:debug1"; 77 - gpios = <&gpio 11 GPIO_ACTIVE_HIGH>; 78 - ... 79 - }; 80 - }; 81 - 82 - Example for 66AK2G: 83 - 84 - gpio0: gpio@2603000 { 85 - compatible = "ti,k2g-gpio", "ti,keystone-gpio"; 86 - reg = <0x02603000 0x100>; 87 - gpio-controller; 88 - #gpio-cells = <2>; 89 - interrupts = <GIC_SPI 432 IRQ_TYPE_EDGE_RISING>, 90 - <GIC_SPI 433 IRQ_TYPE_EDGE_RISING>, 91 - <GIC_SPI 434 IRQ_TYPE_EDGE_RISING>, 92 - <GIC_SPI 435 IRQ_TYPE_EDGE_RISING>, 93 - <GIC_SPI 436 IRQ_TYPE_EDGE_RISING>, 94 - <GIC_SPI 437 IRQ_TYPE_EDGE_RISING>, 95 - <GIC_SPI 438 IRQ_TYPE_EDGE_RISING>, 96 - <GIC_SPI 439 IRQ_TYPE_EDGE_RISING>, 97 - <GIC_SPI 440 IRQ_TYPE_EDGE_RISING>; 98 - interrupt-controller; 99 - #interrupt-cells = <2>; 100 - ti,ngpio = <144>; 101 - ti,davinci-gpio-unbanked = <0>; 102 - clocks = <&k2g_clks 0x001b 0x0>; 103 - clock-names = "gpio"; 104 - }; 105 - 106 - Example for 66AK2HK/66AK2L/66AK2E: 107 - 108 - gpio0: gpio@260bf00 { 109 - compatible = "ti,keystone-gpio"; 110 - reg = <0x0260bf00 0x100>; 111 - gpio-controller; 112 - #gpio-cells = <2>; 113 - /* HW Interrupts mapped to GPIO pins */ 114 - interrupts = <GIC_SPI 120 IRQ_TYPE_EDGE_RISING>, 115 - <GIC_SPI 121 IRQ_TYPE_EDGE_RISING>, 116 - <GIC_SPI 122 IRQ_TYPE_EDGE_RISING>, 117 - <GIC_SPI 123 IRQ_TYPE_EDGE_RISING>, 118 - <GIC_SPI 124 IRQ_TYPE_EDGE_RISING>, 119 - <GIC_SPI 125 IRQ_TYPE_EDGE_RISING>, 120 - <GIC_SPI 126 IRQ_TYPE_EDGE_RISING>, 121 - <GIC_SPI 127 IRQ_TYPE_EDGE_RISING>, 122 - <GIC_SPI 128 IRQ_TYPE_EDGE_RISING>, 123 - <GIC_SPI 129 IRQ_TYPE_EDGE_RISING>, 124 - <GIC_SPI 130 IRQ_TYPE_EDGE_RISING>, 125 - <GIC_SPI 131 IRQ_TYPE_EDGE_RISING>, 126 - <GIC_SPI 132 IRQ_TYPE_EDGE_RISING>, 127 - <GIC_SPI 133 IRQ_TYPE_EDGE_RISING>, 128 - <GIC_SPI 134 IRQ_TYPE_EDGE_RISING>, 129 - <GIC_SPI 135 IRQ_TYPE_EDGE_RISING>, 130 - <GIC_SPI 136 IRQ_TYPE_EDGE_RISING>, 131 - <GIC_SPI 137 IRQ_TYPE_EDGE_RISING>, 132 - <GIC_SPI 138 IRQ_TYPE_EDGE_RISING>, 133 - <GIC_SPI 139 IRQ_TYPE_EDGE_RISING>, 134 - <GIC_SPI 140 IRQ_TYPE_EDGE_RISING>, 135 - <GIC_SPI 141 IRQ_TYPE_EDGE_RISING>, 136 - <GIC_SPI 142 IRQ_TYPE_EDGE_RISING>, 137 - <GIC_SPI 143 IRQ_TYPE_EDGE_RISING>, 138 - <GIC_SPI 144 IRQ_TYPE_EDGE_RISING>, 139 - <GIC_SPI 145 IRQ_TYPE_EDGE_RISING>, 140 - <GIC_SPI 146 IRQ_TYPE_EDGE_RISING>, 141 - <GIC_SPI 147 IRQ_TYPE_EDGE_RISING>, 142 - <GIC_SPI 148 IRQ_TYPE_EDGE_RISING>, 143 - <GIC_SPI 149 IRQ_TYPE_EDGE_RISING>, 144 - <GIC_SPI 150 IRQ_TYPE_EDGE_RISING>, 145 - <GIC_SPI 151 IRQ_TYPE_EDGE_RISING>; 146 - clocks = <&clkgpio>; 147 - clock-names = "gpio"; 148 - ti,ngpio = <32>; 149 - ti,davinci-gpio-unbanked = <32>; 150 - }; 151 - 152 - Example for K3 AM654: 153 - 154 - wkup_gpio0: wkup_gpio0@42110000 { 155 - compatible = "ti,am654-gpio", "ti,keystone-gpio"; 156 - reg = <0x42110000 0x100>; 157 - gpio-controller; 158 - #gpio-cells = <2>; 159 - interrupt-parent = <&intr_wkup_gpio>; 160 - interrupts = <59 128>, <59 129>, <59 130>, <59 131>; 161 - interrupt-controller; 162 - #interrupt-cells = <2>; 163 - ti,ngpio = <56>; 164 - ti,davinci-gpio-unbanked = <0>; 165 - clocks = <&k3_clks 59 0>; 166 - clock-names = "gpio"; 167 - };
+185
Documentation/devicetree/bindings/gpio/gpio-davinci.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/gpio-davinci.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: GPIO controller for Davinci and keystone devices 8 + 9 + maintainers: 10 + - Keerthy <j-keerthy@ti.com> 11 + 12 + properties: 13 + compatible: 14 + oneOf: 15 + - items: 16 + - enum: 17 + - ti,k2g-gpio 18 + - ti,am654-gpio 19 + - ti,j721e-gpio 20 + - ti,am64-gpio 21 + - const: ti,keystone-gpio 22 + 23 + - items: 24 + - enum: 25 + - ti,dm6441-gpio 26 + - ti,keystone-gpio 27 + 28 + reg: 29 + maxItems: 1 30 + 31 + gpio-controller: true 32 + 33 + gpio-ranges: true 34 + 35 + gpio-line-names: 36 + description: strings describing the names of each gpio line. 37 + minItems: 1 38 + maxItems: 100 39 + 40 + "#gpio-cells": 41 + const: 2 42 + description: 43 + first cell is the pin number and second cell is used to specify optional parameters (unused). 44 + 45 + interrupts: 46 + description: 47 + The interrupts are specified as per the interrupt parent. Only banked 48 + or unbanked IRQs are supported at a time. If the interrupts are 49 + banked then provide list of interrupts corresponding to each bank, else 50 + provide the list of interrupts for each gpio. 51 + minItems: 1 52 + maxItems: 100 53 + 54 + ti,ngpio: 55 + $ref: /schemas/types.yaml#/definitions/uint32 56 + description: The number of GPIO pins supported consecutively. 57 + minimum: 1 58 + 59 + ti,davinci-gpio-unbanked: 60 + $ref: /schemas/types.yaml#/definitions/uint32 61 + description: The number of GPIOs that have an individual interrupt line to processor. 62 + minimum: 0 63 + 64 + clocks: 65 + maxItems: 1 66 + 67 + clock-names: 68 + const: gpio 69 + 70 + interrupt-controller: true 71 + 72 + power-domains: 73 + maxItems: 1 74 + 75 + "#interrupt-cells": 76 + const: 2 77 + 78 + patternProperties: 79 + "^(.+-hog(-[0-9]+)?)$": 80 + type: object 81 + 82 + required: 83 + - gpio-hog 84 + 85 + required: 86 + - compatible 87 + - reg 88 + - gpio-controller 89 + - "#gpio-cells" 90 + - interrupts 91 + - ti,ngpio 92 + - ti,davinci-gpio-unbanked 93 + - clocks 94 + - clock-names 95 + 96 + additionalProperties: false 97 + 98 + examples: 99 + - | 100 + #include<dt-bindings/interrupt-controller/arm-gic.h> 101 + 102 + gpio0: gpio@2603000 { 103 + compatible = "ti,k2g-gpio", "ti,keystone-gpio"; 104 + reg = <0x02603000 0x100>; 105 + gpio-controller; 106 + #gpio-cells = <2>; 107 + interrupts = <GIC_SPI 432 IRQ_TYPE_EDGE_RISING>, 108 + <GIC_SPI 433 IRQ_TYPE_EDGE_RISING>, 109 + <GIC_SPI 434 IRQ_TYPE_EDGE_RISING>, 110 + <GIC_SPI 435 IRQ_TYPE_EDGE_RISING>, 111 + <GIC_SPI 436 IRQ_TYPE_EDGE_RISING>, 112 + <GIC_SPI 437 IRQ_TYPE_EDGE_RISING>, 113 + <GIC_SPI 438 IRQ_TYPE_EDGE_RISING>, 114 + <GIC_SPI 439 IRQ_TYPE_EDGE_RISING>, 115 + <GIC_SPI 440 IRQ_TYPE_EDGE_RISING>; 116 + interrupt-controller; 117 + #interrupt-cells = <2>; 118 + ti,ngpio = <144>; 119 + ti,davinci-gpio-unbanked = <0>; 120 + clocks = <&k2g_clks 0x001b 0x0>; 121 + clock-names = "gpio"; 122 + }; 123 + 124 + - | 125 + #include<dt-bindings/interrupt-controller/arm-gic.h> 126 + 127 + gpio1: gpio@260bf00 { 128 + compatible = "ti,keystone-gpio"; 129 + reg = <0x0260bf00 0x100>; 130 + gpio-controller; 131 + #gpio-cells = <2>; 132 + /* HW Interrupts mapped to GPIO pins */ 133 + interrupts = <GIC_SPI 120 IRQ_TYPE_EDGE_RISING>, 134 + <GIC_SPI 121 IRQ_TYPE_EDGE_RISING>, 135 + <GIC_SPI 122 IRQ_TYPE_EDGE_RISING>, 136 + <GIC_SPI 123 IRQ_TYPE_EDGE_RISING>, 137 + <GIC_SPI 124 IRQ_TYPE_EDGE_RISING>, 138 + <GIC_SPI 125 IRQ_TYPE_EDGE_RISING>, 139 + <GIC_SPI 126 IRQ_TYPE_EDGE_RISING>, 140 + <GIC_SPI 127 IRQ_TYPE_EDGE_RISING>, 141 + <GIC_SPI 128 IRQ_TYPE_EDGE_RISING>, 142 + <GIC_SPI 129 IRQ_TYPE_EDGE_RISING>, 143 + <GIC_SPI 130 IRQ_TYPE_EDGE_RISING>, 144 + <GIC_SPI 131 IRQ_TYPE_EDGE_RISING>, 145 + <GIC_SPI 132 IRQ_TYPE_EDGE_RISING>, 146 + <GIC_SPI 133 IRQ_TYPE_EDGE_RISING>, 147 + <GIC_SPI 134 IRQ_TYPE_EDGE_RISING>, 148 + <GIC_SPI 135 IRQ_TYPE_EDGE_RISING>, 149 + <GIC_SPI 136 IRQ_TYPE_EDGE_RISING>, 150 + <GIC_SPI 137 IRQ_TYPE_EDGE_RISING>, 151 + <GIC_SPI 138 IRQ_TYPE_EDGE_RISING>, 152 + <GIC_SPI 139 IRQ_TYPE_EDGE_RISING>, 153 + <GIC_SPI 140 IRQ_TYPE_EDGE_RISING>, 154 + <GIC_SPI 141 IRQ_TYPE_EDGE_RISING>, 155 + <GIC_SPI 142 IRQ_TYPE_EDGE_RISING>, 156 + <GIC_SPI 143 IRQ_TYPE_EDGE_RISING>, 157 + <GIC_SPI 144 IRQ_TYPE_EDGE_RISING>, 158 + <GIC_SPI 145 IRQ_TYPE_EDGE_RISING>, 159 + <GIC_SPI 146 IRQ_TYPE_EDGE_RISING>, 160 + <GIC_SPI 147 IRQ_TYPE_EDGE_RISING>, 161 + <GIC_SPI 148 IRQ_TYPE_EDGE_RISING>, 162 + <GIC_SPI 149 IRQ_TYPE_EDGE_RISING>, 163 + <GIC_SPI 150 IRQ_TYPE_EDGE_RISING>, 164 + <GIC_SPI 151 IRQ_TYPE_EDGE_RISING>; 165 + clocks = <&clkgpio>; 166 + clock-names = "gpio"; 167 + ti,ngpio = <32>; 168 + ti,davinci-gpio-unbanked = <32>; 169 + }; 170 + 171 + - | 172 + wkup_gpio0: gpio0@42110000 { 173 + compatible = "ti,am654-gpio", "ti,keystone-gpio"; 174 + reg = <0x42110000 0x100>; 175 + gpio-controller; 176 + #gpio-cells = <2>; 177 + interrupt-parent = <&intr_wkup_gpio>; 178 + interrupts = <60>, <61>, <62>, <63>; 179 + interrupt-controller; 180 + #interrupt-cells = <2>; 181 + ti,ngpio = <56>; 182 + ti,davinci-gpio-unbanked = <0>; 183 + clocks = <&k3_clks 59 0>; 184 + clock-names = "gpio"; 185 + };
-45
Documentation/devicetree/bindings/gpio/gpio-omap.txt
··· 1 - OMAP GPIO controller bindings 2 - 3 - Required properties: 4 - - compatible: 5 - - "ti,omap2-gpio" for OMAP2 controllers 6 - - "ti,omap3-gpio" for OMAP3 controllers 7 - - "ti,omap4-gpio" for OMAP4 controllers 8 - - reg : Physical base address of the controller and length of memory mapped 9 - region. 10 - - gpio-controller : Marks the device node as a GPIO controller. 11 - - #gpio-cells : Should be two. 12 - - first cell is the pin number 13 - - second cell is used to specify optional parameters (unused) 14 - - interrupt-controller: Mark the device node as an interrupt controller. 15 - - #interrupt-cells : Should be 2. 16 - The first cell is the GPIO number. 17 - The second cell is used to specify flags: 18 - bits[3:0] trigger type and level flags: 19 - 1 = low-to-high edge triggered. 20 - 2 = high-to-low edge triggered. 21 - 4 = active high level-sensitive. 22 - 8 = active low level-sensitive. 23 - - interrupts : The interrupt the controller is rising as output when an 24 - interrupt occures 25 - 26 - OMAP specific properties: 27 - - ti,hwmods: Name of the hwmod associated to the GPIO: 28 - "gpio<X>", <X> being the 1-based instance number 29 - from the HW spec. 30 - - ti,gpio-always-on: Indicates if a GPIO bank is always powered and 31 - so will never lose its logic state. 32 - 33 - 34 - Example: 35 - 36 - gpio0: gpio@44e07000 { 37 - compatible = "ti,omap4-gpio"; 38 - reg = <0x44e07000 0x1000>; 39 - ti,hwmods = "gpio1"; 40 - gpio-controller; 41 - #gpio-cells = <2>; 42 - interrupt-controller; 43 - #interrupt-cells = <2>; 44 - interrupts = <96>; 45 - };
-69
Documentation/devicetree/bindings/gpio/gpio-pcf857x.txt
··· 1 - * PCF857x-compatible I/O expanders 2 - 3 - The PCF857x-compatible chips have "quasi-bidirectional" I/O lines that can be 4 - driven high by a pull-up current source or driven low to ground. This combines 5 - the direction and output level into a single bit per line, which can't be read 6 - back. We can't actually know at initialization time whether a line is configured 7 - (a) as output and driving the signal low/high, or (b) as input and reporting a 8 - low/high value, without knowing the last value written since the chip came out 9 - of reset (if any). The only reliable solution for setting up line direction is 10 - thus to do it explicitly. 11 - 12 - Required Properties: 13 - 14 - - compatible: should be one of the following. 15 - - "maxim,max7328": For the Maxim MAX7378 16 - - "maxim,max7329": For the Maxim MAX7329 17 - - "nxp,pca8574": For the NXP PCA8574 18 - - "nxp,pca8575": For the NXP PCA8575 19 - - "nxp,pca9670": For the NXP PCA9670 20 - - "nxp,pca9671": For the NXP PCA9671 21 - - "nxp,pca9672": For the NXP PCA9672 22 - - "nxp,pca9673": For the NXP PCA9673 23 - - "nxp,pca9674": For the NXP PCA9674 24 - - "nxp,pca9675": For the NXP PCA9675 25 - - "nxp,pcf8574": For the NXP PCF8574 26 - - "nxp,pcf8574a": For the NXP PCF8574A 27 - - "nxp,pcf8575": For the NXP PCF8575 28 - 29 - - reg: I2C slave address. 30 - 31 - - gpio-controller: Marks the device node as a gpio controller. 32 - - #gpio-cells: Should be 2. The first cell is the GPIO number and the second 33 - cell specifies GPIO flags, as defined in <dt-bindings/gpio/gpio.h>. Only the 34 - GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported. 35 - 36 - Optional Properties: 37 - 38 - - lines-initial-states: Bitmask that specifies the initial state of each 39 - line. When a bit is set to zero, the corresponding line will be initialized to 40 - the input (pulled-up) state. When the bit is set to one, the line will be 41 - initialized the low-level output state. If the property is not specified 42 - all lines will be initialized to the input state. 43 - 44 - The I/O expander can detect input state changes, and thus optionally act as 45 - an interrupt controller. When the expander interrupt line is connected all the 46 - following properties must be set. For more information please see the 47 - interrupt controller device tree bindings documentation available at 48 - Documentation/devicetree/bindings/interrupt-controller/interrupts.txt. 49 - 50 - - interrupt-controller: Identifies the node as an interrupt controller. 51 - - #interrupt-cells: Number of cells to encode an interrupt source, shall be 2. 52 - - interrupts: Interrupt specifier for the controllers interrupt. 53 - 54 - 55 - Please refer to gpio.txt in this directory for details of the common GPIO 56 - bindings used by client devices. 57 - 58 - Example: PCF8575 I/O expander node 59 - 60 - pcf8575: gpio@20 { 61 - compatible = "nxp,pcf8575"; 62 - reg = <0x20>; 63 - interrupt-parent = <&irqpin2>; 64 - interrupts = <3 0>; 65 - gpio-controller; 66 - #gpio-cells = <2>; 67 - interrupt-controller; 68 - #interrupt-cells = <2>; 69 - };
-42
Documentation/devicetree/bindings/gpio/gpio-stp-xway.txt
··· 1 - Lantiq SoC Serial To Parallel (STP) GPIO controller 2 - 3 - The Serial To Parallel (STP) is found on MIPS based Lantiq socs. It is a 4 - peripheral controller used to drive external shift register cascades. At most 5 - 3 groups of 8 bits can be driven. The hardware is able to allow the DSL modem 6 - to drive the 2 LSBs of the cascade automatically. 7 - 8 - 9 - Required properties: 10 - - compatible : Should be "lantiq,gpio-stp-xway" 11 - - reg : Address and length of the register set for the device 12 - - #gpio-cells : Should be two. The first cell is the pin number and 13 - the second cell is used to specify optional parameters (currently 14 - unused). 15 - - gpio-controller : Marks the device node as a gpio controller. 16 - 17 - Optional properties: 18 - - lantiq,shadow : The default value that we shall assume as already set on the 19 - shift register cascade. 20 - - lantiq,groups : Set the 3 bit mask to select which of the 3 groups are enabled 21 - in the shift register cascade. 22 - - lantiq,dsl : The dsl core can control the 2 LSBs of the gpio cascade. This 2 bit 23 - property can enable this feature. 24 - - lantiq,phy1 : The gphy1 core can control 3 bits of the gpio cascade. 25 - - lantiq,phy2 : The gphy2 core can control 3 bits of the gpio cascade. 26 - - lantiq,rising : use rising instead of falling edge for the shift register 27 - 28 - Example: 29 - 30 - gpio1: stp@e100bb0 { 31 - compatible = "lantiq,gpio-stp-xway"; 32 - reg = <0xE100BB0 0x40>; 33 - #gpio-cells = <2>; 34 - gpio-controller; 35 - 36 - lantiq,shadow = <0xffff>; 37 - lantiq,groups = <0x7>; 38 - lantiq,dsl = <0x3>; 39 - lantiq,phy1 = <0x7>; 40 - lantiq,phy2 = <0x7>; 41 - /* lantiq,rising; */ 42 - };
+99
Documentation/devicetree/bindings/gpio/gpio-stp-xway.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/gpio-stp-xway.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Lantiq SoC Serial To Parallel (STP) GPIO controller 8 + 9 + description: | 10 + The Serial To Parallel (STP) is found on MIPS based Lantiq socs. It is a 11 + peripheral controller used to drive external shift register cascades. At most 12 + 3 groups of 8 bits can be driven. The hardware is able to allow the DSL modem 13 + and Ethernet PHYs to drive some bytes of the cascade automatically. 14 + 15 + maintainers: 16 + - John Crispin <john@phrozen.org> 17 + 18 + properties: 19 + $nodename: 20 + pattern: "^gpio@[0-9a-f]+$" 21 + 22 + compatible: 23 + const: lantiq,gpio-stp-xway 24 + 25 + reg: 26 + maxItems: 1 27 + 28 + gpio-controller: true 29 + 30 + "#gpio-cells": 31 + description: 32 + The first cell is the pin number and the second cell is used to specify 33 + consumer flags. 34 + const: 2 35 + 36 + lantiq,shadow: 37 + description: 38 + The default value that we shall assume as already set on the 39 + shift register cascade. 40 + $ref: /schemas/types.yaml#/definitions/uint32 41 + minimum: 0x000000 42 + maximum: 0xffffff 43 + 44 + lantiq,groups: 45 + description: 46 + Set the 3 bit mask to select which of the 3 groups are enabled 47 + in the shift register cascade. 48 + $ref: /schemas/types.yaml#/definitions/uint32 49 + minimum: 0x0 50 + maximum: 0x7 51 + 52 + lantiq,dsl: 53 + description: 54 + The dsl core can control the 2 LSBs of the gpio cascade. This 2 bit 55 + property can enable this feature. 56 + $ref: /schemas/types.yaml#/definitions/uint32 57 + minimum: 0x0 58 + maximum: 0x3 59 + 60 + lantiq,rising: 61 + description: 62 + Use rising instead of falling edge for the shift register. 63 + type: boolean 64 + 65 + patternProperties: 66 + "^lantiq,phy[1-4]$": 67 + description: 68 + The gphy core can control 3 bits of the gpio cascade. In the xRX200 family 69 + phy[1-2] are available, in xRX330 phy[1-3] and in XRX330 phy[1-4]. 70 + $ref: /schemas/types.yaml#/definitions/uint32 71 + minimum: 0x0 72 + maximum: 0x7 73 + 74 + required: 75 + - compatible 76 + - reg 77 + - gpio-controller 78 + - "#gpio-cells" 79 + 80 + additionalProperties: false 81 + 82 + examples: 83 + - | 84 + gpio@e100bb0 { 85 + compatible = "lantiq,gpio-stp-xway"; 86 + reg = <0xE100BB0 0x40>; 87 + #gpio-cells = <2>; 88 + gpio-controller; 89 + 90 + pinctrl-0 = <&stp_pins>; 91 + pinctrl-names = "default"; 92 + 93 + lantiq,shadow = <0xffffff>; 94 + lantiq,groups = <0x7>; 95 + lantiq,dsl = <0x3>; 96 + lantiq,phy1 = <0x7>; 97 + lantiq,phy2 = <0x7>; 98 + }; 99 + ...
-36
Documentation/devicetree/bindings/gpio/gpio-zynq.txt
··· 1 - Xilinx Zynq GPIO controller Device Tree Bindings 2 - ------------------------------------------- 3 - 4 - Required properties: 5 - - #gpio-cells : Should be two 6 - - First cell is the GPIO line number 7 - - Second cell is used to specify optional 8 - parameters (unused) 9 - - compatible : Should be "xlnx,zynq-gpio-1.0" or 10 - "xlnx,zynqmp-gpio-1.0" or "xlnx,versal-gpio-1.0 11 - or "xlnx,pmc-gpio-1.0 12 - - clocks : Clock specifier (see clock bindings for details) 13 - - gpio-controller : Marks the device node as a GPIO controller. 14 - - interrupts : Interrupt specifier (see interrupt bindings for 15 - details) 16 - - interrupt-controller : Marks the device node as an interrupt controller. 17 - - #interrupt-cells : Should be 2. The first cell is the GPIO number. 18 - The second cell bits[3:0] is used to specify trigger type and level flags: 19 - 1 = low-to-high edge triggered. 20 - 2 = high-to-low edge triggered. 21 - 4 = active high level-sensitive. 22 - 8 = active low level-sensitive. 23 - - reg : Address and length of the register set for the device 24 - 25 - Example: 26 - gpio@e000a000 { 27 - #gpio-cells = <2>; 28 - compatible = "xlnx,zynq-gpio-1.0"; 29 - clocks = <&clkc 42>; 30 - gpio-controller; 31 - interrupt-parent = <&intc>; 32 - interrupts = <0 20 4>; 33 - interrupt-controller; 34 - #interrupt-cells = <2>; 35 - reg = <0xe000a000 0x1000>; 36 - };
+59
Documentation/devicetree/bindings/gpio/gpio-zynq.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/gpio-zynq.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Xilinx Zynq GPIO controller Device Tree Bindings 8 + 9 + maintainers: 10 + - Michal Simek <michal.simek@xilinx.com> 11 + 12 + properties: 13 + compatible: 14 + const: xlnx,zynq-gpio-1.0 15 + 16 + reg: 17 + maxItems: 1 18 + 19 + "#gpio-cells": 20 + const: 2 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + gpio-controller: true 26 + 27 + interrupt-controller: true 28 + 29 + "#interrupt-cells": 30 + const: 2 31 + 32 + clocks: 33 + maxItems: 1 34 + 35 + required: 36 + - compatible 37 + - reg 38 + - "#gpio-cells" 39 + - interrupts 40 + - gpio-controller 41 + - interrupt-controller 42 + - "#interrupt-cells" 43 + - clocks 44 + 45 + additionalProperties: false 46 + 47 + examples: 48 + - | 49 + gpio@e000a000 { 50 + #gpio-cells = <2>; 51 + compatible = "xlnx,zynq-gpio-1.0"; 52 + clocks = <&clkc 42>; 53 + gpio-controller; 54 + interrupt-parent = <&intc>; 55 + interrupts = <0 20 4>; 56 + interrupt-controller; 57 + #interrupt-cells = <2>; 58 + reg = <0xe000a000 0x1000>; 59 + };
+67
Documentation/devicetree/bindings/gpio/idt,32434-gpio.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/idt,32434-gpio.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: IDT 79RC32434 GPIO controller 8 + 9 + maintainers: 10 + - Thomas Bogendoerfer <tsbogend@alpha.franken.de> 11 + 12 + properties: 13 + compatible: 14 + const: idt,32434-gpio 15 + 16 + reg: 17 + maxItems: 2 18 + 19 + reg-names: 20 + items: 21 + - const: gpio 22 + - const: pic 23 + 24 + gpio-controller: true 25 + 26 + "#gpio-cells": 27 + const: 2 28 + 29 + ngpios: 30 + minimum: 1 31 + maximum: 32 32 + 33 + interrupt-controller: true 34 + 35 + "#interrupt-cells": 36 + const: 2 37 + 38 + interrupts: 39 + maxItems: 1 40 + 41 + required: 42 + - compatible 43 + - reg 44 + - reg-names 45 + - gpio-controller 46 + - "#gpio-cells" 47 + 48 + additionalProperties: false 49 + 50 + examples: 51 + - | 52 + gpio0: gpio@50004 { 53 + compatible = "idt,32434-gpio"; 54 + reg = <0x50004 0x10>, <0x38030 0x0c>; 55 + reg-names = "gpio", "pic"; 56 + 57 + interrupt-controller; 58 + #interrupt-cells = <2>; 59 + 60 + interrupt-parent = <&cpuintc>; 61 + interrupts = <6>; 62 + 63 + gpio-controller; 64 + #gpio-cells = <2>; 65 + 66 + ngpios = <14>; 67 + };
+103
Documentation/devicetree/bindings/gpio/nxp,pcf8575.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/nxp,pcf8575.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: PCF857x-compatible I/O expanders 8 + 9 + maintainers: 10 + - Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> 11 + 12 + description: 13 + The PCF857x-compatible chips have "quasi-bidirectional" I/O lines that can be 14 + driven high by a pull-up current source or driven low to ground. This 15 + combines the direction and output level into a single bit per line, which 16 + can't be read back. We can't actually know at initialization time whether a 17 + line is configured (a) as output and driving the signal low/high, or (b) as 18 + input and reporting a low/high value, without knowing the last value written 19 + since the chip came out of reset (if any). The only reliable solution for 20 + setting up line direction is thus to do it explicitly. 21 + 22 + properties: 23 + compatible: 24 + enum: 25 + - maxim,max7328 26 + - maxim,max7329 27 + - nxp,pca8574 28 + - nxp,pca8575 29 + - nxp,pca9670 30 + - nxp,pca9671 31 + - nxp,pca9672 32 + - nxp,pca9673 33 + - nxp,pca9674 34 + - nxp,pca9675 35 + - nxp,pcf8574 36 + - nxp,pcf8574a 37 + - nxp,pcf8575 38 + 39 + reg: 40 + maxItems: 1 41 + 42 + gpio-controller: true 43 + 44 + '#gpio-cells': 45 + const: 2 46 + description: 47 + The first cell is the GPIO number and the second cell specifies GPIO 48 + flags, as defined in <dt-bindings/gpio/gpio.h>. Only the GPIO_ACTIVE_HIGH 49 + and GPIO_ACTIVE_LOW flags are supported. 50 + 51 + lines-initial-states: 52 + $ref: /schemas/types.yaml#/definitions/uint32 53 + description: 54 + Bitmask that specifies the initial state of each line. 55 + When a bit is set to zero, the corresponding line will be initialized to 56 + the input (pulled-up) state. 57 + When the bit is set to one, the line will be initialized to the 58 + low-level output state. 59 + If the property is not specified all lines will be initialized to the 60 + input state. 61 + 62 + interrupts: 63 + maxItems: 1 64 + 65 + interrupt-controller: true 66 + 67 + '#interrupt-cells': 68 + const: 2 69 + 70 + wakeup-source: true 71 + 72 + patternProperties: 73 + "^(.+-hog(-[0-9]+)?)$": 74 + type: object 75 + 76 + required: 77 + - gpio-hog 78 + 79 + required: 80 + - compatible 81 + - reg 82 + - gpio-controller 83 + - '#gpio-cells' 84 + 85 + additionalProperties: false 86 + 87 + examples: 88 + - | 89 + i2c { 90 + #address-cells = <1>; 91 + #size-cells = <0>; 92 + 93 + pcf8575: gpio@20 { 94 + compatible = "nxp,pcf8575"; 95 + reg = <0x20>; 96 + interrupt-parent = <&irqpin2>; 97 + interrupts = <3 0>; 98 + gpio-controller; 99 + #gpio-cells = <2>; 100 + interrupt-controller; 101 + #interrupt-cells = <2>; 102 + }; 103 + };
-32
Documentation/devicetree/bindings/gpio/rockchip,rk3328-grf-gpio.txt
··· 1 - Rockchip RK3328 GRF (General Register Files) GPIO controller. 2 - 3 - In Rockchip RK3328, the output only GPIO_MUTE pin, originally for codec mute 4 - control, can also be used for general purpose. It is manipulated by the 5 - GRF_SOC_CON10 register in GRF. Aside from the GPIO_MUTE pin, the HDMI pins can 6 - also be set in the same way. 7 - 8 - Currently this GPIO controller only supports the mute pin. If needed in the 9 - future, the HDMI pins support can also be added. 10 - 11 - Required properties: 12 - - compatible: Should contain "rockchip,rk3328-grf-gpio". 13 - - gpio-controller: Marks the device node as a gpio controller. 14 - - #gpio-cells: Should be 2. The first cell is the pin number and 15 - the second cell is used to specify the gpio polarity: 16 - 0 = Active high, 17 - 1 = Active low. 18 - 19 - Example: 20 - 21 - grf: syscon@ff100000 { 22 - compatible = "rockchip,rk3328-grf", "syscon", "simple-mfd"; 23 - 24 - grf_gpio: grf-gpio { 25 - compatible = "rockchip,rk3328-grf-gpio"; 26 - gpio-controller; 27 - #gpio-cells = <2>; 28 - }; 29 - }; 30 - 31 - Note: The grf_gpio node should be declared as the child of the GRF (General 32 - Register File) node. The GPIO_MUTE pin is referred to as <&grf_gpio 0>.
+50
Documentation/devicetree/bindings/gpio/rockchip,rk3328-grf-gpio.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/rockchip,rk3328-grf-gpio.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Rockchip RK3328 General Register Files GPIO controller 8 + 9 + description: 10 + The Rockchip RK3328 General Register File (GRF) outputs only the 11 + GPIO_MUTE pin, originally for codec mute control, but it can also be used 12 + for general purpose. It is manipulated by the GRF_SOC_CON10 register. 13 + If needed in the future support for the HDMI pins can also be added. 14 + The GPIO node should be declared as the child of the GRF node. 15 + 16 + The GPIO_MUTE pin is referred to in the format 17 + 18 + <&grf_gpio 0 GPIO_ACTIVE_LOW> 19 + 20 + The first cell is the pin number and 21 + the second cell is used to specify the GPIO polarity 22 + 0 = Active high 23 + 1 = Active low 24 + 25 + maintainers: 26 + - Heiko Stuebner <heiko@sntech.de> 27 + 28 + properties: 29 + compatible: 30 + const: rockchip,rk3328-grf-gpio 31 + 32 + gpio-controller: true 33 + 34 + "#gpio-cells": 35 + const: 2 36 + 37 + required: 38 + - compatible 39 + - gpio-controller 40 + - "#gpio-cells" 41 + 42 + additionalProperties: false 43 + 44 + examples: 45 + - | 46 + grf_gpio: gpio { 47 + compatible = "rockchip,rk3328-grf-gpio"; 48 + gpio-controller; 49 + #gpio-cells = <2>; 50 + };
+108
Documentation/devicetree/bindings/gpio/ti,omap-gpio.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/ti,omap-gpio.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: OMAP GPIO controller bindings 8 + 9 + maintainers: 10 + - Grygorii Strashko <grygorii.strashko@ti.com> 11 + 12 + description: | 13 + The general-purpose interface combines general-purpose input/output (GPIO) banks. 14 + Each GPIO banks provides up to 32 dedicated general-purpose pins with input 15 + and output capabilities; interrupt generation in active mode and wake-up 16 + request generation in idle mode upon the detection of external events. 17 + 18 + properties: 19 + compatible: 20 + oneOf: 21 + - enum: 22 + - ti,omap2-gpio 23 + - ti,omap3-gpio 24 + - ti,omap4-gpio 25 + - items: 26 + - const: ti,am4372-gpio 27 + - const: ti,omap4-gpio 28 + 29 + reg: 30 + maxItems: 1 31 + 32 + gpio-controller: true 33 + 34 + '#gpio-cells': 35 + const: 2 36 + 37 + interrupt-controller: true 38 + 39 + '#interrupt-cells': 40 + const: 2 41 + 42 + interrupts: 43 + maxItems: 1 44 + 45 + gpio-ranges: true 46 + 47 + gpio-line-names: 48 + minItems: 1 49 + maxItems: 32 50 + 51 + ti,gpio-always-on: 52 + $ref: /schemas/types.yaml#/definitions/flag 53 + description: 54 + Indicates if a GPIO bank is always powered and will never lose its logic state. 55 + 56 + ti,hwmods: 57 + $ref: /schemas/types.yaml#/definitions/string 58 + deprecated: true 59 + description: 60 + Name of the hwmod associated with the GPIO. Needed on some legacy OMAP 61 + SoCs which have not been converted to the ti,sysc interconnect hierarachy. 62 + 63 + ti,no-reset-on-init: 64 + $ref: /schemas/types.yaml#/definitions/flag 65 + deprecated: true 66 + description: 67 + Do not reset on init. Used with ti,hwmods on some legacy OMAP SoCs which 68 + have not been converted to the ti,sysc interconnect hierarachy. 69 + 70 + patternProperties: 71 + "^(.+-hog(-[0-9]+)?)$": 72 + type: object 73 + 74 + required: 75 + - gpio-hog 76 + 77 + required: 78 + - compatible 79 + - reg 80 + - gpio-controller 81 + - "#gpio-cells" 82 + - interrupt-controller 83 + - "#interrupt-cells" 84 + - interrupts 85 + 86 + additionalProperties: false 87 + 88 + examples: 89 + - | 90 + #include <dt-bindings/gpio/gpio.h> 91 + 92 + gpio0: gpio@0 { 93 + compatible = "ti,omap4-gpio"; 94 + reg = <0x0 0x1000>; 95 + gpio-controller; 96 + #gpio-cells = <2>; 97 + interrupt-controller; 98 + #interrupt-cells = <2>; 99 + interrupts = <96>; 100 + ti,gpio-always-on; 101 + 102 + ls-buf-en-hog { 103 + gpio-hog; 104 + gpios = <10 GPIO_ACTIVE_HIGH>; 105 + output-high; 106 + line-name = "LS_BUF_EN"; 107 + }; 108 + };
+2 -2
MAINTAINERS
··· 13471 13471 M: Kevin Hilman <khilman@kernel.org> 13472 13472 L: linux-omap@vger.kernel.org 13473 13473 S: Maintained 13474 - F: Documentation/devicetree/bindings/gpio/gpio-omap.txt 13474 + F: Documentation/devicetree/bindings/gpio/ti,omap-gpio.yaml 13475 13475 F: drivers/gpio/gpio-omap.c 13476 13476 13477 13477 OMAP HARDWARE SPINLOCK SUPPORT ··· 18448 18448 M: Keerthy <j-keerthy@ti.com> 18449 18449 L: linux-gpio@vger.kernel.org 18450 18450 S: Maintained 18451 - F: Documentation/devicetree/bindings/gpio/gpio-davinci.txt 18451 + F: Documentation/devicetree/bindings/gpio/gpio-davinci.yaml 18452 18452 F: drivers/gpio/gpio-davinci.c 18453 18453 18454 18454 TI DAVINCI SERIES MEDIA DRIVER
+12
drivers/gpio/Kconfig
··· 782 782 Say Y here to support the main GPIO block on MStar/SigmaStar 783 783 ARMv7 based SoCs. 784 784 785 + config GPIO_IDT3243X 786 + tristate "IDT 79RC3243X GPIO support" 787 + depends on MIKROTIK_RB532 || COMPILE_TEST 788 + select GPIO_GENERIC 789 + select GPIOLIB_IRQCHIP 790 + help 791 + Select this option to enable GPIO driver for 792 + IDT 79RC3243X based devices like Mikrotik RB532. 793 + 794 + To compile this driver as a module, choose M here: the module will 795 + be called gpio-idt3243x. 796 + 785 797 endmenu 786 798 787 799 menu "Port-mapped I/O GPIO drivers"
+1
drivers/gpio/Makefile
··· 68 68 obj-$(CONFIG_GPIO_HLWD) += gpio-hlwd.o 69 69 obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o 70 70 obj-$(CONFIG_GPIO_ICH) += gpio-ich.o 71 + obj-$(CONFIG_GPIO_IDT3243X) += gpio-idt3243x.o 71 72 obj-$(CONFIG_GPIO_IOP) += gpio-iop.o 72 73 obj-$(CONFIG_GPIO_IT87) += gpio-it87.o 73 74 obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4xx.o
+13 -10
drivers/gpio/gpio-104-idio-16.c
··· 44 44 struct gpio_chip chip; 45 45 raw_spinlock_t lock; 46 46 unsigned long irq_mask; 47 - unsigned base; 48 - unsigned out_state; 47 + unsigned int base; 48 + unsigned int out_state; 49 49 }; 50 50 51 - static int idio_16_gpio_get_direction(struct gpio_chip *chip, unsigned offset) 51 + static int idio_16_gpio_get_direction(struct gpio_chip *chip, 52 + unsigned int offset) 52 53 { 53 54 if (offset > 15) 54 55 return GPIO_LINE_DIRECTION_IN; ··· 57 56 return GPIO_LINE_DIRECTION_OUT; 58 57 } 59 58 60 - static int idio_16_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 59 + static int idio_16_gpio_direction_input(struct gpio_chip *chip, 60 + unsigned int offset) 61 61 { 62 62 return 0; 63 63 } 64 64 65 65 static int idio_16_gpio_direction_output(struct gpio_chip *chip, 66 - unsigned offset, int value) 66 + unsigned int offset, int value) 67 67 { 68 68 chip->set(chip, offset, value); 69 69 return 0; 70 70 } 71 71 72 - static int idio_16_gpio_get(struct gpio_chip *chip, unsigned offset) 72 + static int idio_16_gpio_get(struct gpio_chip *chip, unsigned int offset) 73 73 { 74 74 struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); 75 - const unsigned mask = BIT(offset-16); 75 + const unsigned int mask = BIT(offset-16); 76 76 77 77 if (offset < 16) 78 78 return -EINVAL; ··· 98 96 return 0; 99 97 } 100 98 101 - static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 99 + static void idio_16_gpio_set(struct gpio_chip *chip, unsigned int offset, 100 + int value) 102 101 { 103 102 struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); 104 - const unsigned mask = BIT(offset); 103 + const unsigned int mask = BIT(offset); 105 104 unsigned long flags; 106 105 107 106 if (offset > 15) ··· 183 180 } 184 181 } 185 182 186 - static int idio_16_irq_set_type(struct irq_data *data, unsigned flow_type) 183 + static int idio_16_irq_set_type(struct irq_data *data, unsigned int flow_type) 187 184 { 188 185 /* The only valid irq types are none and both-edges */ 189 186 if (flow_type != IRQ_TYPE_NONE &&
+4 -14
drivers/gpio/gpio-adp5520.c
··· 113 113 if (pdata->gpio_en_mask & (1 << i)) 114 114 dev->lut[gpios++] = 1 << i; 115 115 116 - if (gpios < 1) { 117 - ret = -EINVAL; 118 - goto err; 119 - } 116 + if (gpios < 1) 117 + return -EINVAL; 120 118 121 119 gc = &dev->gpio_chip; 122 120 gc->direction_input = adp5520_gpio_direction_input; ··· 146 148 147 149 if (ret) { 148 150 dev_err(&pdev->dev, "failed to write\n"); 149 - goto err; 151 + return ret; 150 152 } 151 153 152 - ret = devm_gpiochip_add_data(&pdev->dev, &dev->gpio_chip, dev); 153 - if (ret) 154 - goto err; 155 - 156 - platform_set_drvdata(pdev, dev); 157 - return 0; 158 - 159 - err: 160 - return ret; 154 + return devm_gpiochip_add_data(&pdev->dev, &dev->gpio_chip, dev); 161 155 } 162 156 163 157 static struct platform_driver adp5520_gpio_driver = {
+1 -10
drivers/gpio/gpio-altera-a10sr.c
··· 78 78 static int altr_a10sr_gpio_probe(struct platform_device *pdev) 79 79 { 80 80 struct altr_a10sr_gpio *gpio; 81 - int ret; 82 81 struct altr_a10sr *a10sr = dev_get_drvdata(pdev->dev.parent); 83 82 84 83 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); ··· 90 91 gpio->gp.parent = pdev->dev.parent; 91 92 gpio->gp.of_node = pdev->dev.of_node; 92 93 93 - ret = devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio); 94 - if (ret < 0) { 95 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 96 - return ret; 97 - } 98 - 99 - platform_set_drvdata(pdev, gpio); 100 - 101 - return 0; 94 + return devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio); 102 95 } 103 96 104 97 static const struct of_device_id altr_a10sr_gpio_of_match[] = {
+1 -8
drivers/gpio/gpio-ath79.c
··· 234 234 ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL); 235 235 if (!ctrl) 236 236 return -ENOMEM; 237 - platform_set_drvdata(pdev, ctrl); 238 237 239 238 if (np) { 240 239 err = of_property_read_u32(np, "ngpios", &ath79_gpio_count); ··· 289 290 girq->handler = handle_simple_irq; 290 291 } 291 292 292 - err = devm_gpiochip_add_data(dev, &ctrl->gc, ctrl); 293 - if (err) { 294 - dev_err(dev, 295 - "cannot add AR71xx GPIO chip, error=%d", err); 296 - return err; 297 - } 298 - return 0; 293 + return devm_gpiochip_add_data(dev, &ctrl->gc, ctrl); 299 294 } 300 295 301 296 static struct platform_driver ath79_gpio_driver = {
+1 -10
drivers/gpio/gpio-bd9571mwv.c
··· 97 97 static int bd9571mwv_gpio_probe(struct platform_device *pdev) 98 98 { 99 99 struct bd9571mwv_gpio *gpio; 100 - int ret; 101 100 102 101 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 103 102 if (!gpio) 104 103 return -ENOMEM; 105 104 106 - platform_set_drvdata(pdev, gpio); 107 - 108 105 gpio->regmap = dev_get_regmap(pdev->dev.parent, NULL); 109 106 gpio->chip = template_chip; 110 107 gpio->chip.parent = pdev->dev.parent; 111 108 112 - ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); 113 - if (ret < 0) { 114 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 115 - return ret; 116 - } 117 - 118 - return 0; 109 + return devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); 119 110 } 120 111 121 112 static const struct platform_device_id bd9571mwv_gpio_id_table[] = {
+1 -10
drivers/gpio/gpio-da9052.c
··· 196 196 { 197 197 struct da9052_gpio *gpio; 198 198 struct da9052_pdata *pdata; 199 - int ret; 200 199 201 200 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 202 201 if (!gpio) ··· 208 209 if (pdata && pdata->gpio_base) 209 210 gpio->gp.base = pdata->gpio_base; 210 211 211 - ret = devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio); 212 - if (ret < 0) { 213 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 214 - return ret; 215 - } 216 - 217 - platform_set_drvdata(pdev, gpio); 218 - 219 - return 0; 212 + return devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio); 220 213 } 221 214 222 215 static struct platform_driver da9052_gpio_driver = {
+1 -10
drivers/gpio/gpio-da9055.c
··· 133 133 { 134 134 struct da9055_gpio *gpio; 135 135 struct da9055_pdata *pdata; 136 - int ret; 137 136 138 137 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 139 138 if (!gpio) ··· 145 146 if (pdata && pdata->gpio_base) 146 147 gpio->gp.base = pdata->gpio_base; 147 148 148 - ret = devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio); 149 - if (ret < 0) { 150 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 151 - return ret; 152 - } 153 - 154 - platform_set_drvdata(pdev, gpio); 155 - 156 - return 0; 149 + return devm_gpiochip_add_data(&pdev->dev, &gpio->gp, gpio); 157 150 } 158 151 159 152 static struct platform_driver da9055_gpio_driver = {
+7 -16
drivers/gpio/gpio-dwapb.c
··· 13 13 #include <linux/io.h> 14 14 #include <linux/ioport.h> 15 15 #include <linux/irq.h> 16 + #include <linux/mod_devicetable.h> 16 17 #include <linux/module.h> 17 18 #include <linux/of.h> 18 - #include <linux/of_address.h> 19 - #include <linux/of_device.h> 20 - #include <linux/of_irq.h> 19 + #include <linux/platform_data/gpio-dwapb.h> 21 20 #include <linux/platform_device.h> 22 21 #include <linux/property.h> 23 22 #include <linux/reset.h> 24 - #include <linux/spinlock.h> 25 - #include <linux/platform_data/gpio-dwapb.h> 26 23 #include <linux/slab.h> 24 + #include <linux/spinlock.h> 27 25 28 26 #include "gpiolib.h" 29 27 #include "gpiolib-acpi.h" ··· 295 297 irq_hw_number_t bit = irqd_to_hwirq(d); 296 298 unsigned long level, polarity, flags; 297 299 298 - if (type & ~IRQ_TYPE_SENSE_MASK) 299 - return -EINVAL; 300 - 301 300 spin_lock_irqsave(&gc->bgpio_lock, flags); 302 301 level = dwapb_read(gpio, GPIO_INTTYPE_LEVEL); 303 302 polarity = dwapb_read(gpio, GPIO_INT_POLARITY); ··· 526 531 static void dwapb_get_irq(struct device *dev, struct fwnode_handle *fwnode, 527 532 struct dwapb_port_property *pp) 528 533 { 529 - struct device_node *np = NULL; 530 - int irq = -ENXIO, j; 531 - 532 - if (fwnode_property_read_bool(fwnode, "interrupt-controller")) 533 - np = to_of_node(fwnode); 534 + int irq, j; 534 535 535 536 for (j = 0; j < pp->ngpio; j++) { 536 - if (np) 537 - irq = of_irq_get(np, j); 538 - else if (has_acpi_companion(dev)) 537 + if (has_acpi_companion(dev)) 539 538 irq = platform_get_irq_optional(to_platform_device(dev), j); 539 + else 540 + irq = fwnode_irq_get(fwnode, j); 540 541 if (irq > 0) 541 542 pp->irq[j] = irq; 542 543 }
+206
drivers/gpio/gpio-idt3243x.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Driver for IDT/Renesas 79RC3243x Interrupt Controller */ 3 + 4 + #include <linux/bitops.h> 5 + #include <linux/gpio/driver.h> 6 + #include <linux/irq.h> 7 + #include <linux/module.h> 8 + #include <linux/mod_devicetable.h> 9 + #include <linux/platform_device.h> 10 + #include <linux/spinlock.h> 11 + 12 + #define IDT_PIC_IRQ_PEND 0x00 13 + #define IDT_PIC_IRQ_MASK 0x08 14 + 15 + #define IDT_GPIO_DIR 0x00 16 + #define IDT_GPIO_DATA 0x04 17 + #define IDT_GPIO_ILEVEL 0x08 18 + #define IDT_GPIO_ISTAT 0x0C 19 + 20 + struct idt_gpio_ctrl { 21 + struct gpio_chip gc; 22 + void __iomem *pic; 23 + void __iomem *gpio; 24 + u32 mask_cache; 25 + }; 26 + 27 + static void idt_gpio_dispatch(struct irq_desc *desc) 28 + { 29 + struct gpio_chip *gc = irq_desc_get_handler_data(desc); 30 + struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); 31 + struct irq_chip *host_chip = irq_desc_get_chip(desc); 32 + unsigned int bit, virq; 33 + unsigned long pending; 34 + 35 + chained_irq_enter(host_chip, desc); 36 + 37 + pending = readl(ctrl->pic + IDT_PIC_IRQ_PEND); 38 + pending &= ~ctrl->mask_cache; 39 + for_each_set_bit(bit, &pending, gc->ngpio) { 40 + virq = irq_linear_revmap(gc->irq.domain, bit); 41 + if (virq) 42 + generic_handle_irq(virq); 43 + } 44 + 45 + chained_irq_exit(host_chip, desc); 46 + } 47 + 48 + static int idt_gpio_irq_set_type(struct irq_data *d, unsigned int flow_type) 49 + { 50 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 51 + struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); 52 + unsigned int sense = flow_type & IRQ_TYPE_SENSE_MASK; 53 + unsigned long flags; 54 + u32 ilevel; 55 + 56 + /* hardware only supports level triggered */ 57 + if (sense == IRQ_TYPE_NONE || (sense & IRQ_TYPE_EDGE_BOTH)) 58 + return -EINVAL; 59 + 60 + spin_lock_irqsave(&gc->bgpio_lock, flags); 61 + 62 + ilevel = readl(ctrl->gpio + IDT_GPIO_ILEVEL); 63 + if (sense & IRQ_TYPE_LEVEL_HIGH) 64 + ilevel |= BIT(d->hwirq); 65 + else if (sense & IRQ_TYPE_LEVEL_LOW) 66 + ilevel &= ~BIT(d->hwirq); 67 + 68 + writel(ilevel, ctrl->gpio + IDT_GPIO_ILEVEL); 69 + irq_set_handler_locked(d, handle_level_irq); 70 + 71 + spin_unlock_irqrestore(&gc->bgpio_lock, flags); 72 + return 0; 73 + } 74 + 75 + static void idt_gpio_ack(struct irq_data *d) 76 + { 77 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 78 + struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); 79 + 80 + writel(~BIT(d->hwirq), ctrl->gpio + IDT_GPIO_ISTAT); 81 + } 82 + 83 + static void idt_gpio_mask(struct irq_data *d) 84 + { 85 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 86 + struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); 87 + unsigned long flags; 88 + 89 + spin_lock_irqsave(&gc->bgpio_lock, flags); 90 + 91 + ctrl->mask_cache |= BIT(d->hwirq); 92 + writel(ctrl->mask_cache, ctrl->pic + IDT_PIC_IRQ_MASK); 93 + 94 + spin_unlock_irqrestore(&gc->bgpio_lock, flags); 95 + } 96 + 97 + static void idt_gpio_unmask(struct irq_data *d) 98 + { 99 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 100 + struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); 101 + unsigned long flags; 102 + 103 + spin_lock_irqsave(&gc->bgpio_lock, flags); 104 + 105 + ctrl->mask_cache &= ~BIT(d->hwirq); 106 + writel(ctrl->mask_cache, ctrl->pic + IDT_PIC_IRQ_MASK); 107 + 108 + spin_unlock_irqrestore(&gc->bgpio_lock, flags); 109 + } 110 + 111 + static int idt_gpio_irq_init_hw(struct gpio_chip *gc) 112 + { 113 + struct idt_gpio_ctrl *ctrl = gpiochip_get_data(gc); 114 + 115 + /* Mask interrupts. */ 116 + ctrl->mask_cache = 0xffffffff; 117 + writel(ctrl->mask_cache, ctrl->pic + IDT_PIC_IRQ_MASK); 118 + 119 + return 0; 120 + } 121 + 122 + static struct irq_chip idt_gpio_irqchip = { 123 + .name = "IDTGPIO", 124 + .irq_mask = idt_gpio_mask, 125 + .irq_ack = idt_gpio_ack, 126 + .irq_unmask = idt_gpio_unmask, 127 + .irq_set_type = idt_gpio_irq_set_type 128 + }; 129 + 130 + static int idt_gpio_probe(struct platform_device *pdev) 131 + { 132 + struct device *dev = &pdev->dev; 133 + struct gpio_irq_chip *girq; 134 + struct idt_gpio_ctrl *ctrl; 135 + unsigned int parent_irq; 136 + int ngpios; 137 + int ret; 138 + 139 + 140 + ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL); 141 + if (!ctrl) 142 + return -ENOMEM; 143 + 144 + ctrl->gpio = devm_platform_ioremap_resource_byname(pdev, "gpio"); 145 + if (IS_ERR(ctrl->gpio)) 146 + return PTR_ERR(ctrl->gpio); 147 + 148 + ctrl->gc.parent = dev; 149 + 150 + ret = bgpio_init(&ctrl->gc, &pdev->dev, 4, ctrl->gpio + IDT_GPIO_DATA, 151 + NULL, NULL, ctrl->gpio + IDT_GPIO_DIR, NULL, 0); 152 + if (ret) { 153 + dev_err(dev, "bgpio_init failed\n"); 154 + return ret; 155 + } 156 + 157 + ret = device_property_read_u32(dev, "ngpios", &ngpios); 158 + if (!ret) 159 + ctrl->gc.ngpio = ngpios; 160 + 161 + if (device_property_read_bool(dev, "interrupt-controller")) { 162 + ctrl->pic = devm_platform_ioremap_resource_byname(pdev, "pic"); 163 + if (IS_ERR(ctrl->pic)) 164 + return PTR_ERR(ctrl->pic); 165 + 166 + parent_irq = platform_get_irq(pdev, 0); 167 + if (!parent_irq) 168 + return -EINVAL; 169 + 170 + girq = &ctrl->gc.irq; 171 + girq->chip = &idt_gpio_irqchip; 172 + girq->init_hw = idt_gpio_irq_init_hw; 173 + girq->parent_handler = idt_gpio_dispatch; 174 + girq->num_parents = 1; 175 + girq->parents = devm_kcalloc(dev, girq->num_parents, 176 + sizeof(*girq->parents), 177 + GFP_KERNEL); 178 + if (!girq->parents) 179 + return -ENOMEM; 180 + 181 + girq->parents[0] = parent_irq; 182 + girq->default_type = IRQ_TYPE_NONE; 183 + girq->handler = handle_bad_irq; 184 + } 185 + 186 + return devm_gpiochip_add_data(&pdev->dev, &ctrl->gc, ctrl); 187 + } 188 + 189 + static const struct of_device_id idt_gpio_of_match[] = { 190 + { .compatible = "idt,32434-gpio" }, 191 + { } 192 + }; 193 + MODULE_DEVICE_TABLE(of, idt_gpio_of_match); 194 + 195 + static struct platform_driver idt_gpio_driver = { 196 + .probe = idt_gpio_probe, 197 + .driver = { 198 + .name = "idt3243x-gpio", 199 + .of_match_table = idt_gpio_of_match, 200 + }, 201 + }; 202 + module_platform_driver(idt_gpio_driver); 203 + 204 + MODULE_DESCRIPTION("IDT 79RC3243x GPIO/PIC Driver"); 205 + MODULE_AUTHOR("Thomas Bogendoerfer <tsbogend@alpha.franken.de>"); 206 + MODULE_LICENSE("GPL");
+1 -3
drivers/gpio/gpio-logicvc.c
··· 114 114 } 115 115 116 116 base = devm_ioremap_resource(dev, &res); 117 - if (IS_ERR(base)) { 118 - dev_err(dev, "Failed to map I/O base\n"); 117 + if (IS_ERR(base)) 119 118 return PTR_ERR(base); 120 - } 121 119 122 120 logicvc_gpio_regmap_config.max_register = resource_size(&res) - 123 121 logicvc_gpio_regmap_config.reg_stride;
+3 -6
drivers/gpio/gpio-mockup.c
··· 144 144 static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip, 145 145 unsigned int offset, int value) 146 146 { 147 + struct gpio_chip *gc = &chip->gc; 148 + struct gpio_desc *desc = gpiochip_get_desc(gc, offset); 147 149 int curr, irq, irq_type, ret = 0; 148 - struct gpio_desc *desc; 149 - struct gpio_chip *gc; 150 - 151 - gc = &chip->gc; 152 - desc = &gc->gpiodev->descs[offset]; 153 150 154 151 mutex_lock(&chip->lock); 155 152 ··· 366 369 367 370 priv->chip = chip; 368 371 priv->offset = i; 369 - priv->desc = &gc->gpiodev->descs[i]; 372 + priv->desc = gpiochip_get_desc(gc, i); 370 373 371 374 debugfs_create_file(name, 0200, chip->dbg_dir, priv, 372 375 &gpio_mockup_debugfs_ops);
+2 -2
drivers/gpio/gpio-mxs.c
··· 229 229 return rv; 230 230 } 231 231 232 - static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset) 232 + static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned int offset) 233 233 { 234 234 struct mxs_gpio_port *port = gpiochip_get_data(gc); 235 235 236 236 return irq_find_mapping(port->domain, offset); 237 237 } 238 238 239 - static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned offset) 239 + static int mxs_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) 240 240 { 241 241 struct mxs_gpio_port *port = gpiochip_get_data(gc); 242 242 u32 mask = 1 << offset;
+1
drivers/gpio/gpio-pca953x.c
··· 1241 1241 1242 1242 { .compatible = "onnn,cat9554", .data = OF_953X( 8, PCA_INT), }, 1243 1243 { .compatible = "onnn,pca9654", .data = OF_953X( 8, PCA_INT), }, 1244 + { .compatible = "onnn,pca9655", .data = OF_953X(16, PCA_INT), }, 1244 1245 1245 1246 { .compatible = "exar,xra1202", .data = OF_953X( 8, 0), }, 1246 1247 { }
+12 -20
drivers/gpio/gpio-regmap.c
··· 178 178 return gpio_regmap_set_direction(chip, offset, true); 179 179 } 180 180 181 - void gpio_regmap_set_drvdata(struct gpio_regmap *gpio, void *data) 182 - { 183 - gpio->driver_data = data; 184 - } 185 - EXPORT_SYMBOL_GPL(gpio_regmap_set_drvdata); 186 - 187 181 void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio) 188 182 { 189 183 return gpio->driver_data; ··· 220 226 return ERR_PTR(-ENOMEM); 221 227 222 228 gpio->parent = config->parent; 229 + gpio->driver_data = config->drvdata; 223 230 gpio->regmap = config->regmap; 224 231 gpio->ngpio_per_reg = config->ngpio_per_reg; 225 232 gpio->reg_stride = config->reg_stride; ··· 306 311 } 307 312 EXPORT_SYMBOL_GPL(gpio_regmap_unregister); 308 313 309 - static void devm_gpio_regmap_unregister(struct device *dev, void *res) 314 + static void devm_gpio_regmap_unregister(void *res) 310 315 { 311 - gpio_regmap_unregister(*(struct gpio_regmap **)res); 316 + gpio_regmap_unregister(res); 312 317 } 313 318 314 319 /** ··· 325 330 struct gpio_regmap *devm_gpio_regmap_register(struct device *dev, 326 331 const struct gpio_regmap_config *config) 327 332 { 328 - struct gpio_regmap **ptr, *gpio; 329 - 330 - ptr = devres_alloc(devm_gpio_regmap_unregister, sizeof(*ptr), 331 - GFP_KERNEL); 332 - if (!ptr) 333 - return ERR_PTR(-ENOMEM); 333 + struct gpio_regmap *gpio; 334 + int ret; 334 335 335 336 gpio = gpio_regmap_register(config); 336 - if (!IS_ERR(gpio)) { 337 - *ptr = gpio; 338 - devres_add(dev, ptr); 339 - } else { 340 - devres_free(ptr); 341 - } 337 + 338 + if (IS_ERR(gpio)) 339 + return gpio; 340 + 341 + ret = devm_add_action_or_reset(dev, devm_gpio_regmap_unregister, gpio); 342 + if (ret) 343 + return ERR_PTR(ret); 342 344 343 345 return gpio; 344 346 }
+1 -11
drivers/gpio/gpio-spear-spics.c
··· 122 122 { 123 123 struct device_node *np = pdev->dev.of_node; 124 124 struct spear_spics *spics; 125 - int ret; 126 125 127 126 spics = devm_kzalloc(&pdev->dev, sizeof(*spics), GFP_KERNEL); 128 127 if (!spics) ··· 147 148 &spics->cs_enable_shift)) 148 149 goto err_dt_data; 149 150 150 - platform_set_drvdata(pdev, spics); 151 - 152 151 spics->chip.ngpio = NUM_OF_GPIO; 153 152 spics->chip.base = -1; 154 153 spics->chip.request = spics_request; ··· 160 163 spics->chip.owner = THIS_MODULE; 161 164 spics->last_off = -1; 162 165 163 - ret = devm_gpiochip_add_data(&pdev->dev, &spics->chip, spics); 164 - if (ret) { 165 - dev_err(&pdev->dev, "unable to add gpio chip\n"); 166 - return ret; 167 - } 168 - 169 - dev_info(&pdev->dev, "spear spics registered\n"); 170 - return 0; 166 + return devm_gpiochip_add_data(&pdev->dev, &spics->chip, spics); 171 167 172 168 err_dt_data: 173 169 dev_err(&pdev->dev, "DT probe failed\n");
+1 -9
drivers/gpio/gpio-sprd.c
··· 222 222 { 223 223 struct gpio_irq_chip *irq; 224 224 struct sprd_gpio *sprd_gpio; 225 - int ret; 226 225 227 226 sprd_gpio = devm_kzalloc(&pdev->dev, sizeof(*sprd_gpio), GFP_KERNEL); 228 227 if (!sprd_gpio) ··· 258 259 irq->num_parents = 1; 259 260 irq->parents = &sprd_gpio->irq; 260 261 261 - ret = devm_gpiochip_add_data(&pdev->dev, &sprd_gpio->chip, sprd_gpio); 262 - if (ret < 0) { 263 - dev_err(&pdev->dev, "Could not register gpiochip %d\n", ret); 264 - return ret; 265 - } 266 - 267 - platform_set_drvdata(pdev, sprd_gpio); 268 - return 0; 262 + return devm_gpiochip_add_data(&pdev->dev, &sprd_gpio->chip, sprd_gpio); 269 263 } 270 264 271 265 static const struct of_device_id sprd_gpio_of_match[] = {
+1 -9
drivers/gpio/gpio-sta2x11.c
··· 398 398 return err; 399 399 } 400 400 401 - err = devm_gpiochip_add_data(&dev->dev, &chip->gpio, chip); 402 - if (err < 0) { 403 - dev_err(&dev->dev, "sta2x11 gpio: Can't register (%i)\n", 404 - -err); 405 - return err; 406 - } 407 - 408 - platform_set_drvdata(dev, chip); 409 - return 0; 401 + return devm_gpiochip_add_data(&dev->dev, &chip->gpio, chip); 410 402 } 411 403 412 404 static struct platform_driver sta2x11_gpio_platform_driver = {
+13 -19
drivers/gpio/gpio-stmpe.c
··· 449 449 } 450 450 } 451 451 452 + static void stmpe_gpio_disable(void *stmpe) 453 + { 454 + stmpe_disable(stmpe, STMPE_BLOCK_GPIO); 455 + } 456 + 452 457 static int stmpe_gpio_probe(struct platform_device *pdev) 453 458 { 454 459 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); ··· 466 461 return -EINVAL; 467 462 } 468 463 469 - stmpe_gpio = kzalloc(sizeof(*stmpe_gpio), GFP_KERNEL); 464 + stmpe_gpio = devm_kzalloc(&pdev->dev, sizeof(*stmpe_gpio), GFP_KERNEL); 470 465 if (!stmpe_gpio) 471 466 return -ENOMEM; 472 467 ··· 494 489 495 490 ret = stmpe_enable(stmpe, STMPE_BLOCK_GPIO); 496 491 if (ret) 497 - goto out_free; 492 + return ret; 493 + 494 + ret = devm_add_action_or_reset(&pdev->dev, stmpe_gpio_disable, stmpe); 495 + if (ret) 496 + return ret; 498 497 499 498 if (irq > 0) { 500 499 struct gpio_irq_chip *girq; ··· 508 499 "stmpe-gpio", stmpe_gpio); 509 500 if (ret) { 510 501 dev_err(&pdev->dev, "unable to get irq: %d\n", ret); 511 - goto out_disable; 502 + return ret; 512 503 } 513 504 514 505 girq = &stmpe_gpio->chip.irq; ··· 523 514 girq->init_valid_mask = stmpe_init_irq_valid_mask; 524 515 } 525 516 526 - ret = gpiochip_add_data(&stmpe_gpio->chip, stmpe_gpio); 527 - if (ret) { 528 - dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); 529 - goto out_disable; 530 - } 531 - 532 - platform_set_drvdata(pdev, stmpe_gpio); 533 - 534 - return 0; 535 - 536 - out_disable: 537 - stmpe_disable(stmpe, STMPE_BLOCK_GPIO); 538 - gpiochip_remove(&stmpe_gpio->chip); 539 - out_free: 540 - kfree(stmpe_gpio); 541 - return ret; 517 + return devm_gpiochip_add_data(&pdev->dev, &stmpe_gpio->chip, stmpe_gpio); 542 518 } 543 519 544 520 static struct platform_driver stmpe_gpio_driver = {
+1 -10
drivers/gpio/gpio-tc3589x.c
··· 357 357 return ret; 358 358 } 359 359 360 - ret = devm_gpiochip_add_data(&pdev->dev, &tc3589x_gpio->chip, 361 - tc3589x_gpio); 362 - if (ret) { 363 - dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); 364 - return ret; 365 - } 366 - 367 - platform_set_drvdata(pdev, tc3589x_gpio); 368 - 369 - return 0; 360 + return devm_gpiochip_add_data(&pdev->dev, &tc3589x_gpio->chip, tc3589x_gpio); 370 361 } 371 362 372 363 static struct platform_driver tc3589x_gpio_driver = {
+1 -13
drivers/gpio/gpio-tegra186.c
··· 730 730 offset += port->pins; 731 731 } 732 732 733 - platform_set_drvdata(pdev, gpio); 734 - 735 - err = devm_gpiochip_add_data(&pdev->dev, &gpio->gpio, gpio); 736 - if (err < 0) 737 - return err; 738 - 739 - return 0; 740 - } 741 - 742 - static int tegra186_gpio_remove(struct platform_device *pdev) 743 - { 744 - return 0; 733 + return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio, gpio); 745 734 } 746 735 747 736 #define TEGRA186_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \ ··· 902 913 .of_match_table = tegra186_gpio_of_match, 903 914 }, 904 915 .probe = tegra186_gpio_probe, 905 - .remove = tegra186_gpio_remove, 906 916 }; 907 917 module_platform_driver(tegra186_gpio_driver); 908 918
+2 -11
drivers/gpio/gpio-tps65218.c
··· 187 187 { 188 188 struct tps65218 *tps65218 = dev_get_drvdata(pdev->dev.parent); 189 189 struct tps65218_gpio *tps65218_gpio; 190 - int ret; 191 190 192 191 tps65218_gpio = devm_kzalloc(&pdev->dev, sizeof(*tps65218_gpio), 193 192 GFP_KERNEL); ··· 200 201 tps65218_gpio->gpio_chip.of_node = pdev->dev.of_node; 201 202 #endif 202 203 203 - ret = devm_gpiochip_add_data(&pdev->dev, &tps65218_gpio->gpio_chip, 204 - tps65218_gpio); 205 - if (ret < 0) { 206 - dev_err(&pdev->dev, "Failed to register gpiochip, %d\n", ret); 207 - return ret; 208 - } 209 - 210 - platform_set_drvdata(pdev, tps65218_gpio); 211 - 212 - return ret; 204 + return devm_gpiochip_add_data(&pdev->dev, &tps65218_gpio->gpio_chip, 205 + tps65218_gpio); 213 206 } 214 207 215 208 static const struct of_device_id tps65218_dt_match[] = {
+2 -11
drivers/gpio/gpio-tps6586x.c
··· 76 76 { 77 77 struct tps6586x_platform_data *pdata; 78 78 struct tps6586x_gpio *tps6586x_gpio; 79 - int ret; 80 79 81 80 pdata = dev_get_platdata(pdev->dev.parent); 82 81 tps6586x_gpio = devm_kzalloc(&pdev->dev, ··· 105 106 else 106 107 tps6586x_gpio->gpio_chip.base = -1; 107 108 108 - ret = devm_gpiochip_add_data(&pdev->dev, &tps6586x_gpio->gpio_chip, 109 - tps6586x_gpio); 110 - if (ret < 0) { 111 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 112 - return ret; 113 - } 114 - 115 - platform_set_drvdata(pdev, tps6586x_gpio); 116 - 117 - return ret; 109 + return devm_gpiochip_add_data(&pdev->dev, &tps6586x_gpio->gpio_chip, 110 + tps6586x_gpio); 118 111 } 119 112 120 113 static struct platform_driver tps6586x_gpio_driver = {
+2 -10
drivers/gpio/gpio-tps65910.c
··· 165 165 } 166 166 167 167 skip_init: 168 - ret = devm_gpiochip_add_data(&pdev->dev, &tps65910_gpio->gpio_chip, 169 - tps65910_gpio); 170 - if (ret < 0) { 171 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 172 - return ret; 173 - } 174 - 175 - platform_set_drvdata(pdev, tps65910_gpio); 176 - 177 - return ret; 168 + return devm_gpiochip_add_data(&pdev->dev, &tps65910_gpio->gpio_chip, 169 + tps65910_gpio); 178 170 } 179 171 180 172 static struct platform_driver tps65910_gpio_driver = {
+1 -11
drivers/gpio/gpio-tps65912.c
··· 99 99 { 100 100 struct tps65912 *tps = dev_get_drvdata(pdev->dev.parent); 101 101 struct tps65912_gpio *gpio; 102 - int ret; 103 102 104 103 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 105 104 if (!gpio) ··· 108 109 gpio->gpio_chip = template_chip; 109 110 gpio->gpio_chip.parent = tps->dev; 110 111 111 - ret = devm_gpiochip_add_data(&pdev->dev, &gpio->gpio_chip, 112 - gpio); 113 - if (ret < 0) { 114 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 115 - return ret; 116 - } 117 - 118 - platform_set_drvdata(pdev, gpio); 119 - 120 - return 0; 112 + return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio_chip, gpio); 121 113 } 122 114 123 115 static const struct platform_device_id tps65912_gpio_id_table[] = {
+1 -11
drivers/gpio/gpio-tps68470.c
··· 125 125 static int tps68470_gpio_probe(struct platform_device *pdev) 126 126 { 127 127 struct tps68470_gpio_data *tps68470_gpio; 128 - int ret; 129 128 130 129 tps68470_gpio = devm_kzalloc(&pdev->dev, sizeof(*tps68470_gpio), 131 130 GFP_KERNEL); ··· 145 146 tps68470_gpio->gc.base = -1; 146 147 tps68470_gpio->gc.parent = &pdev->dev; 147 148 148 - ret = devm_gpiochip_add_data(&pdev->dev, &tps68470_gpio->gc, 149 - tps68470_gpio); 150 - if (ret < 0) { 151 - dev_err(&pdev->dev, "Failed to register gpio_chip: %d\n", ret); 152 - return ret; 153 - } 154 - 155 - platform_set_drvdata(pdev, tps68470_gpio); 156 - 157 - return ret; 149 + return devm_gpiochip_add_data(&pdev->dev, &tps68470_gpio->gc, tps68470_gpio); 158 150 } 159 151 160 152 static struct platform_driver tps68470_gpio_driver = {
+1 -9
drivers/gpio/gpio-visconti.c
··· 187 187 girq->default_type = IRQ_TYPE_NONE; 188 188 girq->handler = handle_level_irq; 189 189 190 - ret = devm_gpiochip_add_data(dev, &priv->gpio_chip, priv); 191 - if (ret) { 192 - dev_err(dev, "failed to add GPIO chip\n"); 193 - return ret; 194 - } 195 - 196 - platform_set_drvdata(pdev, priv); 197 - 198 - return ret; 190 + return devm_gpiochip_add_data(dev, &priv->gpio_chip, priv); 199 191 } 200 192 201 193 static const struct of_device_id visconti_gpio_of_match[] = {
+1 -11
drivers/gpio/gpio-wm831x.c
··· 261 261 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 262 262 struct wm831x_pdata *pdata = &wm831x->pdata; 263 263 struct wm831x_gpio *wm831x_gpio; 264 - int ret; 265 264 266 265 wm831x_gpio = devm_kzalloc(&pdev->dev, sizeof(*wm831x_gpio), 267 266 GFP_KERNEL); ··· 279 280 wm831x_gpio->gpio_chip.of_node = wm831x->dev->of_node; 280 281 #endif 281 282 282 - ret = devm_gpiochip_add_data(&pdev->dev, &wm831x_gpio->gpio_chip, 283 - wm831x_gpio); 284 - if (ret < 0) { 285 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 286 - return ret; 287 - } 288 - 289 - platform_set_drvdata(pdev, wm831x_gpio); 290 - 291 - return ret; 283 + return devm_gpiochip_add_data(&pdev->dev, &wm831x_gpio->gpio_chip, wm831x_gpio); 292 284 } 293 285 294 286 static struct platform_driver wm831x_gpio_driver = {
+1 -11
drivers/gpio/gpio-wm8350.c
··· 105 105 struct wm8350 *wm8350 = dev_get_drvdata(pdev->dev.parent); 106 106 struct wm8350_platform_data *pdata = dev_get_platdata(wm8350->dev); 107 107 struct wm8350_gpio_data *wm8350_gpio; 108 - int ret; 109 108 110 109 wm8350_gpio = devm_kzalloc(&pdev->dev, sizeof(*wm8350_gpio), 111 110 GFP_KERNEL); ··· 120 121 else 121 122 wm8350_gpio->gpio_chip.base = -1; 122 123 123 - ret = devm_gpiochip_add_data(&pdev->dev, &wm8350_gpio->gpio_chip, 124 - wm8350_gpio); 125 - if (ret < 0) { 126 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 127 - return ret; 128 - } 129 - 130 - platform_set_drvdata(pdev, wm8350_gpio); 131 - 132 - return ret; 124 + return devm_gpiochip_add_data(&pdev->dev, &wm8350_gpio->gpio_chip, wm8350_gpio); 133 125 } 134 126 135 127 static struct platform_driver wm8350_gpio_driver = {
+1 -12
drivers/gpio/gpio-wm8994.c
··· 263 263 struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent); 264 264 struct wm8994_pdata *pdata = dev_get_platdata(wm8994->dev); 265 265 struct wm8994_gpio *wm8994_gpio; 266 - int ret; 267 266 268 267 wm8994_gpio = devm_kzalloc(&pdev->dev, sizeof(*wm8994_gpio), 269 268 GFP_KERNEL); ··· 278 279 else 279 280 wm8994_gpio->gpio_chip.base = -1; 280 281 281 - ret = devm_gpiochip_add_data(&pdev->dev, &wm8994_gpio->gpio_chip, 282 - wm8994_gpio); 283 - if (ret < 0) { 284 - dev_err(&pdev->dev, "Could not register gpiochip, %d\n", 285 - ret); 286 - return ret; 287 - } 288 - 289 - platform_set_drvdata(pdev, wm8994_gpio); 290 - 291 - return ret; 282 + return devm_gpiochip_add_data(&pdev->dev, &wm8994_gpio->gpio_chip, wm8994_gpio); 292 283 } 293 284 294 285 static struct platform_driver wm8994_gpio_driver = {
+1 -10
drivers/gpio/gpio-xgene.c
··· 159 159 static int xgene_gpio_probe(struct platform_device *pdev) 160 160 { 161 161 struct xgene_gpio *gpio; 162 - int err = 0; 163 162 164 163 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 165 164 if (!gpio) ··· 182 183 183 184 platform_set_drvdata(pdev, gpio); 184 185 185 - err = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); 186 - if (err) { 187 - dev_err(&pdev->dev, 188 - "failed to register gpiochip.\n"); 189 - return err; 190 - } 191 - 192 - dev_info(&pdev->dev, "X-Gene GPIO driver registered.\n"); 193 - return 0; 186 + return devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); 194 187 } 195 188 196 189 static const struct of_device_id xgene_gpio_of_match[] = {
+197 -192
drivers/gpio/gpio-xilinx.c
··· 5 5 * Copyright 2008 - 2013 Xilinx, Inc. 6 6 */ 7 7 8 + #include <linux/bitmap.h> 8 9 #include <linux/bitops.h> 9 10 #include <linux/clk.h> 10 11 #include <linux/errno.h> ··· 24 23 #define XGPIO_DATA_OFFSET (0x0) /* Data register */ 25 24 #define XGPIO_TRI_OFFSET (0x4) /* I/O direction register */ 26 25 27 - #define XGPIO_CHANNEL_OFFSET 0x8 26 + #define XGPIO_CHANNEL0_OFFSET 0x0 27 + #define XGPIO_CHANNEL1_OFFSET 0x8 28 28 29 29 #define XGPIO_GIER_OFFSET 0x11c /* Global Interrupt Enable */ 30 30 #define XGPIO_GIER_IE BIT(31) ··· 45 43 * struct xgpio_instance - Stores information about GPIO device 46 44 * @gc: GPIO chip 47 45 * @regs: register block 48 - * @gpio_width: GPIO width for every channel 49 - * @gpio_state: GPIO write state shadow register 50 - * @gpio_last_irq_read: GPIO read state register from last interrupt 51 - * @gpio_dir: GPIO direction shadow register 46 + * @hw_map: GPIO pin mapping on hardware side 47 + * @sw_map: GPIO pin mapping on software side 48 + * @state: GPIO write state shadow register 49 + * @last_irq_read: GPIO read state register from last interrupt 50 + * @dir: GPIO direction shadow register 52 51 * @gpio_lock: Lock used for synchronization 53 52 * @irq: IRQ used by GPIO device 54 53 * @irqchip: IRQ chip 55 - * @irq_enable: GPIO IRQ enable/disable bitfield 56 - * @irq_rising_edge: GPIO IRQ rising edge enable/disable bitfield 57 - * @irq_falling_edge: GPIO IRQ falling edge enable/disable bitfield 54 + * @enable: GPIO IRQ enable/disable bitfield 55 + * @rising_edge: GPIO IRQ rising edge enable/disable bitfield 56 + * @falling_edge: GPIO IRQ falling edge enable/disable bitfield 58 57 * @clk: clock resource for this driver 59 58 */ 60 59 struct xgpio_instance { 61 60 struct gpio_chip gc; 62 61 void __iomem *regs; 63 - unsigned int gpio_width[2]; 64 - u32 gpio_state[2]; 65 - u32 gpio_last_irq_read[2]; 66 - u32 gpio_dir[2]; 62 + DECLARE_BITMAP(hw_map, 64); 63 + DECLARE_BITMAP(sw_map, 64); 64 + DECLARE_BITMAP(state, 64); 65 + DECLARE_BITMAP(last_irq_read, 64); 66 + DECLARE_BITMAP(dir, 64); 67 67 spinlock_t gpio_lock; /* For serializing operations */ 68 68 int irq; 69 69 struct irq_chip irqchip; 70 - u32 irq_enable[2]; 71 - u32 irq_rising_edge[2]; 72 - u32 irq_falling_edge[2]; 70 + DECLARE_BITMAP(enable, 64); 71 + DECLARE_BITMAP(rising_edge, 64); 72 + DECLARE_BITMAP(falling_edge, 64); 73 73 struct clk *clk; 74 74 }; 75 75 76 - static inline int xgpio_index(struct xgpio_instance *chip, int gpio) 76 + static inline int xgpio_from_bit(struct xgpio_instance *chip, int bit) 77 77 { 78 - if (gpio >= chip->gpio_width[0]) 79 - return 1; 80 - 81 - return 0; 78 + return bitmap_bitremap(bit, chip->hw_map, chip->sw_map, 64); 82 79 } 83 80 84 - static inline int xgpio_regoffset(struct xgpio_instance *chip, int gpio) 81 + static inline int xgpio_to_bit(struct xgpio_instance *chip, int gpio) 85 82 { 86 - if (xgpio_index(chip, gpio)) 87 - return XGPIO_CHANNEL_OFFSET; 88 - 89 - return 0; 83 + return bitmap_bitremap(gpio, chip->sw_map, chip->hw_map, 64); 90 84 } 91 85 92 - static inline int xgpio_offset(struct xgpio_instance *chip, int gpio) 86 + static inline u32 xgpio_get_value32(const unsigned long *map, int bit) 93 87 { 94 - if (xgpio_index(chip, gpio)) 95 - return gpio - chip->gpio_width[0]; 88 + const size_t index = BIT_WORD(bit); 89 + const unsigned long offset = (bit % BITS_PER_LONG) & BIT(5); 96 90 97 - return gpio; 91 + return (map[index] >> offset) & 0xFFFFFFFFul; 92 + } 93 + 94 + static inline void xgpio_set_value32(unsigned long *map, int bit, u32 v) 95 + { 96 + const size_t index = BIT_WORD(bit); 97 + const unsigned long offset = (bit % BITS_PER_LONG) & BIT(5); 98 + 99 + map[index] &= ~(0xFFFFFFFFul << offset); 100 + map[index] |= v << offset; 101 + } 102 + 103 + static inline int xgpio_regoffset(struct xgpio_instance *chip, int ch) 104 + { 105 + switch (ch) { 106 + case 0: 107 + return XGPIO_CHANNEL0_OFFSET; 108 + case 1: 109 + return XGPIO_CHANNEL1_OFFSET; 110 + default: 111 + return -EINVAL; 112 + } 113 + } 114 + 115 + static void xgpio_read_ch(struct xgpio_instance *chip, int reg, int bit, unsigned long *a) 116 + { 117 + void __iomem *addr = chip->regs + reg + xgpio_regoffset(chip, bit / 32); 118 + xgpio_set_value32(a, bit, xgpio_readreg(addr)); 119 + } 120 + 121 + static void xgpio_write_ch(struct xgpio_instance *chip, int reg, int bit, unsigned long *a) 122 + { 123 + void __iomem *addr = chip->regs + reg + xgpio_regoffset(chip, bit / 32); 124 + xgpio_writereg(addr, xgpio_get_value32(a, bit)); 125 + } 126 + 127 + static void xgpio_read_ch_all(struct xgpio_instance *chip, int reg, unsigned long *a) 128 + { 129 + int bit, lastbit = xgpio_to_bit(chip, chip->gc.ngpio - 1); 130 + 131 + for (bit = 0; bit <= lastbit ; bit += 32) 132 + xgpio_read_ch(chip, reg, bit, a); 133 + } 134 + 135 + static void xgpio_write_ch_all(struct xgpio_instance *chip, int reg, unsigned long *a) 136 + { 137 + int bit, lastbit = xgpio_to_bit(chip, chip->gc.ngpio - 1); 138 + 139 + for (bit = 0; bit <= lastbit ; bit += 32) 140 + xgpio_write_ch(chip, reg, bit, a); 98 141 } 99 142 100 143 /** ··· 156 109 static int xgpio_get(struct gpio_chip *gc, unsigned int gpio) 157 110 { 158 111 struct xgpio_instance *chip = gpiochip_get_data(gc); 159 - u32 val; 112 + int bit = xgpio_to_bit(chip, gpio); 113 + DECLARE_BITMAP(state, 64); 160 114 161 - val = xgpio_readreg(chip->regs + XGPIO_DATA_OFFSET + 162 - xgpio_regoffset(chip, gpio)); 115 + xgpio_read_ch(chip, XGPIO_DATA_OFFSET, bit, state); 163 116 164 - return !!(val & BIT(xgpio_offset(chip, gpio))); 117 + return test_bit(bit, state); 165 118 } 166 119 167 120 /** ··· 177 130 { 178 131 unsigned long flags; 179 132 struct xgpio_instance *chip = gpiochip_get_data(gc); 180 - int index = xgpio_index(chip, gpio); 181 - int offset = xgpio_offset(chip, gpio); 133 + int bit = xgpio_to_bit(chip, gpio); 182 134 183 135 spin_lock_irqsave(&chip->gpio_lock, flags); 184 136 185 137 /* Write to GPIO signal and set its direction to output */ 186 - if (val) 187 - chip->gpio_state[index] |= BIT(offset); 188 - else 189 - chip->gpio_state[index] &= ~BIT(offset); 138 + __assign_bit(bit, chip->state, val); 190 139 191 - xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + 192 - xgpio_regoffset(chip, gpio), chip->gpio_state[index]); 140 + xgpio_write_ch(chip, XGPIO_DATA_OFFSET, bit, chip->state); 193 141 194 142 spin_unlock_irqrestore(&chip->gpio_lock, flags); 195 143 } ··· 201 159 static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, 202 160 unsigned long *bits) 203 161 { 162 + DECLARE_BITMAP(hw_mask, 64); 163 + DECLARE_BITMAP(hw_bits, 64); 164 + DECLARE_BITMAP(state, 64); 204 165 unsigned long flags; 205 166 struct xgpio_instance *chip = gpiochip_get_data(gc); 206 - int index = xgpio_index(chip, 0); 207 - int offset, i; 167 + 168 + bitmap_remap(hw_mask, mask, chip->sw_map, chip->hw_map, 64); 169 + bitmap_remap(hw_bits, bits, chip->sw_map, chip->hw_map, 64); 208 170 209 171 spin_lock_irqsave(&chip->gpio_lock, flags); 210 172 211 - /* Write to GPIO signals */ 212 - for (i = 0; i < gc->ngpio; i++) { 213 - if (*mask == 0) 214 - break; 215 - /* Once finished with an index write it out to the register */ 216 - if (index != xgpio_index(chip, i)) { 217 - xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + 218 - index * XGPIO_CHANNEL_OFFSET, 219 - chip->gpio_state[index]); 220 - spin_unlock_irqrestore(&chip->gpio_lock, flags); 221 - index = xgpio_index(chip, i); 222 - spin_lock_irqsave(&chip->gpio_lock, flags); 223 - } 224 - if (__test_and_clear_bit(i, mask)) { 225 - offset = xgpio_offset(chip, i); 226 - if (test_bit(i, bits)) 227 - chip->gpio_state[index] |= BIT(offset); 228 - else 229 - chip->gpio_state[index] &= ~BIT(offset); 230 - } 231 - } 173 + bitmap_replace(state, chip->state, hw_bits, hw_mask, 64); 232 174 233 - xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + 234 - index * XGPIO_CHANNEL_OFFSET, chip->gpio_state[index]); 175 + xgpio_write_ch_all(chip, XGPIO_DATA_OFFSET, state); 176 + 177 + bitmap_copy(chip->state, state, 64); 235 178 236 179 spin_unlock_irqrestore(&chip->gpio_lock, flags); 237 180 } ··· 234 207 { 235 208 unsigned long flags; 236 209 struct xgpio_instance *chip = gpiochip_get_data(gc); 237 - int index = xgpio_index(chip, gpio); 238 - int offset = xgpio_offset(chip, gpio); 210 + int bit = xgpio_to_bit(chip, gpio); 239 211 240 212 spin_lock_irqsave(&chip->gpio_lock, flags); 241 213 242 214 /* Set the GPIO bit in shadow register and set direction as input */ 243 - chip->gpio_dir[index] |= BIT(offset); 244 - xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET + 245 - xgpio_regoffset(chip, gpio), chip->gpio_dir[index]); 215 + __set_bit(bit, chip->dir); 216 + xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir); 246 217 247 218 spin_unlock_irqrestore(&chip->gpio_lock, flags); 248 219 ··· 263 238 { 264 239 unsigned long flags; 265 240 struct xgpio_instance *chip = gpiochip_get_data(gc); 266 - int index = xgpio_index(chip, gpio); 267 - int offset = xgpio_offset(chip, gpio); 241 + int bit = xgpio_to_bit(chip, gpio); 268 242 269 243 spin_lock_irqsave(&chip->gpio_lock, flags); 270 244 271 245 /* Write state of GPIO signal */ 272 - if (val) 273 - chip->gpio_state[index] |= BIT(offset); 274 - else 275 - chip->gpio_state[index] &= ~BIT(offset); 276 - xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + 277 - xgpio_regoffset(chip, gpio), chip->gpio_state[index]); 246 + __assign_bit(bit, chip->state, val); 247 + xgpio_write_ch(chip, XGPIO_DATA_OFFSET, bit, chip->state); 278 248 279 249 /* Clear the GPIO bit in shadow register and set direction as output */ 280 - chip->gpio_dir[index] &= ~BIT(offset); 281 - xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET + 282 - xgpio_regoffset(chip, gpio), chip->gpio_dir[index]); 250 + __clear_bit(bit, chip->dir); 251 + xgpio_write_ch(chip, XGPIO_TRI_OFFSET, bit, chip->dir); 283 252 284 253 spin_unlock_irqrestore(&chip->gpio_lock, flags); 285 254 ··· 286 267 */ 287 268 static void xgpio_save_regs(struct xgpio_instance *chip) 288 269 { 289 - xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET, chip->gpio_state[0]); 290 - xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]); 291 - 292 - if (!chip->gpio_width[1]) 293 - return; 294 - 295 - xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + XGPIO_CHANNEL_OFFSET, 296 - chip->gpio_state[1]); 297 - xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET + XGPIO_CHANNEL_OFFSET, 298 - chip->gpio_dir[1]); 270 + xgpio_write_ch_all(chip, XGPIO_DATA_OFFSET, chip->state); 271 + xgpio_write_ch_all(chip, XGPIO_TRI_OFFSET, chip->dir); 299 272 } 300 273 301 274 static int xgpio_request(struct gpio_chip *chip, unsigned int offset) ··· 313 302 struct irq_data *data = irq_get_irq_data(gpio->irq); 314 303 315 304 if (!data) { 316 - dev_err(dev, "irq_get_irq_data() failed\n"); 317 - return -EINVAL; 305 + dev_dbg(dev, "IRQ not connected\n"); 306 + return pm_runtime_force_suspend(dev); 318 307 } 319 308 320 309 if (!irqd_is_wakeup_set(data)) ··· 359 348 struct irq_data *data = irq_get_irq_data(gpio->irq); 360 349 361 350 if (!data) { 362 - dev_err(dev, "irq_get_irq_data() failed\n"); 363 - return -EINVAL; 351 + dev_dbg(dev, "IRQ not connected\n"); 352 + return pm_runtime_force_resume(dev); 364 353 } 365 354 366 355 if (!irqd_is_wakeup_set(data)) ··· 402 391 unsigned long flags; 403 392 struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data); 404 393 int irq_offset = irqd_to_hwirq(irq_data); 405 - int index = xgpio_index(chip, irq_offset); 406 - int offset = xgpio_offset(chip, irq_offset); 394 + int bit = xgpio_to_bit(chip, irq_offset); 395 + u32 mask = BIT(bit / 32), temp; 407 396 408 397 spin_lock_irqsave(&chip->gpio_lock, flags); 409 398 410 - chip->irq_enable[index] &= ~BIT(offset); 399 + __clear_bit(bit, chip->enable); 411 400 412 - if (!chip->irq_enable[index]) { 401 + if (xgpio_get_value32(chip->enable, bit) == 0) { 413 402 /* Disable per channel interrupt */ 414 - u32 temp = xgpio_readreg(chip->regs + XGPIO_IPIER_OFFSET); 415 - 416 - temp &= ~BIT(index); 403 + temp = xgpio_readreg(chip->regs + XGPIO_IPIER_OFFSET); 404 + temp &= ~mask; 417 405 xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, temp); 418 406 } 419 407 spin_unlock_irqrestore(&chip->gpio_lock, flags); ··· 427 417 unsigned long flags; 428 418 struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data); 429 419 int irq_offset = irqd_to_hwirq(irq_data); 430 - int index = xgpio_index(chip, irq_offset); 431 - int offset = xgpio_offset(chip, irq_offset); 432 - u32 old_enable = chip->irq_enable[index]; 420 + int bit = xgpio_to_bit(chip, irq_offset); 421 + u32 old_enable = xgpio_get_value32(chip->enable, bit); 422 + u32 mask = BIT(bit / 32), val; 433 423 434 424 spin_lock_irqsave(&chip->gpio_lock, flags); 435 425 436 - chip->irq_enable[index] |= BIT(offset); 426 + __set_bit(bit, chip->enable); 437 427 438 - if (!old_enable) { 428 + if (old_enable == 0) { 439 429 /* Clear any existing per-channel interrupts */ 440 - u32 val = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET) & 441 - BIT(index); 442 - 443 - if (val) 444 - xgpio_writereg(chip->regs + XGPIO_IPISR_OFFSET, val); 430 + val = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET); 431 + val &= mask; 432 + xgpio_writereg(chip->regs + XGPIO_IPISR_OFFSET, val); 445 433 446 434 /* Update GPIO IRQ read data before enabling interrupt*/ 447 - val = xgpio_readreg(chip->regs + XGPIO_DATA_OFFSET + 448 - index * XGPIO_CHANNEL_OFFSET); 449 - chip->gpio_last_irq_read[index] = val; 435 + xgpio_read_ch(chip, XGPIO_DATA_OFFSET, bit, chip->last_irq_read); 450 436 451 437 /* Enable per channel interrupt */ 452 438 val = xgpio_readreg(chip->regs + XGPIO_IPIER_OFFSET); 453 - val |= BIT(index); 439 + val |= mask; 454 440 xgpio_writereg(chip->regs + XGPIO_IPIER_OFFSET, val); 455 441 } 456 442 ··· 465 459 { 466 460 struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data); 467 461 int irq_offset = irqd_to_hwirq(irq_data); 468 - int index = xgpio_index(chip, irq_offset); 469 - int offset = xgpio_offset(chip, irq_offset); 462 + int bit = xgpio_to_bit(chip, irq_offset); 470 463 471 464 /* 472 465 * The Xilinx GPIO hardware provides a single interrupt status ··· 475 470 */ 476 471 switch (type & IRQ_TYPE_SENSE_MASK) { 477 472 case IRQ_TYPE_EDGE_BOTH: 478 - chip->irq_rising_edge[index] |= BIT(offset); 479 - chip->irq_falling_edge[index] |= BIT(offset); 473 + __set_bit(bit, chip->rising_edge); 474 + __set_bit(bit, chip->falling_edge); 480 475 break; 481 476 case IRQ_TYPE_EDGE_RISING: 482 - chip->irq_rising_edge[index] |= BIT(offset); 483 - chip->irq_falling_edge[index] &= ~BIT(offset); 477 + __set_bit(bit, chip->rising_edge); 478 + __clear_bit(bit, chip->falling_edge); 484 479 break; 485 480 case IRQ_TYPE_EDGE_FALLING: 486 - chip->irq_rising_edge[index] &= ~BIT(offset); 487 - chip->irq_falling_edge[index] |= BIT(offset); 481 + __clear_bit(bit, chip->rising_edge); 482 + __set_bit(bit, chip->falling_edge); 488 483 break; 489 484 default: 490 485 return -EINVAL; ··· 501 496 static void xgpio_irqhandler(struct irq_desc *desc) 502 497 { 503 498 struct xgpio_instance *chip = irq_desc_get_handler_data(desc); 499 + struct gpio_chip *gc = &chip->gc; 504 500 struct irq_chip *irqchip = irq_desc_get_chip(desc); 505 - u32 num_channels = chip->gpio_width[1] ? 2 : 1; 506 - u32 offset = 0, index; 507 - u32 status = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET); 501 + DECLARE_BITMAP(rising, 64); 502 + DECLARE_BITMAP(falling, 64); 503 + DECLARE_BITMAP(all, 64); 504 + int irq_offset; 505 + u32 status; 506 + u32 bit; 508 507 508 + status = xgpio_readreg(chip->regs + XGPIO_IPISR_OFFSET); 509 509 xgpio_writereg(chip->regs + XGPIO_IPISR_OFFSET, status); 510 510 511 511 chained_irq_enter(irqchip, desc); 512 - for (index = 0; index < num_channels; index++) { 513 - if ((status & BIT(index))) { 514 - unsigned long rising_events, falling_events, all_events; 515 - unsigned long flags; 516 - u32 data, bit; 517 - unsigned int irq; 518 512 519 - spin_lock_irqsave(&chip->gpio_lock, flags); 520 - data = xgpio_readreg(chip->regs + XGPIO_DATA_OFFSET + 521 - index * XGPIO_CHANNEL_OFFSET); 522 - rising_events = data & 523 - ~chip->gpio_last_irq_read[index] & 524 - chip->irq_enable[index] & 525 - chip->irq_rising_edge[index]; 526 - falling_events = ~data & 527 - chip->gpio_last_irq_read[index] & 528 - chip->irq_enable[index] & 529 - chip->irq_falling_edge[index]; 530 - dev_dbg(chip->gc.parent, 531 - "IRQ chan %u rising 0x%lx falling 0x%lx\n", 532 - index, rising_events, falling_events); 533 - all_events = rising_events | falling_events; 534 - chip->gpio_last_irq_read[index] = data; 535 - spin_unlock_irqrestore(&chip->gpio_lock, flags); 513 + spin_lock(&chip->gpio_lock); 536 514 537 - for_each_set_bit(bit, &all_events, 32) { 538 - irq = irq_find_mapping(chip->gc.irq.domain, 539 - offset + bit); 540 - generic_handle_irq(irq); 541 - } 542 - } 543 - offset += chip->gpio_width[index]; 515 + xgpio_read_ch_all(chip, XGPIO_DATA_OFFSET, all); 516 + 517 + bitmap_complement(rising, chip->last_irq_read, 64); 518 + bitmap_and(rising, rising, all, 64); 519 + bitmap_and(rising, rising, chip->enable, 64); 520 + bitmap_and(rising, rising, chip->rising_edge, 64); 521 + 522 + bitmap_complement(falling, all, 64); 523 + bitmap_and(falling, falling, chip->last_irq_read, 64); 524 + bitmap_and(falling, falling, chip->enable, 64); 525 + bitmap_and(falling, falling, chip->falling_edge, 64); 526 + 527 + bitmap_copy(chip->last_irq_read, all, 64); 528 + bitmap_or(all, rising, falling, 64); 529 + 530 + spin_unlock(&chip->gpio_lock); 531 + 532 + dev_dbg(gc->parent, "IRQ rising %*pb falling %*pb\n", 64, rising, 64, falling); 533 + 534 + for_each_set_bit(bit, all, 64) { 535 + irq_offset = xgpio_from_bit(chip, bit); 536 + generic_handle_irq(irq_find_mapping(gc->irq.domain, irq_offset)); 544 537 } 545 538 546 539 chained_irq_exit(irqchip, desc); ··· 559 556 struct device_node *np = pdev->dev.of_node; 560 557 u32 is_dual = 0; 561 558 u32 cells = 2; 559 + u32 width[2]; 560 + u32 state[2]; 561 + u32 dir[2]; 562 562 struct gpio_irq_chip *girq; 563 563 u32 temp; 564 564 ··· 571 565 572 566 platform_set_drvdata(pdev, chip); 573 567 568 + /* First, check if the device is dual-channel */ 569 + of_property_read_u32(np, "xlnx,is-dual", &is_dual); 570 + 571 + /* Setup defaults */ 572 + memset32(width, 0, ARRAY_SIZE(width)); 573 + memset32(state, 0, ARRAY_SIZE(state)); 574 + memset32(dir, 0xFFFFFFFF, ARRAY_SIZE(dir)); 575 + 574 576 /* Update GPIO state shadow register with default value */ 575 - if (of_property_read_u32(np, "xlnx,dout-default", &chip->gpio_state[0])) 576 - chip->gpio_state[0] = 0x0; 577 + of_property_read_u32(np, "xlnx,dout-default", &state[0]); 578 + of_property_read_u32(np, "xlnx,dout-default-2", &state[1]); 579 + 580 + bitmap_from_arr32(chip->state, state, 64); 577 581 578 582 /* Update GPIO direction shadow register with default value */ 579 - if (of_property_read_u32(np, "xlnx,tri-default", &chip->gpio_dir[0])) 580 - chip->gpio_dir[0] = 0xFFFFFFFF; 583 + of_property_read_u32(np, "xlnx,tri-default", &dir[0]); 584 + of_property_read_u32(np, "xlnx,tri-default-2", &dir[1]); 585 + 586 + bitmap_from_arr32(chip->dir, dir, 64); 581 587 582 588 /* Update cells with gpio-cells value */ 583 589 if (of_property_read_u32(np, "#gpio-cells", &cells)) ··· 604 586 * Check device node and parent device node for device width 605 587 * and assume default width of 32 606 588 */ 607 - if (of_property_read_u32(np, "xlnx,gpio-width", &chip->gpio_width[0])) 608 - chip->gpio_width[0] = 32; 589 + if (of_property_read_u32(np, "xlnx,gpio-width", &width[0])) 590 + width[0] = 32; 609 591 610 - if (chip->gpio_width[0] > 32) 592 + if (width[0] > 32) 611 593 return -EINVAL; 594 + 595 + if (is_dual && of_property_read_u32(np, "xlnx,gpio2-width", &width[1])) 596 + width[1] = 32; 597 + 598 + if (width[1] > 32) 599 + return -EINVAL; 600 + 601 + /* Setup software pin mapping */ 602 + bitmap_set(chip->sw_map, 0, width[0] + width[1]); 603 + 604 + /* Setup hardware pin mapping */ 605 + bitmap_set(chip->hw_map, 0, width[0]); 606 + bitmap_set(chip->hw_map, 32, width[1]); 612 607 613 608 spin_lock_init(&chip->gpio_lock); 614 609 615 - if (of_property_read_u32(np, "xlnx,is-dual", &is_dual)) 616 - is_dual = 0; 617 - 618 - if (is_dual) { 619 - /* Update GPIO state shadow register with default value */ 620 - if (of_property_read_u32(np, "xlnx,dout-default-2", 621 - &chip->gpio_state[1])) 622 - chip->gpio_state[1] = 0x0; 623 - 624 - /* Update GPIO direction shadow register with default value */ 625 - if (of_property_read_u32(np, "xlnx,tri-default-2", 626 - &chip->gpio_dir[1])) 627 - chip->gpio_dir[1] = 0xFFFFFFFF; 628 - 629 - /* 630 - * Check device node and parent device node for device width 631 - * and assume default width of 32 632 - */ 633 - if (of_property_read_u32(np, "xlnx,gpio2-width", 634 - &chip->gpio_width[1])) 635 - chip->gpio_width[1] = 32; 636 - 637 - if (chip->gpio_width[1] > 32) 638 - return -EINVAL; 639 - } 640 - 641 610 chip->gc.base = -1; 642 - chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1]; 611 + chip->gc.ngpio = bitmap_weight(chip->hw_map, 64); 643 612 chip->gc.parent = &pdev->dev; 644 613 chip->gc.direction_input = xgpio_dir_in; 645 614 chip->gc.direction_output = xgpio_dir_out;
+15 -17
drivers/gpio/gpio-zynq.c
··· 736 736 struct zynq_gpio *gpio = dev_get_drvdata(dev); 737 737 struct irq_data *data = irq_get_irq_data(gpio->irq); 738 738 739 + if (!data) { 740 + dev_err(dev, "irq_get_irq_data() failed\n"); 741 + return -EINVAL; 742 + } 743 + 739 744 if (!device_may_wakeup(dev)) 740 745 disable_irq(gpio->irq); 741 746 ··· 757 752 struct zynq_gpio *gpio = dev_get_drvdata(dev); 758 753 struct irq_data *data = irq_get_irq_data(gpio->irq); 759 754 int ret; 755 + 756 + if (!data) { 757 + dev_err(dev, "irq_get_irq_data() failed\n"); 758 + return -EINVAL; 759 + } 760 760 761 761 if (!device_may_wakeup(dev)) 762 762 enable_irq(gpio->irq); ··· 1011 1001 static int zynq_gpio_remove(struct platform_device *pdev) 1012 1002 { 1013 1003 struct zynq_gpio *gpio = platform_get_drvdata(pdev); 1004 + int ret; 1014 1005 1015 - pm_runtime_get_sync(&pdev->dev); 1006 + ret = pm_runtime_get_sync(&pdev->dev); 1007 + if (ret < 0) 1008 + dev_warn(&pdev->dev, "pm_runtime_get_sync() Failed\n"); 1016 1009 gpiochip_remove(&gpio->chip); 1017 1010 clk_disable_unprepare(gpio->clk); 1018 1011 device_set_wakeup_capable(&pdev->dev, 0); ··· 1033 1020 .remove = zynq_gpio_remove, 1034 1021 }; 1035 1022 1036 - /** 1037 - * zynq_gpio_init - Initial driver registration call 1038 - * 1039 - * Return: value from platform_driver_register 1040 - */ 1041 - static int __init zynq_gpio_init(void) 1042 - { 1043 - return platform_driver_register(&zynq_gpio_driver); 1044 - } 1045 - postcore_initcall(zynq_gpio_init); 1046 - 1047 - static void __exit zynq_gpio_exit(void) 1048 - { 1049 - platform_driver_unregister(&zynq_gpio_driver); 1050 - } 1051 - module_exit(zynq_gpio_exit); 1023 + module_platform_driver(zynq_gpio_driver); 1052 1024 1053 1025 MODULE_AUTHOR("Xilinx Inc."); 1054 1026 MODULE_DESCRIPTION("Zynq GPIO driver");
+13 -21
drivers/gpio/gpiolib-sysfs.c
··· 66 66 mutex_lock(&data->mutex); 67 67 68 68 gpiod_get_direction(desc); 69 - status = sprintf(buf, "%s\n", 70 - test_bit(FLAG_IS_OUT, &desc->flags) 71 - ? "out" : "in"); 69 + status = sysfs_emit(buf, "%s\n", 70 + test_bit(FLAG_IS_OUT, &desc->flags) ? "out" : "in"); 72 71 73 72 mutex_unlock(&data->mutex); 74 73 ··· 108 109 mutex_lock(&data->mutex); 109 110 110 111 status = gpiod_get_value_cansleep(desc); 111 - if (status < 0) 112 - goto err; 112 + if (status >= 0) 113 + status = sysfs_emit(buf, "%zd\n", status); 113 114 114 - buf[0] = '0' + status; 115 - buf[1] = '\n'; 116 - status = 2; 117 - err: 118 115 mutex_unlock(&data->mutex); 119 116 120 117 return status; ··· 244 249 mutex_lock(&data->mutex); 245 250 246 251 for (i = 0; i < ARRAY_SIZE(trigger_types); i++) { 247 - if (data->irq_flags == trigger_types[i].flags) { 248 - status = sprintf(buf, "%s\n", trigger_types[i].name); 252 + if (data->irq_flags == trigger_types[i].flags) 249 253 break; 250 - } 251 254 } 255 + if (i < ARRAY_SIZE(trigger_types)) 256 + status = sysfs_emit(buf, "%s\n", trigger_types[i].name); 252 257 253 258 mutex_unlock(&data->mutex); 254 259 ··· 307 312 if (!!test_bit(FLAG_ACTIVE_LOW, &desc->flags) == !!value) 308 313 return 0; 309 314 310 - if (value) 311 - set_bit(FLAG_ACTIVE_LOW, &desc->flags); 312 - else 313 - clear_bit(FLAG_ACTIVE_LOW, &desc->flags); 315 + assign_bit(FLAG_ACTIVE_LOW, &desc->flags, value); 314 316 315 317 /* reconfigure poll(2) support if enabled on one edge only */ 316 318 if (flags == GPIO_IRQF_TRIGGER_FALLING || ··· 328 336 329 337 mutex_lock(&data->mutex); 330 338 331 - status = sprintf(buf, "%d\n", 332 - !!test_bit(FLAG_ACTIVE_LOW, &desc->flags)); 339 + status = sysfs_emit(buf, "%d\n", 340 + !!test_bit(FLAG_ACTIVE_LOW, &desc->flags)); 333 341 334 342 mutex_unlock(&data->mutex); 335 343 ··· 407 415 { 408 416 const struct gpio_chip *chip = dev_get_drvdata(dev); 409 417 410 - return sprintf(buf, "%d\n", chip->base); 418 + return sysfs_emit(buf, "%d\n", chip->base); 411 419 } 412 420 static DEVICE_ATTR_RO(base); 413 421 ··· 416 424 { 417 425 const struct gpio_chip *chip = dev_get_drvdata(dev); 418 426 419 - return sprintf(buf, "%s\n", chip->label ? : ""); 427 + return sysfs_emit(buf, "%s\n", chip->label ?: ""); 420 428 } 421 429 static DEVICE_ATTR_RO(label); 422 430 ··· 425 433 { 426 434 const struct gpio_chip *chip = dev_get_drvdata(dev); 427 435 428 - return sprintf(buf, "%u\n", chip->ngpio); 436 + return sysfs_emit(buf, "%u\n", chip->ngpio); 429 437 } 430 438 static DEVICE_ATTR_RO(ngpio); 431 439
+38 -21
drivers/gpio/gpiolib.c
··· 2004 2004 { 2005 2005 struct gpio_desc *desc; 2006 2006 2007 - if (offset >= gc->ngpio) 2008 - return NULL; 2009 - 2010 2007 desc = gpiochip_get_desc(gc, offset); 2011 2008 if (IS_ERR(desc)) 2012 2009 return NULL; ··· 2540 2543 2541 2544 while (i < array_size) { 2542 2545 struct gpio_chip *gc = desc_array[i]->gdev->chip; 2543 - unsigned long fastpath[2 * BITS_TO_LONGS(FASTPATH_NGPIO)]; 2546 + DECLARE_BITMAP(fastpath_mask, FASTPATH_NGPIO); 2547 + DECLARE_BITMAP(fastpath_bits, FASTPATH_NGPIO); 2544 2548 unsigned long *mask, *bits; 2545 2549 int first, j; 2546 2550 2547 2551 if (likely(gc->ngpio <= FASTPATH_NGPIO)) { 2548 - mask = fastpath; 2552 + mask = fastpath_mask; 2553 + bits = fastpath_bits; 2549 2554 } else { 2550 - mask = kmalloc_array(2 * BITS_TO_LONGS(gc->ngpio), 2551 - sizeof(*mask), 2552 - can_sleep ? GFP_KERNEL : GFP_ATOMIC); 2555 + gfp_t flags = can_sleep ? GFP_KERNEL : GFP_ATOMIC; 2556 + 2557 + mask = bitmap_alloc(gc->ngpio, flags); 2553 2558 if (!mask) 2554 2559 return -ENOMEM; 2560 + 2561 + bits = bitmap_alloc(gc->ngpio, flags); 2562 + if (!bits) { 2563 + bitmap_free(mask); 2564 + return -ENOMEM; 2565 + } 2555 2566 } 2556 2567 2557 - bits = mask + BITS_TO_LONGS(gc->ngpio); 2558 2568 bitmap_zero(mask, gc->ngpio); 2559 2569 2560 2570 if (!can_sleep) ··· 2584 2580 2585 2581 ret = gpio_chip_get_multiple(gc, mask, bits); 2586 2582 if (ret) { 2587 - if (mask != fastpath) 2588 - kfree(mask); 2583 + if (mask != fastpath_mask) 2584 + bitmap_free(mask); 2585 + if (bits != fastpath_bits) 2586 + bitmap_free(bits); 2589 2587 return ret; 2590 2588 } 2591 2589 ··· 2607 2601 j); 2608 2602 } 2609 2603 2610 - if (mask != fastpath) 2611 - kfree(mask); 2604 + if (mask != fastpath_mask) 2605 + bitmap_free(mask); 2606 + if (bits != fastpath_bits) 2607 + bitmap_free(bits); 2612 2608 } 2613 2609 return 0; 2614 2610 } ··· 2834 2826 2835 2827 while (i < array_size) { 2836 2828 struct gpio_chip *gc = desc_array[i]->gdev->chip; 2837 - unsigned long fastpath[2 * BITS_TO_LONGS(FASTPATH_NGPIO)]; 2829 + DECLARE_BITMAP(fastpath_mask, FASTPATH_NGPIO); 2830 + DECLARE_BITMAP(fastpath_bits, FASTPATH_NGPIO); 2838 2831 unsigned long *mask, *bits; 2839 2832 int count = 0; 2840 2833 2841 2834 if (likely(gc->ngpio <= FASTPATH_NGPIO)) { 2842 - mask = fastpath; 2835 + mask = fastpath_mask; 2836 + bits = fastpath_bits; 2843 2837 } else { 2844 - mask = kmalloc_array(2 * BITS_TO_LONGS(gc->ngpio), 2845 - sizeof(*mask), 2846 - can_sleep ? GFP_KERNEL : GFP_ATOMIC); 2838 + gfp_t flags = can_sleep ? GFP_KERNEL : GFP_ATOMIC; 2839 + 2840 + mask = bitmap_alloc(gc->ngpio, flags); 2847 2841 if (!mask) 2848 2842 return -ENOMEM; 2843 + 2844 + bits = bitmap_alloc(gc->ngpio, flags); 2845 + if (!bits) { 2846 + bitmap_free(mask); 2847 + return -ENOMEM; 2848 + } 2849 2849 } 2850 2850 2851 - bits = mask + BITS_TO_LONGS(gc->ngpio); 2852 2851 bitmap_zero(mask, gc->ngpio); 2853 2852 2854 2853 if (!can_sleep) ··· 2900 2885 if (count != 0) 2901 2886 gpio_chip_set_multiple(gc, mask, bits); 2902 2887 2903 - if (mask != fastpath) 2904 - kfree(mask); 2888 + if (mask != fastpath_mask) 2889 + bitmap_free(mask); 2890 + if (bits != fastpath_bits) 2891 + bitmap_free(bits); 2905 2892 } 2906 2893 return 0; 2907 2894 }
+5 -1
include/linux/gpio/regmap.h
··· 37 37 * offset to a register/bitmask pair. If not 38 38 * given the default gpio_regmap_simple_xlate() 39 39 * is used. 40 + * @drvdata: (Optional) Pointer to driver specific data which is 41 + * not used by gpio-remap but is provided "as is" to the 42 + * driver callback(s). 40 43 * 41 44 * The ->reg_mask_xlate translates a given base address and GPIO offset to 42 45 * register and mask pair. The base address is one of the given register ··· 81 78 int (*reg_mask_xlate)(struct gpio_regmap *gpio, unsigned int base, 82 79 unsigned int offset, unsigned int *reg, 83 80 unsigned int *mask); 81 + 82 + void *drvdata; 84 83 }; 85 84 86 85 struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config); 87 86 void gpio_regmap_unregister(struct gpio_regmap *gpio); 88 87 struct gpio_regmap *devm_gpio_regmap_register(struct device *dev, 89 88 const struct gpio_regmap_config *config); 90 - void gpio_regmap_set_drvdata(struct gpio_regmap *gpio, void *data); 91 89 void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio); 92 90 93 91 #endif /* _LINUX_GPIO_REGMAP_H */
+3 -2
lib/bitmap.c
··· 793 793 } 794 794 EXPORT_SYMBOL(bitmap_parse); 795 795 796 - 797 - #ifdef CONFIG_NUMA 798 796 /** 799 797 * bitmap_pos_to_ord - find ordinal of set bit at given position in bitmap 800 798 * @buf: pointer to a bitmap ··· 901 903 set_bit(bitmap_ord_to_pos(new, n % w, nbits), dst); 902 904 } 903 905 } 906 + EXPORT_SYMBOL(bitmap_remap); 904 907 905 908 /** 906 909 * bitmap_bitremap - Apply map defined by a pair of bitmaps to a single bit ··· 939 940 else 940 941 return bitmap_ord_to_pos(new, n % w, bits); 941 942 } 943 + EXPORT_SYMBOL(bitmap_bitremap); 942 944 945 + #ifdef CONFIG_NUMA 943 946 /** 944 947 * bitmap_onto - translate one bitmap relative to another 945 948 * @dst: resulting translated bitmap