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

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

Pull GPIO updates from Linus Walleij:
"This is the bulk of GPIO changes for the v4.9 series:

Subsystem improvements:

- do away with the last users of the obsolete Kconfig options
ARCH_REQUIRE_GPIOLIB and ARCH_WANT_OPTIONAL_GPIOLIB (the latter
always sounded like an item on a wishlist to Santa Claus to me). We
can now select GPIOLIB and be done with it, for all archs. After
some struggle it even work on UM. Not that it has GPIO, but if it
wants to, it can select the library.

- continued efforts to make drivers properly either tristate or bool.

- introduce a warning for drivers assigning default triggers to their
irqchip lines when probed from device tree, so we find and fix
these ambigous drivers. It is agreed that in the OF config path,
the device tree defines trigger characteristics.

- the same warning, mutatis mutandis, for ACPI-probed GPIO irqchips.

- we introduce the ability to mark certain IRQ lines as "unusable" as
they can be taken by BIOS/firmware, unrouted in silicon and
generally nasty if you use them, and such things. This is put to
good use in the STMPE driver and also in the Cherryview pin control
driver.

- a new "mockup" virtual GPIO device that can be used for testing.
The plan is to add unit tests under tools/* for exercising this
device and verify that the kernel code paths are working as they
should.

- make memory-mapped I/O-drivers depend on HAS_IOMEM. This was
implicit all the time, but when people started building UM with
allyesconfig or allmodconfig it exploded in their face.

- move some stray bits of device tree and ACPI HW description
callbacks down into their respective implementation silo. These
were causing issues when compiling on !HAS_IOMEM as well, so now
eventually UM compiles the GPIOLIB library if it wants to.

New drivers:

- new driver for the Aspeed GPIO front-end companion to the pin
controller merged through the pin control tree.

- new driver for the LP873x PMIC GPIO portions.

- new driver for Technologic Systems' I2C FPGA GPIO such as TS4900,
TS-7970, TS-7990 and TS-4100.

- new driver for the Broadcom BCM63xx series including BCM6338 and
BCM6345.

- new driver for the Intel WhiskeyCove PMIC GPIO.

- new driver for the Allwinner AXP209 PMIC GPIO portions.

- new driver for Diamond Systems 48 line GPIO-MM, another of these
port-mapped I/O expansion cards.

- support the STMicroelectronics STMPE1600 variant in the STMPE
driver.

Driver improvements:

- the STMPE driver now supports rising/falling edge detection
properly for IRQs.

- the PCA954x will now fetch and enable its VCC regulator properly.

- major rework of the PCA953x driver with the goal of eventually
switching it over to use regmap and thus modernize it even more.

- switch the IOP driver to use the generic MMIO GPIO library.

- move the ages old HTC EGPIO (extended GPIO) GPIO expander driver
over to this subsystem from MFD, achieveing some separation of
concerns"

* tag 'gpio-v4.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (81 commits)
gpio: add missing static inline
gpio: OF: localize some gpiochip init functions
gpio: acpi: separation of concerns
gpio: OF: separation of concerns
gpio: make memory-mapped drivers depend on HAS_IOMEM
gpio: stmpe: use BIT() macro
gpio: stmpe: forbid unused lines to be mapped as IRQs
mfd/gpio: Move HTC GPIO driver to GPIO subsystem
gpio: MAINTAINERS: Add an entry for GPIO mockup driver
gpio/mockup: add virtual gpio device
gpio: Added zynq specific check for special pins on bank zero
gpio: axp209: Implement get_direction
gpio: aspeed: remove redundant return value check
gpio: loongson1: remove redundant return value check
ARM: omap2: fix missing include
gpio: tc3589x: fix up complaints on unsigned
gpio: tc3589x: add .get_direction() and small cleanup
gpio: f7188x: use gpiochip_get_data instead of container_of
gpio: tps65218: use devm_gpiochip_add_data() for gpio registration
gpio: aspeed: fix return value check in aspeed_gpio_probe()
...

+3458 -687
+46
Documentation/devicetree/bindings/gpio/brcm,bcm6345-gpio.txt
··· 1 + Bindings for the Broadcom's brcm,bcm6345-gpio memory-mapped GPIO controllers. 2 + 3 + These bindings can be used on any BCM63xx SoC. However, BCM6338 and BCM6345 4 + are the only ones which don't need a pinctrl driver. 5 + BCM6338 have 8-bit data and dirout registers, where GPIO state can be read 6 + and/or written, and the direction changed from input to output. 7 + BCM6345 have 16-bit data and dirout registers, where GPIO state can be read 8 + and/or written, and the direction changed from input to output. 9 + 10 + Required properties: 11 + - compatible: should be "brcm,bcm6345-gpio" 12 + - reg-names: must contain 13 + "dat" - data register 14 + "dirout" - direction (output) register 15 + - reg: address + size pairs describing the GPIO register sets; 16 + order must correspond with the order of entries in reg-names 17 + - #gpio-cells: must be set to 2. The first cell is the pin number and 18 + the second cell is used to specify the gpio polarity: 19 + 0 = active high 20 + 1 = active low 21 + - gpio-controller: Marks the device node as a gpio controller. 22 + 23 + Optional properties: 24 + - native-endian: use native endian memory. 25 + 26 + Examples: 27 + - BCM6338: 28 + gpio: gpio-controller@fffe0407 { 29 + compatible = "brcm,bcm6345-gpio"; 30 + reg-names = "dirout", "dat"; 31 + reg = <0xfffe0407 1>, <0xfffe040f 1>; 32 + 33 + #gpio-cells = <2>; 34 + gpio-controller; 35 + }; 36 + 37 + - BCM6345: 38 + gpio: gpio-controller@fffe0406 { 39 + compatible = "brcm,bcm6345-gpio"; 40 + reg-names = "dirout", "dat"; 41 + reg = <0xfffe0406 2>, <0xfffe040a 2>; 42 + native-endian; 43 + 44 + #gpio-cells = <2>; 45 + gpio-controller; 46 + };
+36
Documentation/devicetree/bindings/gpio/gpio-aspeed.txt
··· 1 + Aspeed GPIO controller Device Tree Bindings 2 + ------------------------------------------- 3 + 4 + Required properties: 5 + - compatible : Either "aspeed,ast2400-gpio" or "aspeed,ast2500-gpio" 6 + 7 + - #gpio-cells : Should be two 8 + - First cell is the GPIO line number 9 + - Second cell is used to specify optional 10 + parameters (unused) 11 + 12 + - reg : Address and length of the register set for the device 13 + - gpio-controller : Marks the device node as a GPIO controller. 14 + - interrupts : Interrupt specifier (see interrupt bindings for 15 + details) 16 + - interrupt-controller : Mark the GPIO controller as an interrupt-controller 17 + 18 + Optional properties: 19 + 20 + - interrupt-parent : The parent interrupt controller, optional if inherited 21 + 22 + The gpio and interrupt properties are further described in their respective 23 + bindings documentation: 24 + 25 + - Documentation/devicetree/bindings/gpio/gpio.txt 26 + - Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 27 + 28 + Example: 29 + gpio@1e780000 { 30 + #gpio-cells = <2>; 31 + compatible = "aspeed,ast2400-gpio"; 32 + gpio-controller; 33 + interrupts = <20>; 34 + reg = <0x1e780000 0x1000>; 35 + interrupt-controller; 36 + };
+30
Documentation/devicetree/bindings/gpio/gpio-axp209.txt
··· 1 + AXP209 GPIO controller 2 + 3 + This driver follows the usual GPIO bindings found in 4 + Documentation/devicetree/bindings/gpio/gpio.txt 5 + 6 + Required properties: 7 + - compatible: Should be "x-powers,axp209-gpio" 8 + - #gpio-cells: Should be two. The first cell is the pin number and the 9 + second is the GPIO flags. 10 + - gpio-controller: Marks the device node as a GPIO controller. 11 + 12 + This node must be a subnode of the axp20x PMIC, documented in 13 + Documentation/devicetree/bindings/mfd/axp20x.txt 14 + 15 + Example: 16 + 17 + axp209: pmic@34 { 18 + compatible = "x-powers,axp209"; 19 + reg = <0x34>; 20 + interrupt-parent = <&nmi_intc>; 21 + interrupts = <0 IRQ_TYPE_LEVEL_LOW>; 22 + interrupt-controller; 23 + #interrupt-cells = <1>; 24 + 25 + axp_gpio: gpio { 26 + compatible = "x-powers,axp209-gpio"; 27 + gpio-controller; 28 + #gpio-cells = <2>; 29 + }; 30 + };
+16
Documentation/devicetree/bindings/gpio/gpio-tpic2810.txt
··· 1 + TPIC2810 GPIO controller bindings 2 + 3 + Required properties: 4 + - compatible : Should be "ti,tpic2810". 5 + - reg : The I2C address of the device 6 + - gpio-controller : Marks the device node as a GPIO controller. 7 + - #gpio-cells : Should be two. For consumer use see gpio.txt. 8 + 9 + Example: 10 + 11 + gpio@60 { 12 + compatible = "ti,tpic2810"; 13 + reg = <0x60>; 14 + gpio-controller; 15 + #gpio-cells = <2>; 16 + };
-16
Documentation/devicetree/bindings/gpio/gpio-tps65086.txt
··· 1 - * TPS65086 GPO Controller bindings 2 - 3 - Required properties: 4 - - compatible : Should be "ti,tps65086-gpio". 5 - - gpio-controller : Marks the device node as a GPIO Controller. 6 - - #gpio-cells : Should be two. The first cell is the pin number 7 - and the second cell is used to specify flags. 8 - See ../gpio/gpio.txt for possible values. 9 - 10 - Example: 11 - 12 - gpio4: gpio { 13 - compatible = "ti,tps65086-gpio"; 14 - gpio-controller; 15 - #gpio-cells = <2>; 16 - };
+30
Documentation/devicetree/bindings/gpio/gpio-ts4900.txt
··· 1 + * Technologic Systems I2C-FPGA's GPIO controller bindings 2 + 3 + This bindings describes the GPIO controller for Technologic's FPGA core. 4 + TS-4900's FPGA encodes the GPIO state on 3 bits, whereas the TS-7970's FPGA 5 + uses 2 bits: it doesn't use a dedicated input bit. 6 + 7 + Required properties: 8 + - compatible: Should be one of the following 9 + "technologic,ts4900-gpio" 10 + "technologic,ts7970-gpio" 11 + - reg: Physical base address of the controller and length 12 + of memory mapped region. 13 + - #gpio-cells: Should be two. The first cell is the pin number. 14 + - gpio-controller: Marks the device node as a gpio controller. 15 + 16 + Optional property: 17 + - ngpios: Number of GPIOs this controller is instantiated with, 18 + the default is 32. See gpio.txt for more details. 19 + 20 + Example: 21 + 22 + &i2c2 { 23 + gpio8: gpio@28 { 24 + compatible = "technologic,ts4900-gpio"; 25 + reg = <0x28>; 26 + #gpio-cells = <2>; 27 + gpio-controller; 28 + ngpios = <32>; 29 + }; 30 + };
-23
Documentation/devicetree/bindings/gpio/mrvl-gpio.txt
··· 44 44 interrupt-controller; 45 45 #interrupt-cells = <0x2>; 46 46 }; 47 - 48 - * Marvell Orion GPIO Controller 49 - 50 - Required properties: 51 - - compatible : Should be "marvell,orion-gpio" 52 - - reg : Address and length of the register set for controller. 53 - - gpio-controller : So we know this is a gpio controller. 54 - - ngpio : How many gpios this controller has. 55 - - interrupts : Up to 4 Interrupts for the controller. 56 - 57 - Optional properties: 58 - - mask-offset : For SMP Orions, offset for Nth CPU 59 - 60 - Example: 61 - 62 - gpio0: gpio@10100 { 63 - compatible = "marvell,orion-gpio"; 64 - #gpio-cells = <2>; 65 - gpio-controller; 66 - reg = <0x10100 0x40>; 67 - ngpio = <32>; 68 - interrupts = <35>, <36>, <37>, <38>; 69 - };
+1
Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
··· 11 11 - "renesas,gpio-r8a7793": for R8A7793 (R-Car M2-N) compatible GPIO controller. 12 12 - "renesas,gpio-r8a7794": for R8A7794 (R-Car E2) compatible GPIO controller. 13 13 - "renesas,gpio-r8a7795": for R8A7795 (R-Car H3) compatible GPIO controller. 14 + - "renesas,gpio-r8a7796": for R8A7796 (R-Car M3-W) compatible GPIO controller. 14 15 - "renesas,gpio-rcar": for generic R-Car GPIO controller. 15 16 16 17 - reg: Base address and length of each memory resource used by the GPIO
+1 -1
Documentation/devicetree/bindings/mfd/stmpe.txt
··· 4 4 keypad, touchscreen, adc, pwm, rotator. 5 5 6 6 Required properties: 7 - - compatible : "st,stmpe[610|801|811|1601|2401|2403]" 7 + - compatible : "st,stmpe[610|801|811|1600|1601|2401|2403]" 8 8 - reg : I2C/SPI address of the device 9 9 10 10 Optional properties:
+3 -3
Documentation/gpio/board.txt
··· 8 8 interface; you just fetch an integer from somewhere and request the 9 9 corresponding GPIO. 10 10 11 - Platforms that make use of GPIOs must select ARCH_REQUIRE_GPIOLIB (if GPIO usage 12 - is mandatory) or ARCH_WANT_OPTIONAL_GPIOLIB (if GPIO support can be omitted) in 13 - their Kconfig. Then, how GPIOs are mapped depends on what the platform uses to 11 + All platforms can enable the GPIO library, but if the platform strictly 12 + requires GPIO functionality to be present, it needs to select GPIOLIB from its 13 + Kconfig. Then, how GPIOs are mapped depends on what the platform uses to 14 14 describe its hardware layout. Currently, mappings can be defined through device 15 15 tree, ACPI, and platform data. 16 16
+4 -12
Documentation/gpio/gpio-legacy.txt
··· 72 72 not care how it's implemented.) 73 73 74 74 That said, if the convention is supported on their platform, drivers should 75 - use it when possible. Platforms must select ARCH_REQUIRE_GPIOLIB or 76 - ARCH_WANT_OPTIONAL_GPIOLIB in their Kconfig. Drivers that can't work without 75 + use it when possible. Platforms must select GPIOLIB if GPIO functionality 76 + is strictly required. Drivers that can't work without 77 77 standard GPIO calls should have Kconfig entries which depend on GPIOLIB. The 78 78 GPIO calls are available, either as "real code" or as optimized-away stubs, 79 79 when drivers use the include file: ··· 553 553 554 554 Platform Support 555 555 ---------------- 556 - To support this framework, a platform's Kconfig will "select" either 557 - ARCH_REQUIRE_GPIOLIB or ARCH_WANT_OPTIONAL_GPIOLIB 558 - and arrange that its <asm/gpio.h> includes <asm-generic/gpio.h> and defines 559 - three functions: gpio_get_value(), gpio_set_value(), and gpio_cansleep(). 556 + To force-enable this framework, a platform's Kconfig will "select" GPIOLIB, 557 + else it is up to the user to configure support for GPIO. 560 558 561 559 It may also provide a custom value for ARCH_NR_GPIOS, so that it better 562 560 reflects the number of GPIOs in actual use on that platform, without 563 561 wasting static table space. (It should count both built-in/SoC GPIOs and 564 562 also ones on GPIO expanders. 565 - 566 - ARCH_REQUIRE_GPIOLIB means that the gpiolib code will always get compiled 567 - into the kernel on that architecture. 568 - 569 - ARCH_WANT_OPTIONAL_GPIOLIB means the gpiolib code defaults to off and the user 570 - can enable it and build it into the kernel optionally. 571 563 572 564 If neither of these options are selected, the platform does not support 573 565 GPIOs through GPIO-lib and the code cannot be enabled by the user.
+4
Documentation/kernel-parameters.txt
··· 1374 1374 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0. 1375 1375 Default: 1024 1376 1376 1377 + gpio-mockup.gpio_mockup_ranges 1378 + [HW] Sets the ranges of gpiochip of for this device. 1379 + Format: <start1>,<end1>,<start2>,<end2>... 1380 + 1377 1381 hardlockup_all_cpu_backtrace= 1378 1382 [KNL] Should the hard-lockup detector generate 1379 1383 backtraces on all cpus.
+13
MAINTAINERS
··· 3794 3794 F: include/sound/da[79]*.h 3795 3795 F: sound/soc/codecs/da[79]*.[ch] 3796 3796 3797 + DIAMOND SYSTEMS GPIO-MM GPIO DRIVER 3798 + M: William Breathitt Gray <vilhelm.gray@gmail.com> 3799 + L: linux-gpio@vger.kernel.org 3800 + S: Maintained 3801 + F: drivers/gpio/gpio-gpio-mm.c 3802 + 3797 3803 DIGI NEO AND CLASSIC PCI PRODUCTS 3798 3804 M: Lidza Louina <lidza.louina@gmail.com> 3799 3805 M: Mark Hounschell <markh@compro.net> ··· 5279 5273 L: linux-input@vger.kernel.org 5280 5274 S: Maintained 5281 5275 F: drivers/input/touchscreen/goodix.c 5276 + 5277 + GPIO MOCKUP DRIVER 5278 + M: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> 5279 + L: linux-gpio@vger.kernel.org 5280 + S: Maintained 5281 + F: drivers/gpio/gpio-mockup.c 5282 + F: tools/testing/selftests/gpio/ 5282 5283 5283 5284 GPIO SUBSYSTEM 5284 5285 M: Linus Walleij <linus.walleij@linaro.org>
+1
arch/arm/mach-omap2/board-rx51-peripherals.c
··· 29 29 #include <linux/power/isp1704_charger.h> 30 30 #include <linux/platform_data/spi-omap2-mcspi.h> 31 31 #include <linux/platform_data/mtd-onenand-omap2.h> 32 + #include <linux/module.h> 32 33 33 34 #include <plat/dmtimer.h> 34 35
+1 -1
arch/arm/mach-pxa/hx4700.c
··· 24 24 #include <linux/input.h> 25 25 #include <linux/input/navpoint.h> 26 26 #include <linux/lcd.h> 27 - #include <linux/mfd/htc-egpio.h> 28 27 #include <linux/mfd/asic3.h> 29 28 #include <linux/mtd/physmap.h> 30 29 #include <linux/pda_power.h> 30 + #include <linux/platform_data/gpio-htc-egpio.h> 31 31 #include <linux/pwm.h> 32 32 #include <linux/pwm_backlight.h> 33 33 #include <linux/regulator/driver.h>
+1 -1
arch/arm/mach-pxa/magician.c
··· 20 20 #include <linux/gpio.h> 21 21 #include <linux/gpio_keys.h> 22 22 #include <linux/input.h> 23 - #include <linux/mfd/htc-egpio.h> 24 23 #include <linux/mfd/htc-pasic3.h> 25 24 #include <linux/mtd/physmap.h> 26 25 #include <linux/pda_power.h> 26 + #include <linux/platform_data/gpio-htc-egpio.h> 27 27 #include <linux/pwm.h> 28 28 #include <linux/pwm_backlight.h> 29 29 #include <linux/regulator/driver.h>
+1 -1
arch/arm/mach-sa1100/h3xxx.c
··· 14 14 #include <linux/gpio.h> 15 15 #include <linux/gpio_keys.h> 16 16 #include <linux/input.h> 17 - #include <linux/mfd/htc-egpio.h> 18 17 #include <linux/mtd/mtd.h> 19 18 #include <linux/mtd/partitions.h> 19 + #include <linux/platform_data/gpio-htc-egpio.h> 20 20 #include <linux/platform_data/sa11x0-serial.h> 21 21 #include <linux/platform_device.h> 22 22 #include <linux/serial_core.h>
-1
arch/arm64/Kconfig
··· 17 17 select ARCH_USE_CMPXCHG_LOCKREF 18 18 select ARCH_SUPPORTS_ATOMIC_RMW 19 19 select ARCH_SUPPORTS_NUMA_BALANCING 20 - select ARCH_WANT_OPTIONAL_GPIOLIB 21 20 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION 22 21 select ARCH_WANT_FRAME_POINTERS 23 22 select ARCH_HAS_UBSAN_SANITIZE_ALL
+6 -6
arch/arm64/Kconfig.platforms
··· 15 15 16 16 config ARCH_BCM2835 17 17 bool "Broadcom BCM2835 family" 18 - select ARCH_REQUIRE_GPIOLIB 19 18 select CLKSRC_OF 19 + select GPIOLIB 20 20 select PINCTRL 21 21 select PINCTRL_BCM2835 22 22 select ARM_AMBA ··· 29 29 config ARCH_BCM_IPROC 30 30 bool "Broadcom iProc SoC Family" 31 31 select COMMON_CLK_IPROC 32 + select GPIOLIB 32 33 select PINCTRL 33 - select ARCH_REQUIRE_GPIOLIB 34 34 help 35 35 This enables support for Broadcom iProc based SoCs 36 36 37 37 config ARCH_BERLIN 38 38 bool "Marvell Berlin SoC Family" 39 - select ARCH_REQUIRE_GPIOLIB 40 39 select DW_APB_ICTL 40 + select GPIOLIB 41 41 select PINCTRL 42 42 help 43 43 This enables support for Marvell Berlin SoC Family ··· 110 110 config ARCH_ROCKCHIP 111 111 bool "Rockchip Platforms" 112 112 select ARCH_HAS_RESET_CONTROLLER 113 - select ARCH_REQUIRE_GPIOLIB 113 + select GPIOLIB 114 114 select PINCTRL 115 115 select PINCTRL_ROCKCHIP 116 116 select ROCKCHIP_TIMER ··· 156 156 config ARCH_TEGRA 157 157 bool "NVIDIA Tegra SoC Family" 158 158 select ARCH_HAS_RESET_CONTROLLER 159 - select ARCH_REQUIRE_GPIOLIB 160 159 select CLKDEV_LOOKUP 161 160 select CLKSRC_MMIO 162 161 select CLKSRC_OF 163 162 select GENERIC_CLOCKEVENTS 163 + select GPIOLIB 164 164 select PINCTRL 165 165 select RESET_CONTROLLER 166 166 help ··· 184 184 185 185 config ARCH_VEXPRESS 186 186 bool "ARMv8 software model (Versatile Express)" 187 - select ARCH_REQUIRE_GPIOLIB 188 187 select COMMON_CLK_VERSATILE 188 + select GPIOLIB 189 189 select PM 190 190 select PM_GENERIC_DOMAINS 191 191 select POWER_RESET_VEXPRESS
+1 -1
arch/blackfin/Kconfig
··· 26 26 select HAVE_OPROFILE 27 27 select HAVE_PERF_EVENTS 28 28 select ARCH_HAVE_CUSTOM_GPIO_H 29 - select ARCH_REQUIRE_GPIOLIB 29 + select GPIOLIB 30 30 select HAVE_UID16 31 31 select HAVE_UNDERSCORE_SYMBOL_PREFIX 32 32 select VIRT_TO_BUS
+80 -22
drivers/gpio/Kconfig
··· 10 10 overriding the default implementations. New uses of this are 11 11 strongly discouraged. 12 12 13 - config ARCH_WANT_OPTIONAL_GPIOLIB 14 - bool 15 - help 16 - Select this config option from the architecture Kconfig, if 17 - it is possible to use gpiolib on the architecture, but let the 18 - user decide whether to actually build it or not. 19 - Select this instead of ARCH_REQUIRE_GPIOLIB, if your architecture does 20 - not depend on GPIOs being available, but rather let the user 21 - decide whether he needs it or not. 22 - 23 - config ARCH_REQUIRE_GPIOLIB 24 - bool 25 - select GPIOLIB 26 - help 27 - Platforms select gpiolib if they use this infrastructure 28 - for all their GPIOs, usually starting with ones integrated 29 - into SOC processors. 30 - Selecting this from the architecture code will cause the gpiolib 31 - code to always get built in. 32 - 33 - 34 13 menuconfig GPIOLIB 35 14 bool "GPIO Support" 36 15 select ANON_INODES ··· 66 87 exported to userspace; this can be useful when debugging. 67 88 68 89 config GPIO_GENERIC 90 + depends on HAS_IOMEM # Only for IOMEM drivers 69 91 tristate 70 92 71 93 # put drivers in the right section, in alphabetical order ··· 76 96 tristate 77 97 78 98 menu "Memory mapped GPIO drivers" 99 + depends on HAS_IOMEM 79 100 80 101 config GPIO_74XX_MMIO 81 102 tristate "GPIO driver for 74xx-ICs with MMIO access" ··· 109 128 driver for GPIO functionality on Promontory IOHub 110 129 Require ACPI ASL code to enumerate as a platform device. 111 130 131 + config GPIO_ASPEED 132 + tristate "Aspeed GPIO support" 133 + depends on (ARCH_ASPEED || COMPILE_TEST) && OF_GPIO 134 + select GPIOLIB_IRQCHIP 135 + help 136 + Say Y here to support Aspeed AST2400 and AST2500 GPIO controllers. 137 + 112 138 config GPIO_ATH79 113 139 tristate "Atheros AR71XX/AR724X/AR913X GPIO support" 114 140 default y if ATH79 ··· 125 137 help 126 138 Select this option to enable GPIO driver for 127 139 Atheros AR71XX/AR724X/AR913X SoC devices. 140 + 141 + config GPIO_AXP209 142 + tristate "X-Powers AXP209 PMIC GPIO Support" 143 + depends on MFD_AXP20X 144 + help 145 + Say yes to enable GPIO support for the AXP209 PMIC 128 146 129 147 config GPIO_BCM_KONA 130 148 bool "Broadcom Kona GPIO" ··· 231 237 232 238 config GPIO_IOP 233 239 tristate "Intel IOP GPIO" 234 - depends on ARM && (ARCH_IOP32X || ARCH_IOP33X) 240 + depends on ARCH_IOP32X || ARCH_IOP33X || COMPILE_TEST 241 + select GPIO_GENERIC 235 242 help 236 243 Say yes here to support the GPIO functionality of a number of Intel 237 244 IOP32X or IOP33X. ··· 281 286 This enables support for memory mapped GPIOs on the External Bus Unit 282 287 (EBU) found on Lantiq SoCs. The gpios are output only as they are 283 288 created by attaching a 16bit latch to the bus. 289 + 290 + config GPIO_MOCKUP 291 + tristate "GPIO Testing Driver" 292 + depends on GPIOLIB 293 + select GPIO_SYSFS 294 + help 295 + This enables GPIO Testing driver, which provides a way to test GPIO 296 + subsystem through sysfs(or char device) and debugfs. GPIO_SYSFS 297 + must be selected for this test. 298 + User could use it through the script in 299 + tools/testing/selftests/gpio/gpio-mockup.sh. Reference the usage in 300 + it. 284 301 285 302 config GPIO_MOXART 286 303 bool "MOXART GPIO support" ··· 581 574 To compile this driver as a module, choose M here: the module will 582 575 be called f7188x-gpio. 583 576 577 + config GPIO_GPIO_MM 578 + tristate "Diamond Systems GPIO-MM GPIO support" 579 + depends on ISA_BUS_API 580 + help 581 + Enables GPIO support for the Diamond Systems GPIO-MM and GPIO-MM-12. 582 + 583 + The Diamond Systems GPIO-MM device features 48 lines of digital I/O 584 + via the emulation of dual 82C55A PPI chips. This driver provides GPIO 585 + support for these 48 channels of digital I/O. 586 + 587 + The base port addresses for the devices may be configured via the base 588 + array module parameter. 589 + 584 590 config GPIO_IT87 585 591 tristate "IT87xx GPIO support" 586 592 help ··· 800 780 To compile this driver as a module, choose M here: the module will 801 781 be called gpio-tpic2810. 802 782 783 + config GPIO_TS4900 784 + tristate "Technologic Systems FPGA I2C GPIO" 785 + select REGMAP_I2C 786 + help 787 + Say yes here to enabled the GPIO driver for Technologic's FPGA core. 788 + Series supported include TS-4100, TS-4900, TS-7970 and TS-7990. 789 + 803 790 endmenu 804 791 805 792 menu "MFD GPIO expanders" ··· 876 849 This driver can also be built as a module. If so, the module 877 850 will be called gpio-dln2. 878 851 852 + config HTC_EGPIO 853 + bool "HTC EGPIO support" 854 + depends on GPIOLIB && ARM 855 + help 856 + This driver supports the CPLD egpio chip present on 857 + several HTC phones. It provides basic support for input 858 + pins, output pins, and irqs. 859 + 879 860 config GPIO_JANZ_TTL 880 861 tristate "Janz VMOD-TTL Digital IO Module" 881 862 depends on MFD_JANZ_CMODIO ··· 909 874 GPIO driver for LP3943 MFD. 910 875 LP3943 can be used as a GPIO expander which provides up to 16 GPIOs. 911 876 Open drain outputs are required for this usage. 877 + 878 + config GPIO_LP873X 879 + tristate "TI LP873X GPO" 880 + depends on MFD_TI_LP873X 881 + help 882 + This driver supports the GPO on TI Lp873x PMICs. 2 GPOs are present 883 + on LP873X PMICs. 884 + 885 + This driver can also be built as a module. If so, the module will be 886 + called gpio-lp873x. 912 887 913 888 config GPIO_MAX77620 914 889 tristate "GPIO support for PMIC MAX77620 and MAX20024" ··· 1029 984 help 1030 985 This enables support for the Philips UCB1400 GPIO pins. 1031 986 The UCB1400 is an AC97 audio codec. 987 + 988 + config GPIO_WHISKEY_COVE 989 + tristate "GPIO support for Whiskey Cove PMIC" 990 + depends on INTEL_SOC_PMIC 991 + select GPIOLIB_IRQCHIP 992 + help 993 + Support for GPIO pins on Whiskey Cove PMIC. 994 + 995 + Say Yes if you have a Intel SoC based tablet with Whiskey Cove PMIC 996 + inside. 997 + 998 + This driver can also be built as a module. If so, the module will be 999 + called gpio-wcove. 1032 1000 1033 1001 config GPIO_WM831X 1034 1002 tristate "WM831x GPIOs"
+8
drivers/gpio/Makefile
··· 28 28 obj-$(CONFIG_GPIO_AMDPT) += gpio-amdpt.o 29 29 obj-$(CONFIG_GPIO_ARIZONA) += gpio-arizona.o 30 30 obj-$(CONFIG_GPIO_ATH79) += gpio-ath79.o 31 + obj-$(CONFIG_GPIO_ASPEED) += gpio-aspeed.o 32 + obj-$(CONFIG_GPIO_AXP209) += gpio-axp209.o 31 33 obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o 32 34 obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o 33 35 obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o ··· 46 44 obj-$(CONFIG_GPIO_ETRAXFS) += gpio-etraxfs.o 47 45 obj-$(CONFIG_GPIO_F7188X) += gpio-f7188x.o 48 46 obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o 47 + obj-$(CONFIG_GPIO_GPIO_MM) += gpio-gpio-mm.o 49 48 obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o 49 + obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o 50 50 obj-$(CONFIG_GPIO_ICH) += gpio-ich.o 51 51 obj-$(CONFIG_GPIO_IOP) += gpio-iop.o 52 52 obj-$(CONFIG_GPIO_IT87) += gpio-it87.o ··· 60 56 obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o 61 57 obj-$(CONFIG_GPIO_LPC18XX) += gpio-lpc18xx.o 62 58 obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o 59 + obj-$(CONFIG_GPIO_LP873X) += gpio-lp873x.o 63 60 obj-$(CONFIG_GPIO_LYNXPOINT) += gpio-lynxpoint.o 64 61 obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o 65 62 obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o ··· 75 70 obj-$(CONFIG_GPIO_MCP23S08) += gpio-mcp23s08.o 76 71 obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o 77 72 obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o 73 + obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o 78 74 obj-$(CONFIG_GPIO_MOXART) += gpio-moxart.o 79 75 obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o 80 76 obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o ··· 116 110 obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o 117 111 obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o 118 112 obj-$(CONFIG_GPIO_TS4800) += gpio-ts4800.o 113 + obj-$(CONFIG_GPIO_TS4900) += gpio-ts4900.o 119 114 obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o 120 115 obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o 121 116 obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o ··· 127 120 obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o 128 121 obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o 129 122 obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o 123 + obj-$(CONFIG_GPIO_WHISKEY_COVE) += gpio-wcove.o 130 124 obj-$(CONFIG_GPIO_WM831X) += gpio-wm831x.o 131 125 obj-$(CONFIG_GPIO_WM8350) += gpio-wm8350.o 132 126 obj-$(CONFIG_GPIO_WM8994) += gpio-wm8994.o
+1
drivers/gpio/gpio-altera.c
··· 17 17 */ 18 18 19 19 #include <linux/io.h> 20 + #include <linux/module.h> 20 21 #include <linux/of_gpio.h> 21 22 #include <linux/platform_device.h> 22 23
+1 -1
drivers/gpio/gpio-arizona.c
··· 79 79 ARIZONA_GPN_LVL, value); 80 80 } 81 81 82 - static struct gpio_chip template_chip = { 82 + static const struct gpio_chip template_chip = { 83 83 .label = "arizona", 84 84 .owner = THIS_MODULE, 85 85 .direction_input = arizona_gpio_direction_in,
+455
drivers/gpio/gpio-aspeed.c
··· 1 + /* 2 + * Copyright 2015 IBM Corp. 3 + * 4 + * Joel Stanley <joel@jms.id.au> 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License 8 + * as published by the Free Software Foundation; either version 9 + * 2 of the License, or (at your option) any later version. 10 + */ 11 + 12 + #include <linux/module.h> 13 + #include <linux/kernel.h> 14 + #include <linux/init.h> 15 + #include <linux/io.h> 16 + #include <linux/spinlock.h> 17 + #include <linux/platform_device.h> 18 + #include <linux/gpio/driver.h> 19 + #include <linux/pinctrl/consumer.h> 20 + 21 + struct aspeed_gpio { 22 + struct gpio_chip chip; 23 + spinlock_t lock; 24 + void __iomem *base; 25 + int irq; 26 + }; 27 + 28 + struct aspeed_gpio_bank { 29 + uint16_t val_regs; 30 + uint16_t irq_regs; 31 + const char names[4]; 32 + }; 33 + 34 + static const struct aspeed_gpio_bank aspeed_gpio_banks[] = { 35 + { 36 + .val_regs = 0x0000, 37 + .irq_regs = 0x0008, 38 + .names = { 'A', 'B', 'C', 'D' }, 39 + }, 40 + { 41 + .val_regs = 0x0020, 42 + .irq_regs = 0x0028, 43 + .names = { 'E', 'F', 'G', 'H' }, 44 + }, 45 + { 46 + .val_regs = 0x0070, 47 + .irq_regs = 0x0098, 48 + .names = { 'I', 'J', 'K', 'L' }, 49 + }, 50 + { 51 + .val_regs = 0x0078, 52 + .irq_regs = 0x00e8, 53 + .names = { 'M', 'N', 'O', 'P' }, 54 + }, 55 + { 56 + .val_regs = 0x0080, 57 + .irq_regs = 0x0118, 58 + .names = { 'Q', 'R', 'S', 'T' }, 59 + }, 60 + { 61 + .val_regs = 0x0088, 62 + .irq_regs = 0x0148, 63 + .names = { 'U', 'V', 'W', 'X' }, 64 + }, 65 + /* 66 + * A bank exists for { 'Y', 'Z', "AA", "AB" }, but is not implemented. 67 + * Only half of GPIOs Y support interrupt configuration, and none of Z, 68 + * AA or AB do as they are output only. 69 + */ 70 + }; 71 + 72 + #define GPIO_BANK(x) ((x) >> 5) 73 + #define GPIO_OFFSET(x) ((x) & 0x1f) 74 + #define GPIO_BIT(x) BIT(GPIO_OFFSET(x)) 75 + 76 + #define GPIO_DATA 0x00 77 + #define GPIO_DIR 0x04 78 + 79 + #define GPIO_IRQ_ENABLE 0x00 80 + #define GPIO_IRQ_TYPE0 0x04 81 + #define GPIO_IRQ_TYPE1 0x08 82 + #define GPIO_IRQ_TYPE2 0x0c 83 + #define GPIO_IRQ_STATUS 0x10 84 + 85 + static const struct aspeed_gpio_bank *to_bank(unsigned int offset) 86 + { 87 + unsigned int bank = GPIO_BANK(offset); 88 + 89 + WARN_ON(bank > ARRAY_SIZE(aspeed_gpio_banks)); 90 + return &aspeed_gpio_banks[bank]; 91 + } 92 + 93 + static void __iomem *bank_val_reg(struct aspeed_gpio *gpio, 94 + const struct aspeed_gpio_bank *bank, 95 + unsigned int reg) 96 + { 97 + return gpio->base + bank->val_regs + reg; 98 + } 99 + 100 + static void __iomem *bank_irq_reg(struct aspeed_gpio *gpio, 101 + const struct aspeed_gpio_bank *bank, 102 + unsigned int reg) 103 + { 104 + return gpio->base + bank->irq_regs + reg; 105 + } 106 + 107 + static int aspeed_gpio_get(struct gpio_chip *gc, unsigned int offset) 108 + { 109 + struct aspeed_gpio *gpio = gpiochip_get_data(gc); 110 + const struct aspeed_gpio_bank *bank = to_bank(offset); 111 + 112 + return !!(ioread32(bank_val_reg(gpio, bank, GPIO_DATA)) 113 + & GPIO_BIT(offset)); 114 + } 115 + 116 + static void __aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset, 117 + int val) 118 + { 119 + struct aspeed_gpio *gpio = gpiochip_get_data(gc); 120 + const struct aspeed_gpio_bank *bank = to_bank(offset); 121 + void __iomem *addr; 122 + u32 reg; 123 + 124 + addr = bank_val_reg(gpio, bank, GPIO_DATA); 125 + reg = ioread32(addr); 126 + 127 + if (val) 128 + reg |= GPIO_BIT(offset); 129 + else 130 + reg &= ~GPIO_BIT(offset); 131 + 132 + iowrite32(reg, addr); 133 + } 134 + 135 + static void aspeed_gpio_set(struct gpio_chip *gc, unsigned int offset, 136 + int val) 137 + { 138 + struct aspeed_gpio *gpio = gpiochip_get_data(gc); 139 + unsigned long flags; 140 + 141 + spin_lock_irqsave(&gpio->lock, flags); 142 + 143 + __aspeed_gpio_set(gc, offset, val); 144 + 145 + spin_unlock_irqrestore(&gpio->lock, flags); 146 + } 147 + 148 + static int aspeed_gpio_dir_in(struct gpio_chip *gc, unsigned int offset) 149 + { 150 + struct aspeed_gpio *gpio = gpiochip_get_data(gc); 151 + const struct aspeed_gpio_bank *bank = to_bank(offset); 152 + unsigned long flags; 153 + u32 reg; 154 + 155 + spin_lock_irqsave(&gpio->lock, flags); 156 + 157 + reg = ioread32(bank_val_reg(gpio, bank, GPIO_DIR)); 158 + iowrite32(reg & ~GPIO_BIT(offset), bank_val_reg(gpio, bank, GPIO_DIR)); 159 + 160 + spin_unlock_irqrestore(&gpio->lock, flags); 161 + 162 + return 0; 163 + } 164 + 165 + static int aspeed_gpio_dir_out(struct gpio_chip *gc, 166 + unsigned int offset, int val) 167 + { 168 + struct aspeed_gpio *gpio = gpiochip_get_data(gc); 169 + const struct aspeed_gpio_bank *bank = to_bank(offset); 170 + unsigned long flags; 171 + u32 reg; 172 + 173 + spin_lock_irqsave(&gpio->lock, flags); 174 + 175 + reg = ioread32(bank_val_reg(gpio, bank, GPIO_DIR)); 176 + iowrite32(reg | GPIO_BIT(offset), bank_val_reg(gpio, bank, GPIO_DIR)); 177 + 178 + __aspeed_gpio_set(gc, offset, val); 179 + 180 + spin_unlock_irqrestore(&gpio->lock, flags); 181 + 182 + return 0; 183 + } 184 + 185 + static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) 186 + { 187 + struct aspeed_gpio *gpio = gpiochip_get_data(gc); 188 + const struct aspeed_gpio_bank *bank = to_bank(offset); 189 + unsigned long flags; 190 + u32 val; 191 + 192 + spin_lock_irqsave(&gpio->lock, flags); 193 + 194 + val = ioread32(bank_val_reg(gpio, bank, GPIO_DIR)) & GPIO_BIT(offset); 195 + 196 + spin_unlock_irqrestore(&gpio->lock, flags); 197 + 198 + return !val; 199 + 200 + } 201 + 202 + static inline int irqd_to_aspeed_gpio_data(struct irq_data *d, 203 + struct aspeed_gpio **gpio, 204 + const struct aspeed_gpio_bank **bank, 205 + u32 *bit) 206 + { 207 + int offset; 208 + 209 + offset = irqd_to_hwirq(d); 210 + 211 + *gpio = irq_data_get_irq_chip_data(d); 212 + *bank = to_bank(offset); 213 + *bit = GPIO_BIT(offset); 214 + 215 + return 0; 216 + } 217 + 218 + static void aspeed_gpio_irq_ack(struct irq_data *d) 219 + { 220 + const struct aspeed_gpio_bank *bank; 221 + struct aspeed_gpio *gpio; 222 + unsigned long flags; 223 + void __iomem *status_addr; 224 + u32 bit; 225 + int rc; 226 + 227 + rc = irqd_to_aspeed_gpio_data(d, &gpio, &bank, &bit); 228 + if (rc) 229 + return; 230 + 231 + status_addr = bank_irq_reg(gpio, bank, GPIO_IRQ_STATUS); 232 + 233 + spin_lock_irqsave(&gpio->lock, flags); 234 + iowrite32(bit, status_addr); 235 + spin_unlock_irqrestore(&gpio->lock, flags); 236 + } 237 + 238 + static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set) 239 + { 240 + const struct aspeed_gpio_bank *bank; 241 + struct aspeed_gpio *gpio; 242 + unsigned long flags; 243 + u32 reg, bit; 244 + void __iomem *addr; 245 + int rc; 246 + 247 + rc = irqd_to_aspeed_gpio_data(d, &gpio, &bank, &bit); 248 + if (rc) 249 + return; 250 + 251 + addr = bank_irq_reg(gpio, bank, GPIO_IRQ_ENABLE); 252 + 253 + spin_lock_irqsave(&gpio->lock, flags); 254 + 255 + reg = ioread32(addr); 256 + if (set) 257 + reg |= bit; 258 + else 259 + reg &= bit; 260 + iowrite32(reg, addr); 261 + 262 + spin_unlock_irqrestore(&gpio->lock, flags); 263 + } 264 + 265 + static void aspeed_gpio_irq_mask(struct irq_data *d) 266 + { 267 + aspeed_gpio_irq_set_mask(d, false); 268 + } 269 + 270 + static void aspeed_gpio_irq_unmask(struct irq_data *d) 271 + { 272 + aspeed_gpio_irq_set_mask(d, true); 273 + } 274 + 275 + static int aspeed_gpio_set_type(struct irq_data *d, unsigned int type) 276 + { 277 + u32 type0 = 0; 278 + u32 type1 = 0; 279 + u32 type2 = 0; 280 + u32 bit, reg; 281 + const struct aspeed_gpio_bank *bank; 282 + irq_flow_handler_t handler; 283 + struct aspeed_gpio *gpio; 284 + unsigned long flags; 285 + void __iomem *addr; 286 + int rc; 287 + 288 + rc = irqd_to_aspeed_gpio_data(d, &gpio, &bank, &bit); 289 + if (rc) 290 + return -EINVAL; 291 + 292 + switch (type & IRQ_TYPE_SENSE_MASK) { 293 + case IRQ_TYPE_EDGE_BOTH: 294 + type2 |= bit; 295 + case IRQ_TYPE_EDGE_RISING: 296 + type0 |= bit; 297 + case IRQ_TYPE_EDGE_FALLING: 298 + handler = handle_edge_irq; 299 + break; 300 + case IRQ_TYPE_LEVEL_HIGH: 301 + type0 |= bit; 302 + case IRQ_TYPE_LEVEL_LOW: 303 + type1 |= bit; 304 + handler = handle_level_irq; 305 + break; 306 + default: 307 + return -EINVAL; 308 + } 309 + 310 + spin_lock_irqsave(&gpio->lock, flags); 311 + 312 + addr = bank_irq_reg(gpio, bank, GPIO_IRQ_TYPE0); 313 + reg = ioread32(addr); 314 + reg = (reg & ~bit) | type0; 315 + iowrite32(reg, addr); 316 + 317 + addr = bank_irq_reg(gpio, bank, GPIO_IRQ_TYPE1); 318 + reg = ioread32(addr); 319 + reg = (reg & ~bit) | type1; 320 + iowrite32(reg, addr); 321 + 322 + addr = bank_irq_reg(gpio, bank, GPIO_IRQ_TYPE2); 323 + reg = ioread32(addr); 324 + reg = (reg & ~bit) | type2; 325 + iowrite32(reg, addr); 326 + 327 + spin_unlock_irqrestore(&gpio->lock, flags); 328 + 329 + irq_set_handler_locked(d, handler); 330 + 331 + return 0; 332 + } 333 + 334 + static void aspeed_gpio_irq_handler(struct irq_desc *desc) 335 + { 336 + struct gpio_chip *gc = irq_desc_get_handler_data(desc); 337 + struct irq_chip *ic = irq_desc_get_chip(desc); 338 + struct aspeed_gpio *data = gpiochip_get_data(gc); 339 + unsigned int i, p, girq; 340 + unsigned long reg; 341 + 342 + chained_irq_enter(ic, desc); 343 + 344 + for (i = 0; i < ARRAY_SIZE(aspeed_gpio_banks); i++) { 345 + const struct aspeed_gpio_bank *bank = &aspeed_gpio_banks[i]; 346 + 347 + reg = ioread32(bank_irq_reg(data, bank, GPIO_IRQ_STATUS)); 348 + 349 + for_each_set_bit(p, &reg, 32) { 350 + girq = irq_find_mapping(gc->irqdomain, i * 32 + p); 351 + generic_handle_irq(girq); 352 + } 353 + 354 + } 355 + 356 + chained_irq_exit(ic, desc); 357 + } 358 + 359 + static struct irq_chip aspeed_gpio_irqchip = { 360 + .name = "aspeed-gpio", 361 + .irq_ack = aspeed_gpio_irq_ack, 362 + .irq_mask = aspeed_gpio_irq_mask, 363 + .irq_unmask = aspeed_gpio_irq_unmask, 364 + .irq_set_type = aspeed_gpio_set_type, 365 + }; 366 + 367 + static int aspeed_gpio_setup_irqs(struct aspeed_gpio *gpio, 368 + struct platform_device *pdev) 369 + { 370 + int rc; 371 + 372 + rc = platform_get_irq(pdev, 0); 373 + if (rc < 0) 374 + return rc; 375 + 376 + gpio->irq = rc; 377 + 378 + rc = gpiochip_irqchip_add(&gpio->chip, &aspeed_gpio_irqchip, 379 + 0, handle_bad_irq, IRQ_TYPE_NONE); 380 + if (rc) { 381 + dev_info(&pdev->dev, "Could not add irqchip\n"); 382 + return rc; 383 + } 384 + 385 + gpiochip_set_chained_irqchip(&gpio->chip, &aspeed_gpio_irqchip, 386 + gpio->irq, aspeed_gpio_irq_handler); 387 + 388 + return 0; 389 + } 390 + 391 + static int aspeed_gpio_request(struct gpio_chip *chip, unsigned int offset) 392 + { 393 + return pinctrl_request_gpio(chip->base + offset); 394 + } 395 + 396 + static void aspeed_gpio_free(struct gpio_chip *chip, unsigned int offset) 397 + { 398 + pinctrl_free_gpio(chip->base + offset); 399 + } 400 + 401 + static int __init aspeed_gpio_probe(struct platform_device *pdev) 402 + { 403 + struct aspeed_gpio *gpio; 404 + struct resource *res; 405 + int rc; 406 + 407 + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 408 + if (!gpio) 409 + return -ENOMEM; 410 + 411 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 412 + gpio->base = devm_ioremap_resource(&pdev->dev, res); 413 + if (IS_ERR(gpio->base)) 414 + return PTR_ERR(gpio->base); 415 + 416 + spin_lock_init(&gpio->lock); 417 + 418 + gpio->chip.ngpio = ARRAY_SIZE(aspeed_gpio_banks) * 32; 419 + 420 + gpio->chip.parent = &pdev->dev; 421 + gpio->chip.direction_input = aspeed_gpio_dir_in; 422 + gpio->chip.direction_output = aspeed_gpio_dir_out; 423 + gpio->chip.get_direction = aspeed_gpio_get_direction; 424 + gpio->chip.request = aspeed_gpio_request; 425 + gpio->chip.free = aspeed_gpio_free; 426 + gpio->chip.get = aspeed_gpio_get; 427 + gpio->chip.set = aspeed_gpio_set; 428 + gpio->chip.label = dev_name(&pdev->dev); 429 + gpio->chip.base = -1; 430 + 431 + rc = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); 432 + if (rc < 0) 433 + return rc; 434 + 435 + return aspeed_gpio_setup_irqs(gpio, pdev); 436 + } 437 + 438 + static const struct of_device_id aspeed_gpio_of_table[] = { 439 + { .compatible = "aspeed,ast2400-gpio" }, 440 + { .compatible = "aspeed,ast2500-gpio" }, 441 + {} 442 + }; 443 + MODULE_DEVICE_TABLE(of, aspeed_gpio_of_table); 444 + 445 + static struct platform_driver aspeed_gpio_driver = { 446 + .driver = { 447 + .name = KBUILD_MODNAME, 448 + .of_match_table = aspeed_gpio_of_table, 449 + }, 450 + }; 451 + 452 + module_platform_driver_probe(aspeed_gpio_driver, aspeed_gpio_probe); 453 + 454 + MODULE_DESCRIPTION("Aspeed GPIO Driver"); 455 + MODULE_LICENSE("GPL");
+1
drivers/gpio/gpio-ath79.c
··· 15 15 #include <linux/platform_data/gpio-ath79.h> 16 16 #include <linux/of_device.h> 17 17 #include <linux/interrupt.h> 18 + #include <linux/module.h> 18 19 #include <linux/irq.h> 19 20 20 21 #define AR71XX_GPIO_REG_OE 0x00
+192
drivers/gpio/gpio-axp209.c
··· 1 + /* 2 + * AXP20x GPIO driver 3 + * 4 + * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License as published by the 8 + * Free Software Foundation; either version 2 of the License, or (at your 9 + * option) any later version. 10 + */ 11 + 12 + #include <linux/bitops.h> 13 + #include <linux/device.h> 14 + #include <linux/gpio/driver.h> 15 + #include <linux/init.h> 16 + #include <linux/interrupt.h> 17 + #include <linux/kernel.h> 18 + #include <linux/mfd/axp20x.h> 19 + #include <linux/module.h> 20 + #include <linux/of.h> 21 + #include <linux/platform_device.h> 22 + #include <linux/regmap.h> 23 + #include <linux/slab.h> 24 + 25 + #define AXP20X_GPIO_FUNCTIONS 0x7 26 + #define AXP20X_GPIO_FUNCTION_OUT_LOW 0 27 + #define AXP20X_GPIO_FUNCTION_OUT_HIGH 1 28 + #define AXP20X_GPIO_FUNCTION_INPUT 2 29 + 30 + struct axp20x_gpio { 31 + struct gpio_chip chip; 32 + struct regmap *regmap; 33 + }; 34 + 35 + static int axp20x_gpio_get_reg(unsigned offset) 36 + { 37 + switch (offset) { 38 + case 0: 39 + return AXP20X_GPIO0_CTRL; 40 + case 1: 41 + return AXP20X_GPIO1_CTRL; 42 + case 2: 43 + return AXP20X_GPIO2_CTRL; 44 + } 45 + 46 + return -EINVAL; 47 + } 48 + 49 + static int axp20x_gpio_input(struct gpio_chip *chip, unsigned offset) 50 + { 51 + struct axp20x_gpio *gpio = gpiochip_get_data(chip); 52 + int reg; 53 + 54 + reg = axp20x_gpio_get_reg(offset); 55 + if (reg < 0) 56 + return reg; 57 + 58 + return regmap_update_bits(gpio->regmap, reg, 59 + AXP20X_GPIO_FUNCTIONS, 60 + AXP20X_GPIO_FUNCTION_INPUT); 61 + } 62 + 63 + static int axp20x_gpio_get(struct gpio_chip *chip, unsigned offset) 64 + { 65 + struct axp20x_gpio *gpio = gpiochip_get_data(chip); 66 + unsigned int val; 67 + int reg, ret; 68 + 69 + reg = axp20x_gpio_get_reg(offset); 70 + if (reg < 0) 71 + return reg; 72 + 73 + ret = regmap_read(gpio->regmap, reg, &val); 74 + if (ret) 75 + return ret; 76 + 77 + return !!(val & BIT(offset + 4)); 78 + } 79 + 80 + static int axp20x_gpio_get_direction(struct gpio_chip *chip, unsigned offset) 81 + { 82 + struct axp20x_gpio *gpio = gpiochip_get_data(chip); 83 + unsigned int val; 84 + int reg, ret; 85 + 86 + reg = axp20x_gpio_get_reg(offset); 87 + if (reg < 0) 88 + return reg; 89 + 90 + ret = regmap_read(gpio->regmap, reg, &val); 91 + if (ret) 92 + return ret; 93 + 94 + /* 95 + * This shouldn't really happen if the pin is in use already, 96 + * or if it's not in use yet, it doesn't matter since we're 97 + * going to change the value soon anyway. Default to output. 98 + */ 99 + if ((val & AXP20X_GPIO_FUNCTIONS) > 2) 100 + return 0; 101 + 102 + /* 103 + * The GPIO directions are the three lowest values. 104 + * 2 is input, 0 and 1 are output 105 + */ 106 + return val & 2; 107 + } 108 + 109 + static int axp20x_gpio_output(struct gpio_chip *chip, unsigned offset, 110 + int value) 111 + { 112 + struct axp20x_gpio *gpio = gpiochip_get_data(chip); 113 + int reg; 114 + 115 + reg = axp20x_gpio_get_reg(offset); 116 + if (reg < 0) 117 + return reg; 118 + 119 + return regmap_update_bits(gpio->regmap, reg, 120 + AXP20X_GPIO_FUNCTIONS, 121 + value ? AXP20X_GPIO_FUNCTION_OUT_HIGH 122 + : AXP20X_GPIO_FUNCTION_OUT_LOW); 123 + } 124 + 125 + static void axp20x_gpio_set(struct gpio_chip *chip, unsigned offset, 126 + int value) 127 + { 128 + axp20x_gpio_output(chip, offset, value); 129 + } 130 + 131 + static int axp20x_gpio_probe(struct platform_device *pdev) 132 + { 133 + struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); 134 + struct axp20x_gpio *gpio; 135 + int ret; 136 + 137 + if (!of_device_is_available(pdev->dev.of_node)) 138 + return -ENODEV; 139 + 140 + if (!axp20x) { 141 + dev_err(&pdev->dev, "Parent drvdata not set\n"); 142 + return -EINVAL; 143 + } 144 + 145 + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 146 + if (!gpio) 147 + return -ENOMEM; 148 + 149 + gpio->chip.base = -1; 150 + gpio->chip.can_sleep = true; 151 + gpio->chip.parent = &pdev->dev; 152 + gpio->chip.label = dev_name(&pdev->dev); 153 + gpio->chip.owner = THIS_MODULE; 154 + gpio->chip.get = axp20x_gpio_get; 155 + gpio->chip.get_direction = axp20x_gpio_get_direction; 156 + gpio->chip.set = axp20x_gpio_set; 157 + gpio->chip.direction_input = axp20x_gpio_input; 158 + gpio->chip.direction_output = axp20x_gpio_output; 159 + gpio->chip.ngpio = 3; 160 + 161 + gpio->regmap = axp20x->regmap; 162 + 163 + ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); 164 + if (ret) { 165 + dev_err(&pdev->dev, "Failed to register GPIO chip\n"); 166 + return ret; 167 + } 168 + 169 + dev_info(&pdev->dev, "AXP209 GPIO driver loaded\n"); 170 + 171 + return 0; 172 + } 173 + 174 + static const struct of_device_id axp20x_gpio_match[] = { 175 + { .compatible = "x-powers,axp209-gpio" }, 176 + { } 177 + }; 178 + MODULE_DEVICE_TABLE(of, axp20x_gpio_match); 179 + 180 + static struct platform_driver axp20x_gpio_driver = { 181 + .probe = axp20x_gpio_probe, 182 + .driver = { 183 + .name = "axp20x-gpio", 184 + .of_match_table = axp20x_gpio_match, 185 + }, 186 + }; 187 + 188 + module_platform_driver(axp20x_gpio_driver); 189 + 190 + MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>"); 191 + MODULE_DESCRIPTION("AXP20x PMIC GPIO driver"); 192 + MODULE_LICENSE("GPL");
+1 -1
drivers/gpio/gpio-bcm-kona.c
··· 308 308 return 0; 309 309 } 310 310 311 - static struct gpio_chip template_chip = { 311 + static const struct gpio_chip template_chip = { 312 312 .label = "bcm-kona-gpio", 313 313 .owner = THIS_MODULE, 314 314 .request = bcm_kona_gpio_request,
+1 -1
drivers/gpio/gpio-da9052.c
··· 184 184 return irq; 185 185 } 186 186 187 - static struct gpio_chip reference_gp = { 187 + static const struct gpio_chip reference_gp = { 188 188 .label = "da9052-gpio", 189 189 .owner = THIS_MODULE, 190 190 .get = da9052_gpio_get,
+1 -1
drivers/gpio/gpio-da9055.c
··· 121 121 DA9055_IRQ_GPI0 + offset); 122 122 } 123 123 124 - static struct gpio_chip reference_gp = { 124 + static const struct gpio_chip reference_gp = { 125 125 .label = "da9055-gpio", 126 126 .owner = THIS_MODULE, 127 127 .get = da9055_gpio_get,
+1 -2
drivers/gpio/gpio-f7188x.c
··· 214 214 static int f7188x_gpio_get_direction(struct gpio_chip *chip, unsigned offset) 215 215 { 216 216 int err; 217 - struct f7188x_gpio_bank *bank = 218 - container_of(chip, struct f7188x_gpio_bank, chip); 217 + struct f7188x_gpio_bank *bank = gpiochip_get_data(chip); 219 218 struct f7188x_sio *sio = bank->data->sio; 220 219 u8 dir; 221 220
+267
drivers/gpio/gpio-gpio-mm.c
··· 1 + /* 2 + * GPIO driver for the Diamond Systems GPIO-MM 3 + * Copyright (C) 2016 William Breathitt Gray 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License, version 2, as 7 + * published by the Free Software Foundation. 8 + * 9 + * This program is distributed in the hope that it will be useful, but 10 + * WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 + * General Public License for more details. 13 + * 14 + * This driver supports the following Diamond Systems devices: GPIO-MM and 15 + * GPIO-MM-12. 16 + */ 17 + #include <linux/bitops.h> 18 + #include <linux/device.h> 19 + #include <linux/errno.h> 20 + #include <linux/gpio/driver.h> 21 + #include <linux/io.h> 22 + #include <linux/ioport.h> 23 + #include <linux/isa.h> 24 + #include <linux/kernel.h> 25 + #include <linux/module.h> 26 + #include <linux/moduleparam.h> 27 + #include <linux/spinlock.h> 28 + 29 + #define GPIOMM_EXTENT 8 30 + #define MAX_NUM_GPIOMM max_num_isa_dev(GPIOMM_EXTENT) 31 + 32 + static unsigned int base[MAX_NUM_GPIOMM]; 33 + static unsigned int num_gpiomm; 34 + module_param_array(base, uint, &num_gpiomm, 0); 35 + MODULE_PARM_DESC(base, "Diamond Systems GPIO-MM base addresses"); 36 + 37 + /** 38 + * struct gpiomm_gpio - GPIO device private data structure 39 + * @chip: instance of the gpio_chip 40 + * @io_state: bit I/O state (whether bit is set to input or output) 41 + * @out_state: output bits state 42 + * @control: Control registers state 43 + * @lock: synchronization lock to prevent I/O race conditions 44 + * @base: base port address of the GPIO device 45 + */ 46 + struct gpiomm_gpio { 47 + struct gpio_chip chip; 48 + unsigned char io_state[6]; 49 + unsigned char out_state[6]; 50 + unsigned char control[2]; 51 + spinlock_t lock; 52 + unsigned int base; 53 + }; 54 + 55 + static int gpiomm_gpio_get_direction(struct gpio_chip *chip, 56 + unsigned int offset) 57 + { 58 + struct gpiomm_gpio *const gpiommgpio = gpiochip_get_data(chip); 59 + const unsigned int port = offset / 8; 60 + const unsigned int mask = BIT(offset % 8); 61 + 62 + return !!(gpiommgpio->io_state[port] & mask); 63 + } 64 + 65 + static int gpiomm_gpio_direction_input(struct gpio_chip *chip, 66 + unsigned int offset) 67 + { 68 + struct gpiomm_gpio *const gpiommgpio = gpiochip_get_data(chip); 69 + const unsigned int io_port = offset / 8; 70 + const unsigned int control_port = io_port / 3; 71 + const unsigned int control_addr = gpiommgpio->base + 3 + control_port*4; 72 + unsigned long flags; 73 + unsigned int control; 74 + 75 + spin_lock_irqsave(&gpiommgpio->lock, flags); 76 + 77 + /* Check if configuring Port C */ 78 + if (io_port == 2 || io_port == 5) { 79 + /* Port C can be configured by nibble */ 80 + if (offset % 8 > 3) { 81 + gpiommgpio->io_state[io_port] |= 0xF0; 82 + gpiommgpio->control[control_port] |= BIT(3); 83 + } else { 84 + gpiommgpio->io_state[io_port] |= 0x0F; 85 + gpiommgpio->control[control_port] |= BIT(0); 86 + } 87 + } else { 88 + gpiommgpio->io_state[io_port] |= 0xFF; 89 + if (io_port == 0 || io_port == 3) 90 + gpiommgpio->control[control_port] |= BIT(4); 91 + else 92 + gpiommgpio->control[control_port] |= BIT(1); 93 + } 94 + 95 + control = BIT(7) | gpiommgpio->control[control_port]; 96 + outb(control, control_addr); 97 + 98 + spin_unlock_irqrestore(&gpiommgpio->lock, flags); 99 + 100 + return 0; 101 + } 102 + 103 + static int gpiomm_gpio_direction_output(struct gpio_chip *chip, 104 + unsigned int offset, int value) 105 + { 106 + struct gpiomm_gpio *const gpiommgpio = gpiochip_get_data(chip); 107 + const unsigned int io_port = offset / 8; 108 + const unsigned int control_port = io_port / 3; 109 + const unsigned int mask = BIT(offset % 8); 110 + const unsigned int control_addr = gpiommgpio->base + 3 + control_port*4; 111 + const unsigned int out_port = (io_port > 2) ? io_port + 1 : io_port; 112 + unsigned long flags; 113 + unsigned int control; 114 + 115 + spin_lock_irqsave(&gpiommgpio->lock, flags); 116 + 117 + /* Check if configuring Port C */ 118 + if (io_port == 2 || io_port == 5) { 119 + /* Port C can be configured by nibble */ 120 + if (offset % 8 > 3) { 121 + gpiommgpio->io_state[io_port] &= 0x0F; 122 + gpiommgpio->control[control_port] &= ~BIT(3); 123 + } else { 124 + gpiommgpio->io_state[io_port] &= 0xF0; 125 + gpiommgpio->control[control_port] &= ~BIT(0); 126 + } 127 + } else { 128 + gpiommgpio->io_state[io_port] &= 0x00; 129 + if (io_port == 0 || io_port == 3) 130 + gpiommgpio->control[control_port] &= ~BIT(4); 131 + else 132 + gpiommgpio->control[control_port] &= ~BIT(1); 133 + } 134 + 135 + if (value) 136 + gpiommgpio->out_state[io_port] |= mask; 137 + else 138 + gpiommgpio->out_state[io_port] &= ~mask; 139 + 140 + control = BIT(7) | gpiommgpio->control[control_port]; 141 + outb(control, control_addr); 142 + 143 + outb(gpiommgpio->out_state[io_port], gpiommgpio->base + out_port); 144 + 145 + spin_unlock_irqrestore(&gpiommgpio->lock, flags); 146 + 147 + return 0; 148 + } 149 + 150 + static int gpiomm_gpio_get(struct gpio_chip *chip, unsigned int offset) 151 + { 152 + struct gpiomm_gpio *const gpiommgpio = gpiochip_get_data(chip); 153 + const unsigned int port = offset / 8; 154 + const unsigned int mask = BIT(offset % 8); 155 + const unsigned int in_port = (port > 2) ? port + 1 : port; 156 + unsigned long flags; 157 + unsigned int port_state; 158 + 159 + spin_lock_irqsave(&gpiommgpio->lock, flags); 160 + 161 + /* ensure that GPIO is set for input */ 162 + if (!(gpiommgpio->io_state[port] & mask)) { 163 + spin_unlock_irqrestore(&gpiommgpio->lock, flags); 164 + return -EINVAL; 165 + } 166 + 167 + port_state = inb(gpiommgpio->base + in_port); 168 + 169 + spin_unlock_irqrestore(&gpiommgpio->lock, flags); 170 + 171 + return !!(port_state & mask); 172 + } 173 + 174 + static void gpiomm_gpio_set(struct gpio_chip *chip, unsigned int offset, 175 + int value) 176 + { 177 + struct gpiomm_gpio *const gpiommgpio = gpiochip_get_data(chip); 178 + const unsigned int port = offset / 8; 179 + const unsigned int mask = BIT(offset % 8); 180 + const unsigned int out_port = (port > 2) ? port + 1 : port; 181 + unsigned long flags; 182 + 183 + spin_lock_irqsave(&gpiommgpio->lock, flags); 184 + 185 + if (value) 186 + gpiommgpio->out_state[port] |= mask; 187 + else 188 + gpiommgpio->out_state[port] &= ~mask; 189 + 190 + outb(gpiommgpio->out_state[port], gpiommgpio->base + out_port); 191 + 192 + spin_unlock_irqrestore(&gpiommgpio->lock, flags); 193 + } 194 + 195 + static int gpiomm_probe(struct device *dev, unsigned int id) 196 + { 197 + struct gpiomm_gpio *gpiommgpio; 198 + const char *const name = dev_name(dev); 199 + int err; 200 + 201 + gpiommgpio = devm_kzalloc(dev, sizeof(*gpiommgpio), GFP_KERNEL); 202 + if (!gpiommgpio) 203 + return -ENOMEM; 204 + 205 + if (!devm_request_region(dev, base[id], GPIOMM_EXTENT, name)) { 206 + dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", 207 + base[id], base[id] + GPIOMM_EXTENT); 208 + return -EBUSY; 209 + } 210 + 211 + gpiommgpio->chip.label = name; 212 + gpiommgpio->chip.parent = dev; 213 + gpiommgpio->chip.owner = THIS_MODULE; 214 + gpiommgpio->chip.base = -1; 215 + gpiommgpio->chip.ngpio = 48; 216 + gpiommgpio->chip.get_direction = gpiomm_gpio_get_direction; 217 + gpiommgpio->chip.direction_input = gpiomm_gpio_direction_input; 218 + gpiommgpio->chip.direction_output = gpiomm_gpio_direction_output; 219 + gpiommgpio->chip.get = gpiomm_gpio_get; 220 + gpiommgpio->chip.set = gpiomm_gpio_set; 221 + gpiommgpio->base = base[id]; 222 + 223 + spin_lock_init(&gpiommgpio->lock); 224 + 225 + dev_set_drvdata(dev, gpiommgpio); 226 + 227 + err = gpiochip_add_data(&gpiommgpio->chip, gpiommgpio); 228 + if (err) { 229 + dev_err(dev, "GPIO registering failed (%d)\n", err); 230 + return err; 231 + } 232 + 233 + /* initialize all GPIO as output */ 234 + outb(0x80, base[id] + 3); 235 + outb(0x00, base[id]); 236 + outb(0x00, base[id] + 1); 237 + outb(0x00, base[id] + 2); 238 + outb(0x80, base[id] + 7); 239 + outb(0x00, base[id] + 4); 240 + outb(0x00, base[id] + 5); 241 + outb(0x00, base[id] + 6); 242 + 243 + return 0; 244 + } 245 + 246 + static int gpiomm_remove(struct device *dev, unsigned int id) 247 + { 248 + struct gpiomm_gpio *const gpiommgpio = dev_get_drvdata(dev); 249 + 250 + gpiochip_remove(&gpiommgpio->chip); 251 + 252 + return 0; 253 + } 254 + 255 + static struct isa_driver gpiomm_driver = { 256 + .probe = gpiomm_probe, 257 + .driver = { 258 + .name = "gpio-mm" 259 + }, 260 + .remove = gpiomm_remove 261 + }; 262 + 263 + module_isa_driver(gpiomm_driver, num_gpiomm); 264 + 265 + MODULE_AUTHOR("William Breathitt Gray <vilhelm.gray@gmail.com>"); 266 + MODULE_DESCRIPTION("Diamond Systems GPIO-MM GPIO driver"); 267 + MODULE_LICENSE("GPL v2");
+22 -93
drivers/gpio/gpio-iop.c
··· 10 10 * your option) any later version. 11 11 */ 12 12 13 - #include <linux/device.h> 14 - #include <linux/init.h> 15 - #include <linux/types.h> 16 - #include <linux/errno.h> 17 - #include <linux/gpio.h> 18 - #include <linux/export.h> 13 + #include <linux/err.h> 14 + #include <linux/module.h> 15 + #include <linux/gpio/driver.h> 19 16 #include <linux/platform_device.h> 20 - #include <linux/bitops.h> 21 - #include <linux/io.h> 22 17 23 - #define IOP3XX_N_GPIOS 8 24 - 25 - #define GPIO_IN 0 26 - #define GPIO_OUT 1 27 - #define GPIO_LOW 0 28 - #define GPIO_HIGH 1 29 - 30 - /* Memory base offset */ 31 - static void __iomem *base; 32 - 33 - #define IOP3XX_GPIO_REG(reg) (base + (reg)) 34 - #define IOP3XX_GPOE IOP3XX_GPIO_REG(0x0000) 35 - #define IOP3XX_GPID IOP3XX_GPIO_REG(0x0004) 36 - #define IOP3XX_GPOD IOP3XX_GPIO_REG(0x0008) 37 - 38 - static void gpio_line_config(int line, int direction) 39 - { 40 - unsigned long flags; 41 - u32 val; 42 - 43 - local_irq_save(flags); 44 - val = readl(IOP3XX_GPOE); 45 - if (direction == GPIO_IN) { 46 - val |= BIT(line); 47 - } else if (direction == GPIO_OUT) { 48 - val &= ~BIT(line); 49 - } 50 - writel(val, IOP3XX_GPOE); 51 - local_irq_restore(flags); 52 - } 53 - 54 - static int gpio_line_get(int line) 55 - { 56 - return !!(readl(IOP3XX_GPID) & BIT(line)); 57 - } 58 - 59 - static void gpio_line_set(int line, int value) 60 - { 61 - unsigned long flags; 62 - u32 val; 63 - 64 - local_irq_save(flags); 65 - val = readl(IOP3XX_GPOD); 66 - if (value == GPIO_LOW) { 67 - val &= ~BIT(line); 68 - } else if (value == GPIO_HIGH) { 69 - val |= BIT(line); 70 - } 71 - writel(val, IOP3XX_GPOD); 72 - local_irq_restore(flags); 73 - } 74 - 75 - static int iop3xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) 76 - { 77 - gpio_line_config(gpio, GPIO_IN); 78 - return 0; 79 - } 80 - 81 - static int iop3xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level) 82 - { 83 - gpio_line_set(gpio, level); 84 - gpio_line_config(gpio, GPIO_OUT); 85 - return 0; 86 - } 87 - 88 - static int iop3xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio) 89 - { 90 - return gpio_line_get(gpio); 91 - } 92 - 93 - static void iop3xx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value) 94 - { 95 - gpio_line_set(gpio, value); 96 - } 97 - 98 - static struct gpio_chip iop3xx_chip = { 99 - .label = "iop3xx", 100 - .direction_input = iop3xx_gpio_direction_input, 101 - .get = iop3xx_gpio_get_value, 102 - .direction_output = iop3xx_gpio_direction_output, 103 - .set = iop3xx_gpio_set_value, 104 - .base = 0, 105 - .ngpio = IOP3XX_N_GPIOS, 106 - }; 18 + #define IOP3XX_GPOE 0x0000 19 + #define IOP3XX_GPID 0x0004 20 + #define IOP3XX_GPOD 0x0008 107 21 108 22 static int iop3xx_gpio_probe(struct platform_device *pdev) 109 23 { 110 24 struct resource *res; 25 + struct gpio_chip *gc; 26 + void __iomem *base; 27 + int err; 28 + 29 + gc = devm_kzalloc(&pdev->dev, sizeof(*gc), GFP_KERNEL); 30 + if (!gc) 31 + return -ENOMEM; 111 32 112 33 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 113 34 base = devm_ioremap_resource(&pdev->dev, res); 114 35 if (IS_ERR(base)) 115 36 return PTR_ERR(base); 116 37 117 - return devm_gpiochip_add_data(&pdev->dev, &iop3xx_chip, NULL); 38 + err = bgpio_init(gc, &pdev->dev, 1, base + IOP3XX_GPID, 39 + base + IOP3XX_GPOD, NULL, NULL, base + IOP3XX_GPOE, 0); 40 + if (err) 41 + return err; 42 + 43 + gc->base = 0; 44 + gc->owner = THIS_MODULE; 45 + 46 + return devm_gpiochip_add_data(&pdev->dev, gc, NULL); 118 47 } 119 48 120 49 static struct platform_driver iop3xx_gpio_driver = {
+1 -1
drivers/gpio/gpio-it87.c
··· 273 273 return rc; 274 274 } 275 275 276 - static struct gpio_chip it87_template_chip = { 276 + static const struct gpio_chip it87_template_chip = { 277 277 .label = KBUILD_MODNAME, 278 278 .owner = THIS_MODULE, 279 279 .request = it87_gpio_request,
+1 -5
drivers/gpio/gpio-loongson1.c
··· 8 8 * warranty of any kind, whether express or implied. 9 9 */ 10 10 11 + #include <linux/module.h> 11 12 #include <linux/gpio/driver.h> 12 13 #include <linux/platform_device.h> 13 14 ··· 56 55 return -ENOMEM; 57 56 58 57 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 59 - if (!res) { 60 - dev_err(dev, "failed to get I/O memory\n"); 61 - return -EINVAL; 62 - } 63 - 64 58 gpio_reg_base = devm_ioremap_resource(dev, res); 65 59 if (IS_ERR(gpio_reg_base)) 66 60 return PTR_ERR(gpio_reg_base);
+183
drivers/gpio/gpio-lp873x.c
··· 1 + /* 2 + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ 3 + * Keerthy <j-keerthy@ti.com> 4 + * 5 + * This program is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundation. 8 + * 9 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 10 + * kind, whether expressed or implied; without even the implied warranty 11 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 + * GNU General Public License version 2 for more details. 13 + * 14 + * Based on the TPS65218 driver 15 + */ 16 + 17 + #include <linux/gpio.h> 18 + #include <linux/module.h> 19 + #include <linux/platform_device.h> 20 + #include <linux/regmap.h> 21 + 22 + #include <linux/mfd/lp873x.h> 23 + 24 + #define BITS_PER_GPO 0x4 25 + #define LP873X_GPO_CTRL_OD 0x2 26 + 27 + struct lp873x_gpio { 28 + struct gpio_chip chip; 29 + struct lp873x *lp873; 30 + }; 31 + 32 + static int lp873x_gpio_get_direction(struct gpio_chip *chip, 33 + unsigned int offset) 34 + { 35 + /* This device is output only */ 36 + return 0; 37 + } 38 + 39 + static int lp873x_gpio_direction_input(struct gpio_chip *chip, 40 + unsigned int offset) 41 + { 42 + /* This device is output only */ 43 + return -EINVAL; 44 + } 45 + 46 + static int lp873x_gpio_direction_output(struct gpio_chip *chip, 47 + unsigned int offset, int value) 48 + { 49 + struct lp873x_gpio *gpio = gpiochip_get_data(chip); 50 + 51 + /* Set the initial value */ 52 + return regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL, 53 + BIT(offset * BITS_PER_GPO), 54 + value ? BIT(offset * BITS_PER_GPO) : 0); 55 + } 56 + 57 + static int lp873x_gpio_get(struct gpio_chip *chip, unsigned int offset) 58 + { 59 + struct lp873x_gpio *gpio = gpiochip_get_data(chip); 60 + int ret, val; 61 + 62 + ret = regmap_read(gpio->lp873->regmap, LP873X_REG_GPO_CTRL, &val); 63 + if (ret < 0) 64 + return ret; 65 + 66 + return val & BIT(offset * BITS_PER_GPO); 67 + } 68 + 69 + static void lp873x_gpio_set(struct gpio_chip *chip, unsigned int offset, 70 + int value) 71 + { 72 + struct lp873x_gpio *gpio = gpiochip_get_data(chip); 73 + 74 + regmap_update_bits(gpio->lp873->regmap, LP873X_REG_GPO_CTRL, 75 + BIT(offset * BITS_PER_GPO), 76 + value ? BIT(offset * BITS_PER_GPO) : 0); 77 + } 78 + 79 + static int lp873x_gpio_request(struct gpio_chip *gc, unsigned int offset) 80 + { 81 + struct lp873x_gpio *gpio = gpiochip_get_data(gc); 82 + int ret; 83 + 84 + switch (offset) { 85 + case 0: 86 + /* No MUX Set up Needed for GPO */ 87 + break; 88 + case 1: 89 + /* Setup the CLKIN_PIN_SEL MUX to GPO2 */ 90 + ret = regmap_update_bits(gpio->lp873->regmap, LP873X_REG_CONFIG, 91 + LP873X_CONFIG_CLKIN_PIN_SEL, 0); 92 + if (ret) 93 + return ret; 94 + 95 + break; 96 + default: 97 + return -EINVAL; 98 + } 99 + 100 + return 0; 101 + } 102 + 103 + static int lp873x_gpio_set_single_ended(struct gpio_chip *gc, 104 + unsigned int offset, 105 + enum single_ended_mode mode) 106 + { 107 + struct lp873x_gpio *gpio = gpiochip_get_data(gc); 108 + 109 + switch (mode) { 110 + case LINE_MODE_OPEN_DRAIN: 111 + return regmap_update_bits(gpio->lp873->regmap, 112 + LP873X_REG_GPO_CTRL, 113 + BIT(offset * BITS_PER_GPO + 114 + LP873X_GPO_CTRL_OD), 115 + BIT(offset * BITS_PER_GPO + 116 + LP873X_GPO_CTRL_OD)); 117 + case LINE_MODE_PUSH_PULL: 118 + return regmap_update_bits(gpio->lp873->regmap, 119 + LP873X_REG_GPO_CTRL, 120 + BIT(offset * BITS_PER_GPO + 121 + LP873X_GPO_CTRL_OD), 0); 122 + default: 123 + return -ENOTSUPP; 124 + } 125 + } 126 + 127 + static const struct gpio_chip template_chip = { 128 + .label = "lp873x-gpio", 129 + .owner = THIS_MODULE, 130 + .request = lp873x_gpio_request, 131 + .get_direction = lp873x_gpio_get_direction, 132 + .direction_input = lp873x_gpio_direction_input, 133 + .direction_output = lp873x_gpio_direction_output, 134 + .get = lp873x_gpio_get, 135 + .set = lp873x_gpio_set, 136 + .set_single_ended = lp873x_gpio_set_single_ended, 137 + .base = -1, 138 + .ngpio = 2, 139 + .can_sleep = true, 140 + }; 141 + 142 + static int lp873x_gpio_probe(struct platform_device *pdev) 143 + { 144 + struct lp873x_gpio *gpio; 145 + int ret; 146 + 147 + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 148 + if (!gpio) 149 + return -ENOMEM; 150 + 151 + platform_set_drvdata(pdev, gpio); 152 + 153 + gpio->lp873 = dev_get_drvdata(pdev->dev.parent); 154 + gpio->chip = template_chip; 155 + gpio->chip.parent = gpio->lp873->dev; 156 + 157 + ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); 158 + if (ret < 0) { 159 + dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 160 + return ret; 161 + } 162 + 163 + return 0; 164 + } 165 + 166 + static const struct platform_device_id lp873x_gpio_id_table[] = { 167 + { "lp873x-gpio", }, 168 + { /* sentinel */ } 169 + }; 170 + MODULE_DEVICE_TABLE(platform, lp873x_gpio_id_table); 171 + 172 + static struct platform_driver lp873x_gpio_driver = { 173 + .driver = { 174 + .name = "lp873x-gpio", 175 + }, 176 + .probe = lp873x_gpio_probe, 177 + .id_table = lp873x_gpio_id_table, 178 + }; 179 + module_platform_driver(lp873x_gpio_driver); 180 + 181 + MODULE_AUTHOR("Keerthy <j-keerthy@ti.com>"); 182 + MODULE_DESCRIPTION("LP873X GPIO driver"); 183 + MODULE_LICENSE("GPL v2");
+1 -1
drivers/gpio/gpio-lpc18xx.c
··· 78 78 return lpc18xx_gpio_direction(chip, offset, true); 79 79 } 80 80 81 - static struct gpio_chip lpc18xx_chip = { 81 + static const struct gpio_chip lpc18xx_chip = { 82 82 .label = "lpc18xx/43xx-gpio", 83 83 .request = gpiochip_generic_request, 84 84 .free = gpiochip_generic_free,
+14 -1
drivers/gpio/gpio-lpc32xx.c
··· 25 25 #include <linux/of_gpio.h> 26 26 #include <linux/platform_device.h> 27 27 #include <linux/module.h> 28 - #include <linux/platform_data/gpio-lpc32xx.h> 29 28 30 29 #include <mach/hardware.h> 31 30 #include <mach/platform.h> ··· 66 67 #define GPIO3_PIN5_IN_SEL(x) (((x) >> 24) & 1) 67 68 #define GPI3_PIN_IN_SEL(x, y) (((x) >> (y)) & 1) 68 69 #define GPO3_PIN_IN_SEL(x, y) (((x) >> (y)) & 1) 70 + 71 + #define LPC32XX_GPIO_P0_MAX 8 72 + #define LPC32XX_GPIO_P1_MAX 24 73 + #define LPC32XX_GPIO_P2_MAX 13 74 + #define LPC32XX_GPIO_P3_MAX 6 75 + #define LPC32XX_GPI_P3_MAX 29 76 + #define LPC32XX_GPO_P3_MAX 24 77 + 78 + #define LPC32XX_GPIO_P0_GRP 0 79 + #define LPC32XX_GPIO_P1_GRP (LPC32XX_GPIO_P0_GRP + LPC32XX_GPIO_P0_MAX) 80 + #define LPC32XX_GPIO_P2_GRP (LPC32XX_GPIO_P1_GRP + LPC32XX_GPIO_P1_MAX) 81 + #define LPC32XX_GPIO_P3_GRP (LPC32XX_GPIO_P2_GRP + LPC32XX_GPIO_P2_MAX) 82 + #define LPC32XX_GPI_P3_GRP (LPC32XX_GPIO_P3_GRP + LPC32XX_GPIO_P3_MAX) 83 + #define LPC32XX_GPO_P3_GRP (LPC32XX_GPI_P3_GRP + LPC32XX_GPI_P3_MAX) 69 84 70 85 struct gpio_regs { 71 86 void __iomem *inp_state;
+4
drivers/gpio/gpio-mmio.c
··· 573 573 574 574 #ifdef CONFIG_OF 575 575 static const struct of_device_id bgpio_of_match[] = { 576 + { .compatible = "brcm,bcm6345-gpio" }, 576 577 { .compatible = "wd,mbl-gpio" }, 577 578 { } 578 579 }; ··· 593 592 return ERR_PTR(-ENOMEM); 594 593 595 594 pdata->base = -1; 595 + 596 + if (of_device_is_big_endian(pdev->dev.of_node)) 597 + *flags |= BGPIOF_BIG_ENDIAN_BYTE_ORDER; 596 598 597 599 if (of_property_read_bool(pdev->dev.of_node, "no-output")) 598 600 *flags |= BGPIOF_NO_OUTPUT;
+214
drivers/gpio/gpio-mockup.c
··· 1 + /* 2 + * GPIO Testing Device Driver 3 + * 4 + * Copyright (C) 2014 Kamlakant Patel <kamlakant.patel@broadcom.com> 5 + * Copyright (C) 2015-2016 Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + * 12 + */ 13 + 14 + #include <linux/init.h> 15 + #include <linux/module.h> 16 + #include <linux/gpio/driver.h> 17 + #include <linux/platform_device.h> 18 + 19 + #define GPIO_NAME "gpio-mockup" 20 + #define MAX_GC 10 21 + 22 + enum direction { 23 + OUT, 24 + IN 25 + }; 26 + 27 + /* 28 + * struct gpio_pin_status - structure describing a GPIO status 29 + * @dir: Configures direction of gpio as "in" or "out", 0=in, 1=out 30 + * @value: Configures status of the gpio as 0(low) or 1(high) 31 + */ 32 + struct gpio_pin_status { 33 + enum direction dir; 34 + bool value; 35 + }; 36 + 37 + struct mockup_gpio_controller { 38 + struct gpio_chip gc; 39 + struct gpio_pin_status *stats; 40 + }; 41 + 42 + static int gpio_mockup_ranges[MAX_GC << 1]; 43 + static int gpio_mockup_params_nr; 44 + module_param_array(gpio_mockup_ranges, int, &gpio_mockup_params_nr, 0400); 45 + 46 + const char pins_name_start = 'A'; 47 + 48 + static int mockup_gpio_get(struct gpio_chip *gc, unsigned int offset) 49 + { 50 + struct mockup_gpio_controller *cntr = gpiochip_get_data(gc); 51 + 52 + return cntr->stats[offset].value; 53 + } 54 + 55 + static void mockup_gpio_set(struct gpio_chip *gc, unsigned int offset, 56 + int value) 57 + { 58 + struct mockup_gpio_controller *cntr = gpiochip_get_data(gc); 59 + 60 + cntr->stats[offset].value = !!value; 61 + } 62 + 63 + static int mockup_gpio_dirout(struct gpio_chip *gc, unsigned int offset, 64 + int value) 65 + { 66 + struct mockup_gpio_controller *cntr = gpiochip_get_data(gc); 67 + 68 + mockup_gpio_set(gc, offset, value); 69 + cntr->stats[offset].dir = OUT; 70 + return 0; 71 + } 72 + 73 + static int mockup_gpio_dirin(struct gpio_chip *gc, unsigned int offset) 74 + { 75 + struct mockup_gpio_controller *cntr = gpiochip_get_data(gc); 76 + 77 + cntr->stats[offset].dir = IN; 78 + return 0; 79 + } 80 + 81 + static int mockup_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) 82 + { 83 + struct mockup_gpio_controller *cntr = gpiochip_get_data(gc); 84 + 85 + return cntr->stats[offset].dir; 86 + } 87 + 88 + static int mockup_gpio_add(struct device *dev, 89 + struct mockup_gpio_controller *cntr, 90 + const char *name, int base, int ngpio) 91 + { 92 + int ret; 93 + 94 + cntr->gc.base = base; 95 + cntr->gc.ngpio = ngpio; 96 + cntr->gc.label = name; 97 + cntr->gc.owner = THIS_MODULE; 98 + cntr->gc.parent = dev; 99 + cntr->gc.get = mockup_gpio_get; 100 + cntr->gc.set = mockup_gpio_set; 101 + cntr->gc.direction_output = mockup_gpio_dirout; 102 + cntr->gc.direction_input = mockup_gpio_dirin; 103 + cntr->gc.get_direction = mockup_gpio_get_direction; 104 + cntr->stats = devm_kzalloc(dev, sizeof(*cntr->stats) * cntr->gc.ngpio, 105 + GFP_KERNEL); 106 + if (!cntr->stats) { 107 + ret = -ENOMEM; 108 + goto err; 109 + } 110 + ret = devm_gpiochip_add_data(dev, &cntr->gc, cntr); 111 + if (ret) 112 + goto err; 113 + 114 + dev_info(dev, "gpio<%d..%d> add successful!", base, base + ngpio); 115 + return 0; 116 + err: 117 + dev_err(dev, "gpio<%d..%d> add failed!", base, base + ngpio); 118 + return ret; 119 + } 120 + 121 + static int mockup_gpio_probe(struct platform_device *pdev) 122 + { 123 + struct device *dev = &pdev->dev; 124 + struct mockup_gpio_controller *cntr; 125 + int ret; 126 + int i; 127 + int base; 128 + int ngpio; 129 + char chip_name[sizeof(GPIO_NAME) + 3]; 130 + 131 + if (gpio_mockup_params_nr < 2) 132 + return -EINVAL; 133 + 134 + cntr = devm_kzalloc(dev, sizeof(*cntr) * (gpio_mockup_params_nr >> 1), 135 + GFP_KERNEL); 136 + if (!cntr) 137 + return -ENOMEM; 138 + 139 + platform_set_drvdata(pdev, cntr); 140 + 141 + for (i = 0; i < gpio_mockup_params_nr >> 1; i++) { 142 + base = gpio_mockup_ranges[i * 2]; 143 + if (base == -1) 144 + ngpio = gpio_mockup_ranges[i * 2 + 1]; 145 + else 146 + ngpio = gpio_mockup_ranges[i * 2 + 1] - base; 147 + 148 + if (ngpio >= 0) { 149 + sprintf(chip_name, "%s-%c", GPIO_NAME, 150 + pins_name_start + i); 151 + ret = mockup_gpio_add(dev, &cntr[i], 152 + chip_name, base, ngpio); 153 + } else { 154 + ret = -1; 155 + } 156 + if (ret) { 157 + if (base < 0) 158 + dev_err(dev, "gpio<%d..%d> add failed\n", 159 + base, ngpio); 160 + else 161 + dev_err(dev, "gpio<%d..%d> add failed\n", 162 + base, base + ngpio); 163 + 164 + return ret; 165 + } 166 + } 167 + 168 + return 0; 169 + } 170 + 171 + static struct platform_driver mockup_gpio_driver = { 172 + .driver = { 173 + .name = GPIO_NAME, 174 + }, 175 + .probe = mockup_gpio_probe, 176 + }; 177 + 178 + static struct platform_device *pdev; 179 + static int __init mock_device_init(void) 180 + { 181 + int err; 182 + 183 + pdev = platform_device_alloc(GPIO_NAME, -1); 184 + if (!pdev) 185 + return -ENOMEM; 186 + 187 + err = platform_device_add(pdev); 188 + if (err) { 189 + platform_device_put(pdev); 190 + return err; 191 + } 192 + 193 + err = platform_driver_register(&mockup_gpio_driver); 194 + if (err) { 195 + platform_device_unregister(pdev); 196 + return err; 197 + } 198 + 199 + return 0; 200 + } 201 + 202 + static void __exit mock_device_exit(void) 203 + { 204 + platform_driver_unregister(&mockup_gpio_driver); 205 + platform_device_unregister(pdev); 206 + } 207 + 208 + module_init(mock_device_init); 209 + module_exit(mock_device_exit); 210 + 211 + MODULE_AUTHOR("Kamlakant Patel <kamlakant.patel@broadcom.com>"); 212 + MODULE_AUTHOR("Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>"); 213 + MODULE_DESCRIPTION("GPIO Testing driver"); 214 + MODULE_LICENSE("GPL v2");
-6
drivers/gpio/gpio-msic.c
··· 20 20 * 21 21 */ 22 22 23 - #include <linux/module.h> 24 23 #include <linux/kernel.h> 25 24 #include <linux/slab.h> 26 25 #include <linux/interrupt.h> ··· 327 328 { 328 329 return platform_driver_register(&platform_msic_gpio_driver); 329 330 } 330 - 331 331 subsys_initcall(platform_msic_gpio_init); 332 - 333 - MODULE_AUTHOR("Mathias Nyman <mathias.nyman@linux.intel.com>"); 334 - MODULE_DESCRIPTION("Intel Medfield MSIC GPIO driver"); 335 - MODULE_LICENSE("GPL v2");
+2 -8
drivers/gpio/gpio-mxc.c
··· 2 2 * MXC GPIO support. (c) 2008 Daniel Mack <daniel@caiaq.de> 3 3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de 4 4 * 5 - * Based on code from Freescale, 5 + * Based on code from Freescale Semiconductor, 6 + * Authors: Daniel Mack, Juergen Beisert. 6 7 * Copyright (C) 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved. 7 8 * 8 9 * This program is free software; you can redistribute it and/or ··· 34 33 #include <linux/gpio.h> 35 34 #include <linux/of.h> 36 35 #include <linux/of_device.h> 37 - #include <linux/module.h> 38 36 #include <linux/bug.h> 39 37 40 38 enum mxc_gpio_hwtype { ··· 516 516 return platform_driver_register(&mxc_gpio_driver); 517 517 } 518 518 subsys_initcall(gpio_mxc_init); 519 - 520 - MODULE_AUTHOR("Freescale Semiconductor, " 521 - "Daniel Mack <danielncaiaq.de>, " 522 - "Juergen Beisert <kernel@pengutronix.de>"); 523 - MODULE_DESCRIPTION("Freescale MXC GPIO"); 524 - MODULE_LICENSE("GPL");
-1
drivers/gpio/gpio-palmas.c
··· 152 152 { .compatible = "ti,tps80036-gpio", .data = &tps80036_dev_data,}, 153 153 { }, 154 154 }; 155 - MODULE_DEVICE_TABLE(of, of_palmas_gpio_match); 156 155 157 156 static int palmas_gpio_probe(struct platform_device *pdev) 158 157 {
+177 -149
drivers/gpio/gpio-pca953x.c
··· 21 21 #include <asm/unaligned.h> 22 22 #include <linux/of_platform.h> 23 23 #include <linux/acpi.h> 24 + #include <linux/regulator/consumer.h> 24 25 25 26 #define PCA953X_INPUT 0 26 27 #define PCA953X_OUTPUT 1 ··· 95 94 96 95 #define NBANK(chip) DIV_ROUND_UP(chip->gpio_chip.ngpio, BANK_SZ) 97 96 97 + struct pca953x_reg_config { 98 + int direction; 99 + int output; 100 + int input; 101 + }; 102 + 103 + static const struct pca953x_reg_config pca953x_regs = { 104 + .direction = PCA953X_DIRECTION, 105 + .output = PCA953X_OUTPUT, 106 + .input = PCA953X_INPUT, 107 + }; 108 + 109 + static const struct pca953x_reg_config pca957x_regs = { 110 + .direction = PCA957X_CFG, 111 + .output = PCA957X_OUT, 112 + .input = PCA957X_IN, 113 + }; 114 + 98 115 struct pca953x_chip { 99 116 unsigned gpio_start; 100 117 u8 reg_output[MAX_BANK]; ··· 130 111 struct i2c_client *client; 131 112 struct gpio_chip gpio_chip; 132 113 const char *const *names; 133 - int chip_type; 134 114 unsigned long driver_data; 115 + struct regulator *regulator; 116 + 117 + const struct pca953x_reg_config *regs; 118 + 119 + int (*write_regs)(struct pca953x_chip *, int, u8 *); 120 + int (*read_regs)(struct pca953x_chip *, int, u8 *); 135 121 }; 136 122 137 123 static int pca953x_read_single(struct pca953x_chip *chip, int reg, u32 *val, ··· 176 152 return 0; 177 153 } 178 154 155 + static int pca953x_write_regs_8(struct pca953x_chip *chip, int reg, u8 *val) 156 + { 157 + return i2c_smbus_write_byte_data(chip->client, reg, *val); 158 + } 159 + 160 + static int pca953x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val) 161 + { 162 + __le16 word = cpu_to_le16(get_unaligned((u16 *)val)); 163 + 164 + return i2c_smbus_write_word_data(chip->client, 165 + reg << 1, (__force u16)word); 166 + } 167 + 168 + static int pca957x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val) 169 + { 170 + int ret; 171 + 172 + ret = i2c_smbus_write_byte_data(chip->client, reg << 1, val[0]); 173 + if (ret < 0) 174 + return ret; 175 + 176 + return i2c_smbus_write_byte_data(chip->client, (reg << 1) + 1, val[1]); 177 + } 178 + 179 + static int pca953x_write_regs_24(struct pca953x_chip *chip, int reg, u8 *val) 180 + { 181 + int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); 182 + 183 + return i2c_smbus_write_i2c_block_data(chip->client, 184 + (reg << bank_shift) | REG_ADDR_AI, 185 + NBANK(chip), val); 186 + } 187 + 179 188 static int pca953x_write_regs(struct pca953x_chip *chip, int reg, u8 *val) 180 189 { 181 190 int ret = 0; 182 191 183 - if (chip->gpio_chip.ngpio <= 8) 184 - ret = i2c_smbus_write_byte_data(chip->client, reg, *val); 185 - else if (chip->gpio_chip.ngpio >= 24) { 186 - int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); 187 - ret = i2c_smbus_write_i2c_block_data(chip->client, 188 - (reg << bank_shift) | REG_ADDR_AI, 189 - NBANK(chip), val); 190 - } else { 191 - switch (chip->chip_type) { 192 - case PCA953X_TYPE: { 193 - __le16 word = cpu_to_le16(get_unaligned((u16 *)val)); 194 - 195 - ret = i2c_smbus_write_word_data(chip->client, reg << 1, 196 - (__force u16)word); 197 - break; 198 - } 199 - case PCA957X_TYPE: 200 - ret = i2c_smbus_write_byte_data(chip->client, reg << 1, 201 - val[0]); 202 - if (ret < 0) 203 - break; 204 - ret = i2c_smbus_write_byte_data(chip->client, 205 - (reg << 1) + 1, 206 - val[1]); 207 - break; 208 - } 209 - } 210 - 192 + ret = chip->write_regs(chip, reg, val); 211 193 if (ret < 0) { 212 194 dev_err(&chip->client->dev, "failed writing register\n"); 213 195 return ret; ··· 222 192 return 0; 223 193 } 224 194 195 + static int pca953x_read_regs_8(struct pca953x_chip *chip, int reg, u8 *val) 196 + { 197 + int ret; 198 + 199 + ret = i2c_smbus_read_byte_data(chip->client, reg); 200 + *val = ret; 201 + 202 + return ret; 203 + } 204 + 205 + static int pca953x_read_regs_16(struct pca953x_chip *chip, int reg, u8 *val) 206 + { 207 + int ret; 208 + 209 + ret = i2c_smbus_read_word_data(chip->client, reg << 1); 210 + val[0] = (u16)ret & 0xFF; 211 + val[1] = (u16)ret >> 8; 212 + 213 + return ret; 214 + } 215 + 216 + static int pca953x_read_regs_24(struct pca953x_chip *chip, int reg, u8 *val) 217 + { 218 + int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); 219 + 220 + return i2c_smbus_read_i2c_block_data(chip->client, 221 + (reg << bank_shift) | REG_ADDR_AI, 222 + NBANK(chip), val); 223 + } 224 + 225 225 static int pca953x_read_regs(struct pca953x_chip *chip, int reg, u8 *val) 226 226 { 227 227 int ret; 228 228 229 - if (chip->gpio_chip.ngpio <= 8) { 230 - ret = i2c_smbus_read_byte_data(chip->client, reg); 231 - *val = ret; 232 - } else if (chip->gpio_chip.ngpio >= 24) { 233 - int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); 234 - 235 - ret = i2c_smbus_read_i2c_block_data(chip->client, 236 - (reg << bank_shift) | REG_ADDR_AI, 237 - NBANK(chip), val); 238 - } else { 239 - ret = i2c_smbus_read_word_data(chip->client, reg << 1); 240 - val[0] = (u16)ret & 0xFF; 241 - val[1] = (u16)ret >> 8; 242 - } 229 + ret = chip->read_regs(chip, reg, val); 243 230 if (ret < 0) { 244 231 dev_err(&chip->client->dev, "failed reading register\n"); 245 232 return ret; ··· 269 222 { 270 223 struct pca953x_chip *chip = gpiochip_get_data(gc); 271 224 u8 reg_val; 272 - int ret, offset = 0; 225 + int ret; 273 226 274 227 mutex_lock(&chip->i2c_lock); 275 228 reg_val = chip->reg_direction[off / BANK_SZ] | (1u << (off % BANK_SZ)); 276 229 277 - switch (chip->chip_type) { 278 - case PCA953X_TYPE: 279 - offset = PCA953X_DIRECTION; 280 - break; 281 - case PCA957X_TYPE: 282 - offset = PCA957X_CFG; 283 - break; 284 - } 285 - ret = pca953x_write_single(chip, offset, reg_val, off); 230 + ret = pca953x_write_single(chip, chip->regs->direction, reg_val, off); 286 231 if (ret) 287 232 goto exit; 288 233 ··· 289 250 { 290 251 struct pca953x_chip *chip = gpiochip_get_data(gc); 291 252 u8 reg_val; 292 - int ret, offset = 0; 253 + int ret; 293 254 294 255 mutex_lock(&chip->i2c_lock); 295 256 /* set output level */ ··· 300 261 reg_val = chip->reg_output[off / BANK_SZ] 301 262 & ~(1u << (off % BANK_SZ)); 302 263 303 - switch (chip->chip_type) { 304 - case PCA953X_TYPE: 305 - offset = PCA953X_OUTPUT; 306 - break; 307 - case PCA957X_TYPE: 308 - offset = PCA957X_OUT; 309 - break; 310 - } 311 - ret = pca953x_write_single(chip, offset, reg_val, off); 264 + ret = pca953x_write_single(chip, chip->regs->output, reg_val, off); 312 265 if (ret) 313 266 goto exit; 314 267 ··· 308 277 309 278 /* then direction */ 310 279 reg_val = chip->reg_direction[off / BANK_SZ] & ~(1u << (off % BANK_SZ)); 311 - switch (chip->chip_type) { 312 - case PCA953X_TYPE: 313 - offset = PCA953X_DIRECTION; 314 - break; 315 - case PCA957X_TYPE: 316 - offset = PCA957X_CFG; 317 - break; 318 - } 319 - ret = pca953x_write_single(chip, offset, reg_val, off); 280 + ret = pca953x_write_single(chip, chip->regs->direction, reg_val, off); 320 281 if (ret) 321 282 goto exit; 322 283 ··· 322 299 { 323 300 struct pca953x_chip *chip = gpiochip_get_data(gc); 324 301 u32 reg_val; 325 - int ret, offset = 0; 302 + int ret; 326 303 327 304 mutex_lock(&chip->i2c_lock); 328 - switch (chip->chip_type) { 329 - case PCA953X_TYPE: 330 - offset = PCA953X_INPUT; 331 - break; 332 - case PCA957X_TYPE: 333 - offset = PCA957X_IN; 334 - break; 335 - } 336 - ret = pca953x_read_single(chip, offset, &reg_val, off); 305 + ret = pca953x_read_single(chip, chip->regs->input, &reg_val, off); 337 306 mutex_unlock(&chip->i2c_lock); 338 307 if (ret < 0) { 339 308 /* NOTE: diagnostic already emitted; that's all we should ··· 342 327 { 343 328 struct pca953x_chip *chip = gpiochip_get_data(gc); 344 329 u8 reg_val; 345 - int ret, offset = 0; 330 + int ret; 346 331 347 332 mutex_lock(&chip->i2c_lock); 348 333 if (val) ··· 352 337 reg_val = chip->reg_output[off / BANK_SZ] 353 338 & ~(1u << (off % BANK_SZ)); 354 339 355 - switch (chip->chip_type) { 356 - case PCA953X_TYPE: 357 - offset = PCA953X_OUTPUT; 358 - break; 359 - case PCA957X_TYPE: 360 - offset = PCA957X_OUT; 361 - break; 362 - } 363 - ret = pca953x_write_single(chip, offset, reg_val, off); 340 + ret = pca953x_write_single(chip, chip->regs->output, reg_val, off); 364 341 if (ret) 365 342 goto exit; 366 343 ··· 362 355 } 363 356 364 357 static void pca953x_gpio_set_multiple(struct gpio_chip *gc, 365 - unsigned long *mask, unsigned long *bits) 358 + unsigned long *mask, unsigned long *bits) 366 359 { 367 360 struct pca953x_chip *chip = gpiochip_get_data(gc); 361 + unsigned int bank_mask, bank_val; 362 + int bank_shift, bank; 368 363 u8 reg_val[MAX_BANK]; 369 - int ret, offset = 0; 370 - int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); 371 - int bank; 364 + int ret; 372 365 373 - switch (chip->chip_type) { 374 - case PCA953X_TYPE: 375 - offset = PCA953X_OUTPUT; 376 - break; 377 - case PCA957X_TYPE: 378 - offset = PCA957X_OUT; 379 - break; 380 - } 366 + bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); 381 367 382 368 memcpy(reg_val, chip->reg_output, NBANK(chip)); 383 369 mutex_lock(&chip->i2c_lock); 384 - for(bank=0; bank<NBANK(chip); bank++) { 385 - unsigned bankmask = mask[bank / sizeof(*mask)] >> 386 - ((bank % sizeof(*mask)) * 8); 387 - if(bankmask) { 388 - unsigned bankval = bits[bank / sizeof(*bits)] >> 389 - ((bank % sizeof(*bits)) * 8); 390 - reg_val[bank] = (reg_val[bank] & ~bankmask) | bankval; 370 + for (bank = 0; bank < NBANK(chip); bank++) { 371 + bank_mask = mask[bank / sizeof(*mask)] >> 372 + ((bank % sizeof(*mask)) * 8); 373 + if (bank_mask) { 374 + bank_val = bits[bank / sizeof(*bits)] >> 375 + ((bank % sizeof(*bits)) * 8); 376 + reg_val[bank] = (reg_val[bank] & ~bank_mask) | bank_val; 391 377 } 392 378 } 393 - ret = i2c_smbus_write_i2c_block_data(chip->client, offset << bank_shift, NBANK(chip), reg_val); 379 + 380 + ret = i2c_smbus_write_i2c_block_data(chip->client, 381 + chip->regs->output << bank_shift, 382 + NBANK(chip), reg_val); 394 383 if (ret) 395 384 goto exit; 396 385 ··· 518 515 bool pending_seen = false; 519 516 bool trigger_seen = false; 520 517 u8 trigger[MAX_BANK]; 521 - int ret, i, offset = 0; 518 + int ret, i; 522 519 523 520 if (chip->driver_data & PCA_PCAL) { 524 521 /* Read the current interrupt status from the device */ ··· 543 540 return pending_seen; 544 541 } 545 542 546 - switch (chip->chip_type) { 547 - case PCA953X_TYPE: 548 - offset = PCA953X_INPUT; 549 - break; 550 - case PCA957X_TYPE: 551 - offset = PCA957X_IN; 552 - break; 553 - } 554 - ret = pca953x_read_regs(chip, offset, cur_stat); 543 + ret = pca953x_read_regs(chip, chip->regs->input, cur_stat); 555 544 if (ret) 556 545 return false; 557 546 ··· 603 608 int irq_base) 604 609 { 605 610 struct i2c_client *client = chip->client; 606 - int ret, i, offset = 0; 611 + int ret, i; 607 612 608 613 if (client->irq && irq_base != -1 609 614 && (chip->driver_data & PCA_INT)) { 610 615 611 - switch (chip->chip_type) { 612 - case PCA953X_TYPE: 613 - offset = PCA953X_INPUT; 614 - break; 615 - case PCA957X_TYPE: 616 - offset = PCA957X_IN; 617 - break; 618 - } 619 - ret = pca953x_read_regs(chip, offset, chip->irq_stat); 616 + ret = pca953x_read_regs(chip, 617 + chip->regs->input, chip->irq_stat); 620 618 if (ret) 621 619 return ret; 622 620 ··· 672 684 int ret; 673 685 u8 val[MAX_BANK]; 674 686 675 - ret = pca953x_read_regs(chip, PCA953X_OUTPUT, chip->reg_output); 687 + chip->regs = &pca953x_regs; 688 + 689 + ret = pca953x_read_regs(chip, chip->regs->output, chip->reg_output); 676 690 if (ret) 677 691 goto out; 678 692 679 - ret = pca953x_read_regs(chip, PCA953X_DIRECTION, 680 - chip->reg_direction); 693 + ret = pca953x_read_regs(chip, chip->regs->direction, 694 + chip->reg_direction); 681 695 if (ret) 682 696 goto out; 683 697 ··· 699 709 int ret; 700 710 u8 val[MAX_BANK]; 701 711 702 - ret = pca953x_read_regs(chip, PCA957X_OUT, chip->reg_output); 712 + chip->regs = &pca957x_regs; 713 + 714 + ret = pca953x_read_regs(chip, chip->regs->output, chip->reg_output); 703 715 if (ret) 704 716 goto out; 705 - ret = pca953x_read_regs(chip, PCA957X_CFG, chip->reg_direction); 717 + ret = pca953x_read_regs(chip, chip->regs->direction, 718 + chip->reg_direction); 706 719 if (ret) 707 720 goto out; 708 721 ··· 739 746 int irq_base = 0; 740 747 int ret; 741 748 u32 invert = 0; 749 + struct regulator *reg; 742 750 743 751 chip = devm_kzalloc(&client->dev, 744 752 sizeof(struct pca953x_chip), GFP_KERNEL); ··· 759 765 760 766 chip->client = client; 761 767 768 + reg = devm_regulator_get(&client->dev, "vcc"); 769 + if (IS_ERR(reg)) { 770 + ret = PTR_ERR(reg); 771 + if (ret != -EPROBE_DEFER) 772 + dev_err(&client->dev, "reg get err: %d\n", ret); 773 + return ret; 774 + } 775 + ret = regulator_enable(reg); 776 + if (ret) { 777 + dev_err(&client->dev, "reg en err: %d\n", ret); 778 + return ret; 779 + } 780 + chip->regulator = reg; 781 + 762 782 if (id) { 763 783 chip->driver_data = id->driver_data; 764 784 } else { ··· 784 776 chip->driver_data = (int)(uintptr_t)match->data; 785 777 } else { 786 778 id = acpi_match_device(pca953x_acpi_ids, &client->dev); 787 - if (!id) 788 - return -ENODEV; 779 + if (!id) { 780 + ret = -ENODEV; 781 + goto err_exit; 782 + } 789 783 790 784 chip->driver_data = id->driver_data; 791 785 } 792 786 } 793 - 794 - chip->chip_type = PCA_CHIP_TYPE(chip->driver_data); 795 787 796 788 mutex_init(&chip->i2c_lock); 797 789 ··· 800 792 */ 801 793 pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK); 802 794 803 - if (chip->chip_type == PCA953X_TYPE) 795 + if (chip->gpio_chip.ngpio <= 8) { 796 + chip->write_regs = pca953x_write_regs_8; 797 + chip->read_regs = pca953x_read_regs_8; 798 + } else if (chip->gpio_chip.ngpio >= 24) { 799 + chip->write_regs = pca953x_write_regs_24; 800 + chip->read_regs = pca953x_read_regs_24; 801 + } else { 802 + if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) 803 + chip->write_regs = pca953x_write_regs_16; 804 + else 805 + chip->write_regs = pca957x_write_regs_16; 806 + chip->read_regs = pca953x_read_regs_16; 807 + } 808 + 809 + if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE) 804 810 ret = device_pca953x_init(chip, invert); 805 811 else 806 812 ret = device_pca957x_init(chip, invert); 807 813 if (ret) 808 - return ret; 814 + goto err_exit; 809 815 810 816 ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip); 811 817 if (ret) 812 - return ret; 818 + goto err_exit; 813 819 814 820 ret = pca953x_irq_setup(chip, irq_base); 815 821 if (ret) 816 - return ret; 822 + goto err_exit; 817 823 818 824 if (pdata && pdata->setup) { 819 825 ret = pdata->setup(client, chip->gpio_chip.base, ··· 838 816 839 817 i2c_set_clientdata(client, chip); 840 818 return 0; 819 + 820 + err_exit: 821 + regulator_disable(chip->regulator); 822 + return ret; 841 823 } 842 824 843 825 static int pca953x_remove(struct i2c_client *client) ··· 853 827 if (pdata && pdata->teardown) { 854 828 ret = pdata->teardown(client, chip->gpio_chip.base, 855 829 chip->gpio_chip.ngpio, pdata->context); 856 - if (ret < 0) { 830 + if (ret < 0) 857 831 dev_err(&client->dev, "%s failed, %d\n", 858 832 "teardown", ret); 859 - return ret; 860 - } 833 + } else { 834 + ret = 0; 861 835 } 862 836 863 - return 0; 837 + regulator_disable(chip->regulator); 838 + 839 + return ret; 864 840 } 865 841 866 842 /* convenience to stop overlong match-table lines */
+1 -1
drivers/gpio/gpio-pisosr.c
··· 90 90 return (gpio->buffer[offset / 8] >> (offset % 8)) & 0x1; 91 91 } 92 92 93 - static struct gpio_chip template_chip = { 93 + static const struct gpio_chip template_chip = { 94 94 .label = "pisosr-gpio", 95 95 .owner = THIS_MODULE, 96 96 .get_direction = pisosr_gpio_get_direction,
+4
drivers/gpio/gpio-rcar.c
··· 348 348 /* Gen3 GPIO is identical to Gen2. */ 349 349 .data = &gpio_rcar_info_gen2, 350 350 }, { 351 + .compatible = "renesas,gpio-r8a7796", 352 + /* Gen3 GPIO is identical to Gen2. */ 353 + .data = &gpio_rcar_info_gen2, 354 + }, { 351 355 .compatible = "renesas,gpio-rcar", 352 356 .data = &gpio_rcar_info_gen1, 353 357 }, {
+1 -1
drivers/gpio/gpio-sch.c
··· 138 138 return 0; 139 139 } 140 140 141 - static struct gpio_chip sch_gpio_chip = { 141 + static const struct gpio_chip sch_gpio_chip = { 142 142 .label = "sch_gpio", 143 143 .owner = THIS_MODULE, 144 144 .direction_input = sch_gpio_direction_in,
+1 -6
drivers/gpio/gpio-spear-spics.c
··· 12 12 #include <linux/err.h> 13 13 #include <linux/gpio.h> 14 14 #include <linux/io.h> 15 - #include <linux/module.h> 15 + #include <linux/init.h> 16 16 #include <linux/of.h> 17 17 #include <linux/platform_device.h> 18 18 #include <linux/types.h> ··· 183 183 { .compatible = "st,spear-spics-gpio" }, 184 184 {} 185 185 }; 186 - MODULE_DEVICE_TABLE(of, spics_gpio_of_match); 187 186 188 187 static struct platform_driver spics_gpio_driver = { 189 188 .probe = spics_gpio_probe, ··· 197 198 return platform_driver_register(&spics_gpio_driver); 198 199 } 199 200 subsys_initcall(spics_gpio_init); 200 - 201 - MODULE_AUTHOR("Shiraz Hashim <shiraz.linux.kernel@gmail.com>"); 202 - MODULE_DESCRIPTION("STMicroelectronics SPEAr SPI Chip Select Abstraction"); 203 - MODULE_LICENSE("GPL");
+144 -60
drivers/gpio/gpio-stmpe.c
··· 13 13 #include <linux/of.h> 14 14 #include <linux/mfd/stmpe.h> 15 15 #include <linux/seq_file.h> 16 + #include <linux/bitops.h> 16 17 17 18 /* 18 19 * These registers are modified under the irq bus lock and cached to avoid 19 20 * unnecessary writes in bus_sync_unlock. 20 21 */ 21 22 enum { REG_RE, REG_FE, REG_IE }; 23 + 24 + enum { LSB, CSB, MSB }; 22 25 23 26 #define CACHE_NR_REGS 3 24 27 /* No variant has more than 24 GPIOs */ ··· 42 39 { 43 40 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); 44 41 struct stmpe *stmpe = stmpe_gpio->stmpe; 45 - u8 reg = stmpe->regs[STMPE_IDX_GPMR_LSB] - (offset / 8); 46 - u8 mask = 1 << (offset % 8); 42 + u8 reg = stmpe->regs[STMPE_IDX_GPMR_LSB + (offset / 8)]; 43 + u8 mask = BIT(offset % 8); 47 44 int ret; 48 45 49 46 ret = stmpe_reg_read(stmpe, reg); ··· 58 55 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); 59 56 struct stmpe *stmpe = stmpe_gpio->stmpe; 60 57 int which = val ? STMPE_IDX_GPSR_LSB : STMPE_IDX_GPCR_LSB; 61 - u8 reg = stmpe->regs[which] - (offset / 8); 62 - u8 mask = 1 << (offset % 8); 58 + u8 reg = stmpe->regs[which + (offset / 8)]; 59 + u8 mask = BIT(offset % 8); 63 60 64 61 /* 65 62 * Some variants have single register for gpio set/clear functionality. ··· 77 74 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); 78 75 struct stmpe *stmpe = stmpe_gpio->stmpe; 79 76 u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); 80 - u8 mask = 1 << (offset % 8); 77 + u8 mask = BIT(offset % 8); 81 78 int ret; 82 79 83 80 ret = stmpe_reg_read(stmpe, reg); ··· 92 89 { 93 90 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); 94 91 struct stmpe *stmpe = stmpe_gpio->stmpe; 95 - u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); 96 - u8 mask = 1 << (offset % 8); 92 + u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB + (offset / 8)]; 93 + u8 mask = BIT(offset % 8); 97 94 98 95 stmpe_gpio_set(chip, offset, val); 99 96 ··· 105 102 { 106 103 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); 107 104 struct stmpe *stmpe = stmpe_gpio->stmpe; 108 - u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); 109 - u8 mask = 1 << (offset % 8); 105 + u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB + (offset / 8)]; 106 + u8 mask = BIT(offset % 8); 110 107 111 108 return stmpe_set_bits(stmpe, reg, mask, 0); 112 109 } ··· 116 113 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(chip); 117 114 struct stmpe *stmpe = stmpe_gpio->stmpe; 118 115 119 - if (stmpe_gpio->norequest_mask & (1 << offset)) 116 + if (stmpe_gpio->norequest_mask & BIT(offset)) 120 117 return -EINVAL; 121 118 122 - return stmpe_set_altfunc(stmpe, 1 << offset, STMPE_BLOCK_GPIO); 119 + return stmpe_set_altfunc(stmpe, BIT(offset), STMPE_BLOCK_GPIO); 123 120 } 124 121 125 - static struct gpio_chip template_chip = { 122 + static const struct gpio_chip template_chip = { 126 123 .label = "stmpe", 127 124 .owner = THIS_MODULE, 128 125 .get_direction = stmpe_gpio_get_direction, ··· 140 137 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); 141 138 int offset = d->hwirq; 142 139 int regoffset = offset / 8; 143 - int mask = 1 << (offset % 8); 140 + int mask = BIT(offset % 8); 144 141 145 142 if (type & IRQ_TYPE_LEVEL_LOW || type & IRQ_TYPE_LEVEL_HIGH) 146 143 return -EINVAL; 147 144 148 - /* STMPE801 doesn't have RE and FE registers */ 149 - if (stmpe_gpio->stmpe->partnum == STMPE801) 145 + /* STMPE801 and STMPE 1600 don't have RE and FE registers */ 146 + if (stmpe_gpio->stmpe->partnum == STMPE801 || 147 + stmpe_gpio->stmpe->partnum == STMPE1600) 150 148 return 0; 151 149 152 150 if (type & IRQ_TYPE_EDGE_RISING) ··· 177 173 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); 178 174 struct stmpe *stmpe = stmpe_gpio->stmpe; 179 175 int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); 180 - static const u8 regmap[] = { 181 - [REG_RE] = STMPE_IDX_GPRER_LSB, 182 - [REG_FE] = STMPE_IDX_GPFER_LSB, 183 - [REG_IE] = STMPE_IDX_IEGPIOR_LSB, 176 + static const u8 regmap[CACHE_NR_REGS][CACHE_NR_BANKS] = { 177 + [REG_RE][LSB] = STMPE_IDX_GPRER_LSB, 178 + [REG_RE][CSB] = STMPE_IDX_GPRER_CSB, 179 + [REG_RE][MSB] = STMPE_IDX_GPRER_MSB, 180 + [REG_FE][LSB] = STMPE_IDX_GPFER_LSB, 181 + [REG_FE][CSB] = STMPE_IDX_GPFER_CSB, 182 + [REG_FE][MSB] = STMPE_IDX_GPFER_MSB, 183 + [REG_IE][LSB] = STMPE_IDX_IEGPIOR_LSB, 184 + [REG_IE][CSB] = STMPE_IDX_IEGPIOR_CSB, 185 + [REG_IE][MSB] = STMPE_IDX_IEGPIOR_MSB, 184 186 }; 185 187 int i, j; 186 188 187 189 for (i = 0; i < CACHE_NR_REGS; i++) { 188 - /* STMPE801 doesn't have RE and FE registers */ 189 - if ((stmpe->partnum == STMPE801) && 190 - (i != REG_IE)) 190 + /* STMPE801 and STMPE1600 don't have RE and FE registers */ 191 + if ((stmpe->partnum == STMPE801 || 192 + stmpe->partnum == STMPE1600) && 193 + (i != REG_IE)) 191 194 continue; 192 195 193 196 for (j = 0; j < num_banks; j++) { ··· 205 194 continue; 206 195 207 196 stmpe_gpio->oldregs[i][j] = new; 208 - stmpe_reg_write(stmpe, stmpe->regs[regmap[i]] - j, new); 197 + stmpe_reg_write(stmpe, stmpe->regs[regmap[i][j]], new); 209 198 } 210 199 } 211 200 ··· 218 207 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); 219 208 int offset = d->hwirq; 220 209 int regoffset = offset / 8; 221 - int mask = 1 << (offset % 8); 210 + int mask = BIT(offset % 8); 222 211 223 212 stmpe_gpio->regs[REG_IE][regoffset] &= ~mask; 224 213 } ··· 227 216 { 228 217 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 229 218 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); 219 + struct stmpe *stmpe = stmpe_gpio->stmpe; 230 220 int offset = d->hwirq; 231 221 int regoffset = offset / 8; 232 - int mask = 1 << (offset % 8); 222 + int mask = BIT(offset % 8); 233 223 234 224 stmpe_gpio->regs[REG_IE][regoffset] |= mask; 225 + 226 + /* 227 + * STMPE1600 workaround: to be able to get IRQ from pins, 228 + * a read must be done on GPMR register, or a write in 229 + * GPSR or GPCR registers 230 + */ 231 + if (stmpe->partnum == STMPE1600) 232 + stmpe_reg_read(stmpe, 233 + stmpe->regs[STMPE_IDX_GPMR_LSB + regoffset]); 235 234 } 236 235 237 236 static void stmpe_dbg_show_one(struct seq_file *s, ··· 251 230 struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); 252 231 struct stmpe *stmpe = stmpe_gpio->stmpe; 253 232 const char *label = gpiochip_is_requested(gc, offset); 254 - int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); 255 233 bool val = !!stmpe_gpio_get(gc, offset); 256 - u8 dir_reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); 257 - u8 mask = 1 << (offset % 8); 234 + u8 bank = offset / 8; 235 + u8 dir_reg = stmpe->regs[STMPE_IDX_GPDR_LSB + bank]; 236 + u8 mask = BIT(offset % 8); 258 237 int ret; 259 238 u8 dir; 260 239 ··· 268 247 gpio, label ?: "(none)", 269 248 val ? "hi" : "lo"); 270 249 } else { 271 - u8 edge_det_reg = stmpe->regs[STMPE_IDX_GPEDR_MSB] + num_banks - 1 - (offset / 8); 272 - u8 rise_reg = stmpe->regs[STMPE_IDX_GPRER_LSB] - (offset / 8); 273 - u8 fall_reg = stmpe->regs[STMPE_IDX_GPFER_LSB] - (offset / 8); 274 - u8 irqen_reg = stmpe->regs[STMPE_IDX_IEGPIOR_LSB] - (offset / 8); 275 - bool edge_det; 276 - bool rise; 277 - bool fall; 250 + u8 edge_det_reg; 251 + u8 rise_reg; 252 + u8 fall_reg; 253 + u8 irqen_reg; 254 + 255 + char *edge_det_values[] = {"edge-inactive", 256 + "edge-asserted", 257 + "not-supported"}; 258 + char *rise_values[] = {"no-rising-edge-detection", 259 + "rising-edge-detection", 260 + "not-supported"}; 261 + char *fall_values[] = {"no-falling-edge-detection", 262 + "falling-edge-detection", 263 + "not-supported"}; 264 + #define NOT_SUPPORTED_IDX 2 265 + u8 edge_det = NOT_SUPPORTED_IDX; 266 + u8 rise = NOT_SUPPORTED_IDX; 267 + u8 fall = NOT_SUPPORTED_IDX; 278 268 bool irqen; 279 269 280 - ret = stmpe_reg_read(stmpe, edge_det_reg); 281 - if (ret < 0) 270 + switch (stmpe->partnum) { 271 + case STMPE610: 272 + case STMPE811: 273 + case STMPE1601: 274 + case STMPE2401: 275 + case STMPE2403: 276 + edge_det_reg = stmpe->regs[STMPE_IDX_GPEDR_LSB + bank]; 277 + ret = stmpe_reg_read(stmpe, edge_det_reg); 278 + if (ret < 0) 279 + return; 280 + edge_det = !!(ret & mask); 281 + 282 + case STMPE1801: 283 + rise_reg = stmpe->regs[STMPE_IDX_GPRER_LSB + bank]; 284 + fall_reg = stmpe->regs[STMPE_IDX_GPFER_LSB + bank]; 285 + 286 + ret = stmpe_reg_read(stmpe, rise_reg); 287 + if (ret < 0) 288 + return; 289 + rise = !!(ret & mask); 290 + ret = stmpe_reg_read(stmpe, fall_reg); 291 + if (ret < 0) 292 + return; 293 + fall = !!(ret & mask); 294 + 295 + case STMPE801: 296 + case STMPE1600: 297 + irqen_reg = stmpe->regs[STMPE_IDX_IEGPIOR_LSB + bank]; 298 + break; 299 + 300 + default: 282 301 return; 283 - edge_det = !!(ret & mask); 284 - ret = stmpe_reg_read(stmpe, rise_reg); 285 - if (ret < 0) 286 - return; 287 - rise = !!(ret & mask); 288 - ret = stmpe_reg_read(stmpe, fall_reg); 289 - if (ret < 0) 290 - return; 291 - fall = !!(ret & mask); 302 + } 303 + 292 304 ret = stmpe_reg_read(stmpe, irqen_reg); 293 305 if (ret < 0) 294 306 return; 295 307 irqen = !!(ret & mask); 296 308 297 - seq_printf(s, " gpio-%-3d (%-20.20s) in %s %s %s%s%s", 309 + seq_printf(s, " gpio-%-3d (%-20.20s) in %s %13s %13s %25s %25s", 298 310 gpio, label ?: "(none)", 299 311 val ? "hi" : "lo", 300 - edge_det ? "edge-asserted" : "edge-inactive", 301 - irqen ? "IRQ-enabled" : "", 302 - rise ? " rising-edge-detection" : "", 303 - fall ? " falling-edge-detection" : ""); 312 + edge_det_values[edge_det], 313 + irqen ? "IRQ-enabled" : "IRQ-disabled", 314 + rise_values[rise], 315 + fall_values[fall]); 304 316 } 305 317 } 306 318 ··· 361 307 { 362 308 struct stmpe_gpio *stmpe_gpio = dev; 363 309 struct stmpe *stmpe = stmpe_gpio->stmpe; 364 - u8 statmsbreg = stmpe->regs[STMPE_IDX_ISGPIOR_MSB]; 310 + u8 statmsbreg; 365 311 int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); 366 312 u8 status[num_banks]; 367 313 int ret; 368 314 int i; 315 + 316 + /* 317 + * the stmpe_block_read() call below, imposes to set statmsbreg 318 + * with the register located at the lowest address. As STMPE1600 319 + * variant is the only one which respect registers address's order 320 + * (LSB regs located at lowest address than MSB ones) whereas all 321 + * the others have a registers layout with MSB located before the 322 + * LSB regs. 323 + */ 324 + if (stmpe->partnum == STMPE1600) 325 + statmsbreg = stmpe->regs[STMPE_IDX_ISGPIOR_LSB]; 326 + else 327 + statmsbreg = stmpe->regs[STMPE_IDX_ISGPIOR_MSB]; 369 328 370 329 ret = stmpe_block_read(stmpe, statmsbreg, num_banks, status); 371 330 if (ret < 0) 372 331 return IRQ_NONE; 373 332 374 333 for (i = 0; i < num_banks; i++) { 375 - int bank = num_banks - i - 1; 334 + int bank = (stmpe_gpio->stmpe->partnum == STMPE1600) ? i : 335 + num_banks - i - 1; 376 336 unsigned int enabled = stmpe_gpio->regs[REG_IE][bank]; 377 337 unsigned int stat = status[i]; 378 338 ··· 401 333 line); 402 334 403 335 handle_nested_irq(child_irq); 404 - stat &= ~(1 << bit); 336 + stat &= ~BIT(bit); 405 337 } 406 338 407 - stmpe_reg_write(stmpe, statmsbreg + i, status[i]); 408 - 409 - /* Edge detect register is not present on 801 */ 410 - if (stmpe->partnum != STMPE801) 411 - stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_GPEDR_MSB] 412 - + i, status[i]); 339 + /* 340 + * interrupt status register write has no effect on 341 + * 801/1801/1600, bits are cleared when read. 342 + * Edge detect register is not present on 801/1600/1801 343 + */ 344 + if (stmpe->partnum != STMPE801 || stmpe->partnum != STMPE1600 || 345 + stmpe->partnum != STMPE1801) { 346 + stmpe_reg_write(stmpe, statmsbreg + i, status[i]); 347 + stmpe_reg_write(stmpe, 348 + stmpe->regs[STMPE_IDX_GPEDR_LSB + i], 349 + status[i]); 350 + } 413 351 } 414 352 415 353 return IRQ_HANDLED; ··· 450 376 451 377 of_property_read_u32(np, "st,norequest-mask", 452 378 &stmpe_gpio->norequest_mask); 379 + if (stmpe_gpio->norequest_mask) 380 + stmpe_gpio->chip.irq_need_valid_mask = true; 453 381 454 382 if (irq < 0) 455 383 dev_info(&pdev->dev, ··· 475 399 if (ret) { 476 400 dev_err(&pdev->dev, "unable to get irq: %d\n", ret); 477 401 goto out_disable; 402 + } 403 + if (stmpe_gpio->norequest_mask) { 404 + int i; 405 + 406 + /* Forbid unused lines to be mapped as IRQs */ 407 + for (i = 0; i < sizeof(u32); i++) 408 + if (stmpe_gpio->norequest_mask & BIT(i)) 409 + clear_bit(i, stmpe_gpio->chip.irq_valid_mask); 478 410 } 479 411 ret = gpiochip_irqchip_add(&stmpe_gpio->chip, 480 412 &stmpe_gpio_irq_chip,
-2
drivers/gpio/gpio-sx150x.c
··· 236 236 {"sx1502q", 3}, 237 237 {} 238 238 }; 239 - MODULE_DEVICE_TABLE(i2c, sx150x_id); 240 239 241 240 static const struct of_device_id sx150x_of_match[] = { 242 241 { .compatible = "semtech,sx1508q" }, ··· 244 245 { .compatible = "semtech,sx1502q" }, 245 246 {}, 246 247 }; 247 - MODULE_DEVICE_TABLE(of, sx150x_of_match); 248 248 249 249 static s32 sx150x_i2c_write(struct i2c_client *client, u8 reg, u8 val) 250 250 {
+32 -15
drivers/gpio/gpio-tc3589x.c
··· 34 34 u8 oldregs[CACHE_NR_REGS][CACHE_NR_BANKS]; 35 35 }; 36 36 37 - static int tc3589x_gpio_get(struct gpio_chip *chip, unsigned offset) 37 + static int tc3589x_gpio_get(struct gpio_chip *chip, unsigned int offset) 38 38 { 39 39 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); 40 40 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; ··· 49 49 return !!(ret & mask); 50 50 } 51 51 52 - static void tc3589x_gpio_set(struct gpio_chip *chip, unsigned offset, int val) 52 + static void tc3589x_gpio_set(struct gpio_chip *chip, unsigned int offset, int val) 53 53 { 54 54 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); 55 55 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; 56 56 u8 reg = TC3589x_GPIODATA0 + (offset / 8) * 2; 57 - unsigned pos = offset % 8; 57 + unsigned int pos = offset % 8; 58 58 u8 data[] = {val ? BIT(pos) : 0, BIT(pos)}; 59 59 60 60 tc3589x_block_write(tc3589x, reg, ARRAY_SIZE(data), data); 61 61 } 62 62 63 63 static int tc3589x_gpio_direction_output(struct gpio_chip *chip, 64 - unsigned offset, int val) 64 + unsigned int offset, int val) 65 65 { 66 66 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); 67 67 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; 68 68 u8 reg = TC3589x_GPIODIR0 + offset / 8; 69 - unsigned pos = offset % 8; 69 + unsigned int pos = offset % 8; 70 70 71 71 tc3589x_gpio_set(chip, offset, val); 72 72 ··· 74 74 } 75 75 76 76 static int tc3589x_gpio_direction_input(struct gpio_chip *chip, 77 - unsigned offset) 77 + unsigned int offset) 78 78 { 79 79 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); 80 80 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; 81 81 u8 reg = TC3589x_GPIODIR0 + offset / 8; 82 - unsigned pos = offset % 8; 82 + unsigned int pos = offset % 8; 83 83 84 84 return tc3589x_set_bits(tc3589x, reg, BIT(pos), 0); 85 85 } 86 86 87 - static int tc3589x_gpio_single_ended(struct gpio_chip *chip, 88 - unsigned offset, 89 - enum single_ended_mode mode) 87 + static int tc3589x_gpio_get_direction(struct gpio_chip *chip, 88 + unsigned int offset) 89 + { 90 + struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); 91 + struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; 92 + u8 reg = TC3589x_GPIODIR0 + offset / 8; 93 + unsigned int pos = offset % 8; 94 + int ret; 95 + 96 + ret = tc3589x_reg_read(tc3589x, reg); 97 + if (ret < 0) 98 + return ret; 99 + 100 + return !!(ret & BIT(pos)); 101 + } 102 + 103 + static int tc3589x_gpio_set_single_ended(struct gpio_chip *chip, 104 + unsigned int offset, 105 + enum single_ended_mode mode) 90 106 { 91 107 struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip); 92 108 struct tc3589x *tc3589x = tc3589x_gpio->tc3589x; ··· 113 97 */ 114 98 u8 odmreg = TC3589x_GPIOODM0 + (offset / 8) * 2; 115 99 u8 odereg = TC3589x_GPIOODE0 + (offset / 8) * 2; 116 - unsigned pos = offset % 8; 100 + unsigned int pos = offset % 8; 117 101 int ret; 118 102 119 103 switch(mode) { ··· 140 124 return -ENOTSUPP; 141 125 } 142 126 143 - static struct gpio_chip template_chip = { 127 + static const struct gpio_chip template_chip = { 144 128 .label = "tc3589x", 145 129 .owner = THIS_MODULE, 146 - .direction_input = tc3589x_gpio_direction_input, 147 130 .get = tc3589x_gpio_get, 148 - .direction_output = tc3589x_gpio_direction_output, 149 131 .set = tc3589x_gpio_set, 150 - .set_single_ended = tc3589x_gpio_single_ended, 132 + .direction_output = tc3589x_gpio_direction_output, 133 + .direction_input = tc3589x_gpio_direction_input, 134 + .get_direction = tc3589x_gpio_get_direction, 135 + .set_single_ended = tc3589x_gpio_set_single_ended, 151 136 .can_sleep = true, 152 137 }; 153 138
+1 -1
drivers/gpio/gpio-tpic2810.c
··· 87 87 tpic2810_set_mask_bits(chip, *mask, *bits); 88 88 } 89 89 90 - static struct gpio_chip template_chip = { 90 + static const struct gpio_chip template_chip = { 91 91 .label = "tpic2810", 92 92 .owner = THIS_MODULE, 93 93 .get_direction = tpic2810_get_direction,
+1 -1
drivers/gpio/gpio-tps65086.c
··· 72 72 BIT(4 + offset), value ? BIT(4 + offset) : 0); 73 73 } 74 74 75 - static struct gpio_chip template_chip = { 75 + static const struct gpio_chip template_chip = { 76 76 .label = "tps65086-gpio", 77 77 .owner = THIS_MODULE, 78 78 .get_direction = tps65086_gpio_get_direction,
+3 -12
drivers/gpio/gpio-tps65218.c
··· 172 172 return -ENOTSUPP; 173 173 } 174 174 175 - static struct gpio_chip template_chip = { 175 + static const struct gpio_chip template_chip = { 176 176 .label = "gpio-tps65218", 177 177 .owner = THIS_MODULE, 178 178 .request = tps65218_gpio_request, ··· 204 204 tps65218_gpio->gpio_chip.of_node = pdev->dev.of_node; 205 205 #endif 206 206 207 - ret = gpiochip_add_data(&tps65218_gpio->gpio_chip, tps65218_gpio); 207 + ret = devm_gpiochip_add_data(&pdev->dev, &tps65218_gpio->gpio_chip, 208 + tps65218_gpio); 208 209 if (ret < 0) { 209 210 dev_err(&pdev->dev, "Failed to register gpiochip, %d\n", ret); 210 211 return ret; ··· 214 213 platform_set_drvdata(pdev, tps65218_gpio); 215 214 216 215 return ret; 217 - } 218 - 219 - static int tps65218_gpio_remove(struct platform_device *pdev) 220 - { 221 - struct tps65218_gpio *tps65218_gpio = platform_get_drvdata(pdev); 222 - 223 - gpiochip_remove(&tps65218_gpio->gpio_chip); 224 - 225 - return 0; 226 216 } 227 217 228 218 static const struct of_device_id tps65218_dt_match[] = { ··· 234 242 .of_match_table = of_match_ptr(tps65218_dt_match) 235 243 }, 236 244 .probe = tps65218_gpio_probe, 237 - .remove = tps65218_gpio_remove, 238 245 .id_table = tps65218_gpio_id_table, 239 246 }; 240 247
+1 -1
drivers/gpio/gpio-tps65912.c
··· 90 90 GPIO_SET_MASK, value ? GPIO_SET_MASK : 0); 91 91 } 92 92 93 - static struct gpio_chip template_chip = { 93 + static const struct gpio_chip template_chip = { 94 94 .label = "tps65912-gpio", 95 95 .owner = THIS_MODULE, 96 96 .get_direction = tps65912_gpio_get_direction,
+1
drivers/gpio/gpio-ts4800.c
··· 9 9 */ 10 10 11 11 #include <linux/gpio/driver.h> 12 + #include <linux/module.h> 12 13 #include <linux/of_address.h> 13 14 #include <linux/of_device.h> 14 15 #include <linux/platform_device.h>
+190
drivers/gpio/gpio-ts4900.c
··· 1 + /* 2 + * Digital I/O driver for Technologic Systems I2C FPGA Core 3 + * 4 + * Copyright (C) 2015 Technologic Systems 5 + * Copyright (C) 2016 Savoir-Faire Linux 6 + * 7 + * This program is free software; you can redistribute it and/or 8 + * modify it under the terms of the GNU General Public License version 2 as 9 + * published by the Free Software Foundation. 10 + * 11 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 12 + * kind, whether expressed or implied; without even the implied warranty 13 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License version 2 for more details. 15 + */ 16 + 17 + #include <linux/gpio/driver.h> 18 + #include <linux/i2c.h> 19 + #include <linux/of_device.h> 20 + #include <linux/module.h> 21 + #include <linux/regmap.h> 22 + 23 + #define DEFAULT_PIN_NUMBER 32 24 + /* 25 + * Register bits used by the GPIO device 26 + * Some boards, such as TS-7970 do not have a separate input bit 27 + */ 28 + #define TS4900_GPIO_OE 0x01 29 + #define TS4900_GPIO_OUT 0x02 30 + #define TS4900_GPIO_IN 0x04 31 + #define TS7970_GPIO_IN 0x02 32 + 33 + struct ts4900_gpio_priv { 34 + struct regmap *regmap; 35 + struct gpio_chip gpio_chip; 36 + unsigned int input_bit; 37 + }; 38 + 39 + static int ts4900_gpio_get_direction(struct gpio_chip *chip, 40 + unsigned int offset) 41 + { 42 + struct ts4900_gpio_priv *priv = gpiochip_get_data(chip); 43 + unsigned int reg; 44 + 45 + regmap_read(priv->regmap, offset, &reg); 46 + 47 + return !(reg & TS4900_GPIO_OE); 48 + } 49 + 50 + static int ts4900_gpio_direction_input(struct gpio_chip *chip, 51 + unsigned int offset) 52 + { 53 + struct ts4900_gpio_priv *priv = gpiochip_get_data(chip); 54 + 55 + /* 56 + * This will clear the output enable bit, the other bits are 57 + * dontcare when this is cleared 58 + */ 59 + return regmap_write(priv->regmap, offset, 0); 60 + } 61 + 62 + static int ts4900_gpio_direction_output(struct gpio_chip *chip, 63 + unsigned int offset, int value) 64 + { 65 + struct ts4900_gpio_priv *priv = gpiochip_get_data(chip); 66 + int ret; 67 + 68 + if (value) 69 + ret = regmap_write(priv->regmap, offset, TS4900_GPIO_OE | 70 + TS4900_GPIO_OUT); 71 + else 72 + ret = regmap_write(priv->regmap, offset, TS4900_GPIO_OE); 73 + 74 + return ret; 75 + } 76 + 77 + static int ts4900_gpio_get(struct gpio_chip *chip, unsigned int offset) 78 + { 79 + struct ts4900_gpio_priv *priv = gpiochip_get_data(chip); 80 + unsigned int reg; 81 + 82 + regmap_read(priv->regmap, offset, &reg); 83 + 84 + return !!(reg & priv->input_bit); 85 + } 86 + 87 + static void ts4900_gpio_set(struct gpio_chip *chip, unsigned int offset, 88 + int value) 89 + { 90 + struct ts4900_gpio_priv *priv = gpiochip_get_data(chip); 91 + 92 + if (value) 93 + regmap_update_bits(priv->regmap, offset, TS4900_GPIO_OUT, 94 + TS4900_GPIO_OUT); 95 + else 96 + regmap_update_bits(priv->regmap, offset, TS4900_GPIO_OUT, 0); 97 + } 98 + 99 + static const struct regmap_config ts4900_regmap_config = { 100 + .reg_bits = 16, 101 + .val_bits = 8, 102 + }; 103 + 104 + static const struct gpio_chip template_chip = { 105 + .label = "ts4900-gpio", 106 + .owner = THIS_MODULE, 107 + .get_direction = ts4900_gpio_get_direction, 108 + .direction_input = ts4900_gpio_direction_input, 109 + .direction_output = ts4900_gpio_direction_output, 110 + .get = ts4900_gpio_get, 111 + .set = ts4900_gpio_set, 112 + .base = -1, 113 + .can_sleep = true, 114 + }; 115 + 116 + static const struct of_device_id ts4900_gpio_of_match_table[] = { 117 + { 118 + .compatible = "technologic,ts4900-gpio", 119 + .data = (void *)TS4900_GPIO_IN, 120 + }, { 121 + .compatible = "technologic,ts7970-gpio", 122 + .data = (void *)TS7970_GPIO_IN, 123 + }, 124 + { /* sentinel */ }, 125 + }; 126 + MODULE_DEVICE_TABLE(of, ts4900_gpio_of_match_table); 127 + 128 + static int ts4900_gpio_probe(struct i2c_client *client, 129 + const struct i2c_device_id *id) 130 + { 131 + const struct of_device_id *match; 132 + struct ts4900_gpio_priv *priv; 133 + u32 ngpio; 134 + int ret; 135 + 136 + match = of_match_device(ts4900_gpio_of_match_table, &client->dev); 137 + if (!match) 138 + return -EINVAL; 139 + 140 + if (of_property_read_u32(client->dev.of_node, "ngpios", &ngpio)) 141 + ngpio = DEFAULT_PIN_NUMBER; 142 + 143 + priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); 144 + if (!priv) 145 + return -ENOMEM; 146 + 147 + priv->gpio_chip = template_chip; 148 + priv->gpio_chip.label = "ts4900-gpio"; 149 + priv->gpio_chip.ngpio = ngpio; 150 + priv->gpio_chip.parent = &client->dev; 151 + priv->input_bit = (uintptr_t)match->data; 152 + 153 + priv->regmap = devm_regmap_init_i2c(client, &ts4900_regmap_config); 154 + if (IS_ERR(priv->regmap)) { 155 + ret = PTR_ERR(priv->regmap); 156 + dev_err(&client->dev, "Failed to allocate register map: %d\n", 157 + ret); 158 + return ret; 159 + } 160 + 161 + ret = devm_gpiochip_add_data(&client->dev, &priv->gpio_chip, priv); 162 + if (ret < 0) { 163 + dev_err(&client->dev, "Unable to register gpiochip\n"); 164 + return ret; 165 + } 166 + 167 + i2c_set_clientdata(client, priv); 168 + 169 + return 0; 170 + } 171 + 172 + static const struct i2c_device_id ts4900_gpio_id_table[] = { 173 + { "ts4900-gpio", }, 174 + { /* sentinel */ } 175 + }; 176 + MODULE_DEVICE_TABLE(i2c, ts4900_gpio_id_table); 177 + 178 + static struct i2c_driver ts4900_gpio_driver = { 179 + .driver = { 180 + .name = "ts4900-gpio", 181 + .of_match_table = ts4900_gpio_of_match_table, 182 + }, 183 + .probe = ts4900_gpio_probe, 184 + .id_table = ts4900_gpio_id_table, 185 + }; 186 + module_i2c_driver(ts4900_gpio_driver); 187 + 188 + MODULE_AUTHOR("Technologic Systems"); 189 + MODULE_DESCRIPTION("GPIO interface for Technologic Systems I2C-FPGA core"); 190 + MODULE_LICENSE("GPL");
+1 -1
drivers/gpio/gpio-twl4030.c
··· 381 381 : -EINVAL; 382 382 } 383 383 384 - static struct gpio_chip template_chip = { 384 + static const struct gpio_chip template_chip = { 385 385 .label = "twl4030", 386 386 .owner = THIS_MODULE, 387 387 .request = twl_request,
+1 -6
drivers/gpio/gpio-vf610.c
··· 1 1 /* 2 - * vf610 GPIO support through PORT and GPIO module 2 + * Freescale vf610 GPIO support through PORT and GPIO 3 3 * 4 4 * Copyright (c) 2014 Toradex AG. 5 5 * ··· 23 23 #include <linux/io.h> 24 24 #include <linux/ioport.h> 25 25 #include <linux/irq.h> 26 - #include <linux/module.h> 27 26 #include <linux/platform_device.h> 28 27 #include <linux/of.h> 29 28 #include <linux/of_device.h> ··· 288 289 return platform_driver_register(&vf610_gpio_driver); 289 290 } 290 291 device_initcall(gpio_vf610_init); 291 - 292 - MODULE_AUTHOR("Stefan Agner <stefan@agner.ch>"); 293 - MODULE_DESCRIPTION("Freescale VF610 GPIO"); 294 - MODULE_LICENSE("GPL v2");
+470
drivers/gpio/gpio-wcove.c
··· 1 + /* 2 + * Intel Whiskey Cove PMIC GPIO Driver 3 + * 4 + * This driver is written based on gpio-crystalcove.c 5 + * 6 + * Copyright (C) 2016 Intel Corporation. All rights reserved. 7 + * 8 + * This program is free software; you can redistribute it and/or 9 + * modify it under the terms of the GNU General Public License version 10 + * 2 as published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + */ 17 + 18 + #include <linux/bitops.h> 19 + #include <linux/module.h> 20 + #include <linux/interrupt.h> 21 + #include <linux/gpio/driver.h> 22 + #include <linux/mfd/intel_soc_pmic.h> 23 + #include <linux/platform_device.h> 24 + #include <linux/regmap.h> 25 + #include <linux/seq_file.h> 26 + 27 + /* 28 + * Whiskey Cove PMIC has 13 physical GPIO pins divided into 3 banks: 29 + * Bank 0: Pin 0 - 6 30 + * Bank 1: Pin 7 - 10 31 + * Bank 2: Pin 11 -12 32 + * Each pin has one output control register and one input control register. 33 + */ 34 + #define BANK0_NR_PINS 7 35 + #define BANK1_NR_PINS 4 36 + #define BANK2_NR_PINS 2 37 + #define WCOVE_GPIO_NUM (BANK0_NR_PINS + BANK1_NR_PINS + BANK2_NR_PINS) 38 + #define WCOVE_VGPIO_NUM 94 39 + /* GPIO output control registers (one per pin): 0x4e44 - 0x4e50 */ 40 + #define GPIO_OUT_CTRL_BASE 0x4e44 41 + /* GPIO input control registers (one per pin): 0x4e51 - 0x4e5d */ 42 + #define GPIO_IN_CTRL_BASE 0x4e51 43 + 44 + /* 45 + * GPIO interrupts are organized in two groups: 46 + * Group 0: Bank 0 pins (Pin 0 - 6) 47 + * Group 1: Bank 1 and Bank 2 pins (Pin 7 - 12) 48 + * Each group has two registers (one bit per pin): status and mask. 49 + */ 50 + #define GROUP0_NR_IRQS 7 51 + #define GROUP1_NR_IRQS 6 52 + #define IRQ_MASK_BASE 0x4e19 53 + #define IRQ_STATUS_BASE 0x4e0b 54 + #define UPDATE_IRQ_TYPE BIT(0) 55 + #define UPDATE_IRQ_MASK BIT(1) 56 + 57 + #define CTLI_INTCNT_DIS (0 << 1) 58 + #define CTLI_INTCNT_NE (1 << 1) 59 + #define CTLI_INTCNT_PE (2 << 1) 60 + #define CTLI_INTCNT_BE (3 << 1) 61 + 62 + #define CTLO_DIR_IN (0 << 5) 63 + #define CTLO_DIR_OUT (1 << 5) 64 + 65 + #define CTLO_DRV_MASK (1 << 4) 66 + #define CTLO_DRV_OD (0 << 4) 67 + #define CTLO_DRV_CMOS (1 << 4) 68 + 69 + #define CTLO_DRV_REN (1 << 3) 70 + 71 + #define CTLO_RVAL_2KDOWN (0 << 1) 72 + #define CTLO_RVAL_2KUP (1 << 1) 73 + #define CTLO_RVAL_50KDOWN (2 << 1) 74 + #define CTLO_RVAL_50KUP (3 << 1) 75 + 76 + #define CTLO_INPUT_SET (CTLO_DRV_CMOS | CTLO_DRV_REN | CTLO_RVAL_2KUP) 77 + #define CTLO_OUTPUT_SET (CTLO_DIR_OUT | CTLO_INPUT_SET) 78 + 79 + enum ctrl_register { 80 + CTRL_IN, 81 + CTRL_OUT, 82 + }; 83 + 84 + /* 85 + * struct wcove_gpio - Whiskey Cove GPIO controller 86 + * @buslock: for bus lock/sync and unlock. 87 + * @chip: the abstract gpio_chip structure. 88 + * @dev: the gpio device 89 + * @regmap: the regmap from the parent device. 90 + * @regmap_irq_chip: the regmap of the gpio irq chip. 91 + * @update: pending IRQ setting update, to be written to the chip upon unlock. 92 + * @intcnt: the Interrupt Detect value to be written. 93 + * @set_irq_mask: true if the IRQ mask needs to be set, false to clear. 94 + */ 95 + struct wcove_gpio { 96 + struct mutex buslock; 97 + struct gpio_chip chip; 98 + struct device *dev; 99 + struct regmap *regmap; 100 + struct regmap_irq_chip_data *regmap_irq_chip; 101 + int update; 102 + int intcnt; 103 + bool set_irq_mask; 104 + }; 105 + 106 + static inline unsigned int to_reg(int gpio, enum ctrl_register reg_type) 107 + { 108 + unsigned int reg; 109 + int bank; 110 + 111 + if (gpio < BANK0_NR_PINS) 112 + bank = 0; 113 + else if (gpio < BANK0_NR_PINS + BANK1_NR_PINS) 114 + bank = 1; 115 + else 116 + bank = 2; 117 + 118 + if (reg_type == CTRL_IN) 119 + reg = GPIO_IN_CTRL_BASE + bank; 120 + else 121 + reg = GPIO_OUT_CTRL_BASE + bank; 122 + 123 + return reg; 124 + } 125 + 126 + static void wcove_update_irq_mask(struct wcove_gpio *wg, int gpio) 127 + { 128 + unsigned int reg, mask; 129 + 130 + if (gpio < GROUP0_NR_IRQS) { 131 + reg = IRQ_MASK_BASE; 132 + mask = BIT(gpio % GROUP0_NR_IRQS); 133 + } else { 134 + reg = IRQ_MASK_BASE + 1; 135 + mask = BIT((gpio - GROUP0_NR_IRQS) % GROUP1_NR_IRQS); 136 + } 137 + 138 + if (wg->set_irq_mask) 139 + regmap_update_bits(wg->regmap, reg, mask, mask); 140 + else 141 + regmap_update_bits(wg->regmap, reg, mask, 0); 142 + } 143 + 144 + static void wcove_update_irq_ctrl(struct wcove_gpio *wg, int gpio) 145 + { 146 + unsigned int reg = to_reg(gpio, CTRL_IN); 147 + 148 + regmap_update_bits(wg->regmap, reg, CTLI_INTCNT_BE, wg->intcnt); 149 + } 150 + 151 + static int wcove_gpio_dir_in(struct gpio_chip *chip, unsigned int gpio) 152 + { 153 + struct wcove_gpio *wg = gpiochip_get_data(chip); 154 + 155 + return regmap_write(wg->regmap, to_reg(gpio, CTRL_OUT), 156 + CTLO_INPUT_SET); 157 + } 158 + 159 + static int wcove_gpio_dir_out(struct gpio_chip *chip, unsigned int gpio, 160 + int value) 161 + { 162 + struct wcove_gpio *wg = gpiochip_get_data(chip); 163 + 164 + return regmap_write(wg->regmap, to_reg(gpio, CTRL_OUT), 165 + CTLO_OUTPUT_SET | value); 166 + } 167 + 168 + static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio) 169 + { 170 + struct wcove_gpio *wg = gpiochip_get_data(chip); 171 + unsigned int val; 172 + int ret; 173 + 174 + ret = regmap_read(wg->regmap, to_reg(gpio, CTRL_OUT), &val); 175 + if (ret) 176 + return ret; 177 + 178 + return !(val & CTLO_DIR_OUT); 179 + } 180 + 181 + static int wcove_gpio_get(struct gpio_chip *chip, unsigned int gpio) 182 + { 183 + struct wcove_gpio *wg = gpiochip_get_data(chip); 184 + unsigned int val; 185 + int ret; 186 + 187 + ret = regmap_read(wg->regmap, to_reg(gpio, CTRL_IN), &val); 188 + if (ret) 189 + return ret; 190 + 191 + return val & 0x1; 192 + } 193 + 194 + static void wcove_gpio_set(struct gpio_chip *chip, 195 + unsigned int gpio, int value) 196 + { 197 + struct wcove_gpio *wg = gpiochip_get_data(chip); 198 + 199 + if (value) 200 + regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 1, 1); 201 + else 202 + regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 1, 0); 203 + } 204 + 205 + static int wcove_gpio_set_single_ended(struct gpio_chip *chip, 206 + unsigned int gpio, 207 + enum single_ended_mode mode) 208 + { 209 + struct wcove_gpio *wg = gpiochip_get_data(chip); 210 + 211 + switch (mode) { 212 + case LINE_MODE_OPEN_DRAIN: 213 + return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 214 + CTLO_DRV_MASK, CTLO_DRV_OD); 215 + case LINE_MODE_PUSH_PULL: 216 + return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 217 + CTLO_DRV_MASK, CTLO_DRV_CMOS); 218 + default: 219 + break; 220 + } 221 + 222 + return -ENOTSUPP; 223 + } 224 + 225 + static int wcove_irq_type(struct irq_data *data, unsigned int type) 226 + { 227 + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 228 + struct wcove_gpio *wg = gpiochip_get_data(chip); 229 + 230 + switch (type) { 231 + case IRQ_TYPE_NONE: 232 + wg->intcnt = CTLI_INTCNT_DIS; 233 + break; 234 + case IRQ_TYPE_EDGE_BOTH: 235 + wg->intcnt = CTLI_INTCNT_BE; 236 + break; 237 + case IRQ_TYPE_EDGE_RISING: 238 + wg->intcnt = CTLI_INTCNT_PE; 239 + break; 240 + case IRQ_TYPE_EDGE_FALLING: 241 + wg->intcnt = CTLI_INTCNT_NE; 242 + break; 243 + default: 244 + return -EINVAL; 245 + } 246 + 247 + wg->update |= UPDATE_IRQ_TYPE; 248 + 249 + return 0; 250 + } 251 + 252 + static void wcove_bus_lock(struct irq_data *data) 253 + { 254 + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 255 + struct wcove_gpio *wg = gpiochip_get_data(chip); 256 + 257 + mutex_lock(&wg->buslock); 258 + } 259 + 260 + static void wcove_bus_sync_unlock(struct irq_data *data) 261 + { 262 + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 263 + struct wcove_gpio *wg = gpiochip_get_data(chip); 264 + int gpio = data->hwirq; 265 + 266 + if (wg->update & UPDATE_IRQ_TYPE) 267 + wcove_update_irq_ctrl(wg, gpio); 268 + if (wg->update & UPDATE_IRQ_MASK) 269 + wcove_update_irq_mask(wg, gpio); 270 + wg->update = 0; 271 + 272 + mutex_unlock(&wg->buslock); 273 + } 274 + 275 + static void wcove_irq_unmask(struct irq_data *data) 276 + { 277 + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 278 + struct wcove_gpio *wg = gpiochip_get_data(chip); 279 + 280 + wg->set_irq_mask = false; 281 + wg->update |= UPDATE_IRQ_MASK; 282 + } 283 + 284 + static void wcove_irq_mask(struct irq_data *data) 285 + { 286 + struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 287 + struct wcove_gpio *wg = gpiochip_get_data(chip); 288 + 289 + wg->set_irq_mask = true; 290 + wg->update |= UPDATE_IRQ_MASK; 291 + } 292 + 293 + static struct irq_chip wcove_irqchip = { 294 + .name = "Whiskey Cove", 295 + .irq_mask = wcove_irq_mask, 296 + .irq_unmask = wcove_irq_unmask, 297 + .irq_set_type = wcove_irq_type, 298 + .irq_bus_lock = wcove_bus_lock, 299 + .irq_bus_sync_unlock = wcove_bus_sync_unlock, 300 + }; 301 + 302 + static irqreturn_t wcove_gpio_irq_handler(int irq, void *data) 303 + { 304 + struct wcove_gpio *wg = (struct wcove_gpio *)data; 305 + unsigned int pending, virq, gpio, mask, offset; 306 + u8 p[2]; 307 + 308 + if (regmap_bulk_read(wg->regmap, IRQ_STATUS_BASE, p, 2)) { 309 + dev_err(wg->dev, "Failed to read irq status register\n"); 310 + return IRQ_NONE; 311 + } 312 + 313 + pending = p[0] | (p[1] << 8); 314 + if (!pending) 315 + return IRQ_NONE; 316 + 317 + /* Iterate until no interrupt is pending */ 318 + while (pending) { 319 + /* One iteration is for all pending bits */ 320 + for_each_set_bit(gpio, (const unsigned long *)&pending, 321 + GROUP0_NR_IRQS) { 322 + offset = (gpio > GROUP0_NR_IRQS) ? 1 : 0; 323 + mask = (offset == 1) ? BIT(gpio - GROUP0_NR_IRQS) : 324 + BIT(gpio); 325 + virq = irq_find_mapping(wg->chip.irqdomain, gpio); 326 + handle_nested_irq(virq); 327 + regmap_update_bits(wg->regmap, IRQ_STATUS_BASE + offset, 328 + mask, mask); 329 + } 330 + 331 + /* Next iteration */ 332 + if (regmap_bulk_read(wg->regmap, IRQ_STATUS_BASE, p, 2)) { 333 + dev_err(wg->dev, "Failed to read irq status\n"); 334 + break; 335 + } 336 + 337 + pending = p[0] | (p[1] << 8); 338 + } 339 + 340 + return IRQ_HANDLED; 341 + } 342 + 343 + static void wcove_gpio_dbg_show(struct seq_file *s, 344 + struct gpio_chip *chip) 345 + { 346 + unsigned int ctlo, ctli, irq_mask, irq_status; 347 + struct wcove_gpio *wg = gpiochip_get_data(chip); 348 + int gpio, offset, group, ret = 0; 349 + 350 + for (gpio = 0; gpio < WCOVE_GPIO_NUM; gpio++) { 351 + group = gpio < GROUP0_NR_IRQS ? 0 : 1; 352 + ret += regmap_read(wg->regmap, to_reg(gpio, CTRL_OUT), &ctlo); 353 + ret += regmap_read(wg->regmap, to_reg(gpio, CTRL_IN), &ctli); 354 + ret += regmap_read(wg->regmap, IRQ_MASK_BASE + group, 355 + &irq_mask); 356 + ret += regmap_read(wg->regmap, IRQ_STATUS_BASE + group, 357 + &irq_status); 358 + if (ret) { 359 + pr_err("Failed to read registers: ctrl out/in or irq status/mask\n"); 360 + break; 361 + } 362 + 363 + offset = gpio % 8; 364 + seq_printf(s, " gpio-%-2d %s %s %s %s ctlo=%2x,%s %s\n", 365 + gpio, ctlo & CTLO_DIR_OUT ? "out" : "in ", 366 + ctli & 0x1 ? "hi" : "lo", 367 + ctli & CTLI_INTCNT_NE ? "fall" : " ", 368 + ctli & CTLI_INTCNT_PE ? "rise" : " ", 369 + ctlo, 370 + irq_mask & BIT(offset) ? "mask " : "unmask", 371 + irq_status & BIT(offset) ? "pending" : " "); 372 + } 373 + } 374 + 375 + static int wcove_gpio_probe(struct platform_device *pdev) 376 + { 377 + struct intel_soc_pmic *pmic; 378 + struct wcove_gpio *wg; 379 + int virq, ret, irq; 380 + struct device *dev; 381 + 382 + /* 383 + * This gpio platform device is created by a mfd device (see 384 + * drivers/mfd/intel_soc_pmic_bxtwc.c for details). Information 385 + * shared by all sub-devices created by the mfd device, the regmap 386 + * pointer for instance, is stored as driver data of the mfd device 387 + * driver. 388 + */ 389 + pmic = dev_get_drvdata(pdev->dev.parent); 390 + if (!pmic) 391 + return -ENODEV; 392 + 393 + irq = platform_get_irq(pdev, 0); 394 + if (irq < 0) 395 + return irq; 396 + 397 + dev = &pdev->dev; 398 + 399 + wg = devm_kzalloc(dev, sizeof(*wg), GFP_KERNEL); 400 + if (!wg) 401 + return -ENOMEM; 402 + 403 + wg->regmap_irq_chip = pmic->irq_chip_data_level2; 404 + 405 + platform_set_drvdata(pdev, wg); 406 + 407 + mutex_init(&wg->buslock); 408 + wg->chip.label = KBUILD_MODNAME; 409 + wg->chip.direction_input = wcove_gpio_dir_in; 410 + wg->chip.direction_output = wcove_gpio_dir_out; 411 + wg->chip.get_direction = wcove_gpio_get_direction; 412 + wg->chip.get = wcove_gpio_get; 413 + wg->chip.set = wcove_gpio_set; 414 + wg->chip.set_single_ended = wcove_gpio_set_single_ended, 415 + wg->chip.base = -1; 416 + wg->chip.ngpio = WCOVE_VGPIO_NUM; 417 + wg->chip.can_sleep = true; 418 + wg->chip.parent = pdev->dev.parent; 419 + wg->chip.dbg_show = wcove_gpio_dbg_show; 420 + wg->dev = dev; 421 + wg->regmap = pmic->regmap; 422 + 423 + ret = devm_gpiochip_add_data(dev, &wg->chip, wg); 424 + if (ret) { 425 + dev_err(dev, "Failed to add gpiochip: %d\n", ret); 426 + return ret; 427 + } 428 + 429 + ret = gpiochip_irqchip_add(&wg->chip, &wcove_irqchip, 0, 430 + handle_simple_irq, IRQ_TYPE_NONE); 431 + if (ret) { 432 + dev_err(dev, "Failed to add irqchip: %d\n", ret); 433 + return ret; 434 + } 435 + 436 + virq = regmap_irq_get_virq(wg->regmap_irq_chip, irq); 437 + if (virq < 0) { 438 + dev_err(dev, "Failed to get virq by irq %d\n", irq); 439 + return virq; 440 + } 441 + 442 + ret = devm_request_threaded_irq(dev, virq, NULL, 443 + wcove_gpio_irq_handler, IRQF_ONESHOT, pdev->name, wg); 444 + if (ret) { 445 + dev_err(dev, "Failed to request irq %d\n", virq); 446 + return ret; 447 + } 448 + 449 + return 0; 450 + } 451 + 452 + /* 453 + * Whiskey Cove PMIC itself is a analog device(but with digital control 454 + * interface) providing power management support for other devices in 455 + * the accompanied SoC, so we have no .pm for Whiskey Cove GPIO driver. 456 + */ 457 + static struct platform_driver wcove_gpio_driver = { 458 + .driver = { 459 + .name = "bxt_wcove_gpio", 460 + }, 461 + .probe = wcove_gpio_probe, 462 + }; 463 + 464 + module_platform_driver(wcove_gpio_driver); 465 + 466 + MODULE_AUTHOR("Ajay Thomas <ajay.thomas.david.rajamanickam@intel.com>"); 467 + MODULE_AUTHOR("Bin Gao <bin.gao@intel.com>"); 468 + MODULE_DESCRIPTION("Intel Whiskey Cove GPIO Driver"); 469 + MODULE_LICENSE("GPL v2"); 470 + MODULE_ALIAS("platform:bxt_wcove_gpio");
+1 -1
drivers/gpio/gpio-wm831x.c
··· 247 247 #define wm831x_gpio_dbg_show NULL 248 248 #endif 249 249 250 - static struct gpio_chip template_chip = { 250 + static const struct gpio_chip template_chip = { 251 251 .label = "wm831x", 252 252 .owner = THIS_MODULE, 253 253 .direction_input = wm831x_gpio_direction_in,
+1 -1
drivers/gpio/gpio-wm8350.c
··· 93 93 return wm8350->irq_base + WM8350_IRQ_GPIO(offset); 94 94 } 95 95 96 - static struct gpio_chip template_chip = { 96 + static const struct gpio_chip template_chip = { 97 97 .label = "wm8350", 98 98 .owner = THIS_MODULE, 99 99 .direction_input = wm8350_gpio_direction_in,
+1 -1
drivers/gpio/gpio-wm8994.c
··· 249 249 #define wm8994_gpio_dbg_show NULL 250 250 #endif 251 251 252 - static struct gpio_chip template_chip = { 252 + static const struct gpio_chip template_chip = { 253 253 .label = "wm8994", 254 254 .owner = THIS_MODULE, 255 255 .request = wm8994_gpio_request,
+13 -2
drivers/gpio/gpio-zynq.c
··· 96 96 /* GPIO upper 16 bit mask */ 97 97 #define ZYNQ_GPIO_UPPER_MASK 0xFFFF0000 98 98 99 + /* For GPIO quirks */ 100 + #define ZYNQ_GPIO_QUIRK_FOO BIT(0) 101 + 99 102 /** 100 103 * struct zynq_gpio - gpio device private data structure 101 104 * @chip: instance of the gpio_chip ··· 125 122 */ 126 123 struct zynq_platform_data { 127 124 const char *label; 125 + u32 quirks; 128 126 u16 ngpio; 129 127 int max_bank; 130 128 int bank_min[ZYNQMP_GPIO_MAX_BANK]; ··· 242 238 static int zynq_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) 243 239 { 244 240 u32 reg; 241 + bool is_zynq_gpio; 245 242 unsigned int bank_num, bank_pin_num; 246 243 struct zynq_gpio *gpio = gpiochip_get_data(chip); 247 244 245 + is_zynq_gpio = gpio->p_data->quirks & ZYNQ_GPIO_QUIRK_FOO; 248 246 zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); 249 247 250 - /* bank 0 pins 7 and 8 are special and cannot be used as inputs */ 251 - if (bank_num == 0 && (bank_pin_num == 7 || bank_pin_num == 8)) 248 + /* 249 + * On zynq bank 0 pins 7 and 8 are special and cannot be used 250 + * as inputs. 251 + */ 252 + if (is_zynq_gpio && bank_num == 0 && 253 + (bank_pin_num == 7 || bank_pin_num == 8)) 252 254 return -EINVAL; 253 255 254 256 /* clear the bit in direction mode reg to set the pin as input */ ··· 637 627 638 628 static const struct zynq_platform_data zynq_gpio_def = { 639 629 .label = "zynq_gpio", 630 + .quirks = ZYNQ_GPIO_QUIRK_FOO, 640 631 .ngpio = ZYNQ_GPIO_NR_GPIOS, 641 632 .max_bank = ZYNQ_GPIO_MAX_BANK, 642 633 .bank_min[0] = ZYNQ_GPIO_BANK0_PIN_MIN(),
+54 -3
drivers/gpio/gpiolib-acpi.c
··· 14 14 #include <linux/gpio.h> 15 15 #include <linux/gpio/consumer.h> 16 16 #include <linux/gpio/driver.h> 17 + #include <linux/gpio/machine.h> 17 18 #include <linux/export.h> 18 19 #include <linux/acpi.h> 19 20 #include <linux/interrupt.h> ··· 396 395 int n; 397 396 }; 398 397 399 - static int acpi_find_gpio(struct acpi_resource *ares, void *data) 398 + static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data) 400 399 { 401 400 struct acpi_gpio_lookup *lookup = data; 402 401 ··· 441 440 442 441 INIT_LIST_HEAD(&res_list); 443 442 444 - ret = acpi_dev_get_resources(lookup->adev, &res_list, acpi_find_gpio, 443 + ret = acpi_dev_get_resources(lookup->adev, &res_list, 444 + acpi_populate_gpio_lookup, 445 445 lookup); 446 446 if (ret < 0) 447 447 return ret; ··· 515 513 * Note: if the GPIO resource has multiple entries in the pin list, this 516 514 * function only returns the first. 517 515 */ 518 - struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev, 516 + static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev, 519 517 const char *propname, int index, 520 518 struct acpi_gpio_info *info) 521 519 { ··· 546 544 547 545 ret = acpi_gpio_resource_lookup(&lookup, info); 548 546 return ret ? ERR_PTR(ret) : lookup.desc; 547 + } 548 + 549 + struct gpio_desc *acpi_find_gpio(struct device *dev, 550 + const char *con_id, 551 + unsigned int idx, 552 + enum gpiod_flags flags, 553 + enum gpio_lookup_flags *lookupflags) 554 + { 555 + struct acpi_device *adev = ACPI_COMPANION(dev); 556 + struct acpi_gpio_info info; 557 + struct gpio_desc *desc; 558 + char propname[32]; 559 + int i; 560 + 561 + /* Try first from _DSD */ 562 + for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { 563 + if (con_id && strcmp(con_id, "gpios")) { 564 + snprintf(propname, sizeof(propname), "%s-%s", 565 + con_id, gpio_suffixes[i]); 566 + } else { 567 + snprintf(propname, sizeof(propname), "%s", 568 + gpio_suffixes[i]); 569 + } 570 + 571 + desc = acpi_get_gpiod_by_index(adev, propname, idx, &info); 572 + if (!IS_ERR(desc) || (PTR_ERR(desc) == -EPROBE_DEFER)) 573 + break; 574 + } 575 + 576 + /* Then from plain _CRS GPIOs */ 577 + if (IS_ERR(desc)) { 578 + if (!acpi_can_fallback_to_crs(adev, con_id)) 579 + return ERR_PTR(-ENOENT); 580 + 581 + desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info); 582 + if (IS_ERR(desc)) 583 + return desc; 584 + 585 + if ((flags == GPIOD_OUT_LOW || flags == GPIOD_OUT_HIGH) && 586 + info.gpioint) { 587 + dev_dbg(dev, "refusing GpioInt() entry when doing GPIOD_OUT_* lookup\n"); 588 + return ERR_PTR(-ENOENT); 589 + } 590 + } 591 + 592 + if (info.polarity == GPIO_ACTIVE_LOW) 593 + *lookupflags |= GPIO_ACTIVE_LOW; 594 + 595 + return desc; 549 596 } 550 597 551 598 /**
+39
drivers/gpio/gpiolib-of.c
··· 113 113 } 114 114 EXPORT_SYMBOL(of_get_named_gpio_flags); 115 115 116 + struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, 117 + unsigned int idx, 118 + enum gpio_lookup_flags *flags) 119 + { 120 + char prop_name[32]; /* 32 is max size of property name */ 121 + enum of_gpio_flags of_flags; 122 + struct gpio_desc *desc; 123 + unsigned int i; 124 + 125 + for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { 126 + if (con_id) 127 + snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id, 128 + gpio_suffixes[i]); 129 + else 130 + snprintf(prop_name, sizeof(prop_name), "%s", 131 + gpio_suffixes[i]); 132 + 133 + desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx, 134 + &of_flags); 135 + if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) 136 + break; 137 + } 138 + 139 + if (IS_ERR(desc)) 140 + return desc; 141 + 142 + if (of_flags & OF_GPIO_ACTIVE_LOW) 143 + *flags |= GPIO_ACTIVE_LOW; 144 + 145 + if (of_flags & OF_GPIO_SINGLE_ENDED) { 146 + if (of_flags & OF_GPIO_ACTIVE_LOW) 147 + *flags |= GPIO_OPEN_DRAIN; 148 + else 149 + *flags |= GPIO_OPEN_SOURCE; 150 + } 151 + 152 + return desc; 153 + } 154 + 116 155 /** 117 156 * of_parse_own_gpio() - Get a GPIO hog descriptor, names and flags for GPIO API 118 157 * @np: device node to get GPIO from
+2 -2
drivers/gpio/gpiolib-sysfs.c
··· 670 670 EXPORT_SYMBOL_GPL(gpiod_export_link); 671 671 672 672 /** 673 - * gpiod_unexport - reverse effect of gpio_export() 673 + * gpiod_unexport - reverse effect of gpiod_export() 674 674 * @gpio: gpio to make unavailable 675 675 * 676 - * This is implicit on gpio_free(). 676 + * This is implicit on gpiod_free(). 677 677 */ 678 678 void gpiod_unexport(struct gpio_desc *desc) 679 679 {
+18 -96
drivers/gpio/gpiolib.c
··· 1370 1370 void *data)) 1371 1371 { 1372 1372 struct gpio_device *gdev; 1373 - struct gpio_chip *chip; 1373 + struct gpio_chip *chip = NULL; 1374 1374 unsigned long flags; 1375 1375 1376 1376 spin_lock_irqsave(&gpio_lock, flags); 1377 1377 list_for_each_entry(gdev, &gpio_devices, list) 1378 - if (gdev->chip && match(gdev->chip, data)) 1378 + if (gdev->chip && match(gdev->chip, data)) { 1379 + chip = gdev->chip; 1379 1380 break; 1380 - 1381 - /* No match? */ 1382 - if (&gdev->list == &gpio_devices) 1383 - chip = NULL; 1384 - else 1385 - chip = gdev->chip; 1381 + } 1386 1382 1387 1383 spin_unlock_irqrestore(&gpio_lock, flags); 1388 1384 ··· 1663 1667 if (gpiochip->of_node) 1664 1668 of_node = gpiochip->of_node; 1665 1669 #endif 1670 + /* 1671 + * Specifying a default trigger is a terrible idea if DT or ACPI is 1672 + * used to configure the interrupts, as you may end-up with 1673 + * conflicting triggers. Tell the user, and reset to NONE. 1674 + */ 1675 + if (WARN(of_node && type != IRQ_TYPE_NONE, 1676 + "%s: Ignoring %d default trigger\n", of_node->full_name, type)) 1677 + type = IRQ_TYPE_NONE; 1678 + if (has_acpi_companion(gpiochip->parent) && type != IRQ_TYPE_NONE) { 1679 + acpi_handle_warn(ACPI_HANDLE(gpiochip->parent), 1680 + "Ignoring %d default trigger\n", type); 1681 + type = IRQ_TYPE_NONE; 1682 + } 1683 + 1666 1684 gpiochip->irqchip = irqchip; 1667 1685 gpiochip->irq_handler = handler; 1668 1686 gpiochip->irq_default_type = type; ··· 2881 2871 list_del(&table->list); 2882 2872 2883 2873 mutex_unlock(&gpio_lookup_lock); 2884 - } 2885 - 2886 - static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, 2887 - unsigned int idx, 2888 - enum gpio_lookup_flags *flags) 2889 - { 2890 - char prop_name[32]; /* 32 is max size of property name */ 2891 - enum of_gpio_flags of_flags; 2892 - struct gpio_desc *desc; 2893 - unsigned int i; 2894 - 2895 - for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { 2896 - if (con_id) 2897 - snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id, 2898 - gpio_suffixes[i]); 2899 - else 2900 - snprintf(prop_name, sizeof(prop_name), "%s", 2901 - gpio_suffixes[i]); 2902 - 2903 - desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx, 2904 - &of_flags); 2905 - if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) 2906 - break; 2907 - } 2908 - 2909 - if (IS_ERR(desc)) 2910 - return desc; 2911 - 2912 - if (of_flags & OF_GPIO_ACTIVE_LOW) 2913 - *flags |= GPIO_ACTIVE_LOW; 2914 - 2915 - if (of_flags & OF_GPIO_SINGLE_ENDED) { 2916 - if (of_flags & OF_GPIO_ACTIVE_LOW) 2917 - *flags |= GPIO_OPEN_DRAIN; 2918 - else 2919 - *flags |= GPIO_OPEN_SOURCE; 2920 - } 2921 - 2922 - return desc; 2923 - } 2924 - 2925 - static struct gpio_desc *acpi_find_gpio(struct device *dev, 2926 - const char *con_id, 2927 - unsigned int idx, 2928 - enum gpiod_flags flags, 2929 - enum gpio_lookup_flags *lookupflags) 2930 - { 2931 - struct acpi_device *adev = ACPI_COMPANION(dev); 2932 - struct acpi_gpio_info info; 2933 - struct gpio_desc *desc; 2934 - char propname[32]; 2935 - int i; 2936 - 2937 - /* Try first from _DSD */ 2938 - for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { 2939 - if (con_id && strcmp(con_id, "gpios")) { 2940 - snprintf(propname, sizeof(propname), "%s-%s", 2941 - con_id, gpio_suffixes[i]); 2942 - } else { 2943 - snprintf(propname, sizeof(propname), "%s", 2944 - gpio_suffixes[i]); 2945 - } 2946 - 2947 - desc = acpi_get_gpiod_by_index(adev, propname, idx, &info); 2948 - if (!IS_ERR(desc) || (PTR_ERR(desc) == -EPROBE_DEFER)) 2949 - break; 2950 - } 2951 - 2952 - /* Then from plain _CRS GPIOs */ 2953 - if (IS_ERR(desc)) { 2954 - if (!acpi_can_fallback_to_crs(adev, con_id)) 2955 - return ERR_PTR(-ENOENT); 2956 - 2957 - desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info); 2958 - if (IS_ERR(desc)) 2959 - return desc; 2960 - 2961 - if ((flags == GPIOD_OUT_LOW || flags == GPIOD_OUT_HIGH) && 2962 - info.gpioint) { 2963 - dev_dbg(dev, "refusing GpioInt() entry when doing GPIOD_OUT_* lookup\n"); 2964 - return ERR_PTR(-ENOENT); 2965 - } 2966 - } 2967 - 2968 - if (info.polarity == GPIO_ACTIVE_LOW) 2969 - *lookupflags |= GPIO_ACTIVE_LOW; 2970 - 2971 - return desc; 2972 2874 } 2973 2875 2974 2876 static struct gpiod_lookup_table *gpiod_find_lookup_table(struct device *dev)
+36 -9
drivers/gpio/gpiolib.h
··· 20 20 21 21 enum of_gpio_flags; 22 22 enum gpiod_flags; 23 + enum gpio_lookup_flags; 23 24 struct acpi_device; 24 25 25 26 /** ··· 87 86 /* gpio suffixes used for ACPI and device tree lookup */ 88 87 static const char * const gpio_suffixes[] = { "gpios", "gpio" }; 89 88 89 + #ifdef CONFIG_OF_GPIO 90 + struct gpio_desc *of_find_gpio(struct device *dev, 91 + const char *con_id, 92 + unsigned int idx, 93 + enum gpio_lookup_flags *flags); 94 + struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, 95 + const char *list_name, int index, enum of_gpio_flags *flags); 96 + int of_gpiochip_add(struct gpio_chip *gc); 97 + void of_gpiochip_remove(struct gpio_chip *gc); 98 + #else 99 + static inline struct gpio_desc *of_find_gpio(struct device *dev, 100 + const char *con_id, 101 + unsigned int idx, 102 + enum gpio_lookup_flags *flags) 103 + { 104 + return ERR_PTR(-ENOENT); 105 + } 106 + static inline struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, 107 + const char *list_name, int index, enum of_gpio_flags *flags) 108 + { 109 + return ERR_PTR(-ENOENT); 110 + } 111 + static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; } 112 + static inline void of_gpiochip_remove(struct gpio_chip *gc) { } 113 + #endif /* CONFIG_OF_GPIO */ 114 + 90 115 #ifdef CONFIG_ACPI 91 116 void acpi_gpiochip_add(struct gpio_chip *chip); 92 117 void acpi_gpiochip_remove(struct gpio_chip *chip); ··· 120 93 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); 121 94 void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); 122 95 123 - struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev, 124 - const char *propname, int index, 125 - struct acpi_gpio_info *info); 96 + struct gpio_desc *acpi_find_gpio(struct device *dev, 97 + const char *con_id, 98 + unsigned int idx, 99 + enum gpiod_flags flags, 100 + enum gpio_lookup_flags *lookupflags); 126 101 struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, 127 102 const char *propname, int index, 128 103 struct acpi_gpio_info *info); ··· 143 114 acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { } 144 115 145 116 static inline struct gpio_desc * 146 - acpi_get_gpiod_by_index(struct acpi_device *adev, const char *propname, 147 - int index, struct acpi_gpio_info *info) 117 + acpi_find_gpio(struct device *dev, const char *con_id, 118 + unsigned int idx, enum gpiod_flags flags, 119 + enum gpio_lookup_flags *lookupflags) 148 120 { 149 - return ERR_PTR(-ENOSYS); 121 + return ERR_PTR(-ENOENT); 150 122 } 151 123 static inline struct gpio_desc * 152 124 acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname, ··· 166 136 return false; 167 137 } 168 138 #endif 169 - 170 - struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, 171 - const char *list_name, int index, enum of_gpio_flags *flags); 172 139 173 140 struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, u16 hwnum); 174 141 void gpiod_set_array_value_complex(bool raw, bool can_sleep,
+14 -8
drivers/mfd/Kconfig
··· 340 340 help 341 341 Select this option to enable Hisilicon hi655x series pmic driver. 342 342 343 - config HTC_EGPIO 344 - bool "HTC EGPIO support" 345 - depends on GPIOLIB && ARM 346 - help 347 - This driver supports the CPLD egpio chip present on 348 - several HTC phones. It provides basic support for input 349 - pins, output pins, and irqs. 350 - 351 343 config HTC_PASIC3 352 344 tristate "HTC PASIC3 LED/DS1WM chip support" 353 345 select MFD_CORE ··· 1215 1223 1216 1224 This driver can also be built as a module. If so, the module 1217 1225 will be called tps65217. 1226 + 1227 + config MFD_TI_LP873X 1228 + tristate "TI LP873X Power Management IC" 1229 + depends on I2C 1230 + select MFD_CORE 1231 + select REGMAP_I2C 1232 + help 1233 + If you say yes here then you get support for the LP873X series of 1234 + Power Management Integrated Circuits (PMIC). 1235 + These include voltage regulators, thermal protection, configurable 1236 + General Purpose Outputs (GPO) that are used in portable devices. 1237 + 1238 + This driver can also be built as a module. If so, the module 1239 + will be called lp873x. 1218 1240 1219 1241 config MFD_TPS65218 1220 1242 tristate "TI TPS65218 Power Management chips"
+2 -1
drivers/mfd/Makefile
··· 18 18 obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o 19 19 obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o 20 20 21 - obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o 22 21 obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o 23 22 obj-$(CONFIG_HTC_I2CPLD) += htc-i2cpld.o 23 + 24 + obj-$(CONFIG_MFD_TI_LP873X) += lp873x.o 24 25 25 26 obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o 26 27 obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o
+1 -1
drivers/mfd/htc-egpio.c drivers/gpio/gpio-htc-egpio.c
··· 14 14 #include <linux/irq.h> 15 15 #include <linux/io.h> 16 16 #include <linux/spinlock.h> 17 + #include <linux/platform_data/gpio-htc-egpio.h> 17 18 #include <linux/platform_device.h> 18 19 #include <linux/slab.h> 19 20 #include <linux/module.h> 20 - #include <linux/mfd/htc-egpio.h> 21 21 22 22 struct egpio_chip { 23 23 int reg_start;
+99
drivers/mfd/lp873x.c
··· 1 + /* 2 + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ 3 + * 4 + * Author: Keerthy <j-keerthy@ti.com> 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License as 8 + * published by the Free Software Foundation version 2. 9 + * 10 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 11 + * kind, whether express or implied; without even the implied warranty 12 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + #include <linux/interrupt.h> 17 + #include <linux/mfd/core.h> 18 + #include <linux/module.h> 19 + #include <linux/of_device.h> 20 + #include <linux/regmap.h> 21 + 22 + #include <linux/mfd/lp873x.h> 23 + 24 + static const struct regmap_config lp873x_regmap_config = { 25 + .reg_bits = 8, 26 + .val_bits = 8, 27 + .max_register = LP873X_REG_MAX, 28 + }; 29 + 30 + static const struct mfd_cell lp873x_cells[] = { 31 + { .name = "lp873x-regulator", }, 32 + { .name = "lp873x-gpio", }, 33 + }; 34 + 35 + static int lp873x_probe(struct i2c_client *client, 36 + const struct i2c_device_id *ids) 37 + { 38 + struct lp873x *lp873; 39 + int ret; 40 + unsigned int otpid; 41 + 42 + lp873 = devm_kzalloc(&client->dev, sizeof(*lp873), GFP_KERNEL); 43 + if (!lp873) 44 + return -ENOMEM; 45 + 46 + lp873->dev = &client->dev; 47 + 48 + lp873->regmap = devm_regmap_init_i2c(client, &lp873x_regmap_config); 49 + if (IS_ERR(lp873->regmap)) { 50 + ret = PTR_ERR(lp873->regmap); 51 + dev_err(lp873->dev, 52 + "Failed to initialize register map: %d\n", ret); 53 + return ret; 54 + } 55 + 56 + mutex_init(&lp873->lock); 57 + 58 + ret = regmap_read(lp873->regmap, LP873X_REG_OTP_REV, &otpid); 59 + if (ret) { 60 + dev_err(lp873->dev, "Failed to read OTP ID\n"); 61 + return ret; 62 + } 63 + 64 + lp873->rev = otpid & LP873X_OTP_REV_OTP_ID; 65 + 66 + i2c_set_clientdata(client, lp873); 67 + 68 + ret = mfd_add_devices(lp873->dev, PLATFORM_DEVID_AUTO, lp873x_cells, 69 + ARRAY_SIZE(lp873x_cells), NULL, 0, NULL); 70 + 71 + return ret; 72 + } 73 + 74 + static const struct of_device_id of_lp873x_match_table[] = { 75 + { .compatible = "ti,lp8733", }, 76 + { .compatible = "ti,lp8732", }, 77 + {} 78 + }; 79 + MODULE_DEVICE_TABLE(of, of_lp873x_match_table); 80 + 81 + static const struct i2c_device_id lp873x_id_table[] = { 82 + { "lp873x", 0 }, 83 + { }, 84 + }; 85 + MODULE_DEVICE_TABLE(i2c, lp873x_id_table); 86 + 87 + static struct i2c_driver lp873x_driver = { 88 + .driver = { 89 + .name = "lp873x", 90 + .of_match_table = of_lp873x_match_table, 91 + }, 92 + .probe = lp873x_probe, 93 + .id_table = lp873x_id_table, 94 + }; 95 + module_i2c_driver(lp873x_driver); 96 + 97 + MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>"); 98 + MODULE_DESCRIPTION("LP873X chip family Multi-Function Device driver"); 99 + MODULE_LICENSE("GPL v2");
+2
drivers/mfd/stmpe-i2c.c
··· 57 57 { .compatible = "st,stmpe610", .data = (void *)STMPE610, }, 58 58 { .compatible = "st,stmpe801", .data = (void *)STMPE801, }, 59 59 { .compatible = "st,stmpe811", .data = (void *)STMPE811, }, 60 + { .compatible = "st,stmpe1600", .data = (void *)STMPE1600, }, 60 61 { .compatible = "st,stmpe1601", .data = (void *)STMPE1601, }, 61 62 { .compatible = "st,stmpe1801", .data = (void *)STMPE1801, }, 62 63 { .compatible = "st,stmpe2401", .data = (void *)STMPE2401, }, ··· 102 101 { "stmpe610", STMPE610 }, 103 102 { "stmpe801", STMPE801 }, 104 103 { "stmpe811", STMPE811 }, 104 + { "stmpe1600", STMPE1600 }, 105 105 { "stmpe1601", STMPE1601 }, 106 106 { "stmpe1801", STMPE1801 }, 107 107 { "stmpe2401", STMPE2401 },
+135 -26
drivers/mfd/stmpe.c
··· 469 469 470 470 static const u8 stmpe811_regs[] = { 471 471 [STMPE_IDX_CHIP_ID] = STMPE811_REG_CHIP_ID, 472 + [STMPE_IDX_SYS_CTRL] = STMPE811_REG_SYS_CTRL, 473 + [STMPE_IDX_SYS_CTRL2] = STMPE811_REG_SYS_CTRL2, 472 474 [STMPE_IDX_ICR_LSB] = STMPE811_REG_INT_CTRL, 473 475 [STMPE_IDX_IER_LSB] = STMPE811_REG_INT_EN, 474 476 [STMPE_IDX_ISR_MSB] = STMPE811_REG_INT_STA, ··· 483 481 [STMPE_IDX_GPAFR_U_MSB] = STMPE811_REG_GPIO_AF, 484 482 [STMPE_IDX_IEGPIOR_LSB] = STMPE811_REG_GPIO_INT_EN, 485 483 [STMPE_IDX_ISGPIOR_MSB] = STMPE811_REG_GPIO_INT_STA, 486 - [STMPE_IDX_GPEDR_MSB] = STMPE811_REG_GPIO_ED, 484 + [STMPE_IDX_GPEDR_LSB] = STMPE811_REG_GPIO_ED, 487 485 }; 488 486 489 487 static struct stmpe_variant_block stmpe811_blocks[] = { ··· 513 511 if (blocks & STMPE_BLOCK_TOUCHSCREEN) 514 512 mask |= STMPE811_SYS_CTRL2_TSC_OFF; 515 513 516 - return __stmpe_set_bits(stmpe, STMPE811_REG_SYS_CTRL2, mask, 514 + return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL2], mask, 517 515 enable ? 0 : mask); 518 516 } 519 517 ··· 553 551 }; 554 552 555 553 /* 554 + * STMPE1600 555 + * Compared to all others STMPE variant, LSB and MSB regs are located in this 556 + * order : LSB addr 557 + * MSB addr + 1 558 + * As there is only 2 * 8bits registers for GPMR/GPSR/IEGPIOPR, CSB index is MSB registers 559 + */ 560 + 561 + static const u8 stmpe1600_regs[] = { 562 + [STMPE_IDX_CHIP_ID] = STMPE1600_REG_CHIP_ID, 563 + [STMPE_IDX_SYS_CTRL] = STMPE1600_REG_SYS_CTRL, 564 + [STMPE_IDX_ICR_LSB] = STMPE1600_REG_SYS_CTRL, 565 + [STMPE_IDX_GPMR_LSB] = STMPE1600_REG_GPMR_LSB, 566 + [STMPE_IDX_GPMR_CSB] = STMPE1600_REG_GPMR_MSB, 567 + [STMPE_IDX_GPSR_LSB] = STMPE1600_REG_GPSR_LSB, 568 + [STMPE_IDX_GPSR_CSB] = STMPE1600_REG_GPSR_MSB, 569 + [STMPE_IDX_GPDR_LSB] = STMPE1600_REG_GPDR_LSB, 570 + [STMPE_IDX_GPDR_CSB] = STMPE1600_REG_GPDR_MSB, 571 + [STMPE_IDX_IEGPIOR_LSB] = STMPE1600_REG_IEGPIOR_LSB, 572 + [STMPE_IDX_IEGPIOR_CSB] = STMPE1600_REG_IEGPIOR_MSB, 573 + [STMPE_IDX_ISGPIOR_LSB] = STMPE1600_REG_ISGPIOR_LSB, 574 + }; 575 + 576 + static struct stmpe_variant_block stmpe1600_blocks[] = { 577 + { 578 + .cell = &stmpe_gpio_cell, 579 + .irq = 0, 580 + .block = STMPE_BLOCK_GPIO, 581 + }, 582 + }; 583 + 584 + static int stmpe1600_enable(struct stmpe *stmpe, unsigned int blocks, 585 + bool enable) 586 + { 587 + if (blocks & STMPE_BLOCK_GPIO) 588 + return 0; 589 + else 590 + return -EINVAL; 591 + } 592 + 593 + static struct stmpe_variant_info stmpe1600 = { 594 + .name = "stmpe1600", 595 + .id_val = STMPE1600_ID, 596 + .id_mask = 0xffff, 597 + .num_gpios = 16, 598 + .af_bits = 0, 599 + .regs = stmpe1600_regs, 600 + .blocks = stmpe1600_blocks, 601 + .num_blocks = ARRAY_SIZE(stmpe1600_blocks), 602 + .num_irqs = STMPE1600_NR_INTERNAL_IRQS, 603 + .enable = stmpe1600_enable, 604 + }; 605 + 606 + /* 556 607 * STMPE1601 557 608 */ 558 609 559 610 static const u8 stmpe1601_regs[] = { 560 611 [STMPE_IDX_CHIP_ID] = STMPE1601_REG_CHIP_ID, 612 + [STMPE_IDX_SYS_CTRL] = STMPE1601_REG_SYS_CTRL, 613 + [STMPE_IDX_SYS_CTRL2] = STMPE1601_REG_SYS_CTRL2, 561 614 [STMPE_IDX_ICR_LSB] = STMPE1601_REG_ICR_LSB, 615 + [STMPE_IDX_IER_MSB] = STMPE1601_REG_IER_MSB, 562 616 [STMPE_IDX_IER_LSB] = STMPE1601_REG_IER_LSB, 563 617 [STMPE_IDX_ISR_MSB] = STMPE1601_REG_ISR_MSB, 564 618 [STMPE_IDX_GPMR_LSB] = STMPE1601_REG_GPIO_MP_LSB, 619 + [STMPE_IDX_GPMR_CSB] = STMPE1601_REG_GPIO_MP_MSB, 565 620 [STMPE_IDX_GPSR_LSB] = STMPE1601_REG_GPIO_SET_LSB, 621 + [STMPE_IDX_GPSR_CSB] = STMPE1601_REG_GPIO_SET_MSB, 566 622 [STMPE_IDX_GPCR_LSB] = STMPE1601_REG_GPIO_CLR_LSB, 623 + [STMPE_IDX_GPCR_CSB] = STMPE1601_REG_GPIO_CLR_MSB, 567 624 [STMPE_IDX_GPDR_LSB] = STMPE1601_REG_GPIO_SET_DIR_LSB, 625 + [STMPE_IDX_GPDR_CSB] = STMPE1601_REG_GPIO_SET_DIR_MSB, 626 + [STMPE_IDX_GPEDR_LSB] = STMPE1601_REG_GPIO_ED_LSB, 627 + [STMPE_IDX_GPEDR_CSB] = STMPE1601_REG_GPIO_ED_MSB, 568 628 [STMPE_IDX_GPRER_LSB] = STMPE1601_REG_GPIO_RE_LSB, 629 + [STMPE_IDX_GPRER_CSB] = STMPE1601_REG_GPIO_RE_MSB, 569 630 [STMPE_IDX_GPFER_LSB] = STMPE1601_REG_GPIO_FE_LSB, 631 + [STMPE_IDX_GPFER_CSB] = STMPE1601_REG_GPIO_FE_MSB, 570 632 [STMPE_IDX_GPPUR_LSB] = STMPE1601_REG_GPIO_PU_LSB, 571 633 [STMPE_IDX_GPAFR_U_MSB] = STMPE1601_REG_GPIO_AF_U_MSB, 572 634 [STMPE_IDX_IEGPIOR_LSB] = STMPE1601_REG_INT_EN_GPIO_MASK_LSB, 635 + [STMPE_IDX_IEGPIOR_CSB] = STMPE1601_REG_INT_EN_GPIO_MASK_MSB, 573 636 [STMPE_IDX_ISGPIOR_MSB] = STMPE1601_REG_INT_STA_GPIO_MSB, 574 - [STMPE_IDX_GPEDR_MSB] = STMPE1601_REG_GPIO_ED_MSB, 575 637 }; 576 638 577 639 static struct stmpe_variant_block stmpe1601_blocks[] = { ··· 706 640 return timeout; 707 641 } 708 642 709 - ret = __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL2, 643 + ret = __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL2], 710 644 STMPE1601_AUTOSLEEP_TIMEOUT_MASK, 711 645 timeout); 712 646 if (ret < 0) 713 647 return ret; 714 648 715 - return __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL2, 649 + return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL2], 716 650 STPME1601_AUTOSLEEP_ENABLE, 717 651 STPME1601_AUTOSLEEP_ENABLE); 718 652 } ··· 737 671 else 738 672 mask &= ~STMPE1601_SYS_CTRL_ENABLE_SPWM; 739 673 740 - return __stmpe_set_bits(stmpe, STMPE1601_REG_SYS_CTRL, mask, 674 + return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL], mask, 741 675 enable ? mask : 0); 742 676 } 743 677 ··· 776 710 */ 777 711 static const u8 stmpe1801_regs[] = { 778 712 [STMPE_IDX_CHIP_ID] = STMPE1801_REG_CHIP_ID, 713 + [STMPE_IDX_SYS_CTRL] = STMPE1801_REG_SYS_CTRL, 779 714 [STMPE_IDX_ICR_LSB] = STMPE1801_REG_INT_CTRL_LOW, 780 715 [STMPE_IDX_IER_LSB] = STMPE1801_REG_INT_EN_MASK_LOW, 781 716 [STMPE_IDX_ISR_LSB] = STMPE1801_REG_INT_STA_LOW, 782 717 [STMPE_IDX_GPMR_LSB] = STMPE1801_REG_GPIO_MP_LOW, 718 + [STMPE_IDX_GPMR_CSB] = STMPE1801_REG_GPIO_MP_MID, 719 + [STMPE_IDX_GPMR_MSB] = STMPE1801_REG_GPIO_MP_HIGH, 783 720 [STMPE_IDX_GPSR_LSB] = STMPE1801_REG_GPIO_SET_LOW, 721 + [STMPE_IDX_GPSR_CSB] = STMPE1801_REG_GPIO_SET_MID, 722 + [STMPE_IDX_GPSR_MSB] = STMPE1801_REG_GPIO_SET_HIGH, 784 723 [STMPE_IDX_GPCR_LSB] = STMPE1801_REG_GPIO_CLR_LOW, 724 + [STMPE_IDX_GPCR_CSB] = STMPE1801_REG_GPIO_CLR_MID, 725 + [STMPE_IDX_GPCR_MSB] = STMPE1801_REG_GPIO_CLR_HIGH, 785 726 [STMPE_IDX_GPDR_LSB] = STMPE1801_REG_GPIO_SET_DIR_LOW, 727 + [STMPE_IDX_GPDR_CSB] = STMPE1801_REG_GPIO_SET_DIR_MID, 728 + [STMPE_IDX_GPDR_MSB] = STMPE1801_REG_GPIO_SET_DIR_HIGH, 786 729 [STMPE_IDX_GPRER_LSB] = STMPE1801_REG_GPIO_RE_LOW, 730 + [STMPE_IDX_GPRER_CSB] = STMPE1801_REG_GPIO_RE_MID, 731 + [STMPE_IDX_GPRER_MSB] = STMPE1801_REG_GPIO_RE_HIGH, 787 732 [STMPE_IDX_GPFER_LSB] = STMPE1801_REG_GPIO_FE_LOW, 733 + [STMPE_IDX_GPFER_CSB] = STMPE1801_REG_GPIO_FE_MID, 734 + [STMPE_IDX_GPFER_MSB] = STMPE1801_REG_GPIO_FE_HIGH, 788 735 [STMPE_IDX_GPPUR_LSB] = STMPE1801_REG_GPIO_PULL_UP_LOW, 789 736 [STMPE_IDX_IEGPIOR_LSB] = STMPE1801_REG_INT_EN_GPIO_MASK_LOW, 790 - [STMPE_IDX_ISGPIOR_LSB] = STMPE1801_REG_INT_STA_GPIO_LOW, 737 + [STMPE_IDX_IEGPIOR_CSB] = STMPE1801_REG_INT_EN_GPIO_MASK_MID, 738 + [STMPE_IDX_IEGPIOR_MSB] = STMPE1801_REG_INT_EN_GPIO_MASK_HIGH, 739 + [STMPE_IDX_ISGPIOR_MSB] = STMPE1801_REG_INT_STA_GPIO_HIGH, 791 740 }; 792 741 793 742 static struct stmpe_variant_block stmpe1801_blocks[] = { ··· 832 751 enable ? mask : 0); 833 752 } 834 753 835 - static int stmpe1801_reset(struct stmpe *stmpe) 754 + static int stmpe_reset(struct stmpe *stmpe) 836 755 { 756 + u16 id_val = stmpe->variant->id_val; 837 757 unsigned long timeout; 838 758 int ret = 0; 759 + u8 reset_bit; 839 760 840 - ret = __stmpe_set_bits(stmpe, STMPE1801_REG_SYS_CTRL, 841 - STMPE1801_MSK_SYS_CTRL_RESET, STMPE1801_MSK_SYS_CTRL_RESET); 761 + if (id_val == STMPE811_ID) 762 + /* STMPE801 and STMPE610 use bit 1 of SYS_CTRL register */ 763 + reset_bit = STMPE811_SYS_CTRL_RESET; 764 + else 765 + /* all other STMPE variant use bit 7 of SYS_CTRL register */ 766 + reset_bit = STMPE_SYS_CTRL_RESET; 767 + 768 + ret = __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL], 769 + reset_bit, reset_bit); 842 770 if (ret < 0) 843 771 return ret; 844 772 845 773 timeout = jiffies + msecs_to_jiffies(100); 846 774 while (time_before(jiffies, timeout)) { 847 - ret = __stmpe_reg_read(stmpe, STMPE1801_REG_SYS_CTRL); 775 + ret = __stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL]); 848 776 if (ret < 0) 849 777 return ret; 850 - if (!(ret & STMPE1801_MSK_SYS_CTRL_RESET)) 778 + if (!(ret & reset_bit)) 851 779 return 0; 852 780 usleep_range(100, 200); 853 781 } ··· 884 794 885 795 static const u8 stmpe24xx_regs[] = { 886 796 [STMPE_IDX_CHIP_ID] = STMPE24XX_REG_CHIP_ID, 797 + [STMPE_IDX_SYS_CTRL] = STMPE24XX_REG_SYS_CTRL, 798 + [STMPE_IDX_SYS_CTRL2] = STMPE24XX_REG_SYS_CTRL2, 887 799 [STMPE_IDX_ICR_LSB] = STMPE24XX_REG_ICR_LSB, 800 + [STMPE_IDX_IER_MSB] = STMPE24XX_REG_IER_MSB, 888 801 [STMPE_IDX_IER_LSB] = STMPE24XX_REG_IER_LSB, 889 802 [STMPE_IDX_ISR_MSB] = STMPE24XX_REG_ISR_MSB, 890 803 [STMPE_IDX_GPMR_LSB] = STMPE24XX_REG_GPMR_LSB, 804 + [STMPE_IDX_GPMR_CSB] = STMPE24XX_REG_GPMR_CSB, 805 + [STMPE_IDX_GPMR_MSB] = STMPE24XX_REG_GPMR_MSB, 891 806 [STMPE_IDX_GPSR_LSB] = STMPE24XX_REG_GPSR_LSB, 807 + [STMPE_IDX_GPSR_CSB] = STMPE24XX_REG_GPSR_CSB, 808 + [STMPE_IDX_GPSR_MSB] = STMPE24XX_REG_GPSR_MSB, 892 809 [STMPE_IDX_GPCR_LSB] = STMPE24XX_REG_GPCR_LSB, 810 + [STMPE_IDX_GPCR_CSB] = STMPE24XX_REG_GPCR_CSB, 811 + [STMPE_IDX_GPCR_MSB] = STMPE24XX_REG_GPCR_MSB, 893 812 [STMPE_IDX_GPDR_LSB] = STMPE24XX_REG_GPDR_LSB, 813 + [STMPE_IDX_GPDR_CSB] = STMPE24XX_REG_GPDR_CSB, 814 + [STMPE_IDX_GPDR_MSB] = STMPE24XX_REG_GPDR_MSB, 894 815 [STMPE_IDX_GPRER_LSB] = STMPE24XX_REG_GPRER_LSB, 816 + [STMPE_IDX_GPRER_CSB] = STMPE24XX_REG_GPRER_CSB, 817 + [STMPE_IDX_GPRER_MSB] = STMPE24XX_REG_GPRER_MSB, 895 818 [STMPE_IDX_GPFER_LSB] = STMPE24XX_REG_GPFER_LSB, 819 + [STMPE_IDX_GPFER_CSB] = STMPE24XX_REG_GPFER_CSB, 820 + [STMPE_IDX_GPFER_MSB] = STMPE24XX_REG_GPFER_MSB, 896 821 [STMPE_IDX_GPPUR_LSB] = STMPE24XX_REG_GPPUR_LSB, 897 822 [STMPE_IDX_GPPDR_LSB] = STMPE24XX_REG_GPPDR_LSB, 898 823 [STMPE_IDX_GPAFR_U_MSB] = STMPE24XX_REG_GPAFR_U_MSB, 899 824 [STMPE_IDX_IEGPIOR_LSB] = STMPE24XX_REG_IEGPIOR_LSB, 825 + [STMPE_IDX_IEGPIOR_CSB] = STMPE24XX_REG_IEGPIOR_CSB, 826 + [STMPE_IDX_IEGPIOR_MSB] = STMPE24XX_REG_IEGPIOR_MSB, 900 827 [STMPE_IDX_ISGPIOR_MSB] = STMPE24XX_REG_ISGPIOR_MSB, 828 + [STMPE_IDX_GPEDR_LSB] = STMPE24XX_REG_GPEDR_LSB, 829 + [STMPE_IDX_GPEDR_CSB] = STMPE24XX_REG_GPEDR_CSB, 901 830 [STMPE_IDX_GPEDR_MSB] = STMPE24XX_REG_GPEDR_MSB, 902 831 }; 903 832 ··· 949 840 if (blocks & STMPE_BLOCK_KEYPAD) 950 841 mask |= STMPE24XX_SYS_CTRL_ENABLE_KPC; 951 842 952 - return __stmpe_set_bits(stmpe, STMPE24XX_REG_SYS_CTRL, mask, 843 + return __stmpe_set_bits(stmpe, stmpe->regs[STMPE_IDX_SYS_CTRL], mask, 953 844 enable ? mask : 0); 954 845 } 955 846 ··· 1002 893 [STMPE610] = &stmpe610, 1003 894 [STMPE801] = &stmpe801, 1004 895 [STMPE811] = &stmpe811, 896 + [STMPE1600] = &stmpe1600, 1005 897 [STMPE1601] = &stmpe1601, 1006 898 [STMPE1801] = &stmpe1801, 1007 899 [STMPE2401] = &stmpe2401, ··· 1029 919 int ret; 1030 920 int i; 1031 921 1032 - if (variant->id_val == STMPE801_ID) { 922 + if (variant->id_val == STMPE801_ID || 923 + variant->id_val == STMPE1600_ID) { 1033 924 int base = irq_create_mapping(stmpe->domain, 0); 1034 925 1035 926 handle_nested_irq(base); ··· 1093 982 continue; 1094 983 1095 984 stmpe->oldier[i] = new; 1096 - stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_IER_LSB] - i, new); 985 + stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_IER_LSB + i], new); 1097 986 } 1098 987 1099 988 mutex_unlock(&stmpe->irq_lock); ··· 1199 1088 if (ret) 1200 1089 return ret; 1201 1090 1202 - if (id == STMPE1801_ID) { 1203 - ret = stmpe1801_reset(stmpe); 1204 - if (ret < 0) 1205 - return ret; 1206 - } 1091 + ret = stmpe_reset(stmpe); 1092 + if (ret < 0) 1093 + return ret; 1207 1094 1208 1095 if (stmpe->irq >= 0) { 1209 - if (id == STMPE801_ID) 1210 - icr = STMPE801_REG_SYS_CTRL_INT_EN; 1096 + if (id == STMPE801_ID || id == STMPE1600_ID) 1097 + icr = STMPE_SYS_CTRL_INT_EN; 1211 1098 else 1212 1099 icr = STMPE_ICR_LSB_GIM; 1213 1100 1214 - /* STMPE801 doesn't support Edge interrupts */ 1215 - if (id != STMPE801_ID) { 1101 + /* STMPE801 and STMPE1600 don't support Edge interrupts */ 1102 + if (id != STMPE801_ID && id != STMPE1600_ID) { 1216 1103 if (irq_trigger == IRQF_TRIGGER_FALLING || 1217 1104 irq_trigger == IRQF_TRIGGER_RISING) 1218 1105 icr |= STMPE_ICR_LSB_EDGE; ··· 1218 1109 1219 1110 if (irq_trigger == IRQF_TRIGGER_RISING || 1220 1111 irq_trigger == IRQF_TRIGGER_HIGH) { 1221 - if (id == STMPE801_ID) 1222 - icr |= STMPE801_REG_SYS_CTRL_INT_HI; 1112 + if (id == STMPE801_ID || id == STMPE1600_ID) 1113 + icr |= STMPE_SYS_CTRL_INT_HI; 1223 1114 else 1224 1115 icr |= STMPE_ICR_LSB_HIGH; 1225 1116 }
+73 -12
drivers/mfd/stmpe.h
··· 104 104 #define STMPE_ICR_LSB_EDGE (1 << 1) 105 105 #define STMPE_ICR_LSB_GIM (1 << 0) 106 106 107 + #define STMPE_SYS_CTRL_RESET (1 << 7) 108 + #define STMPE_SYS_CTRL_INT_EN (1 << 2) 109 + #define STMPE_SYS_CTRL_INT_HI (1 << 0) 110 + 107 111 /* 108 112 * STMPE801 109 113 */ ··· 123 119 #define STMPE801_REG_GPIO_SET_PIN 0x11 124 120 #define STMPE801_REG_GPIO_DIR 0x12 125 121 126 - #define STMPE801_REG_SYS_CTRL_RESET (1 << 7) 127 - #define STMPE801_REG_SYS_CTRL_INT_EN (1 << 2) 128 - #define STMPE801_REG_SYS_CTRL_INT_HI (1 << 0) 129 - 130 122 /* 131 123 * STMPE811 132 124 */ 125 + #define STMPE811_ID 0x0811 133 126 134 127 #define STMPE811_IRQ_TOUCH_DET 0 135 128 #define STMPE811_IRQ_FIFO_TH 1 ··· 139 138 #define STMPE811_NR_INTERNAL_IRQS 8 140 139 141 140 #define STMPE811_REG_CHIP_ID 0x00 141 + #define STMPE811_REG_SYS_CTRL 0x03 142 142 #define STMPE811_REG_SYS_CTRL2 0x04 143 143 #define STMPE811_REG_SPI_CFG 0x08 144 144 #define STMPE811_REG_INT_CTRL 0x09 ··· 156 154 #define STMPE811_REG_GPIO_FE 0x16 157 155 #define STMPE811_REG_GPIO_AF 0x17 158 156 157 + #define STMPE811_SYS_CTRL_RESET (1 << 1) 158 + 159 159 #define STMPE811_SYS_CTRL2_ADC_OFF (1 << 0) 160 160 #define STMPE811_SYS_CTRL2_TSC_OFF (1 << 1) 161 161 #define STMPE811_SYS_CTRL2_GPIO_OFF (1 << 2) 162 162 #define STMPE811_SYS_CTRL2_TS_OFF (1 << 3) 163 + 164 + /* 165 + * STMPE1600 166 + */ 167 + #define STMPE1600_ID 0x0016 168 + #define STMPE1600_NR_INTERNAL_IRQS 16 169 + 170 + #define STMPE1600_REG_CHIP_ID 0x00 171 + #define STMPE1600_REG_SYS_CTRL 0x03 172 + #define STMPE1600_REG_IEGPIOR_LSB 0x08 173 + #define STMPE1600_REG_IEGPIOR_MSB 0x09 174 + #define STMPE1600_REG_ISGPIOR_LSB 0x0A 175 + #define STMPE1600_REG_ISGPIOR_MSB 0x0B 176 + #define STMPE1600_REG_GPMR_LSB 0x10 177 + #define STMPE1600_REG_GPMR_MSB 0x11 178 + #define STMPE1600_REG_GPSR_LSB 0x12 179 + #define STMPE1600_REG_GPSR_MSB 0x13 180 + #define STMPE1600_REG_GPDR_LSB 0x14 181 + #define STMPE1600_REG_GPDR_MSB 0x15 182 + #define STMPE1600_REG_GPPIR_LSB 0x16 183 + #define STMPE1600_REG_GPPIR_MSB 0x17 163 184 164 185 /* 165 186 * STMPE1601 ··· 200 175 201 176 #define STMPE1601_REG_SYS_CTRL 0x02 202 177 #define STMPE1601_REG_SYS_CTRL2 0x03 178 + #define STMPE1601_REG_ICR_MSB 0x10 203 179 #define STMPE1601_REG_ICR_LSB 0x11 180 + #define STMPE1601_REG_IER_MSB 0x12 204 181 #define STMPE1601_REG_IER_LSB 0x13 205 182 #define STMPE1601_REG_ISR_MSB 0x14 206 - #define STMPE1601_REG_CHIP_ID 0x80 183 + #define STMPE1601_REG_ISR_LSB 0x15 184 + #define STMPE1601_REG_INT_EN_GPIO_MASK_MSB 0x16 207 185 #define STMPE1601_REG_INT_EN_GPIO_MASK_LSB 0x17 208 186 #define STMPE1601_REG_INT_STA_GPIO_MSB 0x18 209 - #define STMPE1601_REG_GPIO_MP_LSB 0x87 187 + #define STMPE1601_REG_INT_STA_GPIO_LSB 0x19 188 + #define STMPE1601_REG_CHIP_ID 0x80 189 + #define STMPE1601_REG_GPIO_SET_MSB 0x82 210 190 #define STMPE1601_REG_GPIO_SET_LSB 0x83 191 + #define STMPE1601_REG_GPIO_CLR_MSB 0x84 211 192 #define STMPE1601_REG_GPIO_CLR_LSB 0x85 193 + #define STMPE1601_REG_GPIO_MP_MSB 0x86 194 + #define STMPE1601_REG_GPIO_MP_LSB 0x87 195 + #define STMPE1601_REG_GPIO_SET_DIR_MSB 0x88 212 196 #define STMPE1601_REG_GPIO_SET_DIR_LSB 0x89 213 197 #define STMPE1601_REG_GPIO_ED_MSB 0x8A 198 + #define STMPE1601_REG_GPIO_ED_LSB 0x8B 199 + #define STMPE1601_REG_GPIO_RE_MSB 0x8C 214 200 #define STMPE1601_REG_GPIO_RE_LSB 0x8D 201 + #define STMPE1601_REG_GPIO_FE_MSB 0x8E 215 202 #define STMPE1601_REG_GPIO_FE_LSB 0x8F 203 + #define STMPE1601_REG_GPIO_PU_MSB 0x90 216 204 #define STMPE1601_REG_GPIO_PU_LSB 0x91 217 205 #define STMPE1601_REG_GPIO_AF_U_MSB 0x92 218 206 ··· 281 243 #define STMPE1801_REG_GPIO_PULL_UP_MID 0x23 282 244 #define STMPE1801_REG_GPIO_PULL_UP_HIGH 0x24 283 245 284 - #define STMPE1801_MSK_SYS_CTRL_RESET (1 << 7) 285 - 286 246 #define STMPE1801_MSK_INT_EN_KPC (1 << 1) 287 247 #define STMPE1801_MSK_INT_EN_GPIO (1 << 3) 288 248 ··· 300 264 #define STMPE24XX_NR_INTERNAL_IRQS 9 301 265 302 266 #define STMPE24XX_REG_SYS_CTRL 0x02 267 + #define STMPE24XX_REG_SYS_CTRL2 0x03 268 + #define STMPE24XX_REG_ICR_MSB 0x10 303 269 #define STMPE24XX_REG_ICR_LSB 0x11 270 + #define STMPE24XX_REG_IER_MSB 0x12 304 271 #define STMPE24XX_REG_IER_LSB 0x13 305 272 #define STMPE24XX_REG_ISR_MSB 0x14 306 - #define STMPE24XX_REG_CHIP_ID 0x80 273 + #define STMPE24XX_REG_ISR_LSB 0x15 274 + #define STMPE24XX_REG_IEGPIOR_MSB 0x16 275 + #define STMPE24XX_REG_IEGPIOR_CSB 0x17 307 276 #define STMPE24XX_REG_IEGPIOR_LSB 0x18 308 277 #define STMPE24XX_REG_ISGPIOR_MSB 0x19 309 - #define STMPE24XX_REG_GPMR_LSB 0xA4 278 + #define STMPE24XX_REG_ISGPIOR_CSB 0x1A 279 + #define STMPE24XX_REG_ISGPIOR_LSB 0x1B 280 + #define STMPE24XX_REG_CHIP_ID 0x80 281 + #define STMPE24XX_REG_GPSR_MSB 0x83 282 + #define STMPE24XX_REG_GPSR_CSB 0x84 310 283 #define STMPE24XX_REG_GPSR_LSB 0x85 284 + #define STMPE24XX_REG_GPCR_MSB 0x86 285 + #define STMPE24XX_REG_GPCR_CSB 0x87 311 286 #define STMPE24XX_REG_GPCR_LSB 0x88 287 + #define STMPE24XX_REG_GPDR_MSB 0x89 288 + #define STMPE24XX_REG_GPDR_CSB 0x8A 312 289 #define STMPE24XX_REG_GPDR_LSB 0x8B 313 290 #define STMPE24XX_REG_GPEDR_MSB 0x8C 291 + #define STMPE24XX_REG_GPEDR_CSB 0x8D 292 + #define STMPE24XX_REG_GPEDR_LSB 0x8E 293 + #define STMPE24XX_REG_GPRER_MSB 0x8F 294 + #define STMPE24XX_REG_GPRER_CSB 0x90 314 295 #define STMPE24XX_REG_GPRER_LSB 0x91 296 + #define STMPE24XX_REG_GPFER_MSB 0x92 297 + #define STMPE24XX_REG_GPFER_CSB 0x93 315 298 #define STMPE24XX_REG_GPFER_LSB 0x94 299 + #define STMPE24XX_REG_GPPUR_MSB 0x95 300 + #define STMPE24XX_REG_GPPUR_CSB 0x96 316 301 #define STMPE24XX_REG_GPPUR_LSB 0x97 317 - #define STMPE24XX_REG_GPPDR_LSB 0x9a 302 + #define STMPE24XX_REG_GPPDR_MSB 0x98 303 + #define STMPE24XX_REG_GPPDR_CSB 0x99 304 + #define STMPE24XX_REG_GPPDR_LSB 0x9A 318 305 #define STMPE24XX_REG_GPAFR_U_MSB 0x9B 319 - 306 + #define STMPE24XX_REG_GPMR_MSB 0xA2 307 + #define STMPE24XX_REG_GPMR_CSB 0xA3 308 + #define STMPE24XX_REG_GPMR_LSB 0xA4 320 309 #define STMPE24XX_SYS_CTRL_ENABLE_GPIO (1 << 3) 321 310 #define STMPE24XX_SYSCON_ENABLE_PWM (1 << 2) 322 311 #define STMPE24XX_SYS_CTRL_ENABLE_KPC (1 << 1)
-1
drivers/pinctrl/sunxi/pinctrl-sunxi.c
··· 29 29 #include <linux/slab.h> 30 30 31 31 #include "../core.h" 32 - #include "../../gpio/gpiolib.h" 33 32 #include "pinctrl-sunxi.h" 34 33 35 34 static struct irq_chip sunxi_pinctrl_edge_irq_chip;
+1 -1
drivers/regulator/Kconfig
··· 323 323 324 324 config REGULATOR_LP873X 325 325 tristate "TI LP873X Power regulators" 326 - depends on MFD_LP873X && OF 326 + depends on MFD_TI_LP873X && OF 327 327 help 328 328 This driver supports LP873X voltage regulator chips. LP873X 329 329 provides two step-down converters and two general-purpose LDO
+1 -1
include/linux/gpio/driver.h
··· 3 3 4 4 #include <linux/device.h> 5 5 #include <linux/types.h> 6 - #include <linux/module.h> 7 6 #include <linux/irq.h> 8 7 #include <linux/irqchip/chained_irq.h> 9 8 #include <linux/irqdomain.h> ··· 15 16 struct device_node; 16 17 struct seq_file; 17 18 struct gpio_device; 19 + struct module; 18 20 19 21 #ifdef CONFIG_GPIOLIB 20 22
include/linux/mfd/htc-egpio.h include/linux/platform_data/gpio-htc-egpio.h
+269
include/linux/mfd/lp873x.h
··· 1 + /* 2 + * Functions to access LP873X power management chip. 3 + * 4 + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License as 8 + * published by the Free Software Foundation version 2. 9 + * 10 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 11 + * kind, whether express or implied; without even the implied warranty 12 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + #ifndef __LINUX_MFD_LP873X_H 17 + #define __LINUX_MFD_LP873X_H 18 + 19 + #include <linux/i2c.h> 20 + #include <linux/regulator/driver.h> 21 + #include <linux/regulator/machine.h> 22 + 23 + /* LP873x chip id list */ 24 + #define LP873X 0x00 25 + 26 + /* All register addresses */ 27 + #define LP873X_REG_DEV_REV 0X00 28 + #define LP873X_REG_OTP_REV 0X01 29 + #define LP873X_REG_BUCK0_CTRL_1 0X02 30 + #define LP873X_REG_BUCK0_CTRL_2 0X03 31 + #define LP873X_REG_BUCK1_CTRL_1 0X04 32 + #define LP873X_REG_BUCK1_CTRL_2 0X05 33 + #define LP873X_REG_BUCK0_VOUT 0X06 34 + #define LP873X_REG_BUCK1_VOUT 0X07 35 + #define LP873X_REG_LDO0_CTRL 0X08 36 + #define LP873X_REG_LDO1_CTRL 0X09 37 + #define LP873X_REG_LDO0_VOUT 0X0A 38 + #define LP873X_REG_LDO1_VOUT 0X0B 39 + #define LP873X_REG_BUCK0_DELAY 0X0C 40 + #define LP873X_REG_BUCK1_DELAY 0X0D 41 + #define LP873X_REG_LDO0_DELAY 0X0E 42 + #define LP873X_REG_LDO1_DELAY 0X0F 43 + #define LP873X_REG_GPO_DELAY 0X10 44 + #define LP873X_REG_GPO2_DELAY 0X11 45 + #define LP873X_REG_GPO_CTRL 0X12 46 + #define LP873X_REG_CONFIG 0X13 47 + #define LP873X_REG_PLL_CTRL 0X14 48 + #define LP873X_REG_PGOOD_CTRL1 0X15 49 + #define LP873X_REG_PGOOD_CTRL2 0X16 50 + #define LP873X_REG_PG_FAULT 0X17 51 + #define LP873X_REG_RESET 0X18 52 + #define LP873X_REG_INT_TOP_1 0X19 53 + #define LP873X_REG_INT_TOP_2 0X1A 54 + #define LP873X_REG_INT_BUCK 0X1B 55 + #define LP873X_REG_INT_LDO 0X1C 56 + #define LP873X_REG_TOP_STAT 0X1D 57 + #define LP873X_REG_BUCK_STAT 0X1E 58 + #define LP873X_REG_LDO_STAT 0x1F 59 + #define LP873X_REG_TOP_MASK_1 0x20 60 + #define LP873X_REG_TOP_MASK_2 0x21 61 + #define LP873X_REG_BUCK_MASK 0x22 62 + #define LP873X_REG_LDO_MASK 0x23 63 + #define LP873X_REG_SEL_I_LOAD 0x24 64 + #define LP873X_REG_I_LOAD_2 0x25 65 + #define LP873X_REG_I_LOAD_1 0x26 66 + 67 + #define LP873X_REG_MAX LP873X_REG_I_LOAD_1 68 + 69 + /* Register field definitions */ 70 + #define LP873X_DEV_REV_DEV_ID 0xC0 71 + #define LP873X_DEV_REV_ALL_LAYER 0x30 72 + #define LP873X_DEV_REV_METAL_LAYER 0x0F 73 + 74 + #define LP873X_OTP_REV_OTP_ID 0xFF 75 + 76 + #define LP873X_BUCK0_CTRL_1_BUCK0_FPWM BIT(3) 77 + #define LP873X_BUCK0_CTRL_1_BUCK0_RDIS_EN BIT(2) 78 + #define LP873X_BUCK0_CTRL_1_BUCK0_EN_PIN_CTRL BIT(1) 79 + #define LP873X_BUCK0_CTRL_1_BUCK0_EN BIT(0) 80 + 81 + #define LP873X_BUCK0_CTRL_2_BUCK0_ILIM 0x38 82 + #define LP873X_BUCK0_CTRL_2_BUCK0_SLEW_RATE 0x07 83 + 84 + #define LP873X_BUCK1_CTRL_1_BUCK1_FPWM BIT(3) 85 + #define LP873X_BUCK1_CTRL_1_BUCK1_RDIS_EN BIT(2) 86 + #define LP873X_BUCK1_CTRL_1_BUCK1_EN_PIN_CTRL BIT(1) 87 + #define LP873X_BUCK1_CTRL_1_BUCK1_EN BIT(0) 88 + 89 + #define LP873X_BUCK1_CTRL_2_BUCK1_ILIM 0x38 90 + #define LP873X_BUCK1_CTRL_2_BUCK1_SLEW_RATE 0x07 91 + 92 + #define LP873X_BUCK0_VOUT_BUCK0_VSET 0xFF 93 + 94 + #define LP873X_BUCK1_VOUT_BUCK1_VSET 0xFF 95 + 96 + #define LP873X_LDO0_CTRL_LDO0_RDIS_EN BIT(2) 97 + #define LP873X_LDO0_CTRL_LDO0_EN_PIN_CTRL BIT(1) 98 + #define LP873X_LDO0_CTRL_LDO0_EN BIT(0) 99 + 100 + #define LP873X_LDO1_CTRL_LDO1_RDIS_EN BIT(2) 101 + #define LP873X_LDO1_CTRL_LDO1_EN_PIN_CTRL BIT(1) 102 + #define LP873X_LDO1_CTRL_LDO1_EN BIT(0) 103 + 104 + #define LP873X_LDO0_VOUT_LDO0_VSET 0x1F 105 + 106 + #define LP873X_LDO1_VOUT_LDO1_VSET 0x1F 107 + 108 + #define LP873X_BUCK0_DELAY_BUCK0_SD_DELAY 0xF0 109 + #define LP873X_BUCK0_DELAY_BUCK0_SU_DELAY 0x0F 110 + 111 + #define LP873X_BUCK1_DELAY_BUCK1_SD_DELAY 0xF0 112 + #define LP873X_BUCK1_DELAY_BUCK1_SU_DELAY 0x0F 113 + 114 + #define LP873X_LDO0_DELAY_LDO0_SD_DELAY 0xF0 115 + #define LP873X_LDO0_DELAY_LDO0_SU_DELAY 0x0F 116 + 117 + #define LP873X_LDO1_DELAY_LDO1_SD_DELAY 0xF0 118 + #define LP873X_LDO1_DELAY_LDO1_SU_DELAY 0x0F 119 + 120 + #define LP873X_GPO_DELAY_GPO_SD_DELAY 0xF0 121 + #define LP873X_GPO_DELAY_GPO_SU_DELAY 0x0F 122 + 123 + #define LP873X_GPO2_DELAY_GPO2_SD_DELAY 0xF0 124 + #define LP873X_GPO2_DELAY_GPO2_SU_DELAY 0x0F 125 + 126 + #define LP873X_GPO_CTRL_GPO2_OD BIT(6) 127 + #define LP873X_GPO_CTRL_GPO2_EN_PIN_CTRL BIT(5) 128 + #define LP873X_GPO_CTRL_GPO2_EN BIT(4) 129 + #define LP873X_GPO_CTRL_GPO_OD BIT(2) 130 + #define LP873X_GPO_CTRL_GPO_EN_PIN_CTRL BIT(1) 131 + #define LP873X_GPO_CTRL_GPO_EN BIT(0) 132 + 133 + #define LP873X_CONFIG_SU_DELAY_SEL BIT(6) 134 + #define LP873X_CONFIG_SD_DELAY_SEL BIT(5) 135 + #define LP873X_CONFIG_CLKIN_PIN_SEL BIT(4) 136 + #define LP873X_CONFIG_CLKIN_PD BIT(3) 137 + #define LP873X_CONFIG_EN_PD BIT(2) 138 + #define LP873X_CONFIG_TDIE_WARN_LEVEL BIT(1) 139 + #define LP873X_EN_SPREAD_SPEC BIT(0) 140 + 141 + #define LP873X_PLL_CTRL_EN_PLL BIT(6) 142 + #define LP873X_EXT_CLK_FREQ 0x1F 143 + 144 + #define LP873X_PGOOD_CTRL1_PGOOD_POL BIT(7) 145 + #define LP873X_PGOOD_CTRL1_PGOOD_OD BIT(6) 146 + #define LP873X_PGOOD_CTRL1_PGOOD_WINDOW_LDO BIT(5) 147 + #define LP873X_PGOOD_CTRL1_PGOOD_WINDOWN_BUCK BIT(4) 148 + #define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO1 BIT(3) 149 + #define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_LDO0 BIT(2) 150 + #define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK1 BIT(1) 151 + #define LP873X_PGOOD_CTRL1_PGOOD_EN_PGOOD_BUCK0 BIT(0) 152 + 153 + #define LP873X_PGOOD_CTRL2_EN_PGOOD_TWARN BIT(2) 154 + #define LP873X_PGOOD_CTRL2_EN_PG_FAULT_GATE BIT(1) 155 + #define LP873X_PGOOD_CTRL2_PGOOD_MODE BIT(0) 156 + 157 + #define LP873X_PG_FAULT_PG_FAULT_LDO1 BIT(3) 158 + #define LP873X_PG_FAULT_PG_FAULT_LDO0 BIT(2) 159 + #define LP873X_PG_FAULT_PG_FAULT_BUCK1 BIT(1) 160 + #define LP873X_PG_FAULT_PG_FAULT_BUCK0 BIT(0) 161 + 162 + #define LP873X_RESET_SW_RESET BIT(0) 163 + 164 + #define LP873X_INT_TOP_1_PGOOD_INT BIT(7) 165 + #define LP873X_INT_TOP_1_LDO_INT BIT(6) 166 + #define LP873X_INT_TOP_1_BUCK_INT BIT(5) 167 + #define LP873X_INT_TOP_1_SYNC_CLK_INT BIT(4) 168 + #define LP873X_INT_TOP_1_TDIE_SD_INT BIT(3) 169 + #define LP873X_INT_TOP_1_TDIE_WARN_INT BIT(2) 170 + #define LP873X_INT_TOP_1_OVP_INT BIT(1) 171 + #define LP873X_INT_TOP_1_I_MEAS_INT BIT(0) 172 + 173 + #define LP873X_INT_TOP_2_RESET_REG_INT BIT(0) 174 + 175 + #define LP873X_INT_BUCK_BUCK1_PG_INT BIT(6) 176 + #define LP873X_INT_BUCK_BUCK1_SC_INT BIT(5) 177 + #define LP873X_INT_BUCK_BUCK1_ILIM_INT BIT(4) 178 + #define LP873X_INT_BUCK_BUCK0_PG_INT BIT(2) 179 + #define LP873X_INT_BUCK_BUCK0_SC_INT BIT(1) 180 + #define LP873X_INT_BUCK_BUCK0_ILIM_INT BIT(0) 181 + 182 + #define LP873X_INT_LDO_LDO1_PG_INT BIT(6) 183 + #define LP873X_INT_LDO_LDO1_SC_INT BIT(5) 184 + #define LP873X_INT_LDO_LDO1_ILIM_INT BIT(4) 185 + #define LP873X_INT_LDO_LDO0_PG_INT BIT(2) 186 + #define LP873X_INT_LDO_LDO0_SC_INT BIT(1) 187 + #define LP873X_INT_LDO_LDO0_ILIM_INT BIT(0) 188 + 189 + #define LP873X_TOP_STAT_PGOOD_STAT BIT(7) 190 + #define LP873X_TOP_STAT_SYNC_CLK_STAT BIT(4) 191 + #define LP873X_TOP_STAT_TDIE_SD_STAT BIT(3) 192 + #define LP873X_TOP_STAT_TDIE_WARN_STAT BIT(2) 193 + #define LP873X_TOP_STAT_OVP_STAT BIT(1) 194 + 195 + #define LP873X_BUCK_STAT_BUCK1_STAT BIT(7) 196 + #define LP873X_BUCK_STAT_BUCK1_PG_STAT BIT(6) 197 + #define LP873X_BUCK_STAT_BUCK1_ILIM_STAT BIT(4) 198 + #define LP873X_BUCK_STAT_BUCK0_STAT BIT(3) 199 + #define LP873X_BUCK_STAT_BUCK0_PG_STAT BIT(2) 200 + #define LP873X_BUCK_STAT_BUCK0_ILIM_STAT BIT(0) 201 + 202 + #define LP873X_LDO_STAT_LDO1_STAT BIT(7) 203 + #define LP873X_LDO_STAT_LDO1_PG_STAT BIT(6) 204 + #define LP873X_LDO_STAT_LDO1_ILIM_STAT BIT(4) 205 + #define LP873X_LDO_STAT_LDO0_STAT BIT(3) 206 + #define LP873X_LDO_STAT_LDO0_PG_STAT BIT(2) 207 + #define LP873X_LDO_STAT_LDO0_ILIM_STAT BIT(0) 208 + 209 + #define LP873X_TOP_MASK_1_PGOOD_INT_MASK BIT(7) 210 + #define LP873X_TOP_MASK_1_SYNC_CLK_MASK BIT(4) 211 + #define LP873X_TOP_MASK_1_TDIE_WARN_MASK BIT(2) 212 + #define LP873X_TOP_MASK_1_I_MEAS_MASK BIT(0) 213 + 214 + #define LP873X_TOP_MASK_2_RESET_REG_MASK BIT(0) 215 + 216 + #define LP873X_BUCK_MASK_BUCK1_PGF_MASK BIT(7) 217 + #define LP873X_BUCK_MASK_BUCK1_PGR_MASK BIT(6) 218 + #define LP873X_BUCK_MASK_BUCK1_ILIM_MASK BIT(4) 219 + #define LP873X_BUCK_MASK_BUCK0_PGF_MASK BIT(3) 220 + #define LP873X_BUCK_MASK_BUCK0_PGR_MASK BIT(2) 221 + #define LP873X_BUCK_MASK_BUCK0_ILIM_MASK BIT(0) 222 + 223 + #define LP873X_LDO_MASK_LDO1_PGF_MASK BIT(7) 224 + #define LP873X_LDO_MASK_LDO1_PGR_MASK BIT(6) 225 + #define LP873X_LDO_MASK_LDO1_ILIM_MASK BIT(4) 226 + #define LP873X_LDO_MASK_LDO0_PGF_MASK BIT(3) 227 + #define LP873X_LDO_MASK_LDO0_PGR_MASK BIT(2) 228 + #define LP873X_LDO_MASK_LDO0_ILIM_MASK BIT(0) 229 + 230 + #define LP873X_SEL_I_LOAD_CURRENT_BUCK_SELECT BIT(0) 231 + 232 + #define LP873X_I_LOAD_2_BUCK_LOAD_CURRENT BIT(0) 233 + 234 + #define LP873X_I_LOAD_1_BUCK_LOAD_CURRENT 0xFF 235 + 236 + #define LP873X_MAX_REG_ID LP873X_LDO_1 237 + 238 + /* Number of step-down converters available */ 239 + #define LP873X_NUM_BUCK 2 240 + /* Number of LDO voltage regulators available */ 241 + #define LP873X_NUM_LDO 2 242 + /* Number of total regulators available */ 243 + #define LP873X_NUM_REGULATOR (LP873X_NUM_BUCK + LP873X_NUM_LDO) 244 + 245 + enum lp873x_regulator_id { 246 + /* BUCK's */ 247 + LP873X_BUCK_0, 248 + LP873X_BUCK_1, 249 + /* LDOs */ 250 + LP873X_LDO_0, 251 + LP873X_LDO_1, 252 + }; 253 + 254 + /** 255 + * struct lp873x - state holder for the lp873x driver 256 + * @dev: struct device pointer for MFD device 257 + * @rev: revision of the lp873x 258 + * @lock: lock guarding the data structure 259 + * @regmap: register map of the lp873x PMIC 260 + * 261 + * Device data may be used to access the LP873X chip 262 + */ 263 + struct lp873x { 264 + struct device *dev; 265 + u8 rev; 266 + struct mutex lock; /* lock guarding the data structure */ 267 + struct regmap *regmap; 268 + }; 269 + #endif /* __LINUX_MFD_LP873X_H */
+21
include/linux/mfd/stmpe.h
··· 26 26 STMPE610, 27 27 STMPE801, 28 28 STMPE811, 29 + STMPE1600, 29 30 STMPE1601, 30 31 STMPE1801, 31 32 STMPE2401, ··· 40 39 */ 41 40 enum { 42 41 STMPE_IDX_CHIP_ID, 42 + STMPE_IDX_SYS_CTRL, 43 + STMPE_IDX_SYS_CTRL2, 43 44 STMPE_IDX_ICR_LSB, 44 45 STMPE_IDX_IER_LSB, 46 + STMPE_IDX_IER_MSB, 45 47 STMPE_IDX_ISR_LSB, 46 48 STMPE_IDX_ISR_MSB, 47 49 STMPE_IDX_GPMR_LSB, 50 + STMPE_IDX_GPMR_CSB, 51 + STMPE_IDX_GPMR_MSB, 48 52 STMPE_IDX_GPSR_LSB, 53 + STMPE_IDX_GPSR_CSB, 54 + STMPE_IDX_GPSR_MSB, 49 55 STMPE_IDX_GPCR_LSB, 56 + STMPE_IDX_GPCR_CSB, 57 + STMPE_IDX_GPCR_MSB, 50 58 STMPE_IDX_GPDR_LSB, 59 + STMPE_IDX_GPDR_CSB, 60 + STMPE_IDX_GPDR_MSB, 61 + STMPE_IDX_GPEDR_LSB, 62 + STMPE_IDX_GPEDR_CSB, 51 63 STMPE_IDX_GPEDR_MSB, 52 64 STMPE_IDX_GPRER_LSB, 65 + STMPE_IDX_GPRER_CSB, 66 + STMPE_IDX_GPRER_MSB, 53 67 STMPE_IDX_GPFER_LSB, 68 + STMPE_IDX_GPFER_CSB, 69 + STMPE_IDX_GPFER_MSB, 54 70 STMPE_IDX_GPPUR_LSB, 55 71 STMPE_IDX_GPPDR_LSB, 56 72 STMPE_IDX_GPAFR_U_MSB, 57 73 STMPE_IDX_IEGPIOR_LSB, 74 + STMPE_IDX_IEGPIOR_CSB, 75 + STMPE_IDX_IEGPIOR_MSB, 58 76 STMPE_IDX_ISGPIOR_LSB, 77 + STMPE_IDX_ISGPIOR_CSB, 59 78 STMPE_IDX_ISGPIOR_MSB, 60 79 STMPE_IDX_MAX, 61 80 };
-5
include/linux/of_gpio.h
··· 61 61 } 62 62 extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc); 63 63 64 - extern int of_gpiochip_add(struct gpio_chip *gc); 65 - extern void of_gpiochip_remove(struct gpio_chip *gc); 66 64 extern int of_gpio_simple_xlate(struct gpio_chip *gc, 67 65 const struct of_phandle_args *gpiospec, 68 66 u32 *flags); ··· 83 85 { 84 86 return -ENOSYS; 85 87 } 86 - 87 - static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; } 88 - static inline void of_gpiochip_remove(struct gpio_chip *gc) { } 89 88 90 89 #endif /* CONFIG_OF_GPIO */ 91 90
-50
include/linux/platform_data/gpio-lpc32xx.h
··· 1 - /* 2 - * Author: Kevin Wells <kevin.wells@nxp.com> 3 - * 4 - * Copyright (C) 2010 NXP Semiconductors 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 as published by 8 - * the Free Software Foundation; either version 2 of the License, or 9 - * (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU General Public License for more details. 15 - */ 16 - 17 - #ifndef __MACH_GPIO_LPC32XX_H 18 - #define __MACH_GPIO_LPC32XX_H 19 - 20 - /* 21 - * Note! 22 - * Muxed GP pins need to be setup to the GP state in the board level 23 - * code prior to using this driver. 24 - * GPI pins : 28xP3 group 25 - * GPO pins : 24xP3 group 26 - * GPIO pins: 8xP0 group, 24xP1 group, 13xP2 group, 6xP3 group 27 - */ 28 - 29 - #define LPC32XX_GPIO_P0_MAX 8 30 - #define LPC32XX_GPIO_P1_MAX 24 31 - #define LPC32XX_GPIO_P2_MAX 13 32 - #define LPC32XX_GPIO_P3_MAX 6 33 - #define LPC32XX_GPI_P3_MAX 29 34 - #define LPC32XX_GPO_P3_MAX 24 35 - 36 - #define LPC32XX_GPIO_P0_GRP 0 37 - #define LPC32XX_GPIO_P1_GRP (LPC32XX_GPIO_P0_GRP + LPC32XX_GPIO_P0_MAX) 38 - #define LPC32XX_GPIO_P2_GRP (LPC32XX_GPIO_P1_GRP + LPC32XX_GPIO_P1_MAX) 39 - #define LPC32XX_GPIO_P3_GRP (LPC32XX_GPIO_P2_GRP + LPC32XX_GPIO_P2_MAX) 40 - #define LPC32XX_GPI_P3_GRP (LPC32XX_GPIO_P3_GRP + LPC32XX_GPIO_P3_MAX) 41 - #define LPC32XX_GPO_P3_GRP (LPC32XX_GPI_P3_GRP + LPC32XX_GPI_P3_MAX) 42 - 43 - /* 44 - * A specific GPIO can be selected with this macro 45 - * ie, GPIO_05 can be selected with LPC32XX_GPIO(LPC32XX_GPIO_P3_GRP, 5) 46 - * See the LPC32x0 User's guide for GPIO group numbers 47 - */ 48 - #define LPC32XX_GPIO(x, y) ((x) + (y)) 49 - 50 - #endif /* __MACH_GPIO_LPC32XX_H */