Skip to contentSkip to conversation

riscv: dts: spacemit: add pinctrl property to uart0 in BPI-F3

PATCH In review Jesse Taube 2 participants 4 messages Sep 15, 2024 – Sep 16, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v4 3/3 riscv: dts: spacemit: add pinctrl property to uart0 in BPI-F3

Before pinctrl driver implemented, the uart0 controller reply on bootloader for setting correct pin mux and configurations.

Now, let's add pinctrl property to uart0 of Bananapi-F3 board.

---
 arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts |  3 +++
 arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi    | 20 ++++++++++++++++++++
 arch/riscv/boot/dts/spacemit/k1.dtsi            |  5 +++++
 3 files changed, 28 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3 -0
index 023274189b492..bc88d4de25a62 100644
@@ -4,6 +4,7 @@
  */
 
 #include "k1.dtsi"
+#include "k1-pinctrl.dtsi"
 
 / {
 	model = "Banana Pi BPI-F3";
@@ -15,5 +16,7 @@ chosen {
 };
 
 &uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_2_cfg>;
 	status = "okay";
 };
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi new file +8 -0
new file mode 100644
index 0000000000000..a8eac5517f857
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * Copyright (c) 2024 Yixun Lan <[email protected]>
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+
+#define K1_PADCONF(pin, func) (((pin) << 16) | (func))

It would be nice to have a pinfunc header like
arch/arm/boot/dts/nxp/imx/imx7ulp-pinfunc.h.
It would reference and encode the data of "3.2 Pin Multiplex" in
https://developer.spacemit.com/documentation?token=An1vwTwKaigaXRkYfwmcznTXned , the document you attached in the summary.

Otherwise,

+
+&pinctrl {
+ uart0_2_cfg: uart0-2-cfg {
+ uart0-2-pins {
+ pinmux = <K1_PADCONF(68, 2)>,
+ <K1_PADCONF(69, 2)>;
+
+ bias-pull-up = <0>;
+ drive-strength = <32>;
+ };
+ };
+};

arch/riscv/boot/dts/spacemit/k1.dtsi +5 -0
index 0777bf9e01183..a2d5f7d4a942a 100644
@@ -416,6 +416,11 @@ uart9: serial@d4017800 {
 			status = "disabled";
 		};
 
