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

Merge tag 'gpio-v4.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio

Pull GPIO updates from Linus Walleij:
"This is the bulk of GPIO changes for kernel cycle v4.7:

Core infrastructural changes:

- Support for natively single-ended GPIO driver stages.

This means that if the hardware has registers to configure open
drain or open source configuration, we use that rather than (as we
did before) try to emulate it by switching the line to an input to
get high impedance.

This is also documented throughly in Documentation/gpio/driver.txt
for those of you who did not understand one word of what I just
wrote.

- Start to do away with the unnecessarily complex and unitelligible
ARCH_REQUIRE_GPIOLIB and ARCH_WANT_OPTIONAL_GPIOLIB, another
evolutional artifact from the time when the GPIO subsystem was
unmaintained.

Archs can now just select GPIOLIB and be done with it, cleanups to
arches will trickle in for the next kernel. Some minor archs ACKed
the changes immediately so these are included in this pull request.

- Advancing the use of the data pointer inside the GPIO device for
storing driver data by switching the PowerPC, Super-H Unicore and
a few other subarches or subsystem drivers in ALSA SoC, Input,
serial, SSB, staging etc to use it.

- The initialization now reads the input/output state of the GPIO
lines, so that each GPIO descriptor knows - if this callback is
implemented - whether the line is input or output. This also
reflects nicely in userspace "lsgpio".

- It is now possible to name GPIO producer names, line names, from
the device tree. (Platform data has been supported for a while).
I bet we will get a similar mechanism for ACPI one of those days.
This makes is possible to get sensible producer names for e.g.
GPIO rails in "lsgpio" in userspace.

New drivers:

- New driver for the Loongson1.

- The XLP driver now supports Broadcom Vulcan ARM64.

- The IT87 driver now supports IT8620 and IT8628.

- The PCA953X driver now supports Galileo Gen2.

Driver improvements:

- MCP23S08 was switched to use the gpiolib irqchip helpers and now
also suppors level-triggered interrupts.

- 74x164 and RCAR now supports the .set_multiple() callback

- AMDPT was converted to use generic GPIO.

- TC3589x, TPS65218, SX150X, F7188X, MENZ127, VX855, WM831X, WM8994
support the new single ended callback for open drain and in some
cases open source.

- Implement the .get_direction() callback for a few more drivers like
PL061, Xgene.

Cleanups:

- Paul Gortmaker combed through the drivers and de-modularized those
who are not really modules.

- Move the GPIO poweroff DT bindings to the power subdir where they
belong.

- Rename gpio-generic.c to gpio-mmio.c, which is much more to the
point. That's what it is handling, nothing more, nothing less"

* tag 'gpio-v4.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (126 commits)
MIPS: do away with ARCH_[WANT_OPTIONAL|REQUIRE]_GPIOLIB
gpio: zevio: make it explicitly non-modular
gpio: timberdale: make it explicitly non-modular
gpio: stmpe: make it explicitly non-modular
gpio: sodaville: make it explicitly non-modular
pinctrl: sh-pfc: Let gpio_chip.to_irq() return zero on error
gpio: dwapb: Add ACPI device ID for DWAPB GPIO controller on X-Gene platforms
gpio: dt-bindings: add wd,mbl-gpio bindings
gpio: of: make it possible to name GPIO lines
gpio: make gpiod_to_irq() return negative for NO_IRQ
gpio: xgene: implement .get_direction()
gpio: xgene: Enable ACPI support for X-Gene GFC GPIO driver
gpio: tegra: Implement gpio_get_direction callback
gpio: set up initial state from .get_direction()
gpio: rename gpio-generic.c into gpio-mmio.c
gpio: generic: fix GPIO_GENERIC_PLATFORM is set to module case
gpio: dwapb: add gpio-signaled acpi event support
gpio: dwapb: convert device node to fwnode
gpio: dwapb: remove name from dwapb_port_property
gpio/qoriq: select IRQ_DOMAIN
...

