[PATCH 3/3] LoongArch: dts: Add pinctrl configuration for Loongson 2K0300

Yao Zi posted 3 patches 1 month, 3 weeks ago
[PATCH 3/3] LoongArch: dts: Add pinctrl configuration for Loongson 2K0300
Posted by Yao Zi 1 month, 3 weeks ago
Describe the pin controller for Loongson 2K0300 SoC. As default settings
for the existing UARTs, pinctrls are added and multiplexed to pins taken
corresponding UART as main functionaility.

Signed-off-by: Yao Zi <ziyao@disroot.org>
---
 arch/loongarch/boot/dts/loongson-2k0300.dtsi | 39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/arch/loongarch/boot/dts/loongson-2k0300.dtsi b/arch/loongarch/boot/dts/loongson-2k0300.dtsi
index d909a4eca312..a8ad8bd43f5d 100644
--- a/arch/loongarch/boot/dts/loongson-2k0300.dtsi
+++ b/arch/loongarch/boot/dts/loongson-2k0300.dtsi
@@ -9,6 +9,8 @@
 #include <dt-bindings/clock/loongson,ls2k0300-clk.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 
+#define PINMUX(pin, func)	(((pin) << 8) | func)
+
 / {
 	compatible = "loongson,ls2k0300";
 	#address-cells = <2>;
@@ -55,6 +57,35 @@ clk: clock-controller@16000400 {
 			#clock-cells = <1>;
 		};
 
+		pinctrl: pinctrl@16000490 {
+			compatible = "loongson,ls2k0300-pinctrl";
+			reg = <0x0 0x16000490 0x0 0x20>,
+			      <0x0 0x16000110 0x0 0x4>;
+			reg-names = "mux", "drive";
+
+			func-uart {
+				uart0_pins: uart0-pins {
+					pinmux = <PINMUX(40, 0x3)>,
+						 <PINMUX(41, 0x3)>;
+				};
+
+				uart1_pins: uart1-pins {
+					pinmux = <PINMUX(42, 0x3)>,
+						 <PINMUX(43, 0x3)>;
+				};
+
+				uart2_pins: uart2-pins {
+					pinmux = <PINMUX(44, 0x3)>,
+						 <PINMUX(45, 0x3)>;
+				};
+
+				uart3_pins: uart3-pins {
+					pinmux = <PINMUX(46, 0x3)>,
+						 <PINMUX(47, 0x3)>;
+				};
+			};
+		};
+
 		liointc0: interrupt-controller@16001400 {
 			compatible = "loongson,liointc-2.0";
 			reg = <0x0 0x16001400 0x0 0x40>,
@@ -100,6 +131,8 @@ uart0: serial@16100000 {
 			interrupt-parent = <&liointc0>;
 			interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
 			no-loopback-test;
+			pinctrl-names = "default";
+			pinctrl-0 = <&uart0_pins>;
 			status = "disabled";
 		};
 
@@ -109,6 +142,8 @@ uart1: serial@16100400 {
 			interrupt-parent = <&liointc0>;
 			interrupts = <1 IRQ_TYPE_LEVEL_HIGH>;
 			no-loopback-test;
+			pinctrl-names = "default";
+			pinctrl-0 = <&uart1_pins>;
 			status = "disabled";
 		};
 
@@ -118,6 +153,8 @@ uart2: serial@16100800 {
 			interrupt-parent = <&liointc0>;
 			interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
 			no-loopback-test;
+			pinctrl-names = "default";
+			pinctrl-0 = <&uart2_pins>;
 			status = "disabled";
 		};
 
@@ -127,6 +164,8 @@ uart3: serial@16100c00 {
 			interrupt-parent = <&liointc0>;
 			interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
 			no-loopback-test;
+			pinctrl-names = "default";
+			pinctrl-0 = <&uart3_pins>;
 			status = "disabled";
 		};
 
-- 
2.50.1