+		pinctrl: pinctrl@d401e000 {
+			compatible = "spacemit,k1-pinctrl";
+			reg = <0x0 0xd401e000 0x0 0x400>;
+		};
+
 		plic: interrupt-controller@e0000000 {
 			compatible = "spacemit,k1-plic", "sifive,plic-1.0.0";
 			reg = <0x0 0xe0000000 0x0 0x4000000>;
Signature · 1 line
2.45.2
#1 lore raw

Hi Jesse

Quoted 50 lines · Jesse Taube

Before pinctrl driver implemented, the uart0 controller reply on bootloader for setting correct pin mux and configurations.

Now, let's add pinctrl property to uart0 of Bananapi-F3 board.

---
  arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts |  3 +++
  arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi    | 20 ++++++++++++++++++++
  arch/riscv/boot/dts/spacemit/k1.dtsi            |  5 +++++
  3 files changed, 28 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3 -0
index 023274189b492..bc88d4de25a62 100644
@@ -4,6 +4,7 @@
   */
 
  #include "k1.dtsi"
+#include "k1-pinctrl.dtsi"
 
  / {
  	model = "Banana Pi BPI-F3";
@@ -15,5 +16,7 @@ chosen {
  };
 
  &uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_2_cfg>;
  	status = "okay";
  };
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi new file +8 -0
new file mode 100644
index 0000000000000..a8eac5517f857
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * Copyright (c) 2024 Yixun Lan <[email protected]>
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+
+#define K1_PADCONF(pin, func) (((pin) << 16) | (func))
Quoted 5 lines

It would be nice to have a pinfunc header like arch/arm/boot/dts/nxp/imx/imx7ulp-pinfunc.h.
It would reference and encode the data of "3.2 Pin Multiplex" in
https://developer.spacemit.com/documentation?token=An1vwTwKaigaXRkYfwmcznTXned
, the document you attached in the summary.

Not sure if it's worth the effort..

I gave up of introducing another macro, as it's exactly one to one mapping to GPIO ID, which mean pin(x) -> GPIO_x

maybe I could put a comment at K1_PADCONF() to document this?

/* pin is same to the GPIO id according to 3.2 Pin Multiplex of User Manual */ #define K1_PADCONF(pin, func) (((pin) << 16) | (func))

does this sound good to you?

Quoted 4 lines

Otherwise,

thanks

Quoted 32 lines
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi new file +12 -0
+
+&pinctrl {
+	uart0_2_cfg: uart0-2-cfg {
+		uart0-2-pins {
+			pinmux = <K1_PADCONF(68, 2)>,
+				 <K1_PADCONF(69, 2)>;
+
+			bias-pull-up = <0>;
+			drive-strength = <32>;
+		};
+	};
+};
arch/riscv/boot/dts/spacemit/k1.dtsi +5 -0
index 0777bf9e01183..a2d5f7d4a942a 100644
@@ -416,6 +416,11 @@ uart9: serial@d4017800 {
  			status = "disabled";
  		};
 
+		pinctrl: pinctrl@d401e000 {
+			compatible = "spacemit,k1-pinctrl";
+			reg = <0x0 0xd401e000 0x0 0x400>;
+		};
+
  		plic: interrupt-controller@e0000000 {
  			compatible = "spacemit,k1-plic", "sifive,plic-1.0.0";
  			reg = <0x0 0xe0000000 0x0 0x4000000>;
Signature · 2 lines
-- 
2.45.2
Signature · 3 lines
Yixun Lan (dlan)
Gentoo Linux Developer
GPG Key ID AABEFD55
author
#2 lore raw
Quoted 54 lines · Yixun Lan

Hi Jesse

Quoted 50 lines · Jesse Taube

Before pinctrl driver implemented, the uart0 controller reply on bootloader for setting correct pin mux and configurations.

Now, let's add pinctrl property to uart0 of Bananapi-F3 board.

---
  arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts |  3 +++
  arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi    | 20 ++++++++++++++++++++
  arch/riscv/boot/dts/spacemit/k1.dtsi            |  5 +++++
  3 files changed, 28 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3 -0
index 023274189b492..bc88d4de25a62 100644
@@ -4,6 +4,7 @@
   */
 
  #include "k1.dtsi"
+#include "k1-pinctrl.dtsi"
 
  / {
      model = "Banana Pi BPI-F3";
@@ -15,5 +16,7 @@ chosen {
  };
 
  &uart0 {
+     pinctrl-names = "default";
+     pinctrl-0 = <&uart0_2_cfg>;
      status = "okay";
  };
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi new file +8 -0
new file mode 100644
index 0000000000000..a8eac5517f857
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * Copyright (c) 2024 Yixun Lan <[email protected]>
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+
+#define K1_PADCONF(pin, func) (((pin) << 16) | (func))
Quoted 6 lines
Quoted 5 lines

It would be nice to have a pinfunc header like arch/arm/boot/dts/nxp/imx/imx7ulp-pinfunc.h.
It would reference and encode the data of "3.2 Pin Multiplex" in
https://developer.spacemit.com/documentation?token=An1vwTwKaigaXRkYfwmcznTXned
, the document you attached in the summary.

Not sure if it's worth the effort..

I can send a future patch for this.

Quoted 5 lines

I gave up of introducing another macro, as it's exactly one to one mapping to GPIO ID, which mean pin(x) -> GPIO_x

maybe I could put a comment at K1_PADCONF() to document this?

I'm weary the Manual may not exist on the site in the future or will change formats. But it would be nice otherwise.

Quoted 5 lines

/* pin is same to the GPIO id according to 3.2 Pin Multiplex of User Manual */ #define K1_PADCONF(pin, func) (((pin) << 16) | (func))

does this sound good to you?

Sure, add it.

Also sorry for messing up the reply-to thing thunderbird is confusing.

Thanks,
Jesse Taube

Quoted 44 lines
Quoted 5 lines

Otherwise,

thanks

Quoted 31 lines
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi new file +12 -0
+
+&pinctrl {
+     uart0_2_cfg: uart0-2-cfg {
+             uart0-2-pins {
+                     pinmux = <K1_PADCONF(68, 2)>,
+                              <K1_PADCONF(69, 2)>;
+
+                     bias-pull-up = <0>;
+                     drive-strength = <32>;
+             };
+     };
+};
arch/riscv/boot/dts/spacemit/k1.dtsi +5 -1
index 0777bf9e01183..a2d5f7d4a942a 100644
@@ -416,6 +416,11 @@ uart9: serial@d4017800 {
                      status = "disabled";
              };
 
+             pinctrl: pinctrl@d401e000 {
+                     compatible = "spacemit,k1-pinctrl";
+                     reg = <0x0 0xd401e000 0x0 0x400>;
+             };
+
              plic: interrupt-controller@e0000000 {
                      compatible = "spacemit,k1-plic", "sifive,plic-1.0.0";
                      reg = <0x0 0xe0000000 0x0 0x4000000>;
 
--
Quoted 1 line

2.45.2

--
Yixun Lan (dlan)
Gentoo Linux Developer
GPG Key ID AABEFD55

#3 lore raw

Hi Jesse:

Quoted 55 lines · Jesse T
Quoted 54 lines · Yixun Lan

Hi Jesse

Quoted 50 lines · Jesse Taube

Before pinctrl driver implemented, the uart0 controller reply on bootloader for setting correct pin mux and configurations.

Now, let's add pinctrl property to uart0 of Bananapi-F3 board.

---
  arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts |  3 +++
  arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi    | 20 ++++++++++++++++++++
  arch/riscv/boot/dts/spacemit/k1.dtsi            |  5 +++++
  3 files changed, 28 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +3 -0
index 023274189b492..bc88d4de25a62 100644
@@ -4,6 +4,7 @@
   */
 
  #include "k1.dtsi"
+#include "k1-pinctrl.dtsi"
 
  / {
      model = "Banana Pi BPI-F3";
@@ -15,5 +16,7 @@ chosen {
  };
 
  &uart0 {
+     pinctrl-names = "default";
+     pinctrl-0 = <&uart0_2_cfg>;
      status = "okay";
  };
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi new file +8 -0
new file mode 100644
index 0000000000000..a8eac5517f857
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * Copyright (c) 2024 Yixun Lan <[email protected]>
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+
+#define K1_PADCONF(pin, func) (((pin) << 16) | (func))
Quoted 9 lines
Quoted 6 lines
Quoted 5 lines

It would be nice to have a pinfunc header like arch/arm/boot/dts/nxp/imx/imx7ulp-pinfunc.h.
It would reference and encode the data of "3.2 Pin Multiplex" in
https://developer.spacemit.com/documentation?token=An1vwTwKaigaXRkYfwmcznTXned
, the document you attached in the summary.

Not sure if it's worth the effort..

I can send a future patch for this.

Ok, thanks, no objection from my side
but, that gonna be a lot work as you need to list ALL the functions..

Quoted 66 lines
Quoted 5 lines

I gave up of introducing another macro, as it's exactly one to one mapping to GPIO ID, which mean pin(x) -> GPIO_x

maybe I could put a comment at K1_PADCONF() to document this?

I'm weary the Manual may not exist on the site in the future or will change formats. But it would be nice otherwise.

Quoted 5 lines

/* pin is same to the GPIO id according to 3.2 Pin Multiplex of User Manual */ #define K1_PADCONF(pin, func) (((pin) << 16) | (func))

does this sound good to you?

Sure, add it.

Also sorry for messing up the reply-to thing thunderbird is confusing.

Thanks,
Jesse Taube

Quoted 44 lines
Quoted 5 lines

Otherwise,

thanks

Quoted 31 lines
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi new file +12 -0
+
+&pinctrl {
+     uart0_2_cfg: uart0-2-cfg {
+             uart0-2-pins {
+                     pinmux = <K1_PADCONF(68, 2)>,
+                              <K1_PADCONF(69, 2)>;
+
+                     bias-pull-up = <0>;
+                     drive-strength = <32>;
+             };
+     };
+};
arch/riscv/boot/dts/spacemit/k1.dtsi +5 -1
index 0777bf9e01183..a2d5f7d4a942a 100644
@@ -416,6 +416,11 @@ uart9: serial@d4017800 {
                      status = "disabled";
              };
 
+             pinctrl: pinctrl@d401e000 {
+                     compatible = "spacemit,k1-pinctrl";
+                     reg = <0x0 0xd401e000 0x0 0x400>;
+             };
+
              plic: interrupt-controller@e0000000 {
                      compatible = "spacemit,k1-plic", "sifive,plic-1.0.0";
                      reg = <0x0 0xe0000000 0x0 0x4000000>;
 
--
Quoted 1 line

2.45.2

--
Yixun Lan (dlan)
Gentoo Linux Developer
GPG Key ID AABEFD55

Signature · 3 lines
Yixun Lan (dlan)
Gentoo Linux Developer
GPG Key ID AABEFD55