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

Merge tag 'gpio-v5.6-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 v5.6 kernel cycle.

This is a pretty calm cycle so far, nothing special going on really.
Some more changes will come in from the irqchip and pin control trees.

I also deleted an orphan include file for FMC that was dangling since
subsystem was removed.

Core changes:

- Document the usecases for the kernelspace vs userspace handling of
GPIOs.

- Handle MSI (message signalled interrupts) properly in the core
hierarchical irqdomain code.

- Fix a rare race condition while initializing the descriptor array.

New drivers:

- Xylon LogiCVC GPIO driver.

- WDC934x GPIO controller driver.

Driver improvements:

- Implemented suspend/resume in the Tegra driver.

- MPC8xx edge detection fixup.

- Properly convert ThunderX to use hierarchical irqdomain with
GPIOLIB_IRQCHIP on top of the revert of the previous buggy
switchover. This time it works (hopefully).

Misc:

- Drop a FMC remnant file <linux/ipmi-fru.h>

- A slew of fixes"

* tag 'gpio-v5.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (48 commits)
MAINTAINERS: Replace Tien Hock Loh as Altera PIO maintainer
gpiolib: hold gpio devices lock until ->descs array is initialised
gpio: aspeed-sgpio: fixed typos
gpio: mvebu: clear irq in edge cause register before unmask edge irq
gpiolib: Lower verbosity when allocating hierarchy irq
gpiolib: Remove duplicated function gpio_do_set_config()
gpio: Fix the no return statement warning
gpio: wcd934x: Add support to wcd934x gpio controller
gpiolib: remove set but not used variable 'config'
gpio: vx855: fixed a typo
gpio: mockup: sort headers alphabetically
gpio: mockup: update the license tag
gpio: Remove the unused flags
gpiolib: Set lockdep class for hierarchical irq domains
gpio: thunderx: Switch to GPIOLIB_IRQCHIP
gpiolib: Add the support for the msi parent domain
gpiolib: Add support for the irqdomain which doesn't use irq_fwspec as arg
gpio: Add use guidance documentation
dt-bindings: gpio: wcd934x: Add bindings for gpio
gpio: altera: change to platform_get_irq_optional to avoid false-positive error
...

