.../devicetree/bindings/gpio/spacemit,k1-gpio.yaml | 96 +++++++ arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 11 + arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 3 + arch/riscv/boot/dts/spacemit/k1.dtsi | 15 ++ arch/riscv/configs/defconfig | 1 + drivers/gpio/Kconfig | 9 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-spacemit-k1.c | 293 +++++++++++++++++++++ 8 files changed, 429 insertions(+)
The gpio controller of K1 support basic GPIO functions,
which capable of enabling as input, output. It can also be used
as GPIO interrupt which able to detect rising edge, falling edge,
or both. There are four GPIO ports, each consisting of 32 pins and
has indepedent register sets, while still sharing IRQ line and clocks.
The GPIO controller request the two clock sources from APBC block.
Due to first three GPIO ports has interleave register settings, some
resources (IRQ, clock) are shared by all pins.
The GPIO docs of K1 SoC can be found here, chapter 16.4 GPIO [1]
This patch series has been tested on Bananapi-F3 board,
with following GPIO cases passed:
1) gpio input
2) gpio output - set to high, low
3) gpio interrupt - rising trigger, falling trigger, both edge trigger
This version should resolve DT related concern in V4, and register each bank as
indepedent gpio chip in driver, no more sub children gpio DT node needed.
Please notice in this version, the reset property is added, but optional.
as I see no need to activate it in driver, instead I suspect it may
break cases if bootloader did some prerequisite settings, so I'm leaving
it for future implementation if really necessary.
The DT part (patches 4, 5) has no clock property populated which result
some DT warnings, I will fix it and re-spin the DT part once clock driver merged,
so it's included here for completeness only, please ignore these warnings.
Link: https://developer.spacemit.com/documentation?token=Rn9Kw3iFHirAMgkIpTAcV2Arnkf [1]
Link: https://lore.kernel.org/all/20240730-k1-01-basic-dt-v5-0-98263aae83be@gentoo.org [2]
Link: https://lore.kernel.org/all/20241016-02-k1-pinctrl-v5-0-03d395222e4f@gentoo.org/ [3]
Link: https://lore.kernel.org/all/20250218-gpio-ranges-fourcell-v1-0-b1f3db6c8036@linaro.org [4]
Link: https://lore.kernel.org/all/20250225-gpio-ranges-fourcell-v3-0-860382ba4713@linaro.org [5]
Signed-off-by: Yixun Lan <dlan@gentoo.org>
---
Changes in v8:
- rebased to v6.15-rc1
- adjust dt-binding/code to request clocks
- add reset property
- call irq_domain_update_bus_token() to support threecells interrupt mode
- use devm_platform_ioremap_resource(), so drop "struct resource"
- fix Kconfig
- select GPIO_GENERIC as calling bgpio_init()
- change to tristate, make it possible to build as module
- adjust defconfig to enable gpio
- Link to v7: https://lore.kernel.org/r/20250226-03-k1-gpio-v7-0-be489c4a609b@gentoo.org
Changes in v7:
- dt-binding: fix 80 column, drop unneeded dependencies
- tested with patch v3 of "gpiolib: of: Handle threecell gpios" [5]
- collect review tags
- Link to v6: https://lore.kernel.org/r/20250223-03-k1-gpio-v6-0-db2e4adeef1c@gentoo.org
Changes in v6:
- rebase to threecell gpio patch which proposed by LinusW at [4],
drop unneeded *xlate(), *add_pin_range() function
- add SPACEMIT prefix to macro
- adjust register comments
- drop 'index' member, instead calculate from offset
- add IRQCHIP_SKIP_SET_WAKE as gpio doesn't support irq wake up
- drop #ifdef CONFIG_OF_GPIO
- move interrupt mask disabling/enabling into irq_*mask()
- Link to v5: https://lore.kernel.org/r/20250217-03-k1-gpio-v5-0-2863ec3e7b67@gentoo.org
Changes in v5:
- export add_pin_range() from gpio core, support to add custom version
- change to 3 gpio cells, model to <bank number>, <bank offset>, <gpio flag>
- fold children DT nodes into parent
- Link to v4: https://lore.kernel.org/r/20250121-03-k1-gpio-v4-0-4641c95c0194@gentoo.org
Changes in v4:
- gpio: re-construct gpio as four independent ports, also leverage gpio mmio API
- gpio interrupt: convert to generic gpio irqchip
- Link to v3: https://lore.kernel.org/r/20241225-03-k1-gpio-v3-0-27bb7b441d62@gentoo.org
Changes in v3:
- dt: drop ranges, interrupt-names property
- Link to v2: https://lore.kernel.org/r/20241219-03-k1-gpio-v2-0-28444fd221cd@gentoo.org
Changes in v2:
- address dt-bindings comments, simplify example
- rebase to 6.13-rc3
- Link to v1: https://lore.kernel.org/r/20240904-03-k1-gpio-v1-0-6072ebeecae0@gentoo.org
---
Yixun Lan (5):
dt-bindings: gpio: spacemit: add support for K1 SoC
gpio: spacemit: add support for K1 SoC
riscv: defconfig: spacemit: enable gpio support for K1 SoC
riscv: dts: spacemit: add gpio support for K1 SoC
riscv: dts: spacemit: add gpio LED for system heartbeat
.../devicetree/bindings/gpio/spacemit,k1-gpio.yaml | 96 +++++++
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 11 +
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 3 +
arch/riscv/boot/dts/spacemit/k1.dtsi | 15 ++
arch/riscv/configs/defconfig | 1 +
drivers/gpio/Kconfig | 9 +
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-spacemit-k1.c | 293 +++++++++++++++++++++
8 files changed, 429 insertions(+)
---
base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20240828-03-k1-gpio-61bf92f9032c
Best regards,
--
Yixun Lan
Hi Bartosz, I think this version is good to go, if you agree, can you take patch [1,2 / 5] through gpio tree? Hi Palmer, I believe the change to riscv's defconfig file should go via riscv tree? thanks On 07:31 Sat 12 Apr , Yixun Lan wrote: > The gpio controller of K1 support basic GPIO functions, > which capable of enabling as input, output. It can also be used > as GPIO interrupt which able to detect rising edge, falling edge, > or both. There are four GPIO ports, each consisting of 32 pins and > has indepedent register sets, while still sharing IRQ line and clocks. > The GPIO controller request the two clock sources from APBC block. > > Due to first three GPIO ports has interleave register settings, some > resources (IRQ, clock) are shared by all pins. > > The GPIO docs of K1 SoC can be found here, chapter 16.4 GPIO [1] > > This patch series has been tested on Bananapi-F3 board, > with following GPIO cases passed: > 1) gpio input > 2) gpio output - set to high, low > 3) gpio interrupt - rising trigger, falling trigger, both edge trigger > > This version should resolve DT related concern in V4, and register each bank as > indepedent gpio chip in driver, no more sub children gpio DT node needed. > > Please notice in this version, the reset property is added, but optional. > as I see no need to activate it in driver, instead I suspect it may > break cases if bootloader did some prerequisite settings, so I'm leaving > it for future implementation if really necessary. > > The DT part (patches 4, 5) has no clock property populated which result > some DT warnings, I will fix it and re-spin the DT part once clock driver merged, > so it's included here for completeness only, please ignore these warnings. > > Link: https://developer.spacemit.com/documentation?token=Rn9Kw3iFHirAMgkIpTAcV2Arnkf [1] > Link: https://lore.kernel.org/all/20240730-k1-01-basic-dt-v5-0-98263aae83be@gentoo.org [2] > Link: https://lore.kernel.org/all/20241016-02-k1-pinctrl-v5-0-03d395222e4f@gentoo.org/ [3] > Link: https://lore.kernel.org/all/20250218-gpio-ranges-fourcell-v1-0-b1f3db6c8036@linaro.org [4] > Link: https://lore.kernel.org/all/20250225-gpio-ranges-fourcell-v3-0-860382ba4713@linaro.org [5] > Signed-off-by: Yixun Lan <dlan@gentoo.org> > --- > Changes in v8: > - rebased to v6.15-rc1 > - adjust dt-binding/code to request clocks > - add reset property > - call irq_domain_update_bus_token() to support threecells interrupt mode > - use devm_platform_ioremap_resource(), so drop "struct resource" > - fix Kconfig > - select GPIO_GENERIC as calling bgpio_init() > - change to tristate, make it possible to build as module > - adjust defconfig to enable gpio > - Link to v7: https://lore.kernel.org/r/20250226-03-k1-gpio-v7-0-be489c4a609b@gentoo.org > > Changes in v7: > - dt-binding: fix 80 column, drop unneeded dependencies > - tested with patch v3 of "gpiolib: of: Handle threecell gpios" [5] > - collect review tags > - Link to v6: https://lore.kernel.org/r/20250223-03-k1-gpio-v6-0-db2e4adeef1c@gentoo.org > > Changes in v6: > - rebase to threecell gpio patch which proposed by LinusW at [4], > drop unneeded *xlate(), *add_pin_range() function > - add SPACEMIT prefix to macro > - adjust register comments > - drop 'index' member, instead calculate from offset > - add IRQCHIP_SKIP_SET_WAKE as gpio doesn't support irq wake up > - drop #ifdef CONFIG_OF_GPIO > - move interrupt mask disabling/enabling into irq_*mask() > - Link to v5: https://lore.kernel.org/r/20250217-03-k1-gpio-v5-0-2863ec3e7b67@gentoo.org > > Changes in v5: > - export add_pin_range() from gpio core, support to add custom version > - change to 3 gpio cells, model to <bank number>, <bank offset>, <gpio flag> > - fold children DT nodes into parent > - Link to v4: https://lore.kernel.org/r/20250121-03-k1-gpio-v4-0-4641c95c0194@gentoo.org > > Changes in v4: > - gpio: re-construct gpio as four independent ports, also leverage gpio mmio API > - gpio interrupt: convert to generic gpio irqchip > - Link to v3: https://lore.kernel.org/r/20241225-03-k1-gpio-v3-0-27bb7b441d62@gentoo.org > > Changes in v3: > - dt: drop ranges, interrupt-names property > - Link to v2: https://lore.kernel.org/r/20241219-03-k1-gpio-v2-0-28444fd221cd@gentoo.org > > Changes in v2: > - address dt-bindings comments, simplify example > - rebase to 6.13-rc3 > - Link to v1: https://lore.kernel.org/r/20240904-03-k1-gpio-v1-0-6072ebeecae0@gentoo.org > > --- > Yixun Lan (5): > dt-bindings: gpio: spacemit: add support for K1 SoC > gpio: spacemit: add support for K1 SoC > riscv: defconfig: spacemit: enable gpio support for K1 SoC > riscv: dts: spacemit: add gpio support for K1 SoC > riscv: dts: spacemit: add gpio LED for system heartbeat > > .../devicetree/bindings/gpio/spacemit,k1-gpio.yaml | 96 +++++++ > arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 11 + > arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 3 + > arch/riscv/boot/dts/spacemit/k1.dtsi | 15 ++ > arch/riscv/configs/defconfig | 1 + > drivers/gpio/Kconfig | 9 + > drivers/gpio/Makefile | 1 + > drivers/gpio/gpio-spacemit-k1.c | 293 +++++++++++++++++++++ > 8 files changed, 429 insertions(+) > --- > base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8 > change-id: 20240828-03-k1-gpio-61bf92f9032c > > Best regards, > -- > Yixun Lan > -- Yixun Lan (dlan) Gentoo Linux Developer GPG Key ID AABEFD55
On Tue, Apr 15, 2025 at 4:32 AM Yixun Lan <dlan@gentoo.org> wrote: > Hi Bartosz, > I think this version is good to go, if you agree, > can you take patch [1,2 / 5] through gpio tree? I agree with this, it's the final piece making use of all the nice infrastructure we put in for threecell GPIO and threecell IRQ so let's merge patches 1+2! Yours, Linus Walleij
On Sat, 12 Apr 2025 07:31:27 +0800, Yixun Lan wrote:
> The gpio controller of K1 support basic GPIO functions,
> which capable of enabling as input, output. It can also be used
> as GPIO interrupt which able to detect rising edge, falling edge,
> or both. There are four GPIO ports, each consisting of 32 pins and
> has indepedent register sets, while still sharing IRQ line and clocks.
> The GPIO controller request the two clock sources from APBC block.
>
> [...]
Applied, thanks!
[1/5] dt-bindings: gpio: spacemit: add support for K1 SoC
https://git.kernel.org/brgl/linux/c/378ce04c79d14c730fcee6db9f3076da4078b65f
[2/5] gpio: spacemit: add support for K1 SoC
https://git.kernel.org/brgl/linux/c/6149376c9ad1777aa4214e13d844f12f88e22dea
Best regards,
--
Bartosz Golaszewski <brgl@bgdev.pl>
© 2016 - 2026 Red Hat, Inc.