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

Merge tag 'gpio-v4.13-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.13 series.

Some administrativa:

I have a slew of 8250 serial patches and the new IOT2040 serial+GPIO
driver coming in through this tree, along with a whole bunch of Exar
8250 fixes. These are ACKed by Greg and also hit drivers/platform/*
where they are ACKed by Andy Shevchenko.

Speaking about drivers/platform/* there is also a bunch of ACPI stuff
coming through that route, again ACKed by Andy.

The MCP23S08 changes are coming in here as well. You already have the
commits in your tree, so this is just a result of sharing an immutable
branch between pin control and GPIO.

Core:
- Export add/remove for lookup tables so that modules can export GPIO
descriptor tables.
- Handle GPIO sleep states: it is now possible to flag that a GPIO
line may loose its state during suspend/resume of the system to
save power. This is used in the Wolfson Micro Arizona driver.
- ACPI-based GPIO was tightened up a lot around the edges.
- Use bitmap_fill() to speed up a loop.

New drivers:
- Exar XRA1403 SPI-based GPIO.
- MVEBU driver now supports Armada 7K and 8K.
- LP87565 PMIC GPIO.
- Renesas R-CAR R8A7743 (RZ/G1M).
- The new IOT2040 8250 serial/GPIO also comes in through this
changeset.

Substantial driver changes:
- Seriously fix the Exar 8250 GPIO portions to work.
- The MCP23S08 was moved out to a pin control driver.
- Convert MEVEBU to use regmap for register access.
- Drop Vulcan support from the Broadcom driver.
- Serious cleanup and improvement of the mockup driver, giving us a
better test coverage.

Misc:
- Lots of janitorial clean up.
- A bunch of documentation fixes"

* tag 'gpio-v4.13-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (70 commits)
serial: exar: Add support for IOT2040 device
gpio-exar/8250-exar: Make set of exported GPIOs configurable
platform: Accept const properties
serial: exar: Factor out platform hooks
gpio-exar/8250-exar: Rearrange gpiochip parenthood
gpio: exar: Fix iomap request
gpio-exar/8250-exar: Do not even instantiate a GPIO device for Commtech cards
serial: uapi: Add support for bus termination
gpio: rcar: Add R8A7743 (RZ/G1M) support
gpio: gpio-wcove: Fix GPIO control register offset calculation
gpio: lp87565: Add support for GPIO
gpio: dwapb: fix missing first irq for edgeboth irq type
MAINTAINERS: Take maintainership for GPIO ACPI support
gpio: exar: Fix reading of directions and values
gpio: exar: Allocate resources on behalf of the platform device
gpio-exar/8250-exar: Fix passing in of parent PCI device
gpio: mockup: use devm_kcalloc() where applicable
gpio: mockup: add myself as author
gpio: mockup: improve the error message
gpio: mockup: don't return magic numbers from probe()
...

+1514 -466
+65
Documentation/acpi/gpio-properties.txt
··· 156 156 routine. On removal, the driver should unregister its GPIO mapping table by 157 157 calling acpi_dev_remove_driver_gpios() on the ACPI device object where that 158 158 table was previously registered. 159 + 160 + Using the _CRS fallback 161 + ----------------------- 162 + 163 + If a device does not have _DSD or the driver does not create ACPI GPIO 164 + mapping, the Linux GPIO framework refuses to return any GPIOs. This is 165 + because the driver does not know what it actually gets. For example if we 166 + have a device like below: 167 + 168 + Device (BTH) 169 + { 170 + Name (_HID, ...) 171 + 172 + Name (_CRS, ResourceTemplate () { 173 + GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone, 174 + "\\_SB.GPO0", 0, ResourceConsumer) {15} 175 + GpioIo (Exclusive, PullNone, 0, 0, IoRestrictionNone, 176 + "\\_SB.GPO0", 0, ResourceConsumer) {27} 177 + }) 178 + } 179 + 180 + The driver might expect to get the right GPIO when it does: 181 + 182 + desc = gpiod_get(dev, "reset", GPIOD_OUT_LOW); 183 + 184 + but since there is no way to know the mapping between "reset" and 185 + the GpioIo() in _CRS desc will hold ERR_PTR(-ENOENT). 186 + 187 + The driver author can solve this by passing the mapping explictly 188 + (the recommended way and documented in the above chapter). 189 + 190 + The ACPI GPIO mapping tables should not contaminate drivers that are not 191 + knowing about which exact device they are servicing on. It implies that 192 + the ACPI GPIO mapping tables are hardly linked to ACPI ID and certain 193 + objects, as listed in the above chapter, of the device in question. 194 + 195 + Getting GPIO descriptor 196 + ----------------------- 197 + 198 + There are two main approaches to get GPIO resource from ACPI: 199 + desc = gpiod_get(dev, connection_id, flags); 200 + desc = gpiod_get_index(dev, connection_id, index, flags); 201 + 202 + We may consider two different cases here, i.e. when connection ID is 203 + provided and otherwise. 204 + 205 + Case 1: 206 + desc = gpiod_get(dev, "non-null-connection-id", flags); 207 + desc = gpiod_get_index(dev, "non-null-connection-id", index, flags); 208 + 209 + Case 2: 210 + desc = gpiod_get(dev, NULL, flags); 211 + desc = gpiod_get_index(dev, NULL, index, flags); 212 + 213 + Case 1 assumes that corresponding ACPI device description must have 214 + defined device properties and will prevent to getting any GPIO resources 215 + otherwise. 216 + 217 + Case 2 explicitly tells GPIO core to look for resources in _CRS. 218 + 219 + Be aware that gpiod_get_index() in cases 1 and 2, assuming that there 220 + are two versions of ACPI device description provided and no mapping is 221 + present in the driver, will return different resources. That's why a 222 + certain driver has to handle them carefully as explained in previous 223 + chapter.
+8 -5
Documentation/devicetree/bindings/gpio/gpio.txt
··· 74 74 Optional standard bitfield specifiers for the last cell: 75 75 76 76 - Bit 0: 0 means active high, 1 means active low 77 - - Bit 1: 1 means single-ended wiring, see: 77 + - Bit 1: 0 mean push-pull wiring, see: 78 + https://en.wikipedia.org/wiki/Push-pull_output 79 + 1 means single-ended wiring, see: 78 80 https://en.wikipedia.org/wiki/Single-ended_triode 79 - When used with active-low, this means open drain/collector, see: 81 + - Bit 2: 0 means open-source, 1 means open drain, see: 80 82 https://en.wikipedia.org/wiki/Open_collector 81 - When used with active-high, this means open source/emitter 83 + - Bit 3: 0 means the output should be maintained during sleep/low-power mode 84 + 1 means the output state can be lost during sleep/low-power mode 82 85 83 86 1.1) GPIO specifier best practices 84 87 ---------------------------------- ··· 285 282 }; 286 283 287 284 Here, a single GPIO controller has GPIOs 0..9 routed to pin controller 288 - pinctrl1's pins 20..29, and GPIOs 10..19 routed to pin controller pinctrl2's 289 - pins 50..59. 285 + pinctrl1's pins 20..29, and GPIOs 10..29 routed to pin controller pinctrl2's 286 + pins 50..69. 290 287 291 288 Example 2: 292 289
+1
Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
··· 3 3 Required Properties: 4 4 5 5 - compatible: should contain one of the following. 6 + - "renesas,gpio-r8a7743": for R8A7743 (RZ/G1M) compatible GPIO controller. 6 7 - "renesas,gpio-r8a7778": for R8A7778 (R-Mobile M1) compatible GPIO controller. 7 8 - "renesas,gpio-r8a7779": for R8A7779 (R-Car H1) compatible GPIO controller. 8 9 - "renesas,gpio-r8a7790": for R8A7790 (R-Car H2) compatible GPIO controller.
+24
MAINTAINERS
··· 5747 5747 F: include/uapi/linux/gpio.h 5748 5748 F: tools/gpio/ 5749 5749 5750 + GPIO ACPI SUPPORT 5751 + M: Mika Westerberg <mika.westerberg@linux.intel.com> 5752 + M: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 5753 + L: linux-gpio@vger.kernel.org 5754 + L: linux-acpi@vger.kernel.org 5755 + S: Maintained 5756 + F: Documentation/acpi/gpio-properties.txt 5757 + F: drivers/gpio/gpiolib-acpi.c 5758 + 5750 5759 GRE DEMULTIPLEXER DRIVER 5751 5760 M: Dmitry Kozlov <xeb@mail.ru> 5752 5761 L: netdev@vger.kernel.org ··· 12035 12026 F: drivers/media/platform/davinci/ 12036 12027 F: include/media/davinci/ 12037 12028 12029 + TI DAVINCI SERIES GPIO DRIVER 12030 + M: Keerthy <j-keerthy@ti.com> 12031 + L: linux-gpio@vger.kernel.org 12032 + S: Maintained 12033 + F: Documentation/devicetree/bindings/gpio/gpio-davinci.txt 12034 + F: drivers/gpio/gpio-davinci.c 12035 + 12038 12036 TI AM437X VPFE DRIVER 12039 12037 M: "Lad, Prabhakar" <prabhakar.csengg@gmail.com> 12040 12038 L: linux-media@vger.kernel.org ··· 14353 14337 L: linux-kernel@vger.kernel.org 14354 14338 S: Supported 14355 14339 F: drivers/char/xillybus/ 14340 + 14341 + XRA1403 GPIO EXPANDER 14342 + M: Nandor Han <nandor.han@ge.com> 14343 + M: Semi Malinen <semi.malinen@ge.com> 14344 + L: linux-gpio@vger.kernel.org 14345 + S: Maintained 14346 + F: drivers/gpio/gpio-xra1403.c 14347 + F: Documentation/devicetree/bindings/gpio/gpio-xra1403.txt 14356 14348 14357 14349 XTENSA XTFPGA PLATFORM SUPPORT 14358 14350 M: Max Filippov <jcmvbkbc@gmail.com>
+1 -1
arch/arm/mach-davinci/board-da830-evm.c
··· 17 17 #include <linux/gpio/machine.h> 18 18 #include <linux/platform_device.h> 19 19 #include <linux/i2c.h> 20 - #include <linux/i2c/pcf857x.h> 20 + #include <linux/platform_data/pcf857x.h> 21 21 #include <linux/platform_data/at24.h> 22 22 #include <linux/mtd/mtd.h> 23 23 #include <linux/mtd/partitions.h>
+1 -1
arch/arm/mach-davinci/board-dm644x-evm.c
··· 14 14 #include <linux/platform_device.h> 15 15 #include <linux/gpio.h> 16 16 #include <linux/i2c.h> 17 - #include <linux/i2c/pcf857x.h> 17 + #include <linux/platform_data/pcf857x.h> 18 18 #include <linux/platform_data/at24.h> 19 19 #include <linux/mtd/mtd.h> 20 20 #include <linux/mtd/nand.h>
+1 -1
arch/arm/mach-davinci/board-dm646x-evm.c
··· 23 23 #include <linux/platform_device.h> 24 24 #include <linux/i2c.h> 25 25 #include <linux/platform_data/at24.h> 26 - #include <linux/i2c/pcf857x.h> 26 + #include <linux/platform_data/pcf857x.h> 27 27 28 28 #include <media/i2c/tvp514x.h> 29 29 #include <media/i2c/adv7343.h>
+1 -1
arch/arm/mach-pxa/balloon3.c
··· 27 27 #include <linux/mtd/mtd.h> 28 28 #include <linux/mtd/partitions.h> 29 29 #include <linux/types.h> 30 - #include <linux/i2c/pcf857x.h> 30 + #include <linux/platform_data/pcf857x.h> 31 31 #include <linux/i2c/pxa-i2c.h> 32 32 #include <linux/mtd/nand.h> 33 33 #include <linux/mtd/physmap.h>
+1 -1
arch/arm/mach-pxa/littleton.c
··· 27 27 #include <linux/i2c.h> 28 28 #include <linux/leds.h> 29 29 #include <linux/mfd/da903x.h> 30 - #include <linux/i2c/max732x.h> 30 + #include <linux/platform_data/max732x.h> 31 31 #include <linux/i2c/pxa-i2c.h> 32 32 33 33 #include <asm/types.h>
+1 -1
arch/arm/mach-pxa/stargate2.c
··· 26 26 #include <linux/mtd/partitions.h> 27 27 28 28 #include <linux/i2c/pxa-i2c.h> 29 - #include <linux/i2c/pcf857x.h> 29 + #include <linux/platform_data/pcf857x.h> 30 30 #include <linux/platform_data/at24.h> 31 31 #include <linux/smc91x.h> 32 32 #include <linux/gpio.h>
+1 -1
arch/blackfin/mach-bf537/boards/stamp.c
··· 22 22 #include <linux/usb/isp1362.h> 23 23 #endif 24 24 #include <linux/i2c.h> 25 - #include <linux/i2c/adp5588.h> 25 + #include <linux/platform_data/adp5588.h> 26 26 #include <linux/etherdevice.h> 27 27 #include <linux/ata_platform.h> 28 28 #include <linux/irq.h>
+1 -1
arch/mips/ath79/mach-pb44.c
··· 12 12 #include <linux/platform_device.h> 13 13 #include <linux/i2c.h> 14 14 #include <linux/i2c-gpio.h> 15 - #include <linux/i2c/pcf857x.h> 15 + #include <linux/platform_data/pcf857x.h> 16 16 17 17 #include "machtypes.h" 18 18 #include "dev-gpio-buttons.h"
+1 -1
drivers/base/platform.c
··· 344 344 * platform device is released. 345 345 */ 346 346 int platform_device_add_properties(struct platform_device *pdev, 347 - struct property_entry *properties) 347 + const struct property_entry *properties) 348 348 { 349 349 return device_add_properties(&pdev->dev, properties); 350 350 }
+21 -3
drivers/gpio/Kconfig
··· 337 337 338 338 config GPIO_MVEBU 339 339 def_bool y 340 - depends on PLAT_ORION 340 + depends on PLAT_ORION || ARCH_MVEBU 341 341 depends on OF_GPIO 342 342 select GENERIC_IRQ_CHIP 343 + select REGMAP_MMIO 343 344 344 345 config GPIO_MXC 345 346 def_bool y ··· 516 515 517 516 config GPIO_XLP 518 517 tristate "Netlogic XLP GPIO support" 519 - depends on OF_GPIO && (CPU_XLP || ARCH_VULCAN || ARCH_THUNDER2 || COMPILE_TEST) 518 + depends on OF_GPIO && (CPU_XLP || ARCH_THUNDER2 || COMPILE_TEST) 520 519 select GPIOLIB_IRQCHIP 521 520 help 522 521 This driver provides support for GPIO interface on Netlogic XLP MIPS64 523 522 SoCs. Currently supported XLP variants are XLP8XX, XLP3XX, XLP2XX, 524 - XLP9XX and XLP5XX. 523 + XLP9XX and XLP5XX. The same GPIO controller block is also present in 524 + Cavium's ThunderX2 CN99XX SoCs. 525 525 526 526 If unsure, say N. 527 527 ··· 965 963 This driver can also be built as a module. If so, the module will be 966 964 called gpio-lp873x. 967 965 966 + config GPIO_LP87565 967 + tristate "TI LP87565 GPIO" 968 + depends on MFD_TI_LP87565 969 + help 970 + This driver supports the GPIO on TI Lp873565 PMICs. 3 GPIOs are present 971 + on LP87565 PMICs. 972 + 973 + This driver can also be built as a module. If so, the module will be 974 + called gpio-lp87565. 975 + 968 976 config GPIO_MAX77620 969 977 tristate "GPIO support for PMIC MAX77620 and MAX20024" 970 978 depends on MFD_MAX77620 ··· 1247 1235 help 1248 1236 GPIO driver for SPI compatible parallel-in/serial-out shift 1249 1237 registers. These are input only devices. 1238 + 1239 + config GPIO_XRA1403 1240 + tristate "EXAR XRA1403 16-bit GPIO expander" 1241 + select REGMAP_SPI 1242 + help 1243 + GPIO driver for EXAR XRA1403 16-bit SPI-based GPIO expander. 1250 1244 1251 1245 endmenu 1252 1246
+2
drivers/gpio/Makefile
··· 67 67 obj-$(CONFIG_GPIO_LPC18XX) += gpio-lpc18xx.o 68 68 obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o 69 69 obj-$(CONFIG_GPIO_LP873X) += gpio-lp873x.o 70 + obj-$(CONFIG_GPIO_LP87565) += gpio-lp87565.o 70 71 obj-$(CONFIG_GPIO_LYNXPOINT) += gpio-lynxpoint.o 71 72 obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o 72 73 obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o ··· 142 141 obj-$(CONFIG_GPIO_XGENE_SB) += gpio-xgene-sb.o 143 142 obj-$(CONFIG_GPIO_XILINX) += gpio-xilinx.o 144 143 obj-$(CONFIG_GPIO_XLP) += gpio-xlp.o 144 + obj-$(CONFIG_GPIO_XRA1403) += gpio-xra1403.o 145 145 obj-$(CONFIG_GPIO_XTENSA) += gpio-xtensa.o 146 146 obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o 147 147 obj-$(CONFIG_GPIO_ZYNQ) += gpio-zynq.o
+1 -1
drivers/gpio/gpio-adp5588.c
··· 16 16 #include <linux/interrupt.h> 17 17 #include <linux/irq.h> 18 18 19 - #include <linux/i2c/adp5588.h> 19 + #include <linux/platform_data/adp5588.h> 20 20 21 21 #define DRV_NAME "adp5588-gpio" 22 22
+33 -2
drivers/gpio/gpio-arizona.c
··· 33 33 { 34 34 struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip); 35 35 struct arizona *arizona = arizona_gpio->arizona; 36 + bool persistent = gpiochip_line_is_persistent(chip, offset); 37 + bool change; 38 + int ret; 36 39 37 - return regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset, 38 - ARIZONA_GPN_DIR, ARIZONA_GPN_DIR); 40 + ret = regmap_update_bits_check(arizona->regmap, 41 + ARIZONA_GPIO1_CTRL + offset, 42 + ARIZONA_GPN_DIR, ARIZONA_GPN_DIR, 43 + &change); 44 + if (ret < 0) 45 + return ret; 46 + 47 + if (change && persistent) { 48 + pm_runtime_mark_last_busy(chip->parent); 49 + pm_runtime_put_autosuspend(chip->parent); 50 + } 51 + 52 + return 0; 39 53 } 40 54 41 55 static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset) ··· 99 85 { 100 86 struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip); 101 87 struct arizona *arizona = arizona_gpio->arizona; 88 + bool persistent = gpiochip_line_is_persistent(chip, offset); 89 + unsigned int val; 90 + int ret; 91 + 92 + ret = regmap_read(arizona->regmap, ARIZONA_GPIO1_CTRL + offset, &val); 93 + if (ret < 0) 94 + return ret; 95 + 96 + if ((val & ARIZONA_GPN_DIR) && persistent) { 97 + ret = pm_runtime_get_sync(chip->parent); 98 + if (ret < 0) { 99 + dev_err(chip->parent, "Failed to resume: %d\n", ret); 100 + return ret; 101 + } 102 + } 102 103 103 104 if (value) 104 105 value = ARIZONA_GPN_LVL; ··· 186 157 arizona_gpio->gpio_chip.base = pdata->gpio_base; 187 158 else 188 159 arizona_gpio->gpio_chip.base = -1; 160 + 161 + pm_runtime_enable(&pdev->dev); 189 162 190 163 ret = devm_gpiochip_add_data(&pdev->dev, &arizona_gpio->gpio_chip, 191 164 arizona_gpio);
+9 -2
drivers/gpio/gpio-davinci.c
··· 437 437 { 438 438 unsigned gpio, bank; 439 439 int irq; 440 + int ret; 440 441 struct clk *clk; 441 442 u32 binten = 0; 442 443 unsigned ngpio, bank_irq; ··· 481 480 PTR_ERR(clk)); 482 481 return PTR_ERR(clk); 483 482 } 484 - clk_prepare_enable(clk); 483 + ret = clk_prepare_enable(clk); 484 + if (ret) 485 + return ret; 485 486 486 487 if (!pdata->gpio_unbanked) { 487 488 irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0); 488 489 if (irq < 0) { 489 490 dev_err(dev, "Couldn't allocate IRQ numbers\n"); 491 + clk_disable_unprepare(clk); 490 492 return irq; 491 493 } 492 494 ··· 498 494 chips); 499 495 if (!irq_domain) { 500 496 dev_err(dev, "Couldn't register an IRQ domain\n"); 497 + clk_disable_unprepare(clk); 501 498 return -ENODEV; 502 499 } 503 500 } ··· 567 562 sizeof(struct 568 563 davinci_gpio_irq_data), 569 564 GFP_KERNEL); 570 - if (!irqdata) 565 + if (!irqdata) { 566 + clk_disable_unprepare(clk); 571 567 return -ENOMEM; 568 + } 572 569 573 570 irqdata->regs = g; 574 571 irqdata->bank_num = bank;
+2 -1
drivers/gpio/gpio-dwapb.c
··· 288 288 irq_setup_alt_chip(d, type); 289 289 290 290 dwapb_write(gpio, GPIO_INTTYPE_LEVEL, level); 291 - dwapb_write(gpio, GPIO_INT_POLARITY, polarity); 291 + if (type != IRQ_TYPE_EDGE_BOTH) 292 + dwapb_write(gpio, GPIO_INT_POLARITY, polarity); 292 293 spin_unlock_irqrestore(&gc->bgpio_lock, flags); 293 294 294 295 return 0;
+41 -38
drivers/gpio/gpio-exar.c
··· 31 31 int index; 32 32 void __iomem *regs; 33 33 char name[20]; 34 + unsigned int first_pin; 34 35 }; 35 36 36 37 static void exar_update(struct gpio_chip *chip, unsigned int reg, int val, ··· 52 51 static int exar_set_direction(struct gpio_chip *chip, int direction, 53 52 unsigned int offset) 54 53 { 55 - unsigned int bank = offset / 8; 56 - unsigned int addr; 54 + struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); 55 + unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? 56 + EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO; 57 + unsigned int bit = (offset + exar_gpio->first_pin) % 8; 57 58 58 - addr = bank ? EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO; 59 - exar_update(chip, addr, direction, offset % 8); 59 + exar_update(chip, addr, direction, bit); 60 60 return 0; 61 61 } 62 62 ··· 70 68 value = readb(exar_gpio->regs + reg); 71 69 mutex_unlock(&exar_gpio->lock); 72 70 73 - return !!value; 71 + return value; 74 72 } 75 73 76 74 static int exar_get_direction(struct gpio_chip *chip, unsigned int offset) 77 75 { 78 - unsigned int bank = offset / 8; 79 - unsigned int addr; 80 - int val; 76 + struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); 77 + unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? 78 + EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO; 79 + unsigned int bit = (offset + exar_gpio->first_pin) % 8; 81 80 82 - addr = bank ? EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO; 83 - val = exar_get(chip, addr) >> (offset % 8); 84 - 85 - return !!val; 81 + return !!(exar_get(chip, addr) & BIT(bit)); 86 82 } 87 83 88 84 static int exar_get_value(struct gpio_chip *chip, unsigned int offset) 89 85 { 90 - unsigned int bank = offset / 8; 91 - unsigned int addr; 92 - int val; 86 + struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); 87 + unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? 88 + EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO; 89 + unsigned int bit = (offset + exar_gpio->first_pin) % 8; 93 90 94 - addr = bank ? EXAR_OFFSET_MPIOLVL_LO : EXAR_OFFSET_MPIOLVL_HI; 95 - val = exar_get(chip, addr) >> (offset % 8); 96 - 97 - return !!val; 91 + return !!(exar_get(chip, addr) & BIT(bit)); 98 92 } 99 93 100 94 static void exar_set_value(struct gpio_chip *chip, unsigned int offset, 101 95 int value) 102 96 { 103 - unsigned int bank = offset / 8; 104 - unsigned int addr; 97 + struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip); 98 + unsigned int addr = (offset + exar_gpio->first_pin) / 8 ? 99 + EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO; 100 + unsigned int bit = (offset + exar_gpio->first_pin) % 8; 105 101 106 - addr = bank ? EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO; 107 - exar_update(chip, addr, value, offset % 8); 102 + exar_update(chip, addr, value, bit); 108 103 } 109 104 110 105 static int exar_direction_output(struct gpio_chip *chip, unsigned int offset, ··· 118 119 119 120 static int gpio_exar_probe(struct platform_device *pdev) 120 121 { 121 - struct pci_dev *pcidev = platform_get_drvdata(pdev); 122 + struct pci_dev *pcidev = to_pci_dev(pdev->dev.parent); 122 123 struct exar_gpio_chip *exar_gpio; 124 + u32 first_pin, ngpios; 123 125 void __iomem *p; 124 126 int index, ret; 125 127 126 - if (pcidev->vendor != PCI_VENDOR_ID_EXAR) 127 - return -ENODEV; 128 - 129 128 /* 130 - * Map the pci device to get the register addresses. 131 - * We will need to read and write those registers to control 132 - * the GPIO pins. 133 - * Using managed functions will save us from unmaping on exit. 134 - * As the device is enabled using managed functions by the 135 - * UART driver we can also use managed functions here. 129 + * The UART driver must have mapped region 0 prior to registering this 130 + * device - use it. 136 131 */ 137 - p = pcim_iomap(pcidev, 0, 0); 132 + p = pcim_iomap_table(pcidev)[0]; 138 133 if (!p) 139 134 return -ENOMEM; 140 135 141 - exar_gpio = devm_kzalloc(&pcidev->dev, sizeof(*exar_gpio), GFP_KERNEL); 136 + ret = device_property_read_u32(&pdev->dev, "linux,first-pin", 137 + &first_pin); 138 + if (ret) 139 + return ret; 140 + 141 + ret = device_property_read_u32(&pdev->dev, "ngpios", &ngpios); 142 + if (ret) 143 + return ret; 144 + 145 + exar_gpio = devm_kzalloc(&pdev->dev, sizeof(*exar_gpio), GFP_KERNEL); 142 146 if (!exar_gpio) 143 147 return -ENOMEM; 144 148 ··· 151 149 152 150 sprintf(exar_gpio->name, "exar_gpio%d", index); 153 151 exar_gpio->gpio_chip.label = exar_gpio->name; 154 - exar_gpio->gpio_chip.parent = &pcidev->dev; 152 + exar_gpio->gpio_chip.parent = &pdev->dev; 155 153 exar_gpio->gpio_chip.direction_output = exar_direction_output; 156 154 exar_gpio->gpio_chip.direction_input = exar_direction_input; 157 155 exar_gpio->gpio_chip.get_direction = exar_get_direction; 158 156 exar_gpio->gpio_chip.get = exar_get_value; 159 157 exar_gpio->gpio_chip.set = exar_set_value; 160 158 exar_gpio->gpio_chip.base = -1; 161 - exar_gpio->gpio_chip.ngpio = 16; 159 + exar_gpio->gpio_chip.ngpio = ngpios; 162 160 exar_gpio->regs = p; 163 161 exar_gpio->index = index; 162 + exar_gpio->first_pin = first_pin; 164 163 165 - ret = devm_gpiochip_add_data(&pcidev->dev, 164 + ret = devm_gpiochip_add_data(&pdev->dev, 166 165 &exar_gpio->gpio_chip, exar_gpio); 167 166 if (ret) 168 167 goto err_destroy;
+190
drivers/gpio/gpio-lp87565.c
··· 1 + /* 2 + * Copyright (C) 2017 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 LP873X driver 15 + */ 16 + 17 + #include <linux/gpio/driver.h> 18 + #include <linux/module.h> 19 + #include <linux/platform_device.h> 20 + #include <linux/regmap.h> 21 + 22 + #include <linux/mfd/lp87565.h> 23 + 24 + struct lp87565_gpio { 25 + struct gpio_chip chip; 26 + struct regmap *map; 27 + }; 28 + 29 + static int lp87565_gpio_get_direction(struct gpio_chip *chip, 30 + unsigned int offset) 31 + { 32 + struct lp87565_gpio *gpio = gpiochip_get_data(chip); 33 + int ret, val; 34 + 35 + ret = regmap_read(gpio->map, LP87565_REG_GPIO_CONFIG, &val); 36 + if (ret < 0) 37 + return ret; 38 + 39 + return !(val & BIT(offset)); 40 + } 41 + 42 + static int lp87565_gpio_direction_input(struct gpio_chip *chip, 43 + unsigned int offset) 44 + { 45 + struct lp87565_gpio *gpio = gpiochip_get_data(chip); 46 + 47 + return regmap_update_bits(gpio->map, 48 + LP87565_REG_GPIO_CONFIG, 49 + BIT(offset), 0); 50 + } 51 + 52 + static int lp87565_gpio_direction_output(struct gpio_chip *chip, 53 + unsigned int offset, int value) 54 + { 55 + struct lp87565_gpio *gpio = gpiochip_get_data(chip); 56 + 57 + return regmap_update_bits(gpio->map, 58 + LP87565_REG_GPIO_CONFIG, 59 + BIT(offset), !value ? BIT(offset) : 0); 60 + } 61 + 62 + static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset) 63 + { 64 + struct lp87565_gpio *gpio = gpiochip_get_data(chip); 65 + int ret, val; 66 + 67 + ret = regmap_read(gpio->map, LP87565_REG_GPIO_IN, &val); 68 + if (ret < 0) 69 + return ret; 70 + 71 + return !!(val & BIT(offset)); 72 + } 73 + 74 + static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset, 75 + int value) 76 + { 77 + struct lp87565_gpio *gpio = gpiochip_get_data(chip); 78 + 79 + regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT, 80 + BIT(offset), value ? BIT(offset) : 0); 81 + } 82 + 83 + static int lp87565_gpio_request(struct gpio_chip *gc, unsigned int offset) 84 + { 85 + struct lp87565_gpio *gpio = gpiochip_get_data(gc); 86 + int ret; 87 + 88 + switch (offset) { 89 + case 0: 90 + case 1: 91 + case 2: 92 + /* 93 + * MUX can program the pin to be in EN1/2/3 pin mode 94 + * Or GPIO1/2/3 mode. 95 + * Setup the GPIO*_SEL MUX to GPIO mode 96 + */ 97 + ret = regmap_update_bits(gpio->map, 98 + LP87565_REG_PIN_FUNCTION, 99 + BIT(offset), BIT(offset)); 100 + if (ret) 101 + return ret; 102 + 103 + break; 104 + default: 105 + return -EINVAL; 106 + } 107 + 108 + return 0; 109 + } 110 + 111 + static int lp87565_gpio_set_config(struct gpio_chip *gc, unsigned int offset, 112 + unsigned long config) 113 + { 114 + struct lp87565_gpio *gpio = gpiochip_get_data(gc); 115 + 116 + switch (pinconf_to_config_param(config)) { 117 + case PIN_CONFIG_DRIVE_OPEN_DRAIN: 118 + return regmap_update_bits(gpio->map, 119 + LP87565_REG_GPIO_CONFIG, 120 + BIT(offset + 121 + __ffs(LP87565_GOIO1_OD)), 122 + BIT(offset + 123 + __ffs(LP87565_GOIO1_OD))); 124 + case PIN_CONFIG_DRIVE_PUSH_PULL: 125 + return regmap_update_bits(gpio->map, 126 + LP87565_REG_GPIO_CONFIG, 127 + BIT(offset + 128 + __ffs(LP87565_GOIO1_OD)), 0); 129 + default: 130 + return -ENOTSUPP; 131 + } 132 + } 133 + 134 + static const struct gpio_chip template_chip = { 135 + .label = "lp87565-gpio", 136 + .owner = THIS_MODULE, 137 + .request = lp87565_gpio_request, 138 + .get_direction = lp87565_gpio_get_direction, 139 + .direction_input = lp87565_gpio_direction_input, 140 + .direction_output = lp87565_gpio_direction_output, 141 + .get = lp87565_gpio_get, 142 + .set = lp87565_gpio_set, 143 + .set_config = lp87565_gpio_set_config, 144 + .base = -1, 145 + .ngpio = 3, 146 + .can_sleep = true, 147 + }; 148 + 149 + static int lp87565_gpio_probe(struct platform_device *pdev) 150 + { 151 + struct lp87565_gpio *gpio; 152 + struct lp87565 *lp87565; 153 + int ret; 154 + 155 + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); 156 + if (!gpio) 157 + return -ENOMEM; 158 + 159 + lp87565 = dev_get_drvdata(pdev->dev.parent); 160 + gpio->chip = template_chip; 161 + gpio->chip.parent = lp87565->dev; 162 + gpio->map = lp87565->regmap; 163 + 164 + ret = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); 165 + if (ret < 0) { 166 + dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret); 167 + return ret; 168 + } 169 + 170 + return 0; 171 + } 172 + 173 + static const struct platform_device_id lp87565_gpio_id_table[] = { 174 + { "lp87565-q1-gpio", }, 175 + { /* sentinel */ } 176 + }; 177 + MODULE_DEVICE_TABLE(platform, lp87565_gpio_id_table); 178 + 179 + static struct platform_driver lp87565_gpio_driver = { 180 + .driver = { 181 + .name = "lp87565-gpio", 182 + }, 183 + .probe = lp87565_gpio_probe, 184 + .id_table = lp87565_gpio_id_table, 185 + }; 186 + module_platform_driver(lp87565_gpio_driver); 187 + 188 + MODULE_AUTHOR("Keerthy <j-keerthy@ti.com>"); 189 + MODULE_DESCRIPTION("LP87565 GPIO driver"); 190 + MODULE_LICENSE("GPL v2");
+1 -1
drivers/gpio/gpio-max732x.c
··· 20 20 #include <linux/gpio/driver.h> 21 21 #include <linux/interrupt.h> 22 22 #include <linux/i2c.h> 23 - #include <linux/i2c/max732x.h> 23 + #include <linux/platform_data/max732x.h> 24 24 #include <linux/of.h> 25 25 26 26
-1
drivers/gpio/gpio-merrifield.c
··· 11 11 12 12 #include <linux/bitops.h> 13 13 #include <linux/gpio/driver.h> 14 - #include <linux/gpio.h> 15 14 #include <linux/init.h> 16 15 #include <linux/interrupt.h> 17 16 #include <linux/io.h>
+13 -3
drivers/gpio/gpio-ml-ioh.c
··· 385 385 return ret; 386 386 } 387 387 388 - static void ioh_gpio_alloc_generic_chip(struct ioh_gpio *chip, 389 - unsigned int irq_start, unsigned int num) 388 + static int ioh_gpio_alloc_generic_chip(struct ioh_gpio *chip, 389 + unsigned int irq_start, 390 + unsigned int num) 390 391 { 391 392 struct irq_chip_generic *gc; 392 393 struct irq_chip_type *ct; 393 394 394 395 gc = irq_alloc_generic_chip("ioh_gpio", 1, irq_start, chip->base, 395 396 handle_simple_irq); 397 + if (!gc) 398 + return -ENOMEM; 399 + 396 400 gc->private = chip; 397 401 ct = gc->chip_types; 398 402 ··· 408 404 409 405 irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE, 410 406 IRQ_NOREQUEST | IRQ_NOPROBE, 0); 407 + 408 + return 0; 411 409 } 412 410 413 411 static int ioh_gpio_probe(struct pci_dev *pdev, ··· 474 468 goto err_gpiochip_add; 475 469 } 476 470 chip->irq_base = irq_base; 477 - ioh_gpio_alloc_generic_chip(chip, irq_base, num_ports[j]); 471 + 472 + ret = ioh_gpio_alloc_generic_chip(chip, 473 + irq_base, num_ports[j]); 474 + if (ret) 475 + goto err_gpiochip_add; 478 476 } 479 477 480 478 chip = chip_save;
+56 -42
drivers/gpio/gpio-mockup.c
··· 3 3 * 4 4 * Copyright (C) 2014 Kamlakant Patel <kamlakant.patel@broadcom.com> 5 5 * Copyright (C) 2015-2016 Bamvor Jian Zhang <bamvor.zhangjian@linaro.org> 6 + * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl> 6 7 * 7 8 * This program is free software; you can redistribute it and/or modify it 8 9 * under the terms of the GNU General Public License as published by the ··· 28 27 29 28 #define GPIO_MOCKUP_NAME "gpio-mockup" 30 29 #define GPIO_MOCKUP_MAX_GC 10 30 + /* 31 + * We're storing two values per chip: the GPIO base and the number 32 + * of GPIO lines. 33 + */ 34 + #define GPIO_MOCKUP_MAX_RANGES (GPIO_MOCKUP_MAX_GC * 2) 31 35 32 36 enum { 33 - DIR_IN = 0, 34 - DIR_OUT, 37 + GPIO_MOCKUP_DIR_OUT = 0, 38 + GPIO_MOCKUP_DIR_IN = 1, 35 39 }; 36 40 37 41 /* ··· 47 41 struct gpio_mockup_line_status { 48 42 int dir; 49 43 bool value; 44 + bool irq_enabled; 50 45 }; 51 46 52 47 struct gpio_mockup_irq_context { ··· 68 61 int offset; 69 62 }; 70 63 71 - static int gpio_mockup_ranges[GPIO_MOCKUP_MAX_GC << 1]; 64 + static int gpio_mockup_ranges[GPIO_MOCKUP_MAX_RANGES]; 72 65 static int gpio_mockup_params_nr; 73 66 module_param_array(gpio_mockup_ranges, int, &gpio_mockup_params_nr, 0400); 74 67 ··· 100 93 struct gpio_mockup_chip *chip = gpiochip_get_data(gc); 101 94 102 95 gpio_mockup_set(gc, offset, value); 103 - chip->lines[offset].dir = DIR_OUT; 96 + chip->lines[offset].dir = GPIO_MOCKUP_DIR_OUT; 104 97 105 98 return 0; 106 99 } ··· 109 102 { 110 103 struct gpio_mockup_chip *chip = gpiochip_get_data(gc); 111 104 112 - chip->lines[offset].dir = DIR_IN; 105 + chip->lines[offset].dir = GPIO_MOCKUP_DIR_IN; 113 106 114 107 return 0; 115 108 } ··· 128 121 char **names; 129 122 int i; 130 123 131 - names = devm_kzalloc(dev, sizeof(char *) * gc->ngpio, GFP_KERNEL); 124 + names = devm_kcalloc(dev, gc->ngpio, sizeof(char *), GFP_KERNEL); 132 125 if (!names) 133 126 return -ENOMEM; 134 127 ··· 149 142 return chip->irq_base + offset; 150 143 } 151 144 152 - /* 153 - * While we should generally support irqmask and irqunmask, this driver is 154 - * for testing purposes only so we don't care. 155 - */ 156 - static void gpio_mockup_irqmask(struct irq_data *d) { } 157 - static void gpio_mockup_irqunmask(struct irq_data *d) { } 145 + static void gpio_mockup_irqmask(struct irq_data *data) 146 + { 147 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 148 + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); 149 + 150 + chip->lines[data->irq - gc->irq_base].irq_enabled = false; 151 + } 152 + 153 + static void gpio_mockup_irqunmask(struct irq_data *data) 154 + { 155 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 156 + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); 157 + 158 + chip->lines[data->irq - gc->irq_base].irq_enabled = true; 159 + } 158 160 159 161 static struct irq_chip gpio_mockup_irqchip = { 160 162 .name = GPIO_MOCKUP_NAME, ··· 194 178 195 179 for (i = 0; i < gc->ngpio; i++) { 196 180 irq_set_chip(irq_base + i, gc->irqchip); 181 + irq_set_chip_data(irq_base + i, gc); 197 182 irq_set_handler(irq_base + i, &handle_simple_irq); 198 183 irq_modify_status(irq_base + i, 199 184 IRQ_NOREQUEST | IRQ_NOAUTOEN, IRQ_NOPROBE); ··· 214 197 struct seq_file *sfile; 215 198 struct gpio_desc *desc; 216 199 struct gpio_chip *gc; 217 - int val; 218 - char buf; 200 + int rv, val; 201 + 202 + rv = kstrtoint_from_user(usr_buf, size, 0, &val); 203 + if (rv) 204 + return rv; 205 + if (val != 0 && val != 1) 206 + return -EINVAL; 219 207 220 208 sfile = file->private_data; 221 209 priv = sfile->private; ··· 228 206 chip = priv->chip; 229 207 gc = &chip->gc; 230 208 231 - if (copy_from_user(&buf, usr_buf, 1)) 232 - return -EFAULT; 233 - 234 - if (buf == '0') 235 - val = 0; 236 - else if (buf == '1') 237 - val = 1; 238 - else 239 - return -EINVAL; 240 - 241 - gpiod_set_value_cansleep(desc, val); 242 - priv->chip->irq_ctx.irq = gc->irq_base + priv->offset; 243 - irq_work_queue(&priv->chip->irq_ctx.work); 209 + if (chip->lines[priv->offset].irq_enabled) { 210 + gpiod_set_value_cansleep(desc, val); 211 + priv->chip->irq_ctx.irq = gc->irq_base + priv->offset; 212 + irq_work_queue(&priv->chip->irq_ctx.work); 213 + } 244 214 245 215 return size; 246 216 } ··· 308 294 gc->get_direction = gpio_mockup_get_direction; 309 295 gc->to_irq = gpio_mockup_to_irq; 310 296 311 - chip->lines = devm_kzalloc(dev, sizeof(*chip->lines) * gc->ngpio, 312 - GFP_KERNEL); 297 + chip->lines = devm_kcalloc(dev, gc->ngpio, 298 + sizeof(*chip->lines), GFP_KERNEL); 313 299 if (!chip->lines) 314 300 return -ENOMEM; 315 301 ··· 335 321 336 322 static int gpio_mockup_probe(struct platform_device *pdev) 337 323 { 338 - struct gpio_mockup_chip *chips; 324 + int ret, i, base, ngpio, num_chips; 339 325 struct device *dev = &pdev->dev; 340 - int ret, i, base, ngpio; 326 + struct gpio_mockup_chip *chips; 341 327 char *chip_name; 342 328 343 - if (gpio_mockup_params_nr < 2) 329 + if (gpio_mockup_params_nr < 2 || (gpio_mockup_params_nr % 2)) 344 330 return -EINVAL; 345 331 346 - chips = devm_kzalloc(dev, 347 - sizeof(*chips) * (gpio_mockup_params_nr >> 1), 348 - GFP_KERNEL); 332 + /* Each chip is described by two values. */ 333 + num_chips = gpio_mockup_params_nr / 2; 334 + 335 + chips = devm_kcalloc(dev, num_chips, sizeof(*chips), GFP_KERNEL); 349 336 if (!chips) 350 337 return -ENOMEM; 351 338 352 339 platform_set_drvdata(pdev, chips); 353 340 354 - for (i = 0; i < gpio_mockup_params_nr >> 1; i++) { 341 + for (i = 0; i < num_chips; i++) { 355 342 base = gpio_mockup_ranges[i * 2]; 356 343 357 344 if (base == -1) ··· 370 355 ret = gpio_mockup_add(dev, &chips[i], 371 356 chip_name, base, ngpio); 372 357 } else { 373 - ret = -1; 358 + ret = -EINVAL; 374 359 } 375 360 376 361 if (ret) { 377 - dev_err(dev, "gpio<%d..%d> add failed\n", 378 - base, base < 0 ? ngpio : base + ngpio); 362 + dev_err(dev, 363 + "adding gpiochip failed: %d (base: %d, ngpio: %d)\n", 364 + ret, base, base < 0 ? ngpio : base + ngpio); 379 365 380 366 return ret; 381 367 } 382 - 383 - dev_info(dev, "gpio<%d..%d> add successful!", 384 - base, base + ngpio); 385 368 } 386 369 387 370 return 0; ··· 433 420 434 421 MODULE_AUTHOR("Kamlakant Patel <kamlakant.patel@broadcom.com>"); 435 422 MODULE_AUTHOR("Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>"); 423 + MODULE_AUTHOR("Bartosz Golaszewski <brgl@bgdev.pl>"); 436 424 MODULE_DESCRIPTION("GPIO Testing driver"); 437 425 MODULE_LICENSE("GPL v2");
+339 -215
drivers/gpio/gpio-mvebu.c
··· 33 33 * interrupts. 34 34 */ 35 35 36 - #include <linux/err.h> 37 - #include <linux/init.h> 38 - #include <linux/gpio.h> 39 - #include <linux/irq.h> 40 - #include <linux/slab.h> 41 - #include <linux/irqdomain.h> 42 - #include <linux/io.h> 43 - #include <linux/of_irq.h> 44 - #include <linux/of_device.h> 45 - #include <linux/pwm.h> 46 - #include <linux/clk.h> 47 - #include <linux/pinctrl/consumer.h> 48 - #include <linux/irqchip/chained_irq.h> 49 - #include <linux/platform_device.h> 50 36 #include <linux/bitops.h> 37 + #include <linux/clk.h> 38 + #include <linux/err.h> 39 + #include <linux/gpio.h> 40 + #include <linux/init.h> 41 + #include <linux/io.h> 42 + #include <linux/irq.h> 43 + #include <linux/irqchip/chained_irq.h> 44 + #include <linux/irqdomain.h> 45 + #include <linux/mfd/syscon.h> 46 + #include <linux/of_device.h> 47 + #include <linux/of_irq.h> 48 + #include <linux/pinctrl/consumer.h> 49 + #include <linux/platform_device.h> 50 + #include <linux/pwm.h> 51 + #include <linux/regmap.h> 52 + #include <linux/slab.h> 51 53 52 54 #include "gpiolib.h" 53 55 ··· 89 87 #define MVEBU_GPIO_SOC_VARIANT_ORION 0x1 90 88 #define MVEBU_GPIO_SOC_VARIANT_MV78200 0x2 91 89 #define MVEBU_GPIO_SOC_VARIANT_ARMADAXP 0x3 90 + #define MVEBU_GPIO_SOC_VARIANT_A8K 0x4 92 91 93 92 #define MVEBU_MAX_GPIO_PER_BANK 32 94 93 ··· 109 106 110 107 struct mvebu_gpio_chip { 111 108 struct gpio_chip chip; 112 - spinlock_t lock; 113 - void __iomem *membase; 114 - void __iomem *percpu_membase; 109 + struct regmap *regs; 110 + u32 offset; 111 + struct regmap *percpu_regs; 115 112 int irqbase; 116 113 struct irq_domain *domain; 117 114 int soc_variant; ··· 133 130 * Functions returning addresses of individual registers for a given 134 131 * GPIO controller. 135 132 */ 136 - static void __iomem *mvebu_gpioreg_out(struct mvebu_gpio_chip *mvchip) 137 - { 138 - return mvchip->membase + GPIO_OUT_OFF; 139 - } 140 133 141 - static void __iomem *mvebu_gpioreg_blink(struct mvebu_gpio_chip *mvchip) 142 - { 143 - return mvchip->membase + GPIO_BLINK_EN_OFF; 144 - } 145 - 146 - static void __iomem *mvebu_gpioreg_blink_counter_select(struct mvebu_gpio_chip 147 - *mvchip) 148 - { 149 - return mvchip->membase + GPIO_BLINK_CNT_SELECT_OFF; 150 - } 151 - 152 - static void __iomem *mvebu_gpioreg_io_conf(struct mvebu_gpio_chip *mvchip) 153 - { 154 - return mvchip->membase + GPIO_IO_CONF_OFF; 155 - } 156 - 157 - static void __iomem *mvebu_gpioreg_in_pol(struct mvebu_gpio_chip *mvchip) 158 - { 159 - return mvchip->membase + GPIO_IN_POL_OFF; 160 - } 161 - 162 - static void __iomem *mvebu_gpioreg_data_in(struct mvebu_gpio_chip *mvchip) 163 - { 164 - return mvchip->membase + GPIO_DATA_IN_OFF; 165 - } 166 - 167 - static void __iomem *mvebu_gpioreg_edge_cause(struct mvebu_gpio_chip *mvchip) 134 + static void mvebu_gpioreg_edge_cause(struct mvebu_gpio_chip *mvchip, 135 + struct regmap **map, unsigned int *offset) 168 136 { 169 137 int cpu; 170 138 171 139 switch (mvchip->soc_variant) { 172 140 case MVEBU_GPIO_SOC_VARIANT_ORION: 173 141 case MVEBU_GPIO_SOC_VARIANT_MV78200: 174 - return mvchip->membase + GPIO_EDGE_CAUSE_OFF; 142 + case MVEBU_GPIO_SOC_VARIANT_A8K: 143 + *map = mvchip->regs; 144 + *offset = GPIO_EDGE_CAUSE_OFF + mvchip->offset; 145 + break; 175 146 case MVEBU_GPIO_SOC_VARIANT_ARMADAXP: 176 147 cpu = smp_processor_id(); 177 - return mvchip->percpu_membase + 178 - GPIO_EDGE_CAUSE_ARMADAXP_OFF(cpu); 148 + *map = mvchip->percpu_regs; 149 + *offset = GPIO_EDGE_CAUSE_ARMADAXP_OFF(cpu); 150 + break; 179 151 default: 180 152 BUG(); 181 153 } 182 154 } 183 155 184 - static void __iomem *mvebu_gpioreg_edge_mask(struct mvebu_gpio_chip *mvchip) 156 + static u32 157 + mvebu_gpio_read_edge_cause(struct mvebu_gpio_chip *mvchip) 158 + { 159 + struct regmap *map; 160 + unsigned int offset; 161 + u32 val; 162 + 163 + mvebu_gpioreg_edge_cause(mvchip, &map, &offset); 164 + regmap_read(map, offset, &val); 165 + 166 + return val; 167 + } 168 + 169 + static void 170 + mvebu_gpio_write_edge_cause(struct mvebu_gpio_chip *mvchip, u32 val) 171 + { 172 + struct regmap *map; 173 + unsigned int offset; 174 + 175 + mvebu_gpioreg_edge_cause(mvchip, &map, &offset); 176 + regmap_write(map, offset, val); 177 + } 178 + 179 + static inline void 180 + mvebu_gpioreg_edge_mask(struct mvebu_gpio_chip *mvchip, 181 + struct regmap **map, unsigned int *offset) 185 182 { 186 183 int cpu; 187 184 188 185 switch (mvchip->soc_variant) { 189 186 case MVEBU_GPIO_SOC_VARIANT_ORION: 190 - return mvchip->membase + GPIO_EDGE_MASK_OFF; 187 + case MVEBU_GPIO_SOC_VARIANT_A8K: 188 + *map = mvchip->regs; 189 + *offset = GPIO_EDGE_MASK_OFF + mvchip->offset; 190 + break; 191 191 case MVEBU_GPIO_SOC_VARIANT_MV78200: 192 192 cpu = smp_processor_id(); 193 - return mvchip->membase + GPIO_EDGE_MASK_MV78200_OFF(cpu); 193 + *map = mvchip->regs; 194 + *offset = GPIO_EDGE_MASK_MV78200_OFF(cpu); 195 + break; 194 196 case MVEBU_GPIO_SOC_VARIANT_ARMADAXP: 195 197 cpu = smp_processor_id(); 196 - return mvchip->percpu_membase + 197 - GPIO_EDGE_MASK_ARMADAXP_OFF(cpu); 198 + *map = mvchip->percpu_regs; 199 + *offset = GPIO_EDGE_MASK_ARMADAXP_OFF(cpu); 200 + break; 198 201 default: 199 202 BUG(); 200 203 } 201 204 } 202 205 203 - static void __iomem *mvebu_gpioreg_level_mask(struct mvebu_gpio_chip *mvchip) 206 + static u32 207 + mvebu_gpio_read_edge_mask(struct mvebu_gpio_chip *mvchip) 208 + { 209 + struct regmap *map; 210 + unsigned int offset; 211 + u32 val; 212 + 213 + mvebu_gpioreg_edge_mask(mvchip, &map, &offset); 214 + regmap_read(map, offset, &val); 215 + 216 + return val; 217 + } 218 + 219 + static void 220 + mvebu_gpio_write_edge_mask(struct mvebu_gpio_chip *mvchip, u32 val) 221 + { 222 + struct regmap *map; 223 + unsigned int offset; 224 + 225 + mvebu_gpioreg_edge_mask(mvchip, &map, &offset); 226 + regmap_write(map, offset, val); 227 + } 228 + 229 + static void 230 + mvebu_gpioreg_level_mask(struct mvebu_gpio_chip *mvchip, 231 + struct regmap **map, unsigned int *offset) 204 232 { 205 233 int cpu; 206 234 207 235 switch (mvchip->soc_variant) { 208 236 case MVEBU_GPIO_SOC_VARIANT_ORION: 209 - return mvchip->membase + GPIO_LEVEL_MASK_OFF; 237 + case MVEBU_GPIO_SOC_VARIANT_A8K: 238 + *map = mvchip->regs; 239 + *offset = GPIO_LEVEL_MASK_OFF + mvchip->offset; 240 + break; 210 241 case MVEBU_GPIO_SOC_VARIANT_MV78200: 211 242 cpu = smp_processor_id(); 212 - return mvchip->membase + GPIO_LEVEL_MASK_MV78200_OFF(cpu); 243 + *map = mvchip->regs; 244 + *offset = GPIO_LEVEL_MASK_MV78200_OFF(cpu); 245 + break; 213 246 case MVEBU_GPIO_SOC_VARIANT_ARMADAXP: 214 247 cpu = smp_processor_id(); 215 - return mvchip->percpu_membase + 216 - GPIO_LEVEL_MASK_ARMADAXP_OFF(cpu); 248 + *map = mvchip->percpu_regs; 249 + *offset = GPIO_LEVEL_MASK_ARMADAXP_OFF(cpu); 250 + break; 217 251 default: 218 252 BUG(); 219 253 } 254 + } 255 + 256 + static u32 257 + mvebu_gpio_read_level_mask(struct mvebu_gpio_chip *mvchip) 258 + { 259 + struct regmap *map; 260 + unsigned int offset; 261 + u32 val; 262 + 263 + mvebu_gpioreg_level_mask(mvchip, &map, &offset); 264 + regmap_read(map, offset, &val); 265 + 266 + return val; 267 + } 268 + 269 + static void 270 + mvebu_gpio_write_level_mask(struct mvebu_gpio_chip *mvchip, u32 val) 271 + { 272 + struct regmap *map; 273 + unsigned int offset; 274 + 275 + mvebu_gpioreg_level_mask(mvchip, &map, &offset); 276 + regmap_write(map, offset, val); 220 277 } 221 278 222 279 /* ··· 299 236 static void mvebu_gpio_set(struct gpio_chip *chip, unsigned int pin, int value) 300 237 { 301 238 struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); 302 - unsigned long flags; 303 - u32 u; 304 239 305 - spin_lock_irqsave(&mvchip->lock, flags); 306 - u = readl_relaxed(mvebu_gpioreg_out(mvchip)); 307 - if (value) 308 - u |= BIT(pin); 309 - else 310 - u &= ~BIT(pin); 311 - writel_relaxed(u, mvebu_gpioreg_out(mvchip)); 312 - spin_unlock_irqrestore(&mvchip->lock, flags); 240 + regmap_update_bits(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, 241 + BIT(pin), value ? BIT(pin) : 0); 313 242 } 314 243 315 244 static int mvebu_gpio_get(struct gpio_chip *chip, unsigned int pin) ··· 309 254 struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); 310 255 u32 u; 311 256 312 - if (readl_relaxed(mvebu_gpioreg_io_conf(mvchip)) & BIT(pin)) { 313 - u = readl_relaxed(mvebu_gpioreg_data_in(mvchip)) ^ 314 - readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); 257 + regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u); 258 + 259 + if (u & BIT(pin)) { 260 + u32 data_in, in_pol; 261 + 262 + regmap_read(mvchip->regs, GPIO_DATA_IN_OFF + mvchip->offset, 263 + &data_in); 264 + regmap_read(mvchip->regs, GPIO_IN_POL_OFF + mvchip->offset, 265 + &in_pol); 266 + u = data_in ^ in_pol; 315 267 } else { 316 - u = readl_relaxed(mvebu_gpioreg_out(mvchip)); 268 + regmap_read(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, &u); 317 269 } 318 270 319 271 return (u >> pin) & 1; ··· 330 268 int value) 331 269 { 332 270 struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); 333 - unsigned long flags; 334 - u32 u; 335 271 336 - spin_lock_irqsave(&mvchip->lock, flags); 337 - u = readl_relaxed(mvebu_gpioreg_blink(mvchip)); 338 - if (value) 339 - u |= BIT(pin); 340 - else 341 - u &= ~BIT(pin); 342 - writel_relaxed(u, mvebu_gpioreg_blink(mvchip)); 343 - spin_unlock_irqrestore(&mvchip->lock, flags); 272 + regmap_update_bits(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, 273 + BIT(pin), value ? BIT(pin) : 0); 344 274 } 345 275 346 276 static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned int pin) 347 277 { 348 278 struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); 349 - unsigned long flags; 350 279 int ret; 351 - u32 u; 352 280 353 281 /* 354 282 * Check with the pinctrl driver whether this pin is usable as ··· 348 296 if (ret) 349 297 return ret; 350 298 351 - spin_lock_irqsave(&mvchip->lock, flags); 352 - u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)); 353 - u |= BIT(pin); 354 - writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip)); 355 - spin_unlock_irqrestore(&mvchip->lock, flags); 299 + regmap_update_bits(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, 300 + BIT(pin), BIT(pin)); 356 301 357 302 return 0; 358 303 } ··· 358 309 int value) 359 310 { 360 311 struct mvebu_gpio_chip *mvchip = gpiochip_get_data(chip); 361 - unsigned long flags; 362 312 int ret; 363 - u32 u; 364 313 365 314 /* 366 315 * Check with the pinctrl driver whether this pin is usable as ··· 371 324 mvebu_gpio_blink(chip, pin, 0); 372 325 mvebu_gpio_set(chip, pin, value); 373 326 374 - spin_lock_irqsave(&mvchip->lock, flags); 375 - u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)); 376 - u &= ~BIT(pin); 377 - writel_relaxed(u, mvebu_gpioreg_io_conf(mvchip)); 378 - spin_unlock_irqrestore(&mvchip->lock, flags); 327 + regmap_update_bits(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, 328 + BIT(pin), 0); 379 329 380 330 return 0; 381 331 } ··· 394 350 u32 mask = d->mask; 395 351 396 352 irq_gc_lock(gc); 397 - writel_relaxed(~mask, mvebu_gpioreg_edge_cause(mvchip)); 353 + mvebu_gpio_write_edge_cause(mvchip, ~mask); 398 354 irq_gc_unlock(gc); 399 355 } 400 356 ··· 407 363 408 364 irq_gc_lock(gc); 409 365 ct->mask_cache_priv &= ~mask; 410 - 411 - writel_relaxed(ct->mask_cache_priv, mvebu_gpioreg_edge_mask(mvchip)); 366 + mvebu_gpio_write_edge_mask(mvchip, ct->mask_cache_priv); 412 367 irq_gc_unlock(gc); 413 368 } 414 369 ··· 420 377 421 378 irq_gc_lock(gc); 422 379 ct->mask_cache_priv |= mask; 423 - writel_relaxed(ct->mask_cache_priv, mvebu_gpioreg_edge_mask(mvchip)); 380 + mvebu_gpio_write_edge_mask(mvchip, ct->mask_cache_priv); 424 381 irq_gc_unlock(gc); 425 382 } 426 383 ··· 433 390 434 391 irq_gc_lock(gc); 435 392 ct->mask_cache_priv &= ~mask; 436 - writel_relaxed(ct->mask_cache_priv, mvebu_gpioreg_level_mask(mvchip)); 393 + mvebu_gpio_write_level_mask(mvchip, ct->mask_cache_priv); 437 394 irq_gc_unlock(gc); 438 395 } 439 396 ··· 446 403 447 404 irq_gc_lock(gc); 448 405 ct->mask_cache_priv |= mask; 449 - writel_relaxed(ct->mask_cache_priv, mvebu_gpioreg_level_mask(mvchip)); 406 + mvebu_gpio_write_level_mask(mvchip, ct->mask_cache_priv); 450 407 irq_gc_unlock(gc); 451 408 } 452 409 ··· 486 443 487 444 pin = d->hwirq; 488 445 489 - u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)) & BIT(pin); 490 - if (!u) 446 + regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &u); 447 + if ((u & BIT(pin)) == 0) 491 448 return -EINVAL; 492 449 493 450 type &= IRQ_TYPE_SENSE_MASK; ··· 505 462 switch (type) { 506 463 case IRQ_TYPE_EDGE_RISING: 507 464 case IRQ_TYPE_LEVEL_HIGH: 508 - u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); 509 - u &= ~BIT(pin); 510 - writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); 465 + regmap_update_bits(mvchip->regs, 466 + GPIO_IN_POL_OFF + mvchip->offset, 467 + BIT(pin), 0); 511 468 break; 512 469 case IRQ_TYPE_EDGE_FALLING: 513 470 case IRQ_TYPE_LEVEL_LOW: 514 - u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); 515 - u |= BIT(pin); 516 - writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); 471 + regmap_update_bits(mvchip->regs, 472 + GPIO_IN_POL_OFF + mvchip->offset, 473 + BIT(pin), BIT(pin)); 517 474 break; 518 475 case IRQ_TYPE_EDGE_BOTH: { 519 - u32 v; 476 + u32 data_in, in_pol, val; 520 477 521 - v = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)) ^ 522 - readl_relaxed(mvebu_gpioreg_data_in(mvchip)); 478 + regmap_read(mvchip->regs, 479 + GPIO_IN_POL_OFF + mvchip->offset, &in_pol); 480 + regmap_read(mvchip->regs, 481 + GPIO_DATA_IN_OFF + mvchip->offset, &data_in); 523 482 524 483 /* 525 484 * set initial polarity based on current input level 526 485 */ 527 - u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); 528 - if (v & BIT(pin)) 529 - u |= BIT(pin); /* falling */ 486 + if ((data_in ^ in_pol) & BIT(pin)) 487 + val = BIT(pin); /* falling */ 530 488 else 531 - u &= ~BIT(pin); /* rising */ 532 - writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); 489 + val = 0; /* raising */ 490 + 491 + regmap_update_bits(mvchip->regs, 492 + GPIO_IN_POL_OFF + mvchip->offset, 493 + BIT(pin), val); 533 494 break; 534 495 } 535 496 } ··· 544 497 { 545 498 struct mvebu_gpio_chip *mvchip = irq_desc_get_handler_data(desc); 546 499 struct irq_chip *chip = irq_desc_get_chip(desc); 547 - u32 cause, type; 500 + u32 cause, type, data_in, level_mask, edge_cause, edge_mask; 548 501 int i; 549 502 550 503 if (mvchip == NULL) ··· 552 505 553 506 chained_irq_enter(chip, desc); 554 507 555 - cause = readl_relaxed(mvebu_gpioreg_data_in(mvchip)) & 556 - readl_relaxed(mvebu_gpioreg_level_mask(mvchip)); 557 - cause |= readl_relaxed(mvebu_gpioreg_edge_cause(mvchip)) & 558 - readl_relaxed(mvebu_gpioreg_edge_mask(mvchip)); 508 + regmap_read(mvchip->regs, GPIO_DATA_IN_OFF + mvchip->offset, &data_in); 509 + level_mask = mvebu_gpio_read_level_mask(mvchip); 510 + edge_cause = mvebu_gpio_read_edge_cause(mvchip); 511 + edge_mask = mvebu_gpio_read_edge_mask(mvchip); 512 + 513 + cause = (data_in ^ level_mask) | (edge_cause & edge_mask); 559 514 560 515 for (i = 0; i < mvchip->chip.ngpio; i++) { 561 516 int irq; ··· 572 523 /* Swap polarity (race with GPIO line) */ 573 524 u32 polarity; 574 525 575 - polarity = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); 526 + regmap_read(mvchip->regs, 527 + GPIO_IN_POL_OFF + mvchip->offset, 528 + &polarity); 576 529 polarity ^= BIT(i); 577 - writel_relaxed(polarity, mvebu_gpioreg_in_pol(mvchip)); 530 + regmap_write(mvchip->regs, 531 + GPIO_IN_POL_OFF + mvchip->offset, 532 + polarity); 578 533 } 579 534 580 535 generic_handle_irq(irq); ··· 681 628 state->period = 1; 682 629 } 683 630 684 - u = readl_relaxed(mvebu_gpioreg_blink(mvchip)); 631 + regmap_read(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, &u); 685 632 if (u) 686 633 state->enabled = true; 687 634 else ··· 744 691 { 745 692 struct mvebu_pwm *mvpwm = mvchip->mvpwm; 746 693 747 - mvpwm->blink_select = 748 - readl_relaxed(mvebu_gpioreg_blink_counter_select(mvchip)); 694 + regmap_read(mvchip->regs, GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, 695 + &mvpwm->blink_select); 749 696 mvpwm->blink_on_duration = 750 697 readl_relaxed(mvebu_pwmreg_blink_on_duration(mvpwm)); 751 698 mvpwm->blink_off_duration = ··· 756 703 { 757 704 struct mvebu_pwm *mvpwm = mvchip->mvpwm; 758 705 759 - writel_relaxed(mvpwm->blink_select, 760 - mvebu_gpioreg_blink_counter_select(mvchip)); 706 + regmap_write(mvchip->regs, GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, 707 + mvpwm->blink_select); 761 708 writel_relaxed(mvpwm->blink_on_duration, 762 709 mvebu_pwmreg_blink_on_duration(mvpwm)); 763 710 writel_relaxed(mvpwm->blink_off_duration, ··· 800 747 set = U32_MAX; 801 748 else 802 749 return -EINVAL; 803 - writel_relaxed(set, mvebu_gpioreg_blink_counter_select(mvchip)); 750 + regmap_write(mvchip->regs, 751 + GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, set); 804 752 805 753 mvpwm = devm_kzalloc(dev, sizeof(struct mvebu_pwm), GFP_KERNEL); 806 754 if (!mvpwm) ··· 844 790 u32 out, io_conf, blink, in_pol, data_in, cause, edg_msk, lvl_msk; 845 791 int i; 846 792 847 - out = readl_relaxed(mvebu_gpioreg_out(mvchip)); 848 - io_conf = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)); 849 - blink = readl_relaxed(mvebu_gpioreg_blink(mvchip)); 850 - in_pol = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); 851 - data_in = readl_relaxed(mvebu_gpioreg_data_in(mvchip)); 852 - cause = readl_relaxed(mvebu_gpioreg_edge_cause(mvchip)); 853 - edg_msk = readl_relaxed(mvebu_gpioreg_edge_mask(mvchip)); 854 - lvl_msk = readl_relaxed(mvebu_gpioreg_level_mask(mvchip)); 793 + regmap_read(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, &out); 794 + regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, &io_conf); 795 + regmap_read(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, &blink); 796 + regmap_read(mvchip->regs, GPIO_IN_POL_OFF + mvchip->offset, &in_pol); 797 + regmap_read(mvchip->regs, GPIO_DATA_IN_OFF + mvchip->offset, &data_in); 798 + cause = mvebu_gpio_read_edge_cause(mvchip); 799 + edg_msk = mvebu_gpio_read_edge_mask(mvchip); 800 + lvl_msk = mvebu_gpio_read_level_mask(mvchip); 855 801 856 802 for (i = 0; i < chip->ngpio; i++) { 857 803 const char *label; ··· 910 856 .data = (void *) MVEBU_GPIO_SOC_VARIANT_ORION, 911 857 }, 912 858 { 859 + .compatible = "marvell,armada-8k-gpio", 860 + .data = (void *) MVEBU_GPIO_SOC_VARIANT_A8K, 861 + }, 862 + { 913 863 /* sentinel */ 914 864 }, 915 865 }; ··· 923 865 struct mvebu_gpio_chip *mvchip = platform_get_drvdata(pdev); 924 866 int i; 925 867 926 - mvchip->out_reg = readl(mvebu_gpioreg_out(mvchip)); 927 - mvchip->io_conf_reg = readl(mvebu_gpioreg_io_conf(mvchip)); 928 - mvchip->blink_en_reg = readl(mvebu_gpioreg_blink(mvchip)); 929 - mvchip->in_pol_reg = readl(mvebu_gpioreg_in_pol(mvchip)); 868 + regmap_read(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, 869 + &mvchip->out_reg); 870 + regmap_read(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, 871 + &mvchip->io_conf_reg); 872 + regmap_read(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, 873 + &mvchip->blink_en_reg); 874 + regmap_read(mvchip->regs, GPIO_IN_POL_OFF + mvchip->offset, 875 + &mvchip->in_pol_reg); 930 876 931 877 switch (mvchip->soc_variant) { 932 878 case MVEBU_GPIO_SOC_VARIANT_ORION: 933 - mvchip->edge_mask_regs[0] = 934 - readl(mvchip->membase + GPIO_EDGE_MASK_OFF); 935 - mvchip->level_mask_regs[0] = 936 - readl(mvchip->membase + GPIO_LEVEL_MASK_OFF); 879 + case MVEBU_GPIO_SOC_VARIANT_A8K: 880 + regmap_read(mvchip->regs, GPIO_EDGE_MASK_OFF + mvchip->offset, 881 + &mvchip->edge_mask_regs[0]); 882 + regmap_read(mvchip->regs, GPIO_LEVEL_MASK_OFF + mvchip->offset, 883 + &mvchip->level_mask_regs[0]); 937 884 break; 938 885 case MVEBU_GPIO_SOC_VARIANT_MV78200: 939 886 for (i = 0; i < 2; i++) { 940 - mvchip->edge_mask_regs[i] = 941 - readl(mvchip->membase + 942 - GPIO_EDGE_MASK_MV78200_OFF(i)); 943 - mvchip->level_mask_regs[i] = 944 - readl(mvchip->membase + 945 - GPIO_LEVEL_MASK_MV78200_OFF(i)); 887 + regmap_read(mvchip->regs, 888 + GPIO_EDGE_MASK_MV78200_OFF(i), 889 + &mvchip->edge_mask_regs[i]); 890 + regmap_read(mvchip->regs, 891 + GPIO_LEVEL_MASK_MV78200_OFF(i), 892 + &mvchip->level_mask_regs[i]); 946 893 } 947 894 break; 948 895 case MVEBU_GPIO_SOC_VARIANT_ARMADAXP: 949 896 for (i = 0; i < 4; i++) { 950 - mvchip->edge_mask_regs[i] = 951 - readl(mvchip->membase + 952 - GPIO_EDGE_MASK_ARMADAXP_OFF(i)); 953 - mvchip->level_mask_regs[i] = 954 - readl(mvchip->membase + 955 - GPIO_LEVEL_MASK_ARMADAXP_OFF(i)); 897 + regmap_read(mvchip->regs, 898 + GPIO_EDGE_MASK_ARMADAXP_OFF(i), 899 + &mvchip->edge_mask_regs[i]); 900 + regmap_read(mvchip->regs, 901 + GPIO_LEVEL_MASK_ARMADAXP_OFF(i), 902 + &mvchip->level_mask_regs[i]); 956 903 } 957 904 break; 958 905 default: ··· 975 912 struct mvebu_gpio_chip *mvchip = platform_get_drvdata(pdev); 976 913 int i; 977 914 978 - writel(mvchip->out_reg, mvebu_gpioreg_out(mvchip)); 979 - writel(mvchip->io_conf_reg, mvebu_gpioreg_io_conf(mvchip)); 980 - writel(mvchip->blink_en_reg, mvebu_gpioreg_blink(mvchip)); 981 - writel(mvchip->in_pol_reg, mvebu_gpioreg_in_pol(mvchip)); 915 + regmap_write(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, 916 + mvchip->out_reg); 917 + regmap_write(mvchip->regs, GPIO_IO_CONF_OFF + mvchip->offset, 918 + mvchip->io_conf_reg); 919 + regmap_write(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, 920 + mvchip->blink_en_reg); 921 + regmap_write(mvchip->regs, GPIO_IN_POL_OFF + mvchip->offset, 922 + mvchip->in_pol_reg); 982 923 983 924 switch (mvchip->soc_variant) { 984 925 case MVEBU_GPIO_SOC_VARIANT_ORION: 985 - writel(mvchip->edge_mask_regs[0], 986 - mvchip->membase + GPIO_EDGE_MASK_OFF); 987 - writel(mvchip->level_mask_regs[0], 988 - mvchip->membase + GPIO_LEVEL_MASK_OFF); 926 + case MVEBU_GPIO_SOC_VARIANT_A8K: 927 + regmap_write(mvchip->regs, GPIO_EDGE_MASK_OFF + mvchip->offset, 928 + mvchip->edge_mask_regs[0]); 929 + regmap_write(mvchip->regs, GPIO_LEVEL_MASK_OFF + mvchip->offset, 930 + mvchip->level_mask_regs[0]); 989 931 break; 990 932 case MVEBU_GPIO_SOC_VARIANT_MV78200: 991 933 for (i = 0; i < 2; i++) { 992 - writel(mvchip->edge_mask_regs[i], 993 - mvchip->membase + GPIO_EDGE_MASK_MV78200_OFF(i)); 994 - writel(mvchip->level_mask_regs[i], 995 - mvchip->membase + 996 - GPIO_LEVEL_MASK_MV78200_OFF(i)); 934 + regmap_write(mvchip->regs, 935 + GPIO_EDGE_MASK_MV78200_OFF(i), 936 + mvchip->edge_mask_regs[i]); 937 + regmap_write(mvchip->regs, 938 + GPIO_LEVEL_MASK_MV78200_OFF(i), 939 + mvchip->level_mask_regs[i]); 997 940 } 998 941 break; 999 942 case MVEBU_GPIO_SOC_VARIANT_ARMADAXP: 1000 943 for (i = 0; i < 4; i++) { 1001 - writel(mvchip->edge_mask_regs[i], 1002 - mvchip->membase + 1003 - GPIO_EDGE_MASK_ARMADAXP_OFF(i)); 1004 - writel(mvchip->level_mask_regs[i], 1005 - mvchip->membase + 1006 - GPIO_LEVEL_MASK_ARMADAXP_OFF(i)); 944 + regmap_write(mvchip->regs, 945 + GPIO_EDGE_MASK_ARMADAXP_OFF(i), 946 + mvchip->edge_mask_regs[i]); 947 + regmap_write(mvchip->regs, 948 + GPIO_LEVEL_MASK_ARMADAXP_OFF(i), 949 + mvchip->level_mask_regs[i]); 1007 950 } 1008 951 break; 1009 952 default: ··· 1022 953 return 0; 1023 954 } 1024 955 956 + static const struct regmap_config mvebu_gpio_regmap_config = { 957 + .reg_bits = 32, 958 + .reg_stride = 4, 959 + .val_bits = 32, 960 + .fast_io = true, 961 + }; 962 + 963 + static int mvebu_gpio_probe_raw(struct platform_device *pdev, 964 + struct mvebu_gpio_chip *mvchip) 965 + { 966 + struct resource *res; 967 + void __iomem *base; 968 + 969 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 970 + base = devm_ioremap_resource(&pdev->dev, res); 971 + if (IS_ERR(base)) 972 + return PTR_ERR(base); 973 + 974 + mvchip->regs = devm_regmap_init_mmio(&pdev->dev, base, 975 + &mvebu_gpio_regmap_config); 976 + if (IS_ERR(mvchip->regs)) 977 + return PTR_ERR(mvchip->regs); 978 + 979 + /* 980 + * For the legacy SoCs, the regmap directly maps to the GPIO 981 + * registers, so no offset is needed. 982 + */ 983 + mvchip->offset = 0; 984 + 985 + /* 986 + * The Armada XP has a second range of registers for the 987 + * per-CPU registers 988 + */ 989 + if (mvchip->soc_variant == MVEBU_GPIO_SOC_VARIANT_ARMADAXP) { 990 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 991 + base = devm_ioremap_resource(&pdev->dev, res); 992 + if (IS_ERR(base)) 993 + return PTR_ERR(base); 994 + 995 + mvchip->percpu_regs = 996 + devm_regmap_init_mmio(&pdev->dev, base, 997 + &mvebu_gpio_regmap_config); 998 + if (IS_ERR(mvchip->percpu_regs)) 999 + return PTR_ERR(mvchip->percpu_regs); 1000 + } 1001 + 1002 + return 0; 1003 + } 1004 + 1005 + static int mvebu_gpio_probe_syscon(struct platform_device *pdev, 1006 + struct mvebu_gpio_chip *mvchip) 1007 + { 1008 + mvchip->regs = syscon_node_to_regmap(pdev->dev.parent->of_node); 1009 + if (IS_ERR(mvchip->regs)) 1010 + return PTR_ERR(mvchip->regs); 1011 + 1012 + if (of_property_read_u32(pdev->dev.of_node, "offset", &mvchip->offset)) 1013 + return -EINVAL; 1014 + 1015 + return 0; 1016 + } 1017 + 1025 1018 static int mvebu_gpio_probe(struct platform_device *pdev) 1026 1019 { 1027 1020 struct mvebu_gpio_chip *mvchip; 1028 1021 const struct of_device_id *match; 1029 1022 struct device_node *np = pdev->dev.of_node; 1030 - struct resource *res; 1031 1023 struct irq_chip_generic *gc; 1032 1024 struct irq_chip_type *ct; 1033 1025 unsigned int ngpios; ··· 1146 1016 mvchip->chip.of_node = np; 1147 1017 mvchip->chip.dbg_show = mvebu_gpio_dbg_show; 1148 1018 1149 - spin_lock_init(&mvchip->lock); 1150 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1151 - mvchip->membase = devm_ioremap_resource(&pdev->dev, res); 1152 - if (IS_ERR(mvchip->membase)) 1153 - return PTR_ERR(mvchip->membase); 1019 + if (soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) 1020 + err = mvebu_gpio_probe_syscon(pdev, mvchip); 1021 + else 1022 + err = mvebu_gpio_probe_raw(pdev, mvchip); 1154 1023 1155 - /* 1156 - * The Armada XP has a second range of registers for the 1157 - * per-CPU registers 1158 - */ 1159 - if (soc_variant == MVEBU_GPIO_SOC_VARIANT_ARMADAXP) { 1160 - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1161 - mvchip->percpu_membase = devm_ioremap_resource(&pdev->dev, 1162 - res); 1163 - if (IS_ERR(mvchip->percpu_membase)) 1164 - return PTR_ERR(mvchip->percpu_membase); 1165 - } 1024 + if (err) 1025 + return err; 1166 1026 1167 1027 /* 1168 1028 * Mask and clear GPIO interrupts. 1169 1029 */ 1170 1030 switch (soc_variant) { 1171 1031 case MVEBU_GPIO_SOC_VARIANT_ORION: 1172 - writel_relaxed(0, mvchip->membase + GPIO_EDGE_CAUSE_OFF); 1173 - writel_relaxed(0, mvchip->membase + GPIO_EDGE_MASK_OFF); 1174 - writel_relaxed(0, mvchip->membase + GPIO_LEVEL_MASK_OFF); 1032 + case MVEBU_GPIO_SOC_VARIANT_A8K: 1033 + regmap_write(mvchip->regs, 1034 + GPIO_EDGE_CAUSE_OFF + mvchip->offset, 0); 1035 + regmap_write(mvchip->regs, 1036 + GPIO_EDGE_MASK_OFF + mvchip->offset, 0); 1037 + regmap_write(mvchip->regs, 1038 + GPIO_LEVEL_MASK_OFF + mvchip->offset, 0); 1175 1039 break; 1176 1040 case MVEBU_GPIO_SOC_VARIANT_MV78200: 1177 - writel_relaxed(0, mvchip->membase + GPIO_EDGE_CAUSE_OFF); 1041 + regmap_write(mvchip->regs, GPIO_EDGE_CAUSE_OFF, 0); 1178 1042 for (cpu = 0; cpu < 2; cpu++) { 1179 - writel_relaxed(0, mvchip->membase + 1180 - GPIO_EDGE_MASK_MV78200_OFF(cpu)); 1181 - writel_relaxed(0, mvchip->membase + 1182 - GPIO_LEVEL_MASK_MV78200_OFF(cpu)); 1043 + regmap_write(mvchip->regs, 1044 + GPIO_EDGE_MASK_MV78200_OFF(cpu), 0); 1045 + regmap_write(mvchip->regs, 1046 + GPIO_LEVEL_MASK_MV78200_OFF(cpu), 0); 1183 1047 } 1184 1048 break; 1185 1049 case MVEBU_GPIO_SOC_VARIANT_ARMADAXP: 1186 - writel_relaxed(0, mvchip->membase + GPIO_EDGE_CAUSE_OFF); 1187 - writel_relaxed(0, mvchip->membase + GPIO_EDGE_MASK_OFF); 1188 - writel_relaxed(0, mvchip->membase + GPIO_LEVEL_MASK_OFF); 1050 + regmap_write(mvchip->regs, GPIO_EDGE_CAUSE_OFF, 0); 1051 + regmap_write(mvchip->regs, GPIO_EDGE_MASK_OFF, 0); 1052 + regmap_write(mvchip->regs, GPIO_LEVEL_MASK_OFF, 0); 1189 1053 for (cpu = 0; cpu < 4; cpu++) { 1190 - writel_relaxed(0, mvchip->percpu_membase + 1191 - GPIO_EDGE_CAUSE_ARMADAXP_OFF(cpu)); 1192 - writel_relaxed(0, mvchip->percpu_membase + 1193 - GPIO_EDGE_MASK_ARMADAXP_OFF(cpu)); 1194 - writel_relaxed(0, mvchip->percpu_membase + 1195 - GPIO_LEVEL_MASK_ARMADAXP_OFF(cpu)); 1054 + regmap_write(mvchip->percpu_regs, 1055 + GPIO_EDGE_CAUSE_ARMADAXP_OFF(cpu), 0); 1056 + regmap_write(mvchip->percpu_regs, 1057 + GPIO_EDGE_MASK_ARMADAXP_OFF(cpu), 0); 1058 + regmap_write(mvchip->percpu_regs, 1059 + GPIO_LEVEL_MASK_ARMADAXP_OFF(cpu), 0); 1196 1060 } 1197 1061 break; 1198 1062 default:
+1 -1
drivers/gpio/gpio-pcf857x.c
··· 20 20 21 21 #include <linux/gpio.h> 22 22 #include <linux/i2c.h> 23 - #include <linux/i2c/pcf857x.h> 23 + #include <linux/platform_data/pcf857x.h> 24 24 #include <linux/interrupt.h> 25 25 #include <linux/irq.h> 26 26 #include <linux/irqdomain.h>
+12 -3
drivers/gpio/gpio-pch.c
··· 331 331 return ret; 332 332 } 333 333 334 - static void pch_gpio_alloc_generic_chip(struct pch_gpio *chip, 335 - unsigned int irq_start, unsigned int num) 334 + static int pch_gpio_alloc_generic_chip(struct pch_gpio *chip, 335 + unsigned int irq_start, 336 + unsigned int num) 336 337 { 337 338 struct irq_chip_generic *gc; 338 339 struct irq_chip_type *ct; 339 340 340 341 gc = irq_alloc_generic_chip("pch_gpio", 1, irq_start, chip->base, 341 342 handle_simple_irq); 343 + if (!gc) 344 + return -ENOMEM; 345 + 342 346 gc->private = chip; 343 347 ct = gc->chip_types; 344 348 ··· 353 349 354 350 irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE, 355 351 IRQ_NOREQUEST | IRQ_NOPROBE, 0); 352 + 353 + return 0; 356 354 } 357 355 358 356 static int pch_gpio_probe(struct pci_dev *pdev, ··· 431 425 goto err_request_irq; 432 426 } 433 427 434 - pch_gpio_alloc_generic_chip(chip, irq_base, gpio_pins[chip->ioh]); 428 + ret = pch_gpio_alloc_generic_chip(chip, irq_base, 429 + gpio_pins[chip->ioh]); 430 + if (ret) 431 + goto err_request_irq; 435 432 436 433 end: 437 434 return 0;
+4
drivers/gpio/gpio-rcar.c
··· 344 344 345 345 static const struct of_device_id gpio_rcar_of_table[] = { 346 346 { 347 + .compatible = "renesas,gpio-r8a7743", 348 + /* RZ/G1 GPIO is identical to R-Car Gen2. */ 349 + .data = &gpio_rcar_info_gen2, 350 + }, { 347 351 .compatible = "renesas,gpio-r8a7790", 348 352 .data = &gpio_rcar_info_gen2, 349 353 }, {
+10 -2
drivers/gpio/gpio-sta2x11.c
··· 320 320 return ret; 321 321 } 322 322 323 - static void gsta_alloc_irq_chip(struct gsta_gpio *chip) 323 + static int gsta_alloc_irq_chip(struct gsta_gpio *chip) 324 324 { 325 325 struct irq_chip_generic *gc; 326 326 struct irq_chip_type *ct; 327 327 328 328 gc = irq_alloc_generic_chip(KBUILD_MODNAME, 1, chip->irq_base, 329 329 chip->reg_base, handle_simple_irq); 330 + if (!gc) 331 + return -ENOMEM; 332 + 330 333 gc->private = chip; 331 334 ct = gc->chip_types; 332 335 ··· 353 350 } 354 351 gc->irq_cnt = i - gc->irq_base; 355 352 } 353 + 354 + return 0; 356 355 } 357 356 358 357 /* The platform device used here is instantiated by the MFD device */ ··· 405 400 return err; 406 401 } 407 402 chip->irq_base = err; 408 - gsta_alloc_irq_chip(chip); 403 + 404 + err = gsta_alloc_irq_chip(chip); 405 + if (err) 406 + return err; 409 407 410 408 err = devm_request_irq(&dev->dev, pdev->irq, gsta_gpio_handler, 411 409 IRQF_SHARED, KBUILD_MODNAME, chip);
+51 -24
drivers/gpio/gpio-wcove.c
··· 108 108 static inline unsigned int to_reg(int gpio, enum ctrl_register reg_type) 109 109 { 110 110 unsigned int reg; 111 - int bank; 112 111 113 - if (gpio < BANK0_NR_PINS) 114 - bank = 0; 115 - else if (gpio < BANK0_NR_PINS + BANK1_NR_PINS) 116 - bank = 1; 117 - else 118 - bank = 2; 112 + if (gpio >= WCOVE_GPIO_NUM) 113 + return -EOPNOTSUPP; 119 114 120 115 if (reg_type == CTRL_IN) 121 - reg = GPIO_IN_CTRL_BASE + bank; 116 + reg = GPIO_IN_CTRL_BASE + gpio; 122 117 else 123 - reg = GPIO_OUT_CTRL_BASE + bank; 118 + reg = GPIO_OUT_CTRL_BASE + gpio; 124 119 125 120 return reg; 126 121 } ··· 140 145 141 146 static void wcove_update_irq_ctrl(struct wcove_gpio *wg, int gpio) 142 147 { 143 - unsigned int reg = to_reg(gpio, CTRL_IN); 148 + int reg = to_reg(gpio, CTRL_IN); 149 + 150 + if (reg < 0) 151 + return; 144 152 145 153 regmap_update_bits(wg->regmap, reg, CTLI_INTCNT_BE, wg->intcnt); 146 154 } ··· 151 153 static int wcove_gpio_dir_in(struct gpio_chip *chip, unsigned int gpio) 152 154 { 153 155 struct wcove_gpio *wg = gpiochip_get_data(chip); 156 + int reg = to_reg(gpio, CTRL_OUT); 154 157 155 - return regmap_write(wg->regmap, to_reg(gpio, CTRL_OUT), 156 - CTLO_INPUT_SET); 158 + if (reg < 0) 159 + return 0; 160 + 161 + return regmap_write(wg->regmap, reg, CTLO_INPUT_SET); 157 162 } 158 163 159 164 static int wcove_gpio_dir_out(struct gpio_chip *chip, unsigned int gpio, 160 165 int value) 161 166 { 162 167 struct wcove_gpio *wg = gpiochip_get_data(chip); 168 + int reg = to_reg(gpio, CTRL_OUT); 163 169 164 - return regmap_write(wg->regmap, to_reg(gpio, CTRL_OUT), 165 - CTLO_OUTPUT_SET | value); 170 + if (reg < 0) 171 + return 0; 172 + 173 + return regmap_write(wg->regmap, reg, CTLO_OUTPUT_SET | value); 166 174 } 167 175 168 176 static int wcove_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio) 169 177 { 170 178 struct wcove_gpio *wg = gpiochip_get_data(chip); 171 179 unsigned int val; 172 - int ret; 180 + int ret, reg = to_reg(gpio, CTRL_OUT); 173 181 174 - ret = regmap_read(wg->regmap, to_reg(gpio, CTRL_OUT), &val); 182 + if (reg < 0) 183 + return 0; 184 + 185 + ret = regmap_read(wg->regmap, reg, &val); 175 186 if (ret) 176 187 return ret; 177 188 ··· 191 184 { 192 185 struct wcove_gpio *wg = gpiochip_get_data(chip); 193 186 unsigned int val; 194 - int ret; 187 + int ret, reg = to_reg(gpio, CTRL_IN); 195 188 196 - ret = regmap_read(wg->regmap, to_reg(gpio, CTRL_IN), &val); 189 + if (reg < 0) 190 + return 0; 191 + 192 + ret = regmap_read(wg->regmap, reg, &val); 197 193 if (ret) 198 194 return ret; 199 195 ··· 207 197 unsigned int gpio, int value) 208 198 { 209 199 struct wcove_gpio *wg = gpiochip_get_data(chip); 200 + int reg = to_reg(gpio, CTRL_OUT); 201 + 202 + if (reg < 0) 203 + return; 210 204 211 205 if (value) 212 - regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 1, 1); 206 + regmap_update_bits(wg->regmap, reg, 1, 1); 213 207 else 214 - regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 1, 0); 208 + regmap_update_bits(wg->regmap, reg, 1, 0); 215 209 } 216 210 217 211 static int wcove_gpio_set_config(struct gpio_chip *chip, unsigned int gpio, 218 212 unsigned long config) 219 213 { 220 214 struct wcove_gpio *wg = gpiochip_get_data(chip); 215 + int reg = to_reg(gpio, CTRL_OUT); 216 + 217 + if (reg < 0) 218 + return 0; 221 219 222 220 switch (pinconf_to_config_param(config)) { 223 221 case PIN_CONFIG_DRIVE_OPEN_DRAIN: 224 - return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 225 - CTLO_DRV_MASK, CTLO_DRV_OD); 222 + return regmap_update_bits(wg->regmap, reg, CTLO_DRV_MASK, 223 + CTLO_DRV_OD); 226 224 case PIN_CONFIG_DRIVE_PUSH_PULL: 227 - return regmap_update_bits(wg->regmap, to_reg(gpio, CTRL_OUT), 228 - CTLO_DRV_MASK, CTLO_DRV_CMOS); 225 + return regmap_update_bits(wg->regmap, reg, CTLO_DRV_MASK, 226 + CTLO_DRV_CMOS); 229 227 default: 230 228 break; 231 229 } ··· 245 227 { 246 228 struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 247 229 struct wcove_gpio *wg = gpiochip_get_data(chip); 230 + 231 + if (data->hwirq >= WCOVE_GPIO_NUM) 232 + return 0; 248 233 249 234 switch (type) { 250 235 case IRQ_TYPE_NONE: ··· 299 278 struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 300 279 struct wcove_gpio *wg = gpiochip_get_data(chip); 301 280 281 + if (data->hwirq >= WCOVE_GPIO_NUM) 282 + return; 283 + 302 284 wg->set_irq_mask = false; 303 285 wg->update |= UPDATE_IRQ_MASK; 304 286 } ··· 310 286 { 311 287 struct gpio_chip *chip = irq_data_get_irq_chip_data(data); 312 288 struct wcove_gpio *wg = gpiochip_get_data(chip); 289 + 290 + if (data->hwirq >= WCOVE_GPIO_NUM) 291 + return; 313 292 314 293 wg->set_irq_mask = true; 315 294 wg->update |= UPDATE_IRQ_MASK;
+237
drivers/gpio/gpio-xra1403.c
··· 1 + /* 2 + * GPIO driver for EXAR XRA1403 16-bit GPIO expander 3 + * 4 + * Copyright (c) 2017, General Electric Company 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms and conditions of the GNU General Public License, 8 + * version 2, as published by the Free Software Foundation. 9 + * 10 + * This program is distributed in the hope it will be useful, but WITHOUT 11 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 + * more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 + */ 18 + 19 + #include <linux/bitops.h> 20 + #include <linux/gpio/driver.h> 21 + #include <linux/kernel.h> 22 + #include <linux/module.h> 23 + #include <linux/mutex.h> 24 + #include <linux/of_device.h> 25 + #include <linux/of_gpio.h> 26 + #include <linux/seq_file.h> 27 + #include <linux/spi/spi.h> 28 + #include <linux/regmap.h> 29 + 30 + /* XRA1403 registers */ 31 + #define XRA_GSR 0x00 /* GPIO State */ 32 + #define XRA_OCR 0x02 /* Output Control */ 33 + #define XRA_PIR 0x04 /* Input Polarity Inversion */ 34 + #define XRA_GCR 0x06 /* GPIO Configuration */ 35 + #define XRA_PUR 0x08 /* Input Internal Pull-up Resistor Enable/Disable */ 36 + #define XRA_IER 0x0A /* Input Interrupt Enable */ 37 + #define XRA_TSCR 0x0C /* Output Three-State Control */ 38 + #define XRA_ISR 0x0E /* Input Interrupt Status */ 39 + #define XRA_REIR 0x10 /* Input Rising Edge Interrupt Enable */ 40 + #define XRA_FEIR 0x12 /* Input Falling Edge Interrupt Enable */ 41 + #define XRA_IFR 0x14 /* Input Filter Enable/Disable */ 42 + 43 + struct xra1403 { 44 + struct gpio_chip chip; 45 + struct regmap *regmap; 46 + }; 47 + 48 + static const struct regmap_config xra1403_regmap_cfg = { 49 + .reg_bits = 7, 50 + .pad_bits = 1, 51 + .val_bits = 8, 52 + 53 + .max_register = XRA_IFR | 0x01, 54 + }; 55 + 56 + static unsigned int to_reg(unsigned int reg, unsigned int offset) 57 + { 58 + return reg + (offset > 7); 59 + } 60 + 61 + static int xra1403_direction_input(struct gpio_chip *chip, unsigned int offset) 62 + { 63 + struct xra1403 *xra = gpiochip_get_data(chip); 64 + 65 + return regmap_update_bits(xra->regmap, to_reg(XRA_GCR, offset), 66 + BIT(offset % 8), BIT(offset % 8)); 67 + } 68 + 69 + static int xra1403_direction_output(struct gpio_chip *chip, unsigned int offset, 70 + int value) 71 + { 72 + int ret; 73 + struct xra1403 *xra = gpiochip_get_data(chip); 74 + 75 + ret = regmap_update_bits(xra->regmap, to_reg(XRA_GCR, offset), 76 + BIT(offset % 8), 0); 77 + if (ret) 78 + return ret; 79 + 80 + ret = regmap_update_bits(xra->regmap, to_reg(XRA_OCR, offset), 81 + BIT(offset % 8), value ? BIT(offset % 8) : 0); 82 + 83 + return ret; 84 + } 85 + 86 + static int xra1403_get_direction(struct gpio_chip *chip, unsigned int offset) 87 + { 88 + int ret; 89 + unsigned int val; 90 + struct xra1403 *xra = gpiochip_get_data(chip); 91 + 92 + ret = regmap_read(xra->regmap, to_reg(XRA_GCR, offset), &val); 93 + if (ret) 94 + return ret; 95 + 96 + return !!(val & BIT(offset % 8)); 97 + } 98 + 99 + static int xra1403_get(struct gpio_chip *chip, unsigned int offset) 100 + { 101 + int ret; 102 + unsigned int val; 103 + struct xra1403 *xra = gpiochip_get_data(chip); 104 + 105 + ret = regmap_read(xra->regmap, to_reg(XRA_GSR, offset), &val); 106 + if (ret) 107 + return ret; 108 + 109 + return !!(val & BIT(offset % 8)); 110 + } 111 + 112 + static void xra1403_set(struct gpio_chip *chip, unsigned int offset, int value) 113 + { 114 + int ret; 115 + struct xra1403 *xra = gpiochip_get_data(chip); 116 + 117 + ret = regmap_update_bits(xra->regmap, to_reg(XRA_OCR, offset), 118 + BIT(offset % 8), value ? BIT(offset % 8) : 0); 119 + if (ret) 120 + dev_err(chip->parent, "Failed to set pin: %d, ret: %d\n", 121 + offset, ret); 122 + } 123 + 124 + #ifdef CONFIG_DEBUG_FS 125 + static void xra1403_dbg_show(struct seq_file *s, struct gpio_chip *chip) 126 + { 127 + int reg; 128 + struct xra1403 *xra = gpiochip_get_data(chip); 129 + int value[xra1403_regmap_cfg.max_register]; 130 + int i; 131 + unsigned int gcr; 132 + unsigned int gsr; 133 + 134 + seq_puts(s, "xra reg:"); 135 + for (reg = 0; reg <= xra1403_regmap_cfg.max_register; reg++) 136 + seq_printf(s, " %2.2x", reg); 137 + seq_puts(s, "\n value:"); 138 + for (reg = 0; reg < xra1403_regmap_cfg.max_register; reg++) { 139 + regmap_read(xra->regmap, reg, &value[reg]); 140 + seq_printf(s, " %2.2x", value[reg]); 141 + } 142 + seq_puts(s, "\n"); 143 + 144 + gcr = value[XRA_GCR + 1] << 8 | value[XRA_GCR]; 145 + gsr = value[XRA_GSR + 1] << 8 | value[XRA_GSR]; 146 + for (i = 0; i < chip->ngpio; i++) { 147 + const char *label = gpiochip_is_requested(chip, i); 148 + 149 + if (!label) 150 + continue; 151 + 152 + seq_printf(s, " gpio-%-3d (%-12s) %s %s\n", 153 + chip->base + i, label, 154 + (gcr & BIT(i)) ? "in" : "out", 155 + (gsr & BIT(i)) ? "hi" : "lo"); 156 + } 157 + } 158 + #else 159 + #define xra1403_dbg_show NULL 160 + #endif 161 + 162 + static int xra1403_probe(struct spi_device *spi) 163 + { 164 + struct xra1403 *xra; 165 + struct gpio_desc *reset_gpio; 166 + int ret; 167 + 168 + xra = devm_kzalloc(&spi->dev, sizeof(*xra), GFP_KERNEL); 169 + if (!xra) 170 + return -ENOMEM; 171 + 172 + /* bring the chip out of reset if reset pin is provided*/ 173 + reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW); 174 + if (IS_ERR(reset_gpio)) 175 + dev_warn(&spi->dev, "Could not get reset-gpios\n"); 176 + 177 + xra->chip.direction_input = xra1403_direction_input; 178 + xra->chip.direction_output = xra1403_direction_output; 179 + xra->chip.get_direction = xra1403_get_direction; 180 + xra->chip.get = xra1403_get; 181 + xra->chip.set = xra1403_set; 182 + 183 + xra->chip.dbg_show = xra1403_dbg_show; 184 + 185 + xra->chip.ngpio = 16; 186 + xra->chip.label = "xra1403"; 187 + 188 + xra->chip.base = -1; 189 + xra->chip.can_sleep = true; 190 + xra->chip.parent = &spi->dev; 191 + xra->chip.owner = THIS_MODULE; 192 + 193 + xra->regmap = devm_regmap_init_spi(spi, &xra1403_regmap_cfg); 194 + if (IS_ERR(xra->regmap)) { 195 + ret = PTR_ERR(xra->regmap); 196 + dev_err(&spi->dev, "Failed to allocate regmap: %d\n", ret); 197 + return ret; 198 + } 199 + 200 + ret = devm_gpiochip_add_data(&spi->dev, &xra->chip, xra); 201 + if (ret < 0) { 202 + dev_err(&spi->dev, "Unable to register gpiochip\n"); 203 + return ret; 204 + } 205 + 206 + spi_set_drvdata(spi, xra); 207 + 208 + return 0; 209 + } 210 + 211 + static const struct spi_device_id xra1403_ids[] = { 212 + { "xra1403" }, 213 + {}, 214 + }; 215 + MODULE_DEVICE_TABLE(spi, xra1403_ids); 216 + 217 + static const struct of_device_id xra1403_spi_of_match[] = { 218 + { .compatible = "exar,xra1403" }, 219 + {}, 220 + }; 221 + MODULE_DEVICE_TABLE(of, xra1403_spi_of_match); 222 + 223 + static struct spi_driver xra1403_driver = { 224 + .probe = xra1403_probe, 225 + .id_table = xra1403_ids, 226 + .driver = { 227 + .name = "xra1403", 228 + .of_match_table = of_match_ptr(xra1403_spi_of_match), 229 + }, 230 + }; 231 + 232 + module_spi_driver(xra1403_driver); 233 + 234 + MODULE_AUTHOR("Nandor Han <nandor.han@ge.com>"); 235 + MODULE_AUTHOR("Semi Malinen <semi.malinen@ge.com>"); 236 + MODULE_DESCRIPTION("GPIO expander driver for EXAR XRA1403"); 237 + MODULE_LICENSE("GPL v2");
+17 -9
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) 99 + /* set to differentiate zynq from zynqmp, 0=zynqmp, 1=zynq */ 100 + #define ZYNQ_GPIO_QUIRK_IS_ZYNQ BIT(0) 101 101 102 102 /** 103 103 * struct zynq_gpio - gpio device private data structure ··· 134 134 135 135 static struct irq_chip zynq_gpio_level_irqchip; 136 136 static struct irq_chip zynq_gpio_edge_irqchip; 137 + 138 + /** 139 + * zynq_gpio_is_zynq - test if HW is zynq or zynqmp 140 + * @gpio: Pointer to driver data struct 141 + * 142 + * Return: 0 if zynqmp, 1 if zynq. 143 + */ 144 + static int zynq_gpio_is_zynq(struct zynq_gpio *gpio) 145 + { 146 + return !!(gpio->p_data->quirks & ZYNQ_GPIO_QUIRK_IS_ZYNQ); 147 + } 137 148 138 149 /** 139 150 * zynq_gpio_get_bank_pin - Get the bank number and pin number within that bank ··· 253 242 static int zynq_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) 254 243 { 255 244 u32 reg; 256 - bool is_zynq_gpio; 257 245 unsigned int bank_num, bank_pin_num; 258 246 struct zynq_gpio *gpio = gpiochip_get_data(chip); 259 247 260 - is_zynq_gpio = gpio->p_data->quirks & ZYNQ_GPIO_QUIRK_FOO; 261 248 zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio); 262 249 263 250 /* 264 251 * On zynq bank 0 pins 7 and 8 are special and cannot be used 265 252 * as inputs. 266 253 */ 267 - if (is_zynq_gpio && bank_num == 0 && 254 + if (zynq_gpio_is_zynq(gpio) && bank_num == 0 && 268 255 (bank_pin_num == 7 || bank_pin_num == 8)) 269 256 return -EINVAL; 270 257 ··· 646 637 647 638 static const struct zynq_platform_data zynq_gpio_def = { 648 639 .label = "zynq_gpio", 649 - .quirks = ZYNQ_GPIO_QUIRK_FOO, 640 + .quirks = ZYNQ_GPIO_QUIRK_IS_ZYNQ, 650 641 .ngpio = ZYNQ_GPIO_NR_GPIOS, 651 642 .max_bank = ZYNQ_GPIO_MAX_BANK, 652 643 .bank_min[0] = ZYNQ_GPIO_BANK0_PIN_MIN(), ··· 660 651 }; 661 652 662 653 static const struct of_device_id zynq_gpio_of_match[] = { 663 - { .compatible = "xlnx,zynq-gpio-1.0", .data = (void *)&zynq_gpio_def }, 664 - { .compatible = "xlnx,zynqmp-gpio-1.0", 665 - .data = (void *)&zynqmp_gpio_def }, 654 + { .compatible = "xlnx,zynq-gpio-1.0", .data = &zynq_gpio_def }, 655 + { .compatible = "xlnx,zynqmp-gpio-1.0", .data = &zynqmp_gpio_def }, 666 656 { /* end of table */ } 667 657 }; 668 658 MODULE_DEVICE_TABLE(of, zynq_gpio_of_match);
+112 -73
drivers/gpio/gpiolib-acpi.c
··· 165 165 /* The address of this function is used as a key. */ 166 166 } 167 167 168 + bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, 169 + struct acpi_resource_gpio **agpio) 170 + { 171 + struct acpi_resource_gpio *gpio; 172 + 173 + if (ares->type != ACPI_RESOURCE_TYPE_GPIO) 174 + return false; 175 + 176 + gpio = &ares->data.gpio; 177 + if (gpio->connection_type != ACPI_RESOURCE_GPIO_TYPE_INT) 178 + return false; 179 + 180 + *agpio = gpio; 181 + return true; 182 + } 183 + EXPORT_SYMBOL_GPL(acpi_gpio_get_irq_resource); 184 + 168 185 static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, 169 186 void *context) 170 187 { ··· 195 178 unsigned long irqflags; 196 179 int ret, pin, irq; 197 180 198 - if (ares->type != ACPI_RESOURCE_TYPE_GPIO) 199 - return AE_OK; 200 - 201 - agpio = &ares->data.gpio; 202 - if (agpio->connection_type != ACPI_RESOURCE_GPIO_TYPE_INT) 181 + if (!acpi_gpio_get_irq_resource(ares, &agpio)) 203 182 return AE_OK; 204 183 205 184 handle = ACPI_HANDLE(chip->parent); ··· 436 423 return false; 437 424 } 438 425 426 + static enum gpiod_flags 427 + acpi_gpio_to_gpiod_flags(const struct acpi_resource_gpio *agpio) 428 + { 429 + bool pull_up = agpio->pin_config == ACPI_PIN_CONFIG_PULLUP; 430 + 431 + switch (agpio->io_restriction) { 432 + case ACPI_IO_RESTRICT_INPUT: 433 + return GPIOD_IN; 434 + case ACPI_IO_RESTRICT_OUTPUT: 435 + /* 436 + * ACPI GPIO resources don't contain an initial value for the 437 + * GPIO. Therefore we deduce that value from the pull field 438 + * instead. If the pin is pulled up we assume default to be 439 + * high, otherwise low. 440 + */ 441 + return pull_up ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; 442 + default: 443 + /* 444 + * Assume that the BIOS has configured the direction and pull 445 + * accordingly. 446 + */ 447 + return GPIOD_ASIS; 448 + } 449 + } 450 + 451 + int 452 + acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, enum gpiod_flags update) 453 + { 454 + int ret = 0; 455 + 456 + /* 457 + * Check if the BIOS has IoRestriction with explicitly set direction 458 + * and update @flags accordingly. Otherwise use whatever caller asked 459 + * for. 460 + */ 461 + if (update & GPIOD_FLAGS_BIT_DIR_SET) { 462 + enum gpiod_flags diff = *flags ^ update; 463 + 464 + /* 465 + * Check if caller supplied incompatible GPIO initialization 466 + * flags. 467 + * 468 + * Return %-EINVAL to notify that firmware has different 469 + * settings and we are going to use them. 470 + */ 471 + if (((*flags & GPIOD_FLAGS_BIT_DIR_SET) && (diff & GPIOD_FLAGS_BIT_DIR_OUT)) || 472 + ((*flags & GPIOD_FLAGS_BIT_DIR_OUT) && (diff & GPIOD_FLAGS_BIT_DIR_VAL))) 473 + ret = -EINVAL; 474 + *flags = update; 475 + } 476 + return ret; 477 + } 478 + 439 479 struct acpi_gpio_lookup { 440 480 struct acpi_gpio_info info; 441 481 int index; ··· 526 460 * - ACPI_ACTIVE_HIGH == GPIO_ACTIVE_HIGH 527 461 */ 528 462 if (lookup->info.gpioint) { 463 + lookup->info.flags = GPIOD_IN; 529 464 lookup->info.polarity = agpio->polarity; 530 465 lookup->info.triggering = agpio->triggering; 466 + } else { 467 + lookup->info.flags = acpi_gpio_to_gpiod_flags(agpio); 531 468 } 532 469 533 470 } ··· 657 588 struct gpio_desc *acpi_find_gpio(struct device *dev, 658 589 const char *con_id, 659 590 unsigned int idx, 660 - enum gpiod_flags flags, 591 + enum gpiod_flags *dflags, 661 592 enum gpio_lookup_flags *lookupflags) 662 593 { 663 594 struct acpi_device *adev = ACPI_COMPANION(dev); 664 595 struct acpi_gpio_info info; 665 596 struct gpio_desc *desc; 666 597 char propname[32]; 598 + int err; 667 599 int i; 668 600 669 601 /* Try first from _DSD */ 670 602 for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { 671 - if (con_id && strcmp(con_id, "gpios")) { 603 + if (con_id) { 672 604 snprintf(propname, sizeof(propname), "%s-%s", 673 605 con_id, gpio_suffixes[i]); 674 606 } else { ··· 692 622 desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info); 693 623 if (IS_ERR(desc)) 694 624 return desc; 625 + } 695 626 696 - if ((flags == GPIOD_OUT_LOW || flags == GPIOD_OUT_HIGH) && 697 - info.gpioint) { 698 - dev_dbg(dev, "refusing GpioInt() entry when doing GPIOD_OUT_* lookup\n"); 699 - return ERR_PTR(-ENOENT); 700 - } 627 + if (info.gpioint && 628 + (*dflags == GPIOD_OUT_LOW || *dflags == GPIOD_OUT_HIGH)) { 629 + dev_dbg(dev, "refusing GpioInt() entry when doing GPIOD_OUT_* lookup\n"); 630 + return ERR_PTR(-ENOENT); 701 631 } 702 632 703 633 if (info.polarity == GPIO_ACTIVE_LOW) 704 634 *lookupflags |= GPIO_ACTIVE_LOW; 635 + 636 + err = acpi_gpio_update_gpiod_flags(dflags, info.flags); 637 + if (err) 638 + dev_dbg(dev, "Override GPIO initialization flags\n"); 705 639 706 640 return desc; 707 641 } ··· 760 686 * used to translate from the GPIO offset in the resource to the Linux IRQ 761 687 * number. 762 688 * 689 + * The function is idempotent, though each time it runs it will configure GPIO 690 + * pin direction according to the flags in GpioInt resource. 691 + * 763 692 * Return: Linux IRQ number (>%0) on success, negative errno on failure. 764 693 */ 765 694 int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) 766 695 { 767 696 int idx, i; 768 697 unsigned int irq_flags; 698 + int ret; 769 699 770 700 for (i = 0, idx = 0; idx <= index; i++) { 771 701 struct acpi_gpio_info info; ··· 782 704 return PTR_ERR(desc); 783 705 784 706 if (info.gpioint && idx++ == index) { 707 + char label[32]; 785 708 int irq; 786 709 787 710 if (IS_ERR(desc)) ··· 791 712 irq = gpiod_to_irq(desc); 792 713 if (irq < 0) 793 714 return irq; 715 + 716 + snprintf(label, sizeof(label), "GpioInt() %d", index); 717 + ret = gpiod_configure_flags(desc, label, 0, info.flags); 718 + if (ret < 0) 719 + return ret; 794 720 795 721 irq_flags = acpi_dev_get_irq_type(info.triggering, 796 722 info.polarity); ··· 824 740 struct acpi_resource *ares; 825 741 int pin_index = (int)address; 826 742 acpi_status status; 827 - bool pull_up; 828 743 int length; 829 744 int i; 830 745 ··· 838 755 } 839 756 840 757 agpio = &ares->data.gpio; 841 - pull_up = agpio->pin_config == ACPI_PIN_CONFIG_PULLUP; 842 758 843 759 if (WARN_ON(agpio->io_restriction == ACPI_IO_RESTRICT_INPUT && 844 760 function == ACPI_WRITE)) { ··· 888 806 } 889 807 890 808 if (!found) { 891 - desc = gpiochip_request_own_desc(chip, pin, 892 - "ACPI:OpRegion"); 809 + enum gpiod_flags flags = acpi_gpio_to_gpiod_flags(agpio); 810 + const char *label = "ACPI:OpRegion"; 811 + int err; 812 + 813 + desc = gpiochip_request_own_desc(chip, pin, label); 893 814 if (IS_ERR(desc)) { 894 815 status = AE_ERROR; 895 816 mutex_unlock(&achip->conn_lock); 896 817 goto out; 897 818 } 898 819 899 - switch (agpio->io_restriction) { 900 - case ACPI_IO_RESTRICT_INPUT: 901 - gpiod_direction_input(desc); 902 - break; 903 - case ACPI_IO_RESTRICT_OUTPUT: 904 - /* 905 - * ACPI GPIO resources don't contain an 906 - * initial value for the GPIO. Therefore we 907 - * deduce that value from the pull field 908 - * instead. If the pin is pulled up we 909 - * assume default to be high, otherwise 910 - * low. 911 - */ 912 - gpiod_direction_output(desc, pull_up); 913 - break; 914 - default: 915 - /* 916 - * Assume that the BIOS has configured the 917 - * direction and pull accordingly. 918 - */ 919 - break; 820 + err = gpiod_configure_flags(desc, label, 0, flags); 821 + if (err < 0) { 822 + status = AE_NOT_CONFIGURED; 823 + gpiochip_free_own_desc(desc); 824 + mutex_unlock(&achip->conn_lock); 825 + goto out; 920 826 } 921 827 922 828 conn = kzalloc(sizeof(*conn), GFP_KERNEL); ··· 1159 1089 1160 1090 /* Try first from _DSD */ 1161 1091 for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { 1162 - if (con_id && strcmp(con_id, "gpios")) 1092 + if (con_id) 1163 1093 snprintf(propname, sizeof(propname), "%s-%s", 1164 1094 con_id, gpio_suffixes[i]); 1165 1095 else ··· 1189 1119 struct list_head resource_list; 1190 1120 unsigned int crs_count = 0; 1191 1121 1122 + if (!acpi_can_fallback_to_crs(adev, con_id)) 1123 + return count; 1124 + 1192 1125 INIT_LIST_HEAD(&resource_list); 1193 1126 acpi_dev_get_resources(adev, &resource_list, 1194 1127 acpi_find_gpio_count, &crs_count); ··· 1202 1129 return count ? count : -ENOENT; 1203 1130 } 1204 1131 1205 - struct acpi_crs_lookup { 1206 - struct list_head node; 1207 - struct acpi_device *adev; 1208 - const char *con_id; 1209 - }; 1210 - 1211 - static DEFINE_MUTEX(acpi_crs_lookup_lock); 1212 - static LIST_HEAD(acpi_crs_lookup_list); 1213 - 1214 1132 bool acpi_can_fallback_to_crs(struct acpi_device *adev, const char *con_id) 1215 1133 { 1216 - struct acpi_crs_lookup *l, *lookup = NULL; 1217 - 1218 1134 /* Never allow fallback if the device has properties */ 1219 1135 if (adev->data.properties || adev->driver_gpios) 1220 1136 return false; 1221 1137 1222 - mutex_lock(&acpi_crs_lookup_lock); 1223 - 1224 - list_for_each_entry(l, &acpi_crs_lookup_list, node) { 1225 - if (l->adev == adev) { 1226 - lookup = l; 1227 - break; 1228 - } 1229 - } 1230 - 1231 - if (!lookup) { 1232 - lookup = kmalloc(sizeof(*lookup), GFP_KERNEL); 1233 - if (lookup) { 1234 - lookup->adev = adev; 1235 - lookup->con_id = kstrdup(con_id, GFP_KERNEL); 1236 - list_add_tail(&lookup->node, &acpi_crs_lookup_list); 1237 - } 1238 - } 1239 - 1240 - mutex_unlock(&acpi_crs_lookup_lock); 1241 - 1242 - return lookup && 1243 - ((!lookup->con_id && !con_id) || 1244 - (lookup->con_id && con_id && 1245 - strcmp(lookup->con_id, con_id) == 0)); 1138 + return con_id == NULL; 1246 1139 }
+4 -1
drivers/gpio/gpiolib-of.c
··· 153 153 *flags |= GPIO_OPEN_SOURCE; 154 154 } 155 155 156 + if (of_flags & OF_GPIO_SLEEP_MAY_LOOSE_VALUE) 157 + *flags |= GPIO_SLEEP_MAY_LOOSE_VALUE; 158 + 156 159 return desc; 157 160 } 158 161 ··· 239 236 * 240 237 * This is only used by of_gpiochip_add to request/set GPIO initial 241 238 * configuration. 242 - * It retures error if it fails otherwise 0 on success. 239 + * It returns error if it fails otherwise 0 on success. 243 240 */ 244 241 static int of_gpiochip_scan_gpios(struct gpio_chip *chip) 245 242 {
+23 -8
drivers/gpio/gpiolib.c
··· 1 - #include <linux/bitops.h> 1 + #include <linux/bitmap.h> 2 2 #include <linux/kernel.h> 3 3 #include <linux/module.h> 4 4 #include <linux/interrupt.h> ··· 1472 1472 1473 1473 static int gpiochip_irqchip_init_valid_mask(struct gpio_chip *gpiochip) 1474 1474 { 1475 - int i; 1476 - 1477 1475 if (!gpiochip->irq_need_valid_mask) 1478 1476 return 0; 1479 1477 ··· 1481 1483 return -ENOMEM; 1482 1484 1483 1485 /* Assume by default all GPIOs are valid */ 1484 - for (i = 0; i < gpiochip->ngpio; i++) 1485 - set_bit(i, gpiochip->irq_valid_mask); 1486 + bitmap_fill(gpiochip->irq_valid_mask, gpiochip->ngpio); 1486 1487 1487 1488 return 0; 1488 1489 } ··· 2867 2870 } 2868 2871 EXPORT_SYMBOL_GPL(gpiochip_line_is_open_source); 2869 2872 2873 + bool gpiochip_line_is_persistent(struct gpio_chip *chip, unsigned int offset) 2874 + { 2875 + if (offset >= chip->ngpio) 2876 + return false; 2877 + 2878 + return !test_bit(FLAG_SLEEP_MAY_LOOSE_VALUE, 2879 + &chip->gpiodev->descs[offset].flags); 2880 + } 2881 + EXPORT_SYMBOL_GPL(gpiochip_line_is_persistent); 2882 + 2870 2883 /** 2871 2884 * gpiod_get_raw_value_cansleep() - return a gpio's raw value 2872 2885 * @desc: gpio whose value will be returned ··· 3016 3009 3017 3010 mutex_unlock(&gpio_lookup_lock); 3018 3011 } 3012 + EXPORT_SYMBOL_GPL(gpiod_add_lookup_table); 3019 3013 3020 3014 /** 3021 3015 * gpiod_remove_lookup_table() - unregister GPIO device consumers ··· 3030 3022 3031 3023 mutex_unlock(&gpio_lookup_lock); 3032 3024 } 3025 + EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table); 3033 3026 3034 3027 static struct gpiod_lookup_table *gpiod_find_lookup_table(struct device *dev) 3035 3028 { ··· 3222 3213 * requested function and/or index, or another IS_ERR() code if an error 3223 3214 * occurred while trying to acquire the GPIO. 3224 3215 */ 3225 - static int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, 3216 + int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, 3226 3217 unsigned long lflags, enum gpiod_flags dflags) 3227 3218 { 3228 3219 int status; ··· 3233 3224 set_bit(FLAG_OPEN_DRAIN, &desc->flags); 3234 3225 if (lflags & GPIO_OPEN_SOURCE) 3235 3226 set_bit(FLAG_OPEN_SOURCE, &desc->flags); 3227 + if (lflags & GPIO_SLEEP_MAY_LOOSE_VALUE) 3228 + set_bit(FLAG_SLEEP_MAY_LOOSE_VALUE, &desc->flags); 3236 3229 3237 3230 /* No particular flag request, return here... */ 3238 3231 if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) { ··· 3284 3273 desc = of_find_gpio(dev, con_id, idx, &lookupflags); 3285 3274 } else if (ACPI_COMPANION(dev)) { 3286 3275 dev_dbg(dev, "using ACPI for GPIO lookup\n"); 3287 - desc = acpi_find_gpio(dev, con_id, idx, flags, &lookupflags); 3276 + desc = acpi_find_gpio(dev, con_id, idx, &flags, &lookupflags); 3288 3277 } 3289 3278 } 3290 3279 ··· 3365 3354 struct acpi_gpio_info info; 3366 3355 3367 3356 desc = acpi_node_get_gpiod(fwnode, propname, index, &info); 3368 - if (!IS_ERR(desc)) 3357 + if (!IS_ERR(desc)) { 3369 3358 active_low = info.polarity == GPIO_ACTIVE_LOW; 3359 + ret = acpi_gpio_update_gpiod_flags(&dflags, info.flags); 3360 + if (ret) 3361 + pr_debug("Override GPIO initialization flags\n"); 3362 + } 3370 3363 } 3371 3364 3372 3365 if (IS_ERR(desc))
+16 -2
drivers/gpio/gpiolib.h
··· 75 75 76 76 /** 77 77 * struct acpi_gpio_info - ACPI GPIO specific information 78 + * @flags: GPIO initialization flags 78 79 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo 79 80 * @polarity: interrupt polarity as provided by ACPI 80 81 * @triggering: triggering type as provided by ACPI 81 82 */ 82 83 struct acpi_gpio_info { 84 + enum gpiod_flags flags; 83 85 bool gpioint; 84 86 int polarity; 85 87 int triggering; ··· 123 121 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); 124 122 void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); 125 123 124 + int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, 125 + enum gpiod_flags update); 126 + 126 127 struct gpio_desc *acpi_find_gpio(struct device *dev, 127 128 const char *con_id, 128 129 unsigned int idx, 129 - enum gpiod_flags flags, 130 + enum gpiod_flags *dflags, 130 131 enum gpio_lookup_flags *lookupflags); 131 132 struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, 132 133 const char *propname, int index, ··· 148 143 static inline void 149 144 acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { } 150 145 146 + static inline int 147 + acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, enum gpiod_flags update) 148 + { 149 + return 0; 150 + } 151 + 151 152 static inline struct gpio_desc * 152 153 acpi_find_gpio(struct device *dev, const char *con_id, 153 - unsigned int idx, enum gpiod_flags flags, 154 + unsigned int idx, enum gpiod_flags *dflags, 154 155 enum gpio_lookup_flags *lookupflags) 155 156 { 156 157 return ERR_PTR(-ENOENT); ··· 201 190 #define FLAG_OPEN_SOURCE 8 /* Gpio is open source type */ 202 191 #define FLAG_USED_AS_IRQ 9 /* GPIO is connected to an IRQ */ 203 192 #define FLAG_IS_HOGGED 11 /* GPIO is hogged */ 193 + #define FLAG_SLEEP_MAY_LOOSE_VALUE 12 /* GPIO may loose value in sleep */ 204 194 205 195 /* Connection label */ 206 196 const char *label; ··· 211 199 212 200 int gpiod_request(struct gpio_desc *desc, const char *label); 213 201 void gpiod_free(struct gpio_desc *desc); 202 + int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id, 203 + unsigned long lflags, enum gpiod_flags dflags); 214 204 int gpiod_hog(struct gpio_desc *desc, const char *name, 215 205 unsigned long lflags, enum gpiod_flags dflags); 216 206
+1 -1
drivers/input/keyboard/adp5588-keys.c
··· 20 20 #include <linux/gpio.h> 21 21 #include <linux/slab.h> 22 22 23 - #include <linux/i2c/adp5588.h> 23 + #include <linux/platform_data/adp5588.h> 24 24 25 25 /* Key Event Register xy */ 26 26 #define KEY_EV_PRESSED (1 << 7)
+25 -13
drivers/pnp/pnpacpi/rsparser.c
··· 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 17 * General Public License for more details. 18 - * 19 - * You should have received a copy of the GNU General Public License 20 - * along with this program; if not, write to the Free Software 21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 18 */ 23 19 #include <linux/kernel.h> 24 20 #include <linux/acpi.h> ··· 145 149 uuid_len == sizeof(match->data) && 146 150 memcmp(uuid, match->data, uuid_len) == 0) { 147 151 if (expected_len && expected_len != actual_len) { 148 - dev_err(&dev->dev, "wrong vendor descriptor size; " 149 - "expected %d, found %d bytes\n", 152 + dev_err(&dev->dev, 153 + "wrong vendor descriptor size; expected %d, found %d bytes\n", 150 154 expected_len, actual_len); 151 155 return 0; 152 156 } ··· 176 180 struct pnp_dev *dev = data; 177 181 struct acpi_resource_dma *dma; 178 182 struct acpi_resource_vendor_typed *vendor_typed; 183 + struct acpi_resource_gpio *gpio; 179 184 struct resource_win win = {{0}, 0}; 180 185 struct resource *r = &win.res; 181 186 int i, flags; ··· 200 203 * one interrupt, we won't be able to re-encode it. 201 204 */ 202 205 if (pnp_can_write(dev)) { 203 - dev_warn(&dev->dev, "multiple interrupts in " 204 - "_CRS descriptor; configuration can't " 205 - "be changed\n"); 206 + dev_warn(&dev->dev, 207 + "multiple interrupts in _CRS descriptor; configuration can't be changed\n"); 206 208 dev->capabilities &= ~PNP_WRITE; 207 209 } 208 210 } 211 + return AE_OK; 212 + } else if (acpi_gpio_get_irq_resource(res, &gpio)) { 213 + /* 214 + * If the resource is GpioInt() type then extract the IRQ 215 + * from GPIO resource and fill it into IRQ resource type. 216 + */ 217 + i = acpi_dev_gpio_irq_get(dev->data, 0); 218 + if (i >= 0) { 219 + flags = acpi_dev_irq_flags(gpio->triggering, 220 + gpio->polarity, 221 + gpio->sharable); 222 + } else { 223 + flags = IORESOURCE_DISABLED; 224 + } 225 + pnp_add_irq_resource(dev, i, flags); 209 226 return AE_OK; 210 227 } else if (r->flags & IORESOURCE_DISABLED) { 211 228 pnp_add_irq_resource(dev, 0, IORESOURCE_DISABLED); ··· 342 331 if (p->interrupts[i] < PNP_IRQ_NR) 343 332 __set_bit(p->interrupts[i], map.bits); 344 333 else 345 - dev_err(&dev->dev, "ignoring IRQ %d option " 346 - "(too large for %d entry bitmap)\n", 334 + dev_err(&dev->dev, 335 + "ignoring IRQ %d option (too large for %d entry bitmap)\n", 347 336 p->interrupts[i], PNP_IRQ_NR); 348 337 } 349 338 } ··· 944 933 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: 945 934 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: 946 935 default: /* other type */ 947 - dev_warn(&dev->dev, "can't encode unknown resource " 948 - "type %d\n", resource->type); 936 + dev_warn(&dev->dev, 937 + "can't encode unknown resource type %d\n", 938 + resource->type); 949 939 return -EINVAL; 950 940 } 951 941 resource++;
+168 -5
drivers/tty/serial/8250/8250_exar.c
··· 9 9 * it under the terms of the GNU General Public License as published by 10 10 * the Free Software Foundation; either version 2 of the License. 11 11 */ 12 + #include <linux/acpi.h> 13 + #include <linux/dmi.h> 12 14 #include <linux/io.h> 13 15 #include <linux/kernel.h> 14 16 #include <linux/module.h> 15 17 #include <linux/pci.h> 18 + #include <linux/property.h> 16 19 #include <linux/serial_core.h> 17 20 #include <linux/serial_reg.h> 18 21 #include <linux/slab.h> ··· 63 60 #define UART_EXAR_MPIOSEL_15_8 0x99 /* MPIOSEL[15:8] */ 64 61 #define UART_EXAR_MPIOOD_15_8 0x9a /* MPIOOD[15:8] */ 65 62 63 + #define UART_EXAR_RS485_DLY(x) ((x) << 4) 64 + 65 + /* 66 + * IOT2040 MPIO wiring semantics: 67 + * 68 + * MPIO Port Function 69 + * ---- ---- -------- 70 + * 0 2 Mode bit 0 71 + * 1 2 Mode bit 1 72 + * 2 2 Terminate bus 73 + * 3 - <reserved> 74 + * 4 3 Mode bit 0 75 + * 5 3 Mode bit 1 76 + * 6 3 Terminate bus 77 + * 7 - <reserved> 78 + * 8 2 Enable 79 + * 9 3 Enable 80 + * 10 - Red LED 81 + * 11..15 - <unused> 82 + */ 83 + 84 + /* IOT2040 MPIOs 0..7 */ 85 + #define IOT2040_UART_MODE_RS232 0x01 86 + #define IOT2040_UART_MODE_RS485 0x02 87 + #define IOT2040_UART_MODE_RS422 0x03 88 + #define IOT2040_UART_TERMINATE_BUS 0x04 89 + 90 + #define IOT2040_UART1_MASK 0x0f 91 + #define IOT2040_UART2_SHIFT 4 92 + 93 + #define IOT2040_UARTS_DEFAULT_MODE 0x11 /* both RS232 */ 94 + #define IOT2040_UARTS_GPIO_LO_MODE 0x88 /* reserved pins as input */ 95 + 96 + /* IOT2040 MPIOs 8..15 */ 97 + #define IOT2040_UARTS_ENABLE 0x03 98 + #define IOT2040_UARTS_GPIO_HI_MODE 0xF8 /* enable & LED as outputs */ 99 + 66 100 struct exar8250; 101 + 102 + struct exar8250_platform { 103 + int (*rs485_config)(struct uart_port *, struct serial_rs485 *); 104 + int (*register_gpio)(struct pci_dev *, struct uart_8250_port *); 105 + }; 67 106 68 107 /** 69 108 * struct exar8250_board - board information ··· 239 194 } 240 195 241 196 static void * 242 - xr17v35x_register_gpio(struct pci_dev *pcidev) 197 + __xr17v35x_register_gpio(struct pci_dev *pcidev, 198 + const struct property_entry *properties) 243 199 { 244 200 struct platform_device *pdev; 245 201 ··· 248 202 if (!pdev) 249 203 return NULL; 250 204 251 - platform_set_drvdata(pdev, pcidev); 252 - if (platform_device_add(pdev) < 0) { 205 + pdev->dev.parent = &pcidev->dev; 206 + ACPI_COMPANION_SET(&pdev->dev, ACPI_COMPANION(&pcidev->dev)); 207 + 208 + if (platform_device_add_properties(pdev, properties) < 0 || 209 + platform_device_add(pdev) < 0) { 253 210 platform_device_put(pdev); 254 211 return NULL; 255 212 } ··· 260 211 return pdev; 261 212 } 262 213 214 + static const struct property_entry exar_gpio_properties[] = { 215 + PROPERTY_ENTRY_U32("linux,first-pin", 0), 216 + PROPERTY_ENTRY_U32("ngpios", 16), 217 + { } 218 + }; 219 + 220 + static int xr17v35x_register_gpio(struct pci_dev *pcidev, 221 + struct uart_8250_port *port) 222 + { 223 + if (pcidev->vendor == PCI_VENDOR_ID_EXAR) 224 + port->port.private_data = 225 + __xr17v35x_register_gpio(pcidev, exar_gpio_properties); 226 + 227 + return 0; 228 + } 229 + 230 + static const struct exar8250_platform exar8250_default_platform = { 231 + .register_gpio = xr17v35x_register_gpio, 232 + }; 233 + 234 + static int iot2040_rs485_config(struct uart_port *port, 235 + struct serial_rs485 *rs485) 236 + { 237 + bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED); 238 + u8 __iomem *p = port->membase; 239 + u8 mask = IOT2040_UART1_MASK; 240 + u8 mode, value; 241 + 242 + if (is_rs485) { 243 + if (rs485->flags & SER_RS485_RX_DURING_TX) 244 + mode = IOT2040_UART_MODE_RS422; 245 + else 246 + mode = IOT2040_UART_MODE_RS485; 247 + 248 + if (rs485->flags & SER_RS485_TERMINATE_BUS) 249 + mode |= IOT2040_UART_TERMINATE_BUS; 250 + } else { 251 + mode = IOT2040_UART_MODE_RS232; 252 + } 253 + 254 + if (port->line == 3) { 255 + mask <<= IOT2040_UART2_SHIFT; 256 + mode <<= IOT2040_UART2_SHIFT; 257 + } 258 + 259 + value = readb(p + UART_EXAR_MPIOLVL_7_0); 260 + value &= ~mask; 261 + value |= mode; 262 + writeb(value, p + UART_EXAR_MPIOLVL_7_0); 263 + 264 + value = readb(p + UART_EXAR_FCTR); 265 + if (is_rs485) 266 + value |= UART_FCTR_EXAR_485; 267 + else 268 + value &= ~UART_FCTR_EXAR_485; 269 + writeb(value, p + UART_EXAR_FCTR); 270 + 271 + if (is_rs485) 272 + writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR); 273 + 274 + port->rs485 = *rs485; 275 + 276 + return 0; 277 + } 278 + 279 + static const struct property_entry iot2040_gpio_properties[] = { 280 + PROPERTY_ENTRY_U32("linux,first-pin", 10), 281 + PROPERTY_ENTRY_U32("ngpios", 1), 282 + { } 283 + }; 284 + 285 + static int iot2040_register_gpio(struct pci_dev *pcidev, 286 + struct uart_8250_port *port) 287 + { 288 + u8 __iomem *p = port->port.membase; 289 + 290 + writeb(IOT2040_UARTS_DEFAULT_MODE, p + UART_EXAR_MPIOLVL_7_0); 291 + writeb(IOT2040_UARTS_GPIO_LO_MODE, p + UART_EXAR_MPIOSEL_7_0); 292 + writeb(IOT2040_UARTS_ENABLE, p + UART_EXAR_MPIOLVL_15_8); 293 + writeb(IOT2040_UARTS_GPIO_HI_MODE, p + UART_EXAR_MPIOSEL_15_8); 294 + 295 + port->port.private_data = 296 + __xr17v35x_register_gpio(pcidev, iot2040_gpio_properties); 297 + 298 + return 0; 299 + } 300 + 301 + static const struct exar8250_platform iot2040_platform = { 302 + .rs485_config = iot2040_rs485_config, 303 + .register_gpio = iot2040_register_gpio, 304 + }; 305 + 306 + static const struct dmi_system_id exar_platforms[] = { 307 + { 308 + .matches = { 309 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"), 310 + DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG, 311 + "6ES7647-0AA00-1YA2"), 312 + }, 313 + .driver_data = (void *)&iot2040_platform, 314 + }, 315 + {} 316 + }; 317 + 263 318 static int 264 319 pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev, 265 320 struct uart_8250_port *port, int idx) 266 321 { 267 322 const struct exar8250_board *board = priv->board; 323 + const struct exar8250_platform *platform; 324 + const struct dmi_system_id *dmi_match; 268 325 unsigned int offset = idx * 0x400; 269 326 unsigned int baud = 7812500; 270 327 u8 __iomem *p; 271 328 int ret; 272 329 330 + dmi_match = dmi_first_match(exar_platforms); 331 + if (dmi_match) 332 + platform = dmi_match->driver_data; 333 + else 334 + platform = &exar8250_default_platform; 335 + 273 336 port->port.uartclk = baud * 16; 337 + port->port.rs485_config = platform->rs485_config; 338 + 274 339 /* 275 340 * Setup the uart clock for the devices on expansion slot to 276 341 * half the clock speed of the main chip (which is 125MHz) ··· 407 244 /* Setup Multipurpose Input/Output pins. */ 408 245 setup_gpio(pcidev, p); 409 246 410 - port->port.private_data = xr17v35x_register_gpio(pcidev); 247 + ret = platform->register_gpio(pcidev, port); 411 248 } 412 249 413 - return 0; 250 + return ret; 414 251 } 415 252 416 253 static void pci_xr17v35x_exit(struct pci_dev *pcidev)
+4
include/dt-bindings/gpio/gpio.h
··· 28 28 #define GPIO_OPEN_DRAIN (GPIO_SINGLE_ENDED | GPIO_LINE_OPEN_DRAIN) 29 29 #define GPIO_OPEN_SOURCE (GPIO_SINGLE_ENDED | GPIO_LINE_OPEN_SOURCE) 30 30 31 + /* Bit 3 express GPIO suspend/resume persistence */ 32 + #define GPIO_SLEEP_MAINTAIN_VALUE 0 33 + #define GPIO_SLEEP_MAY_LOOSE_VALUE 8 34 + 31 35 #endif
+7
include/linux/acpi.h
··· 964 964 const struct acpi_gpio_mapping *gpios); 965 965 void devm_acpi_dev_remove_driver_gpios(struct device *dev); 966 966 967 + bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, 968 + struct acpi_resource_gpio **agpio); 967 969 int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index); 968 970 #else 969 971 static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev, ··· 982 980 } 983 981 static inline void devm_acpi_dev_remove_driver_gpios(struct device *dev) {} 984 982 983 + static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, 984 + struct acpi_resource_gpio **agpio) 985 + { 986 + return false; 987 + } 985 988 static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) 986 989 { 987 990 return -ENXIO;
+3
include/linux/gpio/driver.h
··· 213 213 bool gpiochip_line_is_open_drain(struct gpio_chip *chip, unsigned int offset); 214 214 bool gpiochip_line_is_open_source(struct gpio_chip *chip, unsigned int offset); 215 215 216 + /* Sleep persistence inquiry for drivers */ 217 + bool gpiochip_line_is_persistent(struct gpio_chip *chip, unsigned int offset); 218 + 216 219 /* get driver data */ 217 220 void *gpiochip_get_data(struct gpio_chip *chip); 218 221
+2
include/linux/gpio/machine.h
··· 9 9 GPIO_ACTIVE_LOW = (1 << 0), 10 10 GPIO_OPEN_DRAIN = (1 << 1), 11 11 GPIO_OPEN_SOURCE = (1 << 2), 12 + GPIO_SLEEP_MAINTAIN_VALUE = (0 << 3), 13 + GPIO_SLEEP_MAY_LOOSE_VALUE = (1 << 3), 12 14 }; 13 15 14 16 /**
include/linux/i2c/adp5588.h include/linux/platform_data/adp5588.h
include/linux/i2c/max732x.h include/linux/platform_data/max732x.h
include/linux/i2c/pcf857x.h include/linux/platform_data/pcf857x.h
+1
include/linux/of_gpio.h
··· 31 31 OF_GPIO_ACTIVE_LOW = 0x1, 32 32 OF_GPIO_SINGLE_ENDED = 0x2, 33 33 OF_GPIO_OPEN_DRAIN = 0x4, 34 + OF_GPIO_SLEEP_MAY_LOOSE_VALUE = 0x8, 34 35 }; 35 36 36 37 #ifdef CONFIG_OF_GPIO
+1 -1
include/linux/platform_device.h
··· 172 172 extern int platform_device_add_data(struct platform_device *pdev, 173 173 const void *data, size_t size); 174 174 extern int platform_device_add_properties(struct platform_device *pdev, 175 - struct property_entry *properties); 175 + const struct property_entry *properties); 176 176 extern int platform_device_add(struct platform_device *pdev); 177 177 extern void platform_device_del(struct platform_device *pdev); 178 178 extern void platform_device_put(struct platform_device *pdev);