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

Merge tag 'gpio-updates-for-v5.13-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio updates from Bartosz Golaszewski:

- new driver for the Realtek Otto GPIO controller

- ACPI support for gpio-mpc8xxx

- edge event support for gpio-sch (+ Kconfig fixes)

- Kconfig improvements in gpio-ich

- fixes to older issues in gpio-mockup

- ACPI quirk for ignoring EC wakeups on Dell Venue 10 Pro 5055

- improve the GPIO aggregator code by using more generic interfaces
instead of reimplementing them in the driver

- convert the DT bindings for gpio-74x164 to yaml

- documentation improvements

- a slew of other minor fixes and improvements to GPIO drivers

* tag 'gpio-updates-for-v5.13-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (34 commits)
dt-bindings: gpio: add YAML description for rockchip,gpio-bank
gpio: mxs: remove useless function
dt-bindings: gpio: fairchild,74hc595: Convert to json-schema
gpio: it87: remove unused code
gpio: 104-dio-48e: Fix coding style issues
gpio: mpc8xxx: Add ACPI support
gpio: ich: Switch to be dependent on LPC_ICH
gpio: sch: Drop MFD_CORE selection
gpio: sch: depends on LPC_SCH
gpiolib: acpi: Add quirk to ignore EC wakeups on Dell Venue 10 Pro 5055
gpio: sch: Hook into ACPI GPE handler to catch GPIO edge events
gpio: sch: Add edge event support
gpio: aggregator: Replace custom get_arg() with a generic next_arg()
lib/cmdline: Export next_arg() for being used in modules
gpio: omap: Use device_get_match_data() helper
gpio: Add Realtek Otto GPIO support
dt-bindings: gpio: Binding for Realtek Otto GPIO
docs: kernel-parameters: Add gpio_mockup_named_lines
docs: kernel-parameters: Move gpio-mockup for alphabetic order
lib: bitmap: provide devm_bitmap_alloc() and devm_bitmap_zalloc()
...

