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

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

Pull gpio updates from Bartosz Golaszewski:
"We have a single new driver, support for a bunch of new models,
improvements in drivers and core gpiolib code as well device-tree
bindings changes.

Summary:

New driver:
- IMX System Controller Unit GPIOs

GPIO core:
- add fdinfo output for the GPIO character device file descriptors
(allows user-space to determine which processes own which GPIO
lines)
- improvements to OF GPIO code
- new quirk for Asus UM325UAZ in gpiolib-acpi
- new quirk for Freescale SPI in gpiolib-of

Driver improvements:
- add a new macro that reduces the amount of boilerplate code in ISA
drivers and use it in relevant drivers
- support two new models in gpio-pca953x
- support new model in gpio-f7188x
- convert more drivers to use immutable irq chips
- other minor tweaks

Device-tree bindings:
- add DT bindings for gpio-imx-scu
- convert Xilinx GPIO bindings to YAML
- reference the properties from the SPI peripheral device-tree
bindings instead of providing custom ones in the GPIO controller
document
- add parsing of GPIO hog nodes to the DT bindings for gpio-mpfs-gpio
- relax the node name requirements in gpio-stmpe
- add new models for gpio-rcar and gpio-pxa95xx
- add a new vendor prefix: Diodes (for Diodes, Inc.)

Misc:
- pulled in the immutable branch from the x86 platform drivers tree
including support for a new simatic board that depends on GPIO
changes"

* tag 'gpio-updates-for-v6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (36 commits)
gpio: tc3589x: Make irqchip immutable
gpiolib: cdev: add fdinfo output for line request file descriptors
gpio: twl4030: Reorder functions which allows to drop a forward declaraion
gpiolib: fix OOB access in quirk callbacks
gpiolib: of: factor out conversion from OF flags
gpiolib: rework quirk handling in of_find_gpio()
gpiolib: of: make Freescale SPI quirk similar to all others
gpiolib: of: do not ignore requested index when applying quirks
gpio: ws16c48: Ensure number of irq matches number of base
gpio: 104-idio-16: Ensure number of irq matches number of base
gpio: 104-idi-48: Ensure number of irq matches number of base
gpio: 104-dio-48e: Ensure number of irq matches number of base
counter: 104-quad-8: Ensure number of irq matches number of base
isa: Introduce the module_isa_driver_with_irq helper macro
gpio: pca953x: Add support for PCAL6534
gpio: pca953x: Swap if statements to save later complexity
gpio: pca953x: Fix pca953x_gpio_set_pull_up_down()
dt-bindings: gpio: pca95xx: add entry for pcal6534 and PI4IOE5V6534Q
dt-bindings: vendor-prefixes: add Diodes
gpio: mt7621: Switch to use platform_get_irq() function
...