+814 -413
+47
Documentation/devicetree/bindings/gpio/qcom,wcd934x-gpio.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/qcom,wcd934x-gpio.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: WCD9340/WCD9341 GPIO controller 8 + 9 + maintainers: 10 + - Srinivas Kandagatla <srinivas.kandagatla@linaro.org> 11 + 12 + description: | 13 + Qualcomm Technologies Inc WCD9340/WCD9341 Audio Codec has integrated 14 + gpio controller to control 5 gpios on the chip. 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - qcom,wcd9340-gpio 20 + - qcom,wcd9341-gpio 21 + 22 + reg: 23 + maxItems: 1 24 + 25 + gpio-controller: true 26 + 27 + '#gpio-cells': 28 + const: 2 29 + 30 + required: 31 + - compatible 32 + - reg 33 + - gpio-controller 34 + - "#gpio-cells" 35 + 36 + additionalProperties: false 37 + 38 + examples: 39 + - | 40 + wcdgpio: gpio@42 { 41 + compatible = "qcom,wcd9340-gpio"; 42 + reg = <0x042 0x2>; 43 + gpio-controller; 44 + #gpio-cells = <2>; 45 + }; 46 + 47 + ...
+2 -1
Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
··· 18 18 - "renesas,gpio-r8a7793": for R8A7793 (R-Car M2-N) compatible GPIO controller. 19 19 - "renesas,gpio-r8a7794": for R8A7794 (R-Car E2) compatible GPIO controller. 20 20 - "renesas,gpio-r8a7795": for R8A7795 (R-Car H3) compatible GPIO controller. 21 - - "renesas,gpio-r8a7796": for R8A7796 (R-Car M3-W) compatible GPIO controller. 21 + - "renesas,gpio-r8a7796": for R8A77960 (R-Car M3-W) compatible GPIO controller. 22 + - "renesas,gpio-r8a77961": for R8A77961 (R-Car M3-W+) compatible GPIO controller. 22 23 - "renesas,gpio-r8a77965": for R8A77965 (R-Car M3-N) compatible GPIO controller. 23 24 - "renesas,gpio-r8a77970": for R8A77970 (R-Car V3M) compatible GPIO controller. 24 25 - "renesas,gpio-r8a77980": for R8A77980 (R-Car V3H) compatible GPIO controller.
+69
Documentation/devicetree/bindings/gpio/xylon,logicvc-gpio.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + # Copyright 2019 Bootlin 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/gpio/xylon,logicvc-gpio.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Xylon LogiCVC GPIO controller 9 + 10 + maintainers: 11 + - Paul Kocialkowski <paul.kocialkowski@bootlin.com> 12 + 13 + description: | 14 + The LogiCVC GPIO describes the GPIO block included in the LogiCVC display 15 + controller. These are meant to be used for controlling display-related 16 + signals. 17 + 18 + The controller exposes GPIOs from the display and power control registers, 19 + which are mapped by the driver as follows: 20 + - GPIO[4:0] (display control) mapped to index 0-4 21 + - EN_BLIGHT (power control) mapped to index 5 22 + - EN_VDD (power control) mapped to index 6 23 + - EN_VEE (power control) mapped to index 7 24 + - V_EN (power control) mapped to index 8 25 + 26 + properties: 27 + $nodename: 28 + pattern: "^gpio@[0-9a-f]+$" 29 + 30 + compatible: 31 + enum: 32 + - xylon,logicvc-3.02.a-gpio 33 + 34 + reg: 35 + maxItems: 1 36 + 37 + "#gpio-cells": 38 + const: 2 39 + 40 + gpio-controller: true 41 + 42 + gpio-line-names: 43 + minItems: 1 44 + maxItems: 9 45 + 46 + required: 47 + - compatible 48 + - reg 49 + - "#gpio-cells" 50 + - gpio-controller 51 + 52 + examples: 53 + - | 54 + logicvc: logicvc@43c00000 { 55 + compatible = "xylon,logicvc-3.02.a", "syscon", "simple-mfd"; 56 + reg = <0x43c00000 0x6000>; 57 + 58 + #address-cells = <1>; 59 + #size-cells = <1>; 60 + 61 + logicvc_gpio: gpio@40 { 62 + compatible = "xylon,logicvc-3.02.a-gpio"; 63 + reg = <0x40 0x40>; 64 + gpio-controller; 65 + #gpio-cells = <2>; 66 + gpio-line-names = "GPIO0", "GPIO1", "GPIO2", "GPIO3", "GPIO4", 67 + "EN_BLIGHT", "EN_VDD", "EN_VEE", "V_EN"; 68 + }; 69 + };
+50
Documentation/devicetree/bindings/mfd/xylon,logicvc.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + # Copyright 2019 Bootlin 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/mfd/xylon,logicvc.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Xylon LogiCVC multi-function device 9 + 10 + maintainers: 11 + - Paul Kocialkowski <paul.kocialkowski@bootlin.com> 12 + 13 + description: | 14 + The LogiCVC is a display controller that also contains a GPIO controller. 15 + As a result, a multi-function device is exposed as parent of the display 16 + and GPIO blocks. 17 + 18 + properties: 19 + compatible: 20 + items: 21 + - enum: 22 + - xylon,logicvc-3.02.a 23 + - const: syscon 24 + - const: simple-mfd 25 + 26 + reg: 27 + maxItems: 1 28 + 29 + select: 30 + properties: 31 + compatible: 32 + contains: 33 + enum: 34 + - xylon,logicvc-3.02.a 35 + 36 + required: 37 + - compatible 38 + 39 + required: 40 + - compatible 41 + - reg 42 + 43 + examples: 44 + - | 45 + logicvc: logicvc@43c00000 { 46 + compatible = "xylon,logicvc-3.02.a", "syscon", "simple-mfd"; 47 + reg = <0x43c00000 0x6000>; 48 + #address-cells = <1>; 49 + #size-cells = <1>; 50 + };
+2
Documentation/devicetree/bindings/vendor-prefixes.yaml
··· 1060 1060 description: Xilinx 1061 1061 "^xunlong,.*": 1062 1062 description: Shenzhen Xunlong Software CO.,Limited 1063 + "^xylon,.*": 1064 + description: Xylon 1063 1065 "^yones-toptech,.*": 1064 1066 description: Yones Toptech Co., Ltd. 1065 1067 "^ysoft,.*":
+2
Documentation/driver-api/driver-model/devres.rst
··· 267 267 268 268 GPIO 269 269 devm_gpiod_get() 270 + devm_gpiod_get_array() 271 + devm_gpiod_get_array_optional() 270 272 devm_gpiod_get_index() 271 273 devm_gpiod_get_index_optional() 272 274 devm_gpiod_get_optional()
+4 -4
Documentation/driver-api/gpio/drivers-on-gpio.rst
··· 95 95 MTD NOR flash has add-ons for extra GPIO lines too, though the address bus is 96 96 usually connected directly to the flash. 97 97 98 - Use those instead of talking directly to the GPIOs using sysfs; they integrate 99 - with kernel frameworks better than your userspace code could. Needless to say, 100 - just using the appropriate kernel drivers will simplify and speed up your 101 - embedded hacking in particular by providing ready-made components. 98 + Use those instead of talking directly to the GPIOs from userspace; they 99 + integrate with kernel frameworks better than your userspace code could. 100 + Needless to say, just using the appropriate kernel drivers will simplify and 101 + speed up your embedded hacking in particular by providing ready-made components.
+1
Documentation/driver-api/gpio/index.rst
··· 8 8 :maxdepth: 2 9 9 10 10 intro 11 + using-gpio 11 12 driver 12 13 consumer 13 14 board
+50
Documentation/driver-api/gpio/using-gpio.rst
··· 1 + ========================= 2 + Using GPIO Lines in Linux 3 + ========================= 4 + 5 + The Linux kernel exists to abstract and present hardware to users. GPIO lines 6 + as such are normally not user facing abstractions. The most obvious, natural 7 + and preferred way to use GPIO lines is to let kernel hardware drivers deal 8 + with them. 9 + 10 + For examples of already existing generic drivers that will also be good 11 + examples for any other kernel drivers you want to author, refer to 12 + :doc:`drivers-on-gpio` 13 + 14 + For any kind of mass produced system you want to support, such as servers, 15 + laptops, phones, tablets, routers, and any consumer or office or business goods 16 + using appropriate kernel drivers is paramount. Submit your code for inclusion 17 + in the upstream Linux kernel when you feel it is mature enough and you will get 18 + help to refine it, see :doc:`../../process/submitting-patches`. 19 + 20 + In Linux GPIO lines also have a userspace ABI. 21 + 22 + The userspace ABI is intended for one-off deployments. Examples are prototypes, 23 + factory lines, maker community projects, workshop specimen, production tools, 24 + industrial automation, PLC-type use cases, door controllers, in short a piece 25 + of specialized equipment that is not produced by the numbers, requiring 26 + operators to have a deep knowledge of the equipment and knows about the 27 + software-hardware interface to be set up. They should not have a natural fit 28 + to any existing kernel subsystem and not be a good fit for an operating system, 29 + because of not being reusable or abstract enough, or involving a lot of non 30 + computer hardware related policy. 31 + 32 + Applications that have a good reason to use the industrial I/O (IIO) subsystem 33 + from userspace will likely be a good fit for using GPIO lines from userspace as 34 + well. 35 + 36 + Do not under any circumstances abuse the GPIO userspace ABI to cut corners in 37 + any product development projects. If you use it for prototyping, then do not 38 + productify the prototype: rewrite it using proper kernel drivers. Do not under 39 + any circumstances deploy any uniform products using GPIO from userspace. 40 + 41 + The userspace ABI is a character device for each GPIO hardware unit (GPIO chip). 42 + These devices will appear on the system as ``/dev/gpiochip0`` thru 43 + ``/dev/gpiochipN``. Examples of how to directly use the userspace ABI can be 44 + found in the kernel tree ``tools/gpio`` subdirectory. 45 + 46 + For structured and managed applications, we recommend that you make use of the 47 + libgpiod_ library. This provides helper abstractions, command line utlities 48 + and arbitration for multiple simultaneous consumers on the same GPIO chip. 49 + 50 + .. _libgpiod: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/
+1 -1
MAINTAINERS
··· 734 734 F: drivers/mailbox/mailbox-altera.c 735 735 736 736 ALTERA PIO DRIVER 737 - M: Tien Hock Loh <thloh@altera.com> 737 + M: Joyce Ooi <joyce.ooi@intel.com> 738 738 L: linux-gpio@vger.kernel.org 739 739 S: Maintained 740 740 F: drivers/gpio/gpio-altera.c
+14
drivers/gpio/Kconfig
··· 312 312 IXP4xx series of chips. 313 313 314 314 If unsure, say N. 315 + config GPIO_LOGICVC 316 + tristate "Xylon LogiCVC GPIO support" 317 + depends on MFD_SYSCON && OF 318 + help 319 + Say yes here to support GPIO functionality of the Xylon LogiCVC 320 + programmable logic block. 315 321 316 322 config GPIO_LOONGSON 317 323 bool "Loongson-2/3 GPIO support" ··· 588 582 tristate "Cavium ThunderX/OCTEON-TX GPIO" 589 583 depends on ARCH_THUNDER || (64BIT && COMPILE_TEST) 590 584 depends on PCI_MSI 585 + select GPIOLIB_IRQCHIP 591 586 select IRQ_DOMAIN_HIERARCHY 592 587 select IRQ_FASTEOI_HIERARCHY_HANDLERS 593 588 help ··· 627 620 This driver provides common support for accessing the device, 628 621 additional drivers must be enabled in order to use the 629 622 functionality of the device. 623 + 624 + config GPIO_WCD934X 625 + tristate "Qualcomm Technologies Inc WCD9340/WCD9341 gpio controller driver" 626 + depends on MFD_WCD934X && OF_GPIO 627 + help 628 + This driver is to supprot GPIO block found on the Qualcomm Technologies 629 + Inc WCD9340/WCD9341 Audio Codec. 630 630 631 631 config GPIO_XGENE 632 632 bool "APM X-Gene GPIO controller support"
+2
drivers/gpio/Makefile
··· 69 69 obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4xx.o 70 70 obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o 71 71 obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o 72 + obj-$(CONFIG_GPIO_LOGICVC) += gpio-logicvc.o 72 73 obj-$(CONFIG_GPIO_LOONGSON1) += gpio-loongson1.o 73 74 obj-$(CONFIG_GPIO_LOONGSON) += gpio-loongson.o 74 75 obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o ··· 159 158 obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o 160 159 obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o 161 160 obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o 161 + obj-$(CONFIG_GPIO_WCD934X) += gpio-wcd934x.o 162 162 obj-$(CONFIG_GPIO_WHISKEY_COVE) += gpio-wcove.o 163 163 obj-$(CONFIG_GPIO_WINBOND) += gpio-winbond.o 164 164 obj-$(CONFIG_GPIO_WM831X) += gpio-wm831x.o
+41 -5
drivers/gpio/TODO
··· 10 10 ideally have no use or idea of the global GPIO numberspace that has/was 11 11 used in the inception of the GPIO subsystem. 12 12 13 + The numberspace issue is the same as to why irq is moving away from irq 14 + numbers to IRQ descriptors. 15 + 16 + The underlying motivation for this is that the GPIO numberspace has become 17 + unmanageable: machine board files tend to become full of macros trying to 18 + establish the numberspace at compile-time, making it hard to add any numbers 19 + in the middle (such as if you missed a pin on a chip) without the numberspace 20 + breaking. 21 + 22 + Machine descriptions such as device tree or ACPI does not have a concept of the 23 + Linux GPIO number as those descriptions are external to the Linux kernel 24 + and treat GPIO lines as abstract entities. 25 + 26 + The runtime-assigned GPIO numberspace (what you get if you assign the GPIO 27 + base as -1 in struct gpio_chip) has also became unpredictable due to factors 28 + such as probe ordering and the introduction of -EPROBE_DEFER making probe 29 + ordering of independent GPIO chips essentially unpredictable, as their base 30 + number will be assigned on a first come first serve basis. 31 + 32 + The best way to get out of the problem is to make the global GPIO numbers 33 + unimportant by simply not using them. GPIO descriptors deal with this. 34 + 13 35 Work items: 14 36 15 37 - Convert all GPIO device drivers to only #include <linux/gpio/driver.h> ··· 55 33 driver infrastructure for doing simpler MMIO GPIO devices and there was 56 34 no core support for parsing device tree GPIOs from the core library with 57 35 the [devm_]gpiod_get() calls we have today that will implicitly go into 58 - the device tree back-end. 36 + the device tree back-end. It is legacy and should not be used in new code. 59 37 60 38 Work items: 61 39 ··· 79 57 80 58 - Delete <linux/of_gpio.h> when all the above is complete and everything 81 59 uses <linux/gpio/consumer.h> or <linux/gpio/driver.h> instead. 60 + 61 + 62 + Get rid of <linux/gpio.h> 63 + 64 + This legacy header is a one stop shop for anything GPIO is closely tied 65 + to the global GPIO numberspace. The endgame of the above refactorings will 66 + be the removal of <linux/gpio.h> and from that point only the specialized 67 + headers under <linux/gpio/*.h> will be used. This requires all the above to 68 + be completed and is expected to take a long time. 82 69 83 70 84 71 Collect drivers ··· 140 109 141 110 int irq; /* from platform etc */ 142 111 struct my_gpio *g; 143 - struct gpio_irq_chip *girq 112 + struct gpio_irq_chip *girq; 144 113 145 114 /* Set up the irqchip dynamically */ 146 115 g->irq.name = "my_gpio_irq"; ··· 168 137 - Look over and identify any remaining easily converted drivers and 169 138 dry-code conversions to gpiolib irqchip for maintainers to test 170 139 171 - - Support generic hierarchical GPIO interrupts: these are for the 172 - non-cascading case where there is one IRQ per GPIO line, there is 173 - currently no common infrastructure for this. 140 + - Drop gpiochip_set_chained_irqchip() when all the chained irqchips 141 + have been converted to the above infrastructure. 142 + 143 + - Add more infrastructure to make it possible to also pass a threaded 144 + irqchip in struct gpio_irq_chip. 145 + 146 + - Drop gpiochip_irqchip_add_nested() when all the chained irqchips 147 + have been converted to the above infrastructure. 174 148 175 149 176 150 Increase integration with pin control
+1 -1
drivers/gpio/gpio-altera.c
··· 266 266 altera_gc->mmchip.gc.owner = THIS_MODULE; 267 267 altera_gc->mmchip.gc.parent = &pdev->dev; 268 268 269 - altera_gc->mapped_irq = platform_get_irq(pdev, 0); 269 + altera_gc->mapped_irq = platform_get_irq_optional(pdev, 0); 270 270 271 271 if (altera_gc->mapped_irq < 0) 272 272 goto skip_irq;
+1 -1
drivers/gpio/gpio-aspeed-sgpio.c
··· 391 391 392 392 gpio->irq = rc; 393 393 394 - /* Disable IRQ and clear Interrupt status registers for all SPGIO Pins. */ 394 + /* Disable IRQ and clear Interrupt status registers for all SGPIO Pins. */ 395 395 for (i = 0; i < ARRAY_SIZE(aspeed_sgpio_banks); i++) { 396 396 bank = &aspeed_sgpio_banks[i]; 397 397 /* disable irq enable bits */
+1 -1
drivers/gpio/gpio-aspeed.c
··· 978 978 } 979 979 980 980 /** 981 - * aspeed_gpio_copro_set_ops - Sets the callbacks used for handhsaking with 981 + * aspeed_gpio_copro_set_ops - Sets the callbacks used for handshaking with 982 982 * the coprocessor for shared GPIO banks 983 983 * @ops: The callbacks 984 984 * @data: Pointer passed back to the callbacks
+9 -3
drivers/gpio/gpio-bcm-kona.c
··· 19 19 #include <linux/io.h> 20 20 #include <linux/gpio/driver.h> 21 21 #include <linux/of_device.h> 22 - #include <linux/of_irq.h> 23 22 #include <linux/init.h> 24 23 #include <linux/irqdomain.h> 25 24 #include <linux/irqchip/chained_irq.h> ··· 585 586 586 587 kona_gpio->gpio_chip = template_chip; 587 588 chip = &kona_gpio->gpio_chip; 588 - kona_gpio->num_bank = of_irq_count(dev->of_node); 589 - if (kona_gpio->num_bank == 0) { 589 + ret = platform_irq_count(pdev); 590 + if (!ret) { 590 591 dev_err(dev, "Couldn't determine # GPIO banks\n"); 591 592 return -ENOENT; 593 + } else if (ret < 0) { 594 + if (ret != -EPROBE_DEFER) 595 + dev_err(dev, "Couldn't determine GPIO banks: (%pe)\n", 596 + ERR_PTR(ret)); 597 + return ret; 592 598 } 599 + kona_gpio->num_bank = ret; 600 + 593 601 if (kona_gpio->num_bank > GPIO_MAX_BANK_NUM) { 594 602 dev_err(dev, "Too many GPIO banks configured (max=%d)\n", 595 603 GPIO_MAX_BANK_NUM);
+2 -2
drivers/gpio/gpio-creg-snps.c
··· 64 64 if (layout->bit_per_gpio[i] < 1 || layout->bit_per_gpio[i] > 8) 65 65 return -EINVAL; 66 66 67 - /* Check that on valiue fits it's placeholder */ 67 + /* Check that on value fits its placeholder */ 68 68 if (GENMASK(31, layout->bit_per_gpio[i]) & layout->on[i]) 69 69 return -EINVAL; 70 70 71 - /* Check that off valiue fits it's placeholder */ 71 + /* Check that off value fits its placeholder */ 72 72 if (GENMASK(31, layout->bit_per_gpio[i]) & layout->off[i]) 73 73 return -EINVAL; 74 74
+6 -9
drivers/gpio/gpio-grgpio.c
··· 253 253 lirq->irq = irq; 254 254 uirq = &priv->uirqs[lirq->index]; 255 255 if (uirq->refcnt == 0) { 256 + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); 256 257 ret = request_irq(uirq->uirq, grgpio_irq_handler, 0, 257 258 dev_name(priv->dev), priv); 258 259 if (ret) { 259 260 dev_err(priv->dev, 260 261 "Could not request underlying irq %d\n", 261 262 uirq->uirq); 262 - 263 - spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); 264 - 265 263 return ret; 266 264 } 265 + spin_lock_irqsave(&priv->gc.bgpio_lock, flags); 267 266 } 268 267 uirq->refcnt++; 269 268 ··· 308 309 if (index >= 0) { 309 310 uirq = &priv->uirqs[lirq->index]; 310 311 uirq->refcnt--; 311 - if (uirq->refcnt == 0) 312 + if (uirq->refcnt == 0) { 313 + spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); 312 314 free_irq(uirq->uirq, priv); 315 + return; 316 + } 313 317 } 314 318 315 319 spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); ··· 435 433 static int grgpio_remove(struct platform_device *ofdev) 436 434 { 437 435 struct grgpio_priv *priv = platform_get_drvdata(ofdev); 438 - unsigned long flags; 439 436 int i; 440 437 int ret = 0; 441 - 442 - spin_lock_irqsave(&priv->gc.bgpio_lock, flags); 443 438 444 439 if (priv->domain) { 445 440 for (i = 0; i < GRGPIO_MAX_NGPIO; i++) { ··· 453 454 irq_domain_remove(priv->domain); 454 455 455 456 out: 456 - spin_unlock_irqrestore(&priv->gc.bgpio_lock, flags); 457 - 458 457 return ret; 459 458 } 460 459
+170
drivers/gpio/gpio-logicvc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Copyright (C) 2019 Bootlin 4 + * Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com> 5 + */ 6 + 7 + #include <linux/err.h> 8 + #include <linux/gpio/driver.h> 9 + #include <linux/module.h> 10 + #include <linux/of.h> 11 + #include <linux/of_device.h> 12 + #include <linux/of_address.h> 13 + #include <linux/platform_device.h> 14 + #include <linux/regmap.h> 15 + #include <linux/mfd/syscon.h> 16 + 17 + #define LOGICVC_CTRL_REG 0x40 18 + #define LOGICVC_CTRL_GPIO_SHIFT 11 19 + #define LOGICVC_CTRL_GPIO_BITS 5 20 + 21 + #define LOGICVC_POWER_CTRL_REG 0x78 22 + #define LOGICVC_POWER_CTRL_GPIO_SHIFT 0 23 + #define LOGICVC_POWER_CTRL_GPIO_BITS 4 24 + 25 + struct logicvc_gpio { 26 + struct gpio_chip chip; 27 + struct regmap *regmap; 28 + }; 29 + 30 + static void logicvc_gpio_offset(struct logicvc_gpio *logicvc, unsigned offset, 31 + unsigned int *reg, unsigned int *bit) 32 + { 33 + if (offset >= LOGICVC_CTRL_GPIO_BITS) { 34 + *reg = LOGICVC_POWER_CTRL_REG; 35 + 36 + /* To the (virtual) power ctrl offset. */ 37 + offset -= LOGICVC_CTRL_GPIO_BITS; 38 + /* To the actual bit offset in reg. */ 39 + offset += LOGICVC_POWER_CTRL_GPIO_SHIFT; 40 + } else { 41 + *reg = LOGICVC_CTRL_REG; 42 + 43 + /* To the actual bit offset in reg. */ 44 + offset += LOGICVC_CTRL_GPIO_SHIFT; 45 + } 46 + 47 + *bit = BIT(offset); 48 + } 49 + 50 + static int logicvc_gpio_get(struct gpio_chip *chip, unsigned offset) 51 + { 52 + struct logicvc_gpio *logicvc = gpiochip_get_data(chip); 53 + unsigned int reg, bit, value; 54 + int ret; 55 + 56 + logicvc_gpio_offset(logicvc, offset, &reg, &bit); 57 + 58 + ret = regmap_read(logicvc->regmap, reg, &value); 59 + if (ret) 60 + return ret; 61 + 62 + return !!(value & bit); 63 + } 64 + 65 + static void logicvc_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 66 + { 67 + struct logicvc_gpio *logicvc = gpiochip_get_data(chip); 68 + unsigned int reg, bit; 69 + 70 + logicvc_gpio_offset(logicvc, offset, &reg, &bit); 71 + 72 + regmap_update_bits(logicvc->regmap, reg, bit, value ? bit : 0); 73 + } 74 + 75 + static int logicvc_gpio_direction_output(struct gpio_chip *chip, 76 + unsigned offset, int value) 77 + { 78 + /* Pins are always configured as output, so just set the value. */ 79 + logicvc_gpio_set(chip, offset, value); 80 + 81 + return 0; 82 + } 83 + 84 + static struct regmap_config logicvc_gpio_regmap_config = { 85 + .reg_bits = 32, 86 + .val_bits = 32, 87 + .reg_stride = 4, 88 + .name = "logicvc-gpio", 89 + }; 90 + 91 + static int logicvc_gpio_probe(struct platform_device *pdev) 92 + { 93 + struct device *dev = &pdev->dev; 94 + struct device_node *of_node = dev->of_node; 95 + struct logicvc_gpio *logicvc; 96 + int ret; 97 + 98 + logicvc = devm_kzalloc(dev, sizeof(*logicvc), GFP_KERNEL); 99 + if (!logicvc) 100 + return -ENOMEM; 101 + 102 + /* Try to get regmap from parent first. */ 103 + logicvc->regmap = syscon_node_to_regmap(of_node->parent); 104 + 105 + /* Grab our own regmap if that fails. */ 106 + if (IS_ERR(logicvc->regmap)) { 107 + struct resource res; 108 + void __iomem *base; 109 + 110 + ret = of_address_to_resource(of_node, 0, &res); 111 + if (ret) { 112 + dev_err(dev, "Failed to get resource from address\n"); 113 + return ret; 114 + } 115 + 116 + base = devm_ioremap_resource(dev, &res); 117 + if (IS_ERR(base)) { 118 + dev_err(dev, "Failed to map I/O base\n"); 119 + return PTR_ERR(base); 120 + } 121 + 122 + logicvc_gpio_regmap_config.max_register = resource_size(&res) - 123 + logicvc_gpio_regmap_config.reg_stride; 124 + 125 + logicvc->regmap = 126 + devm_regmap_init_mmio(dev, base, 127 + &logicvc_gpio_regmap_config); 128 + if (IS_ERR(logicvc->regmap)) { 129 + dev_err(dev, "Failed to create regmap for I/O\n"); 130 + return PTR_ERR(logicvc->regmap); 131 + } 132 + } 133 + 134 + logicvc->chip.parent = dev; 135 + logicvc->chip.owner = THIS_MODULE; 136 + logicvc->chip.label = dev_name(dev); 137 + logicvc->chip.base = -1; 138 + logicvc->chip.ngpio = LOGICVC_CTRL_GPIO_BITS + 139 + LOGICVC_POWER_CTRL_GPIO_BITS; 140 + logicvc->chip.get = logicvc_gpio_get; 141 + logicvc->chip.set = logicvc_gpio_set; 142 + logicvc->chip.direction_output = logicvc_gpio_direction_output; 143 + 144 + platform_set_drvdata(pdev, logicvc); 145 + 146 + return devm_gpiochip_add_data(dev, &logicvc->chip, logicvc); 147 + } 148 + 149 + static const struct of_device_id logicivc_gpio_of_table[] = { 150 + { 151 + .compatible = "xylon,logicvc-3.02.a-gpio", 152 + }, 153 + { } 154 + }; 155 + 156 + MODULE_DEVICE_TABLE(of, logicivc_gpio_of_table); 157 + 158 + static struct platform_driver logicvc_gpio_driver = { 159 + .driver = { 160 + .name = "gpio-logicvc", 161 + .of_match_table = logicivc_gpio_of_table, 162 + }, 163 + .probe = logicvc_gpio_probe, 164 + }; 165 + 166 + module_platform_driver(logicvc_gpio_driver); 167 + 168 + MODULE_AUTHOR("Paul Kocialkowski <paul.kocialkowski@bootlin.com>"); 169 + MODULE_DESCRIPTION("Xylon LogiCVC GPIO driver"); 170 + MODULE_LICENSE("GPL");
+8 -8
drivers/gpio/gpio-mockup.c
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 2 /* 3 3 * GPIO Testing Device Driver 4 4 * ··· 7 7 * Copyright (C) 2017 Bartosz Golaszewski <brgl@bgdev.pl> 8 8 */ 9 9 10 - #include <linux/init.h> 11 - #include <linux/module.h> 12 - #include <linux/gpio/driver.h> 10 + #include <linux/debugfs.h> 13 11 #include <linux/gpio/consumer.h> 14 - #include <linux/platform_device.h> 15 - #include <linux/slab.h> 12 + #include <linux/gpio/driver.h> 13 + #include <linux/init.h> 16 14 #include <linux/interrupt.h> 17 15 #include <linux/irq.h> 18 16 #include <linux/irq_sim.h> 19 - #include <linux/debugfs.h> 20 - #include <linux/uaccess.h> 17 + #include <linux/module.h> 18 + #include <linux/platform_device.h> 21 19 #include <linux/property.h> 20 + #include <linux/slab.h> 21 + #include <linux/uaccess.h> 22 22 23 23 #include "gpiolib.h" 24 24
+1
drivers/gpio/gpio-mpc8xxx.c
··· 296 296 297 297 static const struct mpc8xxx_gpio_devtype ls1028a_gpio_devtype = { 298 298 .gpio_dir_in_init = ls1028a_gpio_dir_in_init, 299 + .irq_set_type = mpc8xxx_irq_set_type, 299 300 }; 300 301 301 302 static const struct mpc8xxx_gpio_devtype mpc5125_gpio_devtype = {
+6 -2
drivers/gpio/gpio-mvebu.c
··· 46 46 #include <linux/irqdomain.h> 47 47 #include <linux/mfd/syscon.h> 48 48 #include <linux/of_device.h> 49 - #include <linux/of_irq.h> 50 49 #include <linux/pinctrl/consumer.h> 51 50 #include <linux/platform_device.h> 52 51 #include <linux/pwm.h> ··· 431 432 u32 mask = d->mask; 432 433 433 434 irq_gc_lock(gc); 435 + mvebu_gpio_write_edge_cause(mvchip, ~mask); 434 436 ct->mask_cache_priv |= mask; 435 437 mvebu_gpio_write_edge_mask(mvchip, ct->mask_cache_priv); 436 438 irq_gc_unlock(gc); ··· 1102 1102 soc_variant = MVEBU_GPIO_SOC_VARIANT_ORION; 1103 1103 1104 1104 /* Some gpio controllers do not provide irq support */ 1105 - have_irqs = of_irq_count(np) != 0; 1105 + err = platform_irq_count(pdev); 1106 + if (err < 0) 1107 + return err; 1108 + 1109 + have_irqs = err != 0; 1106 1110 1107 1111 mvchip = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_gpio_chip), 1108 1112 GFP_KERNEL);
+1 -4
drivers/gpio/gpio-pca953x.c
··· 764 764 765 765 ret = devm_request_threaded_irq(&client->dev, client->irq, 766 766 NULL, pca953x_irq_handler, 767 - IRQF_TRIGGER_LOW | IRQF_ONESHOT | 768 - IRQF_SHARED, 767 + IRQF_ONESHOT | IRQF_SHARED, 769 768 dev_name(&client->dev), chip); 770 769 if (ret) { 771 770 dev_err(&client->dev, "failed to request irq %d\n", ··· 853 854 out: 854 855 return ret; 855 856 } 856 - 857 - static const struct of_device_id pca953x_dt_ids[]; 858 857 859 858 static int pca953x_probe(struct i2c_client *client, 860 859 const struct i2c_device_id *i2c_id)
-1
drivers/gpio/gpio-sama5d2-piobu.c
··· 244 244 245 245 module_platform_driver(sama5d2_piobu_driver); 246 246 247 - MODULE_VERSION("1.0"); 248 247 MODULE_LICENSE("GPL v2"); 249 248 MODULE_DESCRIPTION("SAMA5D2 PIOBU controller driver"); 250 249 MODULE_AUTHOR("Andrei Stefanescu <andrei.stefanescu@microchip.com>");
-1
drivers/gpio/gpio-tb10x.c
··· 243 243 module_platform_driver(tb10x_gpio_driver); 244 244 MODULE_LICENSE("GPL"); 245 245 MODULE_DESCRIPTION("tb10x gpio."); 246 - MODULE_VERSION("0.0.1");
+10 -11
drivers/gpio/gpio-tegra.c
··· 96 96 static inline void tegra_gpio_writel(struct tegra_gpio_info *tgi, 97 97 u32 val, u32 reg) 98 98 { 99 - __raw_writel(val, tgi->regs + reg); 99 + writel_relaxed(val, tgi->regs + reg); 100 100 } 101 101 102 102 static inline u32 tegra_gpio_readl(struct tegra_gpio_info *tgi, u32 reg) 103 103 { 104 - return __raw_readl(tgi->regs + reg); 104 + return readl_relaxed(tgi->regs + reg); 105 105 } 106 106 107 107 static unsigned int tegra_gpio_compose(unsigned int bank, unsigned int port, ··· 416 416 static int tegra_gpio_resume(struct device *dev) 417 417 { 418 418 struct tegra_gpio_info *tgi = dev_get_drvdata(dev); 419 - unsigned long flags; 420 419 unsigned int b, p; 421 - 422 - local_irq_save(flags); 423 420 424 421 for (b = 0; b < tgi->bank_count; b++) { 425 422 struct tegra_gpio_bank *bank = &tgi->bank_info[b]; ··· 445 448 } 446 449 } 447 450 448 - local_irq_restore(flags); 449 451 return 0; 450 452 } 451 453 452 454 static int tegra_gpio_suspend(struct device *dev) 453 455 { 454 456 struct tegra_gpio_info *tgi = dev_get_drvdata(dev); 455 - unsigned long flags; 456 457 unsigned int b, p; 457 458 458 - local_irq_save(flags); 459 459 for (b = 0; b < tgi->bank_count; b++) { 460 460 struct tegra_gpio_bank *bank = &tgi->bank_info[b]; 461 461 ··· 482 488 GPIO_INT_ENB(tgi, gpio)); 483 489 } 484 490 } 485 - local_irq_restore(flags); 491 + 486 492 return 0; 487 493 } 488 494 ··· 491 497 struct tegra_gpio_bank *bank = irq_data_get_irq_chip_data(d); 492 498 unsigned int gpio = d->hwirq; 493 499 u32 port, bit, mask; 500 + int err; 501 + 502 + err = irq_set_irq_wake(bank->irq, enable); 503 + if (err) 504 + return err; 494 505 495 506 port = GPIO_PORT(gpio); 496 507 bit = GPIO_BIT(gpio); ··· 506 507 else 507 508 bank->wake_enb[port] &= ~mask; 508 509 509 - return irq_set_irq_wake(bank->irq, enable); 510 + return 0; 510 511 } 511 512 #endif 512 513 ··· 556 557 #endif 557 558 558 559 static const struct dev_pm_ops tegra_gpio_pm_ops = { 559 - SET_SYSTEM_SLEEP_PM_OPS(tegra_gpio_suspend, tegra_gpio_resume) 560 + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(tegra_gpio_suspend, tegra_gpio_resume) 560 561 }; 561 562 562 563 static int tegra_gpio_probe(struct platform_device *pdev)
+10 -3
drivers/gpio/gpio-tegra186.c
··· 448 448 return 0; 449 449 } 450 450 451 - static void tegra186_gpio_populate_parent_fwspec(struct gpio_chip *chip, 452 - struct irq_fwspec *fwspec, 451 + static void *tegra186_gpio_populate_parent_fwspec(struct gpio_chip *chip, 453 452 unsigned int parent_hwirq, 454 453 unsigned int parent_type) 455 454 { 456 455 struct tegra_gpio *gpio = gpiochip_get_data(chip); 456 + struct irq_fwspec *fwspec; 457 457 458 + fwspec = kmalloc(sizeof(*fwspec), GFP_KERNEL); 459 + if (!fwspec) 460 + return NULL; 461 + 462 + fwspec->fwnode = chip->irq.parent_domain->fwnode; 458 463 fwspec->param_count = 3; 459 464 fwspec->param[0] = gpio->soc->instance; 460 465 fwspec->param[1] = parent_hwirq; 461 466 fwspec->param[2] = parent_type; 467 + 468 + return fwspec; 462 469 } 463 470 464 471 static int tegra186_gpio_child_to_parent_hwirq(struct gpio_chip *chip, ··· 628 621 irq->chip = &gpio->intc; 629 622 irq->fwnode = of_node_to_fwnode(pdev->dev.of_node); 630 623 irq->child_to_parent_hwirq = tegra186_gpio_child_to_parent_hwirq; 631 - irq->populate_parent_fwspec = tegra186_gpio_populate_parent_fwspec; 624 + irq->populate_parent_alloc_arg = tegra186_gpio_populate_parent_fwspec; 632 625 irq->child_offset_to_irq = tegra186_gpio_child_offset_to_irq; 633 626 irq->child_irq_domain_ops.translate = tegra186_gpio_irq_domain_translate; 634 627 irq->handler = handle_simple_irq;
+77 -100
drivers/gpio/gpio-thunderx.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/pci.h> 17 17 #include <linux/spinlock.h> 18 + #include <asm-generic/msi.h> 18 19 19 20 20 21 #define GPIO_RX_DAT 0x0 ··· 54 53 struct thunderx_gpio { 55 54 struct gpio_chip chip; 56 55 u8 __iomem *register_base; 57 - struct irq_domain *irqd; 58 56 struct msix_entry *msix_entries; /* per line MSI-X */ 59 57 struct thunderx_line *line_entries; /* per line irq info */ 60 58 raw_spinlock_t lock; ··· 286 286 } 287 287 } 288 288 289 - static void thunderx_gpio_irq_ack(struct irq_data *data) 289 + static void thunderx_gpio_irq_ack(struct irq_data *d) 290 290 { 291 - struct thunderx_line *txline = irq_data_get_irq_chip_data(data); 291 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 292 + struct thunderx_gpio *txgpio = gpiochip_get_data(gc); 292 293 293 294 writeq(GPIO_INTR_INTR, 294 - txline->txgpio->register_base + intr_reg(txline->line)); 295 + txgpio->register_base + intr_reg(irqd_to_hwirq(d))); 295 296 } 296 297 297 - static void thunderx_gpio_irq_mask(struct irq_data *data) 298 + static void thunderx_gpio_irq_mask(struct irq_data *d) 298 299 { 299 - struct thunderx_line *txline = irq_data_get_irq_chip_data(data); 300 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 301 + struct thunderx_gpio *txgpio = gpiochip_get_data(gc); 300 302 301 303 writeq(GPIO_INTR_ENA_W1C, 302 - txline->txgpio->register_base + intr_reg(txline->line)); 304 + txgpio->register_base + intr_reg(irqd_to_hwirq(d))); 303 305 } 304 306 305 - static void thunderx_gpio_irq_mask_ack(struct irq_data *data) 307 + static void thunderx_gpio_irq_mask_ack(struct irq_data *d) 306 308 { 307 - struct thunderx_line *txline = irq_data_get_irq_chip_data(data); 309 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 310 + struct thunderx_gpio *txgpio = gpiochip_get_data(gc); 308 311 309 312 writeq(GPIO_INTR_ENA_W1C | GPIO_INTR_INTR, 310 - txline->txgpio->register_base + intr_reg(txline->line)); 313 + txgpio->register_base + intr_reg(irqd_to_hwirq(d))); 311 314 } 312 315 313 - static void thunderx_gpio_irq_unmask(struct irq_data *data) 316 + static void thunderx_gpio_irq_unmask(struct irq_data *d) 314 317 { 315 - struct thunderx_line *txline = irq_data_get_irq_chip_data(data); 318 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 319 + struct thunderx_gpio *txgpio = gpiochip_get_data(gc); 316 320 317 321 writeq(GPIO_INTR_ENA_W1S, 318 - txline->txgpio->register_base + intr_reg(txline->line)); 322 + txgpio->register_base + intr_reg(irqd_to_hwirq(d))); 319 323 } 320 324 321 - static int thunderx_gpio_irq_set_type(struct irq_data *data, 325 + static int thunderx_gpio_irq_set_type(struct irq_data *d, 322 326 unsigned int flow_type) 323 327 { 324 - struct thunderx_line *txline = irq_data_get_irq_chip_data(data); 325 - struct thunderx_gpio *txgpio = txline->txgpio; 328 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 329 + struct thunderx_gpio *txgpio = gpiochip_get_data(gc); 330 + struct thunderx_line *txline = 331 + &txgpio->line_entries[irqd_to_hwirq(d)]; 326 332 u64 bit_cfg; 327 333 328 - irqd_set_trigger_type(data, flow_type); 334 + irqd_set_trigger_type(d, flow_type); 329 335 330 336 bit_cfg = txline->fil_bits | GPIO_BIT_CFG_INT_EN; 331 337 332 338 if (flow_type & IRQ_TYPE_EDGE_BOTH) { 333 - irq_set_handler_locked(data, handle_fasteoi_ack_irq); 339 + irq_set_handler_locked(d, handle_fasteoi_ack_irq); 334 340 bit_cfg |= GPIO_BIT_CFG_INT_TYPE; 335 341 } else { 336 - irq_set_handler_locked(data, handle_fasteoi_mask_irq); 342 + irq_set_handler_locked(d, handle_fasteoi_mask_irq); 337 343 } 338 344 339 345 raw_spin_lock(&txgpio->lock); ··· 368 362 irq_chip_disable_parent(data); 369 363 } 370 364 371 - static int thunderx_gpio_irq_request_resources(struct irq_data *data) 372 - { 373 - struct thunderx_line *txline = irq_data_get_irq_chip_data(data); 374 - struct thunderx_gpio *txgpio = txline->txgpio; 375 - int r; 376 - 377 - r = gpiochip_lock_as_irq(&txgpio->chip, txline->line); 378 - if (r) 379 - return r; 380 - 381 - r = irq_chip_request_resources_parent(data); 382 - if (r) 383 - gpiochip_unlock_as_irq(&txgpio->chip, txline->line); 384 - 385 - return r; 386 - } 387 - 388 - static void thunderx_gpio_irq_release_resources(struct irq_data *data) 389 - { 390 - struct thunderx_line *txline = irq_data_get_irq_chip_data(data); 391 - struct thunderx_gpio *txgpio = txline->txgpio; 392 - 393 - irq_chip_release_resources_parent(data); 394 - 395 - gpiochip_unlock_as_irq(&txgpio->chip, txline->line); 396 - } 397 - 398 365 /* 399 366 * Interrupts are chained from underlying MSI-X vectors. We have 400 367 * these irq_chip functions to be able to handle level triggering ··· 384 405 .irq_unmask = thunderx_gpio_irq_unmask, 385 406 .irq_eoi = irq_chip_eoi_parent, 386 407 .irq_set_affinity = irq_chip_set_affinity_parent, 387 - .irq_request_resources = thunderx_gpio_irq_request_resources, 388 - .irq_release_resources = thunderx_gpio_irq_release_resources, 389 408 .irq_set_type = thunderx_gpio_irq_set_type, 390 409 391 410 .flags = IRQCHIP_SET_TYPE_MASKED 392 411 }; 393 412 394 - static int thunderx_gpio_irq_translate(struct irq_domain *d, 395 - struct irq_fwspec *fwspec, 396 - irq_hw_number_t *hwirq, 397 - unsigned int *type) 413 + static int thunderx_gpio_child_to_parent_hwirq(struct gpio_chip *gc, 414 + unsigned int child, 415 + unsigned int child_type, 416 + unsigned int *parent, 417 + unsigned int *parent_type) 398 418 { 399 - struct thunderx_gpio *txgpio = d->host_data; 419 + struct thunderx_gpio *txgpio = gpiochip_get_data(gc); 420 + struct irq_data *irqd; 421 + unsigned int irq; 400 422 401 - if (WARN_ON(fwspec->param_count < 2)) 423 + irq = txgpio->msix_entries[child].vector; 424 + irqd = irq_domain_get_irq_data(gc->irq.parent_domain, irq); 425 + if (!irqd) 402 426 return -EINVAL; 403 - if (fwspec->param[0] >= txgpio->chip.ngpio) 404 - return -EINVAL; 405 - *hwirq = fwspec->param[0]; 406 - *type = fwspec->param[1] & IRQ_TYPE_SENSE_MASK; 427 + *parent = irqd_to_hwirq(irqd); 428 + *parent_type = IRQ_TYPE_LEVEL_HIGH; 407 429 return 0; 408 430 } 409 431 410 - static int thunderx_gpio_irq_alloc(struct irq_domain *d, unsigned int virq, 411 - unsigned int nr_irqs, void *arg) 432 + static void *thunderx_gpio_populate_parent_alloc_info(struct gpio_chip *chip, 433 + unsigned int parent_hwirq, 434 + unsigned int parent_type) 412 435 { 413 - struct thunderx_line *txline = arg; 436 + msi_alloc_info_t *info; 414 437 415 - return irq_domain_set_hwirq_and_chip(d, virq, txline->line, 416 - &thunderx_gpio_irq_chip, txline); 417 - } 438 + info = kmalloc(sizeof(*info), GFP_KERNEL); 439 + if (!info) 440 + return NULL; 418 441 419 - static const struct irq_domain_ops thunderx_gpio_irqd_ops = { 420 - .alloc = thunderx_gpio_irq_alloc, 421 - .translate = thunderx_gpio_irq_translate 422 - }; 423 - 424 - static int thunderx_gpio_to_irq(struct gpio_chip *chip, unsigned int offset) 425 - { 426 - struct thunderx_gpio *txgpio = gpiochip_get_data(chip); 427 - 428 - return irq_find_mapping(txgpio->irqd, offset); 442 + info->hwirq = parent_hwirq; 443 + return info; 429 444 } 430 445 431 446 static int thunderx_gpio_probe(struct pci_dev *pdev, ··· 429 456 struct device *dev = &pdev->dev; 430 457 struct thunderx_gpio *txgpio; 431 458 struct gpio_chip *chip; 459 + struct gpio_irq_chip *girq; 432 460 int ngpio, i; 433 461 int err = 0; 434 462 ··· 474 500 } 475 501 476 502 txgpio->msix_entries = devm_kcalloc(dev, 477 - ngpio, sizeof(struct msix_entry), 478 - GFP_KERNEL); 503 + ngpio, sizeof(struct msix_entry), 504 + GFP_KERNEL); 479 505 if (!txgpio->msix_entries) { 480 506 err = -ENOMEM; 481 507 goto out; ··· 516 542 if (err < 0) 517 543 goto out; 518 544 519 - /* 520 - * Push GPIO specific irqdomain on hierarchy created as a side 521 - * effect of the pci_enable_msix() 522 - */ 523 - txgpio->irqd = irq_domain_create_hierarchy(irq_get_irq_data(txgpio->msix_entries[0].vector)->domain, 524 - 0, 0, of_node_to_fwnode(dev->of_node), 525 - &thunderx_gpio_irqd_ops, txgpio); 526 - if (!txgpio->irqd) { 527 - err = -ENOMEM; 528 - goto out; 529 - } 530 - 531 - /* Push on irq_data and the domain for each line. */ 532 - for (i = 0; i < ngpio; i++) { 533 - err = irq_domain_push_irq(txgpio->irqd, 534 - txgpio->msix_entries[i].vector, 535 - &txgpio->line_entries[i]); 536 - if (err < 0) 537 - dev_err(dev, "irq_domain_push_irq: %d\n", err); 538 - } 539 - 540 545 chip->label = KBUILD_MODNAME; 541 546 chip->parent = dev; 542 547 chip->owner = THIS_MODULE; ··· 530 577 chip->set = thunderx_gpio_set; 531 578 chip->set_multiple = thunderx_gpio_set_multiple; 532 579 chip->set_config = thunderx_gpio_set_config; 533 - chip->to_irq = thunderx_gpio_to_irq; 580 + girq = &chip->irq; 581 + girq->chip = &thunderx_gpio_irq_chip; 582 + girq->fwnode = of_node_to_fwnode(dev->of_node); 583 + girq->parent_domain = 584 + irq_get_irq_data(txgpio->msix_entries[0].vector)->domain; 585 + girq->child_to_parent_hwirq = thunderx_gpio_child_to_parent_hwirq; 586 + girq->populate_parent_alloc_arg = thunderx_gpio_populate_parent_alloc_info; 587 + girq->handler = handle_bad_irq; 588 + girq->default_type = IRQ_TYPE_NONE; 589 + 534 590 err = devm_gpiochip_add_data(dev, chip, txgpio); 535 591 if (err) 536 592 goto out; 593 + 594 + /* Push on irq_data and the domain for each line. */ 595 + for (i = 0; i < ngpio; i++) { 596 + struct irq_fwspec fwspec; 597 + 598 + fwspec.fwnode = of_node_to_fwnode(dev->of_node); 599 + fwspec.param_count = 2; 600 + fwspec.param[0] = i; 601 + fwspec.param[1] = IRQ_TYPE_NONE; 602 + err = irq_domain_push_irq(girq->domain, 603 + txgpio->msix_entries[i].vector, 604 + &fwspec); 605 + if (err < 0) 606 + dev_err(dev, "irq_domain_push_irq: %d\n", err); 607 + } 537 608 538 609 dev_info(dev, "ThunderX GPIO: %d lines with base %d.\n", 539 610 ngpio, chip->base); ··· 573 596 struct thunderx_gpio *txgpio = pci_get_drvdata(pdev); 574 597 575 598 for (i = 0; i < txgpio->chip.ngpio; i++) 576 - irq_domain_pop_irq(txgpio->irqd, 599 + irq_domain_pop_irq(txgpio->chip.irq.domain, 577 600 txgpio->msix_entries[i].vector); 578 601 579 - irq_domain_remove(txgpio->irqd); 602 + irq_domain_remove(txgpio->chip.irq.domain); 580 603 581 604 pci_set_drvdata(pdev, NULL); 582 605 }
+1 -1
drivers/gpio/gpio-vx855.c
··· 71 71 return 1 << (i + 13); 72 72 } 73 73 74 - /* Mapping betwee numeric GPIO ID and the actual GPIO hardware numbering: 74 + /* Mapping between numeric GPIO ID and the actual GPIO hardware numbering: 75 75 * 0..13 GPI 0..13 76 76 * 14..26 GPO 0..12 77 77 * 27..41 GPIO 0..14
+121
drivers/gpio/gpio-wcd934x.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // Copyright (c) 2019, Linaro Limited 3 + 4 + #include <linux/module.h> 5 + #include <linux/gpio/driver.h> 6 + #include <linux/regmap.h> 7 + #include <linux/slab.h> 8 + #include <linux/of_device.h> 9 + 10 + #define WCD_PIN_MASK(p) BIT(p - 1) 11 + #define WCD_REG_DIR_CTL_OFFSET 0x42 12 + #define WCD_REG_VAL_CTL_OFFSET 0x43 13 + #define WCD934X_NPINS 5 14 + 15 + struct wcd_gpio_data { 16 + struct regmap *map; 17 + struct gpio_chip chip; 18 + }; 19 + 20 + static int wcd_gpio_get_direction(struct gpio_chip *chip, unsigned int pin) 21 + { 22 + struct wcd_gpio_data *data = gpiochip_get_data(chip); 23 + unsigned int value; 24 + int ret; 25 + 26 + ret = regmap_read(data->map, WCD_REG_DIR_CTL_OFFSET, &value); 27 + if (ret < 0) 28 + return ret; 29 + 30 + if (value & WCD_PIN_MASK(pin)) 31 + return GPIO_LINE_DIRECTION_OUT; 32 + 33 + return GPIO_LINE_DIRECTION_IN; 34 + } 35 + 36 + static int wcd_gpio_direction_input(struct gpio_chip *chip, unsigned int pin) 37 + { 38 + struct wcd_gpio_data *data = gpiochip_get_data(chip); 39 + 40 + return regmap_update_bits(data->map, WCD_REG_DIR_CTL_OFFSET, 41 + WCD_PIN_MASK(pin), 0); 42 + } 43 + 44 + static int wcd_gpio_direction_output(struct gpio_chip *chip, unsigned int pin, 45 + int val) 46 + { 47 + struct wcd_gpio_data *data = gpiochip_get_data(chip); 48 + 49 + regmap_update_bits(data->map, WCD_REG_DIR_CTL_OFFSET, 50 + WCD_PIN_MASK(pin), WCD_PIN_MASK(pin)); 51 + 52 + return regmap_update_bits(data->map, WCD_REG_VAL_CTL_OFFSET, 53 + WCD_PIN_MASK(pin), 54 + val ? WCD_PIN_MASK(pin) : 0); 55 + } 56 + 57 + static int wcd_gpio_get(struct gpio_chip *chip, unsigned int pin) 58 + { 59 + struct wcd_gpio_data *data = gpiochip_get_data(chip); 60 + int value; 61 + 62 + regmap_read(data->map, WCD_REG_VAL_CTL_OFFSET, &value); 63 + 64 + return !!(value && WCD_PIN_MASK(pin)); 65 + } 66 + 67 + static void wcd_gpio_set(struct gpio_chip *chip, unsigned int pin, int val) 68 + { 69 + wcd_gpio_direction_output(chip, pin, val); 70 + } 71 + 72 + static int wcd_gpio_probe(struct platform_device *pdev) 73 + { 74 + struct device *dev = &pdev->dev; 75 + struct wcd_gpio_data *data; 76 + struct gpio_chip *chip; 77 + 78 + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); 79 + if (!data) 80 + return -ENOMEM; 81 + 82 + data->map = dev_get_regmap(dev->parent, NULL); 83 + if (!data->map) { 84 + dev_err(dev, "%s: failed to get regmap\n", __func__); 85 + return -EINVAL; 86 + } 87 + 88 + chip = &data->chip; 89 + chip->direction_input = wcd_gpio_direction_input; 90 + chip->direction_output = wcd_gpio_direction_output; 91 + chip->get_direction = wcd_gpio_get_direction; 92 + chip->get = wcd_gpio_get; 93 + chip->set = wcd_gpio_set; 94 + chip->parent = dev; 95 + chip->base = -1; 96 + chip->ngpio = WCD934X_NPINS; 97 + chip->label = dev_name(dev); 98 + chip->of_gpio_n_cells = 2; 99 + chip->can_sleep = false; 100 + 101 + return devm_gpiochip_add_data(dev, chip, data); 102 + } 103 + 104 + static const struct of_device_id wcd_gpio_of_match[] = { 105 + { .compatible = "qcom,wcd9340-gpio" }, 106 + { .compatible = "qcom,wcd9341-gpio" }, 107 + { } 108 + }; 109 + MODULE_DEVICE_TABLE(of, wcd_gpio_of_match); 110 + 111 + static struct platform_driver wcd_gpio_driver = { 112 + .driver = { 113 + .name = "wcd934x-gpio", 114 + .of_match_table = wcd_gpio_of_match, 115 + }, 116 + .probe = wcd_gpio_probe, 117 + }; 118 + 119 + module_platform_driver(wcd_gpio_driver); 120 + MODULE_DESCRIPTION("Qualcomm Technologies, Inc WCD GPIO control driver"); 121 + MODULE_LICENSE("GPL v2");
+3 -4
drivers/gpio/gpiolib-sysfs.c
··· 762 762 parent = &gdev->dev; 763 763 764 764 /* use chip->base for the ID; it's already known to be unique */ 765 - dev = device_create_with_groups(&gpio_class, parent, 766 - MKDEV(0, 0), 767 - chip, gpiochip_groups, 768 - "gpiochip%d", chip->base); 765 + dev = device_create_with_groups(&gpio_class, parent, MKDEV(0, 0), chip, 766 + gpiochip_groups, GPIOCHIP_NAME "%d", 767 + chip->base); 769 768 if (IS_ERR(dev)) 770 769 return PTR_ERR(dev); 771 770
+83 -99
drivers/gpio/gpiolib.c
··· 140 140 * in the given chip for the specified hardware number. 141 141 */ 142 142 struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, 143 - u16 hwnum) 143 + unsigned int hwnum) 144 144 { 145 145 struct gpio_device *gdev = chip->gpiodev; 146 146 ··· 232 232 return -ENOTSUPP; 233 233 234 234 ret = chip->get_direction(chip, offset); 235 - if (ret > 0) { 236 - /* GPIOF_DIR_IN, or other positive */ 235 + if (ret < 0) 236 + return ret; 237 + 238 + /* GPIOF_DIR_IN or other positive, otherwise GPIOF_DIR_OUT */ 239 + if (ret > 0) 237 240 ret = 1; 238 - clear_bit(FLAG_IS_OUT, &desc->flags); 239 - } 240 - if (ret == 0) { 241 - /* GPIOF_DIR_OUT */ 242 - set_bit(FLAG_IS_OUT, &desc->flags); 243 - } 241 + 242 + assign_bit(FLAG_IS_OUT, &desc->flags, !ret); 243 + 244 244 return ret; 245 245 } 246 246 EXPORT_SYMBOL_GPL(gpiod_get_direction); ··· 492 492 return 0; 493 493 } 494 494 495 - static void linehandle_configure_flag(unsigned long *flagsp, 496 - u32 bit, bool active) 497 - { 498 - if (active) 499 - set_bit(bit, flagsp); 500 - else 501 - clear_bit(bit, flagsp); 502 - } 503 - 504 495 static long linehandle_set_config(struct linehandle_state *lh, 505 496 void __user *ip) 506 497 { ··· 513 522 desc = lh->descs[i]; 514 523 flagsp = &desc->flags; 515 524 516 - linehandle_configure_flag(flagsp, FLAG_ACTIVE_LOW, 525 + assign_bit(FLAG_ACTIVE_LOW, flagsp, 517 526 lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW); 518 527 519 - linehandle_configure_flag(flagsp, FLAG_OPEN_DRAIN, 528 + assign_bit(FLAG_OPEN_DRAIN, flagsp, 520 529 lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN); 521 530 522 - linehandle_configure_flag(flagsp, FLAG_OPEN_SOURCE, 531 + assign_bit(FLAG_OPEN_SOURCE, flagsp, 523 532 lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE); 524 533 525 - linehandle_configure_flag(flagsp, FLAG_PULL_UP, 534 + assign_bit(FLAG_PULL_UP, flagsp, 526 535 lflags & GPIOHANDLE_REQUEST_BIAS_PULL_UP); 527 536 528 - linehandle_configure_flag(flagsp, FLAG_PULL_DOWN, 537 + assign_bit(FLAG_PULL_DOWN, flagsp, 529 538 lflags & GPIOHANDLE_REQUEST_BIAS_PULL_DOWN); 530 539 531 - linehandle_configure_flag(flagsp, FLAG_BIAS_DISABLE, 540 + assign_bit(FLAG_BIAS_DISABLE, flagsp, 532 541 lflags & GPIOHANDLE_REQUEST_BIAS_DISABLE); 533 542 534 543 /* ··· 677 686 /* Request each GPIO */ 678 687 for (i = 0; i < handlereq.lines; i++) { 679 688 u32 offset = handlereq.lineoffsets[i]; 680 - struct gpio_desc *desc; 689 + struct gpio_desc *desc = gpiochip_get_desc(gdev->chip, offset); 681 690 682 - if (offset >= gdev->ngpio) { 683 - ret = -EINVAL; 691 + if (IS_ERR(desc)) { 692 + ret = PTR_ERR(desc); 684 693 goto out_free_descs; 685 694 } 686 695 687 - desc = &gdev->descs[offset]; 688 696 ret = gpiod_request(desc, lh->label); 689 697 if (ret) 690 698 goto out_free_descs; ··· 1008 1018 lflags = eventreq.handleflags; 1009 1019 eflags = eventreq.eventflags; 1010 1020 1011 - if (offset >= gdev->ngpio) 1012 - return -EINVAL; 1021 + desc = gpiochip_get_desc(gdev->chip, offset); 1022 + if (IS_ERR(desc)) 1023 + return PTR_ERR(desc); 1013 1024 1014 1025 /* Return an error if a unknown flag is set */ 1015 1026 if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) || ··· 1048 1057 } 1049 1058 } 1050 1059 1051 - desc = &gdev->descs[offset]; 1052 1060 ret = gpiod_request(desc, le->label); 1053 1061 if (ret) 1054 1062 goto out_free_label; ··· 1174 1184 1175 1185 if (copy_from_user(&lineinfo, ip, sizeof(lineinfo))) 1176 1186 return -EFAULT; 1177 - if (lineinfo.line_offset >= gdev->ngpio) 1178 - return -EINVAL; 1179 1187 1180 - desc = &gdev->descs[lineinfo.line_offset]; 1188 + desc = gpiochip_get_desc(chip, lineinfo.line_offset); 1189 + if (IS_ERR(desc)) 1190 + return PTR_ERR(desc); 1191 + 1181 1192 if (desc->name) { 1182 1193 strncpy(lineinfo.name, desc->name, 1183 1194 sizeof(lineinfo.name)); ··· 1418 1427 ret = gdev->id; 1419 1428 goto err_free_gdev; 1420 1429 } 1421 - dev_set_name(&gdev->dev, "gpiochip%d", gdev->id); 1430 + dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); 1422 1431 device_initialize(&gdev->dev); 1423 1432 dev_set_drvdata(&gdev->dev, gdev); 1424 1433 if (chip->parent && chip->parent->driver) ··· 1443 1452 1444 1453 if (chip->ngpio > FASTPATH_NGPIO) 1445 1454 chip_warn(chip, "line cnt %u is greater than fast path cnt %u\n", 1446 - chip->ngpio, FASTPATH_NGPIO); 1455 + chip->ngpio, FASTPATH_NGPIO); 1447 1456 1448 1457 gdev->label = kstrdup_const(chip->label ?: "unknown", GFP_KERNEL); 1449 1458 if (!gdev->label) { ··· 1486 1495 goto err_free_label; 1487 1496 } 1488 1497 1489 - spin_unlock_irqrestore(&gpio_lock, flags); 1490 - 1491 1498 for (i = 0; i < chip->ngpio; i++) 1492 1499 gdev->descs[i].gdev = gdev; 1500 + 1501 + spin_unlock_irqrestore(&gpio_lock, flags); 1493 1502 1494 1503 #ifdef CONFIG_PINCTRL 1495 1504 INIT_LIST_HEAD(&gdev->pin_ranges); ··· 1515 1524 struct gpio_desc *desc = &gdev->descs[i]; 1516 1525 1517 1526 if (chip->get_direction && gpiochip_line_is_valid(chip, i)) { 1518 - if (!chip->get_direction(chip, i)) 1519 - set_bit(FLAG_IS_OUT, &desc->flags); 1520 - else 1521 - clear_bit(FLAG_IS_OUT, &desc->flags); 1527 + assign_bit(FLAG_IS_OUT, 1528 + &desc->flags, !chip->get_direction(chip, i)); 1522 1529 } else { 1523 - if (!chip->direction_input) 1524 - set_bit(FLAG_IS_OUT, &desc->flags); 1525 - else 1526 - clear_bit(FLAG_IS_OUT, &desc->flags); 1530 + assign_bit(FLAG_IS_OUT, 1531 + &desc->flags, !chip->direction_input); 1527 1532 } 1528 1533 } 1529 1534 ··· 1990 2003 irq_hw_number_t hwirq; 1991 2004 unsigned int type = IRQ_TYPE_NONE; 1992 2005 struct irq_fwspec *fwspec = data; 1993 - struct irq_fwspec parent_fwspec; 2006 + void *parent_arg; 1994 2007 unsigned int parent_hwirq; 1995 2008 unsigned int parent_type; 1996 2009 struct gpio_irq_chip *girq = &gc->irq; ··· 2006 2019 if (ret) 2007 2020 return ret; 2008 2021 2009 - chip_info(gc, "allocate IRQ %d, hwirq %lu\n", irq, hwirq); 2022 + chip_dbg(gc, "allocate IRQ %d, hwirq %lu\n", irq, hwirq); 2010 2023 2011 2024 ret = girq->child_to_parent_hwirq(gc, hwirq, type, 2012 2025 &parent_hwirq, &parent_type); ··· 2014 2027 chip_err(gc, "can't look up hwirq %lu\n", hwirq); 2015 2028 return ret; 2016 2029 } 2017 - chip_info(gc, "found parent hwirq %u\n", parent_hwirq); 2030 + chip_dbg(gc, "found parent hwirq %u\n", parent_hwirq); 2018 2031 2019 2032 /* 2020 2033 * We set handle_bad_irq because the .set_type() should ··· 2029 2042 NULL, NULL); 2030 2043 irq_set_probe(irq); 2031 2044 2032 - /* 2033 - * Create a IRQ fwspec to send up to the parent irqdomain: 2034 - * specify the hwirq we address on the parent and tie it 2035 - * all together up the chain. 2036 - */ 2037 - parent_fwspec.fwnode = d->parent->fwnode; 2038 2045 /* This parent only handles asserted level IRQs */ 2039 - girq->populate_parent_fwspec(gc, &parent_fwspec, parent_hwirq, 2040 - parent_type); 2041 - chip_info(gc, "alloc_irqs_parent for %d parent hwirq %d\n", 2046 + parent_arg = girq->populate_parent_alloc_arg(gc, parent_hwirq, parent_type); 2047 + if (!parent_arg) 2048 + return -ENOMEM; 2049 + 2050 + chip_dbg(gc, "alloc_irqs_parent for %d parent hwirq %d\n", 2042 2051 irq, parent_hwirq); 2043 - ret = irq_domain_alloc_irqs_parent(d, irq, 1, &parent_fwspec); 2052 + irq_set_lockdep_class(irq, gc->irq.lock_key, gc->irq.request_key); 2053 + ret = irq_domain_alloc_irqs_parent(d, irq, 1, parent_arg); 2054 + /* 2055 + * If the parent irqdomain is msi, the interrupts have already 2056 + * been allocated, so the EEXIST is good. 2057 + */ 2058 + if (irq_domain_is_msi(d->parent) && (ret == -EEXIST)) 2059 + ret = 0; 2044 2060 if (ret) 2045 2061 chip_err(gc, 2046 2062 "failed to allocate parent hwirq %d for hwirq %lu\n", 2047 2063 parent_hwirq, hwirq); 2048 2064 2065 + kfree(parent_arg); 2049 2066 return ret; 2050 2067 } 2051 2068 ··· 2086 2095 if (!gc->irq.child_offset_to_irq) 2087 2096 gc->irq.child_offset_to_irq = gpiochip_child_offset_to_irq_noop; 2088 2097 2089 - if (!gc->irq.populate_parent_fwspec) 2090 - gc->irq.populate_parent_fwspec = 2098 + if (!gc->irq.populate_parent_alloc_arg) 2099 + gc->irq.populate_parent_alloc_arg = 2091 2100 gpiochip_populate_parent_fwspec_twocell; 2092 2101 2093 2102 gpiochip_hierarchy_setup_domain_ops(&gc->irq.child_irq_domain_ops); ··· 2113 2122 return !!gc->irq.parent_domain; 2114 2123 } 2115 2124 2116 - void gpiochip_populate_parent_fwspec_twocell(struct gpio_chip *chip, 2117 - struct irq_fwspec *fwspec, 2125 + void *gpiochip_populate_parent_fwspec_twocell(struct gpio_chip *chip, 2118 2126 unsigned int parent_hwirq, 2119 2127 unsigned int parent_type) 2120 2128 { 2129 + struct irq_fwspec *fwspec; 2130 + 2131 + fwspec = kmalloc(sizeof(*fwspec), GFP_KERNEL); 2132 + if (!fwspec) 2133 + return NULL; 2134 + 2135 + fwspec->fwnode = chip->irq.parent_domain->fwnode; 2121 2136 fwspec->param_count = 2; 2122 2137 fwspec->param[0] = parent_hwirq; 2123 2138 fwspec->param[1] = parent_type; 2139 + 2140 + return fwspec; 2124 2141 } 2125 2142 EXPORT_SYMBOL_GPL(gpiochip_populate_parent_fwspec_twocell); 2126 2143 2127 - void gpiochip_populate_parent_fwspec_fourcell(struct gpio_chip *chip, 2128 - struct irq_fwspec *fwspec, 2144 + void *gpiochip_populate_parent_fwspec_fourcell(struct gpio_chip *chip, 2129 2145 unsigned int parent_hwirq, 2130 2146 unsigned int parent_type) 2131 2147 { 2148 + struct irq_fwspec *fwspec; 2149 + 2150 + fwspec = kmalloc(sizeof(*fwspec), GFP_KERNEL); 2151 + if (!fwspec) 2152 + return NULL; 2153 + 2154 + fwspec->fwnode = chip->irq.parent_domain->fwnode; 2132 2155 fwspec->param_count = 4; 2133 2156 fwspec->param[0] = 0; 2134 2157 fwspec->param[1] = parent_hwirq; 2135 2158 fwspec->param[2] = 0; 2136 2159 fwspec->param[3] = parent_type; 2160 + 2161 + return fwspec; 2137 2162 } 2138 2163 EXPORT_SYMBOL_GPL(gpiochip_populate_parent_fwspec_fourcell); 2139 2164 ··· 3005 2998 * A pointer to the GPIO descriptor, or an ERR_PTR()-encoded negative error 3006 2999 * code on failure. 3007 3000 */ 3008 - struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, 3001 + struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, 3002 + unsigned int hwnum, 3009 3003 const char *label, 3010 3004 enum gpio_lookup_flags lflags, 3011 3005 enum gpiod_flags dflags) ··· 3058 3050 * rely on gpio_request() having been called beforehand. 3059 3051 */ 3060 3052 3061 - static int gpio_set_config(struct gpio_chip *gc, unsigned offset, 3053 + static int gpio_set_config(struct gpio_chip *gc, unsigned int offset, 3062 3054 enum pin_config_param mode) 3063 3055 { 3064 - unsigned long config; 3065 - unsigned arg; 3056 + if (!gc->set_config) 3057 + return -ENOTSUPP; 3066 3058 3067 - switch (mode) { 3068 - case PIN_CONFIG_BIAS_DISABLE: 3069 - case PIN_CONFIG_BIAS_PULL_DOWN: 3070 - case PIN_CONFIG_BIAS_PULL_UP: 3071 - arg = 1; 3072 - break; 3073 - 3074 - default: 3075 - arg = 0; 3076 - } 3077 - 3078 - config = PIN_CONF_PACKED(mode, arg); 3079 - return gc->set_config ? gc->set_config(gc, offset, config) : -ENOTSUPP; 3059 + return gc->set_config(gc, offset, mode); 3080 3060 } 3081 3061 3082 3062 static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc) ··· 3298 3302 3299 3303 VALIDATE_DESC(desc); 3300 3304 chip = desc->gdev->chip; 3301 - if (!chip->set || !chip->set_config) { 3302 - gpiod_dbg(desc, 3303 - "%s: missing set() or set_config() operations\n", 3304 - __func__); 3305 - return -ENOTSUPP; 3306 - } 3307 3305 3308 3306 config = pinconf_to_config_packed(PIN_CONFIG_INPUT_DEBOUNCE, debounce); 3309 - return chip->set_config(chip, gpio_chip_hwgpio(desc), config); 3307 + return gpio_set_config(chip, gpio_chip_hwgpio(desc), config); 3310 3308 } 3311 3309 EXPORT_SYMBOL_GPL(gpiod_set_debounce); 3312 3310 ··· 3324 3334 * Handle FLAG_TRANSITORY first, enabling queries to gpiolib for 3325 3335 * persistence state. 3326 3336 */ 3327 - if (transitory) 3328 - set_bit(FLAG_TRANSITORY, &desc->flags); 3329 - else 3330 - clear_bit(FLAG_TRANSITORY, &desc->flags); 3337 + assign_bit(FLAG_TRANSITORY, &desc->flags, transitory); 3331 3338 3332 3339 /* If the driver supports it, set the persistence state now */ 3333 3340 chip = desc->gdev->chip; ··· 3334 3347 packed = pinconf_to_config_packed(PIN_CONFIG_PERSIST_STATE, 3335 3348 !transitory); 3336 3349 gpio = gpio_chip_hwgpio(desc); 3337 - rc = chip->set_config(chip, gpio, packed); 3350 + rc = gpio_set_config(chip, gpio, packed); 3338 3351 if (rc == -ENOTSUPP) { 3339 3352 dev_dbg(&desc->gdev->dev, "Persistence not supported for GPIO %d\n", 3340 3353 gpio); ··· 3791 3804 gpio_set_open_source_value_commit(desc, value); 3792 3805 } else { 3793 3806 __set_bit(hwgpio, mask); 3794 - if (value) 3795 - __set_bit(hwgpio, bits); 3796 - else 3797 - __clear_bit(hwgpio, bits); 3807 + __assign_bit(hwgpio, bits, value); 3798 3808 count++; 3799 3809 } 3800 3810 i++; ··· 5108 5124 return ret; 5109 5125 } 5110 5126 5111 - ret = alloc_chrdev_region(&gpio_devt, 0, GPIO_DEV_MAX, "gpiochip"); 5127 + ret = alloc_chrdev_region(&gpio_devt, 0, GPIO_DEV_MAX, GPIOCHIP_NAME); 5112 5128 if (ret < 0) { 5113 5129 pr_err("gpiolib: failed to allocate char dev region\n"); 5114 5130 bus_unregister(&gpio_bus_type);
+4 -1
drivers/gpio/gpiolib.h
··· 16 16 #include <linux/module.h> 17 17 #include <linux/cdev.h> 18 18 19 + #define GPIOCHIP_NAME "gpiochip" 20 + 19 21 /** 20 22 * struct gpio_device - internal state container for GPIO devices 21 23 * @id: numerical ID number for the GPIO chip ··· 80 78 unsigned long invert_mask[]; 81 79 }; 82 80 83 - struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, u16 hwnum); 81 + struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, 82 + unsigned int hwnum); 84 83 int gpiod_get_array_value_complex(bool raw, bool can_sleep, 85 84 unsigned int array_size, 86 85 struct gpio_desc **desc_array,
+1 -1
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
··· 1060 1060 girq->fwnode = of_node_to_fwnode(state->dev->of_node); 1061 1061 girq->parent_domain = parent_domain; 1062 1062 girq->child_to_parent_hwirq = pmic_gpio_child_to_parent_hwirq; 1063 - girq->populate_parent_fwspec = gpiochip_populate_parent_fwspec_fourcell; 1063 + girq->populate_parent_alloc_arg = gpiochip_populate_parent_fwspec_fourcell; 1064 1064 girq->child_offset_to_irq = pmic_gpio_child_offset_to_irq; 1065 1065 girq->child_irq_domain_ops.translate = pmic_gpio_domain_translate; 1066 1066
+1 -1
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
··· 794 794 girq->fwnode = of_node_to_fwnode(pctrl->dev->of_node); 795 795 girq->parent_domain = parent_domain; 796 796 girq->child_to_parent_hwirq = pm8xxx_child_to_parent_hwirq; 797 - girq->populate_parent_fwspec = gpiochip_populate_parent_fwspec_fourcell; 797 + girq->populate_parent_alloc_arg = gpiochip_populate_parent_fwspec_fourcell; 798 798 girq->child_offset_to_irq = pm8xxx_child_offset_to_irq; 799 799 girq->child_irq_domain_ops.translate = pm8xxx_domain_translate; 800 800
+12 -14
include/linux/gpio/driver.h
··· 94 94 unsigned int *parent_type); 95 95 96 96 /** 97 - * @populate_parent_fwspec: 97 + * @populate_parent_alloc_arg : 98 98 * 99 - * This optional callback populates the &struct irq_fwspec for the 100 - * parent's IRQ domain. If this is not specified, then 99 + * This optional callback allocates and populates the specific struct 100 + * for the parent's IRQ domain. If this is not specified, then 101 101 * &gpiochip_populate_parent_fwspec_twocell will be used. A four-cell 102 102 * variant named &gpiochip_populate_parent_fwspec_fourcell is also 103 103 * available. 104 104 */ 105 - void (*populate_parent_fwspec)(struct gpio_chip *chip, 106 - struct irq_fwspec *fwspec, 105 + void *(*populate_parent_alloc_arg)(struct gpio_chip *chip, 107 106 unsigned int parent_hwirq, 108 107 unsigned int parent_type); 109 108 ··· 536 537 537 538 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY 538 539 539 - void gpiochip_populate_parent_fwspec_twocell(struct gpio_chip *chip, 540 - struct irq_fwspec *fwspec, 540 + void *gpiochip_populate_parent_fwspec_twocell(struct gpio_chip *chip, 541 541 unsigned int parent_hwirq, 542 542 unsigned int parent_type); 543 - void gpiochip_populate_parent_fwspec_fourcell(struct gpio_chip *chip, 544 - struct irq_fwspec *fwspec, 543 + void *gpiochip_populate_parent_fwspec_fourcell(struct gpio_chip *chip, 545 544 unsigned int parent_hwirq, 546 545 unsigned int parent_type); 547 546 548 547 #else 549 548 550 - static inline void gpiochip_populate_parent_fwspec_twocell(struct gpio_chip *chip, 551 - struct irq_fwspec *fwspec, 549 + static inline void *gpiochip_populate_parent_fwspec_twocell(struct gpio_chip *chip, 552 550 unsigned int parent_hwirq, 553 551 unsigned int parent_type) 554 552 { 553 + return NULL; 555 554 } 556 555 557 - static inline void gpiochip_populate_parent_fwspec_fourcell(struct gpio_chip *chip, 558 - struct irq_fwspec *fwspec, 556 + static inline void *gpiochip_populate_parent_fwspec_fourcell(struct gpio_chip *chip, 559 557 unsigned int parent_hwirq, 560 558 unsigned int parent_type) 561 559 { 560 + return NULL; 562 561 } 563 562 564 563 #endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */ ··· 712 715 713 716 #endif /* CONFIG_PINCTRL */ 714 717 715 - struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, 718 + struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, 719 + unsigned int hwnum, 716 720 const char *label, 717 721 enum gpio_lookup_flags lflags, 718 722 enum gpiod_flags dflags);
-134
include/linux/ipmi-fru.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0+ */ 2 - /* 3 - * Copyright (C) 2012 CERN (www.cern.ch) 4 - * Author: Alessandro Rubini <rubini@gnudd.com> 5 - * 6 - * This work is part of the White Rabbit project, a research effort led 7 - * by CERN, the European Institute for Nuclear Research. 8 - */ 9 - #ifndef __LINUX_IPMI_FRU_H__ 10 - #define __LINUX_IPMI_FRU_H__ 11 - #ifdef __KERNEL__ 12 - # include <linux/types.h> 13 - # include <linux/string.h> 14 - #else 15 - # include <stdint.h> 16 - # include <string.h> 17 - #endif 18 - 19 - /* 20 - * These structures match the unaligned crap we have in FRU1011.pdf 21 - * (http://download.intel.com/design/servers/ipmi/FRU1011.pdf) 22 - */ 23 - 24 - /* chapter 8, page 5 */ 25 - struct fru_common_header { 26 - uint8_t format; /* 0x01 */ 27 - uint8_t internal_use_off; /* multiple of 8 bytes */ 28 - uint8_t chassis_info_off; /* multiple of 8 bytes */ 29 - uint8_t board_area_off; /* multiple of 8 bytes */ 30 - uint8_t product_area_off; /* multiple of 8 bytes */ 31 - uint8_t multirecord_off; /* multiple of 8 bytes */ 32 - uint8_t pad; /* must be 0 */ 33 - uint8_t checksum; /* sum modulo 256 must be 0 */ 34 - }; 35 - 36 - /* chapter 9, page 5 -- internal_use: not used by us */ 37 - 38 - /* chapter 10, page 6 -- chassis info: not used by us */ 39 - 40 - /* chapter 13, page 9 -- used by board_info_area below */ 41 - struct fru_type_length { 42 - uint8_t type_length; 43 - uint8_t data[0]; 44 - }; 45 - 46 - /* chapter 11, page 7 */ 47 - struct fru_board_info_area { 48 - uint8_t format; /* 0x01 */ 49 - uint8_t area_len; /* multiple of 8 bytes */ 50 - uint8_t language; /* I hope it's 0 */ 51 - uint8_t mfg_date[3]; /* LSB, minutes since 1996-01-01 */ 52 - struct fru_type_length tl[0]; /* type-length stuff follows */ 53 - 54 - /* 55 - * the TL there are in order: 56 - * Board Manufacturer 57 - * Board Product Name 58 - * Board Serial Number 59 - * Board Part Number 60 - * FRU File ID (may be null) 61 - * more manufacturer-specific stuff 62 - * 0xc1 as a terminator 63 - * 0x00 pad to a multiple of 8 bytes - 1 64 - * checksum (sum of all stuff module 256 must be zero) 65 - */ 66 - }; 67 - 68 - enum fru_type { 69 - FRU_TYPE_BINARY = 0x00, 70 - FRU_TYPE_BCDPLUS = 0x40, 71 - FRU_TYPE_ASCII6 = 0x80, 72 - FRU_TYPE_ASCII = 0xc0, /* not ascii: depends on language */ 73 - }; 74 - 75 - /* 76 - * some helpers 77 - */ 78 - static inline struct fru_board_info_area *fru_get_board_area( 79 - const struct fru_common_header *header) 80 - { 81 - /* we know for sure that the header is 8 bytes in size */ 82 - return (struct fru_board_info_area *)(header + header->board_area_off); 83 - } 84 - 85 - static inline int fru_type(struct fru_type_length *tl) 86 - { 87 - return tl->type_length & 0xc0; 88 - } 89 - 90 - static inline int fru_length(struct fru_type_length *tl) 91 - { 92 - return (tl->type_length & 0x3f) + 1; /* len of whole record */ 93 - } 94 - 95 - /* assume ascii-latin1 encoding */ 96 - static inline int fru_strlen(struct fru_type_length *tl) 97 - { 98 - return fru_length(tl) - 1; 99 - } 100 - 101 - static inline char *fru_strcpy(char *dest, struct fru_type_length *tl) 102 - { 103 - int len = fru_strlen(tl); 104 - memcpy(dest, tl->data, len); 105 - dest[len] = '\0'; 106 - return dest; 107 - } 108 - 109 - static inline struct fru_type_length *fru_next_tl(struct fru_type_length *tl) 110 - { 111 - return tl + fru_length(tl); 112 - } 113 - 114 - static inline int fru_is_eof(struct fru_type_length *tl) 115 - { 116 - return tl->type_length == 0xc1; 117 - } 118 - 119 - /* 120 - * External functions defined in fru-parse.c. 121 - */ 122 - extern int fru_header_cksum_ok(struct fru_common_header *header); 123 - extern int fru_bia_cksum_ok(struct fru_board_info_area *bia); 124 - 125 - /* All these 4 return allocated strings by calling fru_alloc() */ 126 - extern char *fru_get_board_manufacturer(struct fru_common_header *header); 127 - extern char *fru_get_product_name(struct fru_common_header *header); 128 - extern char *fru_get_serial_number(struct fru_common_header *header); 129 - extern char *fru_get_part_number(struct fru_common_header *header); 130 - 131 - /* This must be defined by the caller of the above functions */ 132 - extern void *fru_alloc(size_t size); 133 - 134 - #endif /* __LINUX_IMPI_FRU_H__ */