]> www.infradead.org Git - users/willy/xarray.git/commitdiff
riscv: dts: spacemit: add gpio support for K1 SoC
authorYixun Lan <dlan@gentoo.org>
Thu, 24 Apr 2025 09:40:50 +0000 (17:40 +0800)
committerYixun Lan <dlan@gentoo.org>
Wed, 14 May 2025 03:43:55 +0000 (11:43 +0800)
Populate the GPIO node in the device tree for SpacemiT K1 SoC.
Each of 32 pins will act as one bank and map pins to pinctrl controller.

Link: https://lore.kernel.org/r/20250424-03-k1-gpio-v9-2-eaece8cc5a86@gentoo.org
Signed-off-by: Yixun Lan <dlan@gentoo.org>
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
arch/riscv/boot/dts/spacemit/k1.dtsi

index a8eac5517f8578d60cb45214589ccb45ac376b9a..283663647a86ff137917ced8bfe79a129c86342a 100644 (file)
@@ -7,6 +7,9 @@
 
 #define K1_PADCONF(pin, func) (((pin) << 16) | (func))
 
+/* Map GPIO pin to each bank's <index, offset> */
+#define K1_GPIO(x)     (x / 32) (x % 32)
+
 &pinctrl {
        uart0_2_cfg: uart0-2-cfg {
                uart0-2-pins {
index 2c7aa9b37fee27afe839346b45983fc5070031cf..c0f8c5fca975d73b6ea6886da13fcf55289cb16c 100644 (file)
                        status = "disabled";
                };
 
+               gpio: gpio@d4019000 {
+                       compatible = "spacemit,k1-gpio";
+                       reg = <0x0 0xd4019000 0x0 0x100>;
+                       clocks = <&syscon_apbc CLK_GPIO>,
+                                <&syscon_apbc CLK_GPIO_BUS>;
+                       clock-names = "core", "bus";
+                       gpio-controller;
+                       #gpio-cells = <3>;
+                       interrupts = <58>;
+                       interrupt-parent = <&plic>;
+                       interrupt-controller;
+                       #interrupt-cells = <3>;
+                       gpio-ranges = <&pinctrl 0 0 0 32>,
+                                     <&pinctrl 1 0 32 32>,
+                                     <&pinctrl 2 0 64 32>,
+                                     <&pinctrl 3 0 96 32>;
+               };
+
                pinctrl: pinctrl@d401e000 {
                        compatible = "spacemit,k1-pinctrl";
                        reg = <0x0 0xd401e000 0x0 0x400>;