+873 -391
+5
Documentation/devicetree/bindings/firmware/fsl,scu.yaml
··· 30 30 Clock controller node that provides the clocks controlled by the SCU 31 31 $ref: /schemas/clock/fsl,scu-clk.yaml 32 32 33 + gpio: 34 + description: 35 + Control the GPIO PINs on SCU domain over the firmware APIs 36 + $ref: /schemas/gpio/fsl,imx8qxp-sc-gpio.yaml 37 + 33 38 ocotp: 34 39 description: 35 40 OCOTP controller node provided by the SCU
+4 -3
Documentation/devicetree/bindings/gpio/fairchild,74hc595.yaml
··· 33 33 description: GPIO connected to the OE (Output Enable) pin. 34 34 maxItems: 1 35 35 36 - spi-max-frequency: true 37 - 38 36 patternProperties: 39 37 "^(hog-[0-9]+|.+-hog(-[0-9]+)?)$": 40 38 type: object ··· 57 59 - '#gpio-cells' 58 60 - registers-number 59 61 60 - additionalProperties: false 62 + allOf: 63 + - $ref: /schemas/spi/spi-peripheral-props.yaml# 64 + 65 + unevaluatedProperties: false 61 66 62 67 examples: 63 68 - |
+39
Documentation/devicetree/bindings/gpio/fsl,imx8qxp-sc-gpio.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/fsl,imx8qxp-sc-gpio.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: GPIO driver over IMX SCU firmware API 8 + 9 + maintainers: 10 + - Shenwei Wang <shenwei.wang@nxp.com> 11 + 12 + description: | 13 + This module provides the standard interface to control the 14 + resource pins in SCU domain on i.MX8 platforms. 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - fsl,imx8qxp-sc-gpio 20 + 21 + "#gpio-cells": 22 + const: 2 23 + 24 + gpio-controller: true 25 + 26 + required: 27 + - compatible 28 + - "#gpio-cells" 29 + - gpio-controller 30 + 31 + additionalProperties: false 32 + 33 + examples: 34 + - | 35 + gpio0: gpio { 36 + compatible = "fsl,imx8qxp-sc-gpio"; 37 + gpio-controller; 38 + #gpio-cells = <2>; 39 + };
+53 -46
Documentation/devicetree/bindings/gpio/gpio-pca95xx.yaml
··· 15 15 16 16 properties: 17 17 compatible: 18 - enum: 19 - - exar,xra1202 20 - - maxim,max7310 21 - - maxim,max7312 22 - - maxim,max7313 23 - - maxim,max7315 24 - - maxim,max7319 25 - - maxim,max7320 26 - - maxim,max7321 27 - - maxim,max7322 28 - - maxim,max7323 29 - - maxim,max7324 30 - - maxim,max7325 31 - - maxim,max7326 32 - - maxim,max7327 33 - - nxp,pca6408 34 - - nxp,pca6416 35 - - nxp,pca9505 36 - - nxp,pca9506 37 - - nxp,pca9534 38 - - nxp,pca9535 39 - - nxp,pca9536 40 - - nxp,pca9537 41 - - nxp,pca9538 42 - - nxp,pca9539 43 - - nxp,pca9554 44 - - nxp,pca9555 45 - - nxp,pca9556 46 - - nxp,pca9557 47 - - nxp,pca9574 48 - - nxp,pca9575 49 - - nxp,pca9698 50 - - nxp,pcal6416 51 - - nxp,pcal6524 52 - - nxp,pcal9535 53 - - nxp,pcal9554b 54 - - nxp,pcal9555a 55 - - onnn,cat9554 56 - - onnn,pca9654 57 - - ti,pca6107 58 - - ti,pca9536 59 - - ti,tca6408 60 - - ti,tca6416 61 - - ti,tca6424 62 - - ti,tca9539 63 - - ti,tca9554 18 + oneOf: 19 + - items: 20 + - const: diodes,pi4ioe5v6534q 21 + - const: nxp,pcal6534 22 + - items: 23 + - enum: 24 + - exar,xra1202 25 + - maxim,max7310 26 + - maxim,max7312 27 + - maxim,max7313 28 + - maxim,max7315 29 + - maxim,max7319 30 + - maxim,max7320 31 + - maxim,max7321 32 + - maxim,max7322 33 + - maxim,max7323 34 + - maxim,max7324 35 + - maxim,max7325 36 + - maxim,max7326 37 + - maxim,max7327 38 + - nxp,pca6408 39 + - nxp,pca6416 40 + - nxp,pca9505 41 + - nxp,pca9506 42 + - nxp,pca9534 43 + - nxp,pca9535 44 + - nxp,pca9536 45 + - nxp,pca9537 46 + - nxp,pca9538 47 + - nxp,pca9539 48 + - nxp,pca9554 49 + - nxp,pca9555 50 + - nxp,pca9556 51 + - nxp,pca9557 52 + - nxp,pca9574 53 + - nxp,pca9575 54 + - nxp,pca9698 55 + - nxp,pcal6408 56 + - nxp,pcal6416 57 + - nxp,pcal6524 58 + - nxp,pcal6534 59 + - nxp,pcal9535 60 + - nxp,pcal9554b 61 + - nxp,pcal9555a 62 + - onnn,cat9554 63 + - onnn,pca9654 64 + - ti,pca6107 65 + - ti,pca9536 66 + - ti,tca6408 67 + - ti,tca6416 68 + - ti,tca6424 69 + - ti,tca9539 70 + - ti,tca9554 64 71 65 72 reg: 66 73 maxItems: 1
+1 -2
Documentation/devicetree/bindings/gpio/gpio-stmpe.txt
··· 8 8 - st,norequest-mask: bitmask specifying which GPIOs should _not_ be requestable 9 9 due to different usage (e.g. touch, keypad) 10 10 11 - Node name must be stmpe_gpio and should be child node of stmpe node to which it 12 - belongs. 11 + Node should be child node of stmpe node to which it belongs. 13 12 14 13 Example: 15 14 stmpe_gpio {
-48
Documentation/devicetree/bindings/gpio/gpio-xilinx.txt
··· 1 - Xilinx plb/axi GPIO controller 2 - 3 - Dual channel GPIO controller with configurable number of pins 4 - (from 1 to 32 per channel). Every pin can be configured as 5 - input/output/tristate. Both channels share the same global IRQ but 6 - local interrupts can be enabled on channel basis. 7 - 8 - Required properties: 9 - - compatible : Should be "xlnx,xps-gpio-1.00.a" 10 - - reg : Address and length of the register set for the device 11 - - #gpio-cells : Should be two. The first cell is the pin number and the 12 - second cell is used to specify optional parameters (currently unused). 13 - - gpio-controller : Marks the device node as a GPIO controller. 14 - 15 - Optional properties: 16 - - clocks : Input clock specifier. Refer to common clock bindings. 17 - - interrupts : Interrupt mapping for GPIO IRQ. 18 - - xlnx,all-inputs : if n-th bit is setup, GPIO-n is input 19 - - xlnx,dout-default : if n-th bit is 1, GPIO-n default value is 1 20 - - xlnx,gpio-width : gpio width 21 - - xlnx,tri-default : if n-th bit is 1, GPIO-n is in tristate mode 22 - - xlnx,is-dual : if 1, controller also uses the second channel 23 - - xlnx,all-inputs-2 : as above but for the second channel 24 - - xlnx,dout-default-2 : as above but the second channel 25 - - xlnx,gpio2-width : as above but for the second channel 26 - - xlnx,tri-default-2 : as above but for the second channel 27 - 28 - 29 - Example: 30 - gpio: gpio@40000000 { 31 - #gpio-cells = <2>; 32 - compatible = "xlnx,xps-gpio-1.00.a"; 33 - clocks = <&clkc25>; 34 - gpio-controller ; 35 - interrupt-parent = <&microblaze_0_intc>; 36 - interrupts = < 6 2 >; 37 - reg = < 0x40000000 0x10000 >; 38 - xlnx,all-inputs = <0x0>; 39 - xlnx,all-inputs-2 = <0x0>; 40 - xlnx,dout-default = <0x0>; 41 - xlnx,dout-default-2 = <0x0>; 42 - xlnx,gpio-width = <0x2>; 43 - xlnx,gpio2-width = <0x2>; 44 - xlnx,interrupt-present = <0x1>; 45 - xlnx,is-dual = <0x1>; 46 - xlnx,tri-default = <0xffffffff>; 47 - xlnx,tri-default-2 = <0xffffffff>; 48 - } ;
+18
Documentation/devicetree/bindings/gpio/microchip,mpfs-gpio.yaml
··· 44 44 45 45 gpio-controller: true 46 46 47 + patternProperties: 48 + "^.+-hog(-[0-9]+)?$": 49 + type: object 50 + 51 + additionalProperties: false 52 + 53 + properties: 54 + gpio-hog: true 55 + gpios: true 56 + input: true 57 + output-high: true 58 + output-low: true 59 + line-name: true 60 + 61 + required: 62 + - gpio-hog 63 + - gpios 64 + 47 65 required: 48 66 - compatible 49 67 - reg
+1
Documentation/devicetree/bindings/gpio/renesas,rcar-gpio.yaml
··· 52 52 - enum: 53 53 - renesas,gpio-r8a779a0 # R-Car V3U 54 54 - renesas,gpio-r8a779f0 # R-Car S4-8 55 + - renesas,gpio-r8a779g0 # R-Car V4H 55 56 - const: renesas,rcar-gen4-gpio # R-Car Gen4 56 57 57 58 reg:
+154
Documentation/devicetree/bindings/gpio/xlnx,gpio-xilinx.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/xlnx,gpio-xilinx.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Xilinx AXI GPIO controller 8 + 9 + maintainers: 10 + - Neeli Srinivas <srinivas.neeli@xilinx.com> 11 + 12 + description: 13 + The AXI GPIO design provides a general purpose input/output interface 14 + to an AXI4-Lite interface. The AXI GPIO can be configured as either 15 + a single or a dual-channel device. The width of each channel is 16 + independently configurable. The channels can be configured to 17 + generate an interrupt when a transition on any of their inputs occurs. 18 + 19 + properties: 20 + compatible: 21 + enum: 22 + - xlnx,xps-gpio-1.00.a 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + "#gpio-cells": 28 + const: 2 29 + 30 + interrupts: 31 + maxItems: 1 32 + 33 + gpio-controller: true 34 + 35 + gpio-line-names: 36 + description: strings describing the names of each gpio line 37 + minItems: 1 38 + maxItems: 64 39 + 40 + interrupt-controller: true 41 + 42 + "#interrupt-cells": 43 + const: 2 44 + 45 + clocks: 46 + maxItems: 1 47 + 48 + interrupt-names: true 49 + 50 + xlnx,all-inputs: 51 + $ref: /schemas/types.yaml#/definitions/uint32 52 + description: This option sets this GPIO channel1 bits in input mode. 53 + 54 + xlnx,all-inputs-2: 55 + $ref: /schemas/types.yaml#/definitions/uint32 56 + description: This option sets this GPIO channel2 bits in input mode. 57 + 58 + xlnx,all-outputs: 59 + $ref: /schemas/types.yaml#/definitions/uint32 60 + description: This option sets this GPIO channel1 bits in output mode. 61 + 62 + xlnx,all-outputs-2: 63 + $ref: /schemas/types.yaml#/definitions/uint32 64 + description: This option sets this GPIO channel2 bits in output mode. 65 + 66 + xlnx,dout-default: 67 + $ref: /schemas/types.yaml#/definitions/uint32 68 + description: Sets the default value of all the enabled bits of 69 + channel1. 70 + default: 0 71 + 72 + xlnx,dout-default-2: 73 + $ref: /schemas/types.yaml#/definitions/uint32 74 + description: Sets the default value of all the enabled bits of 75 + channel2. 76 + default: 0 77 + 78 + xlnx,gpio-width: 79 + $ref: /schemas/types.yaml#/definitions/uint32 80 + description: The value defines the bit width of the GPIO channel1. 81 + minimum: 1 82 + maximum: 32 83 + default: 32 84 + 85 + xlnx,gpio2-width: 86 + $ref: /schemas/types.yaml#/definitions/uint32 87 + description: The value defines the bit width of the GPIO channel2. 88 + minimum: 1 89 + maximum: 32 90 + default: 32 91 + 92 + xlnx,interrupt-present: 93 + $ref: /schemas/types.yaml#/definitions/uint32 94 + description: This parameter enables interrupt control logic 95 + and interrupt registers in GPIO module. 96 + minimum: 0 97 + maximum: 1 98 + default: 0 99 + 100 + xlnx,is-dual: 101 + $ref: /schemas/types.yaml#/definitions/uint32 102 + description: This parameter enables a second GPIO channel (GPIO2). 103 + minimum: 0 104 + maximum: 1 105 + default: 0 106 + 107 + xlnx,tri-default: 108 + $ref: /schemas/types.yaml#/definitions/uint32 109 + description: This value configures the input or output mode 110 + of each bit of GPIO channel1. 111 + 112 + xlnx,tri-default-2: 113 + $ref: /schemas/types.yaml#/definitions/uint32 114 + description: This value configures the input or output mode 115 + of each bit of GPIO channel2. 116 + 117 + required: 118 + - reg 119 + - compatible 120 + - gpio-controller 121 + - "#gpio-cells" 122 + 123 + unevaluatedProperties: false 124 + 125 + examples: 126 + - | 127 + #include <dt-bindings/interrupt-controller/arm-gic.h> 128 + 129 + gpio@e000a000 { 130 + compatible = "xlnx,xps-gpio-1.00.a"; 131 + reg = <0xa0020000 0x10000>; 132 + #gpio-cells = <2>; 133 + #interrupt-cells = <0x2>; 134 + clocks = <&zynqmp_clk 71>; 135 + gpio-controller; 136 + interrupt-controller; 137 + interrupt-names = "ip2intc_irpt"; 138 + interrupt-parent = <&gic>; 139 + interrupts = <0 89 4>; 140 + xlnx,all-inputs = <0x0>; 141 + xlnx,all-inputs-2 = <0x0>; 142 + xlnx,all-outputs = <0x0>; 143 + xlnx,all-outputs-2 = <0x0>; 144 + xlnx,dout-default = <0x0>; 145 + xlnx,dout-default-2 = <0x0>; 146 + xlnx,gpio-width = <0x20>; 147 + xlnx,gpio2-width = <0x20>; 148 + xlnx,interrupt-present = <0x1>; 149 + xlnx,is-dual = <0x1>; 150 + xlnx,tri-default = <0xFFFFFFFF>; 151 + xlnx,tri-default-2 = <0xFFFFFFFF>; 152 + }; 153 + 154 + ...
+2
Documentation/devicetree/bindings/vendor-prefixes.yaml
··· 330 330 description: Digi International Inc. 331 331 "^digilent,.*": 332 332 description: Diglent, Inc. 333 + "^diodes,.*": 334 + description: Diodes, Inc. 333 335 "^dioo,.*": 334 336 description: Dioo Microcircuit Co., Ltd 335 337 "^dlc,.*":
+3 -2
drivers/counter/104-quad-8.c
··· 28 28 MODULE_PARM_DESC(base, "ACCES 104-QUAD-8 base addresses"); 29 29 30 30 static unsigned int irq[max_num_isa_dev(QUAD8_EXTENT)]; 31 - module_param_hw_array(irq, uint, irq, NULL, 0); 31 + static unsigned int num_irq; 32 + module_param_hw_array(irq, uint, irq, &num_irq, 0); 32 33 MODULE_PARM_DESC(irq, "ACCES 104-QUAD-8 interrupt line numbers"); 33 34 34 35 #define QUAD8_NUM_COUNTERS 8 ··· 1272 1271 } 1273 1272 }; 1274 1273 1275 - module_isa_driver(quad8_driver, num_quad8); 1274 + module_isa_driver_with_irq(quad8_driver, num_quad8, num_irq); 1276 1275 1277 1276 MODULE_AUTHOR("William Breathitt Gray <vilhelm.gray@gmail.com>"); 1278 1277 MODULE_DESCRIPTION("ACCES 104-QUAD-8 driver");
+4
drivers/gpio/Kconfig
··· 341 341 342 342 If unsure, say N. 343 343 344 + config GPIO_IMX_SCU 345 + def_bool y 346 + depends on IMX_SCU 347 + 344 348 config GPIO_IOP 345 349 tristate "Intel IOP GPIO" 346 350 depends on ARCH_IOP32X || COMPILE_TEST
+1
drivers/gpio/Makefile
··· 70 70 obj-$(CONFIG_GPIO_I8255) += gpio-i8255.o 71 71 obj-$(CONFIG_GPIO_ICH) += gpio-ich.o 72 72 obj-$(CONFIG_GPIO_IDT3243X) += gpio-idt3243x.o 73 + obj-$(CONFIG_GPIO_IMX_SCU) += gpio-imx-scu.o 73 74 obj-$(CONFIG_GPIO_IOP) += gpio-iop.o 74 75 obj-$(CONFIG_GPIO_IT87) += gpio-it87.o 75 76 obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4xx.o
+3 -2
drivers/gpio/gpio-104-dio-48e.c
··· 34 34 MODULE_PARM_DESC(base, "ACCES 104-DIO-48E base addresses"); 35 35 36 36 static unsigned int irq[MAX_NUM_DIO48E]; 37 - module_param_hw_array(irq, uint, irq, NULL, 0); 37 + static unsigned int num_irq; 38 + module_param_hw_array(irq, uint, irq, &num_irq, 0); 38 39 MODULE_PARM_DESC(irq, "ACCES 104-DIO-48E interrupt line numbers"); 39 40 40 41 #define DIO48E_NUM_PPI 2 ··· 363 362 .name = "104-dio-48e" 364 363 }, 365 364 }; 366 - module_isa_driver(dio48e_driver, num_dio48e); 365 + module_isa_driver_with_irq(dio48e_driver, num_dio48e, num_irq); 367 366 368 367 MODULE_AUTHOR("William Breathitt Gray <vilhelm.gray@gmail.com>"); 369 368 MODULE_DESCRIPTION("ACCES 104-DIO-48E GPIO driver");
+3 -2
drivers/gpio/gpio-104-idi-48.c
··· 34 34 MODULE_PARM_DESC(base, "ACCES 104-IDI-48 base addresses"); 35 35 36 36 static unsigned int irq[MAX_NUM_IDI_48]; 37 - module_param_hw_array(irq, uint, irq, NULL, 0); 37 + static unsigned int num_irq; 38 + module_param_hw_array(irq, uint, irq, &num_irq, 0); 38 39 MODULE_PARM_DESC(irq, "ACCES 104-IDI-48 interrupt line numbers"); 39 40 40 41 /** ··· 305 304 .name = "104-idi-48" 306 305 }, 307 306 }; 308 - module_isa_driver(idi_48_driver, num_idi_48); 307 + module_isa_driver_with_irq(idi_48_driver, num_idi_48, num_irq); 309 308 310 309 MODULE_AUTHOR("William Breathitt Gray <vilhelm.gray@gmail.com>"); 311 310 MODULE_DESCRIPTION("ACCES 104-IDI-48 GPIO driver");
+3 -2
drivers/gpio/gpio-104-idio-16.c
··· 30 30 MODULE_PARM_DESC(base, "ACCES 104-IDIO-16 base addresses"); 31 31 32 32 static unsigned int irq[MAX_NUM_IDIO_16]; 33 - module_param_hw_array(irq, uint, irq, NULL, 0); 33 + static unsigned int num_irq; 34 + module_param_hw_array(irq, uint, irq, &num_irq, 0); 34 35 MODULE_PARM_DESC(irq, "ACCES 104-IDIO-16 interrupt line numbers"); 35 36 36 37 /** ··· 338 337 }, 339 338 }; 340 339 341 - module_isa_driver(idio_16_driver, num_idio_16); 340 + module_isa_driver_with_irq(idio_16_driver, num_idio_16, num_irq); 342 341 343 342 MODULE_AUTHOR("William Breathitt Gray <vilhelm.gray@gmail.com>"); 344 343 MODULE_DESCRIPTION("ACCES 104-IDIO-16 GPIO driver");
+35 -5
drivers/gpio/gpio-exar.c
··· 21 21 #define EXAR_OFFSET_MPIOLVL_HI 0x96 22 22 #define EXAR_OFFSET_MPIOSEL_HI 0x99 23 23 24 + /* 25 + * The Device Configuration and UART Configuration Registers 26 + * for each UART channel take 1KB of memory address space. 27 + */ 28 + #define EXAR_UART_CHANNEL_SIZE 0x400 29 + 24 30 #define DRIVER_NAME "gpio_exar" 25 31 26 32 static DEFINE_IDA(ida_index); ··· 37 31 int index; 38 32 char name[20]; 39 33 unsigned int first_pin; 34 + /* 35 + * The offset to the cascaded device's (if existing) 36 + * Device Configuration Registers. 37 + */ 38 + unsigned int cascaded_offset; 40 39 }; 41 40 42 41 static unsigned int 43 42 exar_offset_to_sel_addr(struct exar_gpio_chip *exar_gpio, unsigned int offset) 44 43 { 45 - return (offset + exar_gpio->first_pin) / 8 ? EXAR_OFFSET_MPIOSEL_HI 46 - : EXAR_OFFSET_MPIOSEL_LO; 44 + unsigned int pin = exar_gpio->first_pin + (offset % 16); 45 + unsigned int cascaded = offset / 16; 46 + unsigned int addr = pin / 8 ? EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO; 47 + 48 + return addr + (cascaded ? exar_gpio->cascaded_offset : 0); 47 49 } 48 50 49 51 static unsigned int 50 52 exar_offset_to_lvl_addr(struct exar_gpio_chip *exar_gpio, unsigned int offset) 51 53 { 52 - return (offset + exar_gpio->first_pin) / 8 ? EXAR_OFFSET_MPIOLVL_HI 53 - : EXAR_OFFSET_MPIOLVL_LO; 54 + unsigned int pin = exar_gpio->first_pin + (offset % 16); 55 + unsigned int cascaded = offset / 16; 56 + unsigned int addr = pin / 8 ? EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO; 57 + 58 + return addr + (cascaded ? exar_gpio->cascaded_offset : 0); 54 59 } 55 60 56 61 static unsigned int 57 62 exar_offset_to_bit(struct exar_gpio_chip *exar_gpio, unsigned int offset) 58 63 { 59 - return (offset + exar_gpio->first_pin) % 8; 64 + unsigned int pin = exar_gpio->first_pin + (offset % 16); 65 + 66 + return pin % 8; 60 67 } 61 68 62 69 static int exar_get_direction(struct gpio_chip *chip, unsigned int offset) ··· 171 152 exar_gpio = devm_kzalloc(dev, sizeof(*exar_gpio), GFP_KERNEL); 172 153 if (!exar_gpio) 173 154 return -ENOMEM; 155 + 156 + /* 157 + * If cascaded, secondary xr17v354 or xr17v358 have the same amount 158 + * of MPIOs as their primaries and the last 4 bits of the primary's 159 + * PCI Device ID is the number of its UART channels. 160 + */ 161 + if (pcidev->device & GENMASK(15, 12)) { 162 + ngpios += ngpios; 163 + exar_gpio->cascaded_offset = (pcidev->device & GENMASK(3, 0)) * 164 + EXAR_UART_CHANNEL_SIZE; 165 + } 174 166 175 167 /* 176 168 * We don't need to check the return values of mmio regmap operations (unless
+139
drivers/gpio/gpio-imx-scu.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright 2021~2022 NXP 4 + * 5 + * The driver exports a standard gpiochip interface 6 + * to control the PIN resources on SCU domain. 7 + */ 8 + 9 + #include <linux/module.h> 10 + #include <linux/gpio/driver.h> 11 + #include <linux/platform_device.h> 12 + #include <linux/firmware/imx/svc/rm.h> 13 + #include <dt-bindings/firmware/imx/rsrc.h> 14 + 15 + struct scu_gpio_priv { 16 + struct gpio_chip chip; 17 + struct mutex lock; 18 + struct device *dev; 19 + struct imx_sc_ipc *handle; 20 + }; 21 + 22 + static unsigned int scu_rsrc_arr[] = { 23 + IMX_SC_R_BOARD_R0, 24 + IMX_SC_R_BOARD_R1, 25 + IMX_SC_R_BOARD_R2, 26 + IMX_SC_R_BOARD_R3, 27 + IMX_SC_R_BOARD_R4, 28 + IMX_SC_R_BOARD_R5, 29 + IMX_SC_R_BOARD_R6, 30 + IMX_SC_R_BOARD_R7, 31 + }; 32 + 33 + static int imx_scu_gpio_get(struct gpio_chip *chip, unsigned int offset) 34 + { 35 + struct scu_gpio_priv *priv = gpiochip_get_data(chip); 36 + int level; 37 + int err; 38 + 39 + if (offset >= chip->ngpio) 40 + return -EINVAL; 41 + 42 + mutex_lock(&priv->lock); 43 + 44 + /* to read PIN state via scu api */ 45 + err = imx_sc_misc_get_control(priv->handle, 46 + scu_rsrc_arr[offset], 0, &level); 47 + mutex_unlock(&priv->lock); 48 + 49 + if (err) { 50 + dev_err(priv->dev, "SCU get failed: %d\n", err); 51 + return err; 52 + } 53 + 54 + return level; 55 + } 56 + 57 + static void imx_scu_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) 58 + { 59 + struct scu_gpio_priv *priv = gpiochip_get_data(chip); 60 + int err; 61 + 62 + if (offset >= chip->ngpio) 63 + return; 64 + 65 + mutex_lock(&priv->lock); 66 + 67 + /* to set PIN output level via scu api */ 68 + err = imx_sc_misc_set_control(priv->handle, 69 + scu_rsrc_arr[offset], 0, value); 70 + mutex_unlock(&priv->lock); 71 + 72 + if (err) 73 + dev_err(priv->dev, "SCU set (%d) failed: %d\n", 74 + scu_rsrc_arr[offset], err); 75 + } 76 + 77 + static int imx_scu_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) 78 + { 79 + if (offset >= chip->ngpio) 80 + return -EINVAL; 81 + 82 + return GPIO_LINE_DIRECTION_OUT; 83 + } 84 + 85 + static int imx_scu_gpio_probe(struct platform_device *pdev) 86 + { 87 + struct device *dev = &pdev->dev; 88 + struct scu_gpio_priv *priv; 89 + struct gpio_chip *gc; 90 + int ret; 91 + 92 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 93 + if (!priv) 94 + return -ENOMEM; 95 + 96 + ret = imx_scu_get_handle(&priv->handle); 97 + if (ret) 98 + return ret; 99 + 100 + priv->dev = dev; 101 + mutex_init(&priv->lock); 102 + 103 + gc = &priv->chip; 104 + gc->base = -1; 105 + gc->parent = dev; 106 + gc->ngpio = sizeof(scu_rsrc_arr)/sizeof(unsigned int); 107 + gc->label = dev_name(dev); 108 + gc->get = imx_scu_gpio_get; 109 + gc->set = imx_scu_gpio_set; 110 + gc->get_direction = imx_scu_gpio_get_direction; 111 + 112 + platform_set_drvdata(pdev, priv); 113 + 114 + return devm_gpiochip_add_data(dev, gc, priv); 115 + } 116 + 117 + static const struct of_device_id imx_scu_gpio_dt_ids[] = { 118 + { .compatible = "fsl,imx8qxp-sc-gpio" }, 119 + { /* sentinel */ } 120 + }; 121 + 122 + static struct platform_driver imx_scu_gpio_driver = { 123 + .driver = { 124 + .name = "gpio-imx-scu", 125 + .of_match_table = imx_scu_gpio_dt_ids, 126 + }, 127 + .probe = imx_scu_gpio_probe, 128 + }; 129 + 130 + static int __init _imx_scu_gpio_init(void) 131 + { 132 + return platform_driver_register(&imx_scu_gpio_driver); 133 + } 134 + 135 + subsys_initcall_sync(_imx_scu_gpio_init); 136 + 137 + MODULE_AUTHOR("Shenwei Wang <shenwei.wang@nxp.com>"); 138 + MODULE_DESCRIPTION("NXP GPIO over IMX SCU API"); 139 + MODULE_LICENSE("GPL");
+4 -3
drivers/gpio/gpio-mt7621.c
··· 9 9 #include <linux/interrupt.h> 10 10 #include <linux/io.h> 11 11 #include <linux/module.h> 12 - #include <linux/of_irq.h> 13 12 #include <linux/platform_device.h> 14 13 #include <linux/spinlock.h> 15 14 ··· 298 299 mediatek_gpio_probe(struct platform_device *pdev) 299 300 { 300 301 struct device *dev = &pdev->dev; 301 - struct device_node *np = dev->of_node; 302 302 struct mtk *mtk; 303 303 int i; 304 304 int ret; ··· 310 312 if (IS_ERR(mtk->base)) 311 313 return PTR_ERR(mtk->base); 312 314 313 - mtk->gpio_irq = irq_of_parse_and_map(np, 0); 315 + mtk->gpio_irq = platform_get_irq(pdev, 0); 316 + if (mtk->gpio_irq < 0) 317 + return mtk->gpio_irq; 318 + 314 319 mtk->dev = dev; 315 320 platform_set_drvdata(pdev, mtk); 316 321
+139 -38
drivers/gpio/gpio-pca953x.c
··· 66 66 #define PCA_LATCH_INT (PCA_PCAL | PCA_INT) 67 67 #define PCA953X_TYPE BIT(12) 68 68 #define PCA957X_TYPE BIT(13) 69 + #define PCAL653X_TYPE BIT(14) 69 70 #define PCA_TYPE_MASK GENMASK(15, 12) 70 71 71 72 #define PCA_CHIP_TYPE(x) ((x) & PCA_TYPE_MASK) ··· 90 89 { "pca9575", 16 | PCA957X_TYPE | PCA_INT, }, 91 90 { "pca9698", 40 | PCA953X_TYPE, }, 92 91 92 + { "pcal6408", 8 | PCA953X_TYPE | PCA_LATCH_INT, }, 93 93 { "pcal6416", 16 | PCA953X_TYPE | PCA_LATCH_INT, }, 94 94 { "pcal6524", 24 | PCA953X_TYPE | PCA_LATCH_INT, }, 95 + { "pcal6534", 34 | PCAL653X_TYPE | PCA_LATCH_INT, }, 95 96 { "pcal9535", 16 | PCA953X_TYPE | PCA_LATCH_INT, }, 96 97 { "pcal9554b", 8 | PCA953X_TYPE | PCA_LATCH_INT, }, 97 98 { "pcal9555a", 16 | PCA953X_TYPE | PCA_LATCH_INT, }, ··· 214 211 struct regulator *regulator; 215 212 216 213 const struct pca953x_reg_config *regs; 214 + 215 + u8 (*recalc_addr)(struct pca953x_chip *chip, int reg, int off); 216 + bool (*check_reg)(struct pca953x_chip *chip, unsigned int reg, 217 + u32 checkbank); 217 218 }; 218 219 219 220 static int pca953x_bank_shift(struct pca953x_chip *chip) ··· 295 288 return true; 296 289 } 297 290 291 + /* 292 + * Unfortunately, whilst the PCAL6534 chip (and compatibles) broadly follow the 293 + * same register layout as the PCAL6524, the spacing of the registers has been 294 + * fundamentally altered by compacting them and thus does not obey the same 295 + * rules, including being able to use bit shifting to determine bank. These 296 + * chips hence need special handling here. 297 + */ 298 + static bool pcal6534_check_register(struct pca953x_chip *chip, unsigned int reg, 299 + u32 checkbank) 300 + { 301 + int bank; 302 + int offset; 303 + 304 + if (reg >= 0x30) { 305 + /* 306 + * Reserved block between 14h and 2Fh does not align on 307 + * expected bank boundaries like other devices. 308 + */ 309 + int temp = reg - 0x30; 310 + 311 + bank = temp / NBANK(chip); 312 + offset = temp - (bank * NBANK(chip)); 313 + bank += 8; 314 + } else if (reg >= 0x54) { 315 + /* 316 + * Handle lack of reserved registers after output port 317 + * configuration register to form a bank. 318 + */ 319 + int temp = reg - 0x54; 320 + 321 + bank = temp / NBANK(chip); 322 + offset = temp - (bank * NBANK(chip)); 323 + bank += 16; 324 + } else { 325 + bank = reg / NBANK(chip); 326 + offset = reg - (bank * NBANK(chip)); 327 + } 328 + 329 + /* Register is not in the matching bank. */ 330 + if (!(BIT(bank) & checkbank)) 331 + return false; 332 + 333 + /* Register is not within allowed range of bank. */ 334 + if (offset >= NBANK(chip)) 335 + return false; 336 + 337 + return true; 338 + } 339 + 298 340 static bool pca953x_readable_register(struct device *dev, unsigned int reg) 299 341 { 300 342 struct pca953x_chip *chip = dev_get_drvdata(dev); 301 343 u32 bank; 302 344 303 - if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) { 304 - bank = PCA953x_BANK_INPUT | PCA953x_BANK_OUTPUT | 305 - PCA953x_BANK_POLARITY | PCA953x_BANK_CONFIG; 306 - } else { 345 + if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE) { 307 346 bank = PCA957x_BANK_INPUT | PCA957x_BANK_OUTPUT | 308 347 PCA957x_BANK_POLARITY | PCA957x_BANK_CONFIG | 309 348 PCA957x_BANK_BUSHOLD; 349 + } else { 350 + bank = PCA953x_BANK_INPUT | PCA953x_BANK_OUTPUT | 351 + PCA953x_BANK_POLARITY | PCA953x_BANK_CONFIG; 310 352 } 311 353 312 354 if (chip->driver_data & PCA_PCAL) { ··· 364 308 PCAL9xxx_BANK_IRQ_STAT; 365 309 } 366 310 367 - return pca953x_check_register(chip, reg, bank); 311 + return chip->check_reg(chip, reg, bank); 368 312 } 369 313 370 314 static bool pca953x_writeable_register(struct device *dev, unsigned int reg) ··· 372 316 struct pca953x_chip *chip = dev_get_drvdata(dev); 373 317 u32 bank; 374 318 375 - if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) { 376 - bank = PCA953x_BANK_OUTPUT | PCA953x_BANK_POLARITY | 377 - PCA953x_BANK_CONFIG; 378 - } else { 319 + if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE) { 379 320 bank = PCA957x_BANK_OUTPUT | PCA957x_BANK_POLARITY | 380 321 PCA957x_BANK_CONFIG | PCA957x_BANK_BUSHOLD; 322 + } else { 323 + bank = PCA953x_BANK_OUTPUT | PCA953x_BANK_POLARITY | 324 + PCA953x_BANK_CONFIG; 381 325 } 382 326 383 327 if (chip->driver_data & PCA_PCAL) 384 328 bank |= PCAL9xxx_BANK_IN_LATCH | PCAL9xxx_BANK_PULL_EN | 385 329 PCAL9xxx_BANK_PULL_SEL | PCAL9xxx_BANK_IRQ_MASK; 386 330 387 - return pca953x_check_register(chip, reg, bank); 331 + return chip->check_reg(chip, reg, bank); 388 332 } 389 333 390 334 static bool pca953x_volatile_register(struct device *dev, unsigned int reg) ··· 392 336 struct pca953x_chip *chip = dev_get_drvdata(dev); 393 337 u32 bank; 394 338 395 - if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) 396 - bank = PCA953x_BANK_INPUT; 397 - else 339 + if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE) 398 340 bank = PCA957x_BANK_INPUT; 341 + else 342 + bank = PCA953x_BANK_INPUT; 399 343 400 344 if (chip->driver_data & PCA_PCAL) 401 345 bank |= PCAL9xxx_BANK_IRQ_STAT; 402 346 403 - return pca953x_check_register(chip, reg, bank); 347 + return chip->check_reg(chip, reg, bank); 404 348 } 405 349 406 350 static const struct regmap_config pca953x_i2c_regmap = { ··· 445 389 return regaddr; 446 390 } 447 391 392 + /* 393 + * The PCAL6534 and compatible chips have altered bank alignment that doesn't 394 + * fit within the bit shifting scheme used for other devices. 395 + */ 396 + static u8 pcal6534_recalc_addr(struct pca953x_chip *chip, int reg, int off) 397 + { 398 + int addr; 399 + int pinctrl; 400 + 401 + addr = (reg & PCAL_GPIO_MASK) * NBANK(chip); 402 + 403 + switch (reg) { 404 + case PCAL953X_OUT_STRENGTH: 405 + case PCAL953X_IN_LATCH: 406 + case PCAL953X_PULL_EN: 407 + case PCAL953X_PULL_SEL: 408 + case PCAL953X_INT_MASK: 409 + case PCAL953X_INT_STAT: 410 + case PCAL953X_OUT_CONF: 411 + pinctrl = ((reg & PCAL_PINCTRL_MASK) >> 1) + 0x20; 412 + break; 413 + case PCAL6524_INT_EDGE: 414 + case PCAL6524_INT_CLR: 415 + case PCAL6524_IN_STATUS: 416 + case PCAL6524_OUT_INDCONF: 417 + case PCAL6524_DEBOUNCE: 418 + pinctrl = ((reg & PCAL_PINCTRL_MASK) >> 1) + 0x1c; 419 + break; 420 + } 421 + 422 + return pinctrl + addr + (off / BANK_SZ); 423 + } 424 + 448 425 static int pca953x_write_regs(struct pca953x_chip *chip, int reg, unsigned long *val) 449 426 { 450 - u8 regaddr = pca953x_recalc_addr(chip, reg, 0); 427 + u8 regaddr = chip->recalc_addr(chip, reg, 0); 451 428 u8 value[MAX_BANK]; 452 429 int i, ret; 453 430 ··· 498 409 499 410 static int pca953x_read_regs(struct pca953x_chip *chip, int reg, unsigned long *val) 500 411 { 501 - u8 regaddr = pca953x_recalc_addr(chip, reg, 0); 412 + u8 regaddr = chip->recalc_addr(chip, reg, 0); 502 413 u8 value[MAX_BANK]; 503 414 int i, ret; 504 415 ··· 517 428 static int pca953x_gpio_direction_input(struct gpio_chip *gc, unsigned off) 518 429 { 519 430 struct pca953x_chip *chip = gpiochip_get_data(gc); 520 - u8 dirreg = pca953x_recalc_addr(chip, chip->regs->direction, off); 431 + u8 dirreg = chip->recalc_addr(chip, chip->regs->direction, off); 521 432 u8 bit = BIT(off % BANK_SZ); 522 433 int ret; 523 434 ··· 531 442 unsigned off, int val) 532 443 { 533 444 struct pca953x_chip *chip = gpiochip_get_data(gc); 534 - u8 dirreg = pca953x_recalc_addr(chip, chip->regs->direction, off); 535 - u8 outreg = pca953x_recalc_addr(chip, chip->regs->output, off); 445 + u8 dirreg = chip->recalc_addr(chip, chip->regs->direction, off); 446 + u8 outreg = chip->recalc_addr(chip, chip->regs->output, off); 536 447 u8 bit = BIT(off % BANK_SZ); 537 448 int ret; 538 449 ··· 552 463 static int pca953x_gpio_get_value(struct gpio_chip *gc, unsigned off) 553 464 { 554 465 struct pca953x_chip *chip = gpiochip_get_data(gc); 555 - u8 inreg = pca953x_recalc_addr(chip, chip->regs->input, off); 466 + u8 inreg = chip->recalc_addr(chip, chip->regs->input, off); 556 467 u8 bit = BIT(off % BANK_SZ); 557 468 u32 reg_val; 558 469 int ret; ··· 569 480 static void pca953x_gpio_set_value(struct gpio_chip *gc, unsigned off, int val) 570 481 { 571 482 struct pca953x_chip *chip = gpiochip_get_data(gc); 572 - u8 outreg = pca953x_recalc_addr(chip, chip->regs->output, off); 483 + u8 outreg = chip->recalc_addr(chip, chip->regs->output, off); 573 484 u8 bit = BIT(off % BANK_SZ); 574 485 575 486 mutex_lock(&chip->i2c_lock); ··· 580 491 static int pca953x_gpio_get_direction(struct gpio_chip *gc, unsigned off) 581 492 { 582 493 struct pca953x_chip *chip = gpiochip_get_data(gc); 583 - u8 dirreg = pca953x_recalc_addr(chip, chip->regs->direction, off); 494 + u8 dirreg = chip->recalc_addr(chip, chip->regs->direction, off); 584 495 u8 bit = BIT(off % BANK_SZ); 585 496 u32 reg_val; 586 497 int ret; ··· 637 548 unsigned int offset, 638 549 unsigned long config) 639 550 { 640 - u8 pull_en_reg = pca953x_recalc_addr(chip, PCAL953X_PULL_EN, offset); 641 - u8 pull_sel_reg = pca953x_recalc_addr(chip, PCAL953X_PULL_SEL, offset); 551 + enum pin_config_param param = pinconf_to_config_param(config); 552 + 553 + u8 pull_en_reg = chip->recalc_addr(chip, PCAL953X_PULL_EN, offset); 554 + u8 pull_sel_reg = chip->recalc_addr(chip, PCAL953X_PULL_SEL, offset); 642 555 u8 bit = BIT(offset % BANK_SZ); 643 556 int ret; 644 557 ··· 654 563 mutex_lock(&chip->i2c_lock); 655 564 656 565 /* Configure pull-up/pull-down */ 657 - if (config == PIN_CONFIG_BIAS_PULL_UP) 566 + if (param == PIN_CONFIG_BIAS_PULL_UP) 658 567 ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, bit); 659 - else if (config == PIN_CONFIG_BIAS_PULL_DOWN) 568 + else if (param == PIN_CONFIG_BIAS_PULL_DOWN) 660 569 ret = regmap_write_bits(chip->regmap, pull_sel_reg, bit, 0); 661 570 else 662 571 ret = 0; ··· 664 573 goto exit; 665 574 666 575 /* Disable/Enable pull-up/pull-down */ 667 - if (config == PIN_CONFIG_BIAS_DISABLE) 576 + if (param == PIN_CONFIG_BIAS_DISABLE) 668 577 ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, 0); 669 578 else 670 579 ret = regmap_write_bits(chip->regmap, pull_en_reg, bit, bit); ··· 1003 912 u8 regaddr; 1004 913 int ret; 1005 914 1006 - regaddr = pca953x_recalc_addr(chip, chip->regs->output, 0); 915 + regaddr = chip->recalc_addr(chip, chip->regs->output, 0); 1007 916 ret = regcache_sync_region(chip->regmap, regaddr, 1008 917 regaddr + NBANK(chip) - 1); 1009 918 if (ret) 1010 919 goto out; 1011 920 1012 - regaddr = pca953x_recalc_addr(chip, chip->regs->direction, 0); 921 + regaddr = chip->recalc_addr(chip, chip->regs->direction, 0); 1013 922 ret = regcache_sync_region(chip->regmap, regaddr, 1014 923 regaddr + NBANK(chip) - 1); 1015 924 if (ret) ··· 1128 1037 regmap_config = &pca953x_i2c_regmap; 1129 1038 } 1130 1039 1040 + if (PCA_CHIP_TYPE(chip->driver_data) == PCAL653X_TYPE) { 1041 + chip->recalc_addr = pcal6534_recalc_addr; 1042 + chip->check_reg = pcal6534_check_register; 1043 + } else { 1044 + chip->recalc_addr = pca953x_recalc_addr; 1045 + chip->check_reg = pca953x_check_register; 1046 + } 1047 + 1131 1048 chip->regmap = devm_regmap_init_i2c(client, regmap_config); 1132 1049 if (IS_ERR(chip->regmap)) { 1133 1050 ret = PTR_ERR(chip->regmap); ··· 1167 1068 /* initialize cached registers from their original values. 1168 1069 * we can't share this chip with another i2c master. 1169 1070 */ 1170 - 1171 - if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) { 1172 - chip->regs = &pca953x_regs; 1173 - ret = device_pca95xx_init(chip, invert); 1174 - } else { 1071 + if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE) { 1175 1072 chip->regs = &pca957x_regs; 1176 1073 ret = device_pca957x_init(chip, invert); 1074 + } else { 1075 + chip->regs = &pca953x_regs; 1076 + ret = device_pca95xx_init(chip, invert); 1177 1077 } 1178 1078 if (ret) 1179 1079 goto err_exit; ··· 1223 1125 * The ordering between direction and output is important, 1224 1126 * sync these registers first and only then sync the rest. 1225 1127 */ 1226 - regaddr = pca953x_recalc_addr(chip, chip->regs->direction, 0); 1128 + regaddr = chip->recalc_addr(chip, chip->regs->direction, 0); 1227 1129 ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip) - 1); 1228 1130 if (ret) { 1229 1131 dev_err(dev, "Failed to sync GPIO dir registers: %d\n", ret); 1230 1132 return ret; 1231 1133 } 1232 1134 1233 - regaddr = pca953x_recalc_addr(chip, chip->regs->output, 0); 1135 + regaddr = chip->recalc_addr(chip, chip->regs->output, 0); 1234 1136 ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip) - 1); 1235 1137 if (ret) { 1236 1138 dev_err(dev, "Failed to sync GPIO out registers: %d\n", ret); ··· 1239 1141 1240 1142 #ifdef CONFIG_GPIO_PCA953X_IRQ 1241 1143 if (chip->driver_data & PCA_PCAL) { 1242 - regaddr = pca953x_recalc_addr(chip, PCAL953X_IN_LATCH, 0); 1144 + regaddr = chip->recalc_addr(chip, PCAL953X_IN_LATCH, 0); 1243 1145 ret = regcache_sync_region(chip->regmap, regaddr, 1244 1146 regaddr + NBANK(chip) - 1); 1245 1147 if (ret) { ··· 1248 1150 return ret; 1249 1151 } 1250 1152 1251 - regaddr = pca953x_recalc_addr(chip, PCAL953X_INT_MASK, 0); 1153 + regaddr = chip->recalc_addr(chip, PCAL953X_INT_MASK, 0); 1252 1154 ret = regcache_sync_region(chip->regmap, regaddr, 1253 1155 regaddr + NBANK(chip) - 1); 1254 1156 if (ret) { ··· 1312 1214 #endif 1313 1215 1314 1216 /* convenience to stop overlong match-table lines */ 1217 + #define OF_653X(__nrgpio, __int) ((void *)(__nrgpio | PCAL653X_TYPE | __int)) 1315 1218 #define OF_953X(__nrgpio, __int) (void *)(__nrgpio | PCA953X_TYPE | __int) 1316 1219 #define OF_957X(__nrgpio, __int) (void *)(__nrgpio | PCA957X_TYPE | __int) 1317 1220 ··· 1335 1236 { .compatible = "nxp,pca9575", .data = OF_957X(16, PCA_INT), }, 1336 1237 { .compatible = "nxp,pca9698", .data = OF_953X(40, 0), }, 1337 1238 1239 + { .compatible = "nxp,pcal6408", .data = OF_953X(8, PCA_LATCH_INT), }, 1338 1240 { .compatible = "nxp,pcal6416", .data = OF_953X(16, PCA_LATCH_INT), }, 1339 1241 { .compatible = "nxp,pcal6524", .data = OF_953X(24, PCA_LATCH_INT), }, 1242 + { .compatible = "nxp,pcal6534", .data = OF_653X(34, PCA_LATCH_INT), }, 1340 1243 { .compatible = "nxp,pcal9535", .data = OF_953X(16, PCA_LATCH_INT), }, 1341 1244 { .compatible = "nxp,pcal9554b", .data = OF_953X( 8, PCA_LATCH_INT), }, 1342 1245 { .compatible = "nxp,pcal9555a", .data = OF_953X(16, PCA_LATCH_INT), },
+5 -16
drivers/gpio/gpio-rockchip.c
··· 325 325 { 326 326 struct irq_chip *chip = irq_desc_get_chip(desc); 327 327 struct rockchip_pin_bank *bank = irq_desc_get_handler_data(desc); 328 - u32 pend; 328 + unsigned long pending; 329 + unsigned int irq; 329 330 330 331 dev_dbg(bank->dev, "got irq for bank %s\n", bank->name); 331 332 332 333 chained_irq_enter(chip, desc); 333 334 334 - pend = readl_relaxed(bank->reg_base + bank->gpio_regs->int_status); 335 - 336 - while (pend) { 337 - unsigned int irq, virq; 338 - 339 - irq = __ffs(pend); 340 - pend &= ~BIT(irq); 341 - virq = irq_find_mapping(bank->domain, irq); 342 - 343 - if (!virq) { 344 - dev_err(bank->dev, "unmapped irq %d\n", irq); 345 - continue; 346 - } 347 - 335 + pending = readl_relaxed(bank->reg_base + bank->gpio_regs->int_status); 336 + for_each_set_bit(irq, &pending, 32) { 348 337 dev_dbg(bank->dev, "handling irq %d\n", irq); 349 338 350 339 /* ··· 367 378 } while ((data & BIT(irq)) != (data_old & BIT(irq))); 368 379 } 369 380 370 - generic_handle_irq(virq); 381 + generic_handle_domain_irq(bank->domain, irq); 371 382 } 372 383 373 384 chained_irq_exit(chip, desc);
+6 -2
drivers/gpio/gpio-tc3589x.c
··· 230 230 231 231 tc3589x_gpio->regs[REG_IE][regoffset] &= ~mask; 232 232 tc3589x_gpio->regs[REG_DIRECT][regoffset] |= mask; 233 + gpiochip_disable_irq(gc, offset); 233 234 } 234 235 235 236 static void tc3589x_gpio_irq_unmask(struct irq_data *d) ··· 241 240 int regoffset = offset / 8; 242 241 int mask = BIT(offset % 8); 243 242 243 + gpiochip_enable_irq(gc, offset); 244 244 tc3589x_gpio->regs[REG_IE][regoffset] |= mask; 245 245 tc3589x_gpio->regs[REG_DIRECT][regoffset] &= ~mask; 246 246 } 247 247 248 - static struct irq_chip tc3589x_gpio_irq_chip = { 248 + static const struct irq_chip tc3589x_gpio_irq_chip = { 249 249 .name = "tc3589x-gpio", 250 250 .irq_bus_lock = tc3589x_gpio_irq_lock, 251 251 .irq_bus_sync_unlock = tc3589x_gpio_irq_sync_unlock, 252 252 .irq_mask = tc3589x_gpio_irq_mask, 253 253 .irq_unmask = tc3589x_gpio_irq_unmask, 254 254 .irq_set_type = tc3589x_gpio_irq_set_type, 255 + .flags = IRQCHIP_IMMUTABLE, 256 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 255 257 }; 256 258 257 259 static irqreturn_t tc3589x_gpio_irq(int irq, void *dev) ··· 325 321 tc3589x_gpio->chip.base = -1; 326 322 327 323 girq = &tc3589x_gpio->chip.irq; 328 - girq->chip = &tc3589x_gpio_irq_chip; 324 + gpio_irq_chip_set_chip(girq, &tc3589x_gpio_irq_chip); 329 325 /* This will let us handle the parent IRQ in the driver */ 330 326 girq->parent_handler = NULL; 331 327 girq->num_parents = 0;
+12 -14
drivers/gpio/gpio-twl4030.c
··· 465 465 REG_GPIO_DEBEN1, 3); 466 466 } 467 467 468 - static int gpio_twl4030_remove(struct platform_device *pdev); 469 - 470 468 static struct twl4030_gpio_platform_data *of_gpio_twl4030(struct device *dev, 471 469 struct twl4030_gpio_platform_data *pdata) 472 470 { ··· 490 492 &omap_twl_info->pulldowns); 491 493 492 494 return omap_twl_info; 495 + } 496 + 497 + /* Cannot use as gpio_twl4030_probe() calls us */ 498 + static int gpio_twl4030_remove(struct platform_device *pdev) 499 + { 500 + struct gpio_twl4030_priv *priv = platform_get_drvdata(pdev); 501 + 502 + gpiochip_remove(&priv->gpio_chip); 503 + 504 + /* REVISIT no support yet for deregistering all the IRQs */ 505 + WARN_ON(!is_module()); 506 + return 0; 493 507 } 494 508 495 509 static int gpio_twl4030_probe(struct platform_device *pdev) ··· 598 588 599 589 out: 600 590 return ret; 601 - } 602 - 603 - /* Cannot use as gpio_twl4030_probe() calls us */ 604 - static int gpio_twl4030_remove(struct platform_device *pdev) 605 - { 606 - struct gpio_twl4030_priv *priv = platform_get_drvdata(pdev); 607 - 608 - gpiochip_remove(&priv->gpio_chip); 609 - 610 - /* REVISIT no support yet for deregistering all the IRQs */ 611 - WARN_ON(!is_module()); 612 - return 0; 613 591 } 614 592 615 593 static const struct of_device_id twl_gpio_match[] = {
+1
drivers/gpio/gpio-ucb1400.c
··· 7 7 8 8 #include <linux/module.h> 9 9 #include <linux/ucb1400.h> 10 + #include <linux/gpio/driver.h> 10 11 11 12 static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off) 12 13 {
+3 -2
drivers/gpio/gpio-ws16c48.c
··· 27 27 MODULE_PARM_DESC(base, "WinSystems WS16C48 base addresses"); 28 28 29 29 static unsigned int irq[MAX_NUM_WS16C48]; 30 - module_param_hw_array(irq, uint, irq, NULL, 0); 30 + static unsigned int num_irq; 31 + module_param_hw_array(irq, uint, irq, &num_irq, 0); 31 32 MODULE_PARM_DESC(irq, "WinSystems WS16C48 interrupt line numbers"); 32 33 33 34 /** ··· 502 501 }, 503 502 }; 504 503 505 - module_isa_driver(ws16c48_driver, num_ws16c48); 504 + module_isa_driver_with_irq(ws16c48_driver, num_ws16c48, num_irq); 506 505 507 506 MODULE_AUTHOR("William Breathitt Gray <vilhelm.gray@gmail.com>"); 508 507 MODULE_DESCRIPTION("WinSystems WS16C48 GPIO driver");
+34 -4
drivers/gpio/gpiolib-acpi.c
··· 32 32 "controller@pin combos on which to ignore the ACPI wake flag " 33 33 "ignore_wake=controller@pin[,controller@pin[,...]]"); 34 34 35 + static char *ignore_interrupt; 36 + module_param(ignore_interrupt, charp, 0444); 37 + MODULE_PARM_DESC(ignore_interrupt, 38 + "controller@pin combos on which to ignore interrupt " 39 + "ignore_interrupt=controller@pin[,controller@pin[,...]]"); 40 + 35 41 struct acpi_gpiolib_dmi_quirk { 36 42 bool no_edge_events_on_boot; 37 43 char *ignore_wake; 44 + char *ignore_interrupt; 38 45 }; 39 46 40 47 /** ··· 324 317 return desc; 325 318 } 326 319 327 - static bool acpi_gpio_in_ignore_list(const char *controller_in, unsigned int pin_in) 320 + static bool acpi_gpio_in_ignore_list(const char *ignore_list, const char *controller_in, 321 + unsigned int pin_in) 328 322 { 329 323 const char *controller, *pin_str; 330 324 unsigned int pin; 331 325 char *endp; 332 326 int len; 333 327 334 - controller = ignore_wake; 328 + controller = ignore_list; 335 329 while (controller) { 336 330 pin_str = strchr(controller, '@'); 337 331 if (!pin_str) ··· 356 348 357 349 return false; 358 350 err: 359 - pr_err_once("Error: Invalid value for gpiolib_acpi.ignore_wake: %s\n", ignore_wake); 351 + pr_err_once("Error: Invalid value for gpiolib_acpi.ignore_...: %s\n", ignore_list); 360 352 return false; 361 353 } 362 354 ··· 368 360 if (agpio->wake_capable != ACPI_WAKE_CAPABLE) 369 361 return false; 370 362 371 - if (acpi_gpio_in_ignore_list(dev_name(parent), pin)) { 363 + if (acpi_gpio_in_ignore_list(ignore_wake, dev_name(parent), pin)) { 372 364 dev_info(parent, "Ignoring wakeup on pin %u\n", pin); 373 365 return false; 374 366 } ··· 433 425 "Failed to translate GPIO pin 0x%04X to IRQ, err %d\n", 434 426 pin, irq); 435 427 goto fail_unlock_irq; 428 + } 429 + 430 + if (acpi_gpio_in_ignore_list(ignore_interrupt, dev_name(chip->parent), pin)) { 431 + dev_info(chip->parent, "Ignoring interrupt on pin %u\n", pin); 432 + return AE_OK; 436 433 } 437 434 438 435 event = kzalloc(sizeof(*event), GFP_KERNEL); ··· 1576 1563 .ignore_wake = "INT33FF:01@0", 1577 1564 }, 1578 1565 }, 1566 + { 1567 + /* 1568 + * Interrupt storm caused from edge triggered floating pin 1569 + * Found in BIOS UX325UAZ.300 1570 + * https://bugzilla.kernel.org/show_bug.cgi?id=216208 1571 + */ 1572 + .matches = { 1573 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), 1574 + DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX325UAZ_UM325UAZ"), 1575 + }, 1576 + .driver_data = &(struct acpi_gpiolib_dmi_quirk) { 1577 + .ignore_interrupt = "AMDI0030:00@18", 1578 + }, 1579 + }, 1579 1580 {} /* Terminating entry */ 1580 1581 }; 1581 1582 ··· 1611 1584 1612 1585 if (ignore_wake == NULL && quirk && quirk->ignore_wake) 1613 1586 ignore_wake = quirk->ignore_wake; 1587 + 1588 + if (ignore_interrupt == NULL && quirk && quirk->ignore_interrupt) 1589 + ignore_interrupt = quirk->ignore_interrupt; 1614 1590 1615 1591 return 0; 1616 1592 }
+18
drivers/gpio/gpiolib-cdev.c
··· 1497 1497 return 0; 1498 1498 } 1499 1499 1500 + #ifdef CONFIG_PROC_FS 1501 + static void linereq_show_fdinfo(struct seq_file *out, struct file *file) 1502 + { 1503 + struct linereq *lr = file->private_data; 1504 + struct device *dev = &lr->gdev->dev; 1505 + u16 i; 1506 + 1507 + seq_printf(out, "gpio-chip:\t%s\n", dev_name(dev)); 1508 + 1509 + for (i = 0; i < lr->num_lines; i++) 1510 + seq_printf(out, "gpio-line:\t%d\n", 1511 + gpio_chip_hwgpio(lr->lines[i].desc)); 1512 + } 1513 + #endif 1514 + 1500 1515 static const struct file_operations line_fileops = { 1501 1516 .release = linereq_release, 1502 1517 .read = linereq_read, ··· 1521 1506 .unlocked_ioctl = linereq_ioctl, 1522 1507 #ifdef CONFIG_COMPAT 1523 1508 .compat_ioctl = linereq_ioctl_compat, 1509 + #endif 1510 + #ifdef CONFIG_PROC_FS 1511 + .show_fdinfo = linereq_show_fdinfo, 1524 1512 #endif 1525 1513 }; 1526 1514
+74 -110
drivers/gpio/gpiolib-of.c
··· 289 289 } 290 290 EXPORT_SYMBOL_GPL(of_get_named_gpio_flags); 291 291 292 + /* Converts gpio_lookup_flags into bitmask of GPIO_* values */ 293 + static unsigned long of_convert_gpio_flags(enum of_gpio_flags flags) 294 + { 295 + unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; 296 + 297 + if (flags & OF_GPIO_ACTIVE_LOW) 298 + lflags |= GPIO_ACTIVE_LOW; 299 + 300 + if (flags & OF_GPIO_SINGLE_ENDED) { 301 + if (flags & OF_GPIO_OPEN_DRAIN) 302 + lflags |= GPIO_OPEN_DRAIN; 303 + else 304 + lflags |= GPIO_OPEN_SOURCE; 305 + } 306 + 307 + if (flags & OF_GPIO_TRANSITORY) 308 + lflags |= GPIO_TRANSITORY; 309 + 310 + if (flags & OF_GPIO_PULL_UP) 311 + lflags |= GPIO_PULL_UP; 312 + 313 + if (flags & OF_GPIO_PULL_DOWN) 314 + lflags |= GPIO_PULL_DOWN; 315 + 316 + if (flags & OF_GPIO_PULL_DISABLE) 317 + lflags |= GPIO_PULL_DISABLE; 318 + 319 + return lflags; 320 + } 321 + 292 322 /** 293 323 * gpiod_get_from_of_node() - obtain a GPIO from an OF node 294 324 * @node: handle of the OF node ··· 338 308 enum gpiod_flags dflags, 339 309 const char *label) 340 310 { 341 - unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; 311 + unsigned long lflags; 342 312 struct gpio_desc *desc; 343 - enum of_gpio_flags flags; 344 - bool active_low = false; 345 - bool single_ended = false; 346 - bool open_drain = false; 347 - bool transitory = false; 313 + enum of_gpio_flags of_flags; 348 314 int ret; 349 315 350 - desc = of_get_named_gpiod_flags(node, propname, 351 - index, &flags); 352 - 353 - if (!desc || IS_ERR(desc)) { 316 + desc = of_get_named_gpiod_flags(node, propname, index, &of_flags); 317 + if (!desc || IS_ERR(desc)) 354 318 return desc; 355 - } 356 - 357 - active_low = flags & OF_GPIO_ACTIVE_LOW; 358 - single_ended = flags & OF_GPIO_SINGLE_ENDED; 359 - open_drain = flags & OF_GPIO_OPEN_DRAIN; 360 - transitory = flags & OF_GPIO_TRANSITORY; 361 319 362 320 ret = gpiod_request(desc, label); 363 321 if (ret == -EBUSY && (dflags & GPIOD_FLAGS_BIT_NONEXCLUSIVE)) ··· 353 335 if (ret) 354 336 return ERR_PTR(ret); 355 337 356 - if (active_low) 357 - lflags |= GPIO_ACTIVE_LOW; 358 - 359 - if (single_ended) { 360 - if (open_drain) 361 - lflags |= GPIO_OPEN_DRAIN; 362 - else 363 - lflags |= GPIO_OPEN_SOURCE; 364 - } 365 - 366 - if (transitory) 367 - lflags |= GPIO_TRANSITORY; 368 - 369 - if (flags & OF_GPIO_PULL_UP) 370 - lflags |= GPIO_PULL_UP; 371 - 372 - if (flags & OF_GPIO_PULL_DOWN) 373 - lflags |= GPIO_PULL_DOWN; 374 - 375 - if (flags & OF_GPIO_PULL_DISABLE) 376 - lflags |= GPIO_PULL_DISABLE; 338 + lflags = of_convert_gpio_flags(of_flags); 377 339 378 340 ret = gpiod_configure_flags(desc, propname, lflags, dflags); 379 341 if (ret < 0) { ··· 370 372 * properties should be named "foo-gpios" so we have this special kludge for 371 373 * them. 372 374 */ 373 - static struct gpio_desc *of_find_spi_gpio(struct device *dev, const char *con_id, 375 + static struct gpio_desc *of_find_spi_gpio(struct device_node *np, 376 + const char *con_id, 377 + unsigned int idx, 374 378 enum of_gpio_flags *of_flags) 375 379 { 376 380 char prop_name[32]; /* 32 is max size of property name */ 377 - const struct device_node *np = dev->of_node; 378 - struct gpio_desc *desc; 379 381 380 382 /* 381 383 * Hopefully the compiler stubs the rest of the function if this ··· 391 393 /* Will be "gpio-sck", "gpio-mosi" or "gpio-miso" */ 392 394 snprintf(prop_name, sizeof(prop_name), "%s-%s", "gpio", con_id); 393 395 394 - desc = of_get_named_gpiod_flags(np, prop_name, 0, of_flags); 395 - return desc; 396 + return of_get_named_gpiod_flags(np, prop_name, idx, of_flags); 396 397 } 397 398 398 399 /* ··· 399 402 * lines rather than "cs-gpios" like all other SPI hardware. Account for this 400 403 * with a special quirk. 401 404 */ 402 - static struct gpio_desc *of_find_spi_cs_gpio(struct device *dev, 405 + static struct gpio_desc *of_find_spi_cs_gpio(struct device_node *np, 403 406 const char *con_id, 404 407 unsigned int idx, 405 - unsigned long *flags) 408 + enum of_gpio_flags *of_flags) 406 409 { 407 - const struct device_node *np = dev->of_node; 408 - 409 410 if (!IS_ENABLED(CONFIG_SPI_MASTER)) 410 411 return ERR_PTR(-ENOENT); 411 412 ··· 421 426 * uses just "gpios" so translate to that when "cs-gpios" is 422 427 * requested. 423 428 */ 424 - return of_find_gpio(dev, NULL, idx, flags); 429 + return of_get_named_gpiod_flags(np, "gpios", idx, of_flags); 425 430 } 426 431 427 432 /* ··· 429 434 * properties should be named "foo-gpios" so we have this special kludge for 430 435 * them. 431 436 */ 432 - static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char *con_id, 437 + static struct gpio_desc *of_find_regulator_gpio(struct device_node *np, 438 + const char *con_id, 439 + unsigned int idx, 433 440 enum of_gpio_flags *of_flags) 434 441 { 435 442 /* These are the connection IDs we accept as legacy GPIO phandles */ ··· 440 443 "wlf,ldo1ena", /* WM8994 */ 441 444 "wlf,ldo2ena", /* WM8994 */ 442 445 }; 443 - const struct device_node *np = dev->of_node; 444 - struct gpio_desc *desc; 445 446 int i; 446 447 447 448 if (!IS_ENABLED(CONFIG_REGULATOR)) ··· 452 457 if (i < 0) 453 458 return ERR_PTR(-ENOENT); 454 459 455 - desc = of_get_named_gpiod_flags(np, con_id, 0, of_flags); 456 - return desc; 460 + return of_get_named_gpiod_flags(np, con_id, idx, of_flags); 457 461 } 458 462 459 - static struct gpio_desc *of_find_arizona_gpio(struct device *dev, 463 + static struct gpio_desc *of_find_arizona_gpio(struct device_node *np, 460 464 const char *con_id, 465 + unsigned int idx, 461 466 enum of_gpio_flags *of_flags) 462 467 { 463 468 if (!IS_ENABLED(CONFIG_MFD_ARIZONA)) ··· 466 471 if (!con_id || strcmp(con_id, "wlf,reset")) 467 472 return ERR_PTR(-ENOENT); 468 473 469 - return of_get_named_gpiod_flags(dev->of_node, con_id, 0, of_flags); 474 + return of_get_named_gpiod_flags(np, con_id, idx, of_flags); 470 475 } 471 476 472 - static struct gpio_desc *of_find_usb_gpio(struct device *dev, 477 + static struct gpio_desc *of_find_usb_gpio(struct device_node *np, 473 478 const char *con_id, 479 + unsigned int idx, 474 480 enum of_gpio_flags *of_flags) 475 481 { 476 482 /* 477 - * Currently this USB quirk is only for the Fairchild FUSB302 host which is using 478 - * an undocumented DT GPIO line named "fcs,int_n" without the compulsory "-gpios" 479 - * suffix. 483 + * Currently this USB quirk is only for the Fairchild FUSB302 host 484 + * which is using an undocumented DT GPIO line named "fcs,int_n" 485 + * without the compulsory "-gpios" suffix. 480 486 */ 481 487 if (!IS_ENABLED(CONFIG_TYPEC_FUSB302)) 482 488 return ERR_PTR(-ENOENT); ··· 485 489 if (!con_id || strcmp(con_id, "fcs,int_n")) 486 490 return ERR_PTR(-ENOENT); 487 491 488 - return of_get_named_gpiod_flags(dev->of_node, con_id, 0, of_flags); 492 + return of_get_named_gpiod_flags(np, con_id, idx, of_flags); 489 493 } 494 + 495 + typedef struct gpio_desc *(*of_find_gpio_quirk)(struct device_node *np, 496 + const char *con_id, 497 + unsigned int idx, 498 + enum of_gpio_flags *of_flags); 499 + static const of_find_gpio_quirk of_find_gpio_quirks[] = { 500 + of_find_spi_gpio, 501 + of_find_spi_cs_gpio, 502 + of_find_regulator_gpio, 503 + of_find_arizona_gpio, 504 + of_find_usb_gpio, 505 + NULL 506 + }; 490 507 491 508 struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, 492 509 unsigned int idx, unsigned long *flags) 493 510 { 494 511 char prop_name[32]; /* 32 is max size of property name */ 495 512 enum of_gpio_flags of_flags; 513 + const of_find_gpio_quirk *q; 496 514 struct gpio_desc *desc; 497 515 unsigned int i; 498 516 ··· 526 516 break; 527 517 } 528 518 529 - if (gpiod_not_found(desc)) { 530 - /* Special handling for SPI GPIOs if used */ 531 - desc = of_find_spi_gpio(dev, con_id, &of_flags); 532 - } 533 - 534 - if (gpiod_not_found(desc)) { 535 - /* This quirk looks up flags and all */ 536 - desc = of_find_spi_cs_gpio(dev, con_id, idx, flags); 537 - if (!IS_ERR(desc)) 538 - return desc; 539 - } 540 - 541 - if (gpiod_not_found(desc)) { 542 - /* Special handling for regulator GPIOs if used */ 543 - desc = of_find_regulator_gpio(dev, con_id, &of_flags); 544 - } 545 - 546 - if (gpiod_not_found(desc)) 547 - desc = of_find_arizona_gpio(dev, con_id, &of_flags); 548 - 549 - if (gpiod_not_found(desc)) 550 - desc = of_find_usb_gpio(dev, con_id, &of_flags); 519 + /* Properly named GPIO was not found, try workarounds */ 520 + for (q = of_find_gpio_quirks; gpiod_not_found(desc) && *q; q++) 521 + desc = (*q)(dev->of_node, con_id, idx, &of_flags); 551 522 552 523 if (IS_ERR(desc)) 553 524 return desc; 554 525 555 - if (of_flags & OF_GPIO_ACTIVE_LOW) 556 - *flags |= GPIO_ACTIVE_LOW; 557 - 558 - if (of_flags & OF_GPIO_SINGLE_ENDED) { 559 - if (of_flags & OF_GPIO_OPEN_DRAIN) 560 - *flags |= GPIO_OPEN_DRAIN; 561 - else 562 - *flags |= GPIO_OPEN_SOURCE; 563 - } 564 - 565 - if (of_flags & OF_GPIO_TRANSITORY) 566 - *flags |= GPIO_TRANSITORY; 567 - 568 - if (of_flags & OF_GPIO_PULL_UP) 569 - *flags |= GPIO_PULL_UP; 570 - if (of_flags & OF_GPIO_PULL_DOWN) 571 - *flags |= GPIO_PULL_DOWN; 572 - if (of_flags & OF_GPIO_PULL_DISABLE) 573 - *flags |= GPIO_PULL_DISABLE; 526 + *flags = of_convert_gpio_flags(of_flags); 574 527 575 528 return desc; 576 529 } ··· 591 618 if (IS_ERR(desc)) 592 619 return desc; 593 620 594 - if (xlate_flags & OF_GPIO_ACTIVE_LOW) 595 - *lflags |= GPIO_ACTIVE_LOW; 596 - if (xlate_flags & OF_GPIO_TRANSITORY) 597 - *lflags |= GPIO_TRANSITORY; 598 - if (xlate_flags & OF_GPIO_PULL_UP) 599 - *lflags |= GPIO_PULL_UP; 600 - if (xlate_flags & OF_GPIO_PULL_DOWN) 601 - *lflags |= GPIO_PULL_DOWN; 602 - if (xlate_flags & OF_GPIO_PULL_DISABLE) 603 - *lflags |= GPIO_PULL_DISABLE; 621 + *lflags = of_convert_gpio_flags(xlate_flags); 604 622 605 623 if (of_property_read_bool(np, "input")) 606 624 *dflags |= GPIOD_IN;
+66 -66
drivers/gpio/gpiolib.c
··· 3799 3799 } 3800 3800 3801 3801 /** 3802 + * fwnode_get_named_gpiod - obtain a GPIO from firmware node 3803 + * @fwnode: handle of the firmware node 3804 + * @propname: name of the firmware property representing the GPIO 3805 + * @index: index of the GPIO to obtain for the consumer 3806 + * @dflags: GPIO initialization flags 3807 + * @label: label to attach to the requested GPIO 3808 + * 3809 + * This function can be used for drivers that get their configuration 3810 + * from opaque firmware. 3811 + * 3812 + * The function properly finds the corresponding GPIO using whatever is the 3813 + * underlying firmware interface and then makes sure that the GPIO 3814 + * descriptor is requested before it is returned to the caller. 3815 + * 3816 + * Returns: 3817 + * On successful request the GPIO pin is configured in accordance with 3818 + * provided @dflags. 3819 + * 3820 + * In case of error an ERR_PTR() is returned. 3821 + */ 3822 + static struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 3823 + const char *propname, int index, 3824 + enum gpiod_flags dflags, 3825 + const char *label) 3826 + { 3827 + unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; 3828 + struct gpio_desc *desc = ERR_PTR(-ENODEV); 3829 + int ret; 3830 + 3831 + if (is_of_node(fwnode)) { 3832 + desc = gpiod_get_from_of_node(to_of_node(fwnode), 3833 + propname, index, 3834 + dflags, 3835 + label); 3836 + return desc; 3837 + } else if (is_acpi_node(fwnode)) { 3838 + struct acpi_gpio_info info; 3839 + 3840 + desc = acpi_node_get_gpiod(fwnode, propname, index, &info); 3841 + if (IS_ERR(desc)) 3842 + return desc; 3843 + 3844 + acpi_gpio_update_gpiod_flags(&dflags, &info); 3845 + acpi_gpio_update_gpiod_lookup_flags(&lflags, &info); 3846 + } else { 3847 + return ERR_PTR(-EINVAL); 3848 + } 3849 + 3850 + /* Currently only ACPI takes this path */ 3851 + ret = gpiod_request(desc, label); 3852 + if (ret) 3853 + return ERR_PTR(ret); 3854 + 3855 + ret = gpiod_configure_flags(desc, propname, lflags, dflags); 3856 + if (ret < 0) { 3857 + gpiod_put(desc); 3858 + return ERR_PTR(ret); 3859 + } 3860 + 3861 + blocking_notifier_call_chain(&desc->gdev->notifier, 3862 + GPIOLINE_CHANGED_REQUESTED, desc); 3863 + 3864 + return desc; 3865 + } 3866 + 3867 + /** 3802 3868 * fwnode_gpiod_get_index - obtain a GPIO from firmware node 3803 3869 * @fwnode: handle of the firmware node 3804 3870 * @con_id: function within the GPIO consumer ··· 4128 4062 return desc; 4129 4063 } 4130 4064 EXPORT_SYMBOL_GPL(gpiod_get_index); 4131 - 4132 - /** 4133 - * fwnode_get_named_gpiod - obtain a GPIO from firmware node 4134 - * @fwnode: handle of the firmware node 4135 - * @propname: name of the firmware property representing the GPIO 4136 - * @index: index of the GPIO to obtain for the consumer 4137 - * @dflags: GPIO initialization flags 4138 - * @label: label to attach to the requested GPIO 4139 - * 4140 - * This function can be used for drivers that get their configuration 4141 - * from opaque firmware. 4142 - * 4143 - * The function properly finds the corresponding GPIO using whatever is the 4144 - * underlying firmware interface and then makes sure that the GPIO 4145 - * descriptor is requested before it is returned to the caller. 4146 - * 4147 - * Returns: 4148 - * On successful request the GPIO pin is configured in accordance with 4149 - * provided @dflags. 4150 - * 4151 - * In case of error an ERR_PTR() is returned. 4152 - */ 4153 - struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 4154 - const char *propname, int index, 4155 - enum gpiod_flags dflags, 4156 - const char *label) 4157 - { 4158 - unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; 4159 - struct gpio_desc *desc = ERR_PTR(-ENODEV); 4160 - int ret; 4161 - 4162 - if (is_of_node(fwnode)) { 4163 - desc = gpiod_get_from_of_node(to_of_node(fwnode), 4164 - propname, index, 4165 - dflags, 4166 - label); 4167 - return desc; 4168 - } else if (is_acpi_node(fwnode)) { 4169 - struct acpi_gpio_info info; 4170 - 4171 - desc = acpi_node_get_gpiod(fwnode, propname, index, &info); 4172 - if (IS_ERR(desc)) 4173 - return desc; 4174 - 4175 - acpi_gpio_update_gpiod_flags(&dflags, &info); 4176 - acpi_gpio_update_gpiod_lookup_flags(&lflags, &info); 4177 - } else 4178 - return ERR_PTR(-EINVAL); 4179 - 4180 - /* Currently only ACPI takes this path */ 4181 - ret = gpiod_request(desc, label); 4182 - if (ret) 4183 - return ERR_PTR(ret); 4184 - 4185 - ret = gpiod_configure_flags(desc, propname, lflags, dflags); 4186 - if (ret < 0) { 4187 - gpiod_put(desc); 4188 - return ERR_PTR(ret); 4189 - } 4190 - 4191 - blocking_notifier_call_chain(&desc->gdev->notifier, 4192 - GPIOLINE_CHANGED_REQUESTED, desc); 4193 - 4194 - return desc; 4195 - } 4196 - EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod); 4197 4065 4198 4066 /** 4199 4067 * gpiod_get_index_optional - obtain an optional GPIO from a multi-index GPIO
-13
include/linux/gpio/consumer.h
··· 174 174 /* Child properties interface */ 175 175 struct fwnode_handle; 176 176 177 - struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 178 - const char *propname, int index, 179 - enum gpiod_flags dflags, 180 - const char *label); 181 177 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode, 182 178 const char *con_id, int index, 183 179 enum gpiod_flags flags, ··· 548 552 549 553 /* Child properties interface */ 550 554 struct fwnode_handle; 551 - 552 - static inline 553 - struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 554 - const char *propname, int index, 555 - enum gpiod_flags dflags, 556 - const char *label) 557 - { 558 - return ERR_PTR(-ENOSYS); 559 - } 560 555 561 556 static inline 562 557 struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
+42 -10
include/linux/isa.h
··· 38 38 } 39 39 #endif 40 40 41 + #define module_isa_driver_init(__isa_driver, __num_isa_dev) \ 42 + static int __init __isa_driver##_init(void) \ 43 + { \ 44 + return isa_register_driver(&(__isa_driver), __num_isa_dev); \ 45 + } \ 46 + module_init(__isa_driver##_init) 47 + 48 + #define module_isa_driver_with_irq_init(__isa_driver, __num_isa_dev, __num_irq) \ 49 + static int __init __isa_driver##_init(void) \ 50 + { \ 51 + if (__num_irq != __num_isa_dev) { \ 52 + pr_err("%s: Number of irq (%u) does not match number of base (%u)\n", \ 53 + __isa_driver.driver.name, __num_irq, __num_isa_dev); \ 54 + return -EINVAL; \ 55 + } \ 56 + return isa_register_driver(&(__isa_driver), __num_isa_dev); \ 57 + } \ 58 + module_init(__isa_driver##_init) 59 + 60 + #define module_isa_driver_exit(__isa_driver) \ 61 + static void __exit __isa_driver##_exit(void) \ 62 + { \ 63 + isa_unregister_driver(&(__isa_driver)); \ 64 + } \ 65 + module_exit(__isa_driver##_exit) 66 + 41 67 /** 42 68 * module_isa_driver() - Helper macro for registering a ISA driver 43 69 * @__isa_driver: isa_driver struct ··· 74 48 * use this macro once, and calling it replaces module_init and module_exit. 75 49 */ 76 50 #define module_isa_driver(__isa_driver, __num_isa_dev) \ 77 - static int __init __isa_driver##_init(void) \ 78 - { \ 79 - return isa_register_driver(&(__isa_driver), __num_isa_dev); \ 80 - } \ 81 - module_init(__isa_driver##_init); \ 82 - static void __exit __isa_driver##_exit(void) \ 83 - { \ 84 - isa_unregister_driver(&(__isa_driver)); \ 85 - } \ 86 - module_exit(__isa_driver##_exit); 51 + module_isa_driver_init(__isa_driver, __num_isa_dev); \ 52 + module_isa_driver_exit(__isa_driver) 53 + 54 + /** 55 + * module_isa_driver_with_irq() - Helper macro for registering an ISA driver with irq 56 + * @__isa_driver: isa_driver struct 57 + * @__num_isa_dev: number of devices to register 58 + * @__num_irq: number of IRQ to register 59 + * 60 + * Helper macro for ISA drivers with irq that do not do anything special in 61 + * module init/exit. Each module may only use this macro once, and calling it 62 + * replaces module_init and module_exit. 63 + */ 64 + #define module_isa_driver_with_irq(__isa_driver, __num_isa_dev, __num_irq) \ 65 + module_isa_driver_with_irq_init(__isa_driver, __num_isa_dev, __num_irq); \ 66 + module_isa_driver_exit(__isa_driver) 87 67 88 68 /** 89 69 * max_num_isa_dev() - Maximum possible number registered of an ISA device
+1 -1
include/linux/ucb1400.h
··· 23 23 #include <sound/ac97_codec.h> 24 24 #include <linux/mutex.h> 25 25 #include <linux/platform_device.h> 26 - #include <linux/gpio.h> 26 + #include <linux/gpio/driver.h> 27 27 28 28 /* 29 29 * UCB1400 AC-link registers