+1067 -349
+6 -5
Documentation/admin-guide/gpio/gpio-mockup.rst
··· 17 17 gpio_mockup_ranges 18 18 19 19 This parameter takes an argument in the form of an array of integer 20 - pairs. Each pair defines the base GPIO number (if any) and the number 21 - of lines exposed by the chip. If the base GPIO is -1, the gpiolib 22 - will assign it automatically. 20 + pairs. Each pair defines the base GPIO number (non-negative integer) 21 + and the first number after the last of this chip. If the base GPIO 22 + is -1, the gpiolib will assign it automatically. while the following 23 + parameter is the number of lines exposed by the chip. 23 24 24 - Example: gpio_mockup_ranges=-1,8,-1,16,405,4 25 + Example: gpio_mockup_ranges=-1,8,-1,16,405,409 25 26 26 27 The line above creates three chips. The first one will expose 8 lines, 27 28 the second 16 and the third 4. The base GPIO for the third chip is set 28 29 to 405 while for two first chips it will be assigned automatically. 29 30 30 - gpio_named_lines 31 + gpio_mockup_named_lines 31 32 32 33 This parameter doesn't take any arguments. It lets the driver know that 33 34 GPIO lines exposed by it should be named.
+6 -4
Documentation/admin-guide/kernel-parameters.txt
··· 1469 1469 Don't use this when you are not running on the 1470 1470 android emulator 1471 1471 1472 + gpio-mockup.gpio_mockup_ranges 1473 + [HW] Sets the ranges of gpiochip of for this device. 1474 + Format: <start1>,<end1>,<start2>,<end2>... 1475 + gpio-mockup.gpio_mockup_named_lines 1476 + [HW] Let the driver know GPIO lines should be named. 1477 + 1472 1478 gpt [EFI] Forces disk with valid GPT signature but 1473 1479 invalid Protective MBR to be treated as GPT. If the 1474 1480 primary GPT is corrupted, it enables the backup/alternate ··· 1497 1491 grcan.rxsize= [HW] Sets the size of the rx buffer. 1498 1492 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0. 1499 1493 Default: 1024 1500 - 1501 - gpio-mockup.gpio_mockup_ranges 1502 - [HW] Sets the ranges of gpiochip of for this device. 1503 - Format: <start1>,<end1>,<start2>,<end2>... 1504 1494 1505 1495 hardlockup_all_cpu_backtrace= 1506 1496 [KNL] Should the hard-lockup detector generate
+12 -10
Documentation/core-api/irq/irq-domain.rst
··· 42 42 ================ 43 43 44 44 An interrupt controller driver creates and registers an irq_domain by 45 - calling one of the irq_domain_add_*() functions (each mapping method 46 - has a different allocator function, more on that later). The function 47 - will return a pointer to the irq_domain on success. The caller must 48 - provide the allocator function with an irq_domain_ops structure. 45 + calling one of the irq_domain_add_*() or irq_domain_create_*() functions 46 + (each mapping method has a different allocator function, more on that later). 47 + The function will return a pointer to the irq_domain on success. The caller 48 + must provide the allocator function with an irq_domain_ops structure. 49 49 50 50 In most cases, the irq_domain will begin empty without any mappings 51 51 between hwirq and IRQ numbers. Mappings are added to the irq_domain ··· 147 147 irq_domain_add_simple() 148 148 irq_domain_add_legacy() 149 149 irq_domain_add_legacy_isa() 150 + irq_domain_create_simple() 150 151 irq_domain_create_legacy() 151 152 152 153 The Legacy mapping is a special case for drivers that already have a ··· 170 169 mapping Linux IRQs 0-15 so that existing ISA drivers get the correct IRQ 171 170 numbers. 172 171 173 - Most users of legacy mappings should use irq_domain_add_simple() which 174 - will use a legacy domain only if an IRQ range is supplied by the 175 - system and will otherwise use a linear domain mapping. The semantics 176 - of this call are such that if an IRQ range is specified then 172 + Most users of legacy mappings should use irq_domain_add_simple() or 173 + irq_domain_create_simple() which will use a legacy domain only if an IRQ range 174 + is supplied by the system and will otherwise use a linear domain mapping. 175 + The semantics of this call are such that if an IRQ range is specified then 177 176 descriptors will be allocated on-the-fly for it, and if no range is 178 - specified it will fall through to irq_domain_add_linear() which means 179 - *no* irq descriptors will be allocated. 177 + specified it will fall through to irq_domain_add_linear() or 178 + irq_domain_create_linear() which means *no* irq descriptors will be allocated. 180 179 181 180 A typical use case for simple domains is where an irqchip provider 182 181 is supporting both dynamic and static IRQ assignments. ··· 187 186 before any irq_find_mapping() since the latter will actually work 188 187 for the static IRQ assignment case. 189 188 189 + irq_domain_add_simple() and irq_domain_create_simple() as well as 190 190 irq_domain_add_legacy() and irq_domain_create_legacy() are functionally 191 191 equivalent, except for the first argument is different - the former 192 192 accepts an Open Firmware specific 'struct device_node', while the latter
+77
Documentation/devicetree/bindings/gpio/fairchild,74hc595.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/fairchild,74hc595.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Generic 8-bit shift register 8 + 9 + maintainers: 10 + - Maxime Ripard <mripard@kernel.org> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - fairchild,74hc595 16 + - nxp,74lvc594 17 + 18 + reg: 19 + maxItems: 1 20 + 21 + gpio-controller: true 22 + 23 + '#gpio-cells': 24 + description: 25 + The second cell is only used to specify the GPIO polarity. 26 + const: 2 27 + 28 + registers-number: 29 + description: Number of daisy-chained shift registers 30 + 31 + enable-gpios: 32 + description: GPIO connected to the OE (Output Enable) pin. 33 + maxItems: 1 34 + 35 + spi-max-frequency: true 36 + 37 + patternProperties: 38 + "^(hog-[0-9]+|.+-hog(-[0-9]+)?)$": 39 + type: object 40 + 41 + properties: 42 + gpio-hog: true 43 + gpios: true 44 + output-high: true 45 + output-low: true 46 + line-name: true 47 + 48 + required: 49 + - gpio-hog 50 + - gpios 51 + 52 + additionalProperties: false 53 + 54 + required: 55 + - compatible 56 + - reg 57 + - gpio-controller 58 + - '#gpio-cells' 59 + - registers-number 60 + 61 + additionalProperties: false 62 + 63 + examples: 64 + - | 65 + spi { 66 + #address-cells = <1>; 67 + #size-cells = <0>; 68 + 69 + gpio5: gpio5@0 { 70 + compatible = "fairchild,74hc595"; 71 + reg = <0>; 72 + gpio-controller; 73 + #gpio-cells = <2>; 74 + registers-number = <4>; 75 + spi-max-frequency = <100000>; 76 + }; 77 + };
-27
Documentation/devicetree/bindings/gpio/gpio-74x164.txt
··· 1 - * Generic 8-bits shift register GPIO driver 2 - 3 - Required properties: 4 - - compatible: Should contain one of the following: 5 - "fairchild,74hc595" 6 - "nxp,74lvc594" 7 - - reg : chip select number 8 - - gpio-controller : Marks the device node as a gpio controller. 9 - - #gpio-cells : Should be two. The first cell is the pin number and 10 - the second cell is used to specify the gpio polarity: 11 - 0 = active high 12 - 1 = active low 13 - - registers-number: Number of daisy-chained shift registers 14 - 15 - Optional properties: 16 - - enable-gpios: GPIO connected to the OE (Output Enable) pin. 17 - 18 - Example: 19 - 20 - gpio5: gpio5@0 { 21 - compatible = "fairchild,74hc595"; 22 - reg = <0>; 23 - gpio-controller; 24 - #gpio-cells = <2>; 25 - registers-number = <4>; 26 - spi-max-frequency = <100000>; 27 - };
+78
Documentation/devicetree/bindings/gpio/realtek,otto-gpio.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/realtek,otto-gpio.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Realtek Otto GPIO controller 8 + 9 + maintainers: 10 + - Sander Vanheule <sander@svanheule.net> 11 + - Bert Vermeulen <bert@biot.com> 12 + 13 + description: | 14 + Realtek's GPIO controller on their MIPS switch SoCs (Otto platform) consists 15 + of two banks of 32 GPIOs. These GPIOs can generate edge-triggered interrupts. 16 + Each bank's interrupts are cascased into one interrupt line on the parent 17 + interrupt controller, if provided. 18 + This binding allows defining a single bank in the devicetree. The interrupt 19 + controller is not supported on the fallback compatible name, which only 20 + allows for GPIO port use. 21 + 22 + properties: 23 + $nodename: 24 + pattern: "^gpio@[0-9a-f]+$" 25 + 26 + compatible: 27 + items: 28 + - enum: 29 + - realtek,rtl8380-gpio 30 + - realtek,rtl8390-gpio 31 + - const: realtek,otto-gpio 32 + 33 + reg: 34 + maxItems: 1 35 + 36 + "#gpio-cells": 37 + const: 2 38 + 39 + gpio-controller: true 40 + 41 + ngpios: 42 + minimum: 1 43 + maximum: 32 44 + 45 + interrupt-controller: true 46 + 47 + "#interrupt-cells": 48 + const: 2 49 + 50 + interrupts: 51 + maxItems: 1 52 + 53 + required: 54 + - compatible 55 + - reg 56 + - "#gpio-cells" 57 + - gpio-controller 58 + 59 + additionalProperties: false 60 + 61 + dependencies: 62 + interrupt-controller: [ interrupts ] 63 + 64 + examples: 65 + - | 66 + gpio@3500 { 67 + compatible = "realtek,rtl8380-gpio", "realtek,otto-gpio"; 68 + reg = <0x3500 0x1c>; 69 + gpio-controller; 70 + #gpio-cells = <2>; 71 + ngpios = <24>; 72 + interrupt-controller; 73 + #interrupt-cells = <2>; 74 + interrupt-parent = <&rtlintc>; 75 + interrupts = <23>; 76 + }; 77 + 78 + ...
+82
Documentation/devicetree/bindings/gpio/rockchip,gpio-bank.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/gpio/rockchip,gpio-bank.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Rockchip GPIO bank 8 + 9 + maintainers: 10 + - Heiko Stuebner <heiko@sntech.de> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - rockchip,gpio-bank 16 + - rockchip,rk3188-gpio-bank0 17 + 18 + reg: 19 + maxItems: 1 20 + 21 + interrupts: 22 + maxItems: 1 23 + 24 + clocks: 25 + maxItems: 1 26 + 27 + gpio-controller: true 28 + 29 + "#gpio-cells": 30 + const: 2 31 + 32 + interrupt-controller: true 33 + 34 + "#interrupt-cells": 35 + const: 2 36 + 37 + required: 38 + - compatible 39 + - reg 40 + - interrupts 41 + - clocks 42 + - gpio-controller 43 + - "#gpio-cells" 44 + - interrupt-controller 45 + - "#interrupt-cells" 46 + 47 + additionalProperties: false 48 + 49 + examples: 50 + - | 51 + #include <dt-bindings/interrupt-controller/arm-gic.h> 52 + pinctrl: pinctrl { 53 + #address-cells = <1>; 54 + #size-cells = <1>; 55 + ranges; 56 + 57 + gpio0: gpio@2000a000 { 58 + compatible = "rockchip,rk3188-gpio-bank0"; 59 + reg = <0x2000a000 0x100>; 60 + interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>; 61 + clocks = <&clk_gates8 9>; 62 + 63 + gpio-controller; 64 + #gpio-cells = <2>; 65 + 66 + interrupt-controller; 67 + #interrupt-cells = <2>; 68 + }; 69 + 70 + gpio1: gpio@2003c000 { 71 + compatible = "rockchip,gpio-bank"; 72 + reg = <0x2003c000 0x100>; 73 + interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>; 74 + clocks = <&clk_gates8 10>; 75 + 76 + gpio-controller; 77 + #gpio-cells = <2>; 78 + 79 + interrupt-controller; 80 + #interrupt-cells = <2>; 81 + }; 82 + };
+1 -57
Documentation/devicetree/bindings/pinctrl/rockchip,pinctrl.txt
··· 51 51 Use rockchip,grf and rockchip,pmu described above instead. 52 52 53 53 Required properties for gpio sub nodes: 54 - - compatible: "rockchip,gpio-bank" 55 - - reg: register of the gpio bank (different than the iomux registerset) 56 - - interrupts: base interrupt of the gpio bank in the interrupt controller 57 - - clocks: clock that drives this bank 58 - - gpio-controller: identifies the node as a gpio controller and pin bank. 59 - - #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO 60 - binding is used, the amount of cells must be specified as 2. See generic 61 - GPIO binding documentation for description of particular cells. 62 - - interrupt-controller: identifies the controller node as interrupt-parent. 63 - - #interrupt-cells: the value of this property should be 2 and the interrupt 64 - cells should use the standard two-cell scheme described in 65 - bindings/interrupt-controller/interrupts.txt 66 - 67 - Deprecated properties for gpio sub nodes: 68 - - compatible: "rockchip,rk3188-gpio-bank0" 69 - - reg: second element: separate pull register for rk3188 bank0, use 70 - rockchip,pmu described above instead 54 + See rockchip,gpio-bank.yaml 71 55 72 56 Required properties for pin configuration node: 73 57 - rockchip,pins: 3 integers array, represents a group of pins mux and config ··· 112 128 pinctrl-names = "default"; 113 129 pinctrl-0 = <&uart2_xfer>; 114 130 }; 115 - 116 - Example for rk3188: 117 - 118 - pinctrl@20008000 { 119 - compatible = "rockchip,rk3188-pinctrl"; 120 - rockchip,grf = <&grf>; 121 - rockchip,pmu = <&pmu>; 122 - #address-cells = <1>; 123 - #size-cells = <1>; 124 - ranges; 125 - 126 - gpio0: gpio0@2000a000 { 127 - compatible = "rockchip,rk3188-gpio-bank0"; 128 - reg = <0x2000a000 0x100>; 129 - interrupts = <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>; 130 - clocks = <&clk_gates8 9>; 131 - 132 - gpio-controller; 133 - #gpio-cells = <2>; 134 - 135 - interrupt-controller; 136 - #interrupt-cells = <2>; 137 - }; 138 - 139 - gpio1: gpio1@2003c000 { 140 - compatible = "rockchip,gpio-bank"; 141 - reg = <0x2003c000 0x100>; 142 - interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>; 143 - clocks = <&clk_gates8 10>; 144 - 145 - gpio-controller; 146 - #gpio-cells = <2>; 147 - 148 - interrupt-controller; 149 - #interrupt-cells = <2>; 150 - }; 151 - 152 - ... 153 - 154 - };
+1 -1
Documentation/driver-api/gpio/consumer.rst
··· 12 12 13 13 Drivers that can't work without standard GPIO calls should have Kconfig entries 14 14 that depend on GPIOLIB or select GPIOLIB. The functions that allow a driver to 15 - obtain and use GPIOs are available by including the following file: 15 + obtain and use GPIOs are available by including the following file:: 16 16 17 17 #include <linux/gpio/consumer.h> 18 18
+6
Documentation/driver-api/gpio/drivers-on-gpio.rst
··· 96 96 way to pass the charging parameters from hardware descriptions such as the 97 97 device tree. 98 98 99 + - gpio-mux: drivers/mux/gpio.c is used for controlling a multiplexer using 100 + n GPIO lines such that you can mux in 2^n different devices by activating 101 + different GPIO lines. Often the GPIOs are on a SoC and the devices are 102 + some SoC-external entities, such as different components on a PCB that 103 + can be selectively enabled. 104 + 99 105 Apart from this there are special GPIO drivers in subsystems like MMC/SD to 100 106 read card detect and write protect GPIO lines, and in the TTY serial subsystem 101 107 to emulate MCTRL (modem control) signals CTS/RTS by using two GPIO lines. The
+18 -6
drivers/gpio/Kconfig
··· 321 321 322 322 config GPIO_ICH 323 323 tristate "Intel ICH GPIO" 324 - depends on PCI && X86 325 - select MFD_CORE 326 - select LPC_ICH 324 + depends on X86 325 + depends on LPC_ICH 327 326 help 328 327 Say yes here to support the GPIO functionality of a number of Intel 329 328 ICH-based chipsets. Currently supported devices: ICH6, ICH7, ICH8 ··· 500 501 select GPIOLIB_IRQCHIP 501 502 help 502 503 Say Y here to support RDA Micro GPIO controller. 504 + 505 + config GPIO_REALTEK_OTTO 506 + tristate "Realtek Otto GPIO support" 507 + depends on MACH_REALTEK_RTL 508 + default MACH_REALTEK_RTL 509 + select GPIO_GENERIC 510 + select GPIOLIB_IRQCHIP 511 + help 512 + The GPIO controller on the Otto MIPS platform supports up to two 513 + banks of 32 GPIOs, with edge triggered interrupts. The 32 GPIOs 514 + are grouped in four 8-bit wide ports. 515 + 516 + When built as a module, the module will be called realtek_otto_gpio. 503 517 504 518 config GPIO_REG 505 519 bool ··· 859 847 860 848 config GPIO_SCH 861 849 tristate "Intel SCH/TunnelCreek/Centerton/Quark X1000 GPIO" 862 - depends on (X86 || COMPILE_TEST) && PCI 863 - select MFD_CORE 864 - select LPC_SCH 850 + depends on (X86 || COMPILE_TEST) && ACPI 851 + depends on LPC_SCH 852 + select GPIOLIB_IRQCHIP 865 853 help 866 854 Say yes here to support GPIO interface on Intel Poulsbo SCH, 867 855 Intel Tunnel Creek processor, Intel Centerton processor or
+1
drivers/gpio/Makefile
··· 125 125 obj-$(CONFIG_GPIO_RCAR) += gpio-rcar.o 126 126 obj-$(CONFIG_GPIO_RDA) += gpio-rda.o 127 127 obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o 128 + obj-$(CONFIG_GPIO_REALTEK_OTTO) += gpio-realtek-otto.o 128 129 obj-$(CONFIG_GPIO_REG) += gpio-reg.o 129 130 obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o 130 131 obj-$(CONFIG_GPIO_SAMA5D2_PIOBU) += gpio-sama5d2-piobu.o
+25 -25
drivers/gpio/gpio-104-dio-48e.c
··· 49 49 unsigned char out_state[6]; 50 50 unsigned char control[2]; 51 51 raw_spinlock_t lock; 52 - unsigned base; 52 + unsigned int base; 53 53 unsigned char irq_mask; 54 54 }; 55 55 56 - static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned offset) 56 + static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) 57 57 { 58 58 struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); 59 - const unsigned port = offset / 8; 60 - const unsigned mask = BIT(offset % 8); 59 + const unsigned int port = offset / 8; 60 + const unsigned int mask = BIT(offset % 8); 61 61 62 62 if (dio48egpio->io_state[port] & mask) 63 63 return GPIO_LINE_DIRECTION_IN; ··· 65 65 return GPIO_LINE_DIRECTION_OUT; 66 66 } 67 67 68 - static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned offset) 68 + static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) 69 69 { 70 70 struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); 71 - const unsigned io_port = offset / 8; 71 + const unsigned int io_port = offset / 8; 72 72 const unsigned int control_port = io_port / 3; 73 - const unsigned control_addr = dio48egpio->base + 3 + control_port*4; 73 + const unsigned int control_addr = dio48egpio->base + 3 + control_port * 4; 74 74 unsigned long flags; 75 - unsigned control; 75 + unsigned int control; 76 76 77 77 raw_spin_lock_irqsave(&dio48egpio->lock, flags); 78 78 ··· 104 104 return 0; 105 105 } 106 106 107 - static int dio48e_gpio_direction_output(struct gpio_chip *chip, unsigned offset, 108 - int value) 107 + static int dio48e_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, 108 + int value) 109 109 { 110 110 struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); 111 - const unsigned io_port = offset / 8; 111 + const unsigned int io_port = offset / 8; 112 112 const unsigned int control_port = io_port / 3; 113 - const unsigned mask = BIT(offset % 8); 114 - const unsigned control_addr = dio48egpio->base + 3 + control_port*4; 115 - const unsigned out_port = (io_port > 2) ? io_port + 1 : io_port; 113 + const unsigned int mask = BIT(offset % 8); 114 + const unsigned int control_addr = dio48egpio->base + 3 + control_port * 4; 115 + const unsigned int out_port = (io_port > 2) ? io_port + 1 : io_port; 116 116 unsigned long flags; 117 - unsigned control; 117 + unsigned int control; 118 118 119 119 raw_spin_lock_irqsave(&dio48egpio->lock, flags); 120 120 ··· 154 154 return 0; 155 155 } 156 156 157 - static int dio48e_gpio_get(struct gpio_chip *chip, unsigned offset) 157 + static int dio48e_gpio_get(struct gpio_chip *chip, unsigned int offset) 158 158 { 159 159 struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); 160 - const unsigned port = offset / 8; 161 - const unsigned mask = BIT(offset % 8); 162 - const unsigned in_port = (port > 2) ? port + 1 : port; 160 + const unsigned int port = offset / 8; 161 + const unsigned int mask = BIT(offset % 8); 162 + const unsigned int in_port = (port > 2) ? port + 1 : port; 163 163 unsigned long flags; 164 - unsigned port_state; 164 + unsigned int port_state; 165 165 166 166 raw_spin_lock_irqsave(&dio48egpio->lock, flags); 167 167 ··· 202 202 return 0; 203 203 } 204 204 205 - static void dio48e_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 205 + static void dio48e_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) 206 206 { 207 207 struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); 208 - const unsigned port = offset / 8; 209 - const unsigned mask = BIT(offset % 8); 210 - const unsigned out_port = (port > 2) ? port + 1 : port; 208 + const unsigned int port = offset / 8; 209 + const unsigned int mask = BIT(offset % 8); 210 + const unsigned int out_port = (port > 2) ? port + 1 : port; 211 211 unsigned long flags; 212 212 213 213 raw_spin_lock_irqsave(&dio48egpio->lock, flags); ··· 306 306 raw_spin_unlock_irqrestore(&dio48egpio->lock, flags); 307 307 } 308 308 309 - static int dio48e_irq_set_type(struct irq_data *data, unsigned flow_type) 309 + static int dio48e_irq_set_type(struct irq_data *data, unsigned int flow_type) 310 310 { 311 311 const unsigned long offset = irqd_to_hwirq(data); 312 312
+5 -34
drivers/gpio/gpio-aggregator.c
··· 37 37 static DEFINE_MUTEX(gpio_aggregator_lock); /* protects idr */ 38 38 static DEFINE_IDR(gpio_aggregator_idr); 39 39 40 - static char *get_arg(char **args) 41 - { 42 - char *start, *end; 43 - 44 - start = skip_spaces(*args); 45 - if (!*start) 46 - return NULL; 47 - 48 - if (*start == '"') { 49 - /* Quoted arg */ 50 - end = strchr(++start, '"'); 51 - if (!end) 52 - return ERR_PTR(-EINVAL); 53 - } else { 54 - /* Unquoted arg */ 55 - for (end = start; *end && !isspace(*end); end++) ; 56 - } 57 - 58 - if (*end) 59 - *end++ = '\0'; 60 - 61 - *args = end; 62 - return start; 63 - } 64 - 65 40 static int aggr_add_gpio(struct gpio_aggregator *aggr, const char *key, 66 41 int hwnum, unsigned int *n) 67 42 { ··· 58 83 59 84 static int aggr_parse(struct gpio_aggregator *aggr) 60 85 { 86 + char *args = skip_spaces(aggr->args); 61 87 char *name, *offsets, *p; 62 - char *args = aggr->args; 63 88 unsigned long *bitmap; 64 89 unsigned int i, n = 0; 65 90 int error = 0; ··· 68 93 if (!bitmap) 69 94 return -ENOMEM; 70 95 71 - for (name = get_arg(&args), offsets = get_arg(&args); name; 72 - offsets = get_arg(&args)) { 73 - if (IS_ERR(name)) { 74 - pr_err("Cannot get GPIO specifier: %pe\n", name); 75 - error = PTR_ERR(name); 76 - goto free_bitmap; 77 - } 96 + args = next_arg(args, &name, &p); 97 + while (*args) { 98 + args = next_arg(args, &offsets, &p); 78 99 79 100 p = get_options(offsets, 0, &error); 80 101 if (error == 0 || *p) { ··· 96 125 goto free_bitmap; 97 126 } 98 127 99 - name = get_arg(&args); 128 + args = next_arg(args, &name, &p); 100 129 } 101 130 102 131 if (!n) {
-2
drivers/gpio/gpio-ich.c
··· 5 5 * Copyright (C) 2010 Extreme Engineering Solutions. 6 6 */ 7 7 8 - 9 8 #include <linux/bitops.h> 10 9 #include <linux/gpio/driver.h> 11 10 #include <linux/ioport.h> 12 11 #include <linux/mfd/lpc_ich.h> 13 12 #include <linux/module.h> 14 - #include <linux/pci.h> 15 13 #include <linux/platform_device.h> 16 14 17 15 #define DRV_NAME "gpio_ich"
-8
drivers/gpio/gpio-it87.c
··· 125 125 return val; 126 126 } 127 127 128 - static inline void superio_outw(int val, int reg) 129 - { 130 - outb(reg++, REG); 131 - outb(val >> 8, VAL); 132 - outb(reg, REG); 133 - outb(val, VAL); 134 - } 135 - 136 128 static inline void superio_set_mask(int mask, int reg) 137 129 { 138 130 u8 curr_val = superio_inb(reg);
+2 -7
drivers/gpio/gpio-mockup.c
··· 479 479 480 480 static void gpio_mockup_unregister_pdevs(void) 481 481 { 482 - struct platform_device *pdev; 483 482 int i; 484 483 485 - for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++) { 486 - pdev = gpio_mockup_pdevs[i]; 487 - 488 - if (pdev) 489 - platform_device_unregister(pdev); 490 - } 484 + for (i = 0; i < GPIO_MOCKUP_MAX_GC; i++) 485 + platform_device_unregister(gpio_mockup_pdevs[i]); 491 486 } 492 487 493 488 static __init char **gpio_mockup_make_line_names(const char *label,
+33 -14
drivers/gpio/gpio-mpc8xxx.c
··· 9 9 * kind, whether express or implied. 10 10 */ 11 11 12 + #include <linux/acpi.h> 12 13 #include <linux/kernel.h> 13 14 #include <linux/init.h> 14 15 #include <linux/spinlock.h> ··· 19 18 #include <linux/of_address.h> 20 19 #include <linux/of_irq.h> 21 20 #include <linux/of_platform.h> 21 + #include <linux/property.h> 22 + #include <linux/mod_devicetable.h> 22 23 #include <linux/slab.h> 23 24 #include <linux/irq.h> 24 25 #include <linux/gpio/driver.h> ··· 306 303 struct device_node *np = pdev->dev.of_node; 307 304 struct mpc8xxx_gpio_chip *mpc8xxx_gc; 308 305 struct gpio_chip *gc; 309 - const struct mpc8xxx_gpio_devtype *devtype = 310 - of_device_get_match_data(&pdev->dev); 306 + const struct mpc8xxx_gpio_devtype *devtype = NULL; 307 + struct fwnode_handle *fwnode; 311 308 int ret; 312 309 313 310 mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL); ··· 318 315 319 316 raw_spin_lock_init(&mpc8xxx_gc->lock); 320 317 321 - mpc8xxx_gc->regs = of_iomap(np, 0); 322 - if (!mpc8xxx_gc->regs) 323 - return -ENOMEM; 318 + mpc8xxx_gc->regs = devm_platform_ioremap_resource(pdev, 0); 319 + if (IS_ERR(mpc8xxx_gc->regs)) 320 + return PTR_ERR(mpc8xxx_gc->regs); 324 321 325 322 gc = &mpc8xxx_gc->gc; 326 323 gc->parent = &pdev->dev; 327 324 328 - if (of_property_read_bool(np, "little-endian")) { 325 + if (device_property_read_bool(&pdev->dev, "little-endian")) { 329 326 ret = bgpio_init(gc, &pdev->dev, 4, 330 327 mpc8xxx_gc->regs + GPIO_DAT, 331 328 NULL, NULL, ··· 348 345 349 346 mpc8xxx_gc->direction_output = gc->direction_output; 350 347 348 + devtype = device_get_match_data(&pdev->dev); 351 349 if (!devtype) 352 350 devtype = &mpc8xxx_gpio_devtype_default; 353 351 ··· 373 369 * associated input enable must be set (GPIOxGPIE[IEn]=1) to propagate 374 370 * the port value to the GPIO Data Register. 375 371 */ 372 + fwnode = dev_fwnode(&pdev->dev); 376 373 if (of_device_is_compatible(np, "fsl,qoriq-gpio") || 377 374 of_device_is_compatible(np, "fsl,ls1028a-gpio") || 378 - of_device_is_compatible(np, "fsl,ls1088a-gpio")) 375 + of_device_is_compatible(np, "fsl,ls1088a-gpio") || 376 + is_acpi_node(fwnode)) 379 377 gc->write_reg(mpc8xxx_gc->regs + GPIO_IBE, 0xffffffff); 380 378 381 379 ret = gpiochip_add_data(gc, mpc8xxx_gc); 382 380 if (ret) { 383 - pr_err("%pOF: GPIO chip registration failed with status %d\n", 384 - np, ret); 381 + dev_err(&pdev->dev, 382 + "GPIO chip registration failed with status %d\n", ret); 385 383 goto err; 386 384 } 387 385 388 - mpc8xxx_gc->irqn = irq_of_parse_and_map(np, 0); 386 + mpc8xxx_gc->irqn = platform_get_irq(pdev, 0); 389 387 if (!mpc8xxx_gc->irqn) 390 388 return 0; 391 389 392 - mpc8xxx_gc->irq = irq_domain_add_linear(np, MPC8XXX_GPIO_PINS, 393 - &mpc8xxx_gpio_irq_ops, mpc8xxx_gc); 390 + mpc8xxx_gc->irq = irq_domain_create_linear(fwnode, 391 + MPC8XXX_GPIO_PINS, 392 + &mpc8xxx_gpio_irq_ops, 393 + mpc8xxx_gc); 394 + 394 395 if (!mpc8xxx_gc->irq) 395 396 return 0; 396 397 ··· 408 399 IRQF_SHARED, "gpio-cascade", 409 400 mpc8xxx_gc); 410 401 if (ret) { 411 - dev_err(&pdev->dev, "%s: failed to devm_request_irq(%d), ret = %d\n", 412 - np->full_name, mpc8xxx_gc->irqn, ret); 402 + dev_err(&pdev->dev, 403 + "failed to devm_request_irq(%d), ret = %d\n", 404 + mpc8xxx_gc->irqn, ret); 413 405 goto err; 414 406 } 415 407 ··· 435 425 return 0; 436 426 } 437 427 428 + #ifdef CONFIG_ACPI 429 + static const struct acpi_device_id gpio_acpi_ids[] = { 430 + {"NXP0031",}, 431 + { } 432 + }; 433 + MODULE_DEVICE_TABLE(acpi, gpio_acpi_ids); 434 + #endif 435 + 438 436 static struct platform_driver mpc8xxx_plat_driver = { 439 437 .probe = mpc8xxx_probe, 440 438 .remove = mpc8xxx_remove, 441 439 .driver = { 442 440 .name = "gpio-mpc8xxx", 443 441 .of_match_table = mpc8xxx_gpio_ids, 442 + .acpi_match_table = ACPI_PTR(gpio_acpi_ids), 444 443 }, 445 444 }; 446 445
-5
drivers/gpio/gpio-mxs.c
··· 60 60 return port->devid == IMX23_GPIO; 61 61 } 62 62 63 - static inline int is_imx28_gpio(struct mxs_gpio_port *port) 64 - { 65 - return port->devid == IMX28_GPIO; 66 - } 67 - 68 63 /* Note: This driver assumes 32 GPIOs are handled in one register */ 69 64 70 65 static int mxs_gpio_set_irq_type(struct irq_data *d, unsigned int type)
+2 -3
drivers/gpio/gpio-omap.c
··· 1373 1373 { 1374 1374 struct device *dev = &pdev->dev; 1375 1375 struct device_node *node = dev->of_node; 1376 - const struct of_device_id *match; 1377 1376 const struct omap_gpio_platform_data *pdata; 1378 1377 struct gpio_bank *bank; 1379 1378 struct irq_chip *irqc; 1380 1379 int ret; 1381 1380 1382 - match = of_match_device(of_match_ptr(omap_gpio_match), dev); 1381 + pdata = device_get_match_data(dev); 1383 1382 1384 - pdata = match ? match->data : dev_get_platdata(dev); 1383 + pdata = pdata ?: dev_get_platdata(dev); 1385 1384 if (!pdata) 1386 1385 return -EINVAL; 1387 1386
+325
drivers/gpio/gpio-realtek-otto.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + 3 + #include <linux/gpio/driver.h> 4 + #include <linux/irq.h> 5 + #include <linux/minmax.h> 6 + #include <linux/mod_devicetable.h> 7 + #include <linux/module.h> 8 + #include <linux/platform_device.h> 9 + #include <linux/property.h> 10 + 11 + /* 12 + * Total register block size is 0x1C for one bank of four ports (A, B, C, D). 13 + * An optional second bank, with ports E, F, G, and H, may be present, starting 14 + * at register offset 0x1C. 15 + */ 16 + 17 + /* 18 + * Pin select: (0) "normal", (1) "dedicate peripheral" 19 + * Not used on RTL8380/RTL8390, peripheral selection is managed by control bits 20 + * in the peripheral registers. 21 + */ 22 + #define REALTEK_GPIO_REG_CNR 0x00 23 + /* Clear bit (0) for input, set bit (1) for output */ 24 + #define REALTEK_GPIO_REG_DIR 0x08 25 + #define REALTEK_GPIO_REG_DATA 0x0C 26 + /* Read bit for IRQ status, write 1 to clear IRQ */ 27 + #define REALTEK_GPIO_REG_ISR 0x10 28 + /* Two bits per GPIO in IMR registers */ 29 + #define REALTEK_GPIO_REG_IMR 0x14 30 + #define REALTEK_GPIO_REG_IMR_AB 0x14 31 + #define REALTEK_GPIO_REG_IMR_CD 0x18 32 + #define REALTEK_GPIO_IMR_LINE_MASK GENMASK(1, 0) 33 + #define REALTEK_GPIO_IRQ_EDGE_FALLING 1 34 + #define REALTEK_GPIO_IRQ_EDGE_RISING 2 35 + #define REALTEK_GPIO_IRQ_EDGE_BOTH 3 36 + 37 + #define REALTEK_GPIO_MAX 32 38 + #define REALTEK_GPIO_PORTS_PER_BANK 4 39 + 40 + /** 41 + * realtek_gpio_ctrl - Realtek Otto GPIO driver data 42 + * 43 + * @gc: Associated gpio_chip instance 44 + * @base: Base address of the register block for a GPIO bank 45 + * @lock: Lock for accessing the IRQ registers and values 46 + * @intr_mask: Mask for interrupts lines 47 + * @intr_type: Interrupt type selection 48 + * 49 + * Because the interrupt mask register (IMR) combines the function of IRQ type 50 + * selection and masking, two extra values are stored. @intr_mask is used to 51 + * mask/unmask the interrupts for a GPIO port, and @intr_type is used to store 52 + * the selected interrupt types. The logical AND of these values is written to 53 + * IMR on changes. 54 + */ 55 + struct realtek_gpio_ctrl { 56 + struct gpio_chip gc; 57 + void __iomem *base; 58 + raw_spinlock_t lock; 59 + u16 intr_mask[REALTEK_GPIO_PORTS_PER_BANK]; 60 + u16 intr_type[REALTEK_GPIO_PORTS_PER_BANK]; 61 + }; 62 + 63 + /* Expand with more flags as devices with other quirks are added */ 64 + enum realtek_gpio_flags { 65 + /* 66 + * Allow disabling interrupts, for cases where the port order is 67 + * unknown. This may result in a port mismatch between ISR and IMR. 68 + * An interrupt would appear to come from a different line than the 69 + * line the IRQ handler was assigned to, causing uncaught interrupts. 70 + */ 71 + GPIO_INTERRUPTS_DISABLED = BIT(0), 72 + }; 73 + 74 + static struct realtek_gpio_ctrl *irq_data_to_ctrl(struct irq_data *data) 75 + { 76 + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); 77 + 78 + return container_of(gc, struct realtek_gpio_ctrl, gc); 79 + } 80 + 81 + /* 82 + * Normal port order register access 83 + * 84 + * Port information is stored with the first port at offset 0, followed by the 85 + * second, etc. Most registers store one bit per GPIO and use a u8 value per 86 + * port. The two interrupt mask registers store two bits per GPIO, so use u16 87 + * values. 88 + */ 89 + static void realtek_gpio_write_imr(struct realtek_gpio_ctrl *ctrl, 90 + unsigned int port, u16 irq_type, u16 irq_mask) 91 + { 92 + iowrite16(irq_type & irq_mask, ctrl->base + REALTEK_GPIO_REG_IMR + 2 * port); 93 + } 94 + 95 + static void realtek_gpio_clear_isr(struct realtek_gpio_ctrl *ctrl, 96 + unsigned int port, u8 mask) 97 + { 98 + iowrite8(mask, ctrl->base + REALTEK_GPIO_REG_ISR + port); 99 + } 100 + 101 + static u8 realtek_gpio_read_isr(struct realtek_gpio_ctrl *ctrl, unsigned int port) 102 + { 103 + return ioread8(ctrl->base + REALTEK_GPIO_REG_ISR + port); 104 + } 105 + 106 + /* Set the rising and falling edge mask bits for a GPIO port pin */ 107 + static u16 realtek_gpio_imr_bits(unsigned int pin, u16 value) 108 + { 109 + return (value & REALTEK_GPIO_IMR_LINE_MASK) << 2 * pin; 110 + } 111 + 112 + static void realtek_gpio_irq_ack(struct irq_data *data) 113 + { 114 + struct realtek_gpio_ctrl *ctrl = irq_data_to_ctrl(data); 115 + irq_hw_number_t line = irqd_to_hwirq(data); 116 + unsigned int port = line / 8; 117 + unsigned int port_pin = line % 8; 118 + 119 + realtek_gpio_clear_isr(ctrl, port, BIT(port_pin)); 120 + } 121 + 122 + static void realtek_gpio_irq_unmask(struct irq_data *data) 123 + { 124 + struct realtek_gpio_ctrl *ctrl = irq_data_to_ctrl(data); 125 + unsigned int line = irqd_to_hwirq(data); 126 + unsigned int port = line / 8; 127 + unsigned int port_pin = line % 8; 128 + unsigned long flags; 129 + u16 m; 130 + 131 + raw_spin_lock_irqsave(&ctrl->lock, flags); 132 + m = ctrl->intr_mask[port]; 133 + m |= realtek_gpio_imr_bits(port_pin, REALTEK_GPIO_IMR_LINE_MASK); 134 + ctrl->intr_mask[port] = m; 135 + realtek_gpio_write_imr(ctrl, port, ctrl->intr_type[port], m); 136 + raw_spin_unlock_irqrestore(&ctrl->lock, flags); 137 + } 138 + 139 + static void realtek_gpio_irq_mask(struct irq_data *data) 140 + { 141 + struct realtek_gpio_ctrl *ctrl = irq_data_to_ctrl(data); 142 + unsigned int line = irqd_to_hwirq(data); 143 + unsigned int port = line / 8; 144 + unsigned int port_pin = line % 8; 145 + unsigned long flags; 146 + u16 m; 147 + 148 + raw_spin_lock_irqsave(&ctrl->lock, flags); 149 + m = ctrl->intr_mask[port]; 150 + m &= ~realtek_gpio_imr_bits(port_pin, REALTEK_GPIO_IMR_LINE_MASK); 151 + ctrl->intr_mask[port] = m; 152 + realtek_gpio_write_imr(ctrl, port, ctrl->intr_type[port], m); 153 + raw_spin_unlock_irqrestore(&ctrl->lock, flags); 154 + } 155 + 156 + static int realtek_gpio_irq_set_type(struct irq_data *data, unsigned int flow_type) 157 + { 158 + struct realtek_gpio_ctrl *ctrl = irq_data_to_ctrl(data); 159 + unsigned int line = irqd_to_hwirq(data); 160 + unsigned int port = line / 8; 161 + unsigned int port_pin = line % 8; 162 + unsigned long flags; 163 + u16 type, t; 164 + 165 + switch (flow_type & IRQ_TYPE_SENSE_MASK) { 166 + case IRQ_TYPE_EDGE_FALLING: 167 + type = REALTEK_GPIO_IRQ_EDGE_FALLING; 168 + break; 169 + case IRQ_TYPE_EDGE_RISING: 170 + type = REALTEK_GPIO_IRQ_EDGE_RISING; 171 + break; 172 + case IRQ_TYPE_EDGE_BOTH: 173 + type = REALTEK_GPIO_IRQ_EDGE_BOTH; 174 + break; 175 + default: 176 + return -EINVAL; 177 + } 178 + 179 + irq_set_handler_locked(data, handle_edge_irq); 180 + 181 + raw_spin_lock_irqsave(&ctrl->lock, flags); 182 + t = ctrl->intr_type[port]; 183 + t &= ~realtek_gpio_imr_bits(port_pin, REALTEK_GPIO_IMR_LINE_MASK); 184 + t |= realtek_gpio_imr_bits(port_pin, type); 185 + ctrl->intr_type[port] = t; 186 + realtek_gpio_write_imr(ctrl, port, t, ctrl->intr_mask[port]); 187 + raw_spin_unlock_irqrestore(&ctrl->lock, flags); 188 + 189 + return 0; 190 + } 191 + 192 + static void realtek_gpio_irq_handler(struct irq_desc *desc) 193 + { 194 + struct gpio_chip *gc = irq_desc_get_handler_data(desc); 195 + struct realtek_gpio_ctrl *ctrl = gpiochip_get_data(gc); 196 + struct irq_chip *irq_chip = irq_desc_get_chip(desc); 197 + unsigned int lines_done; 198 + unsigned int port_pin_count; 199 + unsigned int irq; 200 + unsigned long status; 201 + int offset; 202 + 203 + chained_irq_enter(irq_chip, desc); 204 + 205 + for (lines_done = 0; lines_done < gc->ngpio; lines_done += 8) { 206 + status = realtek_gpio_read_isr(ctrl, lines_done / 8); 207 + port_pin_count = min(gc->ngpio - lines_done, 8U); 208 + for_each_set_bit(offset, &status, port_pin_count) { 209 + irq = irq_find_mapping(gc->irq.domain, offset); 210 + generic_handle_irq(irq); 211 + } 212 + } 213 + 214 + chained_irq_exit(irq_chip, desc); 215 + } 216 + 217 + static int realtek_gpio_irq_init(struct gpio_chip *gc) 218 + { 219 + struct realtek_gpio_ctrl *ctrl = gpiochip_get_data(gc); 220 + unsigned int port; 221 + 222 + for (port = 0; (port * 8) < gc->ngpio; port++) { 223 + realtek_gpio_write_imr(ctrl, port, 0, 0); 224 + realtek_gpio_clear_isr(ctrl, port, GENMASK(7, 0)); 225 + } 226 + 227 + return 0; 228 + } 229 + 230 + static struct irq_chip realtek_gpio_irq_chip = { 231 + .name = "realtek-otto-gpio", 232 + .irq_ack = realtek_gpio_irq_ack, 233 + .irq_mask = realtek_gpio_irq_mask, 234 + .irq_unmask = realtek_gpio_irq_unmask, 235 + .irq_set_type = realtek_gpio_irq_set_type, 236 + }; 237 + 238 + static const struct of_device_id realtek_gpio_of_match[] = { 239 + { 240 + .compatible = "realtek,otto-gpio", 241 + .data = (void *)GPIO_INTERRUPTS_DISABLED, 242 + }, 243 + { 244 + .compatible = "realtek,rtl8380-gpio", 245 + }, 246 + { 247 + .compatible = "realtek,rtl8390-gpio", 248 + }, 249 + {} 250 + }; 251 + MODULE_DEVICE_TABLE(of, realtek_gpio_of_match); 252 + 253 + static int realtek_gpio_probe(struct platform_device *pdev) 254 + { 255 + struct device *dev = &pdev->dev; 256 + unsigned int dev_flags; 257 + struct gpio_irq_chip *girq; 258 + struct realtek_gpio_ctrl *ctrl; 259 + u32 ngpios; 260 + int err, irq; 261 + 262 + ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL); 263 + if (!ctrl) 264 + return -ENOMEM; 265 + 266 + dev_flags = (unsigned int) device_get_match_data(dev); 267 + 268 + ngpios = REALTEK_GPIO_MAX; 269 + device_property_read_u32(dev, "ngpios", &ngpios); 270 + 271 + if (ngpios > REALTEK_GPIO_MAX) { 272 + dev_err(&pdev->dev, "invalid ngpios (max. %d)\n", 273 + REALTEK_GPIO_MAX); 274 + return -EINVAL; 275 + } 276 + 277 + ctrl->base = devm_platform_ioremap_resource(pdev, 0); 278 + if (IS_ERR(ctrl->base)) 279 + return PTR_ERR(ctrl->base); 280 + 281 + raw_spin_lock_init(&ctrl->lock); 282 + 283 + err = bgpio_init(&ctrl->gc, dev, 4, 284 + ctrl->base + REALTEK_GPIO_REG_DATA, NULL, NULL, 285 + ctrl->base + REALTEK_GPIO_REG_DIR, NULL, 286 + BGPIOF_BIG_ENDIAN_BYTE_ORDER); 287 + if (err) { 288 + dev_err(dev, "unable to init generic GPIO"); 289 + return err; 290 + } 291 + 292 + ctrl->gc.ngpio = ngpios; 293 + ctrl->gc.owner = THIS_MODULE; 294 + 295 + irq = platform_get_irq_optional(pdev, 0); 296 + if (!(dev_flags & GPIO_INTERRUPTS_DISABLED) && irq > 0) { 297 + girq = &ctrl->gc.irq; 298 + girq->chip = &realtek_gpio_irq_chip; 299 + girq->default_type = IRQ_TYPE_NONE; 300 + girq->handler = handle_bad_irq; 301 + girq->parent_handler = realtek_gpio_irq_handler; 302 + girq->num_parents = 1; 303 + girq->parents = devm_kcalloc(dev, girq->num_parents, 304 + sizeof(*girq->parents), GFP_KERNEL); 305 + if (!girq->parents) 306 + return -ENOMEM; 307 + girq->parents[0] = irq; 308 + girq->init_hw = realtek_gpio_irq_init; 309 + } 310 + 311 + return devm_gpiochip_add_data(dev, &ctrl->gc, ctrl); 312 + } 313 + 314 + static struct platform_driver realtek_gpio_driver = { 315 + .driver = { 316 + .name = "realtek-otto-gpio", 317 + .of_match_table = realtek_gpio_of_match, 318 + }, 319 + .probe = realtek_gpio_probe, 320 + }; 321 + module_platform_driver(realtek_gpio_driver); 322 + 323 + MODULE_DESCRIPTION("Realtek Otto GPIO support"); 324 + MODULE_AUTHOR("Sander Vanheule <sander@svanheule.net>"); 325 + MODULE_LICENSE("GPL v2");
+190 -8
drivers/gpio/gpio-sch.c
··· 7 7 */ 8 8 9 9 #include <linux/acpi.h> 10 + #include <linux/bitops.h> 10 11 #include <linux/errno.h> 11 12 #include <linux/gpio/driver.h> 12 13 #include <linux/io.h> 14 + #include <linux/irq.h> 13 15 #include <linux/kernel.h> 14 16 #include <linux/module.h> 15 17 #include <linux/pci_ids.h> 16 18 #include <linux/platform_device.h> 19 + #include <linux/types.h> 17 20 18 21 #define GEN 0x00 19 22 #define GIO 0x04 20 23 #define GLV 0x08 24 + #define GTPE 0x0c 25 + #define GTNE 0x10 26 + #define GGPE 0x14 27 + #define GSMI 0x18 28 + #define GTS 0x1c 29 + 30 + #define CORE_BANK_OFFSET 0x00 31 + #define RESUME_BANK_OFFSET 0x20 32 + 33 + /* 34 + * iLB datasheet describes GPE0BLK registers, in particular GPE0E.GPIO bit. 35 + * Document Number: 328195-001 36 + */ 37 + #define GPE0E_GPIO 14 21 38 22 39 struct sch_gpio { 23 40 struct gpio_chip chip; 41 + struct irq_chip irqchip; 24 42 spinlock_t lock; 25 43 unsigned short iobase; 26 44 unsigned short resume_base; 45 + 46 + /* GPE handling */ 47 + u32 gpe; 48 + acpi_gpe_handler gpe_handler; 27 49 }; 28 50 29 51 static unsigned int sch_gpio_offset(struct sch_gpio *sch, unsigned int gpio, 30 52 unsigned int reg) 31 53 { 32 - unsigned int base = 0; 54 + unsigned int base = CORE_BANK_OFFSET; 33 55 34 56 if (gpio >= sch->resume_base) { 35 57 gpio -= sch->resume_base; 36 - base += 0x20; 58 + base = RESUME_BANK_OFFSET; 37 59 } 38 60 39 61 return base + reg + gpio / 8; ··· 101 79 static int sch_gpio_direction_in(struct gpio_chip *gc, unsigned int gpio_num) 102 80 { 103 81 struct sch_gpio *sch = gpiochip_get_data(gc); 82 + unsigned long flags; 104 83 105 - spin_lock(&sch->lock); 84 + spin_lock_irqsave(&sch->lock, flags); 106 85 sch_gpio_reg_set(sch, gpio_num, GIO, 1); 107 - spin_unlock(&sch->lock); 86 + spin_unlock_irqrestore(&sch->lock, flags); 108 87 return 0; 109 88 } 110 89 ··· 119 96 static void sch_gpio_set(struct gpio_chip *gc, unsigned int gpio_num, int val) 120 97 { 121 98 struct sch_gpio *sch = gpiochip_get_data(gc); 99 + unsigned long flags; 122 100 123 - spin_lock(&sch->lock); 101 + spin_lock_irqsave(&sch->lock, flags); 124 102 sch_gpio_reg_set(sch, gpio_num, GLV, val); 125 - spin_unlock(&sch->lock); 103 + spin_unlock_irqrestore(&sch->lock, flags); 126 104 } 127 105 128 106 static int sch_gpio_direction_out(struct gpio_chip *gc, unsigned int gpio_num, 129 107 int val) 130 108 { 131 109 struct sch_gpio *sch = gpiochip_get_data(gc); 110 + unsigned long flags; 132 111 133 - spin_lock(&sch->lock); 112 + spin_lock_irqsave(&sch->lock, flags); 134 113 sch_gpio_reg_set(sch, gpio_num, GIO, 0); 135 - spin_unlock(&sch->lock); 114 + spin_unlock_irqrestore(&sch->lock, flags); 136 115 137 116 /* 138 117 * according to the datasheet, writing to the level register has no ··· 169 144 .get_direction = sch_gpio_get_direction, 170 145 }; 171 146 147 + static int sch_irq_type(struct irq_data *d, unsigned int type) 148 + { 149 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 150 + struct sch_gpio *sch = gpiochip_get_data(gc); 151 + irq_hw_number_t gpio_num = irqd_to_hwirq(d); 152 + unsigned long flags; 153 + int rising, falling; 154 + 155 + switch (type & IRQ_TYPE_SENSE_MASK) { 156 + case IRQ_TYPE_EDGE_RISING: 157 + rising = 1; 158 + falling = 0; 159 + break; 160 + case IRQ_TYPE_EDGE_FALLING: 161 + rising = 0; 162 + falling = 1; 163 + break; 164 + case IRQ_TYPE_EDGE_BOTH: 165 + rising = 1; 166 + falling = 1; 167 + break; 168 + default: 169 + return -EINVAL; 170 + } 171 + 172 + spin_lock_irqsave(&sch->lock, flags); 173 + 174 + sch_gpio_reg_set(sch, gpio_num, GTPE, rising); 175 + sch_gpio_reg_set(sch, gpio_num, GTNE, falling); 176 + 177 + irq_set_handler_locked(d, handle_edge_irq); 178 + 179 + spin_unlock_irqrestore(&sch->lock, flags); 180 + 181 + return 0; 182 + } 183 + 184 + static void sch_irq_ack(struct irq_data *d) 185 + { 186 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 187 + struct sch_gpio *sch = gpiochip_get_data(gc); 188 + irq_hw_number_t gpio_num = irqd_to_hwirq(d); 189 + unsigned long flags; 190 + 191 + spin_lock_irqsave(&sch->lock, flags); 192 + sch_gpio_reg_set(sch, gpio_num, GTS, 1); 193 + spin_unlock_irqrestore(&sch->lock, flags); 194 + } 195 + 196 + static void sch_irq_mask_unmask(struct irq_data *d, int val) 197 + { 198 + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 199 + struct sch_gpio *sch = gpiochip_get_data(gc); 200 + irq_hw_number_t gpio_num = irqd_to_hwirq(d); 201 + unsigned long flags; 202 + 203 + spin_lock_irqsave(&sch->lock, flags); 204 + sch_gpio_reg_set(sch, gpio_num, GGPE, val); 205 + spin_unlock_irqrestore(&sch->lock, flags); 206 + } 207 + 208 + static void sch_irq_mask(struct irq_data *d) 209 + { 210 + sch_irq_mask_unmask(d, 0); 211 + } 212 + 213 + static void sch_irq_unmask(struct irq_data *d) 214 + { 215 + sch_irq_mask_unmask(d, 1); 216 + } 217 + 218 + static u32 sch_gpio_gpe_handler(acpi_handle gpe_device, u32 gpe, void *context) 219 + { 220 + struct sch_gpio *sch = context; 221 + struct gpio_chip *gc = &sch->chip; 222 + unsigned long core_status, resume_status; 223 + unsigned long pending; 224 + unsigned long flags; 225 + int offset; 226 + u32 ret; 227 + 228 + spin_lock_irqsave(&sch->lock, flags); 229 + 230 + core_status = inl(sch->iobase + CORE_BANK_OFFSET + GTS); 231 + resume_status = inl(sch->iobase + RESUME_BANK_OFFSET + GTS); 232 + 233 + spin_unlock_irqrestore(&sch->lock, flags); 234 + 235 + pending = (resume_status << sch->resume_base) | core_status; 236 + for_each_set_bit(offset, &pending, sch->chip.ngpio) 237 + generic_handle_irq(irq_find_mapping(gc->irq.domain, offset)); 238 + 239 + /* Set returning value depending on whether we handled an interrupt */ 240 + ret = pending ? ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 241 + 242 + /* Acknowledge GPE to ACPICA */ 243 + ret |= ACPI_REENABLE_GPE; 244 + 245 + return ret; 246 + } 247 + 248 + static void sch_gpio_remove_gpe_handler(void *data) 249 + { 250 + struct sch_gpio *sch = data; 251 + 252 + acpi_disable_gpe(NULL, sch->gpe); 253 + acpi_remove_gpe_handler(NULL, sch->gpe, sch->gpe_handler); 254 + } 255 + 256 + static int sch_gpio_install_gpe_handler(struct sch_gpio *sch) 257 + { 258 + struct device *dev = sch->chip.parent; 259 + acpi_status status; 260 + 261 + status = acpi_install_gpe_handler(NULL, sch->gpe, ACPI_GPE_LEVEL_TRIGGERED, 262 + sch->gpe_handler, sch); 263 + if (ACPI_FAILURE(status)) { 264 + dev_err(dev, "Failed to install GPE handler for %u: %s\n", 265 + sch->gpe, acpi_format_exception(status)); 266 + return -ENODEV; 267 + } 268 + 269 + status = acpi_enable_gpe(NULL, sch->gpe); 270 + if (ACPI_FAILURE(status)) { 271 + dev_err(dev, "Failed to enable GPE handler for %u: %s\n", 272 + sch->gpe, acpi_format_exception(status)); 273 + acpi_remove_gpe_handler(NULL, sch->gpe, sch->gpe_handler); 274 + return -ENODEV; 275 + } 276 + 277 + return devm_add_action_or_reset(dev, sch_gpio_remove_gpe_handler, sch); 278 + } 279 + 172 280 static int sch_gpio_probe(struct platform_device *pdev) 173 281 { 282 + struct gpio_irq_chip *girq; 174 283 struct sch_gpio *sch; 175 284 struct resource *res; 285 + int ret; 176 286 177 287 sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL); 178 288 if (!sch) ··· 366 206 } 367 207 368 208 platform_set_drvdata(pdev, sch); 209 + 210 + sch->irqchip.name = "sch_gpio"; 211 + sch->irqchip.irq_ack = sch_irq_ack; 212 + sch->irqchip.irq_mask = sch_irq_mask; 213 + sch->irqchip.irq_unmask = sch_irq_unmask; 214 + sch->irqchip.irq_set_type = sch_irq_type; 215 + 216 + girq = &sch->chip.irq; 217 + girq->chip = &sch->irqchip; 218 + girq->num_parents = 0; 219 + girq->parents = NULL; 220 + girq->parent_handler = NULL; 221 + girq->default_type = IRQ_TYPE_NONE; 222 + girq->handler = handle_bad_irq; 223 + 224 + /* GPE setup is optional */ 225 + sch->gpe = GPE0E_GPIO; 226 + sch->gpe_handler = sch_gpio_gpe_handler; 227 + 228 + ret = sch_gpio_install_gpe_handler(sch); 229 + if (ret) 230 + dev_warn(&pdev->dev, "Can't setup GPE, no IRQ support\n"); 369 231 370 232 return devm_gpiochip_add_data(&pdev->dev, &sch->chip, sch); 371 233 }
+21
drivers/gpio/gpiolib-acpi.c
··· 1291 1291 kfree(acpi_gpio); 1292 1292 } 1293 1293 1294 + void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) 1295 + { 1296 + /* Set default fwnode to parent's one if present */ 1297 + if (gc->parent) 1298 + ACPI_COMPANION_SET(&gdev->dev, ACPI_COMPANION(gc->parent)); 1299 + } 1300 + 1294 1301 static int acpi_gpio_package_count(const union acpi_object *obj) 1295 1302 { 1296 1303 const union acpi_object *element = obj->package.elements; ··· 1443 1436 }, 1444 1437 .driver_data = &(struct acpi_gpiolib_dmi_quirk) { 1445 1438 .no_edge_events_on_boot = true, 1439 + }, 1440 + }, 1441 + { 1442 + /* 1443 + * The Dell Venue 10 Pro 5055, with Bay Trail SoC + TI PMIC uses an 1444 + * external embedded-controller connected via I2C + an ACPI GPIO 1445 + * event handler on INT33FFC:02 pin 12, causing spurious wakeups. 1446 + */ 1447 + .matches = { 1448 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 1449 + DMI_MATCH(DMI_PRODUCT_NAME, "Venue 10 Pro 5055"), 1450 + }, 1451 + .driver_data = &(struct acpi_gpiolib_dmi_quirk) { 1452 + .ignore_wake = "INT33FC:02@12", 1446 1453 }, 1447 1454 }, 1448 1455 {
+4
drivers/gpio/gpiolib-acpi.h
··· 36 36 void acpi_gpiochip_add(struct gpio_chip *chip); 37 37 void acpi_gpiochip_remove(struct gpio_chip *chip); 38 38 39 + void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev); 40 + 39 41 void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); 40 42 void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); 41 43 ··· 59 57 #else 60 58 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } 61 59 static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { } 60 + 61 + static inline void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) { } 62 62 63 63 static inline void 64 64 acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
+4 -2
drivers/gpio/gpiolib-of.c
··· 1042 1042 1043 1043 void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) 1044 1044 { 1045 + /* Set default OF node to parent's one if present */ 1046 + if (gc->parent) 1047 + gdev->dev.of_node = gc->parent->of_node; 1048 + 1045 1049 /* If the gpiochip has an assigned OF node this takes precedence */ 1046 1050 if (gc->of_node) 1047 1051 gdev->dev.of_node = gc->of_node; 1048 1052 else 1049 1053 gc->of_node = gdev->dev.of_node; 1050 - if (gdev->dev.of_node) 1051 - gdev->dev.fwnode = of_fwnode_handle(gdev->dev.of_node); 1052 1054 }
+24 -38
drivers/gpio/gpiolib.c
··· 586 586 if (!gdev) 587 587 return -ENOMEM; 588 588 gdev->dev.bus = &gpio_bus_type; 589 + gdev->dev.parent = gc->parent; 589 590 gdev->chip = gc; 590 591 gc->gpiodev = gdev; 591 - if (gc->parent) { 592 - gdev->dev.parent = gc->parent; 593 - gdev->dev.of_node = gc->parent->of_node; 594 - } 595 592 596 593 of_gpio_dev_init(gc, gdev); 594 + acpi_gpio_dev_init(gc, gdev); 597 595 598 596 /* 599 597 * Assign fwnode depending on the result of the previous calls, ··· 1463 1465 struct lock_class_key *lock_key, 1464 1466 struct lock_class_key *request_key) 1465 1467 { 1468 + struct fwnode_handle *fwnode = dev_fwnode(&gc->gpiodev->dev); 1466 1469 struct irq_chip *irqchip = gc->irq.chip; 1467 - const struct irq_domain_ops *ops = NULL; 1468 - struct device_node *np; 1469 1470 unsigned int type; 1470 1471 unsigned int i; 1471 1472 ··· 1476 1479 return -EINVAL; 1477 1480 } 1478 1481 1479 - np = gc->gpiodev->dev.of_node; 1480 1482 type = gc->irq.default_type; 1481 1483 1482 1484 /* ··· 1483 1487 * used to configure the interrupts, as you may end up with 1484 1488 * conflicting triggers. Tell the user, and reset to NONE. 1485 1489 */ 1486 - if (WARN(np && type != IRQ_TYPE_NONE, 1487 - "%s: Ignoring %u default trigger\n", np->full_name, type)) 1490 + if (WARN(fwnode && type != IRQ_TYPE_NONE, 1491 + "%pfw: Ignoring %u default trigger\n", fwnode, type)) 1488 1492 type = IRQ_TYPE_NONE; 1489 - 1490 - if (has_acpi_companion(gc->parent) && type != IRQ_TYPE_NONE) { 1491 - acpi_handle_warn(ACPI_HANDLE(gc->parent), 1492 - "Ignoring %u default trigger\n", type); 1493 - type = IRQ_TYPE_NONE; 1494 - } 1495 1493 1496 1494 if (gc->to_irq) 1497 1495 chip_warn(gc, "to_irq is redefined in %s and you shouldn't rely on it\n", __func__); ··· 1502 1512 return ret; 1503 1513 } else { 1504 1514 /* Some drivers provide custom irqdomain ops */ 1505 - if (gc->irq.domain_ops) 1506 - ops = gc->irq.domain_ops; 1507 - 1508 - if (!ops) 1509 - ops = &gpiochip_domain_ops; 1510 - gc->irq.domain = irq_domain_add_simple(np, 1515 + gc->irq.domain = irq_domain_create_simple(fwnode, 1511 1516 gc->ngpio, 1512 1517 gc->irq.first, 1513 - ops, gc); 1518 + gc->irq.domain_ops ?: &gpiochip_domain_ops, 1519 + gc); 1514 1520 if (!gc->irq.domain) 1515 1521 return -EINVAL; 1516 1522 } ··· 3670 3684 */ 3671 3685 int gpiod_count(struct device *dev, const char *con_id) 3672 3686 { 3687 + const struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL; 3673 3688 int count = -ENOENT; 3674 3689 3675 - if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) 3690 + if (is_of_node(fwnode)) 3676 3691 count = of_gpio_get_count(dev, con_id); 3677 - else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) 3692 + else if (is_acpi_node(fwnode)) 3678 3693 count = acpi_gpio_count(dev, con_id); 3679 3694 3680 3695 if (count < 0) ··· 3813 3826 int ret; 3814 3827 /* Maybe we have a device name, maybe not */ 3815 3828 const char *devname = dev ? dev_name(dev) : "?"; 3829 + const struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL; 3816 3830 3817 3831 dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id); 3818 3832 3819 - if (dev) { 3820 - /* Using device tree? */ 3821 - if (IS_ENABLED(CONFIG_OF) && dev->of_node) { 3822 - dev_dbg(dev, "using device tree for GPIO lookup\n"); 3823 - desc = of_find_gpio(dev, con_id, idx, &lookupflags); 3824 - } else if (ACPI_COMPANION(dev)) { 3825 - dev_dbg(dev, "using ACPI for GPIO lookup\n"); 3826 - desc = acpi_find_gpio(dev, con_id, idx, &flags, &lookupflags); 3827 - } 3833 + /* Using device tree? */ 3834 + if (is_of_node(fwnode)) { 3835 + dev_dbg(dev, "using device tree for GPIO lookup\n"); 3836 + desc = of_find_gpio(dev, con_id, idx, &lookupflags); 3837 + } else if (is_acpi_node(fwnode)) { 3838 + dev_dbg(dev, "using ACPI for GPIO lookup\n"); 3839 + desc = acpi_find_gpio(dev, con_id, idx, &flags, &lookupflags); 3828 3840 } 3829 3841 3830 3842 /* ··· 3907 3921 struct gpio_desc *desc = ERR_PTR(-ENODEV); 3908 3922 int ret; 3909 3923 3910 - if (!fwnode) 3911 - return ERR_PTR(-EINVAL); 3912 - 3913 3924 if (is_of_node(fwnode)) { 3914 3925 desc = gpiod_get_from_of_node(to_of_node(fwnode), 3915 3926 propname, index, ··· 3922 3939 3923 3940 acpi_gpio_update_gpiod_flags(&dflags, &info); 3924 3941 acpi_gpio_update_gpiod_lookup_flags(&lflags, &info); 3925 - } 3942 + } else 3943 + return ERR_PTR(-EINVAL); 3926 3944 3927 3945 /* Currently only ACPI takes this path */ 3928 3946 ret = gpiod_request(desc, label); ··· 4204 4220 4205 4221 static int gpio_bus_match(struct device *dev, struct device_driver *drv) 4206 4222 { 4223 + struct fwnode_handle *fwnode = dev_fwnode(dev); 4224 + 4207 4225 /* 4208 4226 * Only match if the fwnode doesn't already have a proper struct device 4209 4227 * created for it. 4210 4228 */ 4211 - if (dev->fwnode && dev->fwnode->dev != dev) 4229 + if (fwnode && fwnode->dev != dev) 4212 4230 return 0; 4213 4231 return 1; 4214 4232 }
+66 -59
include/linux/bitmap.h
··· 4 4 5 5 #ifndef __ASSEMBLY__ 6 6 7 - #include <linux/types.h> 8 7 #include <linux/bitops.h> 9 - #include <linux/string.h> 10 8 #include <linux/kernel.h> 9 + #include <linux/string.h> 10 + #include <linux/types.h> 11 + 12 + struct device; 11 13 12 14 /* 13 15 * bitmaps provide bit arrays that consume one or more unsigned ··· 120 118 * Allocation and deallocation of bitmap. 121 119 * Provided in lib/bitmap.c to avoid circular dependency. 122 120 */ 123 - extern unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags); 124 - extern unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags); 125 - extern void bitmap_free(const unsigned long *bitmap); 121 + unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags); 122 + unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags); 123 + void bitmap_free(const unsigned long *bitmap); 124 + 125 + /* Managed variants of the above. */ 126 + unsigned long *devm_bitmap_alloc(struct device *dev, 127 + unsigned int nbits, gfp_t flags); 128 + unsigned long *devm_bitmap_zalloc(struct device *dev, 129 + unsigned int nbits, gfp_t flags); 126 130 127 131 /* 128 132 * lib/bitmap.c provides these functions: 129 133 */ 130 134 131 - extern int __bitmap_equal(const unsigned long *bitmap1, 132 - const unsigned long *bitmap2, unsigned int nbits); 133 - extern bool __pure __bitmap_or_equal(const unsigned long *src1, 134 - const unsigned long *src2, 135 - const unsigned long *src3, 136 - unsigned int nbits); 137 - extern void __bitmap_complement(unsigned long *dst, const unsigned long *src, 138 - unsigned int nbits); 139 - extern void __bitmap_shift_right(unsigned long *dst, const unsigned long *src, 140 - unsigned int shift, unsigned int nbits); 141 - extern void __bitmap_shift_left(unsigned long *dst, const unsigned long *src, 142 - unsigned int shift, unsigned int nbits); 143 - extern void bitmap_cut(unsigned long *dst, const unsigned long *src, 144 - unsigned int first, unsigned int cut, 145 - unsigned int nbits); 146 - extern int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 135 + int __bitmap_equal(const unsigned long *bitmap1, 136 + const unsigned long *bitmap2, unsigned int nbits); 137 + bool __pure __bitmap_or_equal(const unsigned long *src1, 138 + const unsigned long *src2, 139 + const unsigned long *src3, 140 + unsigned int nbits); 141 + void __bitmap_complement(unsigned long *dst, const unsigned long *src, 142 + unsigned int nbits); 143 + void __bitmap_shift_right(unsigned long *dst, const unsigned long *src, 144 + unsigned int shift, unsigned int nbits); 145 + void __bitmap_shift_left(unsigned long *dst, const unsigned long *src, 146 + unsigned int shift, unsigned int nbits); 147 + void bitmap_cut(unsigned long *dst, const unsigned long *src, 148 + unsigned int first, unsigned int cut, unsigned int nbits); 149 + int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 150 + const unsigned long *bitmap2, unsigned int nbits); 151 + void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, 152 + const unsigned long *bitmap2, unsigned int nbits); 153 + void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, 154 + const unsigned long *bitmap2, unsigned int nbits); 155 + int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 156 + const unsigned long *bitmap2, unsigned int nbits); 157 + void __bitmap_replace(unsigned long *dst, 158 + const unsigned long *old, const unsigned long *new, 159 + const unsigned long *mask, unsigned int nbits); 160 + int __bitmap_intersects(const unsigned long *bitmap1, 147 161 const unsigned long *bitmap2, unsigned int nbits); 148 - extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, 149 - const unsigned long *bitmap2, unsigned int nbits); 150 - extern void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, 151 - const unsigned long *bitmap2, unsigned int nbits); 152 - extern int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 153 - const unsigned long *bitmap2, unsigned int nbits); 154 - extern void __bitmap_replace(unsigned long *dst, 155 - const unsigned long *old, const unsigned long *new, 156 - const unsigned long *mask, unsigned int nbits); 157 - extern int __bitmap_intersects(const unsigned long *bitmap1, 158 - const unsigned long *bitmap2, unsigned int nbits); 159 - extern int __bitmap_subset(const unsigned long *bitmap1, 160 - const unsigned long *bitmap2, unsigned int nbits); 161 - extern int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); 162 - extern void __bitmap_set(unsigned long *map, unsigned int start, int len); 163 - extern void __bitmap_clear(unsigned long *map, unsigned int start, int len); 162 + int __bitmap_subset(const unsigned long *bitmap1, 163 + const unsigned long *bitmap2, unsigned int nbits); 164 + int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); 165 + void __bitmap_set(unsigned long *map, unsigned int start, int len); 166 + void __bitmap_clear(unsigned long *map, unsigned int start, int len); 164 167 165 - extern unsigned long bitmap_find_next_zero_area_off(unsigned long *map, 166 - unsigned long size, 167 - unsigned long start, 168 - unsigned int nr, 169 - unsigned long align_mask, 170 - unsigned long align_offset); 168 + unsigned long bitmap_find_next_zero_area_off(unsigned long *map, 169 + unsigned long size, 170 + unsigned long start, 171 + unsigned int nr, 172 + unsigned long align_mask, 173 + unsigned long align_offset); 171 174 172 175 /** 173 176 * bitmap_find_next_zero_area - find a contiguous aligned zero area ··· 197 190 align_mask, 0); 198 191 } 199 192 200 - extern int bitmap_parse(const char *buf, unsigned int buflen, 193 + int bitmap_parse(const char *buf, unsigned int buflen, 201 194 unsigned long *dst, int nbits); 202 - extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, 195 + int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, 203 196 unsigned long *dst, int nbits); 204 - extern int bitmap_parselist(const char *buf, unsigned long *maskp, 197 + int bitmap_parselist(const char *buf, unsigned long *maskp, 205 198 int nmaskbits); 206 - extern int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen, 199 + int bitmap_parselist_user(const char __user *ubuf, unsigned int ulen, 207 200 unsigned long *dst, int nbits); 208 - extern void bitmap_remap(unsigned long *dst, const unsigned long *src, 201 + void bitmap_remap(unsigned long *dst, const unsigned long *src, 209 202 const unsigned long *old, const unsigned long *new, unsigned int nbits); 210 - extern int bitmap_bitremap(int oldbit, 203 + int bitmap_bitremap(int oldbit, 211 204 const unsigned long *old, const unsigned long *new, int bits); 212 - extern void bitmap_onto(unsigned long *dst, const unsigned long *orig, 205 + void bitmap_onto(unsigned long *dst, const unsigned long *orig, 213 206 const unsigned long *relmap, unsigned int bits); 214 - extern void bitmap_fold(unsigned long *dst, const unsigned long *orig, 207 + void bitmap_fold(unsigned long *dst, const unsigned long *orig, 215 208 unsigned int sz, unsigned int nbits); 216 - extern int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order); 217 - extern void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order); 218 - extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); 209 + int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order); 210 + void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order); 211 + int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); 219 212 220 213 #ifdef __BIG_ENDIAN 221 - extern void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int nbits); 214 + void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int nbits); 222 215 #else 223 216 #define bitmap_copy_le bitmap_copy 224 217 #endif 225 - extern unsigned int bitmap_ord_to_pos(const unsigned long *bitmap, unsigned int ord, unsigned int nbits); 226 - extern int bitmap_print_to_pagebuf(bool list, char *buf, 218 + unsigned int bitmap_ord_to_pos(const unsigned long *bitmap, unsigned int ord, unsigned int nbits); 219 + int bitmap_print_to_pagebuf(bool list, char *buf, 227 220 const unsigned long *maskp, int nmaskbits); 228 221 229 222 #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) ··· 272 265 * therefore conversion is not needed when copying data from/to arrays of u32. 273 266 */ 274 267 #if BITS_PER_LONG == 64 275 - extern void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, 268 + void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf, 276 269 unsigned int nbits); 277 - extern void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, 270 + void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, 278 271 unsigned int nbits); 279 272 #else 280 273 #define bitmap_from_arr32(bitmap, buf, nbits) \
+6 -6
include/linux/gpio/driver.h
··· 227 227 /** 228 228 * @valid_mask: 229 229 * 230 - * If not %NULL holds bitmask of GPIOs which are valid to be included 230 + * If not %NULL, holds bitmask of GPIOs which are valid to be included 231 231 * in IRQ domain of the chip. 232 232 */ 233 233 unsigned long *valid_mask; ··· 346 346 * output. 347 347 * 348 348 * A gpio_chip can help platforms abstract various sources of GPIOs so 349 - * they can all be accessed through a common programing interface. 349 + * they can all be accessed through a common programming interface. 350 350 * Example sources would be SOC controllers, FPGAs, multifunction 351 351 * chips, dedicated GPIO expanders, and so on. 352 352 * ··· 435 435 /** 436 436 * @valid_mask: 437 437 * 438 - * If not %NULL holds bitmask of GPIOs which are valid to be used 438 + * If not %NULL, holds bitmask of GPIOs which are valid to be used 439 439 * from the chip. 440 440 */ 441 441 unsigned long *valid_mask; 442 442 443 443 #if defined(CONFIG_OF_GPIO) 444 444 /* 445 - * If CONFIG_OF is enabled, then all GPIO controllers described in the 446 - * device tree automatically may have an OF translation 445 + * If CONFIG_OF_GPIO is enabled, then all GPIO controllers described in 446 + * the device tree automatically may have an OF translation 447 447 */ 448 448 449 449 /** ··· 508 508 * for GPIOs will fail rudely. 509 509 * 510 510 * gpiochip_add_data() must only be called after gpiolib initialization, 511 - * ie after core_initcall(). 511 + * i.e. after core_initcall(). 512 512 * 513 513 * If gc->base is negative, this requests dynamic assignment of 514 514 * a range of valid GPIOs.
+14 -5
include/linux/irqdomain.h
··· 256 256 irq_hw_number_t hwirq_max, int direct_max, 257 257 const struct irq_domain_ops *ops, 258 258 void *host_data); 259 - struct irq_domain *irq_domain_add_simple(struct device_node *of_node, 260 - unsigned int size, 261 - unsigned int first_irq, 262 - const struct irq_domain_ops *ops, 263 - void *host_data); 259 + struct irq_domain *irq_domain_create_simple(struct fwnode_handle *fwnode, 260 + unsigned int size, 261 + unsigned int first_irq, 262 + const struct irq_domain_ops *ops, 263 + void *host_data); 264 264 struct irq_domain *irq_domain_add_legacy(struct device_node *of_node, 265 265 unsigned int size, 266 266 unsigned int first_irq, ··· 323 323 d = irq_find_matching_host(node, DOMAIN_BUS_ANY); 324 324 325 325 return d; 326 + } 327 + 328 + static inline struct irq_domain *irq_domain_add_simple(struct device_node *of_node, 329 + unsigned int size, 330 + unsigned int first_irq, 331 + const struct irq_domain_ops *ops, 332 + void *host_data) 333 + { 334 + return irq_domain_create_simple(of_node_to_fwnode(of_node), size, first_irq, ops, host_data); 326 335 } 327 336 328 337 /**
+10 -10
kernel/irq/irqdomain.c
··· 295 295 EXPORT_SYMBOL_GPL(irq_domain_update_bus_token); 296 296 297 297 /** 298 - * irq_domain_add_simple() - Register an irq_domain and optionally map a range of irqs 299 - * @of_node: pointer to interrupt controller's device tree node. 298 + * irq_domain_create_simple() - Register an irq_domain and optionally map a range of irqs 299 + * @fwnode: firmware node for the interrupt controller 300 300 * @size: total number of irqs in mapping 301 301 * @first_irq: first number of irq block assigned to the domain, 302 302 * pass zero to assign irqs on-the-fly. If first_irq is non-zero, then ··· 312 312 * irqs get mapped dynamically on the fly. However, if the controller requires 313 313 * static virq assignments (non-DT boot) then it will set that up correctly. 314 314 */ 315 - struct irq_domain *irq_domain_add_simple(struct device_node *of_node, 316 - unsigned int size, 317 - unsigned int first_irq, 318 - const struct irq_domain_ops *ops, 319 - void *host_data) 315 + struct irq_domain *irq_domain_create_simple(struct fwnode_handle *fwnode, 316 + unsigned int size, 317 + unsigned int first_irq, 318 + const struct irq_domain_ops *ops, 319 + void *host_data) 320 320 { 321 321 struct irq_domain *domain; 322 322 323 - domain = __irq_domain_add(of_node_to_fwnode(of_node), size, size, 0, ops, host_data); 323 + domain = __irq_domain_add(fwnode, size, size, 0, ops, host_data); 324 324 if (!domain) 325 325 return NULL; 326 326 ··· 328 328 if (IS_ENABLED(CONFIG_SPARSE_IRQ)) { 329 329 /* attempt to allocated irq_descs */ 330 330 int rc = irq_alloc_descs(first_irq, first_irq, size, 331 - of_node_to_nid(of_node)); 331 + of_node_to_nid(to_of_node(fwnode))); 332 332 if (rc < 0) 333 333 pr_info("Cannot allocate irq_descs @ IRQ%d, assuming pre-allocated\n", 334 334 first_irq); ··· 338 338 339 339 return domain; 340 340 } 341 - EXPORT_SYMBOL_GPL(irq_domain_add_simple); 341 + EXPORT_SYMBOL_GPL(irq_domain_create_simple); 342 342 343 343 /** 344 344 * irq_domain_add_legacy() - Allocate and register a legacy revmap irq_domain.
+38 -4
lib/bitmap.c
··· 3 3 * lib/bitmap.c 4 4 * Helper functions for bitmap.h. 5 5 */ 6 - #include <linux/export.h> 7 - #include <linux/thread_info.h> 8 - #include <linux/ctype.h> 9 - #include <linux/errno.h> 6 + 10 7 #include <linux/bitmap.h> 11 8 #include <linux/bitops.h> 12 9 #include <linux/bug.h> 10 + #include <linux/ctype.h> 11 + #include <linux/device.h> 12 + #include <linux/errno.h> 13 + #include <linux/export.h> 13 14 #include <linux/kernel.h> 14 15 #include <linux/mm.h> 15 16 #include <linux/slab.h> 16 17 #include <linux/string.h> 18 + #include <linux/thread_info.h> 17 19 #include <linux/uaccess.h> 18 20 19 21 #include <asm/page.h> ··· 1272 1270 kfree(bitmap); 1273 1271 } 1274 1272 EXPORT_SYMBOL(bitmap_free); 1273 + 1274 + static void devm_bitmap_free(void *data) 1275 + { 1276 + unsigned long *bitmap = data; 1277 + 1278 + bitmap_free(bitmap); 1279 + } 1280 + 1281 + unsigned long *devm_bitmap_alloc(struct device *dev, 1282 + unsigned int nbits, gfp_t flags) 1283 + { 1284 + unsigned long *bitmap; 1285 + int ret; 1286 + 1287 + bitmap = bitmap_alloc(nbits, flags); 1288 + if (!bitmap) 1289 + return NULL; 1290 + 1291 + ret = devm_add_action_or_reset(dev, devm_bitmap_free, bitmap); 1292 + if (ret) 1293 + return NULL; 1294 + 1295 + return bitmap; 1296 + } 1297 + EXPORT_SYMBOL_GPL(devm_bitmap_alloc); 1298 + 1299 + unsigned long *devm_bitmap_zalloc(struct device *dev, 1300 + unsigned int nbits, gfp_t flags) 1301 + { 1302 + return devm_bitmap_alloc(dev, nbits, flags | __GFP_ZERO); 1303 + } 1304 + EXPORT_SYMBOL_GPL(devm_bitmap_zalloc); 1275 1305 1276 1306 #if BITS_PER_LONG == 64 1277 1307 /**
+1
lib/cmdline.c
··· 272 272 /* Chew up trailing spaces. */ 273 273 return skip_spaces(args); 274 274 } 275 + EXPORT_SYMBOL(next_arg);
+9 -9
tools/gpio/gpio-utils.c
··· 20 20 #define CONSUMER "gpio-utils" 21 21 22 22 /** 23 - * doc: Operation of gpio 23 + * DOC: Operation of gpio 24 24 * 25 25 * Provide the api of gpiochip for chardev interface. There are two 26 26 * types of api. The first one provide as same function as each ··· 100 100 } 101 101 102 102 /** 103 - * gpiotools_set_values(): Set the value of gpio(s) 103 + * gpiotools_set_values() - Set the value of gpio(s) 104 104 * @fd: The fd returned by 105 105 * gpiotools_request_line(). 106 106 * @values: The array of values want to set. ··· 124 124 } 125 125 126 126 /** 127 - * gpiotools_get_values(): Get the value of gpio(s) 127 + * gpiotools_get_values() - Get the value of gpio(s) 128 128 * @fd: The fd returned by 129 129 * gpiotools_request_line(). 130 130 * @values: The array of values get from hardware. ··· 148 148 } 149 149 150 150 /** 151 - * gpiotools_release_line(): Release the line(s) of gpiochip 151 + * gpiotools_release_line() - Release the line(s) of gpiochip 152 152 * @fd: The fd returned by 153 153 * gpiotools_request_line(). 154 154 * ··· 169 169 } 170 170 171 171 /** 172 - * gpiotools_get(): Get value from specific line 172 + * gpiotools_get() - Get value from specific line 173 173 * @device_name: The name of gpiochip without prefix "/dev/", 174 174 * such as "gpiochip0" 175 175 * @line: number of line, such as 2. ··· 191 191 192 192 193 193 /** 194 - * gpiotools_gets(): Get values from specific lines. 194 + * gpiotools_gets() - Get values from specific lines. 195 195 * @device_name: The name of gpiochip without prefix "/dev/", 196 196 * such as "gpiochip0". 197 197 * @lines: An array desired lines, specified by offset ··· 230 230 } 231 231 232 232 /** 233 - * gpiotools_set(): Set value to specific line 233 + * gpiotools_set() - Set value to specific line 234 234 * @device_name: The name of gpiochip without prefix "/dev/", 235 235 * such as "gpiochip0" 236 236 * @line: number of line, such as 2. ··· 248 248 } 249 249 250 250 /** 251 - * gpiotools_sets(): Set values to specific lines. 251 + * gpiotools_sets() - Set values to specific lines. 252 252 * @device_name: The name of gpiochip without prefix "/dev/", 253 253 * such as "gpiochip0". 254 254 * @lines: An array desired lines, specified by offset 255 255 * index for the associated GPIO device. 256 256 * @num_lines: The number of lines to request. 257 - * @value: The array of values set to gpiochip, must be 257 + * @values: The array of values set to gpiochip, must be 258 258 * 0(low) or 1(high). 259 259 * 260 260 * Return: On success return 0;