+1567 -1170
+3 -1
Documentation/devicetree/bindings/gpio/gpio-74x164.txt
··· 1 1 * Generic 8-bits shift register GPIO driver 2 2 3 3 Required properties: 4 - - compatible : Should be "fairchild,74hc595" 4 + - compatible: Should contain one of the following: 5 + "fairchild,74hc595" 6 + "nxp,74lvc594" 5 7 - reg : chip select number 6 8 - gpio-controller : Marks the device node as a gpio controller. 7 9 - #gpio-cells : Should be two. The first cell is the pin number and
+17 -3
Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt
··· 1 - * Freescale MPC512x/MPC8xxx/Layerscape GPIO controller 1 + * Freescale MPC512x/MPC8xxx/QorIQ/Layerscape GPIO controller 2 2 3 3 Required properties: 4 4 - compatible : Should be "fsl,<soc>-gpio" 5 5 The following <soc>s are known to be supported: 6 - mpc5121, mpc5125, mpc8349, mpc8572, mpc8610, pq3, qoriq. 6 + mpc5121, mpc5125, mpc8349, mpc8572, mpc8610, pq3, qoriq, 7 + ls1021a, ls1043a, ls2080a. 7 8 - reg : Address and length of the register set for the device 8 9 - interrupts : Should be the port interrupt shared by all 32 pins. 9 10 - #gpio-cells : Should be two. The first cell is the pin number and ··· 16 15 - little-endian : GPIO registers are used as little endian. If not 17 16 present registers are used as big endian by default. 18 17 19 - Example: 18 + Example of gpio-controller node for a mpc5125 SoC: 20 19 21 20 gpio0: gpio@1100 { 22 21 compatible = "fsl,mpc5125-gpio"; ··· 24 23 reg = <0x1100 0x080>; 25 24 interrupts = <78 0x8>; 26 25 status = "okay"; 26 + }; 27 + 28 + Example of gpio-controller node for a ls2080a SoC: 29 + 30 + gpio0: gpio@2300000 { 31 + compatible = "fsl,ls2080a-gpio", "fsl,qoriq-gpio"; 32 + reg = <0x0 0x2300000 0x0 0x10000>; 33 + interrupts = <0 36 0x4>; /* Level high type */ 34 + gpio-controller; 35 + little-endian; 36 + #gpio-cells = <2>; 37 + interrupt-controller; 38 + #interrupt-cells = <2>; 27 39 };
Documentation/devicetree/bindings/gpio/gpio-poweroff.txt Documentation/devicetree/bindings/power/reset/gpio-poweroff.txt
Documentation/devicetree/bindings/gpio/gpio-restart.txt Documentation/devicetree/bindings/power/reset/gpio-restart.txt
+3
Documentation/devicetree/bindings/gpio/gpio-xlp.txt
··· 3 3 4 4 This GPIO driver is used for following Netlogic XLP SoCs: 5 5 XLP832, XLP316, XLP208, XLP980, XLP532 6 + This GPIO driver is also compatible with GPIO controller found on 7 + Broadcom Vulcan ARM64. 6 8 7 9 Required properties: 8 10 ------------------- ··· 15 13 - "netlogic,xlp208-gpio": For Netlogic XLP208 16 14 - "netlogic,xlp980-gpio": For Netlogic XLP980 17 15 - "netlogic,xlp532-gpio": For Netlogic XLP532 16 + - "brcm,vulcan-gpio": For Broadcom Vulcan ARM64 18 17 - reg: Physical base address and length of the controller's registers. 19 18 - #gpio-cells: Should be two. The first cell is the pin number and the second 20 19 cell is used to specify optional parameters (currently unused).
+26
Documentation/devicetree/bindings/gpio/gpio.txt
··· 131 131 property, and a #gpio-cells integer property, which indicates the number of 132 132 cells in a gpio-specifier. 133 133 134 + Some system-on-chips (SoCs) use the concept of GPIO banks. A GPIO bank is an 135 + instance of a hardware IP core on a silicon die, usually exposed to the 136 + programmer as a coherent range of I/O addresses. Usually each such bank is 137 + exposed in the device tree as an individual gpio-controller node, reflecting 138 + the fact that the hardware was synthesized by reusing the same IP block a 139 + few times over. 140 + 134 141 Optionally, a GPIO controller may have a "ngpios" property. This property 135 142 indicates the number of in-use slots of available slots for GPIOs. The 136 143 typical example is something like this: the hardware register is 32 bits ··· 152 145 and which are dummies. The bindings for this case has not yet been 153 146 specified, but should be specified if/when such hardware appears. 154 147 148 + Optionally, a GPIO controller may have a "gpio-line-names" property. This is 149 + an array of strings defining the names of the GPIO lines going out of the 150 + GPIO controller. This name should be the most meaningful producer name 151 + for the system, such as a rail name indicating the usage. Package names 152 + such as pin name are discouraged: such lines have opaque names (since they 153 + are by definition generic purpose) and such names are usually not very 154 + helpful. For example "MMC-CD", "Red LED Vdd" and "ethernet reset" are 155 + reasonable line names as they describe what the line is used for. "GPIO0" 156 + is not a good name to give to a GPIO line. Placeholders are discouraged: 157 + rather use the "" (blank string) if the use of the GPIO line is undefined 158 + in your design. The names are assigned starting from line offset 0 from 159 + left to right from the passed array. An incomplete array (where the number 160 + of passed named are less than ngpios) will still be used up until the last 161 + provided valid line index. 162 + 155 163 Example: 156 164 157 165 gpio-controller@00000000 { ··· 175 153 gpio-controller; 176 154 #gpio-cells = <2>; 177 155 ngpios = <18>; 156 + gpio-line-names = "MMC-CD", "MMC-WP", "VDD eth", "RST eth", "LED R", 157 + "LED G", "LED B", "Col A", "Col B", "Col C", "Col D", 158 + "Row A", "Row B", "Row C", "Row D", "NMI button", 159 + "poweroff", "reset"; 178 160 } 179 161 180 162 The GPIO chip may contain GPIO hog definitions. GPIO hogging is a mechanism
+38
Documentation/devicetree/bindings/gpio/wd,mbl-gpio.txt
··· 1 + Bindings for the Western Digital's MyBook Live memory-mapped GPIO controllers. 2 + 3 + The Western Digital MyBook Live has two memory-mapped GPIO controllers. 4 + Both GPIO controller only have a single 8-bit data register, where GPIO 5 + state can be read and/or written. 6 + 7 + Required properties: 8 + - compatible: should be "wd,mbl-gpio" 9 + - reg-names: must contain 10 + "dat" - data register 11 + - reg: address + size pairs describing the GPIO register sets; 12 + order must correspond with the order of entries in reg-names 13 + - #gpio-cells: must be set to 2. The first cell is the pin number and 14 + the second cell is used to specify the gpio polarity: 15 + 0 = active high 16 + 1 = active low 17 + - gpio-controller: Marks the device node as a gpio controller. 18 + 19 + Optional properties: 20 + - no-output: GPIOs are read-only. 21 + 22 + Examples: 23 + gpio0: gpio0@e0000000 { 24 + compatible = "wd,mbl-gpio"; 25 + reg-names = "dat"; 26 + reg = <0xe0000000 0x1>; 27 + #gpio-cells = <2>; 28 + gpio-controller; 29 + }; 30 + 31 + gpio1: gpio1@e0100000 { 32 + compatible = "wd,mbl-gpio"; 33 + reg-names = "dat"; 34 + reg = <0xe0100000 0x1>; 35 + #gpio-cells = <2>; 36 + gpio-controller; 37 + no-output; 38 + };
+97
Documentation/gpio/driver.txt
··· 68 68 on -RT (inside hard IRQ handlers and similar contexts). Normally this should 69 69 not be required. 70 70 71 + 72 + GPIOs with open drain/source support 73 + ------------------------------------ 74 + 75 + Open drain (CMOS) or open collector (TTL) means the line is not actively driven 76 + high: instead you provide the drain/collector as output, so when the transistor 77 + is not open, it will present a high-impedance (tristate) to the external rail. 78 + 79 + 80 + CMOS CONFIGURATION TTL CONFIGURATION 81 + 82 + ||--- out +--- out 83 + in ----|| |/ 84 + ||--+ in ----| 85 + | |\ 86 + GND GND 87 + 88 + This configuration is normally used as a way to achieve one of two things: 89 + 90 + - Level-shifting: to reach a logical level higher than that of the silicon 91 + where the output resides. 92 + 93 + - inverse wire-OR on an I/O line, for example a GPIO line, making it possible 94 + for any driving stage on the line to drive it low even if any other output 95 + to the same line is simultaneously driving it high. A special case of this 96 + is driving the SCL and SCA lines of an I2C bus, which is by definition a 97 + wire-OR bus. 98 + 99 + Both usecases require that the line be equipped with a pull-up resistor. This 100 + resistor will make the line tend to high level unless one of the transistors on 101 + the rail actively pulls it down. 102 + 103 + The level on the line will go as high as the VDD on the pull-up resistor, which 104 + may be higher than the level supported by the transistor, achieveing a 105 + level-shift to the higher VDD. 106 + 107 + Integrated electronics often have an output driver stage in the form of a CMOS 108 + "totem-pole" with one N-MOS and one P-MOS transistor where one of them drives 109 + the line high and one of them drives the line low. This is called a push-pull 110 + output. The "totem-pole" looks like so: 111 + 112 + VDD 113 + | 114 + OD ||--+ 115 + +--/ ---o|| P-MOS-FET 116 + | ||--+ 117 + IN --+ +----- out 118 + | ||--+ 119 + +--/ ----|| N-MOS-FET 120 + OS ||--+ 121 + | 122 + GND 123 + 124 + The desired output signal (e.g. coming directly from some GPIO output register) 125 + arrives at IN. The switches named "OD" and "OS" are normally closed, creating 126 + a push-pull circuit. 127 + 128 + Consider the little "switches" named "OD" and "OS" that enable/disable the 129 + P-MOS or N-MOS transistor right after the split of the input. As you can see, 130 + either transistor will go totally numb if this switch is open. The totem-pole 131 + is then halved and give high impedance instead of actively driving the line 132 + high or low respectively. That is usually how software-controlled open 133 + drain/source works. 134 + 135 + Some GPIO hardware come in open drain / open source configuration. Some are 136 + hard-wired lines that will only support open drain or open source no matter 137 + what: there is only one transistor there. Some are software-configurable: 138 + by flipping a bit in a register the output can be configured as open drain 139 + or open source, in practice by flicking open the switches labeled "OD" and "OS" 140 + in the drawing above. 141 + 142 + By disabling the P-MOS transistor, the output can be driven between GND and 143 + high impedance (open drain), and by disabling the N-MOS transistor, the output 144 + can be driven between VDD and high impedance (open source). In the first case, 145 + a pull-up resistor is needed on the outgoing rail to complete the circuit, and 146 + in the second case, a pull-down resistor is needed on the rail. 147 + 148 + Hardware that supports open drain or open source or both, can implement a 149 + special callback in the gpio_chip: .set_single_ended() that takes an enum flag 150 + telling whether to configure the line as open drain, open source or push-pull. 151 + This will happen in response to the GPIO_OPEN_DRAIN or GPIO_OPEN_SOURCE flag 152 + set in the machine file, or coming from other hardware descriptions. 153 + 154 + If this state can not be configured in hardware, i.e. if the GPIO hardware does 155 + not support open drain/open source in hardware, the GPIO library will instead 156 + use a trick: when a line is set as output, if the line is flagged as open 157 + drain, and the IN output value is low, it will be driven low as usual. But 158 + if the IN output value is set to high, it will instead *NOT* be driven high, 159 + instead it will be switched to input, as input mode is high impedance, thus 160 + achieveing an "open drain emulation" of sorts: electrically the behaviour will 161 + be identical, with the exception of possible hardware glitches when switching 162 + the mode of the line. 163 + 164 + For open source configuration the same principle is used, just that instead 165 + of actively driving the line low, it is set to input. 166 + 167 + 71 168 GPIO drivers providing IRQs 72 169 --------------------------- 73 170 It is custom that GPIO drivers (GPIO chips) are also providing interrupts,
+1
MAINTAINERS
··· 4902 4902 L: linux-gpio@vger.kernel.org 4903 4903 T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git 4904 4904 S: Maintained 4905 + F: Documentation/devicetree/bindings/gpio/ 4905 4906 F: Documentation/gpio/ 4906 4907 F: Documentation/ABI/testing/gpio-cdev 4907 4908 F: Documentation/ABI/obsolete/sysfs-gpio
-1
arch/alpha/Kconfig
··· 13 13 select GENERIC_IRQ_PROBE 14 14 select AUTO_IRQ_AFFINITY if SMP 15 15 select GENERIC_IRQ_SHOW 16 - select ARCH_WANT_OPTIONAL_GPIOLIB 17 16 select ARCH_WANT_IPC_PARSE_VERSION 18 17 select ARCH_HAVE_NMI_SAFE_CMPXCHG 19 18 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
+1 -1
arch/arc/plat-axs10x/Kconfig
··· 13 13 select OF_GPIO 14 14 select MIGHT_HAVE_PCI 15 15 select GENERIC_IRQ_CHIP 16 - select ARCH_REQUIRE_GPIOLIB 16 + select GPIOLIB 17 17 help 18 18 Support for the ARC AXS10x Software Development Platforms. 19 19
+1 -1
arch/arc/plat-tb10x/Kconfig
··· 21 21 select PINCTRL 22 22 select PINCTRL_TB10X 23 23 select PINMUX 24 - select ARCH_REQUIRE_GPIOLIB 24 + select GPIOLIB 25 25 select GPIO_TB10X 26 26 select TB10X_IRQC 27 27 help
+1 -1
arch/avr32/Kconfig
··· 74 74 select SUBARCH_AVR32B 75 75 select MMU 76 76 select PERFORMANCE_COUNTERS 77 - select ARCH_REQUIRE_GPIOLIB 77 + select GPIOLIB 78 78 select GENERIC_ALLOCATOR 79 79 select HAVE_FB_ATMEL 80 80
+1 -1
arch/cris/Kconfig
··· 61 61 select CLONE_BACKWARDS2 62 62 select OLD_SIGSUSPEND 63 63 select OLD_SIGACTION 64 - select ARCH_REQUIRE_GPIOLIB 64 + select GPIOLIB 65 65 select IRQ_DOMAIN if ETRAX_ARCH_V32 66 66 select OF if ETRAX_ARCH_V32 67 67 select OF_EARLY_FLATTREE if ETRAX_ARCH_V32
+1 -1
arch/m68k/Kconfig.cpu
··· 22 22 23 23 config COLDFIRE 24 24 bool "Coldfire CPU family support" 25 - select ARCH_REQUIRE_GPIOLIB 26 25 select ARCH_HAVE_CUSTOM_GPIO_H 27 26 select CPU_HAS_NO_BITFIELDS 28 27 select CPU_HAS_NO_MULDIV64 29 28 select GENERIC_CSUM 29 + select GPIOLIB 30 30 select HAVE_CLK 31 31 32 32 endchoice
-1
arch/metag/Kconfig.soc
··· 16 16 17 17 config SOC_TZ1090 18 18 bool "Toumaz Xenif TZ1090 SoC (Comet)" 19 - select ARCH_WANT_OPTIONAL_GPIOLIB 20 19 select IMGPDC_IRQ 21 20 select METAG_LNKGET_AROUND_CACHE 22 21 select METAG_META21
+15 -17
arch/mips/Kconfig
··· 79 79 select SYS_HAS_CPU_MIPS32_R1 80 80 select SYS_SUPPORTS_32BIT_KERNEL 81 81 select SYS_SUPPORTS_APM_EMULATION 82 - select ARCH_REQUIRE_GPIOLIB 82 + select GPIOLIB 83 83 select SYS_SUPPORTS_ZBOOT 84 84 select COMMON_CLK 85 85 ··· 98 98 select SYS_SUPPORTS_LITTLE_ENDIAN 99 99 select SYS_SUPPORTS_MIPS16 100 100 select SYS_SUPPORTS_ZBOOT_UART16550 101 - select ARCH_REQUIRE_GPIOLIB 101 + select GPIOLIB 102 102 select VLYNQ 103 103 select HAVE_CLK 104 104 help ··· 122 122 config ATH79 123 123 bool "Atheros AR71XX/AR724X/AR913X based boards" 124 124 select ARCH_HAS_RESET_CONTROLLER 125 - select ARCH_REQUIRE_GPIOLIB 126 125 select BOOT_RAW 127 126 select CEVT_R4K 128 127 select CSRC_R4K 129 128 select DMA_NONCOHERENT 129 + select GPIOLIB 130 130 select HAVE_CLK 131 131 select COMMON_CLK 132 132 select CLKDEV_LOOKUP ··· 170 170 select USB_EHCI_BIG_ENDIAN_MMIO if CPU_BIG_ENDIAN 171 171 select USB_OHCI_BIG_ENDIAN_DESC if CPU_BIG_ENDIAN 172 172 select USB_OHCI_BIG_ENDIAN_MMIO if CPU_BIG_ENDIAN 173 - select ARCH_WANT_OPTIONAL_GPIOLIB 174 173 help 175 174 Build a generic DT-based kernel image that boots on select 176 175 BCM33xx cable modem chips, BCM63xx DSL chips, and BCM7xxx set-top ··· 178 179 179 180 config BCM47XX 180 181 bool "Broadcom BCM47XX based boards" 181 - select ARCH_WANT_OPTIONAL_GPIOLIB 182 182 select BOOT_RAW 183 183 select CEVT_R4K 184 184 select CSRC_R4K ··· 209 211 select SYS_SUPPORTS_BIG_ENDIAN 210 212 select SYS_HAS_EARLY_PRINTK 211 213 select SWAP_IO_SPACE 212 - select ARCH_REQUIRE_GPIOLIB 214 + select GPIOLIB 213 215 select HAVE_CLK 214 216 select MIPS_L1_CACHE_SHIFT_4 215 217 help ··· 303 305 select SYS_SUPPORTS_ZBOOT_UART16550 304 306 select DMA_NONCOHERENT 305 307 select IRQ_MIPS_CPU 306 - select ARCH_REQUIRE_GPIOLIB 308 + select GPIOLIB 307 309 select COMMON_CLK 308 310 select GENERIC_IRQ_CHIP 309 311 select BUILTIN_DTB ··· 323 325 select SYS_SUPPORTS_MIPS16 324 326 select SYS_SUPPORTS_MULTITHREADING 325 327 select SYS_HAS_EARLY_PRINTK 326 - select ARCH_REQUIRE_GPIOLIB 328 + select GPIOLIB 327 329 select SWAP_IO_SPACE 328 330 select BOOT_RAW 329 331 select CLKDEV_LOOKUP ··· 375 377 376 378 config MACH_PISTACHIO 377 379 bool "IMG Pistachio SoC based boards" 378 - select ARCH_REQUIRE_GPIOLIB 379 380 select BOOT_ELF32 380 381 select BOOT_RAW 381 382 select CEVT_R4K ··· 382 385 select COMMON_CLK 383 386 select CSRC_R4K 384 387 select DMA_MAYBE_COHERENT 388 + select GPIOLIB 385 389 select IRQ_MIPS_CPU 386 390 select LIBFDT 387 391 select MFD_SYSCON ··· 404 406 405 407 config MACH_XILFPGA 406 408 bool "MIPSfpga Xilinx based boards" 407 - select ARCH_REQUIRE_GPIOLIB 408 409 select BOOT_ELF32 409 410 select BOOT_RAW 410 411 select BUILTIN_DTB 411 412 select CEVT_R4K 412 413 select COMMON_CLK 413 414 select CSRC_R4K 415 + select GPIOLIB 414 416 select IRQ_MIPS_CPU 415 417 select LIBFDT 416 418 select MIPS_CPU_SCACHE ··· 534 536 select CSRC_R4K 535 537 select SYS_HAS_CPU_VR41XX 536 538 select SYS_SUPPORTS_MIPS16 537 - select ARCH_REQUIRE_GPIOLIB 539 + select GPIOLIB 538 540 539 541 config NXP_STB220 540 542 bool "NXP STB220 board" ··· 854 856 select SYS_SUPPORTS_LITTLE_ENDIAN 855 857 select SWAP_IO_SPACE 856 858 select BOOT_RAW 857 - select ARCH_REQUIRE_GPIOLIB 859 + select GPIOLIB 858 860 select MIPS_L1_CACHE_SHIFT_4 859 861 help 860 862 Support the Mikrotik(tm) RouterBoard 532 series, ··· 877 879 select HW_HAS_PCI 878 880 select ZONE_DMA32 879 881 select HOLES_IN_ZONE 880 - select ARCH_REQUIRE_GPIOLIB 882 + select GPIOLIB 881 883 select LIBFDT 882 884 select USE_OF 883 885 select ARCH_SPARSEMEM_ENABLE ··· 935 937 select SYS_SUPPORTS_32BIT_KERNEL 936 938 select SYS_SUPPORTS_64BIT_KERNEL 937 939 select ARCH_PHYS_ADDR_T_64BIT 938 - select ARCH_REQUIRE_GPIOLIB 940 + select GPIOLIB 939 941 select SYS_SUPPORTS_BIG_ENDIAN 940 942 select SYS_SUPPORTS_LITTLE_ENDIAN 941 943 select SYS_SUPPORTS_HIGHMEM ··· 1075 1077 def_bool CSRC_R4K || CLKSRC_MIPS_GIC 1076 1078 1077 1079 config GPIO_TXX9 1078 - select ARCH_REQUIRE_GPIOLIB 1080 + select GPIOLIB 1079 1081 bool 1080 1082 1081 1083 config FW_CFE ··· 1340 1342 select CPU_SUPPORTS_HUGEPAGES 1341 1343 select WEAK_ORDERING 1342 1344 select WEAK_REORDERING_BEYOND_LLSC 1343 - select ARCH_REQUIRE_GPIOLIB 1345 + select GPIOLIB 1344 1346 help 1345 1347 The Loongson 3 processor implements the MIPS64R2 instruction 1346 1348 set with many extensions. ··· 1360 1362 bool "Loongson 2F" 1361 1363 depends on SYS_HAS_CPU_LOONGSON2F 1362 1364 select CPU_LOONGSON2 1363 - select ARCH_REQUIRE_GPIOLIB 1365 + select GPIOLIB 1364 1366 help 1365 1367 The Loongson 2F processor implements the MIPS III instruction set 1366 1368 with many extensions.
+1 -1
arch/mips/alchemy/Kconfig
··· 20 20 21 21 config MIPS_DB1XXX 22 22 bool "Alchemy DB1XXX / PB1XXX boards" 23 - select ARCH_REQUIRE_GPIOLIB 23 + select GPIOLIB 24 24 select HW_HAS_PCI 25 25 select SYS_SUPPORTS_LITTLE_ENDIAN 26 26 select SYS_HAS_EARLY_PRINTK
+1 -1
arch/mips/pic32/Kconfig
··· 14 14 select SYS_HAS_EARLY_PRINTK 15 15 select SYS_SUPPORTS_32BIT_KERNEL 16 16 select SYS_SUPPORTS_LITTLE_ENDIAN 17 - select ARCH_REQUIRE_GPIOLIB 17 + select GPIOLIB 18 18 select COMMON_CLK 19 19 select CLKDEV_LOOKUP 20 20 select LIBFDT
-1
arch/nios2/Kconfig
··· 1 1 config NIOS2 2 2 def_bool y 3 - select ARCH_WANT_OPTIONAL_GPIOLIB 4 3 select CLKSRC_OF 5 4 select GENERIC_ATOMIC64 6 5 select GENERIC_CLOCKEVENTS
+5 -10
arch/powerpc/platforms/52xx/mpc52xx_gpt.c
··· 278 278 * GPIOLIB hooks 279 279 */ 280 280 #if defined(CONFIG_GPIOLIB) 281 - static inline struct mpc52xx_gpt_priv *gc_to_mpc52xx_gpt(struct gpio_chip *gc) 282 - { 283 - return container_of(gc, struct mpc52xx_gpt_priv, gc); 284 - } 285 - 286 281 static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio) 287 282 { 288 - struct mpc52xx_gpt_priv *gpt = gc_to_mpc52xx_gpt(gc); 283 + struct mpc52xx_gpt_priv *gpt = gpiochip_get_data(gc); 289 284 290 285 return (in_be32(&gpt->regs->status) >> 8) & 1; 291 286 } ··· 288 293 static void 289 294 mpc52xx_gpt_gpio_set(struct gpio_chip *gc, unsigned int gpio, int v) 290 295 { 291 - struct mpc52xx_gpt_priv *gpt = gc_to_mpc52xx_gpt(gc); 296 + struct mpc52xx_gpt_priv *gpt = gpiochip_get_data(gc); 292 297 unsigned long flags; 293 298 u32 r; 294 299 ··· 302 307 303 308 static int mpc52xx_gpt_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) 304 309 { 305 - struct mpc52xx_gpt_priv *gpt = gc_to_mpc52xx_gpt(gc); 310 + struct mpc52xx_gpt_priv *gpt = gpiochip_get_data(gc); 306 311 unsigned long flags; 307 312 308 313 dev_dbg(gpt->dev, "%s: gpio:%d\n", __func__, gpio); ··· 349 354 clrsetbits_be32(&gpt->regs->mode, MPC52xx_GPT_MODE_MS_MASK, 350 355 MPC52xx_GPT_MODE_MS_GPIO); 351 356 352 - rc = gpiochip_add(&gpt->gc); 357 + rc = gpiochip_add_data(&gpt->gc, gpt); 353 358 if (rc) 354 - dev_err(gpt->dev, "gpiochip_add() failed; rc=%i\n", rc); 359 + dev_err(gpt->dev, "gpiochip_add_data() failed; rc=%i\n", rc); 355 360 356 361 dev_dbg(gpt->dev, "%s() complete.\n", __func__); 357 362 }
+3 -3
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
··· 16 16 #include <linux/device.h> 17 17 #include <linux/mutex.h> 18 18 #include <linux/i2c.h> 19 - #include <linux/gpio.h> 19 + #include <linux/gpio/driver.h> 20 20 #include <linux/of.h> 21 21 #include <linux/of_gpio.h> 22 22 #include <linux/slab.h> ··· 99 99 100 100 static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) 101 101 { 102 - struct mcu *mcu = container_of(gc, struct mcu, gc); 102 + struct mcu *mcu = gpiochip_get_data(gc); 103 103 u8 bit = 1 << (4 + gpio); 104 104 105 105 mutex_lock(&mcu->lock); ··· 136 136 gc->direction_output = mcu_gpio_dir_out; 137 137 gc->of_node = np; 138 138 139 - return gpiochip_add(gc); 139 + return gpiochip_add_data(gc, mcu); 140 140 } 141 141 142 142 static int mcu_gpiochip_remove(struct mcu *mcu)
+12 -24
arch/powerpc/sysdev/cpm1.c
··· 532 532 u16 cpdata; 533 533 }; 534 534 535 - static inline struct cpm1_gpio16_chip * 536 - to_cpm1_gpio16_chip(struct of_mm_gpio_chip *mm_gc) 537 - { 538 - return container_of(mm_gc, struct cpm1_gpio16_chip, mm_gc); 539 - } 540 - 541 535 static void cpm1_gpio16_save_regs(struct of_mm_gpio_chip *mm_gc) 542 536 { 543 - struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); 537 + struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 544 538 struct cpm_ioport16 __iomem *iop = mm_gc->regs; 545 539 546 540 cpm1_gc->cpdata = in_be16(&iop->dat); ··· 554 560 static void __cpm1_gpio16_set(struct of_mm_gpio_chip *mm_gc, u16 pin_mask, 555 561 int value) 556 562 { 557 - struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); 563 + struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 558 564 struct cpm_ioport16 __iomem *iop = mm_gc->regs; 559 565 560 566 if (value) ··· 568 574 static void cpm1_gpio16_set(struct gpio_chip *gc, unsigned int gpio, int value) 569 575 { 570 576 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 571 - struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); 577 + struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 572 578 unsigned long flags; 573 579 u16 pin_mask = 1 << (15 - gpio); 574 580 ··· 582 588 static int cpm1_gpio16_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) 583 589 { 584 590 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 585 - struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); 591 + struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 586 592 struct cpm_ioport16 __iomem *iop = mm_gc->regs; 587 593 unsigned long flags; 588 594 u16 pin_mask = 1 << (15 - gpio); ··· 600 606 static int cpm1_gpio16_dir_in(struct gpio_chip *gc, unsigned int gpio) 601 607 { 602 608 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 603 - struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); 609 + struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 604 610 struct cpm_ioport16 __iomem *iop = mm_gc->regs; 605 611 unsigned long flags; 606 612 u16 pin_mask = 1 << (15 - gpio); ··· 636 642 gc->get = cpm1_gpio16_get; 637 643 gc->set = cpm1_gpio16_set; 638 644 639 - return of_mm_gpiochip_add(np, mm_gc); 645 + return of_mm_gpiochip_add_data(np, mm_gc, cpm1_gc); 640 646 } 641 647 642 648 struct cpm1_gpio32_chip { ··· 647 653 u32 cpdata; 648 654 }; 649 655 650 - static inline struct cpm1_gpio32_chip * 651 - to_cpm1_gpio32_chip(struct of_mm_gpio_chip *mm_gc) 652 - { 653 - return container_of(mm_gc, struct cpm1_gpio32_chip, mm_gc); 654 - } 655 - 656 656 static void cpm1_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc) 657 657 { 658 - struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); 658 + struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 659 659 struct cpm_ioport32b __iomem *iop = mm_gc->regs; 660 660 661 661 cpm1_gc->cpdata = in_be32(&iop->dat); ··· 669 681 static void __cpm1_gpio32_set(struct of_mm_gpio_chip *mm_gc, u32 pin_mask, 670 682 int value) 671 683 { 672 - struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); 684 + struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 673 685 struct cpm_ioport32b __iomem *iop = mm_gc->regs; 674 686 675 687 if (value) ··· 683 695 static void cpm1_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value) 684 696 { 685 697 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 686 - struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); 698 + struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 687 699 unsigned long flags; 688 700 u32 pin_mask = 1 << (31 - gpio); 689 701 ··· 697 709 static int cpm1_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) 698 710 { 699 711 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 700 - struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); 712 + struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 701 713 struct cpm_ioport32b __iomem *iop = mm_gc->regs; 702 714 unsigned long flags; 703 715 u32 pin_mask = 1 << (31 - gpio); ··· 715 727 static int cpm1_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio) 716 728 { 717 729 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 718 - struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); 730 + struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc); 719 731 struct cpm_ioport32b __iomem *iop = mm_gc->regs; 720 732 unsigned long flags; 721 733 u32 pin_mask = 1 << (31 - gpio); ··· 751 763 gc->get = cpm1_gpio32_get; 752 764 gc->set = cpm1_gpio32_set; 753 765 754 - return of_mm_gpiochip_add(np, mm_gc); 766 + return of_mm_gpiochip_add_data(np, mm_gc, cpm1_gc); 755 767 } 756 768 757 769 static int cpm_init_par_io(void)
+6 -12
arch/powerpc/sysdev/cpm_common.c
··· 80 80 u32 cpdata; 81 81 }; 82 82 83 - static inline struct cpm2_gpio32_chip * 84 - to_cpm2_gpio32_chip(struct of_mm_gpio_chip *mm_gc) 85 - { 86 - return container_of(mm_gc, struct cpm2_gpio32_chip, mm_gc); 87 - } 88 - 89 83 static void cpm2_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc) 90 84 { 91 - struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); 85 + struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(&mm_gc->gc); 92 86 struct cpm2_ioports __iomem *iop = mm_gc->regs; 93 87 94 88 cpm2_gc->cpdata = in_be32(&iop->dat); ··· 102 108 static void __cpm2_gpio32_set(struct of_mm_gpio_chip *mm_gc, u32 pin_mask, 103 109 int value) 104 110 { 105 - struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); 111 + struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(&mm_gc->gc); 106 112 struct cpm2_ioports __iomem *iop = mm_gc->regs; 107 113 108 114 if (value) ··· 116 122 static void cpm2_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value) 117 123 { 118 124 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 119 - struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); 125 + struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(gc); 120 126 unsigned long flags; 121 127 u32 pin_mask = 1 << (31 - gpio); 122 128 ··· 130 136 static int cpm2_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) 131 137 { 132 138 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 133 - struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); 139 + struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(gc); 134 140 struct cpm2_ioports __iomem *iop = mm_gc->regs; 135 141 unsigned long flags; 136 142 u32 pin_mask = 1 << (31 - gpio); ··· 148 154 static int cpm2_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio) 149 155 { 150 156 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 151 - struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); 157 + struct cpm2_gpio32_chip *cpm2_gc = gpiochip_get_data(gc); 152 158 struct cpm2_ioports __iomem *iop = mm_gc->regs; 153 159 unsigned long flags; 154 160 u32 pin_mask = 1 << (31 - gpio); ··· 184 190 gc->get = cpm2_gpio32_get; 185 191 gc->set = cpm2_gpio32_set; 186 192 187 - return of_mm_gpiochip_add(np, mm_gc); 193 + return of_mm_gpiochip_add_data(np, mm_gc, cpm2_gc); 188 194 } 189 195 #endif /* CONFIG_CPM2 || CONFIG_8xx_GPIO */
+5 -12
arch/powerpc/sysdev/ppc4xx_gpio.c
··· 27 27 #include <linux/io.h> 28 28 #include <linux/of.h> 29 29 #include <linux/of_gpio.h> 30 - #include <linux/gpio.h> 30 + #include <linux/gpio/driver.h> 31 31 #include <linux/types.h> 32 32 #include <linux/slab.h> 33 33 ··· 67 67 * There are a maximum of 32 gpios in each gpio controller. 68 68 */ 69 69 70 - static inline struct ppc4xx_gpio_chip * 71 - to_ppc4xx_gpiochip(struct of_mm_gpio_chip *mm_gc) 72 - { 73 - return container_of(mm_gc, struct ppc4xx_gpio_chip, mm_gc); 74 - } 75 - 76 70 static int ppc4xx_gpio_get(struct gpio_chip *gc, unsigned int gpio) 77 71 { 78 72 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); ··· 90 96 static void 91 97 ppc4xx_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) 92 98 { 93 - struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 94 - struct ppc4xx_gpio_chip *chip = to_ppc4xx_gpiochip(mm_gc); 99 + struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc); 95 100 unsigned long flags; 96 101 97 102 spin_lock_irqsave(&chip->lock, flags); ··· 105 112 static int ppc4xx_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) 106 113 { 107 114 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 108 - struct ppc4xx_gpio_chip *chip = to_ppc4xx_gpiochip(mm_gc); 115 + struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc); 109 116 struct ppc4xx_gpio __iomem *regs = mm_gc->regs; 110 117 unsigned long flags; 111 118 ··· 135 142 ppc4xx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) 136 143 { 137 144 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 138 - struct ppc4xx_gpio_chip *chip = to_ppc4xx_gpiochip(mm_gc); 145 + struct ppc4xx_gpio_chip *chip = gpiochip_get_data(gc); 139 146 struct ppc4xx_gpio __iomem *regs = mm_gc->regs; 140 147 unsigned long flags; 141 148 ··· 193 200 gc->get = ppc4xx_gpio_get; 194 201 gc->set = ppc4xx_gpio_set; 195 202 196 - ret = of_mm_gpiochip_add(np, mm_gc); 203 + ret = of_mm_gpiochip_add_data(np, mm_gc, ppc4xx_gc); 197 204 if (ret) 198 205 goto err; 199 206 continue;
+4 -9
arch/powerpc/sysdev/simple_gpio.c
··· 19 19 #include <linux/io.h> 20 20 #include <linux/of.h> 21 21 #include <linux/of_gpio.h> 22 - #include <linux/gpio.h> 22 + #include <linux/gpio/driver.h> 23 23 #include <linux/slab.h> 24 24 #include <asm/prom.h> 25 25 #include "simple_gpio.h" ··· 31 31 /* shadowed data register to clear/set bits safely */ 32 32 u8 data; 33 33 }; 34 - 35 - static struct u8_gpio_chip *to_u8_gpio_chip(struct of_mm_gpio_chip *mm_gc) 36 - { 37 - return container_of(mm_gc, struct u8_gpio_chip, mm_gc); 38 - } 39 34 40 35 static u8 u8_pin2mask(unsigned int pin) 41 36 { ··· 47 52 static void u8_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) 48 53 { 49 54 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 50 - struct u8_gpio_chip *u8_gc = to_u8_gpio_chip(mm_gc); 55 + struct u8_gpio_chip *u8_gc = gpiochip_get_data(gc); 51 56 unsigned long flags; 52 57 53 58 spin_lock_irqsave(&u8_gc->lock, flags); ··· 75 80 76 81 static void u8_gpio_save_regs(struct of_mm_gpio_chip *mm_gc) 77 82 { 78 - struct u8_gpio_chip *u8_gc = to_u8_gpio_chip(mm_gc); 83 + struct u8_gpio_chip *u8_gc = gpiochip_get_data(&mm_gc->gc); 79 84 80 85 u8_gc->data = in_8(mm_gc->regs); 81 86 } ··· 103 108 gc->get = u8_gpio_get; 104 109 gc->set = u8_gpio_set; 105 110 106 - ret = of_mm_gpiochip_add(np, mm_gc); 111 + ret = of_mm_gpiochip_add_data(np, mm_gc, u8_gc); 107 112 if (ret) 108 113 goto err; 109 114 return 0;
+2 -2
arch/sh/boards/mach-sdk7786/gpio.c
··· 9 9 */ 10 10 #include <linux/init.h> 11 11 #include <linux/interrupt.h> 12 - #include <linux/gpio.h> 12 + #include <linux/gpio/driver.h> 13 13 #include <linux/irq.h> 14 14 #include <linux/kernel.h> 15 15 #include <linux/spinlock.h> ··· 44 44 45 45 static int __init usrgpir_gpio_setup(void) 46 46 { 47 - return gpiochip_add(&usrgpir_gpio_chip); 47 + return gpiochip_add_data(&usrgpir_gpio_chip, NULL); 48 48 } 49 49 device_initcall(usrgpir_gpio_setup);
+2 -2
arch/sh/boards/mach-x3proto/gpio.c
··· 13 13 14 14 #include <linux/init.h> 15 15 #include <linux/interrupt.h> 16 - #include <linux/gpio.h> 16 + #include <linux/gpio/driver.h> 17 17 #include <linux/irq.h> 18 18 #include <linux/kernel.h> 19 19 #include <linux/spinlock.h> ··· 107 107 if (unlikely(ilsel < 0)) 108 108 return ilsel; 109 109 110 - ret = gpiochip_add(&x3proto_gpio_chip); 110 + ret = gpiochip_add_data(&x3proto_gpio_chip, NULL); 111 111 if (unlikely(ret)) 112 112 goto err_gpio; 113 113
-1
arch/sparc/Kconfig
··· 21 21 select HAVE_ARCH_KGDB if !SMP || SPARC64 22 22 select HAVE_ARCH_TRACEHOOK 23 23 select SYSCTL_EXCEPTION_TRACE 24 - select ARCH_WANT_OPTIONAL_GPIOLIB 25 24 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 26 25 select RTC_CLASS 27 26 select RTC_DRV_M48T59
+3 -1
arch/unicore32/kernel/gpio.c
··· 14 14 15 15 #include <linux/init.h> 16 16 #include <linux/module.h> 17 + #include <linux/gpio/driver.h> 18 + /* FIXME: needed for gpio_set_value() - convert to use descriptors or hogs */ 17 19 #include <linux/gpio.h> 18 20 #include <mach/hardware.h> 19 21 ··· 120 118 * gpio_set_value(GPO_SET_V2, 1); 121 119 */ 122 120 #endif 123 - gpiochip_add(&puv3_gpio_chip); 121 + gpiochip_add_data(&puv3_gpio_chip, NULL); 124 122 }
-1
arch/xtensa/Kconfig
··· 5 5 def_bool y 6 6 select ARCH_WANT_FRAME_POINTERS 7 7 select ARCH_WANT_IPC_PARSE_VERSION 8 - select ARCH_WANT_OPTIONAL_GPIOLIB 9 8 select BUILDTIME_EXTABLE_SORT 10 9 select CLONE_BACKWARDS 11 10 select COMMON_CLK
+18 -4
drivers/gpio/Kconfig
··· 33 33 34 34 menuconfig GPIOLIB 35 35 bool "GPIO Support" 36 - depends on ARCH_WANT_OPTIONAL_GPIOLIB || ARCH_REQUIRE_GPIOLIB 37 36 help 38 37 This enables GPIO support through the generic GPIO library. 39 38 You only need to enable this, if you also want to enable ··· 48 49 49 50 config OF_GPIO 50 51 def_bool y 51 - depends on OF 52 + depends on OF || COMPILE_TEST 52 53 53 54 config GPIO_ACPI 54 55 def_bool y ··· 121 122 config GPIO_AMDPT 122 123 tristate "AMD Promontory GPIO support" 123 124 depends on ACPI 125 + select GPIO_GENERIC 124 126 help 125 127 driver for GPIO functionality on Promontory IOHub 126 128 Require ACPI ASL code to enumerate as a platform device. ··· 303 303 FSL_SOC_BOOKE || PPC_86xx || ARCH_LAYERSCAPE || ARM || \ 304 304 COMPILE_TEST 305 305 select GPIO_GENERIC 306 + select IRQ_DOMAIN 306 307 help 307 308 Say Y here if you're going to use hardware that connects to the 308 309 MPC512x/831x/834x/837x/8572/8610/QorIQ GPIOs. ··· 400 399 select GENERIC_IRQ_CHIP 401 400 select OF_GPIO 402 401 402 + config GPIO_TEGRA 403 + bool 404 + default y 405 + depends on ARCH_TEGRA || COMPILE_TEST 406 + 403 407 config GPIO_TS4800 404 408 tristate "TS-4800 DIO blocks and compatibles" 405 409 depends on OF_GPIO ··· 479 473 480 474 config GPIO_XLP 481 475 tristate "Netlogic XLP GPIO support" 482 - depends on CPU_XLP && OF_GPIO 476 + depends on OF_GPIO && (CPU_XLP || ARCH_VULCAN || COMPILE_TEST) 483 477 select GPIOLIB_IRQCHIP 484 478 help 485 479 This driver provides support for GPIO interface on Netlogic XLP MIPS64 ··· 515 509 select GPIOLIB_IRQCHIP 516 510 help 517 511 Say yes here to support the GPIO device on ZTE ZX SoCs. 512 + 513 + config GPIO_LOONGSON1 514 + tristate "Loongson1 GPIO support" 515 + depends on MACH_LOONGSON32 516 + select GPIO_GENERIC 517 + help 518 + Say Y or M here to support GPIO on Loongson1 SoCs. 518 519 519 520 endmenu 520 521 ··· 570 557 Say yes here to support GPIO functionality of IT87xx Super I/O chips. 571 558 572 559 This driver is tested with ITE IT8728 and IT8732 Super I/O chips, and 573 - supports the IT8761E Super I/O chip as well. 560 + supports the IT8761E, IT8620E and IT8628E Super I/O chip as well. 574 561 575 562 To compile this driver as a module, choose M here: the module will 576 563 be called gpio_it87 ··· 1104 1091 1105 1092 config GPIO_MCP23S08 1106 1093 tristate "Microchip MCP23xxx I/O expander" 1094 + select GPIOLIB_IRQCHIP 1107 1095 help 1108 1096 SPI/I2C driver for Microchip MCP23S08/MCP23S17/MCP23008/MCP23017 1109 1097 I/O expanders.
+5 -1
drivers/gpio/Makefile
··· 12 12 # Device drivers. Generally keep list sorted alphabetically 13 13 obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o 14 14 15 + # directly supported by gpio-generic 16 + gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o 17 + 15 18 obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o 16 19 obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o 17 20 obj-$(CONFIG_GPIO_104_IDI_48) += gpio-104-idi-48.o ··· 98 95 obj-$(CONFIG_GPIO_SYSCON) += gpio-syscon.o 99 96 obj-$(CONFIG_GPIO_TB10X) += gpio-tb10x.o 100 97 obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o 101 - obj-$(CONFIG_ARCH_TEGRA) += gpio-tegra.o 98 + obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o 102 99 obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o 103 100 obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o 104 101 obj-$(CONFIG_GPIO_TPIC2810) += gpio-tpic2810.o ··· 130 127 obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o 131 128 obj-$(CONFIG_GPIO_ZYNQ) += gpio-zynq.o 132 129 obj-$(CONFIG_GPIO_ZX) += gpio-zx.o 130 + obj-$(CONFIG_GPIO_LOONGSON1) += gpio-loongson1.o
+25
drivers/gpio/gpio-74x164.c
··· 75 75 mutex_unlock(&chip->lock); 76 76 } 77 77 78 + static void gen_74x164_set_multiple(struct gpio_chip *gc, unsigned long *mask, 79 + unsigned long *bits) 80 + { 81 + struct gen_74x164_chip *chip = gpiochip_get_data(gc); 82 + unsigned int i, idx, shift; 83 + u8 bank, bankmask; 84 + 85 + mutex_lock(&chip->lock); 86 + for (i = 0, bank = chip->registers - 1; i < chip->registers; 87 + i++, bank--) { 88 + idx = i / sizeof(*mask); 89 + shift = i % sizeof(*mask) * BITS_PER_BYTE; 90 + bankmask = mask[idx] >> shift; 91 + if (!bankmask) 92 + continue; 93 + 94 + chip->buffer[bank] &= ~bankmask; 95 + chip->buffer[bank] |= bankmask & (bits[idx] >> shift); 96 + } 97 + __gen_74x164_write_config(chip); 98 + mutex_unlock(&chip->lock); 99 + } 100 + 78 101 static int gen_74x164_direction_output(struct gpio_chip *gc, 79 102 unsigned offset, int val) 80 103 { ··· 137 114 chip->gpio_chip.direction_output = gen_74x164_direction_output; 138 115 chip->gpio_chip.get = gen_74x164_get_value; 139 116 chip->gpio_chip.set = gen_74x164_set_value; 117 + chip->gpio_chip.set_multiple = gen_74x164_set_multiple; 140 118 chip->gpio_chip.base = -1; 141 119 142 120 chip->registers = nregs; ··· 177 153 178 154 static const struct of_device_id gen_74x164_dt_ids[] = { 179 155 { .compatible = "fairchild,74hc595" }, 156 + { .compatible = "nxp,74lvc594" }, 180 157 {}, 181 158 }; 182 159 MODULE_DEVICE_TABLE(of, gen_74x164_dt_ids);
+15 -108
drivers/gpio/gpio-amdpt.c
··· 28 28 struct pt_gpio_chip { 29 29 struct gpio_chip gc; 30 30 void __iomem *reg_base; 31 - spinlock_t lock; 32 31 }; 33 32 34 33 static int pt_gpio_request(struct gpio_chip *gc, unsigned offset) ··· 38 39 39 40 dev_dbg(gc->parent, "pt_gpio_request offset=%x\n", offset); 40 41 41 - spin_lock_irqsave(&pt_gpio->lock, flags); 42 + spin_lock_irqsave(&gc->bgpio_lock, flags); 42 43 43 44 using_pins = readl(pt_gpio->reg_base + PT_SYNC_REG); 44 45 if (using_pins & BIT(offset)) { 45 46 dev_warn(gc->parent, "PT GPIO pin %x reconfigured\n", 46 47 offset); 47 - spin_unlock_irqrestore(&pt_gpio->lock, flags); 48 + spin_unlock_irqrestore(&gc->bgpio_lock, flags); 48 49 return -EINVAL; 49 50 } 50 51 51 52 writel(using_pins | BIT(offset), pt_gpio->reg_base + PT_SYNC_REG); 52 53 53 - spin_unlock_irqrestore(&pt_gpio->lock, flags); 54 + spin_unlock_irqrestore(&gc->bgpio_lock, flags); 54 55 55 56 return 0; 56 57 } ··· 61 62 unsigned long flags; 62 63 u32 using_pins; 63 64 64 - spin_lock_irqsave(&pt_gpio->lock, flags); 65 + spin_lock_irqsave(&gc->bgpio_lock, flags); 65 66 66 67 using_pins = readl(pt_gpio->reg_base + PT_SYNC_REG); 67 68 using_pins &= ~BIT(offset); 68 69 writel(using_pins, pt_gpio->reg_base + PT_SYNC_REG); 69 70 70 - spin_unlock_irqrestore(&pt_gpio->lock, flags); 71 + spin_unlock_irqrestore(&gc->bgpio_lock, flags); 71 72 72 73 dev_dbg(gc->parent, "pt_gpio_free offset=%x\n", offset); 73 - } 74 - 75 - static void pt_gpio_set_value(struct gpio_chip *gc, unsigned offset, int value) 76 - { 77 - struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); 78 - unsigned long flags; 79 - u32 data; 80 - 81 - dev_dbg(gc->parent, "pt_gpio_set_value offset=%x, value=%x\n", 82 - offset, value); 83 - 84 - spin_lock_irqsave(&pt_gpio->lock, flags); 85 - 86 - data = readl(pt_gpio->reg_base + PT_OUTPUTDATA_REG); 87 - data &= ~BIT(offset); 88 - if (value) 89 - data |= BIT(offset); 90 - writel(data, pt_gpio->reg_base + PT_OUTPUTDATA_REG); 91 - 92 - spin_unlock_irqrestore(&pt_gpio->lock, flags); 93 - } 94 - 95 - static int pt_gpio_get_value(struct gpio_chip *gc, unsigned offset) 96 - { 97 - struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); 98 - unsigned long flags; 99 - u32 data; 100 - 101 - spin_lock_irqsave(&pt_gpio->lock, flags); 102 - 103 - data = readl(pt_gpio->reg_base + PT_DIRECTION_REG); 104 - 105 - /* configure as output */ 106 - if (data & BIT(offset)) 107 - data = readl(pt_gpio->reg_base + PT_OUTPUTDATA_REG); 108 - else /* configure as input */ 109 - data = readl(pt_gpio->reg_base + PT_INPUTDATA_REG); 110 - 111 - spin_unlock_irqrestore(&pt_gpio->lock, flags); 112 - 113 - data >>= offset; 114 - data &= 1; 115 - 116 - dev_dbg(gc->parent, "pt_gpio_get_value offset=%x, value=%x\n", 117 - offset, data); 118 - 119 - return data; 120 - } 121 - 122 - static int pt_gpio_direction_input(struct gpio_chip *gc, unsigned offset) 123 - { 124 - struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); 125 - unsigned long flags; 126 - u32 data; 127 - 128 - dev_dbg(gc->parent, "pt_gpio_dirction_input offset=%x\n", offset); 129 - 130 - spin_lock_irqsave(&pt_gpio->lock, flags); 131 - 132 - data = readl(pt_gpio->reg_base + PT_DIRECTION_REG); 133 - data &= ~BIT(offset); 134 - writel(data, pt_gpio->reg_base + PT_DIRECTION_REG); 135 - 136 - spin_unlock_irqrestore(&pt_gpio->lock, flags); 137 - 138 - return 0; 139 - } 140 - 141 - static int pt_gpio_direction_output(struct gpio_chip *gc, 142 - unsigned offset, int value) 143 - { 144 - struct pt_gpio_chip *pt_gpio = gpiochip_get_data(gc); 145 - unsigned long flags; 146 - u32 data; 147 - 148 - dev_dbg(gc->parent, "pt_gpio_direction_output offset=%x, value=%x\n", 149 - offset, value); 150 - 151 - spin_lock_irqsave(&pt_gpio->lock, flags); 152 - 153 - data = readl(pt_gpio->reg_base + PT_OUTPUTDATA_REG); 154 - if (value) 155 - data |= BIT(offset); 156 - else 157 - data &= ~BIT(offset); 158 - writel(data, pt_gpio->reg_base + PT_OUTPUTDATA_REG); 159 - 160 - data = readl(pt_gpio->reg_base + PT_DIRECTION_REG); 161 - data |= BIT(offset); 162 - writel(data, pt_gpio->reg_base + PT_DIRECTION_REG); 163 - 164 - spin_unlock_irqrestore(&pt_gpio->lock, flags); 165 - 166 - return 0; 167 74 } 168 75 169 76 static int pt_gpio_probe(struct platform_device *pdev) ··· 101 196 return PTR_ERR(pt_gpio->reg_base); 102 197 } 103 198 104 - spin_lock_init(&pt_gpio->lock); 199 + ret = bgpio_init(&pt_gpio->gc, dev, 4, 200 + pt_gpio->reg_base + PT_INPUTDATA_REG, 201 + pt_gpio->reg_base + PT_OUTPUTDATA_REG, NULL, 202 + pt_gpio->reg_base + PT_DIRECTION_REG, NULL, 203 + BGPIOF_READ_OUTPUT_REG_SET); 204 + if (ret) { 205 + dev_err(&pdev->dev, "bgpio_init failed\n"); 206 + return ret; 207 + } 105 208 106 - pt_gpio->gc.label = pdev->name; 107 209 pt_gpio->gc.owner = THIS_MODULE; 108 - pt_gpio->gc.parent = dev; 109 210 pt_gpio->gc.request = pt_gpio_request; 110 211 pt_gpio->gc.free = pt_gpio_free; 111 - pt_gpio->gc.direction_input = pt_gpio_direction_input; 112 - pt_gpio->gc.direction_output = pt_gpio_direction_output; 113 - pt_gpio->gc.get = pt_gpio_get_value; 114 - pt_gpio->gc.set = pt_gpio_set_value; 115 - pt_gpio->gc.base = -1; 116 212 pt_gpio->gc.ngpio = PT_TOTAL_GPIO; 117 213 #if defined(CONFIG_OF_GPIO) 118 214 pt_gpio->gc.of_node = pdev->dev.of_node; ··· 145 239 146 240 static const struct acpi_device_id pt_gpio_acpi_match[] = { 147 241 { "AMDF030", 0 }, 242 + { "AMDIF030", 0 }, 148 243 { }, 149 244 }; 150 245 MODULE_DEVICE_TABLE(acpi, pt_gpio_acpi_match);
+5 -9
drivers/gpio/gpio-bcm-kona.c
··· 1 1 /* 2 + * Broadcom Kona GPIO Driver 3 + * 4 + * Author: Broadcom Corporation <bcm-kernel-feedback-list@broadcom.com> 2 5 * Copyright (C) 2012-2014 Broadcom Corporation 3 6 * 4 7 * This program is free software; you can redistribute it and/or ··· 20 17 #include <linux/gpio.h> 21 18 #include <linux/of_device.h> 22 19 #include <linux/of_irq.h> 23 - #include <linux/module.h> 20 + #include <linux/init.h> 24 21 #include <linux/irqdomain.h> 25 22 #include <linux/irqchip/chained_irq.h> 26 23 ··· 505 502 {} 506 503 }; 507 504 508 - MODULE_DEVICE_TABLE(of, bcm_kona_gpio_of_match); 509 - 510 505 /* 511 506 * This lock class tells lockdep that GPIO irqs are in a different 512 507 * category than their parents, so it won't report false recursion. ··· 660 659 }, 661 660 .probe = bcm_kona_gpio_probe, 662 661 }; 663 - 664 - module_platform_driver(bcm_kona_gpio_driver); 665 - 666 - MODULE_AUTHOR("Broadcom Corporation <bcm-kernel-feedback-list@broadcom.com>"); 667 - MODULE_DESCRIPTION("Broadcom Kona GPIO Driver"); 668 - MODULE_LICENSE("GPL v2"); 662 + builtin_platform_driver(bcm_kona_gpio_driver);
+1
drivers/gpio/gpio-brcmstb.c
··· 461 461 bank->id = num_banks; 462 462 if (bank_width <= 0 || bank_width > MAX_GPIO_PER_BANK) { 463 463 dev_err(dev, "Invalid bank width %d\n", bank_width); 464 + err = -EINVAL; 464 465 goto fail; 465 466 } else { 466 467 bank->width = bank_width;
+46 -32
drivers/gpio/gpio-dwapb.c
··· 7 7 * 8 8 * All enquiries to support@picochip.com 9 9 */ 10 + #include <linux/acpi.h> 10 11 #include <linux/gpio/driver.h> 11 12 /* FIXME: for gpio_get_value(), replace this with direct register read */ 12 13 #include <linux/gpio.h> ··· 23 22 #include <linux/of_address.h> 24 23 #include <linux/of_irq.h> 25 24 #include <linux/platform_device.h> 25 + #include <linux/property.h> 26 26 #include <linux/spinlock.h> 27 27 #include <linux/platform_data/gpio-dwapb.h> 28 28 #include <linux/slab.h> 29 + 30 + #include "gpiolib.h" 29 31 30 32 #define GPIO_SWPORTA_DR 0x00 31 33 #define GPIO_SWPORTA_DDR 0x04 ··· 294 290 struct dwapb_port_property *pp) 295 291 { 296 292 struct gpio_chip *gc = &port->gc; 297 - struct device_node *node = pp->node; 293 + struct fwnode_handle *fwnode = pp->fwnode; 298 294 struct irq_chip_generic *irq_gc = NULL; 299 295 unsigned int hwirq, ngpio = gc->ngpio; 300 296 struct irq_chip_type *ct; 301 297 int err, i; 302 298 303 - gpio->domain = irq_domain_add_linear(node, ngpio, 304 - &irq_generic_chip_ops, gpio); 299 + gpio->domain = irq_domain_create_linear(fwnode, ngpio, 300 + &irq_generic_chip_ops, gpio); 305 301 if (!gpio->domain) 306 302 return; 307 303 ··· 413 409 err = bgpio_init(&port->gc, gpio->dev, 4, dat, set, NULL, dirout, 414 410 NULL, false); 415 411 if (err) { 416 - dev_err(gpio->dev, "failed to init gpio chip for %s\n", 417 - pp->name); 412 + dev_err(gpio->dev, "failed to init gpio chip for port%d\n", 413 + port->idx); 418 414 return err; 419 415 } 420 416 421 417 #ifdef CONFIG_OF_GPIO 422 - port->gc.of_node = pp->node; 418 + port->gc.of_node = to_of_node(pp->fwnode); 423 419 #endif 424 420 port->gc.ngpio = pp->ngpio; 425 421 port->gc.base = pp->gpio_base; ··· 433 429 434 430 err = gpiochip_add_data(&port->gc, port); 435 431 if (err) 436 - dev_err(gpio->dev, "failed to register gpiochip for %s\n", 437 - pp->name); 432 + dev_err(gpio->dev, "failed to register gpiochip for port%d\n", 433 + port->idx); 438 434 else 439 435 port->is_registered = true; 436 + 437 + /* Add GPIO-signaled ACPI event support */ 438 + if (pp->irq) 439 + acpi_gpiochip_request_interrupts(&port->gc); 440 440 441 441 return err; 442 442 } ··· 455 447 } 456 448 457 449 static struct dwapb_platform_data * 458 - dwapb_gpio_get_pdata_of(struct device *dev) 450 + dwapb_gpio_get_pdata(struct device *dev) 459 451 { 460 - struct device_node *node, *port_np; 452 + struct fwnode_handle *fwnode; 461 453 struct dwapb_platform_data *pdata; 462 454 struct dwapb_port_property *pp; 463 455 int nports; 464 456 int i; 465 457 466 - node = dev->of_node; 467 - if (!IS_ENABLED(CONFIG_OF_GPIO) || !node) 468 - return ERR_PTR(-ENODEV); 469 - 470 - nports = of_get_child_count(node); 458 + nports = device_get_child_node_count(dev); 471 459 if (nports == 0) 472 460 return ERR_PTR(-ENODEV); 473 461 ··· 478 474 pdata->nports = nports; 479 475 480 476 i = 0; 481 - for_each_child_of_node(node, port_np) { 477 + device_for_each_child_node(dev, fwnode) { 482 478 pp = &pdata->properties[i++]; 483 - pp->node = port_np; 479 + pp->fwnode = fwnode; 484 480 485 - if (of_property_read_u32(port_np, "reg", &pp->idx) || 481 + if (fwnode_property_read_u32(fwnode, "reg", &pp->idx) || 486 482 pp->idx >= DWAPB_MAX_PORTS) { 487 - dev_err(dev, "missing/invalid port index for %s\n", 488 - port_np->full_name); 483 + dev_err(dev, 484 + "missing/invalid port index for port%d\n", i); 489 485 return ERR_PTR(-EINVAL); 490 486 } 491 487 492 - if (of_property_read_u32(port_np, "snps,nr-gpios", 488 + if (fwnode_property_read_u32(fwnode, "snps,nr-gpios", 493 489 &pp->ngpio)) { 494 - dev_info(dev, "failed to get number of gpios for %s\n", 495 - port_np->full_name); 490 + dev_info(dev, 491 + "failed to get number of gpios for port%d\n", 492 + i); 496 493 pp->ngpio = 32; 497 494 } 498 495 ··· 501 496 * Only port A can provide interrupts in all configurations of 502 497 * the IP. 503 498 */ 504 - if (pp->idx == 0 && 505 - of_property_read_bool(port_np, "interrupt-controller")) { 506 - pp->irq = irq_of_parse_and_map(port_np, 0); 507 - if (!pp->irq) { 508 - dev_warn(dev, "no irq for bank %s\n", 509 - port_np->full_name); 510 - } 499 + if (dev->of_node && pp->idx == 0 && 500 + fwnode_property_read_bool(fwnode, 501 + "interrupt-controller")) { 502 + pp->irq = irq_of_parse_and_map(to_of_node(fwnode), 0); 503 + if (!pp->irq) 504 + dev_warn(dev, "no irq for port%d\n", pp->idx); 511 505 } 506 + 507 + if (has_acpi_companion(dev) && pp->idx == 0) 508 + pp->irq = platform_get_irq(to_platform_device(dev), 0); 512 509 513 510 pp->irq_shared = false; 514 511 pp->gpio_base = -1; 515 - pp->name = port_np->full_name; 516 512 } 517 513 518 514 return pdata; ··· 529 523 struct dwapb_platform_data *pdata = dev_get_platdata(dev); 530 524 531 525 if (!pdata) { 532 - pdata = dwapb_gpio_get_pdata_of(dev); 526 + pdata = dwapb_gpio_get_pdata(dev); 533 527 if (IS_ERR(pdata)) 534 528 return PTR_ERR(pdata); 535 529 } ··· 585 579 { /* Sentinel */ } 586 580 }; 587 581 MODULE_DEVICE_TABLE(of, dwapb_of_match); 582 + 583 + static const struct acpi_device_id dwapb_acpi_match[] = { 584 + {"HISI0181", 0}, 585 + {"APMC0D07", 0}, 586 + { } 587 + }; 588 + MODULE_DEVICE_TABLE(acpi, dwapb_acpi_match); 588 589 589 590 #ifdef CONFIG_PM_SLEEP 590 591 static int dwapb_gpio_suspend(struct device *dev) ··· 687 674 .name = "gpio-dwapb", 688 675 .pm = &dwapb_gpio_pm_ops, 689 676 .of_match_table = of_match_ptr(dwapb_of_match), 677 + .acpi_match_table = ACPI_PTR(dwapb_acpi_match), 690 678 }, 691 679 .probe = dwapb_gpio_probe, 692 680 .remove = dwapb_gpio_remove,
+43 -9
drivers/gpio/gpio-f7188x.c
··· 15 15 #include <linux/init.h> 16 16 #include <linux/platform_device.h> 17 17 #include <linux/io.h> 18 - #include <linux/gpio.h> 18 + #include <linux/gpio/driver.h> 19 + #include <linux/bitops.h> 19 20 20 21 #define DRVNAME "gpio-f7188x" 21 22 ··· 130 129 static int f7188x_gpio_direction_out(struct gpio_chip *chip, 131 130 unsigned offset, int value); 132 131 static void f7188x_gpio_set(struct gpio_chip *chip, unsigned offset, int value); 132 + static int f7188x_gpio_set_single_ended(struct gpio_chip *gc, 133 + unsigned offset, 134 + enum single_ended_mode mode); 133 135 134 136 #define F7188X_GPIO_BANK(_base, _ngpio, _regbase) \ 135 137 { \ ··· 143 139 .get = f7188x_gpio_get, \ 144 140 .direction_output = f7188x_gpio_direction_out, \ 145 141 .set = f7188x_gpio_set, \ 142 + .set_single_ended = f7188x_gpio_set_single_ended, \ 146 143 .base = _base, \ 147 144 .ngpio = _ngpio, \ 148 145 .can_sleep = true, \ ··· 222 217 superio_select(sio->addr, SIO_LD_GPIO); 223 218 224 219 dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); 225 - dir &= ~(1 << offset); 220 + dir &= ~BIT(offset); 226 221 superio_outb(sio->addr, gpio_dir(bank->regbase), dir); 227 222 228 223 superio_exit(sio->addr); ··· 243 238 superio_select(sio->addr, SIO_LD_GPIO); 244 239 245 240 dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); 246 - dir = !!(dir & (1 << offset)); 241 + dir = !!(dir & BIT(offset)); 247 242 if (dir) 248 243 data = superio_inb(sio->addr, gpio_data_out(bank->regbase)); 249 244 else ··· 251 246 252 247 superio_exit(sio->addr); 253 248 254 - return !!(data & 1 << offset); 249 + return !!(data & BIT(offset)); 255 250 } 256 251 257 252 static int f7188x_gpio_direction_out(struct gpio_chip *chip, ··· 269 264 270 265 data_out = superio_inb(sio->addr, gpio_data_out(bank->regbase)); 271 266 if (value) 272 - data_out |= (1 << offset); 267 + data_out |= BIT(offset); 273 268 else 274 - data_out &= ~(1 << offset); 269 + data_out &= ~BIT(offset); 275 270 superio_outb(sio->addr, gpio_data_out(bank->regbase), data_out); 276 271 277 272 dir = superio_inb(sio->addr, gpio_dir(bank->regbase)); 278 - dir |= (1 << offset); 273 + dir |= BIT(offset); 279 274 superio_outb(sio->addr, gpio_dir(bank->regbase), dir); 280 275 281 276 superio_exit(sio->addr); ··· 297 292 298 293 data_out = superio_inb(sio->addr, gpio_data_out(bank->regbase)); 299 294 if (value) 300 - data_out |= (1 << offset); 295 + data_out |= BIT(offset); 301 296 else 302 - data_out &= ~(1 << offset); 297 + data_out &= ~BIT(offset); 303 298 superio_outb(sio->addr, gpio_data_out(bank->regbase), data_out); 304 299 305 300 superio_exit(sio->addr); 301 + } 302 + 303 + static int f7188x_gpio_set_single_ended(struct gpio_chip *chip, 304 + unsigned offset, 305 + enum single_ended_mode mode) 306 + { 307 + int err; 308 + struct f7188x_gpio_bank *bank = gpiochip_get_data(chip); 309 + struct f7188x_sio *sio = bank->data->sio; 310 + u8 data; 311 + 312 + if (mode != LINE_MODE_OPEN_DRAIN && 313 + mode != LINE_MODE_PUSH_PULL) 314 + return -ENOTSUPP; 315 + 316 + err = superio_enter(sio->addr); 317 + if (err) 318 + return err; 319 + superio_select(sio->addr, SIO_LD_GPIO); 320 + 321 + data = superio_inb(sio->addr, gpio_out_mode(bank->regbase)); 322 + if (mode == LINE_MODE_OPEN_DRAIN) 323 + data &= ~BIT(offset); 324 + else 325 + data |= BIT(offset); 326 + superio_outb(sio->addr, gpio_out_mode(bank->regbase), data); 327 + 328 + superio_exit(sio->addr); 329 + return 0; 306 330 } 307 331 308 332 /*
+1 -1
drivers/gpio/gpio-generic.c drivers/gpio/gpio-mmio.c
··· 549 549 } 550 550 EXPORT_SYMBOL_GPL(bgpio_init); 551 551 552 - #ifdef CONFIG_GPIO_GENERIC_PLATFORM 552 + #if IS_ENABLED(CONFIG_GPIO_GENERIC_PLATFORM) 553 553 554 554 static void __iomem *bgpio_map(struct platform_device *pdev, 555 555 const char *name,
+10
drivers/gpio/gpio-it87.c
··· 34 34 35 35 /* Chip Id numbers */ 36 36 #define NO_DEV_ID 0xffff 37 + #define IT8620_ID 0x8620 38 + #define IT8628_ID 0x8628 37 39 #define IT8728_ID 0x8728 38 40 #define IT8732_ID 0x8732 39 41 #define IT8761_ID 0x8761 ··· 304 302 it87_gpio->chip = it87_template_chip; 305 303 306 304 switch (chip_type) { 305 + case IT8620_ID: 306 + case IT8628_ID: 307 + gpio_ba_reg = 0x62; 308 + it87_gpio->io_size = 11; 309 + it87_gpio->output_base = 0xc8; 310 + it87_gpio->simple_size = 0; 311 + it87_gpio->chip.ngpio = 64; 312 + break; 307 313 case IT8728_ID: 308 314 case IT8732_ID: 309 315 gpio_ba_reg = 0x62;
+102
drivers/gpio/gpio-loongson1.c
··· 1 + /* 2 + * GPIO Driver for Loongson 1 SoC 3 + * 4 + * Copyright (C) 2015-2016 Zhang, Keguang <keguang.zhang@gmail.com> 5 + * 6 + * This file is licensed under the terms of the GNU General Public 7 + * License version 2. This program is licensed "as is" without any 8 + * warranty of any kind, whether express or implied. 9 + */ 10 + 11 + #include <linux/gpio/driver.h> 12 + #include <linux/platform_device.h> 13 + 14 + /* Loongson 1 GPIO Register Definitions */ 15 + #define GPIO_CFG 0x0 16 + #define GPIO_DIR 0x10 17 + #define GPIO_DATA 0x20 18 + #define GPIO_OUTPUT 0x30 19 + 20 + static void __iomem *gpio_reg_base; 21 + 22 + static int ls1x_gpio_request(struct gpio_chip *gc, unsigned int offset) 23 + { 24 + unsigned long pinmask = gc->pin2mask(gc, offset); 25 + unsigned long flags; 26 + 27 + spin_lock_irqsave(&gc->bgpio_lock, flags); 28 + __raw_writel(__raw_readl(gpio_reg_base + GPIO_CFG) | pinmask, 29 + gpio_reg_base + GPIO_CFG); 30 + spin_unlock_irqrestore(&gc->bgpio_lock, flags); 31 + 32 + return 0; 33 + } 34 + 35 + static void ls1x_gpio_free(struct gpio_chip *gc, unsigned int offset) 36 + { 37 + unsigned long pinmask = gc->pin2mask(gc, offset); 38 + unsigned long flags; 39 + 40 + spin_lock_irqsave(&gc->bgpio_lock, flags); 41 + __raw_writel(__raw_readl(gpio_reg_base + GPIO_CFG) & ~pinmask, 42 + gpio_reg_base + GPIO_CFG); 43 + spin_unlock_irqrestore(&gc->bgpio_lock, flags); 44 + } 45 + 46 + static int ls1x_gpio_probe(struct platform_device *pdev) 47 + { 48 + struct device *dev = &pdev->dev; 49 + struct gpio_chip *gc; 50 + struct resource *res; 51 + int ret; 52 + 53 + gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL); 54 + if (!gc) 55 + return -ENOMEM; 56 + 57 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 58 + if (!res) { 59 + dev_err(dev, "failed to get I/O memory\n"); 60 + return -EINVAL; 61 + } 62 + 63 + gpio_reg_base = devm_ioremap_resource(dev, res); 64 + if (IS_ERR(gpio_reg_base)) 65 + return PTR_ERR(gpio_reg_base); 66 + 67 + ret = bgpio_init(gc, dev, 4, gpio_reg_base + GPIO_DATA, 68 + gpio_reg_base + GPIO_OUTPUT, NULL, 69 + NULL, gpio_reg_base + GPIO_DIR, 0); 70 + if (ret) 71 + goto err; 72 + 73 + gc->owner = THIS_MODULE; 74 + gc->request = ls1x_gpio_request; 75 + gc->free = ls1x_gpio_free; 76 + gc->base = pdev->id * 32; 77 + 78 + ret = devm_gpiochip_add_data(dev, gc, NULL); 79 + if (ret) 80 + goto err; 81 + 82 + platform_set_drvdata(pdev, gc); 83 + dev_info(dev, "Loongson1 GPIO driver registered\n"); 84 + 85 + return 0; 86 + err: 87 + dev_err(dev, "failed to register GPIO device\n"); 88 + return ret; 89 + } 90 + 91 + static struct platform_driver ls1x_gpio_driver = { 92 + .probe = ls1x_gpio_probe, 93 + .driver = { 94 + .name = "ls1x-gpio", 95 + }, 96 + }; 97 + 98 + module_platform_driver(ls1x_gpio_driver); 99 + 100 + MODULE_AUTHOR("Kelvin Cheung <keguang.zhang@gmail.com>"); 101 + MODULE_DESCRIPTION("Loongson1 GPIO driver"); 102 + MODULE_LICENSE("GPL");
+1 -9
drivers/gpio/gpio-mb86s7x.c
··· 17 17 #include <linux/io.h> 18 18 #include <linux/init.h> 19 19 #include <linux/clk.h> 20 - #include <linux/module.h> 21 20 #include <linux/err.h> 22 21 #include <linux/errno.h> 23 22 #include <linux/ioport.h> ··· 184 185 gchip->gc.parent = &pdev->dev; 185 186 gchip->gc.base = -1; 186 187 187 - platform_set_drvdata(pdev, gchip); 188 - 189 188 ret = gpiochip_add_data(&gchip->gc, gchip); 190 189 if (ret) { 191 190 dev_err(&pdev->dev, "couldn't register gpio driver\n"); ··· 207 210 { .compatible = "fujitsu,mb86s70-gpio" }, 208 211 { /* sentinel */ } 209 212 }; 210 - MODULE_DEVICE_TABLE(of, mb86s70_gpio_dt_ids); 211 213 212 214 static struct platform_driver mb86s70_gpio_driver = { 213 215 .driver = { ··· 221 225 { 222 226 return platform_driver_register(&mb86s70_gpio_driver); 223 227 } 224 - module_init(mb86s70_gpio_init); 225 - 226 - MODULE_DESCRIPTION("MB86S7x GPIO Driver"); 227 - MODULE_ALIAS("platform:mb86s70-gpio"); 228 - MODULE_LICENSE("GPL"); 228 + device_initcall(mb86s70_gpio_init);
+2 -10
drivers/gpio/gpio-mc9s08dz60.c
··· 15 15 */ 16 16 17 17 #include <linux/kernel.h> 18 - #include <linux/module.h> 18 + #include <linux/init.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/i2c.h> 21 21 #include <linux/gpio.h> ··· 111 111 {}, 112 112 }; 113 113 114 - MODULE_DEVICE_TABLE(i2c, mc9s08dz60_id); 115 - 116 114 static struct i2c_driver mc9s08dz60_i2c_driver = { 117 115 .driver = { 118 116 .name = "mc9s08dz60", ··· 118 120 .probe = mc9s08dz60_probe, 119 121 .id_table = mc9s08dz60_id, 120 122 }; 121 - 122 - module_i2c_driver(mc9s08dz60_i2c_driver); 123 - 124 - MODULE_AUTHOR("Freescale Semiconductor, Inc. " 125 - "Wu Guoxing <b39297@freescale.com>"); 126 - MODULE_DESCRIPTION("mc9s08dz60 gpio function on mx35 3ds board"); 127 - MODULE_LICENSE("GPL v2"); 123 + builtin_i2c_driver(mc9s08dz60_i2c_driver);
+35 -78
drivers/gpio/gpio-mcp23s08.c
··· 77 77 /* lock protects the cached values */ 78 78 struct mutex lock; 79 79 struct mutex irq_lock; 80 - struct irq_domain *irq_domain; 81 80 82 81 struct gpio_chip chip; 83 82 ··· 94 95 struct mcp23s08 *mcp[8]; 95 96 struct mcp23s08 chip[]; 96 97 }; 97 - 98 - /* This lock class tells lockdep that GPIO irqs are in a different 99 - * category than their parents, so it won't report false recursion. 100 - */ 101 - static struct lock_class_key gpio_lock_class; 102 98 103 99 /*----------------------------------------------------------------------*/ 104 100 ··· 362 368 for (i = 0; i < mcp->chip.ngpio; i++) { 363 369 if ((BIT(i) & mcp->cache[MCP_INTF]) && 364 370 ((BIT(i) & intcap & mcp->irq_rise) || 365 - (mcp->irq_fall & ~intcap & BIT(i)))) { 366 - child_irq = irq_find_mapping(mcp->irq_domain, i); 371 + (mcp->irq_fall & ~intcap & BIT(i)) || 372 + (BIT(i) & mcp->cache[MCP_INTCON]))) { 373 + child_irq = irq_find_mapping(mcp->chip.irqdomain, i); 367 374 handle_nested_irq(child_irq); 368 375 } 369 376 } ··· 372 377 return IRQ_HANDLED; 373 378 } 374 379 375 - static int mcp23s08_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 376 - { 377 - struct mcp23s08 *mcp = gpiochip_get_data(chip); 378 - 379 - return irq_find_mapping(mcp->irq_domain, offset); 380 - } 381 - 382 380 static void mcp23s08_irq_mask(struct irq_data *data) 383 381 { 384 - struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); 382 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 383 + struct mcp23s08 *mcp = gpiochip_get_data(gc); 385 384 unsigned int pos = data->hwirq; 386 385 387 386 mcp->cache[MCP_GPINTEN] &= ~BIT(pos); ··· 383 394 384 395 static void mcp23s08_irq_unmask(struct irq_data *data) 385 396 { 386 - struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); 397 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 398 + struct mcp23s08 *mcp = gpiochip_get_data(gc); 387 399 unsigned int pos = data->hwirq; 388 400 389 401 mcp->cache[MCP_GPINTEN] |= BIT(pos); ··· 392 402 393 403 static int mcp23s08_irq_set_type(struct irq_data *data, unsigned int type) 394 404 { 395 - struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); 405 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 406 + struct mcp23s08 *mcp = gpiochip_get_data(gc); 396 407 unsigned int pos = data->hwirq; 397 408 int status = 0; 398 409 ··· 409 418 mcp->cache[MCP_INTCON] &= ~BIT(pos); 410 419 mcp->irq_rise &= ~BIT(pos); 411 420 mcp->irq_fall |= BIT(pos); 421 + } else if (type & IRQ_TYPE_LEVEL_HIGH) { 422 + mcp->cache[MCP_INTCON] |= BIT(pos); 423 + mcp->cache[MCP_DEFVAL] &= ~BIT(pos); 424 + } else if (type & IRQ_TYPE_LEVEL_LOW) { 425 + mcp->cache[MCP_INTCON] |= BIT(pos); 426 + mcp->cache[MCP_DEFVAL] |= BIT(pos); 412 427 } else 413 428 return -EINVAL; 414 429 ··· 423 426 424 427 static void mcp23s08_irq_bus_lock(struct irq_data *data) 425 428 { 426 - struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); 429 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 430 + struct mcp23s08 *mcp = gpiochip_get_data(gc); 427 431 428 432 mutex_lock(&mcp->irq_lock); 429 433 } 430 434 431 435 static void mcp23s08_irq_bus_unlock(struct irq_data *data) 432 436 { 433 - struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); 437 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 438 + struct mcp23s08 *mcp = gpiochip_get_data(gc); 434 439 435 440 mutex_lock(&mcp->lock); 436 441 mcp->ops->write(mcp, MCP_GPINTEN, mcp->cache[MCP_GPINTEN]); ··· 442 443 mutex_unlock(&mcp->irq_lock); 443 444 } 444 445 445 - static int mcp23s08_irq_reqres(struct irq_data *data) 446 - { 447 - struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); 448 - 449 - if (gpiochip_lock_as_irq(&mcp->chip, data->hwirq)) { 450 - dev_err(mcp->chip.parent, 451 - "unable to lock HW IRQ %lu for IRQ usage\n", 452 - data->hwirq); 453 - return -EINVAL; 454 - } 455 - 456 - return 0; 457 - } 458 - 459 - static void mcp23s08_irq_relres(struct irq_data *data) 460 - { 461 - struct mcp23s08 *mcp = irq_data_get_irq_chip_data(data); 462 - 463 - gpiochip_unlock_as_irq(&mcp->chip, data->hwirq); 464 - } 465 - 466 446 static struct irq_chip mcp23s08_irq_chip = { 467 447 .name = "gpio-mcp23xxx", 468 448 .irq_mask = mcp23s08_irq_mask, ··· 449 471 .irq_set_type = mcp23s08_irq_set_type, 450 472 .irq_bus_lock = mcp23s08_irq_bus_lock, 451 473 .irq_bus_sync_unlock = mcp23s08_irq_bus_unlock, 452 - .irq_request_resources = mcp23s08_irq_reqres, 453 - .irq_release_resources = mcp23s08_irq_relres, 454 474 }; 455 475 456 476 static int mcp23s08_irq_setup(struct mcp23s08 *mcp) 457 477 { 458 478 struct gpio_chip *chip = &mcp->chip; 459 - int err, irq, j; 479 + int err; 460 480 unsigned long irqflags = IRQF_ONESHOT | IRQF_SHARED; 461 481 462 482 mutex_init(&mcp->irq_lock); 463 - 464 - mcp->irq_domain = irq_domain_add_linear(chip->parent->of_node, 465 - chip->ngpio, 466 - &irq_domain_simple_ops, mcp); 467 - if (!mcp->irq_domain) 468 - return -ENODEV; 469 483 470 484 if (mcp->irq_active_high) 471 485 irqflags |= IRQF_TRIGGER_HIGH; ··· 473 503 return err; 474 504 } 475 505 476 - chip->to_irq = mcp23s08_gpio_to_irq; 477 - 478 - for (j = 0; j < mcp->chip.ngpio; j++) { 479 - irq = irq_create_mapping(mcp->irq_domain, j); 480 - irq_set_lockdep_class(irq, &gpio_lock_class); 481 - irq_set_chip_data(irq, mcp); 482 - irq_set_chip(irq, &mcp23s08_irq_chip); 483 - irq_set_nested_thread(irq, true); 484 - irq_set_noprobe(irq); 506 + err = gpiochip_irqchip_add(chip, 507 + &mcp23s08_irq_chip, 508 + 0, 509 + handle_simple_irq, 510 + IRQ_TYPE_NONE); 511 + if (err) { 512 + dev_err(chip->parent, 513 + "could not connect irqchip to gpiochip: %d\n", err); 514 + return err; 485 515 } 516 + 517 + gpiochip_set_chained_irqchip(chip, 518 + &mcp23s08_irq_chip, 519 + mcp->irq, 520 + NULL); 521 + 486 522 return 0; 487 - } 488 - 489 - static void mcp23s08_irq_teardown(struct mcp23s08 *mcp) 490 - { 491 - unsigned int irq, i; 492 - 493 - for (i = 0; i < mcp->chip.ngpio; i++) { 494 - irq = irq_find_mapping(mcp->irq_domain, i); 495 - if (irq > 0) 496 - irq_dispose_mapping(irq); 497 - } 498 - 499 - irq_domain_remove(mcp->irq_domain); 500 523 } 501 524 502 525 /*----------------------------------------------------------------------*/ ··· 684 721 if (mcp->irq && mcp->irq_controller) { 685 722 status = mcp23s08_irq_setup(mcp); 686 723 if (status) { 687 - mcp23s08_irq_teardown(mcp); 688 724 goto fail; 689 725 } 690 726 } ··· 808 846 static int mcp230xx_remove(struct i2c_client *client) 809 847 { 810 848 struct mcp23s08 *mcp = i2c_get_clientdata(client); 811 - 812 - if (client->irq && mcp->irq_controller) 813 - mcp23s08_irq_teardown(mcp); 814 849 815 850 gpiochip_remove(&mcp->chip); 816 851 kfree(mcp); ··· 976 1017 if (!data->mcp[addr]) 977 1018 continue; 978 1019 979 - if (spi->irq && data->mcp[addr]->irq_controller) 980 - mcp23s08_irq_teardown(data->mcp[addr]); 981 1020 gpiochip_remove(&data->mcp[addr]->chip); 982 1021 } 983 1022
+12 -10
drivers/gpio/gpio-menz127.c
··· 35 35 struct men_z127_gpio { 36 36 struct gpio_chip gc; 37 37 void __iomem *reg_base; 38 - struct mcb_device *mdev; 39 38 struct resource *mem; 40 39 }; 41 40 ··· 42 43 unsigned debounce) 43 44 { 44 45 struct men_z127_gpio *priv = gpiochip_get_data(gc); 45 - struct device *dev = &priv->mdev->dev; 46 + struct device *dev = gc->parent; 46 47 unsigned int rnd; 47 48 u32 db_en, db_cnt; 48 49 ··· 87 88 return 0; 88 89 } 89 90 90 - static int men_z127_request(struct gpio_chip *gc, unsigned gpio_pin) 91 + static int men_z127_set_single_ended(struct gpio_chip *gc, 92 + unsigned offset, 93 + enum single_ended_mode mode) 91 94 { 92 95 struct men_z127_gpio *priv = gpiochip_get_data(gc); 93 96 u32 od_en; 94 97 95 - if (gpio_pin >= gc->ngpio) 96 - return -EINVAL; 98 + if (mode != LINE_MODE_OPEN_DRAIN && 99 + mode != LINE_MODE_PUSH_PULL) 100 + return -ENOTSUPP; 97 101 98 102 spin_lock(&gc->bgpio_lock); 99 103 od_en = readl(priv->reg_base + MEN_Z127_ODER); 100 104 101 - if (gpiochip_line_is_open_drain(gc, gpio_pin)) 102 - od_en |= BIT(gpio_pin); 105 + if (mode == LINE_MODE_OPEN_DRAIN) 106 + od_en |= BIT(offset); 103 107 else 104 - od_en &= ~BIT(gpio_pin); 108 + /* Implicitly LINE_MODE_PUSH_PULL */ 109 + od_en &= ~BIT(offset); 105 110 106 111 writel(od_en, priv->reg_base + MEN_Z127_ODER); 107 112 spin_unlock(&gc->bgpio_lock); ··· 138 135 goto err_release; 139 136 } 140 137 141 - men_z127_gpio->mdev = mdev; 142 138 mcb_set_drvdata(mdev, men_z127_gpio); 143 139 144 140 ret = bgpio_init(&men_z127_gpio->gc, &mdev->dev, 4, ··· 150 148 goto err_unmap; 151 149 152 150 men_z127_gpio->gc.set_debounce = men_z127_debounce; 153 - men_z127_gpio->gc.request = men_z127_request; 151 + men_z127_gpio->gc.set_single_ended = men_z127_set_single_ended; 154 152 155 153 ret = gpiochip_add_data(&men_z127_gpio->gc, men_z127_gpio); 156 154 if (ret) {
+1 -6
drivers/gpio/gpio-moxart.c
··· 15 15 #include <linux/irq.h> 16 16 #include <linux/io.h> 17 17 #include <linux/platform_device.h> 18 - #include <linux/module.h> 19 18 #include <linux/of_address.h> 20 19 #include <linux/of_gpio.h> 21 20 #include <linux/pinctrl/consumer.h> ··· 81 82 }, 82 83 .probe = moxart_gpio_probe, 83 84 }; 84 - module_platform_driver(moxart_gpio_driver); 85 - 86 - MODULE_DESCRIPTION("MOXART GPIO chip driver"); 87 - MODULE_LICENSE("GPL"); 88 - MODULE_AUTHOR("Jonas Jensen <jonas.jensen@gmail.com>"); 85 + builtin_platform_driver(moxart_gpio_driver);
+2 -3
drivers/gpio/gpio-mvebu.c
··· 34 34 */ 35 35 36 36 #include <linux/err.h> 37 - #include <linux/module.h> 37 + #include <linux/init.h> 38 38 #include <linux/gpio.h> 39 39 #include <linux/irq.h> 40 40 #include <linux/slab.h> ··· 557 557 /* sentinel */ 558 558 }, 559 559 }; 560 - MODULE_DEVICE_TABLE(of, mvebu_gpio_of_match); 561 560 562 561 static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state) 563 562 { ··· 837 838 .suspend = mvebu_gpio_suspend, 838 839 .resume = mvebu_gpio_resume, 839 840 }; 840 - module_platform_driver(mvebu_gpio_driver); 841 + builtin_platform_driver(mvebu_gpio_driver);
+8 -18
drivers/gpio/gpio-octeon.c
··· 83 83 struct octeon_gpio *gpio; 84 84 struct gpio_chip *chip; 85 85 struct resource *res_mem; 86 + void __iomem *reg_base; 86 87 int err = 0; 87 88 88 89 gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); ··· 92 91 chip = &gpio->chip; 93 92 94 93 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 95 - if (res_mem == NULL) { 96 - dev_err(&pdev->dev, "found no memory resource\n"); 97 - err = -ENXIO; 98 - goto out; 99 - } 100 - if (!devm_request_mem_region(&pdev->dev, res_mem->start, 101 - resource_size(res_mem), 102 - res_mem->name)) { 103 - dev_err(&pdev->dev, "request_mem_region failed\n"); 104 - err = -ENXIO; 105 - goto out; 106 - } 107 - gpio->register_base = (u64)devm_ioremap(&pdev->dev, res_mem->start, 108 - resource_size(res_mem)); 94 + reg_base = devm_ioremap_resource(&pdev->dev, res_mem); 95 + if (IS_ERR(reg_base)) 96 + return PTR_ERR(reg_base); 109 97 98 + gpio->register_base = (u64)reg_base; 110 99 pdev->dev.platform_data = chip; 111 100 chip->label = "octeon-gpio"; 112 101 chip->parent = &pdev->dev; ··· 110 119 chip->set = octeon_gpio_set; 111 120 err = devm_gpiochip_add_data(&pdev->dev, chip, gpio); 112 121 if (err) 113 - goto out; 122 + return err; 114 123 115 124 dev_info(&pdev->dev, "OCTEON GPIO driver probed.\n"); 116 - out: 117 - return err; 125 + return 0; 118 126 } 119 127 120 - static struct of_device_id octeon_gpio_match[] = { 128 + static const struct of_device_id octeon_gpio_match[] = { 121 129 { 122 130 .compatible = "cavium,octeon-3860-gpio", 123 131 },
+2 -40
drivers/gpio/gpio-omap.c
··· 611 611 omap_disable_gpio_irqbank(bank, BIT(offset)); 612 612 } 613 613 614 - /* 615 - * Note that ENAWAKEUP needs to be enabled in GPIO_SYSCONFIG register. 616 - * 1510 does not seem to have a wake-up register. If JTAG is connected 617 - * to the target, system will wake up always on GPIO events. While 618 - * system is running all registered GPIO interrupts need to have wake-up 619 - * enabled. When system is suspended, only selected GPIO interrupts need 620 - * to have wake-up enabled. 621 - */ 622 - static int omap_set_gpio_wakeup(struct gpio_bank *bank, unsigned offset, 623 - int enable) 624 - { 625 - u32 gpio_bit = BIT(offset); 626 - unsigned long flags; 627 - 628 - if (bank->non_wakeup_gpios & gpio_bit) { 629 - dev_err(bank->chip.parent, 630 - "Unable to modify wakeup on non-wakeup GPIO%d\n", 631 - offset); 632 - return -EINVAL; 633 - } 634 - 635 - raw_spin_lock_irqsave(&bank->lock, flags); 636 - if (enable) 637 - bank->context.wake_en |= gpio_bit; 638 - else 639 - bank->context.wake_en &= ~gpio_bit; 640 - 641 - writel_relaxed(bank->context.wake_en, bank->base + bank->regs->wkup_en); 642 - raw_spin_unlock_irqrestore(&bank->lock, flags); 643 - 644 - return 0; 645 - } 646 - 647 614 /* Use disable_irq_wake() and enable_irq_wake() functions from drivers */ 648 615 static int omap_gpio_wake_enable(struct irq_data *d, unsigned int enable) 649 616 { 650 617 struct gpio_bank *bank = omap_irq_data_get_bank(d); 651 - unsigned offset = d->hwirq; 652 - int ret; 653 618 654 - ret = omap_set_gpio_wakeup(bank, offset, enable); 655 - if (!ret) 656 - ret = irq_set_irq_wake(bank->irq, enable); 657 - 658 - return ret; 619 + return irq_set_irq_wake(bank->irq, enable); 659 620 } 660 621 661 622 static int omap_gpio_request(struct gpio_chip *chip, unsigned offset) ··· 1148 1187 irqc->irq_bus_lock = omap_gpio_irq_bus_lock, 1149 1188 irqc->irq_bus_sync_unlock = gpio_irq_bus_sync_unlock, 1150 1189 irqc->name = dev_name(&pdev->dev); 1190 + irqc->flags = IRQCHIP_MASK_ON_SUSPEND; 1151 1191 1152 1192 bank->irq = platform_get_irq(pdev, 0); 1153 1193 if (bank->irq <= 0) {
+1 -12
drivers/gpio/gpio-palmas.c
··· 20 20 21 21 #include <linux/gpio.h> 22 22 #include <linux/kernel.h> 23 - #include <linux/module.h> 23 + #include <linux/init.h> 24 24 #include <linux/mfd/palmas.h> 25 25 #include <linux/of.h> 26 26 #include <linux/of_device.h> ··· 218 218 return platform_driver_register(&palmas_gpio_driver); 219 219 } 220 220 subsys_initcall(palmas_gpio_init); 221 - 222 - static void __exit palmas_gpio_exit(void) 223 - { 224 - platform_driver_unregister(&palmas_gpio_driver); 225 - } 226 - module_exit(palmas_gpio_exit); 227 - 228 - MODULE_ALIAS("platform:palmas-gpio"); 229 - MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); 230 - MODULE_DESCRIPTION("GPIO driver for TI Palmas series PMICs"); 231 - MODULE_LICENSE("GPL v2");
+41 -1
drivers/gpio/gpio-pca953x.c
··· 38 38 #define PCA957X_MSK 6 39 39 #define PCA957X_INTS 7 40 40 41 + #define PCAL953X_IN_LATCH 34 42 + #define PCAL953X_INT_MASK 37 43 + #define PCAL953X_INT_STAT 38 44 + 41 45 #define PCA_GPIO_MASK 0x00FF 42 46 #define PCA_INT 0x0100 47 + #define PCA_PCAL 0x0200 43 48 #define PCA953X_TYPE 0x1000 44 49 #define PCA957X_TYPE 0x2000 45 50 #define PCA_TYPE_MASK 0xF000 ··· 82 77 MODULE_DEVICE_TABLE(i2c, pca953x_id); 83 78 84 79 static const struct acpi_device_id pca953x_acpi_ids[] = { 85 - { "INT3491", 16 | PCA953X_TYPE | PCA_INT, }, 80 + { "INT3491", 16 | PCA953X_TYPE | PCA_INT | PCA_PCAL, }, 86 81 { } 87 82 }; 88 83 MODULE_DEVICE_TABLE(acpi, pca953x_acpi_ids); ··· 442 437 struct pca953x_chip *chip = gpiochip_get_data(gc); 443 438 u8 new_irqs; 444 439 int level, i; 440 + u8 invert_irq_mask[MAX_BANK]; 441 + 442 + if (chip->driver_data & PCA_PCAL) { 443 + /* Enable latch on interrupt-enabled inputs */ 444 + pca953x_write_regs(chip, PCAL953X_IN_LATCH, chip->irq_mask); 445 + 446 + for (i = 0; i < NBANK(chip); i++) 447 + invert_irq_mask[i] = ~chip->irq_mask[i]; 448 + 449 + /* Unmask enabled interrupts */ 450 + pca953x_write_regs(chip, PCAL953X_INT_MASK, invert_irq_mask); 451 + } 445 452 446 453 /* Look for any newly setup interrupt */ 447 454 for (i = 0; i < NBANK(chip); i++) { ··· 514 497 bool trigger_seen = false; 515 498 u8 trigger[MAX_BANK]; 516 499 int ret, i, offset = 0; 500 + 501 + if (chip->driver_data & PCA_PCAL) { 502 + /* Read the current interrupt status from the device */ 503 + ret = pca953x_read_regs(chip, PCAL953X_INT_STAT, trigger); 504 + if (ret) 505 + return false; 506 + 507 + /* Check latched inputs and clear interrupt status */ 508 + ret = pca953x_read_regs(chip, PCA953X_INPUT, cur_stat); 509 + if (ret) 510 + return false; 511 + 512 + for (i = 0; i < NBANK(chip); i++) { 513 + /* Apply filter for rising/falling edge selection */ 514 + pending[i] = (~cur_stat[i] & chip->irq_trig_fall[i]) | 515 + (cur_stat[i] & chip->irq_trig_raise[i]); 516 + pending[i] &= trigger[i]; 517 + if (pending[i]) 518 + pending_seen = true; 519 + } 520 + 521 + return pending_seen; 522 + } 517 523 518 524 switch (chip->chip_type) { 519 525 case PCA953X_TYPE:
+12 -14
drivers/gpio/gpio-pl061.c
··· 1 1 /* 2 2 * Copyright (C) 2008, 2009 Provigent Ltd. 3 3 * 4 + * Author: Baruch Siach <baruch@tkos.co.il> 5 + * 4 6 * This program is free software; you can redistribute it and/or modify 5 7 * it under the terms of the GNU General Public License version 2 as 6 8 * published by the Free Software Foundation. ··· 13 11 */ 14 12 #include <linux/spinlock.h> 15 13 #include <linux/errno.h> 16 - #include <linux/module.h> 14 + #include <linux/init.h> 17 15 #include <linux/io.h> 18 16 #include <linux/ioport.h> 19 17 #include <linux/interrupt.h> ··· 61 59 #endif 62 60 }; 63 61 62 + static int pl061_get_direction(struct gpio_chip *gc, unsigned offset) 63 + { 64 + struct pl061_gpio *chip = gpiochip_get_data(gc); 65 + 66 + return !(readb(chip->base + GPIODIR) & BIT(offset)); 67 + } 68 + 64 69 static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) 65 70 { 66 71 struct pl061_gpio *chip = gpiochip_get_data(gc); 67 72 unsigned long flags; 68 73 unsigned char gpiodir; 69 - 70 - if (offset >= gc->ngpio) 71 - return -EINVAL; 72 74 73 75 spin_lock_irqsave(&chip->lock, flags); 74 76 gpiodir = readb(chip->base + GPIODIR); ··· 89 83 struct pl061_gpio *chip = gpiochip_get_data(gc); 90 84 unsigned long flags; 91 85 unsigned char gpiodir; 92 - 93 - if (offset >= gc->ngpio) 94 - return -EINVAL; 95 86 96 87 spin_lock_irqsave(&chip->lock, flags); 97 88 writeb(!!value << offset, chip->base + (BIT(offset + 2))); ··· 322 319 chip->gc.free = gpiochip_generic_free; 323 320 } 324 321 322 + chip->gc.get_direction = pl061_get_direction; 325 323 chip->gc.direction_input = pl061_direction_input; 326 324 chip->gc.direction_output = pl061_direction_output; 327 325 chip->gc.get = pl061_get_value; ··· 433 429 { 0, 0 }, 434 430 }; 435 431 436 - MODULE_DEVICE_TABLE(amba, pl061_ids); 437 - 438 432 static struct amba_driver pl061_gpio_driver = { 439 433 .drv = { 440 434 .name = "pl061_gpio", ··· 448 446 { 449 447 return amba_driver_register(&pl061_gpio_driver); 450 448 } 451 - module_init(pl061_gpio_init); 452 - 453 - MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); 454 - MODULE_DESCRIPTION("PL061 GPIO driver"); 455 - MODULE_LICENSE("GPL"); 449 + device_initcall(pl061_gpio_init);
-12
drivers/gpio/gpio-rc5t583.c
··· 23 23 #include <linux/init.h> 24 24 #include <linux/kernel.h> 25 25 #include <linux/slab.h> 26 - #include <linux/module.h> 27 26 #include <linux/platform_device.h> 28 27 #include <linux/device.h> 29 28 #include <linux/gpio.h> ··· 151 152 return platform_driver_register(&rc5t583_gpio_driver); 152 153 } 153 154 subsys_initcall(rc5t583_gpio_init); 154 - 155 - static void __exit rc5t583_gpio_exit(void) 156 - { 157 - platform_driver_unregister(&rc5t583_gpio_driver); 158 - } 159 - module_exit(rc5t583_gpio_exit); 160 - 161 - MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); 162 - MODULE_DESCRIPTION("GPIO interface for RC5T583"); 163 - MODULE_LICENSE("GPL v2"); 164 - MODULE_ALIAS("platform:rc5t583-gpio");
+20
drivers/gpio/gpio-rcar.c
··· 284 284 spin_unlock_irqrestore(&p->lock, flags); 285 285 } 286 286 287 + static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask, 288 + unsigned long *bits) 289 + { 290 + struct gpio_rcar_priv *p = gpiochip_get_data(chip); 291 + unsigned long flags; 292 + u32 val, bankmask; 293 + 294 + bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0); 295 + if (!bankmask) 296 + return; 297 + 298 + spin_lock_irqsave(&p->lock, flags); 299 + val = gpio_rcar_read(p, OUTDT); 300 + val &= ~bankmask; 301 + val |= (bankmask & bits[0]); 302 + gpio_rcar_write(p, OUTDT, val); 303 + spin_unlock_irqrestore(&p->lock, flags); 304 + } 305 + 287 306 static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset, 288 307 int value) 289 308 { ··· 444 425 gpio_chip->get = gpio_rcar_get; 445 426 gpio_chip->direction_output = gpio_rcar_direction_output; 446 427 gpio_chip->set = gpio_rcar_set; 428 + gpio_chip->set_multiple = gpio_rcar_set_multiple; 447 429 gpio_chip->label = name; 448 430 gpio_chip->parent = dev; 449 431 gpio_chip->owner = THIS_MODULE;
+6 -22
drivers/gpio/gpio-sodaville.c
··· 3 3 * 4 4 * Copyright (c) 2010, 2011 Intel Corporation 5 5 * 6 + * Author: Hans J. Koch <hjk@linutronix.de> 7 + * 6 8 * This program is free software; you can redistribute it and/or modify 7 9 * it under the terms of the GNU General Public License 2 as published 8 10 * by the Free Software Foundation. ··· 17 15 #include <linux/irq.h> 18 16 #include <linux/interrupt.h> 19 17 #include <linux/kernel.h> 20 - #include <linux/module.h> 21 18 #include <linux/pci.h> 22 19 #include <linux/platform_device.h> 23 20 #include <linux/of_irq.h> ··· 258 257 return ret; 259 258 } 260 259 261 - static void sdv_gpio_remove(struct pci_dev *pdev) 262 - { 263 - struct sdv_gpio_chip_data *sd = pci_get_drvdata(pdev); 264 - 265 - free_irq(pdev->irq, sd); 266 - irq_free_descs(sd->irq_base, SDV_NUM_PUB_GPIOS); 267 - 268 - gpiochip_remove(&sd->chip); 269 - pci_release_region(pdev, GPIO_BAR); 270 - iounmap(sd->gpio_pub_base); 271 - pci_disable_device(pdev); 272 - kfree(sd); 273 - } 274 - 275 260 static const struct pci_device_id sdv_gpio_pci_ids[] = { 276 261 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_SDV_GPIO) }, 277 262 { 0, }, 278 263 }; 279 264 280 265 static struct pci_driver sdv_gpio_driver = { 266 + .driver = { 267 + .suppress_bind_attrs = true, 268 + }, 281 269 .name = DRV_NAME, 282 270 .id_table = sdv_gpio_pci_ids, 283 271 .probe = sdv_gpio_probe, 284 - .remove = sdv_gpio_remove, 285 272 }; 286 - 287 - module_pci_driver(sdv_gpio_driver); 288 - 289 - MODULE_AUTHOR("Hans J. Koch <hjk@linutronix.de>"); 290 - MODULE_DESCRIPTION("GPIO interface for Intel Sodaville SoCs"); 291 - MODULE_LICENSE("GPL v2"); 273 + builtin_pci_driver(sdv_gpio_driver);
+2 -6
drivers/gpio/gpio-sta2x11.c
··· 20 20 * 21 21 */ 22 22 23 - #include <linux/module.h> 23 + #include <linux/init.h> 24 24 #include <linux/kernel.h> 25 25 #include <linux/slab.h> 26 26 #include <linux/gpio.h> ··· 432 432 }, 433 433 .probe = gsta_probe, 434 434 }; 435 - 436 - module_platform_driver(sta2x11_gpio_platform_driver); 437 - 438 - MODULE_LICENSE("GPL v2"); 439 - MODULE_DESCRIPTION("sta2x11_gpio GPIO driver"); 435 + builtin_platform_driver(sta2x11_gpio_platform_driver);
+5 -26
drivers/gpio/gpio-stmpe.c
··· 5 5 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 6 6 */ 7 7 8 - #include <linux/module.h> 9 8 #include <linux/init.h> 10 9 #include <linux/platform_device.h> 11 10 #include <linux/slab.h> ··· 412 413 return ret; 413 414 } 414 415 415 - static int stmpe_gpio_remove(struct platform_device *pdev) 416 - { 417 - struct stmpe_gpio *stmpe_gpio = platform_get_drvdata(pdev); 418 - struct stmpe *stmpe = stmpe_gpio->stmpe; 419 - 420 - gpiochip_remove(&stmpe_gpio->chip); 421 - stmpe_disable(stmpe, STMPE_BLOCK_GPIO); 422 - kfree(stmpe_gpio); 423 - 424 - return 0; 425 - } 426 - 427 416 static struct platform_driver stmpe_gpio_driver = { 428 - .driver.name = "stmpe-gpio", 429 - .driver.owner = THIS_MODULE, 417 + .driver = { 418 + .suppress_bind_attrs = true, 419 + .name = "stmpe-gpio", 420 + .owner = THIS_MODULE, 421 + }, 430 422 .probe = stmpe_gpio_probe, 431 - .remove = stmpe_gpio_remove, 432 423 }; 433 424 434 425 static int __init stmpe_gpio_init(void) ··· 426 437 return platform_driver_register(&stmpe_gpio_driver); 427 438 } 428 439 subsys_initcall(stmpe_gpio_init); 429 - 430 - static void __exit stmpe_gpio_exit(void) 431 - { 432 - platform_driver_unregister(&stmpe_gpio_driver); 433 - } 434 - module_exit(stmpe_gpio_exit); 435 - 436 - MODULE_LICENSE("GPL v2"); 437 - MODULE_DESCRIPTION("STMPExxxx GPIO driver"); 438 - MODULE_AUTHOR("Rabin Vincent <rabin.vincent@stericsson.com>");
+82 -18
drivers/gpio/gpio-sx150x.c
··· 1 1 /* Copyright (c) 2010, Code Aurora Forum. All rights reserved. 2 2 * 3 + * Driver for Semtech SX150X I2C GPIO Expanders 4 + * 5 + * Author: Gregory Bean <gbean@codeaurora.org> 6 + * 3 7 * This program is free software; you can redistribute it and/or modify 4 8 * it under the terms of the GNU General Public License version 2 and 5 9 * only version 2 as published by the Free Software Foundation. ··· 23 19 #include <linux/init.h> 24 20 #include <linux/interrupt.h> 25 21 #include <linux/irq.h> 26 - #include <linux/module.h> 27 22 #include <linux/mutex.h> 28 23 #include <linux/slab.h> 29 - #include <linux/i2c/sx150x.h> 30 24 #include <linux/of.h> 31 25 #include <linux/of_address.h> 32 26 #include <linux/of_irq.h> ··· 82 80 struct sx150x_456_pri x456; 83 81 struct sx150x_789_pri x789; 84 82 } pri; 83 + }; 84 + 85 + /** 86 + * struct sx150x_platform_data - config data for SX150x driver 87 + * @gpio_base: The index number of the first GPIO assigned to this 88 + * GPIO expander. The expander will create a block of 89 + * consecutively numbered gpios beginning at the given base, 90 + * with the size of the block depending on the model of the 91 + * expander chip. 92 + * @oscio_is_gpo: If set to true, the driver will configure OSCIO as a GPO 93 + * instead of as an oscillator, increasing the size of the 94 + * GP(I)O pool created by this expander by one. The 95 + * output-only GPO pin will be added at the end of the block. 96 + * @io_pullup_ena: A bit-mask which enables or disables the pull-up resistor 97 + * for each IO line in the expander. Setting the bit at 98 + * position n will enable the pull-up for the IO at 99 + * the corresponding offset. For chips with fewer than 100 + * 16 IO pins, high-end bits are ignored. 101 + * @io_pulldn_ena: A bit-mask which enables-or disables the pull-down 102 + * resistor for each IO line in the expander. Setting the 103 + * bit at position n will enable the pull-down for the IO at 104 + * the corresponding offset. For chips with fewer than 105 + * 16 IO pins, high-end bits are ignored. 106 + * @io_polarity: A bit-mask which enables polarity inversion for each IO line 107 + * in the expander. Setting the bit at position n inverts 108 + * the polarity of that IO line, while clearing it results 109 + * in normal polarity. For chips with fewer than 16 IO pins, 110 + * high-end bits are ignored. 111 + * @irq_summary: The 'summary IRQ' line to which the GPIO expander's INT line 112 + * is connected, via which it reports interrupt events 113 + * across all GPIO lines. This must be a real, 114 + * pre-existing IRQ line. 115 + * Setting this value < 0 disables the irq_chip functionality 116 + * of the driver. 117 + * @irq_base: The first 'virtual IRQ' line at which our block of GPIO-based 118 + * IRQ lines will appear. Similarly to gpio_base, the expander 119 + * will create a block of irqs beginning at this number. 120 + * This value is ignored if irq_summary is < 0. 121 + * @reset_during_probe: If set to true, the driver will trigger a full 122 + * reset of the chip at the beginning of the probe 123 + * in order to place it in a known state. 124 + */ 125 + struct sx150x_platform_data { 126 + unsigned gpio_base; 127 + bool oscio_is_gpo; 128 + u16 io_pullup_ena; 129 + u16 io_pulldn_ena; 130 + u16 io_polarity; 131 + int irq_summary; 132 + unsigned irq_base; 133 + bool reset_during_probe; 85 134 }; 86 135 87 136 struct sx150x_chip { ··· 407 354 mutex_unlock(&chip->lock); 408 355 } 409 356 357 + static int sx150x_gpio_set_single_ended(struct gpio_chip *gc, 358 + unsigned offset, 359 + enum single_ended_mode mode) 360 + { 361 + struct sx150x_chip *chip = gpiochip_get_data(gc); 362 + 363 + /* On the SX160X 789 we can set open drain */ 364 + if (chip->dev_cfg->model != SX150X_789) 365 + return -ENOTSUPP; 366 + 367 + if (mode == LINE_MODE_PUSH_PULL) 368 + return sx150x_write_cfg(chip, 369 + offset, 370 + 1, 371 + chip->dev_cfg->pri.x789.reg_drain, 372 + 0); 373 + 374 + if (mode == LINE_MODE_OPEN_DRAIN) 375 + return sx150x_write_cfg(chip, 376 + offset, 377 + 1, 378 + chip->dev_cfg->pri.x789.reg_drain, 379 + 1); 380 + return -ENOTSUPP; 381 + } 382 + 410 383 static int sx150x_gpio_direction_input(struct gpio_chip *gc, unsigned offset) 411 384 { 412 385 struct sx150x_chip *chip = gpiochip_get_data(gc); ··· 587 508 chip->gpio_chip.direction_output = sx150x_gpio_direction_output; 588 509 chip->gpio_chip.get = sx150x_gpio_get; 589 510 chip->gpio_chip.set = sx150x_gpio_set; 511 + chip->gpio_chip.set_single_ended = sx150x_gpio_set_single_ended; 590 512 chip->gpio_chip.base = pdata->gpio_base; 591 513 chip->gpio_chip.can_sleep = true; 592 514 chip->gpio_chip.ngpio = chip->dev_cfg->ngpios; ··· 676 596 return err; 677 597 678 598 if (chip->dev_cfg->model == SX150X_789) { 679 - err = sx150x_init_io(chip, 680 - chip->dev_cfg->pri.x789.reg_drain, 681 - pdata->io_open_drain_ena); 682 - if (err < 0) 683 - return err; 684 - 685 599 err = sx150x_init_io(chip, 686 600 chip->dev_cfg->pri.x789.reg_polarity, 687 601 pdata->io_polarity); ··· 792 718 return i2c_add_driver(&sx150x_driver); 793 719 } 794 720 subsys_initcall(sx150x_init); 795 - 796 - static void __exit sx150x_exit(void) 797 - { 798 - return i2c_del_driver(&sx150x_driver); 799 - } 800 - module_exit(sx150x_exit); 801 - 802 - MODULE_AUTHOR("Gregory Bean <gbean@codeaurora.org>"); 803 - MODULE_DESCRIPTION("Driver for Semtech SX150X I2C GPIO Expanders"); 804 - MODULE_LICENSE("GPL v2");
+50 -19
drivers/gpio/gpio-tc3589x.c
··· 6 6 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 7 7 */ 8 8 9 - #include <linux/module.h> 10 9 #include <linux/init.h> 11 10 #include <linux/platform_device.h> 12 11 #include <linux/slab.h> 13 - #include <linux/gpio.h> 12 + #include <linux/gpio/driver.h> 14 13 #include <linux/of.h> 15 14 #include <linux/interrupt.h> 16 15 #include <linux/mfd/tc3589x.h> 16 + #include <linux/bitops.h> 17 17 18 18 /* 19 19 * These registers are modified under the irq bus lock and cached to avoid ··· 39 39 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); 40 40 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; 41 41 u8 reg = TC3589x_GPIODATA0 + (offset / 8) * 2; 42 - u8 mask = 1 << (offset % 8); 42 + u8 mask = BIT(offset % 8); 43 43 int ret; 44 44 45 45 ret = tc3589x_reg_read(tc3589x, reg); ··· 55 55 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; 56 56 u8 reg = TC3589x_GPIODATA0 + (offset / 8) * 2; 57 57 unsigned pos = offset % 8; 58 - u8 data[] = {!!val << pos, 1 << pos}; 58 + u8 data[] = {val ? BIT(pos) : 0, BIT(pos)}; 59 59 60 60 tc3589x_block_write(tc3589x, reg, ARRAY_SIZE(data), data); 61 61 } ··· 70 70 71 71 tc3589x_gpio_set(chip, offset, val); 72 72 73 - return tc3589x_set_bits(tc3589x, reg, 1 << pos, 1 << pos); 73 + return tc3589x_set_bits(tc3589x, reg, BIT(pos), BIT(pos)); 74 74 } 75 75 76 76 static int tc3589x_gpio_direction_input(struct gpio_chip *chip, ··· 81 81 u8 reg = TC3589x_GPIODIR0 + offset / 8; 82 82 unsigned pos = offset % 8; 83 83 84 - return tc3589x_set_bits(tc3589x, reg, 1 << pos, 0); 84 + return tc3589x_set_bits(tc3589x, reg, BIT(pos), 0); 85 + } 86 + 87 + static int tc3589x_gpio_single_ended(struct gpio_chip *chip, 88 + unsigned offset, 89 + enum single_ended_mode mode) 90 + { 91 + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); 92 + struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; 93 + /* 94 + * These registers are alterated at each second address 95 + * ODM bit 0 = drive to GND or Hi-Z (open drain) 96 + * ODM bit 1 = drive to VDD or Hi-Z (open source) 97 + */ 98 + u8 odmreg = TC3589x_GPIOODM0 + (offset / 8) * 2; 99 + u8 odereg = TC3589x_GPIOODE0 + (offset / 8) * 2; 100 + unsigned pos = offset % 8; 101 + int ret; 102 + 103 + switch(mode) { 104 + case LINE_MODE_OPEN_DRAIN: 105 + /* Set open drain mode */ 106 + ret = tc3589x_set_bits(tc3589x, odmreg, BIT(pos), 0); 107 + if (ret) 108 + return ret; 109 + /* Enable open drain/source mode */ 110 + return tc3589x_set_bits(tc3589x, odereg, BIT(pos), BIT(pos)); 111 + case LINE_MODE_OPEN_SOURCE: 112 + /* Set open source mode */ 113 + ret = tc3589x_set_bits(tc3589x, odmreg, BIT(pos), BIT(pos)); 114 + if (ret) 115 + return ret; 116 + /* Enable open drain/source mode */ 117 + return tc3589x_set_bits(tc3589x, odereg, BIT(pos), BIT(pos)); 118 + case LINE_MODE_PUSH_PULL: 119 + /* Disable open drain/source mode */ 120 + return tc3589x_set_bits(tc3589x, odereg, BIT(pos), 0); 121 + default: 122 + break; 123 + } 124 + return -ENOTSUPP; 85 125 } 86 126 87 127 static struct gpio_chip template_chip = { ··· 131 91 .get = tc3589x_gpio_get, 132 92 .direction_output = tc3589x_gpio_direction_output, 133 93 .set = tc3589x_gpio_set, 94 + .set_single_ended = tc3589x_gpio_single_ended, 134 95 .can_sleep = true, 135 96 }; 136 97 ··· 141 100 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); 142 101 int offset = d->hwirq; 143 102 int regoffset = offset / 8; 144 - int mask = 1 << (offset % 8); 103 + int mask = BIT(offset % 8); 145 104 146 105 if (type == IRQ_TYPE_EDGE_BOTH) { 147 106 tc3589x_gpio->regs[REG_IBE][regoffset] |= mask; ··· 206 165 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); 207 166 int offset = d->hwirq; 208 167 int regoffset = offset / 8; 209 - int mask = 1 << (offset % 8); 168 + int mask = BIT(offset % 8); 210 169 211 170 tc3589x_gpio->regs[REG_IE][regoffset] &= ~mask; 212 171 } ··· 217 176 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(gc); 218 177 int offset = d->hwirq; 219 178 int regoffset = offset / 8; 220 - int mask = 1 << (offset % 8); 179 + int mask = BIT(offset % 8); 221 180 222 181 tc3589x_gpio->regs[REG_IE][regoffset] |= mask; 223 182 } ··· 352 311 return platform_driver_register(&tc3589x_gpio_driver); 353 312 } 354 313 subsys_initcall(tc3589x_gpio_init); 355 - 356 - static void __exit tc3589x_gpio_exit(void) 357 - { 358 - platform_driver_unregister(&tc3589x_gpio_driver); 359 - } 360 - module_exit(tc3589x_gpio_exit); 361 - 362 - MODULE_LICENSE("GPL v2"); 363 - MODULE_DESCRIPTION("TC3589x GPIO driver"); 364 - MODULE_AUTHOR("Hanumath Prasad, Rabin Vincent");
+306 -179
drivers/gpio/gpio-tegra.c
··· 35 35 #define GPIO_PORT(x) (((x) >> 3) & 0x3) 36 36 #define GPIO_BIT(x) ((x) & 0x7) 37 37 38 - #define GPIO_REG(x) (GPIO_BANK(x) * tegra_gpio_bank_stride + \ 38 + #define GPIO_REG(tgi, x) (GPIO_BANK(x) * tgi->soc->bank_stride + \ 39 39 GPIO_PORT(x) * 4) 40 40 41 - #define GPIO_CNF(x) (GPIO_REG(x) + 0x00) 42 - #define GPIO_OE(x) (GPIO_REG(x) + 0x10) 43 - #define GPIO_OUT(x) (GPIO_REG(x) + 0X20) 44 - #define GPIO_IN(x) (GPIO_REG(x) + 0x30) 45 - #define GPIO_INT_STA(x) (GPIO_REG(x) + 0x40) 46 - #define GPIO_INT_ENB(x) (GPIO_REG(x) + 0x50) 47 - #define GPIO_INT_LVL(x) (GPIO_REG(x) + 0x60) 48 - #define GPIO_INT_CLR(x) (GPIO_REG(x) + 0x70) 41 + #define GPIO_CNF(t, x) (GPIO_REG(t, x) + 0x00) 42 + #define GPIO_OE(t, x) (GPIO_REG(t, x) + 0x10) 43 + #define GPIO_OUT(t, x) (GPIO_REG(t, x) + 0X20) 44 + #define GPIO_IN(t, x) (GPIO_REG(t, x) + 0x30) 45 + #define GPIO_INT_STA(t, x) (GPIO_REG(t, x) + 0x40) 46 + #define GPIO_INT_ENB(t, x) (GPIO_REG(t, x) + 0x50) 47 + #define GPIO_INT_LVL(t, x) (GPIO_REG(t, x) + 0x60) 48 + #define GPIO_INT_CLR(t, x) (GPIO_REG(t, x) + 0x70) 49 + #define GPIO_DBC_CNT(t, x) (GPIO_REG(t, x) + 0xF0) 49 50 50 - #define GPIO_MSK_CNF(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x00) 51 - #define GPIO_MSK_OE(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x10) 52 - #define GPIO_MSK_OUT(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0X20) 53 - #define GPIO_MSK_INT_STA(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x40) 54 - #define GPIO_MSK_INT_ENB(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x50) 55 - #define GPIO_MSK_INT_LVL(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x60) 51 + 52 + #define GPIO_MSK_CNF(t, x) (GPIO_REG(t, x) + t->soc->upper_offset + 0x00) 53 + #define GPIO_MSK_OE(t, x) (GPIO_REG(t, x) + t->soc->upper_offset + 0x10) 54 + #define GPIO_MSK_OUT(t, x) (GPIO_REG(t, x) + t->soc->upper_offset + 0X20) 55 + #define GPIO_MSK_DBC_EN(t, x) (GPIO_REG(t, x) + t->soc->upper_offset + 0x30) 56 + #define GPIO_MSK_INT_STA(t, x) (GPIO_REG(t, x) + t->soc->upper_offset + 0x40) 57 + #define GPIO_MSK_INT_ENB(t, x) (GPIO_REG(t, x) + t->soc->upper_offset + 0x50) 58 + #define GPIO_MSK_INT_LVL(t, x) (GPIO_REG(t, x) + t->soc->upper_offset + 0x60) 56 59 57 60 #define GPIO_INT_LVL_MASK 0x010101 58 61 #define GPIO_INT_LVL_EDGE_RISING 0x000101 ··· 64 61 #define GPIO_INT_LVL_LEVEL_HIGH 0x000001 65 62 #define GPIO_INT_LVL_LEVEL_LOW 0x000000 66 63 64 + struct tegra_gpio_info; 65 + 67 66 struct tegra_gpio_bank { 68 67 int bank; 69 68 int irq; 70 69 spinlock_t lvl_lock[4]; 70 + spinlock_t dbc_lock[4]; /* Lock for updating debounce count register */ 71 71 #ifdef CONFIG_PM_SLEEP 72 72 u32 cnf[4]; 73 73 u32 out[4]; ··· 78 72 u32 int_enb[4]; 79 73 u32 int_lvl[4]; 80 74 u32 wake_enb[4]; 75 + u32 dbc_enb[4]; 81 76 #endif 77 + u32 dbc_cnt[4]; 78 + struct tegra_gpio_info *tgi; 82 79 }; 83 80 84 - static struct device *dev; 85 - static struct irq_domain *irq_domain; 86 - static void __iomem *regs; 87 - static u32 tegra_gpio_bank_count; 88 - static u32 tegra_gpio_bank_stride; 89 - static u32 tegra_gpio_upper_offset; 90 - static struct tegra_gpio_bank *tegra_gpio_banks; 81 + struct tegra_gpio_soc_config { 82 + bool debounce_supported; 83 + u32 bank_stride; 84 + u32 upper_offset; 85 + }; 91 86 92 - static inline void tegra_gpio_writel(u32 val, u32 reg) 87 + struct tegra_gpio_info { 88 + struct device *dev; 89 + void __iomem *regs; 90 + struct irq_domain *irq_domain; 91 + struct tegra_gpio_bank *bank_info; 92 + const struct tegra_gpio_soc_config *soc; 93 + struct gpio_chip gc; 94 + struct irq_chip ic; 95 + struct lock_class_key lock_class; 96 + u32 bank_count; 97 + }; 98 + 99 + static inline void tegra_gpio_writel(struct tegra_gpio_info *tgi, 100 + u32 val, u32 reg) 93 101 { 94 - __raw_writel(val, regs + reg); 102 + __raw_writel(val, tgi->regs + reg); 95 103 } 96 104 97 - static inline u32 tegra_gpio_readl(u32 reg) 105 + static inline u32 tegra_gpio_readl(struct tegra_gpio_info *tgi, u32 reg) 98 106 { 99 - return __raw_readl(regs + reg); 107 + return __raw_readl(tgi->regs + reg); 100 108 } 101 109 102 110 static int tegra_gpio_compose(int bank, int port, int bit) ··· 118 98 return (bank << 5) | ((port & 0x3) << 3) | (bit & 0x7); 119 99 } 120 100 121 - static void tegra_gpio_mask_write(u32 reg, int gpio, int value) 101 + static void tegra_gpio_mask_write(struct tegra_gpio_info *tgi, u32 reg, 102 + int gpio, int value) 122 103 { 123 104 u32 val; 124 105 125 106 val = 0x100 << GPIO_BIT(gpio); 126 107 if (value) 127 108 val |= 1 << GPIO_BIT(gpio); 128 - tegra_gpio_writel(val, reg); 109 + tegra_gpio_writel(tgi, val, reg); 129 110 } 130 111 131 - static void tegra_gpio_enable(int gpio) 112 + static void tegra_gpio_enable(struct tegra_gpio_info *tgi, int gpio) 132 113 { 133 - tegra_gpio_mask_write(GPIO_MSK_CNF(gpio), gpio, 1); 114 + tegra_gpio_mask_write(tgi, GPIO_MSK_CNF(tgi, gpio), gpio, 1); 134 115 } 135 116 136 - static void tegra_gpio_disable(int gpio) 117 + static void tegra_gpio_disable(struct tegra_gpio_info *tgi, int gpio) 137 118 { 138 - tegra_gpio_mask_write(GPIO_MSK_CNF(gpio), gpio, 0); 119 + tegra_gpio_mask_write(tgi, GPIO_MSK_CNF(tgi, gpio), gpio, 0); 139 120 } 140 121 141 122 static int tegra_gpio_request(struct gpio_chip *chip, unsigned offset) ··· 146 125 147 126 static void tegra_gpio_free(struct gpio_chip *chip, unsigned offset) 148 127 { 128 + struct tegra_gpio_info *tgi = gpiochip_get_data(chip); 129 + 149 130 pinctrl_free_gpio(offset); 150 - tegra_gpio_disable(offset); 131 + tegra_gpio_disable(tgi, offset); 151 132 } 152 133 153 134 static void tegra_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 154 135 { 155 - tegra_gpio_mask_write(GPIO_MSK_OUT(offset), offset, value); 136 + struct tegra_gpio_info *tgi = gpiochip_get_data(chip); 137 + 138 + tegra_gpio_mask_write(tgi, GPIO_MSK_OUT(tgi, offset), offset, value); 156 139 } 157 140 158 141 static int tegra_gpio_get(struct gpio_chip *chip, unsigned offset) 159 142 { 160 - /* If gpio is in output mode then read from the out value */ 161 - if ((tegra_gpio_readl(GPIO_OE(offset)) >> GPIO_BIT(offset)) & 1) 162 - return (tegra_gpio_readl(GPIO_OUT(offset)) >> 163 - GPIO_BIT(offset)) & 0x1; 143 + struct tegra_gpio_info *tgi = gpiochip_get_data(chip); 144 + int bval = BIT(GPIO_BIT(offset)); 164 145 165 - return (tegra_gpio_readl(GPIO_IN(offset)) >> GPIO_BIT(offset)) & 0x1; 146 + /* If gpio is in output mode then read from the out value */ 147 + if (tegra_gpio_readl(tgi, GPIO_OE(tgi, offset)) & bval) 148 + return !!(tegra_gpio_readl(tgi, GPIO_OUT(tgi, offset)) & bval); 149 + 150 + return !!(tegra_gpio_readl(tgi, GPIO_IN(tgi, offset)) & bval); 166 151 } 167 152 168 153 static int tegra_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 169 154 { 170 - tegra_gpio_mask_write(GPIO_MSK_OE(offset), offset, 0); 171 - tegra_gpio_enable(offset); 155 + struct tegra_gpio_info *tgi = gpiochip_get_data(chip); 156 + 157 + tegra_gpio_mask_write(tgi, GPIO_MSK_OE(tgi, offset), offset, 0); 158 + tegra_gpio_enable(tgi, offset); 172 159 return 0; 173 160 } 174 161 175 162 static int tegra_gpio_direction_output(struct gpio_chip *chip, unsigned offset, 176 163 int value) 177 164 { 165 + struct tegra_gpio_info *tgi = gpiochip_get_data(chip); 166 + 178 167 tegra_gpio_set(chip, offset, value); 179 - tegra_gpio_mask_write(GPIO_MSK_OE(offset), offset, 1); 180 - tegra_gpio_enable(offset); 168 + tegra_gpio_mask_write(tgi, GPIO_MSK_OE(tgi, offset), offset, 1); 169 + tegra_gpio_enable(tgi, offset); 170 + return 0; 171 + } 172 + 173 + static int tegra_gpio_get_direction(struct gpio_chip *chip, unsigned offset) 174 + { 175 + struct tegra_gpio_info *tgi = gpiochip_get_data(chip); 176 + u32 pin_mask = BIT(GPIO_BIT(offset)); 177 + u32 cnf, oe; 178 + 179 + cnf = tegra_gpio_readl(tgi, GPIO_CNF(tgi, offset)); 180 + if (!(cnf & pin_mask)) 181 + return -EINVAL; 182 + 183 + oe = tegra_gpio_readl(tgi, GPIO_OE(tgi, offset)); 184 + 185 + return (oe & pin_mask) ? GPIOF_DIR_OUT : GPIOF_DIR_IN; 186 + } 187 + 188 + static int tegra_gpio_set_debounce(struct gpio_chip *chip, unsigned int offset, 189 + unsigned int debounce) 190 + { 191 + struct tegra_gpio_info *tgi = gpiochip_get_data(chip); 192 + struct tegra_gpio_bank *bank = &tgi->bank_info[GPIO_BANK(offset)]; 193 + unsigned int debounce_ms = DIV_ROUND_UP(debounce, 1000); 194 + unsigned long flags; 195 + int port; 196 + 197 + if (!debounce_ms) { 198 + tegra_gpio_mask_write(tgi, GPIO_MSK_DBC_EN(tgi, offset), 199 + offset, 0); 200 + return 0; 201 + } 202 + 203 + debounce_ms = min(debounce_ms, 255U); 204 + port = GPIO_PORT(offset); 205 + 206 + /* There is only one debounce count register per port and hence 207 + * set the maximum of current and requested debounce time. 208 + */ 209 + spin_lock_irqsave(&bank->dbc_lock[port], flags); 210 + if (bank->dbc_cnt[port] < debounce_ms) { 211 + tegra_gpio_writel(tgi, debounce_ms, GPIO_DBC_CNT(tgi, offset)); 212 + bank->dbc_cnt[port] = debounce_ms; 213 + } 214 + spin_unlock_irqrestore(&bank->dbc_lock[port], flags); 215 + 216 + tegra_gpio_mask_write(tgi, GPIO_MSK_DBC_EN(tgi, offset), offset, 1); 217 + 181 218 return 0; 182 219 } 183 220 184 221 static int tegra_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 185 222 { 186 - return irq_find_mapping(irq_domain, offset); 187 - } 223 + struct tegra_gpio_info *tgi = gpiochip_get_data(chip); 188 224 189 - static struct gpio_chip tegra_gpio_chip = { 190 - .label = "tegra-gpio", 191 - .request = tegra_gpio_request, 192 - .free = tegra_gpio_free, 193 - .direction_input = tegra_gpio_direction_input, 194 - .get = tegra_gpio_get, 195 - .direction_output = tegra_gpio_direction_output, 196 - .set = tegra_gpio_set, 197 - .to_irq = tegra_gpio_to_irq, 198 - .base = 0, 199 - }; 225 + return irq_find_mapping(tgi->irq_domain, offset); 226 + } 200 227 201 228 static void tegra_gpio_irq_ack(struct irq_data *d) 202 229 { 230 + struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); 231 + struct tegra_gpio_info *tgi = bank->tgi; 203 232 int gpio = d->hwirq; 204 233 205 - tegra_gpio_writel(1 << GPIO_BIT(gpio), GPIO_INT_CLR(gpio)); 234 + tegra_gpio_writel(tgi, 1 << GPIO_BIT(gpio), GPIO_INT_CLR(tgi, gpio)); 206 235 } 207 236 208 237 static void tegra_gpio_irq_mask(struct irq_data *d) 209 238 { 239 + struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); 240 + struct tegra_gpio_info *tgi = bank->tgi; 210 241 int gpio = d->hwirq; 211 242 212 - tegra_gpio_mask_write(GPIO_MSK_INT_ENB(gpio), gpio, 0); 243 + tegra_gpio_mask_write(tgi, GPIO_MSK_INT_ENB(tgi, gpio), gpio, 0); 213 244 } 214 245 215 246 static void tegra_gpio_irq_unmask(struct irq_data *d) 216 247 { 248 + struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); 249 + struct tegra_gpio_info *tgi = bank->tgi; 217 250 int gpio = d->hwirq; 218 251 219 - tegra_gpio_mask_write(GPIO_MSK_INT_ENB(gpio), gpio, 1); 252 + tegra_gpio_mask_write(tgi, GPIO_MSK_INT_ENB(tgi, gpio), gpio, 1); 220 253 } 221 254 222 255 static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type) 223 256 { 224 257 int gpio = d->hwirq; 225 258 struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); 259 + struct tegra_gpio_info *tgi = bank->tgi; 226 260 int port = GPIO_PORT(gpio); 227 261 int lvl_type; 228 262 int val; ··· 309 233 return -EINVAL; 310 234 } 311 235 312 - ret = gpiochip_lock_as_irq(&tegra_gpio_chip, gpio); 236 + ret = gpiochip_lock_as_irq(&tgi->gc, gpio); 313 237 if (ret) { 314 - dev_err(dev, "unable to lock Tegra GPIO %d as IRQ\n", gpio); 238 + dev_err(tgi->dev, 239 + "unable to lock Tegra GPIO %d as IRQ\n", gpio); 315 240 return ret; 316 241 } 317 242 318 243 spin_lock_irqsave(&bank->lvl_lock[port], flags); 319 244 320 - val = tegra_gpio_readl(GPIO_INT_LVL(gpio)); 245 + val = tegra_gpio_readl(tgi, GPIO_INT_LVL(tgi, gpio)); 321 246 val &= ~(GPIO_INT_LVL_MASK << GPIO_BIT(gpio)); 322 247 val |= lvl_type << GPIO_BIT(gpio); 323 - tegra_gpio_writel(val, GPIO_INT_LVL(gpio)); 248 + tegra_gpio_writel(tgi, val, GPIO_INT_LVL(tgi, gpio)); 324 249 325 250 spin_unlock_irqrestore(&bank->lvl_lock[port], flags); 326 251 327 - tegra_gpio_mask_write(GPIO_MSK_OE(gpio), gpio, 0); 328 - tegra_gpio_enable(gpio); 252 + tegra_gpio_mask_write(tgi, GPIO_MSK_OE(tgi, gpio), gpio, 0); 253 + tegra_gpio_enable(tgi, gpio); 329 254 330 255 if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) 331 256 irq_set_handler_locked(d, handle_level_irq); ··· 338 261 339 262 static void tegra_gpio_irq_shutdown(struct irq_data *d) 340 263 { 264 + struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); 265 + struct tegra_gpio_info *tgi = bank->tgi; 341 266 int gpio = d->hwirq; 342 267 343 - gpiochip_unlock_as_irq(&tegra_gpio_chip, gpio); 268 + gpiochip_unlock_as_irq(&tgi->gc, gpio); 344 269 } 345 270 346 271 static void tegra_gpio_irq_handler(struct irq_desc *desc) ··· 350 271 int port; 351 272 int pin; 352 273 int unmasked = 0; 274 + int gpio; 275 + u32 lvl; 276 + unsigned long sta; 353 277 struct irq_chip *chip = irq_desc_get_chip(desc); 354 278 struct tegra_gpio_bank *bank = irq_desc_get_handler_data(desc); 279 + struct tegra_gpio_info *tgi = bank->tgi; 355 280 356 281 chained_irq_enter(chip, desc); 357 282 358 283 for (port = 0; port < 4; port++) { 359 - int gpio = tegra_gpio_compose(bank->bank, port, 0); 360 - unsigned long sta = tegra_gpio_readl(GPIO_INT_STA(gpio)) & 361 - tegra_gpio_readl(GPIO_INT_ENB(gpio)); 362 - u32 lvl = tegra_gpio_readl(GPIO_INT_LVL(gpio)); 284 + gpio = tegra_gpio_compose(bank->bank, port, 0); 285 + sta = tegra_gpio_readl(tgi, GPIO_INT_STA(tgi, gpio)) & 286 + tegra_gpio_readl(tgi, GPIO_INT_ENB(tgi, gpio)); 287 + lvl = tegra_gpio_readl(tgi, GPIO_INT_LVL(tgi, gpio)); 363 288 364 289 for_each_set_bit(pin, &sta, 8) { 365 - tegra_gpio_writel(1 << pin, GPIO_INT_CLR(gpio)); 290 + tegra_gpio_writel(tgi, 1 << pin, 291 + GPIO_INT_CLR(tgi, gpio)); 366 292 367 293 /* if gpio is edge triggered, clear condition 368 294 * before executing the handler so that we don't ··· 390 306 #ifdef CONFIG_PM_SLEEP 391 307 static int tegra_gpio_resume(struct device *dev) 392 308 { 309 + struct platform_device *pdev = to_platform_device(dev); 310 + struct tegra_gpio_info *tgi = platform_get_drvdata(pdev); 393 311 unsigned long flags; 394 312 int b; 395 313 int p; 396 314 397 315 local_irq_save(flags); 398 316 399 - for (b = 0; b < tegra_gpio_bank_count; b++) { 400 - struct tegra_gpio_bank *bank = &tegra_gpio_banks[b]; 317 + for (b = 0; b < tgi->bank_count; b++) { 318 + struct tegra_gpio_bank *bank = &tgi->bank_info[b]; 401 319 402 320 for (p = 0; p < ARRAY_SIZE(bank->oe); p++) { 403 321 unsigned int gpio = (b<<5) | (p<<3); 404 - tegra_gpio_writel(bank->cnf[p], GPIO_CNF(gpio)); 405 - tegra_gpio_writel(bank->out[p], GPIO_OUT(gpio)); 406 - tegra_gpio_writel(bank->oe[p], GPIO_OE(gpio)); 407 - tegra_gpio_writel(bank->int_lvl[p], GPIO_INT_LVL(gpio)); 408 - tegra_gpio_writel(bank->int_enb[p], GPIO_INT_ENB(gpio)); 322 + tegra_gpio_writel(tgi, bank->cnf[p], 323 + GPIO_CNF(tgi, gpio)); 324 + 325 + if (tgi->soc->debounce_supported) { 326 + tegra_gpio_writel(tgi, bank->dbc_cnt[p], 327 + GPIO_DBC_CNT(tgi, gpio)); 328 + tegra_gpio_writel(tgi, bank->dbc_enb[p], 329 + GPIO_MSK_DBC_EN(tgi, gpio)); 330 + } 331 + 332 + tegra_gpio_writel(tgi, bank->out[p], 333 + GPIO_OUT(tgi, gpio)); 334 + tegra_gpio_writel(tgi, bank->oe[p], 335 + GPIO_OE(tgi, gpio)); 336 + tegra_gpio_writel(tgi, bank->int_lvl[p], 337 + GPIO_INT_LVL(tgi, gpio)); 338 + tegra_gpio_writel(tgi, bank->int_enb[p], 339 + GPIO_INT_ENB(tgi, gpio)); 409 340 } 410 341 } 411 342 ··· 430 331 431 332 static int tegra_gpio_suspend(struct device *dev) 432 333 { 334 + struct platform_device *pdev = to_platform_device(dev); 335 + struct tegra_gpio_info *tgi = platform_get_drvdata(pdev); 433 336 unsigned long flags; 434 337 int b; 435 338 int p; 436 339 437 340 local_irq_save(flags); 438 - for (b = 0; b < tegra_gpio_bank_count; b++) { 439 - struct tegra_gpio_bank *bank = &tegra_gpio_banks[b]; 341 + for (b = 0; b < tgi->bank_count; b++) { 342 + struct tegra_gpio_bank *bank = &tgi->bank_info[b]; 440 343 441 344 for (p = 0; p < ARRAY_SIZE(bank->oe); p++) { 442 345 unsigned int gpio = (b<<5) | (p<<3); 443 - bank->cnf[p] = tegra_gpio_readl(GPIO_CNF(gpio)); 444 - bank->out[p] = tegra_gpio_readl(GPIO_OUT(gpio)); 445 - bank->oe[p] = tegra_gpio_readl(GPIO_OE(gpio)); 446 - bank->int_enb[p] = tegra_gpio_readl(GPIO_INT_ENB(gpio)); 447 - bank->int_lvl[p] = tegra_gpio_readl(GPIO_INT_LVL(gpio)); 346 + bank->cnf[p] = tegra_gpio_readl(tgi, 347 + GPIO_CNF(tgi, gpio)); 348 + bank->out[p] = tegra_gpio_readl(tgi, 349 + GPIO_OUT(tgi, gpio)); 350 + bank->oe[p] = tegra_gpio_readl(tgi, 351 + GPIO_OE(tgi, gpio)); 352 + if (tgi->soc->debounce_supported) { 353 + bank->dbc_enb[p] = tegra_gpio_readl(tgi, 354 + GPIO_MSK_DBC_EN(tgi, gpio)); 355 + bank->dbc_enb[p] = (bank->dbc_enb[p] << 8) | 356 + bank->dbc_enb[p]; 357 + } 358 + 359 + bank->int_enb[p] = tegra_gpio_readl(tgi, 360 + GPIO_INT_ENB(tgi, gpio)); 361 + bank->int_lvl[p] = tegra_gpio_readl(tgi, 362 + GPIO_INT_LVL(tgi, gpio)); 448 363 449 364 /* Enable gpio irq for wake up source */ 450 - tegra_gpio_writel(bank->wake_enb[p], 451 - GPIO_INT_ENB(gpio)); 365 + tegra_gpio_writel(tgi, bank->wake_enb[p], 366 + GPIO_INT_ENB(tgi, gpio)); 452 367 } 453 368 } 454 369 local_irq_restore(flags); ··· 495 382 496 383 static int dbg_gpio_show(struct seq_file *s, void *unused) 497 384 { 385 + struct tegra_gpio_info *tgi = s->private; 498 386 int i; 499 387 int j; 500 388 501 - for (i = 0; i < tegra_gpio_bank_count; i++) { 389 + for (i = 0; i < tgi->bank_count; i++) { 502 390 for (j = 0; j < 4; j++) { 503 391 int gpio = tegra_gpio_compose(i, j, 0); 504 392 seq_printf(s, 505 393 "%d:%d %02x %02x %02x %02x %02x %02x %06x\n", 506 394 i, j, 507 - tegra_gpio_readl(GPIO_CNF(gpio)), 508 - tegra_gpio_readl(GPIO_OE(gpio)), 509 - tegra_gpio_readl(GPIO_OUT(gpio)), 510 - tegra_gpio_readl(GPIO_IN(gpio)), 511 - tegra_gpio_readl(GPIO_INT_STA(gpio)), 512 - tegra_gpio_readl(GPIO_INT_ENB(gpio)), 513 - tegra_gpio_readl(GPIO_INT_LVL(gpio))); 395 + tegra_gpio_readl(tgi, GPIO_CNF(tgi, gpio)), 396 + tegra_gpio_readl(tgi, GPIO_OE(tgi, gpio)), 397 + tegra_gpio_readl(tgi, GPIO_OUT(tgi, gpio)), 398 + tegra_gpio_readl(tgi, GPIO_IN(tgi, gpio)), 399 + tegra_gpio_readl(tgi, GPIO_INT_STA(tgi, gpio)), 400 + tegra_gpio_readl(tgi, GPIO_INT_ENB(tgi, gpio)), 401 + tegra_gpio_readl(tgi, GPIO_INT_LVL(tgi, gpio))); 514 402 } 515 403 } 516 404 return 0; ··· 519 405 520 406 static int dbg_gpio_open(struct inode *inode, struct file *file) 521 407 { 522 - return single_open(file, dbg_gpio_show, &inode->i_private); 408 + return single_open(file, dbg_gpio_show, inode->i_private); 523 409 } 524 410 525 411 static const struct file_operations debug_fops = { ··· 529 415 .release = single_release, 530 416 }; 531 417 532 - static void tegra_gpio_debuginit(void) 418 + static void tegra_gpio_debuginit(struct tegra_gpio_info *tgi) 533 419 { 534 420 (void) debugfs_create_file("tegra_gpio", S_IRUGO, 535 - NULL, NULL, &debug_fops); 421 + NULL, tgi, &debug_fops); 536 422 } 537 423 538 424 #else 539 425 540 - static inline void tegra_gpio_debuginit(void) 426 + static inline void tegra_gpio_debuginit(struct tegra_gpio_info *tgi) 541 427 { 542 428 } 543 429 544 430 #endif 545 - 546 - static struct irq_chip tegra_gpio_irq_chip = { 547 - .name = "GPIO", 548 - .irq_ack = tegra_gpio_irq_ack, 549 - .irq_mask = tegra_gpio_irq_mask, 550 - .irq_unmask = tegra_gpio_irq_unmask, 551 - .irq_set_type = tegra_gpio_irq_set_type, 552 - .irq_shutdown = tegra_gpio_irq_shutdown, 553 - #ifdef CONFIG_PM_SLEEP 554 - .irq_set_wake = tegra_gpio_irq_set_wake, 555 - #endif 556 - }; 557 431 558 432 static const struct dev_pm_ops tegra_gpio_pm_ops = { 559 433 SET_SYSTEM_SLEEP_PM_OPS(tegra_gpio_suspend, tegra_gpio_resume) 560 434 }; 561 435 562 - struct tegra_gpio_soc_config { 563 - u32 bank_stride; 564 - u32 upper_offset; 565 - }; 566 - 567 - static struct tegra_gpio_soc_config tegra20_gpio_config = { 568 - .bank_stride = 0x80, 569 - .upper_offset = 0x800, 570 - }; 571 - 572 - static struct tegra_gpio_soc_config tegra30_gpio_config = { 573 - .bank_stride = 0x100, 574 - .upper_offset = 0x80, 575 - }; 576 - 577 - static const struct of_device_id tegra_gpio_of_match[] = { 578 - { .compatible = "nvidia,tegra30-gpio", .data = &tegra30_gpio_config }, 579 - { .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config }, 580 - { }, 581 - }; 582 - 583 - /* This lock class tells lockdep that GPIO irqs are in a different 584 - * category than their parents, so it won't report false recursion. 585 - */ 586 - static struct lock_class_key gpio_lock_class; 587 - 588 436 static int tegra_gpio_probe(struct platform_device *pdev) 589 437 { 590 - const struct of_device_id *match; 591 - struct tegra_gpio_soc_config *config; 438 + const struct tegra_gpio_soc_config *config; 439 + struct tegra_gpio_info *tgi; 592 440 struct resource *res; 593 441 struct tegra_gpio_bank *bank; 594 442 int ret; ··· 558 482 int i; 559 483 int j; 560 484 561 - dev = &pdev->dev; 562 - 563 - match = of_match_device(tegra_gpio_of_match, &pdev->dev); 564 - if (!match) { 485 + config = of_device_get_match_data(&pdev->dev); 486 + if (!config) { 565 487 dev_err(&pdev->dev, "Error: No device match found\n"); 566 488 return -ENODEV; 567 489 } 568 - config = (struct tegra_gpio_soc_config *)match->data; 569 490 570 - tegra_gpio_bank_stride = config->bank_stride; 571 - tegra_gpio_upper_offset = config->upper_offset; 491 + tgi = devm_kzalloc(&pdev->dev, sizeof(*tgi), GFP_KERNEL); 492 + if (!tgi) 493 + return -ENODEV; 494 + 495 + tgi->soc = config; 496 + tgi->dev = &pdev->dev; 572 497 573 498 for (;;) { 574 - res = platform_get_resource(pdev, IORESOURCE_IRQ, tegra_gpio_bank_count); 499 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 500 + tgi->bank_count); 575 501 if (!res) 576 502 break; 577 - tegra_gpio_bank_count++; 503 + tgi->bank_count++; 578 504 } 579 - if (!tegra_gpio_bank_count) { 505 + if (!tgi->bank_count) { 580 506 dev_err(&pdev->dev, "Missing IRQ resource\n"); 581 507 return -ENODEV; 582 508 } 583 509 584 - tegra_gpio_chip.ngpio = tegra_gpio_bank_count * 32; 510 + tgi->gc.label = "tegra-gpio"; 511 + tgi->gc.request = tegra_gpio_request; 512 + tgi->gc.free = tegra_gpio_free; 513 + tgi->gc.direction_input = tegra_gpio_direction_input; 514 + tgi->gc.get = tegra_gpio_get; 515 + tgi->gc.direction_output = tegra_gpio_direction_output; 516 + tgi->gc.set = tegra_gpio_set; 517 + tgi->gc.get_direction = tegra_gpio_get_direction; 518 + tgi->gc.to_irq = tegra_gpio_to_irq; 519 + tgi->gc.base = 0; 520 + tgi->gc.ngpio = tgi->bank_count * 32; 521 + tgi->gc.parent = &pdev->dev; 522 + tgi->gc.of_node = pdev->dev.of_node; 585 523 586 - tegra_gpio_banks = devm_kzalloc(&pdev->dev, 587 - tegra_gpio_bank_count * sizeof(*tegra_gpio_banks), 588 - GFP_KERNEL); 589 - if (!tegra_gpio_banks) 524 + tgi->ic.name = "GPIO"; 525 + tgi->ic.irq_ack = tegra_gpio_irq_ack; 526 + tgi->ic.irq_mask = tegra_gpio_irq_mask; 527 + tgi->ic.irq_unmask = tegra_gpio_irq_unmask; 528 + tgi->ic.irq_set_type = tegra_gpio_irq_set_type; 529 + tgi->ic.irq_shutdown = tegra_gpio_irq_shutdown; 530 + #ifdef CONFIG_PM_SLEEP 531 + tgi->ic.irq_set_wake = tegra_gpio_irq_set_wake; 532 + #endif 533 + 534 + platform_set_drvdata(pdev, tgi); 535 + 536 + if (config->debounce_supported) 537 + tgi->gc.set_debounce = tegra_gpio_set_debounce; 538 + 539 + tgi->bank_info = devm_kzalloc(&pdev->dev, tgi->bank_count * 540 + sizeof(*tgi->bank_info), GFP_KERNEL); 541 + if (!tgi->bank_info) 590 542 return -ENODEV; 591 543 592 - irq_domain = irq_domain_add_linear(pdev->dev.of_node, 593 - tegra_gpio_chip.ngpio, 594 - &irq_domain_simple_ops, NULL); 595 - if (!irq_domain) 544 + tgi->irq_domain = irq_domain_add_linear(pdev->dev.of_node, 545 + tgi->gc.ngpio, 546 + &irq_domain_simple_ops, NULL); 547 + if (!tgi->irq_domain) 596 548 return -ENODEV; 597 549 598 - for (i = 0; i < tegra_gpio_bank_count; i++) { 550 + for (i = 0; i < tgi->bank_count; i++) { 599 551 res = platform_get_resource(pdev, IORESOURCE_IRQ, i); 600 552 if (!res) { 601 553 dev_err(&pdev->dev, "Missing IRQ resource\n"); 602 554 return -ENODEV; 603 555 } 604 556 605 - bank = &tegra_gpio_banks[i]; 557 + bank = &tgi->bank_info[i]; 606 558 bank->bank = i; 607 559 bank->irq = res->start; 560 + bank->tgi = tgi; 608 561 } 609 562 610 563 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 611 - regs = devm_ioremap_resource(&pdev->dev, res); 612 - if (IS_ERR(regs)) 613 - return PTR_ERR(regs); 564 + tgi->regs = devm_ioremap_resource(&pdev->dev, res); 565 + if (IS_ERR(tgi->regs)) 566 + return PTR_ERR(tgi->regs); 614 567 615 - for (i = 0; i < tegra_gpio_bank_count; i++) { 568 + for (i = 0; i < tgi->bank_count; i++) { 616 569 for (j = 0; j < 4; j++) { 617 570 int gpio = tegra_gpio_compose(i, j, 0); 618 - tegra_gpio_writel(0x00, GPIO_INT_ENB(gpio)); 571 + tegra_gpio_writel(tgi, 0x00, GPIO_INT_ENB(tgi, gpio)); 619 572 } 620 573 } 621 574 622 - tegra_gpio_chip.of_node = pdev->dev.of_node; 623 - 624 - ret = devm_gpiochip_add_data(&pdev->dev, &tegra_gpio_chip, NULL); 575 + ret = devm_gpiochip_add_data(&pdev->dev, &tgi->gc, tgi); 625 576 if (ret < 0) { 626 - irq_domain_remove(irq_domain); 577 + irq_domain_remove(tgi->irq_domain); 627 578 return ret; 628 579 } 629 580 630 - for (gpio = 0; gpio < tegra_gpio_chip.ngpio; gpio++) { 631 - int irq = irq_create_mapping(irq_domain, gpio); 581 + for (gpio = 0; gpio < tgi->gc.ngpio; gpio++) { 582 + int irq = irq_create_mapping(tgi->irq_domain, gpio); 632 583 /* No validity check; all Tegra GPIOs are valid IRQs */ 633 584 634 - bank = &tegra_gpio_banks[GPIO_BANK(gpio)]; 585 + bank = &tgi->bank_info[GPIO_BANK(gpio)]; 635 586 636 - irq_set_lockdep_class(irq, &gpio_lock_class); 587 + irq_set_lockdep_class(irq, &tgi->lock_class); 637 588 irq_set_chip_data(irq, bank); 638 - irq_set_chip_and_handler(irq, &tegra_gpio_irq_chip, 639 - handle_simple_irq); 589 + irq_set_chip_and_handler(irq, &tgi->ic, handle_simple_irq); 640 590 } 641 591 642 - for (i = 0; i < tegra_gpio_bank_count; i++) { 643 - bank = &tegra_gpio_banks[i]; 592 + for (i = 0; i < tgi->bank_count; i++) { 593 + bank = &tgi->bank_info[i]; 644 594 645 595 irq_set_chained_handler_and_data(bank->irq, 646 596 tegra_gpio_irq_handler, bank); 647 597 648 - for (j = 0; j < 4; j++) 598 + for (j = 0; j < 4; j++) { 649 599 spin_lock_init(&bank->lvl_lock[j]); 600 + spin_lock_init(&bank->dbc_lock[j]); 601 + } 650 602 } 651 603 652 - tegra_gpio_debuginit(); 604 + tegra_gpio_debuginit(tgi); 653 605 654 606 return 0; 655 607 } 608 + 609 + static const struct tegra_gpio_soc_config tegra20_gpio_config = { 610 + .bank_stride = 0x80, 611 + .upper_offset = 0x800, 612 + }; 613 + 614 + static const struct tegra_gpio_soc_config tegra30_gpio_config = { 615 + .bank_stride = 0x100, 616 + .upper_offset = 0x80, 617 + }; 618 + 619 + static const struct tegra_gpio_soc_config tegra210_gpio_config = { 620 + .debounce_supported = true, 621 + .bank_stride = 0x100, 622 + .upper_offset = 0x80, 623 + }; 624 + 625 + static const struct of_device_id tegra_gpio_of_match[] = { 626 + { .compatible = "nvidia,tegra210-gpio", .data = &tegra210_gpio_config }, 627 + { .compatible = "nvidia,tegra30-gpio", .data = &tegra30_gpio_config }, 628 + { .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config }, 629 + { }, 630 + }; 656 631 657 632 static struct platform_driver tegra_gpio_driver = { 658 633 .driver = {
+5 -30
drivers/gpio/gpio-timberdale.c
··· 1 1 /* 2 2 * Timberdale FPGA GPIO driver 3 + * Author: Mocean Laboratories 3 4 * Copyright (c) 2009 Intel Corporation 4 5 * 5 6 * This program is free software; you can redistribute it and/or modify ··· 21 20 * Timberdale FPGA GPIO 22 21 */ 23 22 24 - #include <linux/module.h> 23 + #include <linux/init.h> 25 24 #include <linux/gpio.h> 26 25 #include <linux/platform_device.h> 27 26 #include <linux/irq.h> ··· 291 290 return 0; 292 291 } 293 292 294 - static int timbgpio_remove(struct platform_device *pdev) 295 - { 296 - struct timbgpio_platform_data *pdata = dev_get_platdata(&pdev->dev); 297 - struct timbgpio *tgpio = platform_get_drvdata(pdev); 298 - int irq = platform_get_irq(pdev, 0); 299 - 300 - if (irq >= 0 && tgpio->irq_base > 0) { 301 - int i; 302 - for (i = 0; i < pdata->nr_pins; i++) { 303 - irq_set_chip(tgpio->irq_base + i, NULL); 304 - irq_set_chip_data(tgpio->irq_base + i, NULL); 305 - } 306 - 307 - irq_set_handler(irq, NULL); 308 - irq_set_handler_data(irq, NULL); 309 - } 310 - 311 - return 0; 312 - } 313 - 314 293 static struct platform_driver timbgpio_platform_driver = { 315 294 .driver = { 316 - .name = DRIVER_NAME, 295 + .name = DRIVER_NAME, 296 + .suppress_bind_attrs = true, 317 297 }, 318 298 .probe = timbgpio_probe, 319 - .remove = timbgpio_remove, 320 299 }; 321 300 322 301 /*--------------------------------------------------------------------------*/ 323 302 324 - module_platform_driver(timbgpio_platform_driver); 325 - 326 - MODULE_DESCRIPTION("Timberdale GPIO driver"); 327 - MODULE_LICENSE("GPL v2"); 328 - MODULE_AUTHOR("Mocean Laboratories"); 329 - MODULE_ALIAS("platform:"DRIVER_NAME); 330 - 303 + builtin_platform_driver(timbgpio_platform_driver);
+15 -20
drivers/gpio/gpio-tpic2810.c
··· 57 57 return 0; 58 58 } 59 59 60 - static void tpic2810_set(struct gpio_chip *chip, unsigned offset, int value) 60 + static void tpic2810_set_mask_bits(struct gpio_chip *chip, u8 mask, u8 bits) 61 61 { 62 62 struct tpic2810 *gpio = gpiochip_get_data(chip); 63 + u8 buffer; 64 + int err; 63 65 64 66 mutex_lock(&gpio->lock); 65 67 66 - if (value) 67 - gpio->buffer |= BIT(offset); 68 - else 69 - gpio->buffer &= ~BIT(offset); 68 + buffer = gpio->buffer & ~mask; 69 + buffer |= (mask & bits); 70 70 71 - i2c_smbus_write_byte_data(gpio->client, TPIC2810_WS_COMMAND, 72 - gpio->buffer); 71 + err = i2c_smbus_write_byte_data(gpio->client, TPIC2810_WS_COMMAND, 72 + buffer); 73 + if (!err) 74 + gpio->buffer = buffer; 73 75 74 76 mutex_unlock(&gpio->lock); 77 + } 78 + 79 + static void tpic2810_set(struct gpio_chip *chip, unsigned offset, int value) 80 + { 81 + tpic2810_set_mask_bits(chip, BIT(offset), value ? BIT(offset) : 0); 75 82 } 76 83 77 84 static void tpic2810_set_multiple(struct gpio_chip *chip, unsigned long *mask, 78 85 unsigned long *bits) 79 86 { 80 - struct tpic2810 *gpio = gpiochip_get_data(chip); 81 - 82 - mutex_lock(&gpio->lock); 83 - 84 - /* clear bits under mask */ 85 - gpio->buffer &= ~(*mask); 86 - /* set bits under mask */ 87 - gpio->buffer |= ((*mask) & (*bits)); 88 - 89 - i2c_smbus_write_byte_data(gpio->client, TPIC2810_WS_COMMAND, 90 - gpio->buffer); 91 - 92 - mutex_unlock(&gpio->lock); 87 + tpic2810_set_mask_bits(chip, *mask, *bits); 93 88 } 94 89 95 90 static struct gpio_chip template_chip = {
+35 -10
drivers/gpio/gpio-tps65218.c
··· 101 101 102 102 break; 103 103 case 1: 104 - /* GP02 is push-pull by default, can be set as open drain. */ 105 - if (gpiochip_line_is_open_drain(gc, offset)) { 106 - ret = tps65218_clear_bits(tps65218, 107 - TPS65218_REG_CONFIG1, 108 - TPS65218_CONFIG1_GPO2_BUF, 109 - TPS65218_PROTECT_L1); 110 - if (ret) 111 - return ret; 112 - } 113 - 114 104 /* Setup GPO2 */ 115 105 ret = tps65218_clear_bits(tps65218, TPS65218_REG_CONFIG1, 116 106 TPS65218_CONFIG1_IO1_SEL, ··· 138 148 return 0; 139 149 } 140 150 151 + static int tps65218_gpio_set_single_ended(struct gpio_chip *gc, 152 + unsigned offset, 153 + enum single_ended_mode mode) 154 + { 155 + struct tps65218_gpio *tps65218_gpio = gpiochip_get_data(gc); 156 + struct tps65218 *tps65218 = tps65218_gpio->tps65218; 157 + 158 + switch (offset) { 159 + case 0: 160 + case 2: 161 + /* GPO1 is hardwired to be open drain */ 162 + if (mode == LINE_MODE_OPEN_DRAIN) 163 + return 0; 164 + return -ENOTSUPP; 165 + case 1: 166 + /* GPO2 is push-pull by default, can be set as open drain. */ 167 + if (mode == LINE_MODE_OPEN_DRAIN) 168 + return tps65218_clear_bits(tps65218, 169 + TPS65218_REG_CONFIG1, 170 + TPS65218_CONFIG1_GPO2_BUF, 171 + TPS65218_PROTECT_L1); 172 + if (mode == LINE_MODE_PUSH_PULL) 173 + return tps65218_set_bits(tps65218, 174 + TPS65218_REG_CONFIG1, 175 + TPS65218_CONFIG1_GPO2_BUF, 176 + TPS65218_CONFIG1_GPO2_BUF, 177 + TPS65218_PROTECT_L1); 178 + return -ENOTSUPP; 179 + default: 180 + break; 181 + } 182 + return -ENOTSUPP; 183 + } 184 + 141 185 static struct gpio_chip template_chip = { 142 186 .label = "gpio-tps65218", 143 187 .owner = THIS_MODULE, ··· 180 156 .direction_input = tps65218_gpio_input, 181 157 .get = tps65218_gpio_get, 182 158 .set = tps65218_gpio_set, 159 + .set_single_ended = tps65218_gpio_set_single_ended, 183 160 .can_sleep = true, 184 161 .ngpio = 3, 185 162 .base = -1,
+1 -12
drivers/gpio/gpio-tps6586x.c
··· 24 24 #include <linux/errno.h> 25 25 #include <linux/gpio.h> 26 26 #include <linux/kernel.h> 27 - #include <linux/module.h> 27 + #include <linux/init.h> 28 28 #include <linux/mfd/tps6586x.h> 29 29 #include <linux/of_device.h> 30 30 #include <linux/platform_device.h> ··· 140 140 return platform_driver_register(&tps6586x_gpio_driver); 141 141 } 142 142 subsys_initcall(tps6586x_gpio_init); 143 - 144 - static void __exit tps6586x_gpio_exit(void) 145 - { 146 - platform_driver_unregister(&tps6586x_gpio_driver); 147 - } 148 - module_exit(tps6586x_gpio_exit); 149 - 150 - MODULE_ALIAS("platform:tps6586x-gpio"); 151 - MODULE_DESCRIPTION("GPIO interface for TPS6586X PMIC"); 152 - MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); 153 - MODULE_LICENSE("GPL");
+2 -14
drivers/gpio/gpio-tps65910.c
··· 4 4 * Copyright 2010 Texas Instruments Inc. 5 5 * 6 6 * Author: Graeme Gregory <gg@slimlogic.co.uk> 7 - * Author: Jorge Eduardo Candelaria jedu@slimlogic.co.uk> 7 + * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk> 8 8 * 9 9 * This program is free software; you can redistribute it and/or modify it 10 10 * under the terms of the GNU General Public License as published by the ··· 14 14 */ 15 15 16 16 #include <linux/kernel.h> 17 - #include <linux/module.h> 17 + #include <linux/init.h> 18 18 #include <linux/errno.h> 19 19 #include <linux/gpio.h> 20 20 #include <linux/i2c.h> ··· 193 193 return platform_driver_register(&tps65910_gpio_driver); 194 194 } 195 195 subsys_initcall(tps65910_gpio_init); 196 - 197 - static void __exit tps65910_gpio_exit(void) 198 - { 199 - platform_driver_unregister(&tps65910_gpio_driver); 200 - } 201 - module_exit(tps65910_gpio_exit); 202 - 203 - MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>"); 204 - MODULE_AUTHOR("Jorge Eduardo Candelaria jedu@slimlogic.co.uk>"); 205 - MODULE_DESCRIPTION("GPIO interface for TPS65910/TPS6511 PMICs"); 206 - MODULE_LICENSE("GPL v2"); 207 - MODULE_ALIAS("platform:tps65910-gpio");
+23
drivers/gpio/gpio-vx855.c
··· 186 186 return 0; 187 187 } 188 188 189 + static int vx855gpio_set_single_ended(struct gpio_chip *gpio, 190 + unsigned int nr, 191 + enum single_ended_mode mode) 192 + { 193 + /* The GPI cannot be single-ended */ 194 + if (nr < NR_VX855_GPI) 195 + return -EINVAL; 196 + 197 + /* The GPO's are push-pull */ 198 + if (nr < NR_VX855_GPInO) { 199 + if (mode != LINE_MODE_PUSH_PULL) 200 + return -ENOTSUPP; 201 + return 0; 202 + } 203 + 204 + /* The GPIO's are open drain */ 205 + if (mode != LINE_MODE_OPEN_DRAIN) 206 + return -ENOTSUPP; 207 + 208 + return 0; 209 + } 210 + 189 211 static const char *vx855gpio_names[NR_VX855_GP] = { 190 212 "VX855_GPI0", "VX855_GPI1", "VX855_GPI2", "VX855_GPI3", "VX855_GPI4", 191 213 "VX855_GPI5", "VX855_GPI6", "VX855_GPI7", "VX855_GPI8", "VX855_GPI9", ··· 231 209 c->direction_output = vx855gpio_direction_output; 232 210 c->get = vx855gpio_get; 233 211 c->set = vx855gpio_set; 212 + c->set_single_ended = vx855gpio_set_single_ended; 234 213 c->dbg_show = NULL; 235 214 c->base = 0; 236 215 c->ngpio = NR_VX855_GP;
+24 -1
drivers/gpio/gpio-wm831x.c
··· 132 132 return wm831x_set_bits(wm831x, reg, WM831X_GPN_FN_MASK, fn); 133 133 } 134 134 135 + static int wm831x_set_single_ended(struct gpio_chip *chip, 136 + unsigned int offset, 137 + enum single_ended_mode mode) 138 + { 139 + struct wm831x_gpio *wm831x_gpio = gpiochip_get_data(chip); 140 + struct wm831x *wm831x = wm831x_gpio->wm831x; 141 + int reg = WM831X_GPIO1_CONTROL + offset; 142 + 143 + switch (mode) { 144 + case LINE_MODE_OPEN_DRAIN: 145 + return wm831x_set_bits(wm831x, reg, 146 + WM831X_GPN_OD_MASK, WM831X_GPN_OD); 147 + case LINE_MODE_PUSH_PULL: 148 + return wm831x_set_bits(wm831x, reg, 149 + WM831X_GPN_OD_MASK, 0); 150 + default: 151 + break; 152 + } 153 + 154 + return -ENOTSUPP; 155 + } 156 + 135 157 #ifdef CONFIG_DEBUG_FS 136 158 static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) 137 159 { ··· 238 216 pull, 239 217 powerdomain, 240 218 reg & WM831X_GPN_POL ? "" : " inverted", 241 - reg & WM831X_GPN_OD ? "open-drain" : "CMOS", 219 + reg & WM831X_GPN_OD ? "open-drain" : "push-pull", 242 220 tristated ? " tristated" : "", 243 221 reg); 244 222 } ··· 256 234 .set = wm831x_gpio_set, 257 235 .to_irq = wm831x_gpio_to_irq, 258 236 .set_debounce = wm831x_gpio_set_debounce, 237 + .set_single_ended = wm831x_set_single_ended, 259 238 .dbg_show = wm831x_gpio_dbg_show, 260 239 .can_sleep = true, 261 240 };
+24 -1
drivers/gpio/gpio-wm8994.c
··· 103 103 wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, WM8994_GPN_LVL, value); 104 104 } 105 105 106 + static int wm8994_gpio_set_single_ended(struct gpio_chip *chip, 107 + unsigned int offset, 108 + enum single_ended_mode mode) 109 + { 110 + struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); 111 + struct wm8994 *wm8994 = wm8994_gpio->wm8994; 112 + 113 + switch (mode) { 114 + case LINE_MODE_OPEN_DRAIN: 115 + return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, 116 + WM8994_GPN_OP_CFG_MASK, 117 + WM8994_GPN_OP_CFG); 118 + case LINE_MODE_PUSH_PULL: 119 + return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset, 120 + WM8994_GPN_OP_CFG_MASK, 0); 121 + default: 122 + break; 123 + } 124 + 125 + return -ENOTSUPP; 126 + } 127 + 106 128 static int wm8994_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 107 129 { 108 130 struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip); ··· 239 217 if (reg & WM8994_GPN_OP_CFG) 240 218 seq_printf(s, "open drain "); 241 219 else 242 - seq_printf(s, "CMOS "); 220 + seq_printf(s, "push-pull "); 243 221 244 222 seq_printf(s, "%s (%x)\n", 245 223 wm8994_gpio_fn(reg & WM8994_GPN_FN_MASK), reg); ··· 257 235 .get = wm8994_gpio_get, 258 236 .direction_output = wm8994_gpio_direction_out, 259 237 .set = wm8994_gpio_set, 238 + .set_single_ended = wm8994_gpio_set_single_ended, 260 239 .to_irq = wm8994_gpio_to_irq, 261 240 .dbg_show = wm8994_gpio_dbg_show, 262 241 .can_sleep = true,
+1 -14
drivers/gpio/gpio-xgene-sb.c
··· 216 216 &parent_fwspec); 217 217 } 218 218 219 - static void xgene_gpio_sb_domain_free(struct irq_domain *domain, 220 - unsigned int virq, 221 - unsigned int nr_irqs) 222 - { 223 - struct irq_data *d; 224 - unsigned int i; 225 - 226 - for (i = 0; i < nr_irqs; i++) { 227 - d = irq_domain_get_irq_data(domain, virq + i); 228 - irq_domain_reset_irq_data(d); 229 - } 230 - } 231 - 232 219 static const struct irq_domain_ops xgene_gpio_sb_domain_ops = { 233 220 .translate = xgene_gpio_sb_domain_translate, 234 221 .alloc = xgene_gpio_sb_domain_alloc, 235 - .free = xgene_gpio_sb_domain_free, 222 + .free = irq_domain_free_irqs_common, 236 223 .activate = xgene_gpio_sb_domain_activate, 237 224 .deactivate = xgene_gpio_sb_domain_deactivate, 238 225 };
+22 -8
drivers/gpio/gpio-xgene.c
··· 17 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 18 */ 19 19 20 - #include <linux/module.h> 20 + #include <linux/acpi.h> 21 21 #include <linux/kernel.h> 22 22 #include <linux/init.h> 23 23 #include <linux/io.h> ··· 83 83 spin_lock_irqsave(&chip->lock, flags); 84 84 __xgene_gpio_set(gc, offset, val); 85 85 spin_unlock_irqrestore(&chip->lock, flags); 86 + } 87 + 88 + static int xgene_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) 89 + { 90 + struct xgene_gpio *chip = gpiochip_get_data(gc); 91 + unsigned long bank_offset, bit_offset; 92 + 93 + bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset); 94 + bit_offset = GPIO_BIT_OFFSET(offset); 95 + 96 + return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset)); 86 97 } 87 98 88 99 static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset) ··· 200 189 201 190 spin_lock_init(&gpio->lock); 202 191 gpio->chip.parent = &pdev->dev; 192 + gpio->chip.get_direction = xgene_gpio_get_direction; 203 193 gpio->chip.direction_input = xgene_gpio_dir_in; 204 194 gpio->chip.direction_output = xgene_gpio_dir_out; 205 195 gpio->chip.get = xgene_gpio_get; ··· 228 216 { .compatible = "apm,xgene-gpio", }, 229 217 {}, 230 218 }; 231 - MODULE_DEVICE_TABLE(of, xgene_gpio_of_match); 219 + 220 + #ifdef CONFIG_ACPI 221 + static const struct acpi_device_id xgene_gpio_acpi_match[] = { 222 + { "APMC0D14", 0 }, 223 + { }, 224 + }; 225 + #endif 232 226 233 227 static struct platform_driver xgene_gpio_driver = { 234 228 .driver = { 235 229 .name = "xgene-gpio", 236 230 .of_match_table = xgene_gpio_of_match, 231 + .acpi_match_table = ACPI_PTR(xgene_gpio_acpi_match), 237 232 .pm = XGENE_GPIO_PM_OPS, 238 233 }, 239 234 .probe = xgene_gpio_probe, 240 235 }; 241 - 242 - module_platform_driver(xgene_gpio_driver); 243 - 244 - MODULE_AUTHOR("Feng Kan <fkan@apm.com>"); 245 - MODULE_DESCRIPTION("APM X-Gene GPIO driver"); 246 - MODULE_LICENSE("GPL"); 236 + builtin_platform_driver(xgene_gpio_driver);
+20 -5
drivers/gpio/gpio-xlp.c
··· 85 85 XLP_GPIO_VARIANT_XLP316, 86 86 XLP_GPIO_VARIANT_XLP208, 87 87 XLP_GPIO_VARIANT_XLP980, 88 - XLP_GPIO_VARIANT_XLP532 88 + XLP_GPIO_VARIANT_XLP532, 89 + GPIO_VARIANT_VULCAN 89 90 }; 90 91 91 92 struct xlp_gpio_priv { ··· 286 285 .compatible = "netlogic,xlp532-gpio", 287 286 .data = (void *)XLP_GPIO_VARIANT_XLP532, 288 287 }, 288 + { 289 + .compatible = "brcm,vulcan-gpio", 290 + .data = (void *)GPIO_VARIANT_VULCAN, 291 + }, 289 292 { /* sentinel */ }, 290 293 }; 291 294 MODULE_DEVICE_TABLE(of, xlp_gpio_of_ids); ··· 352 347 break; 353 348 case XLP_GPIO_VARIANT_XLP980: 354 349 case XLP_GPIO_VARIANT_XLP532: 350 + case GPIO_VARIANT_VULCAN: 355 351 priv->gpio_out_en = gpio_base + GPIO_9XX_OUTPUT_EN; 356 352 priv->gpio_paddrv = gpio_base + GPIO_9XX_PADDRV; 357 353 priv->gpio_intr_stat = gpio_base + GPIO_9XX_INT_STAT; ··· 360 354 priv->gpio_intr_pol = gpio_base + GPIO_9XX_INT_POL; 361 355 priv->gpio_intr_en = gpio_base + GPIO_9XX_INT_EN00; 362 356 363 - ngpio = (soc_type == XLP_GPIO_VARIANT_XLP980) ? 66 : 67; 357 + if (soc_type == XLP_GPIO_VARIANT_XLP980) 358 + ngpio = 66; 359 + else if (soc_type == XLP_GPIO_VARIANT_XLP532) 360 + ngpio = 67; 361 + else 362 + ngpio = 70; 364 363 break; 365 364 default: 366 365 dev_err(&pdev->dev, "Unknown Processor type!\n"); ··· 388 377 gc->get = xlp_gpio_get; 389 378 390 379 spin_lock_init(&priv->lock); 391 - irq_base = irq_alloc_descs(-1, XLP_GPIO_IRQ_BASE, gc->ngpio, 0); 392 - if (irq_base < 0) { 380 + /* XLP has fixed IRQ range for GPIO interrupts */ 381 + if (soc_type == GPIO_VARIANT_VULCAN) 382 + irq_base = irq_alloc_descs(-1, 0, gc->ngpio, 0); 383 + else 384 + irq_base = irq_alloc_descs(-1, XLP_GPIO_IRQ_BASE, gc->ngpio, 0); 385 + if (IS_ERR_VALUE(irq_base)) { 393 386 dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); 394 - return -ENODEV; 387 + return irq_base; 395 388 } 396 389 397 390 err = gpiochip_add_data(gc, priv);
+3 -18
drivers/gpio/gpio-zevio.c
··· 10 10 11 11 #include <linux/spinlock.h> 12 12 #include <linux/errno.h> 13 - #include <linux/module.h> 13 + #include <linux/init.h> 14 14 #include <linux/bitops.h> 15 15 #include <linux/io.h> 16 16 #include <linux/of_device.h> ··· 203 203 return 0; 204 204 } 205 205 206 - static int zevio_gpio_remove(struct platform_device *pdev) 207 - { 208 - struct zevio_gpio *controller = platform_get_drvdata(pdev); 209 - 210 - of_mm_gpiochip_remove(&controller->chip); 211 - 212 - return 0; 213 - } 214 - 215 206 static const struct of_device_id zevio_gpio_of_match[] = { 216 207 { .compatible = "lsi,zevio-gpio", }, 217 208 { }, 218 209 }; 219 210 220 - MODULE_DEVICE_TABLE(of, zevio_gpio_of_match); 221 - 222 211 static struct platform_driver zevio_gpio_driver = { 223 212 .driver = { 224 213 .name = "gpio-zevio", 225 214 .of_match_table = zevio_gpio_of_match, 215 + .suppress_bind_attrs = true, 226 216 }, 227 217 .probe = zevio_gpio_probe, 228 - .remove = zevio_gpio_remove, 229 218 }; 230 - module_platform_driver(zevio_gpio_driver); 231 - 232 - MODULE_LICENSE("GPL"); 233 - MODULE_AUTHOR("Fabian Vogt <fabian@ritter-vogt.de>"); 234 - MODULE_DESCRIPTION("LSI ZEVIO SoC GPIO driver"); 219 + builtin_platform_driver(zevio_gpio_driver);
+6 -8
drivers/gpio/gpio-zx.c
··· 1 1 /* 2 + * ZTE ZX296702 GPIO driver 3 + * 4 + * Author: Jun Nie <jun.nie@linaro.org> 5 + * 2 6 * Copyright (C) 2015 Linaro Ltd. 3 7 * 4 8 * This program is free software; you can redistribute it and/or modify ··· 14 10 #include <linux/errno.h> 15 11 #include <linux/gpio/driver.h> 16 12 #include <linux/irqchip/chained_irq.h> 17 - #include <linux/module.h> 13 + #include <linux/init.h> 18 14 #include <linux/of.h> 19 15 #include <linux/pinctrl/consumer.h> 20 16 #include <linux/platform_device.h> ··· 286 282 }, 287 283 { }, 288 284 }; 289 - MODULE_DEVICE_TABLE(of, zx_gpio_match); 290 285 291 286 static struct platform_driver zx_gpio_driver = { 292 287 .probe = zx_gpio_probe, ··· 294 291 .of_match_table = of_match_ptr(zx_gpio_match), 295 292 }, 296 293 }; 297 - 298 - module_platform_driver(zx_gpio_driver) 299 - 300 - MODULE_AUTHOR("Jun Nie <jun.nie@linaro.org>"); 301 - MODULE_DESCRIPTION("ZTE ZX296702 GPIO driver"); 302 - MODULE_LICENSE("GPL"); 294 + builtin_platform_driver(zx_gpio_driver)
+3 -1
drivers/gpio/gpio-zynq.c
··· 713 713 pm_runtime_enable(&pdev->dev); 714 714 ret = pm_runtime_get_sync(&pdev->dev); 715 715 if (ret < 0) 716 - return ret; 716 + goto err_pm_dis; 717 717 718 718 /* report a bug if gpio chip registration fails */ 719 719 ret = gpiochip_add_data(chip, gpio); ··· 745 745 gpiochip_remove(chip); 746 746 err_pm_put: 747 747 pm_runtime_put(&pdev->dev); 748 + err_pm_dis: 749 + pm_runtime_disable(&pdev->dev); 748 750 749 751 return ret; 750 752 }
+59 -7
drivers/gpio/gpiolib-of.c
··· 196 196 } 197 197 198 198 /** 199 + * of_gpiochip_set_names() - set up the names of the lines 200 + * @chip: GPIO chip whose lines should be named, if possible 201 + */ 202 + static void of_gpiochip_set_names(struct gpio_chip *gc) 203 + { 204 + struct gpio_device *gdev = gc->gpiodev; 205 + struct device_node *np = gc->of_node; 206 + int i; 207 + int nstrings; 208 + 209 + nstrings = of_property_count_strings(np, "gpio-line-names"); 210 + if (nstrings <= 0) 211 + /* Lines names not present */ 212 + return; 213 + 214 + /* This is normally not what you want */ 215 + if (gdev->ngpio != nstrings) 216 + dev_info(&gdev->dev, "gpio-line-names specifies %d line " 217 + "names but there are %d lines on the chip\n", 218 + nstrings, gdev->ngpio); 219 + 220 + /* 221 + * Make sure to not index beyond the end of the number of descriptors 222 + * of the GPIO device. 223 + */ 224 + for (i = 0; i < gdev->ngpio; i++) { 225 + const char *name; 226 + int ret; 227 + 228 + ret = of_property_read_string_index(np, 229 + "gpio-line-names", 230 + i, 231 + &name); 232 + if (ret) { 233 + if (ret != -ENODATA) 234 + dev_err(&gdev->dev, 235 + "unable to name line %d: %d\n", 236 + i, ret); 237 + break; 238 + } 239 + gdev->descs[i].name = name; 240 + } 241 + } 242 + 243 + /** 199 244 * of_gpiochip_scan_gpios - Scan gpio-controller for gpio definitions 200 245 * @chip: gpio chip to act on 201 246 * 202 247 * This is only used by of_gpiochip_add to request/set GPIO initial 203 248 * configuration. 249 + * It retures error if it fails otherwise 0 on success. 204 250 */ 205 - static void of_gpiochip_scan_gpios(struct gpio_chip *chip) 251 + static int of_gpiochip_scan_gpios(struct gpio_chip *chip) 206 252 { 207 253 struct gpio_desc *desc = NULL; 208 254 struct device_node *np; 209 255 const char *name; 210 256 enum gpio_lookup_flags lflags; 211 257 enum gpiod_flags dflags; 258 + int ret; 212 259 213 - for_each_child_of_node(chip->of_node, np) { 260 + for_each_available_child_of_node(chip->of_node, np) { 214 261 if (!of_property_read_bool(np, "gpio-hog")) 215 262 continue; 216 263 ··· 265 218 if (IS_ERR(desc)) 266 219 continue; 267 220 268 - if (gpiod_hog(desc, name, lflags, dflags)) 269 - continue; 221 + ret = gpiod_hog(desc, name, lflags, dflags); 222 + if (ret < 0) 223 + return ret; 270 224 } 225 + 226 + return 0; 271 227 } 272 228 273 229 /** ··· 490 440 if (status) 491 441 return status; 492 442 443 + /* If the chip defines names itself, these take precedence */ 444 + if (!chip->names) 445 + of_gpiochip_set_names(chip); 446 + 493 447 of_node_get(chip->of_node); 494 448 495 - of_gpiochip_scan_gpios(chip); 496 - 497 - return 0; 449 + return of_gpiochip_scan_gpios(chip); 498 450 } 499 451 500 452 void of_gpiochip_remove(struct gpio_chip *chip)
+91 -42
drivers/gpio/gpiolib.c
··· 622 622 struct gpio_desc *desc = &gdev->descs[i]; 623 623 624 624 desc->gdev = gdev; 625 - 626 - /* REVISIT: most hardware initializes GPIOs as inputs (often 627 - * with pullups enabled) so power usage is minimized. Linux 628 - * code should set the gpio direction first thing; but until 629 - * it does, and in case chip->get_direction is not set, we may 630 - * expose the wrong direction in sysfs. 625 + /* 626 + * REVISIT: most hardware initializes GPIOs as inputs 627 + * (often with pullups enabled) so power usage is 628 + * minimized. Linux code should set the gpio direction 629 + * first thing; but until it does, and in case 630 + * chip->get_direction is not set, we may expose the 631 + * wrong direction in sysfs. 631 632 */ 632 - desc->flags = !chip->direction_input ? (1 << FLAG_IS_OUT) : 0; 633 + 634 + if (chip->get_direction) { 635 + /* 636 + * If we have .get_direction, set up the initial 637 + * direction flag from the hardware. 638 + */ 639 + int dir = chip->get_direction(chip, i); 640 + 641 + if (!dir) 642 + set_bit(FLAG_IS_OUT, &desc->flags); 643 + } else if (!chip->direction_input) { 644 + /* 645 + * If the chip lacks the .direction_input callback 646 + * we logically assume all lines are outputs. 647 + */ 648 + set_bit(FLAG_IS_OUT, &desc->flags); 649 + } 633 650 } 634 651 635 652 spin_unlock_irqrestore(&gpio_lock, flags); ··· 1564 1547 1565 1548 static int _gpiod_direction_output_raw(struct gpio_desc *desc, int value) 1566 1549 { 1567 - struct gpio_chip *chip; 1568 - int status = -EINVAL; 1550 + struct gpio_chip *gc = desc->gdev->chip; 1551 + int ret; 1569 1552 1570 1553 /* GPIOs used for IRQs shall not be set as output */ 1571 1554 if (test_bit(FLAG_USED_AS_IRQ, &desc->flags)) { ··· 1575 1558 return -EIO; 1576 1559 } 1577 1560 1578 - /* Open drain pin should not be driven to 1 */ 1579 - if (value && test_bit(FLAG_OPEN_DRAIN, &desc->flags)) 1580 - return gpiod_direction_input(desc); 1561 + if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { 1562 + /* First see if we can enable open drain in hardware */ 1563 + if (gc->set_single_ended) { 1564 + ret = gc->set_single_ended(gc, gpio_chip_hwgpio(desc), 1565 + LINE_MODE_OPEN_DRAIN); 1566 + if (!ret) 1567 + goto set_output_value; 1568 + } 1569 + /* Emulate open drain by not actively driving the line high */ 1570 + if (value) 1571 + return gpiod_direction_input(desc); 1572 + } 1573 + else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) { 1574 + if (gc->set_single_ended) { 1575 + ret = gc->set_single_ended(gc, gpio_chip_hwgpio(desc), 1576 + LINE_MODE_OPEN_SOURCE); 1577 + if (!ret) 1578 + goto set_output_value; 1579 + } 1580 + /* Emulate open source by not actively driving the line low */ 1581 + if (!value) 1582 + return gpiod_direction_input(desc); 1583 + } else { 1584 + /* Make sure to disable open drain/source hardware, if any */ 1585 + if (gc->set_single_ended) 1586 + gc->set_single_ended(gc, 1587 + gpio_chip_hwgpio(desc), 1588 + LINE_MODE_PUSH_PULL); 1589 + } 1581 1590 1582 - /* Open source pin should not be driven to 0 */ 1583 - if (!value && test_bit(FLAG_OPEN_SOURCE, &desc->flags)) 1584 - return gpiod_direction_input(desc); 1585 - 1586 - chip = desc->gdev->chip; 1587 - if (!chip->set || !chip->direction_output) { 1591 + set_output_value: 1592 + if (!gc->set || !gc->direction_output) { 1588 1593 gpiod_warn(desc, 1589 1594 "%s: missing set() or direction_output() operations\n", 1590 1595 __func__); 1591 1596 return -EIO; 1592 1597 } 1593 1598 1594 - status = chip->direction_output(chip, gpio_chip_hwgpio(desc), value); 1595 - if (status == 0) 1599 + ret = gc->direction_output(gc, gpio_chip_hwgpio(desc), value); 1600 + if (!ret) 1596 1601 set_bit(FLAG_IS_OUT, &desc->flags); 1597 1602 trace_gpio_value(desc_to_gpio(desc), 0, value); 1598 - trace_gpio_direction(desc_to_gpio(desc), 0, status); 1599 - return status; 1603 + trace_gpio_direction(desc_to_gpio(desc), 0, ret); 1604 + return ret; 1600 1605 } 1601 1606 1602 1607 /** ··· 1880 1841 } 1881 1842 } 1882 1843 1883 - static void gpiod_set_array_value_priv(bool raw, bool can_sleep, 1884 - unsigned int array_size, 1885 - struct gpio_desc **desc_array, 1886 - int *value_array) 1844 + void gpiod_set_array_value_complex(bool raw, bool can_sleep, 1845 + unsigned int array_size, 1846 + struct gpio_desc **desc_array, 1847 + int *value_array) 1887 1848 { 1888 1849 int i = 0; 1889 1850 ··· 1989 1950 { 1990 1951 if (!desc_array) 1991 1952 return; 1992 - gpiod_set_array_value_priv(true, false, array_size, desc_array, 1993 - value_array); 1953 + gpiod_set_array_value_complex(true, false, array_size, desc_array, 1954 + value_array); 1994 1955 } 1995 1956 EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value); 1996 1957 ··· 2011 1972 { 2012 1973 if (!desc_array) 2013 1974 return; 2014 - gpiod_set_array_value_priv(false, false, array_size, desc_array, 2015 - value_array); 1975 + gpiod_set_array_value_complex(false, false, array_size, desc_array, 1976 + value_array); 2016 1977 } 2017 1978 EXPORT_SYMBOL_GPL(gpiod_set_array_value); 2018 1979 ··· 2037 1998 */ 2038 1999 int gpiod_to_irq(const struct gpio_desc *desc) 2039 2000 { 2040 - struct gpio_chip *chip; 2041 - int offset; 2001 + struct gpio_chip *chip; 2002 + int offset; 2042 2003 2043 2004 VALIDATE_DESC(desc); 2044 2005 chip = desc->gdev->chip; 2045 2006 offset = gpio_chip_hwgpio(desc); 2046 - return chip->to_irq ? chip->to_irq(chip, offset) : -ENXIO; 2007 + if (chip->to_irq) { 2008 + int retirq = chip->to_irq(chip, offset); 2009 + 2010 + /* Zero means NO_IRQ */ 2011 + if (!retirq) 2012 + return -ENXIO; 2013 + 2014 + return retirq; 2015 + } 2016 + return -ENXIO; 2047 2017 } 2048 2018 EXPORT_SYMBOL_GPL(gpiod_to_irq); 2049 2019 ··· 2224 2176 might_sleep_if(extra_checks); 2225 2177 if (!desc_array) 2226 2178 return; 2227 - gpiod_set_array_value_priv(true, true, array_size, desc_array, 2228 - value_array); 2179 + gpiod_set_array_value_complex(true, true, array_size, desc_array, 2180 + value_array); 2229 2181 } 2230 2182 EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value_cansleep); 2231 2183 ··· 2247 2199 might_sleep_if(extra_checks); 2248 2200 if (!desc_array) 2249 2201 return; 2250 - gpiod_set_array_value_priv(false, true, array_size, desc_array, 2251 - value_array); 2202 + gpiod_set_array_value_complex(false, true, array_size, desc_array, 2203 + value_array); 2252 2204 } 2253 2205 EXPORT_SYMBOL_GPL(gpiod_set_array_value_cansleep); 2254 2206 ··· 2774 2726 2775 2727 local_desc = gpiochip_request_own_desc(chip, hwnum, name); 2776 2728 if (IS_ERR(local_desc)) { 2777 - pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n", 2778 - name, chip->label, hwnum); 2779 - return PTR_ERR(local_desc); 2729 + status = PTR_ERR(local_desc); 2730 + pr_err("requesting hog GPIO %s (chip %s, offset %d) failed, %d\n", 2731 + name, chip->label, hwnum, status); 2732 + return status; 2780 2733 } 2781 2734 2782 2735 status = gpiod_configure_flags(desc, name, dflags); 2783 2736 if (status < 0) { 2784 - pr_err("setup of hog GPIO %s (chip %s, offset %d) failed\n", 2785 - name, chip->label, hwnum); 2737 + pr_err("setup of hog GPIO %s (chip %s, offset %d) failed, %d\n", 2738 + name, chip->label, hwnum, status); 2786 2739 gpiochip_free_own_desc(desc); 2787 2740 return status; 2788 2741 }
+4
drivers/gpio/gpiolib.h
··· 141 141 const char *list_name, int index, enum of_gpio_flags *flags); 142 142 143 143 struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, u16 hwnum); 144 + void gpiod_set_array_value_complex(bool raw, bool can_sleep, 145 + unsigned int array_size, 146 + struct gpio_desc **desc_array, 147 + int *value_array); 144 148 145 149 extern struct spinlock gpio_lock; 146 150 extern struct list_head gpio_devices;
+5 -5
drivers/input/keyboard/adp5588-keys.c
··· 73 73 #ifdef CONFIG_GPIOLIB 74 74 static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned off) 75 75 { 76 - struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 76 + struct adp5588_kpad *kpad = gpiochip_get_data(chip); 77 77 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 78 78 unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 79 79 int val; ··· 93 93 static void adp5588_gpio_set_value(struct gpio_chip *chip, 94 94 unsigned off, int val) 95 95 { 96 - struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 96 + struct adp5588_kpad *kpad = gpiochip_get_data(chip); 97 97 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 98 98 unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 99 99 ··· 112 112 113 113 static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned off) 114 114 { 115 - struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 115 + struct adp5588_kpad *kpad = gpiochip_get_data(chip); 116 116 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 117 117 unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 118 118 int ret; ··· 130 130 static int adp5588_gpio_direction_output(struct gpio_chip *chip, 131 131 unsigned off, int val) 132 132 { 133 - struct adp5588_kpad *kpad = container_of(chip, struct adp5588_kpad, gc); 133 + struct adp5588_kpad *kpad = gpiochip_get_data(chip); 134 134 unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]); 135 135 unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]); 136 136 int ret; ··· 210 210 211 211 mutex_init(&kpad->gpio_lock); 212 212 213 - error = gpiochip_add(&kpad->gc); 213 + error = gpiochip_add_data(&kpad->gc, kpad); 214 214 if (error) { 215 215 dev_err(dev, "gpiochip_add failed, err: %d\n", error); 216 216 return error;
+6 -6
drivers/input/keyboard/adp5589-keys.c
··· 387 387 #ifdef CONFIG_GPIOLIB 388 388 static int adp5589_gpio_get_value(struct gpio_chip *chip, unsigned off) 389 389 { 390 - struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); 390 + struct adp5589_kpad *kpad = gpiochip_get_data(chip); 391 391 unsigned int bank = kpad->var->bank(kpad->gpiomap[off]); 392 392 unsigned int bit = kpad->var->bit(kpad->gpiomap[off]); 393 393 ··· 399 399 static void adp5589_gpio_set_value(struct gpio_chip *chip, 400 400 unsigned off, int val) 401 401 { 402 - struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); 402 + struct adp5589_kpad *kpad = gpiochip_get_data(chip); 403 403 unsigned int bank = kpad->var->bank(kpad->gpiomap[off]); 404 404 unsigned int bit = kpad->var->bit(kpad->gpiomap[off]); 405 405 ··· 418 418 419 419 static int adp5589_gpio_direction_input(struct gpio_chip *chip, unsigned off) 420 420 { 421 - struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); 421 + struct adp5589_kpad *kpad = gpiochip_get_data(chip); 422 422 unsigned int bank = kpad->var->bank(kpad->gpiomap[off]); 423 423 unsigned int bit = kpad->var->bit(kpad->gpiomap[off]); 424 424 int ret; ··· 438 438 static int adp5589_gpio_direction_output(struct gpio_chip *chip, 439 439 unsigned off, int val) 440 440 { 441 - struct adp5589_kpad *kpad = container_of(chip, struct adp5589_kpad, gc); 441 + struct adp5589_kpad *kpad = gpiochip_get_data(chip); 442 442 unsigned int bank = kpad->var->bank(kpad->gpiomap[off]); 443 443 unsigned int bit = kpad->var->bit(kpad->gpiomap[off]); 444 444 int ret; ··· 525 525 526 526 mutex_init(&kpad->gpio_lock); 527 527 528 - error = gpiochip_add(&kpad->gc); 528 + error = gpiochip_add_data(&kpad->gc, kpad); 529 529 if (error) { 530 - dev_err(dev, "gpiochip_add failed, err: %d\n", error); 530 + dev_err(dev, "gpiochip_add_data() failed, err: %d\n", error); 531 531 return error; 532 532 } 533 533
+5 -5
drivers/input/touchscreen/ad7879.c
··· 379 379 static int ad7879_gpio_direction_input(struct gpio_chip *chip, 380 380 unsigned gpio) 381 381 { 382 - struct ad7879 *ts = container_of(chip, struct ad7879, gc); 382 + struct ad7879 *ts = gpiochip_get_data(chip); 383 383 int err; 384 384 385 385 mutex_lock(&ts->mutex); ··· 393 393 static int ad7879_gpio_direction_output(struct gpio_chip *chip, 394 394 unsigned gpio, int level) 395 395 { 396 - struct ad7879 *ts = container_of(chip, struct ad7879, gc); 396 + struct ad7879 *ts = gpiochip_get_data(chip); 397 397 int err; 398 398 399 399 mutex_lock(&ts->mutex); ··· 412 412 413 413 static int ad7879_gpio_get_value(struct gpio_chip *chip, unsigned gpio) 414 414 { 415 - struct ad7879 *ts = container_of(chip, struct ad7879, gc); 415 + struct ad7879 *ts = gpiochip_get_data(chip); 416 416 u16 val; 417 417 418 418 mutex_lock(&ts->mutex); ··· 425 425 static void ad7879_gpio_set_value(struct gpio_chip *chip, 426 426 unsigned gpio, int value) 427 427 { 428 - struct ad7879 *ts = container_of(chip, struct ad7879, gc); 428 + struct ad7879 *ts = gpiochip_get_data(chip); 429 429 430 430 mutex_lock(&ts->mutex); 431 431 if (value) ··· 456 456 ts->gc.owner = THIS_MODULE; 457 457 ts->gc.parent = ts->dev; 458 458 459 - ret = gpiochip_add(&ts->gc); 459 + ret = gpiochip_add_data(&ts->gc, ts); 460 460 if (ret) 461 461 dev_err(ts->dev, "failed to register gpio %d\n", 462 462 ts->gc.base);
+1 -2
drivers/mfd/intel_quark_i2c_gpio.c
··· 219 219 return -ENOMEM; 220 220 221 221 /* Set the properties for portA */ 222 - pdata->properties->node = NULL; 223 - pdata->properties->name = "intel-quark-x1000-gpio-portA"; 222 + pdata->properties->fwnode = NULL; 224 223 pdata->properties->idx = 0; 225 224 pdata->properties->ngpio = INTEL_QUARK_MFD_NGPIO; 226 225 pdata->properties->gpio_base = INTEL_QUARK_MFD_GPIO_BASE;
+1 -1
drivers/pinctrl/sh-pfc/gpio.c
··· 212 212 } 213 213 } 214 214 215 - return -ENOSYS; 215 + return 0; 216 216 217 217 found: 218 218 return pfc->irqs[i];
+3 -3
drivers/platform/x86/intel_pmic_gpio.c
··· 30 30 #include <linux/ioport.h> 31 31 #include <linux/init.h> 32 32 #include <linux/io.h> 33 - #include <linux/gpio.h> 33 + #include <linux/gpio/driver.h> 34 34 #include <asm/intel_scu_ipc.h> 35 35 #include <linux/device.h> 36 36 #include <linux/intel_pmic_gpio.h> ··· 174 174 175 175 static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned offset) 176 176 { 177 - struct pmic_gpio *pg = container_of(chip, struct pmic_gpio, chip); 177 + struct pmic_gpio *pg = gpiochip_get_data(chip); 178 178 179 179 return pg->irq_base + offset; 180 180 } ··· 279 279 mutex_init(&pg->buslock); 280 280 281 281 pg->chip.parent = dev; 282 - retval = gpiochip_add(&pg->chip); 282 + retval = gpiochip_add_data(&pg->chip, pg); 283 283 if (retval) { 284 284 pr_err("Can not add pmic gpio chip\n"); 285 285 goto err;
+8 -12
drivers/soc/fsl/qe/gpio.c
··· 18 18 #include <linux/io.h> 19 19 #include <linux/of.h> 20 20 #include <linux/of_gpio.h> 21 + #include <linux/gpio/driver.h> 22 + /* FIXME: needed for gpio_to_chip() get rid of this */ 21 23 #include <linux/gpio.h> 22 24 #include <linux/slab.h> 23 25 #include <linux/export.h> ··· 39 37 struct qe_pio_regs saved_regs; 40 38 }; 41 39 42 - static inline struct qe_gpio_chip * 43 - to_qe_gpio_chip(struct of_mm_gpio_chip *mm_gc) 44 - { 45 - return container_of(mm_gc, struct qe_gpio_chip, mm_gc); 46 - } 47 - 48 40 static void qe_gpio_save_regs(struct of_mm_gpio_chip *mm_gc) 49 41 { 50 - struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc); 42 + struct qe_gpio_chip *qe_gc = gpiochip_get_data(&mm_gc->gc); 51 43 struct qe_pio_regs __iomem *regs = mm_gc->regs; 52 44 53 45 qe_gc->cpdata = in_be32(&regs->cpdata); ··· 65 69 static void qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) 66 70 { 67 71 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 68 - struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc); 72 + struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc); 69 73 struct qe_pio_regs __iomem *regs = mm_gc->regs; 70 74 unsigned long flags; 71 75 u32 pin_mask = 1 << (QE_PIO_PINS - 1 - gpio); ··· 85 89 static int qe_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio) 86 90 { 87 91 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 88 - struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc); 92 + struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc); 89 93 unsigned long flags; 90 94 91 95 spin_lock_irqsave(&qe_gc->lock, flags); ··· 100 104 static int qe_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) 101 105 { 102 106 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 103 - struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc); 107 + struct qe_gpio_chip *qe_gc = gpiochip_get_data(gc); 104 108 unsigned long flags; 105 109 106 110 qe_gpio_set(gc, gpio, val); ··· 161 165 } 162 166 163 167 mm_gc = to_of_mm_gpio_chip(gc); 164 - qe_gc = to_qe_gpio_chip(mm_gc); 168 + qe_gc = gpiochip_get_data(gc); 165 169 166 170 spin_lock_irqsave(&qe_gc->lock, flags); 167 171 ··· 298 302 gc->get = qe_gpio_get; 299 303 gc->set = qe_gpio_set; 300 304 301 - ret = of_mm_gpiochip_add(np, mm_gc); 305 + ret = of_mm_gpiochip_add_data(np, mm_gc, qe_gc); 302 306 if (ret) 303 307 goto err; 304 308 continue;
+14 -19
drivers/ssb/driver_gpio.c
··· 8 8 * Licensed under the GNU/GPL. See COPYING for details. 9 9 */ 10 10 11 - #include <linux/gpio.h> 11 + #include <linux/gpio/driver.h> 12 12 #include <linux/irq.h> 13 13 #include <linux/interrupt.h> 14 14 #include <linux/irqdomain.h> ··· 22 22 * Shared 23 23 **************************************************/ 24 24 25 - static struct ssb_bus *ssb_gpio_get_bus(struct gpio_chip *chip) 26 - { 27 - return container_of(chip, struct ssb_bus, gpio); 28 - } 29 - 30 25 #if IS_ENABLED(CONFIG_SSB_EMBEDDED) 31 26 static int ssb_gpio_to_irq(struct gpio_chip *chip, unsigned gpio) 32 27 { 33 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 28 + struct ssb_bus *bus = gpiochip_get_data(chip); 34 29 35 30 if (bus->bustype == SSB_BUSTYPE_SSB) 36 31 return irq_find_mapping(bus->irq_domain, gpio); ··· 40 45 41 46 static int ssb_gpio_chipco_get_value(struct gpio_chip *chip, unsigned gpio) 42 47 { 43 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 48 + struct ssb_bus *bus = gpiochip_get_data(chip); 44 49 45 50 return !!ssb_chipco_gpio_in(&bus->chipco, 1 << gpio); 46 51 } ··· 48 53 static void ssb_gpio_chipco_set_value(struct gpio_chip *chip, unsigned gpio, 49 54 int value) 50 55 { 51 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 56 + struct ssb_bus *bus = gpiochip_get_data(chip); 52 57 53 58 ssb_chipco_gpio_out(&bus->chipco, 1 << gpio, value ? 1 << gpio : 0); 54 59 } ··· 56 61 static int ssb_gpio_chipco_direction_input(struct gpio_chip *chip, 57 62 unsigned gpio) 58 63 { 59 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 64 + struct ssb_bus *bus = gpiochip_get_data(chip); 60 65 61 66 ssb_chipco_gpio_outen(&bus->chipco, 1 << gpio, 0); 62 67 return 0; ··· 65 70 static int ssb_gpio_chipco_direction_output(struct gpio_chip *chip, 66 71 unsigned gpio, int value) 67 72 { 68 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 73 + struct ssb_bus *bus = gpiochip_get_data(chip); 69 74 70 75 ssb_chipco_gpio_outen(&bus->chipco, 1 << gpio, 1 << gpio); 71 76 ssb_chipco_gpio_out(&bus->chipco, 1 << gpio, value ? 1 << gpio : 0); ··· 74 79 75 80 static int ssb_gpio_chipco_request(struct gpio_chip *chip, unsigned gpio) 76 81 { 77 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 82 + struct ssb_bus *bus = gpiochip_get_data(chip); 78 83 79 84 ssb_chipco_gpio_control(&bus->chipco, 1 << gpio, 0); 80 85 /* clear pulldown */ ··· 87 92 88 93 static void ssb_gpio_chipco_free(struct gpio_chip *chip, unsigned gpio) 89 94 { 90 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 95 + struct ssb_bus *bus = gpiochip_get_data(chip); 91 96 92 97 /* clear pullup */ 93 98 ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 0); ··· 241 246 if (err) 242 247 return err; 243 248 244 - err = gpiochip_add(chip); 249 + err = gpiochip_add_data(chip, bus); 245 250 if (err) { 246 251 ssb_gpio_irq_chipco_domain_exit(bus); 247 252 return err; ··· 258 263 259 264 static int ssb_gpio_extif_get_value(struct gpio_chip *chip, unsigned gpio) 260 265 { 261 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 266 + struct ssb_bus *bus = gpiochip_get_data(chip); 262 267 263 268 return !!ssb_extif_gpio_in(&bus->extif, 1 << gpio); 264 269 } ··· 266 271 static void ssb_gpio_extif_set_value(struct gpio_chip *chip, unsigned gpio, 267 272 int value) 268 273 { 269 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 274 + struct ssb_bus *bus = gpiochip_get_data(chip); 270 275 271 276 ssb_extif_gpio_out(&bus->extif, 1 << gpio, value ? 1 << gpio : 0); 272 277 } ··· 274 279 static int ssb_gpio_extif_direction_input(struct gpio_chip *chip, 275 280 unsigned gpio) 276 281 { 277 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 282 + struct ssb_bus *bus = gpiochip_get_data(chip); 278 283 279 284 ssb_extif_gpio_outen(&bus->extif, 1 << gpio, 0); 280 285 return 0; ··· 283 288 static int ssb_gpio_extif_direction_output(struct gpio_chip *chip, 284 289 unsigned gpio, int value) 285 290 { 286 - struct ssb_bus *bus = ssb_gpio_get_bus(chip); 291 + struct ssb_bus *bus = gpiochip_get_data(chip); 287 292 288 293 ssb_extif_gpio_outen(&bus->extif, 1 << gpio, 1 << gpio); 289 294 ssb_extif_gpio_out(&bus->extif, 1 << gpio, value ? 1 << gpio : 0); ··· 434 439 if (err) 435 440 return err; 436 441 437 - err = gpiochip_add(chip); 442 + err = gpiochip_add_data(chip, bus); 438 443 if (err) { 439 444 ssb_gpio_irq_extif_domain_exit(bus); 440 445 return err;
+6 -11
drivers/staging/vme/devices/vme_pio2_gpio.c
··· 17 17 #include <linux/device.h> 18 18 #include <linux/platform_device.h> 19 19 #include <linux/ctype.h> 20 - #include <linux/gpio.h> 20 + #include <linux/gpio/driver.h> 21 21 #include <linux/slab.h> 22 22 #include <linux/vme.h> 23 23 ··· 25 25 26 26 static const char driver_name[] = "pio2_gpio"; 27 27 28 - static struct pio2_card *gpio_to_pio2_card(struct gpio_chip *chip) 29 - { 30 - return container_of(chip, struct pio2_card, gc); 31 - } 32 - 33 28 static int pio2_gpio_get(struct gpio_chip *chip, unsigned int offset) 34 29 { 35 30 u8 reg; 36 31 int retval; 37 - struct pio2_card *card = gpio_to_pio2_card(chip); 32 + struct pio2_card *card = gpiochip_get_data(chip); 38 33 39 34 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == OUTPUT) | 40 35 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) { ··· 66 71 { 67 72 u8 reg; 68 73 int retval; 69 - struct pio2_card *card = gpio_to_pio2_card(chip); 74 + struct pio2_card *card = gpiochip_get_data(chip); 70 75 71 76 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) | 72 77 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) { ··· 95 100 static int pio2_gpio_dir_in(struct gpio_chip *chip, unsigned offset) 96 101 { 97 102 int data; 98 - struct pio2_card *card = gpio_to_pio2_card(chip); 103 + struct pio2_card *card = gpiochip_get_data(chip); 99 104 100 105 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == OUTPUT) | 101 106 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) { ··· 114 119 static int pio2_gpio_dir_out(struct gpio_chip *chip, unsigned offset, int value) 115 120 { 116 121 int data; 117 - struct pio2_card *card = gpio_to_pio2_card(chip); 122 + struct pio2_card *card = gpiochip_get_data(chip); 118 123 119 124 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) | 120 125 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) { ··· 200 205 card->gc.set = pio2_gpio_set; 201 206 202 207 /* This function adds a memory mapped GPIO chip */ 203 - retval = gpiochip_add(&card->gc); 208 + retval = gpiochip_add_data(&card->gc, card); 204 209 if (retval) { 205 210 dev_err(&card->vdev->dev, "Unable to register GPIO\n"); 206 211 kfree(card->gc.label);
+6 -6
drivers/tty/serial/max310x.c
··· 17 17 #include <linux/clk.h> 18 18 #include <linux/delay.h> 19 19 #include <linux/device.h> 20 - #include <linux/gpio.h> 20 + #include <linux/gpio/driver.h> 21 21 #include <linux/module.h> 22 22 #include <linux/of.h> 23 23 #include <linux/of_device.h> ··· 1036 1036 static int max310x_gpio_get(struct gpio_chip *chip, unsigned offset) 1037 1037 { 1038 1038 unsigned int val; 1039 - struct max310x_port *s = container_of(chip, struct max310x_port, gpio); 1039 + struct max310x_port *s = gpiochip_get_data(chip); 1040 1040 struct uart_port *port = &s->p[offset / 4].port; 1041 1041 1042 1042 val = max310x_port_read(port, MAX310X_GPIODATA_REG); ··· 1046 1046 1047 1047 static void max310x_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 1048 1048 { 1049 - struct max310x_port *s = container_of(chip, struct max310x_port, gpio); 1049 + struct max310x_port *s = gpiochip_get_data(chip); 1050 1050 struct uart_port *port = &s->p[offset / 4].port; 1051 1051 1052 1052 max310x_port_update(port, MAX310X_GPIODATA_REG, 1 << (offset % 4), ··· 1055 1055 1056 1056 static int max310x_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 1057 1057 { 1058 - struct max310x_port *s = container_of(chip, struct max310x_port, gpio); 1058 + struct max310x_port *s = gpiochip_get_data(chip); 1059 1059 struct uart_port *port = &s->p[offset / 4].port; 1060 1060 1061 1061 max310x_port_update(port, MAX310X_GPIOCFG_REG, 1 << (offset % 4), 0); ··· 1066 1066 static int max310x_gpio_direction_output(struct gpio_chip *chip, 1067 1067 unsigned offset, int value) 1068 1068 { 1069 - struct max310x_port *s = container_of(chip, struct max310x_port, gpio); 1069 + struct max310x_port *s = gpiochip_get_data(chip); 1070 1070 struct uart_port *port = &s->p[offset / 4].port; 1071 1071 1072 1072 max310x_port_update(port, MAX310X_GPIODATA_REG, 1 << (offset % 4), ··· 1183 1183 s->gpio.base = -1; 1184 1184 s->gpio.ngpio = devtype->nr * 4; 1185 1185 s->gpio.can_sleep = 1; 1186 - ret = gpiochip_add(&s->gpio); 1186 + ret = gpiochip_add_data(&s->gpio, s); 1187 1187 if (ret) 1188 1188 goto out_uart; 1189 1189 #endif
+6 -10
drivers/tty/serial/sc16is7xx.c
··· 17 17 #include <linux/clk.h> 18 18 #include <linux/delay.h> 19 19 #include <linux/device.h> 20 - #include <linux/gpio.h> 20 + #include <linux/gpio/driver.h> 21 21 #include <linux/i2c.h> 22 22 #include <linux/module.h> 23 23 #include <linux/of.h> ··· 1104 1104 static int sc16is7xx_gpio_get(struct gpio_chip *chip, unsigned offset) 1105 1105 { 1106 1106 unsigned int val; 1107 - struct sc16is7xx_port *s = container_of(chip, struct sc16is7xx_port, 1108 - gpio); 1107 + struct sc16is7xx_port *s = gpiochip_get_data(chip); 1109 1108 struct uart_port *port = &s->p[0].port; 1110 1109 1111 1110 val = sc16is7xx_port_read(port, SC16IS7XX_IOSTATE_REG); ··· 1114 1115 1115 1116 static void sc16is7xx_gpio_set(struct gpio_chip *chip, unsigned offset, int val) 1116 1117 { 1117 - struct sc16is7xx_port *s = container_of(chip, struct sc16is7xx_port, 1118 - gpio); 1118 + struct sc16is7xx_port *s = gpiochip_get_data(chip); 1119 1119 struct uart_port *port = &s->p[0].port; 1120 1120 1121 1121 sc16is7xx_port_update(port, SC16IS7XX_IOSTATE_REG, BIT(offset), ··· 1124 1126 static int sc16is7xx_gpio_direction_input(struct gpio_chip *chip, 1125 1127 unsigned offset) 1126 1128 { 1127 - struct sc16is7xx_port *s = container_of(chip, struct sc16is7xx_port, 1128 - gpio); 1129 + struct sc16is7xx_port *s = gpiochip_get_data(chip); 1129 1130 struct uart_port *port = &s->p[0].port; 1130 1131 1131 1132 sc16is7xx_port_update(port, SC16IS7XX_IODIR_REG, BIT(offset), 0); ··· 1135 1138 static int sc16is7xx_gpio_direction_output(struct gpio_chip *chip, 1136 1139 unsigned offset, int val) 1137 1140 { 1138 - struct sc16is7xx_port *s = container_of(chip, struct sc16is7xx_port, 1139 - gpio); 1141 + struct sc16is7xx_port *s = gpiochip_get_data(chip); 1140 1142 struct uart_port *port = &s->p[0].port; 1141 1143 1142 1144 sc16is7xx_port_update(port, SC16IS7XX_IOSTATE_REG, BIT(offset), ··· 1206 1210 s->gpio.base = -1; 1207 1211 s->gpio.ngpio = devtype->nr_gpio; 1208 1212 s->gpio.can_sleep = 1; 1209 - ret = gpiochip_add(&s->gpio); 1213 + ret = gpiochip_add_data(&s->gpio, s); 1210 1214 if (ret) 1211 1215 goto out_thread; 1212 1216 }
+24 -1
include/linux/gpio/driver.h
··· 20 20 #ifdef CONFIG_GPIOLIB 21 21 22 22 /** 23 + * enum single_ended_mode - mode for single ended operation 24 + * @LINE_MODE_PUSH_PULL: normal mode for a GPIO line, drive actively high/low 25 + * @LINE_MODE_OPEN_DRAIN: set line to be open drain 26 + * @LINE_MODE_OPEN_SOURCE: set line to be open source 27 + */ 28 + enum single_ended_mode { 29 + LINE_MODE_PUSH_PULL, 30 + LINE_MODE_OPEN_DRAIN, 31 + LINE_MODE_OPEN_SOURCE, 32 + }; 33 + 34 + /** 23 35 * struct gpio_chip - abstract a GPIO controller 24 36 * @label: a functional name for the GPIO device, such as a part 25 37 * number or the name of the SoC IP-block implementing it. ··· 50 38 * @set: assigns output value for signal "offset" 51 39 * @set_multiple: assigns output values for multiple signals defined by "mask" 52 40 * @set_debounce: optional hook for setting debounce time for specified gpio in 53 - * interrupt triggered gpio chips 41 + * interrupt triggered gpio chips 42 + * @set_single_ended: optional hook for setting a line as open drain, open 43 + * source, or non-single ended (restore from open drain/source to normal 44 + * push-pull mode) this should be implemented if the hardware supports 45 + * open drain or open source settings. The GPIOlib will otherwise try 46 + * to emulate open drain/source by not actively driving lines high/low 47 + * if a consumer request this. The driver may return -ENOTSUPP if e.g. 48 + * it supports just open drain but not open source and is called 49 + * with LINE_MODE_OPEN_SOURCE as mode argument. 54 50 * @to_irq: optional hook supporting non-static gpio_to_irq() mappings; 55 51 * implementation may not sleep 56 52 * @dbg_show: optional routine to show contents in debugfs; default code ··· 150 130 int (*set_debounce)(struct gpio_chip *chip, 151 131 unsigned offset, 152 132 unsigned debounce); 133 + int (*set_single_ended)(struct gpio_chip *chip, 134 + unsigned offset, 135 + enum single_ended_mode mode); 153 136 154 137 int (*to_irq)(struct gpio_chip *chip, 155 138 unsigned offset);
-82
include/linux/i2c/sx150x.h
··· 1 - /* 2 - * Driver for the Semtech SX150x I2C GPIO Expanders 3 - * 4 - * Copyright (c) 2010, Code Aurora Forum. All rights reserved. 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License version 2 and 8 - * only version 2 as published by the Free Software Foundation. 9 - * 10 - * This program is distributed in the hope that it will be useful, 11 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 - * GNU General Public License for more details. 14 - * 15 - * You should have received a copy of the GNU General Public License 16 - * along with this program; if not, write to the Free Software 17 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 - * 02110-1301, USA. 19 - */ 20 - #ifndef __LINUX_I2C_SX150X_H 21 - #define __LINUX_I2C_SX150X_H 22 - 23 - /** 24 - * struct sx150x_platform_data - config data for SX150x driver 25 - * @gpio_base: The index number of the first GPIO assigned to this 26 - * GPIO expander. The expander will create a block of 27 - * consecutively numbered gpios beginning at the given base, 28 - * with the size of the block depending on the model of the 29 - * expander chip. 30 - * @oscio_is_gpo: If set to true, the driver will configure OSCIO as a GPO 31 - * instead of as an oscillator, increasing the size of the 32 - * GP(I)O pool created by this expander by one. The 33 - * output-only GPO pin will be added at the end of the block. 34 - * @io_pullup_ena: A bit-mask which enables or disables the pull-up resistor 35 - * for each IO line in the expander. Setting the bit at 36 - * position n will enable the pull-up for the IO at 37 - * the corresponding offset. For chips with fewer than 38 - * 16 IO pins, high-end bits are ignored. 39 - * @io_pulldn_ena: A bit-mask which enables-or disables the pull-down 40 - * resistor for each IO line in the expander. Setting the 41 - * bit at position n will enable the pull-down for the IO at 42 - * the corresponding offset. For chips with fewer than 43 - * 16 IO pins, high-end bits are ignored. 44 - * @io_open_drain_ena: A bit-mask which enables-or disables open-drain 45 - * operation for each IO line in the expander. Setting the 46 - * bit at position n enables open-drain operation for 47 - * the IO at the corresponding offset. Clearing the bit 48 - * enables regular push-pull operation for that IO. 49 - * For chips with fewer than 16 IO pins, high-end bits 50 - * are ignored. 51 - * @io_polarity: A bit-mask which enables polarity inversion for each IO line 52 - * in the expander. Setting the bit at position n inverts 53 - * the polarity of that IO line, while clearing it results 54 - * in normal polarity. For chips with fewer than 16 IO pins, 55 - * high-end bits are ignored. 56 - * @irq_summary: The 'summary IRQ' line to which the GPIO expander's INT line 57 - * is connected, via which it reports interrupt events 58 - * across all GPIO lines. This must be a real, 59 - * pre-existing IRQ line. 60 - * Setting this value < 0 disables the irq_chip functionality 61 - * of the driver. 62 - * @irq_base: The first 'virtual IRQ' line at which our block of GPIO-based 63 - * IRQ lines will appear. Similarly to gpio_base, the expander 64 - * will create a block of irqs beginning at this number. 65 - * This value is ignored if irq_summary is < 0. 66 - * @reset_during_probe: If set to true, the driver will trigger a full 67 - * reset of the chip at the beginning of the probe 68 - * in order to place it in a known state. 69 - */ 70 - struct sx150x_platform_data { 71 - unsigned gpio_base; 72 - bool oscio_is_gpo; 73 - u16 io_pullup_ena; 74 - u16 io_pulldn_ena; 75 - u16 io_open_drain_ena; 76 - u16 io_polarity; 77 - int irq_summary; 78 - unsigned irq_base; 79 - bool reset_during_probe; 80 - }; 81 - 82 - #endif /* __LINUX_I2C_SX150X_H */
+1 -2
include/linux/platform_data/gpio-dwapb.h
··· 15 15 #define GPIO_DW_APB_H 16 16 17 17 struct dwapb_port_property { 18 - struct device_node *node; 19 - const char *name; 18 + struct fwnode_handle *fwnode; 20 19 unsigned int idx; 21 20 unsigned int ngpio; 22 21 unsigned int gpio_base;
+1
kernel/irq/irqdomain.c
··· 1100 1100 } 1101 1101 irq_domain_free_irqs_parent(domain, virq, nr_irqs); 1102 1102 } 1103 + EXPORT_SYMBOL_GPL(irq_domain_free_irqs_common); 1103 1104 1104 1105 /** 1105 1106 * irq_domain_free_irqs_top - Clear handler and handler data, clear irqdata and free parent
+6 -11
sound/soc/codecs/rt5677.c
··· 4520 4520 } 4521 4521 4522 4522 #ifdef CONFIG_GPIOLIB 4523 - static inline struct rt5677_priv *gpio_to_rt5677(struct gpio_chip *chip) 4524 - { 4525 - return container_of(chip, struct rt5677_priv, gpio_chip); 4526 - } 4527 - 4528 4523 static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 4529 4524 { 4530 - struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4525 + struct rt5677_priv *rt5677 = gpiochip_get_data(chip); 4531 4526 4532 4527 switch (offset) { 4533 4528 case RT5677_GPIO1 ... RT5677_GPIO5: ··· 4543 4548 static int rt5677_gpio_direction_out(struct gpio_chip *chip, 4544 4549 unsigned offset, int value) 4545 4550 { 4546 - struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4551 + struct rt5677_priv *rt5677 = gpiochip_get_data(chip); 4547 4552 4548 4553 switch (offset) { 4549 4554 case RT5677_GPIO1 ... RT5677_GPIO5: ··· 4567 4572 4568 4573 static int rt5677_gpio_get(struct gpio_chip *chip, unsigned offset) 4569 4574 { 4570 - struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4575 + struct rt5677_priv *rt5677 = gpiochip_get_data(chip); 4571 4576 int value, ret; 4572 4577 4573 4578 ret = regmap_read(rt5677->regmap, RT5677_GPIO_ST, &value); ··· 4579 4584 4580 4585 static int rt5677_gpio_direction_in(struct gpio_chip *chip, unsigned offset) 4581 4586 { 4582 - struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4587 + struct rt5677_priv *rt5677 = gpiochip_get_data(chip); 4583 4588 4584 4589 switch (offset) { 4585 4590 case RT5677_GPIO1 ... RT5677_GPIO5: ··· 4633 4638 4634 4639 static int rt5677_to_irq(struct gpio_chip *chip, unsigned offset) 4635 4640 { 4636 - struct rt5677_priv *rt5677 = gpio_to_rt5677(chip); 4641 + struct rt5677_priv *rt5677 = gpiochip_get_data(chip); 4637 4642 struct regmap_irq_chip_data *data = rt5677->irq_data; 4638 4643 int irq; 4639 4644 ··· 4692 4697 rt5677->gpio_chip.parent = &i2c->dev; 4693 4698 rt5677->gpio_chip.base = -1; 4694 4699 4695 - ret = gpiochip_add(&rt5677->gpio_chip); 4700 + ret = gpiochip_add_data(&rt5677->gpio_chip, rt5677); 4696 4701 if (ret != 0) 4697 4702 dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret); 4698 4703 }
+6 -10
sound/soc/codecs/wm5100.c
··· 17 17 #include <linux/export.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/gcd.h> 20 + #include <linux/gpio/driver.h> 20 21 #include <linux/gpio.h> 21 22 #include <linux/i2c.h> 22 23 #include <linux/pm_runtime.h> ··· 2237 2236 } 2238 2237 2239 2238 #ifdef CONFIG_GPIOLIB 2240 - static inline struct wm5100_priv *gpio_to_wm5100(struct gpio_chip *chip) 2241 - { 2242 - return container_of(chip, struct wm5100_priv, gpio_chip); 2243 - } 2244 - 2245 2239 static void wm5100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 2246 2240 { 2247 - struct wm5100_priv *wm5100 = gpio_to_wm5100(chip); 2241 + struct wm5100_priv *wm5100 = gpiochip_get_data(chip); 2248 2242 2249 2243 regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, 2250 2244 WM5100_GP1_LVL, !!value << WM5100_GP1_LVL_SHIFT); ··· 2248 2252 static int wm5100_gpio_direction_out(struct gpio_chip *chip, 2249 2253 unsigned offset, int value) 2250 2254 { 2251 - struct wm5100_priv *wm5100 = gpio_to_wm5100(chip); 2255 + struct wm5100_priv *wm5100 = gpiochip_get_data(chip); 2252 2256 int val, ret; 2253 2257 2254 2258 val = (1 << WM5100_GP1_FN_SHIFT) | (!!value << WM5100_GP1_LVL_SHIFT); ··· 2264 2268 2265 2269 static int wm5100_gpio_get(struct gpio_chip *chip, unsigned offset) 2266 2270 { 2267 - struct wm5100_priv *wm5100 = gpio_to_wm5100(chip); 2271 + struct wm5100_priv *wm5100 = gpiochip_get_data(chip); 2268 2272 unsigned int reg; 2269 2273 int ret; 2270 2274 ··· 2277 2281 2278 2282 static int wm5100_gpio_direction_in(struct gpio_chip *chip, unsigned offset) 2279 2283 { 2280 - struct wm5100_priv *wm5100 = gpio_to_wm5100(chip); 2284 + struct wm5100_priv *wm5100 = gpiochip_get_data(chip); 2281 2285 2282 2286 return regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, 2283 2287 WM5100_GP1_FN_MASK | WM5100_GP1_DIR, ··· 2309 2313 else 2310 2314 wm5100->gpio_chip.base = -1; 2311 2315 2312 - ret = gpiochip_add(&wm5100->gpio_chip); 2316 + ret = gpiochip_add_data(&wm5100->gpio_chip, wm5100); 2313 2317 if (ret != 0) 2314 2318 dev_err(&i2c->dev, "Failed to add GPIOs: %d\n", ret); 2315 2319 }
+6 -11
sound/soc/codecs/wm8903.c
··· 20 20 #include <linux/init.h> 21 21 #include <linux/completion.h> 22 22 #include <linux/delay.h> 23 - #include <linux/gpio.h> 23 + #include <linux/gpio/driver.h> 24 24 #include <linux/pm.h> 25 25 #include <linux/i2c.h> 26 26 #include <linux/regmap.h> ··· 1766 1766 } 1767 1767 1768 1768 #ifdef CONFIG_GPIOLIB 1769 - static inline struct wm8903_priv *gpio_to_wm8903(struct gpio_chip *chip) 1770 - { 1771 - return container_of(chip, struct wm8903_priv, gpio_chip); 1772 - } 1773 - 1774 1769 static int wm8903_gpio_request(struct gpio_chip *chip, unsigned offset) 1775 1770 { 1776 1771 if (offset >= WM8903_NUM_GPIO) ··· 1776 1781 1777 1782 static int wm8903_gpio_direction_in(struct gpio_chip *chip, unsigned offset) 1778 1783 { 1779 - struct wm8903_priv *wm8903 = gpio_to_wm8903(chip); 1784 + struct wm8903_priv *wm8903 = gpiochip_get_data(chip); 1780 1785 unsigned int mask, val; 1781 1786 int ret; 1782 1787 ··· 1794 1799 1795 1800 static int wm8903_gpio_get(struct gpio_chip *chip, unsigned offset) 1796 1801 { 1797 - struct wm8903_priv *wm8903 = gpio_to_wm8903(chip); 1802 + struct wm8903_priv *wm8903 = gpiochip_get_data(chip); 1798 1803 unsigned int reg; 1799 1804 1800 1805 regmap_read(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset, &reg); ··· 1805 1810 static int wm8903_gpio_direction_out(struct gpio_chip *chip, 1806 1811 unsigned offset, int value) 1807 1812 { 1808 - struct wm8903_priv *wm8903 = gpio_to_wm8903(chip); 1813 + struct wm8903_priv *wm8903 = gpiochip_get_data(chip); 1809 1814 unsigned int mask, val; 1810 1815 int ret; 1811 1816 ··· 1823 1828 1824 1829 static void wm8903_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 1825 1830 { 1826 - struct wm8903_priv *wm8903 = gpio_to_wm8903(chip); 1831 + struct wm8903_priv *wm8903 = gpiochip_get_data(chip); 1827 1832 1828 1833 regmap_update_bits(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset, 1829 1834 WM8903_GP1_LVL_MASK, ··· 1855 1860 else 1856 1861 wm8903->gpio_chip.base = -1; 1857 1862 1858 - ret = gpiochip_add(&wm8903->gpio_chip); 1863 + ret = gpiochip_add_data(&wm8903->gpio_chip, wm8903); 1859 1864 if (ret != 0) 1860 1865 dev_err(wm8903->dev, "Failed to add GPIOs: %d\n", ret); 1861 1866 }
+5 -10
sound/soc/codecs/wm8962.c
··· 18 18 #include <linux/delay.h> 19 19 #include <linux/pm.h> 20 20 #include <linux/gcd.h> 21 - #include <linux/gpio.h> 21 + #include <linux/gpio/driver.h> 22 22 #include <linux/i2c.h> 23 23 #include <linux/input.h> 24 24 #include <linux/pm_runtime.h> ··· 3307 3307 } 3308 3308 3309 3309 #ifdef CONFIG_GPIOLIB 3310 - static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip) 3311 - { 3312 - return container_of(chip, struct wm8962_priv, gpio_chip); 3313 - } 3314 - 3315 3310 static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) 3316 3311 { 3317 - struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); 3312 + struct wm8962_priv *wm8962 = gpiochip_get_data(chip); 3318 3313 3319 3314 /* The WM8962 GPIOs aren't linearly numbered. For simplicity 3320 3315 * we export linear numbers and error out if the unsupported ··· 3332 3337 3333 3338 static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 3334 3339 { 3335 - struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); 3340 + struct wm8962_priv *wm8962 = gpiochip_get_data(chip); 3336 3341 struct snd_soc_codec *codec = wm8962->codec; 3337 3342 3338 3343 snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, ··· 3342 3347 static int wm8962_gpio_direction_out(struct gpio_chip *chip, 3343 3348 unsigned offset, int value) 3344 3349 { 3345 - struct wm8962_priv *wm8962 = gpio_to_wm8962(chip); 3350 + struct wm8962_priv *wm8962 = gpiochip_get_data(chip); 3346 3351 struct snd_soc_codec *codec = wm8962->codec; 3347 3352 int ret, val; 3348 3353 ··· 3381 3386 else 3382 3387 wm8962->gpio_chip.base = -1; 3383 3388 3384 - ret = gpiochip_add(&wm8962->gpio_chip); 3389 + ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962); 3385 3390 if (ret != 0) 3386 3391 dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); 3387 3392 }
+6 -10
sound/soc/codecs/wm8996.c
··· 17 17 #include <linux/delay.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/gcd.h> 20 + #include <linux/gpio/driver.h> 20 21 #include <linux/gpio.h> 21 22 #include <linux/i2c.h> 22 23 #include <linux/regmap.h> ··· 2140 2139 } 2141 2140 2142 2141 #ifdef CONFIG_GPIOLIB 2143 - static inline struct wm8996_priv *gpio_to_wm8996(struct gpio_chip *chip) 2144 - { 2145 - return container_of(chip, struct wm8996_priv, gpio_chip); 2146 - } 2147 - 2148 2142 static void wm8996_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 2149 2143 { 2150 - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); 2144 + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); 2151 2145 2152 2146 regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, 2153 2147 WM8996_GP1_LVL, !!value << WM8996_GP1_LVL_SHIFT); ··· 2151 2155 static int wm8996_gpio_direction_out(struct gpio_chip *chip, 2152 2156 unsigned offset, int value) 2153 2157 { 2154 - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); 2158 + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); 2155 2159 int val; 2156 2160 2157 2161 val = (1 << WM8996_GP1_FN_SHIFT) | (!!value << WM8996_GP1_LVL_SHIFT); ··· 2163 2167 2164 2168 static int wm8996_gpio_get(struct gpio_chip *chip, unsigned offset) 2165 2169 { 2166 - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); 2170 + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); 2167 2171 unsigned int reg; 2168 2172 int ret; 2169 2173 ··· 2176 2180 2177 2181 static int wm8996_gpio_direction_in(struct gpio_chip *chip, unsigned offset) 2178 2182 { 2179 - struct wm8996_priv *wm8996 = gpio_to_wm8996(chip); 2183 + struct wm8996_priv *wm8996 = gpiochip_get_data(chip); 2180 2184 2181 2185 return regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, 2182 2186 WM8996_GP1_FN_MASK | WM8996_GP1_DIR, ··· 2207 2211 else 2208 2212 wm8996->gpio_chip.base = -1; 2209 2213 2210 - ret = gpiochip_add(&wm8996->gpio_chip); 2214 + ret = gpiochip_add_data(&wm8996->gpio_chip, wm8996); 2211 2215 if (ret != 0) 2212 2216 dev_err(wm8996->dev, "Failed to add GPIOs: %d\n", ret); 2213 2217 }
+3 -5
sound/soc/soc-ac97.c
··· 59 59 #ifdef CONFIG_GPIOLIB 60 60 static inline struct snd_soc_codec *gpio_to_codec(struct gpio_chip *chip) 61 61 { 62 - struct snd_ac97_gpio_priv *gpio_priv = 63 - container_of(chip, struct snd_ac97_gpio_priv, gpio_chip); 62 + struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); 64 63 65 64 return gpio_priv->codec; 66 65 } ··· 97 98 static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset, 98 99 int value) 99 100 { 100 - struct snd_ac97_gpio_priv *gpio_priv = 101 - container_of(chip, struct snd_ac97_gpio_priv, gpio_chip); 101 + struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); 102 102 struct snd_soc_codec *codec = gpio_to_codec(chip); 103 103 104 104 gpio_priv->gpios_set &= ~(1 << offset); ··· 143 145 gpio_priv->gpio_chip.parent = codec->dev; 144 146 gpio_priv->gpio_chip.base = -1; 145 147 146 - ret = gpiochip_add(&gpio_priv->gpio_chip); 148 + ret = gpiochip_add_data(&gpio_priv->gpio_chip, gpio_priv); 147 149 if (ret != 0) 148 150 dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); 149 151 return ret;
+1 -1
tools/gpio/Makefile
··· 1 1 CC = $(CROSS_COMPILE)gcc 2 - CFLAGS += -Wall -g -D_GNU_SOURCE 2 + CFLAGS += -O2 -Wall -g -D_GNU_SOURCE 3 3 4 4 all: lsgpio 5 5
+1 -1
tools/gpio/lsgpio.c
··· 147 147 148 148 int main(int argc, char **argv) 149 149 { 150 - const char *device_name; 150 + const char *device_name = NULL; 151 151 int ret; 152 152 int c; 153 153