Support GPIO controller of Loongson-2K0300 SoC
Subsystems (4)
v3 cover Support GPIO controller of Loongson-2K0300 SoC
This series adds support for Loongson-2K0300's GPIO controller. While being mostly identical to previous implementation, its interrupt functionality hasn't been implemented in gpio-loongson-64bit.c. PATCH 2 implements its interrupt support with an IRQCHIP, and the code could be reused for other Loongson SoCs with similar interrupt functionality like LS2K1500 and LS2K2000.
Tested on CTCISZ Forever Pi, reading/writing GPIOs works correctly, and both level and edge interrupts could be triggered.
The devicetree patch depends on series "Support reset controller of Loongson 2K0300 SoC"[1] for a clean apply. Thanks for your time and review.
Changed from v2:
- Adjust SoC naming style
- Fold some multi-line calls to dev_err_probe() in the driver into a single line
- Collect review tags
- Link to v2: https://lore.kernel.org/all/[email protected]/
Changed from v1:
- Rebase on top of gpio/for-next, adapt changes that convert gpio-loongson-64bit.c to use generic gpiochip.
- Collect review tags
- Link to v1: https://lore.kernel.org/all/[email protected]/
[1]: https://lore.kernel.org/all/[email protected]/
Yao Zi (3):
dt-bindings: gpio: loongson: Document GPIO controller of LS2K0300 SoC
gpio: loongson-64bit: Add support for Loongson-2K0300 SoC
LoongArch: dts: Add GPIO controller for Loongson-2K0300
.../bindings/gpio/loongson,ls-gpio.yaml | 28 ++- arch/loongarch/boot/dts/loongson-2k0300.dtsi | 20 ++ drivers/gpio/Kconfig | 1 + drivers/gpio/gpio-loongson-64bit.c | 189 +++++++++++++++++- 4 files changed, 230 insertions(+), 8 deletions(-)
Signature · 1 line
2.50.1
PATCH v3 1/3 dt-bindings: gpio: loongson: Document GPIO controller of LS2K0300 SoC
Loongson-2K0300 ships a GPIO controller whose input/output control logic is similar to previous generation of SoCs. Additionally, it acts as an interrupt-controller supporting both level and edge interrupts and has a distinct reset signal.
Describe its compatible in devicetree. We enlarge the maximum value of ngpios to 128, since the controller technically supports at most 128 pins, although only 106 are routed out of the package. Properties for interrupt-controllers and resets are introduced and limited as LS2K0300 only.
--- .../bindings/gpio/loongson,ls-gpio.yaml | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/gpio/loongson,ls-gpio.yaml +27 -1
@@ -14,6 +14,7 @@ properties: oneOf: - enum: - loongson,ls2k-gpio + - loongson,ls2k0300-gpio - loongson,ls2k0500-gpio0 - loongson,ls2k0500-gpio1 - loongson,ls2k2000-gpio0
@@ -36,7 +37,7 @@ properties: ngpios: minimum: 1 - maximum: 64 + maximum: 128 "#gpio-cells": const: 2
@@ -49,6 +50,14 @@ properties: minItems: 1 maxItems: 64 + "#interrupt-cells": + const: 2 + + interrupt-controller: true + + resets: + maxItems: 1 + required: - compatible - reg
@@ -58,6 +67,23 @@ required: - gpio-ranges - interrupts +allOf: + - if: + properties: + compatible: + contains: + const: loongson,ls2k0300-gpio + then: + required: + - "#interrupt-cells" + - interrupt-controller + - resets + else: + properties: + "#interrupts-cells": false + interrupt-controller: false + resets: false + additionalProperties: false examples:
Signature · 1 line
2.50.1
Re: [PATCH v3 1/3] dt-bindings: gpio: loongson: Document GPIO controller of LS2K0300 SoC
Quoted 11 lines · Yao Zi
Loongson-2K0300 ships a GPIO controller whose input/output control logic is similar to previous generation of SoCs. Additionally, it acts as an interrupt-controller supporting both level and edge interrupts and has a distinct reset signal.
Describe its compatible in devicetree. We enlarge the maximum value of ngpios to 128, since the controller technically supports at most 128 pins, although only 106 are routed out of the package. Properties for interrupt-controllers and resets are introduced and limited as LS2K0300 only.
Quoted 3 lines
Signed-off-by Yao Zi <[email protected]>Reviewed-by Krzysztof Kozlowski <[email protected]>Reviewed-by Huacai Chen <[email protected]>
Looks good:
Yours,
Linus Walleij
PATCH v3 2/3 gpio: loongson-64bit: Add support for Loongson-2K0300 SoC
In reply to Yao ZiThis controller's input and output logic is similar to previous generations of SoCs. Additionally, it's capable of interrupt masking, and could be configured to detect levels and edges, and is supplied with a distinct reset signal.
The interrupt functionality is implemented through an irqchip, whose operations are written with previous generation SoCs in mind and could be reused. Since all Loongson SoCs with similar interrupt capability (LS2K1500, LS2K2000) support byte-control mode, these operations are for byte-control mode only for simplicity.
--- drivers/gpio/Kconfig | 1 + drivers/gpio/gpio-loongson-64bit.c | 189 +++++++++++++++++++++++++++-- 2 files changed, 183 insertions(+), 7 deletions(-)
drivers/gpio/Kconfig +1 -0
@@ -437,6 +437,7 @@ config GPIO_LOONGSON_64BIT depends on LOONGARCH || COMPILE_TEST depends on OF_GPIO select GPIO_GENERIC + select GPIOLIB_IRQCHIP help Say yes here to support the GPIO functionality of a number of Loongson series of chips. The Loongson GPIO controller supports
drivers/gpio/gpio-loongson-64bit.c +182 -7
262 lines not on this page · raw message
Signature · 1 line
2.50.1
Re: [PATCH v3 2/3] gpio: loongson-64bit: Add support for Loongson-2K0300 SoC
Quoted 5 lines · Yao Zi
This controller's input and output logic is similar to previous generations of SoCs. Additionally, it's capable of interrupt masking, and could be configured to detect levels and edges, and is supplied with a distinct reset signal.
Quoted 8 lines
The interrupt functionality is implemented through an irqchip, whose operations are written with previous generation SoCs in mind and could be reused. Since all Loongson SoCs with similar interrupt capability (LS2K1500, LS2K2000) support byte-control mode, these operations are for byte-control mode only for simplicity.
Signed-off-by Yao Zi <[email protected]>Reviewed-by Huacai Chen <[email protected]>
Uses generic GPIO IRQCHIP which is great, and generic_handle_domain_irq() so I think it looks great.
Yours,
Linus Walleij
PATCH v3 3/3 LoongArch: dts: Add GPIO controller for Loongson-2K0300
In reply to Yao ZiDescribe Loongson-2K0300's GPIO controller in devicetree.
--- arch/loongarch/boot/dts/loongson-2k0300.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/loongarch/boot/dts/loongson-2k0300.dtsi +20 -0
@@ -240,6 +240,26 @@ uart9: serial@16102400 { status = "disabled"; }; + gpio: gpio@16104000 { + compatible = "loongson,ls2k0300-gpio"; + reg = <0x0 0x16104000 0x0 0x4000>; + interrupt-parent = <&liointc1>; + interrupts = <21 IRQ_TYPE_LEVEL_HIGH>, + <22 IRQ_TYPE_LEVEL_HIGH>, + <23 IRQ_TYPE_LEVEL_HIGH>, + <24 IRQ_TYPE_LEVEL_HIGH>, + <25 IRQ_TYPE_LEVEL_HIGH>, + <26 IRQ_TYPE_LEVEL_HIGH>, + <27 IRQ_TYPE_LEVEL_HIGH>; + ngpios = <106>; + gpio-controller; + gpio-ranges = <&pinctrl 0 0 106>; + #gpio-cells = <2>; + interrupt-controller; + #interrupt-cells = <2>; + resets = <&rst RST_GPIO>; + }; + isa@16400000 { compatible = "isa"; #address-cells = <2>;
Signature · 1 line
2.50.1
Bartosz Golaszewski
AppliedRe: (subset) [PATCH v3 0/3] Support GPIO controller of Loongson-2K0300 SoC
In reply to Yao ZiFrom: Bartosz Golaszewski <[email protected]>
Quoted 8 lines · Yao Zi
This series adds support for Loongson-2K0300's GPIO controller. While being mostly identical to previous implementation, its interrupt functionality hasn't been implemented in
gpio-loongson-64bit.c. PATCH 2 implements its interrupt support with an IRQCHIP, and the code could be reused for other Loongson SoCs with similar interrupt functionality like LS2K1500 and LS2K2000.[...]
Applied, thanks!
[1/3] dt-bindings: gpio: loongson: Document GPIO controller of LS2K0300 SoC
https://git.kernel.org/brgl/linux/c/084d01a173f5f41afd326b1dfe73085972530ca7 [2/3] gpio: loongson-64bit: Add support for Loongson-2K0300 SoC https://git.kernel.org/brgl/linux/c/03c146cb6cd14fdab2d2c7ab1b4e8035b54df8cc
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>