linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Support reset controller of Loongson 2K0300 SoC
@ 2025-08-16  3:33 Yao Zi
  2025-08-16  3:33 ` [PATCH 1/3] dt-bindings: reset: Document " Yao Zi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yao Zi @ 2025-08-16  3:33 UTC (permalink / raw)
  To: Philipp Zabel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Huacai Chen, WANG Xuerui
  Cc: devicetree, linux-kernel, loongarch, Mingcong Bai, Kexy Biscuit,
	Yao Zi

Different from previous Loongson SoCs, 2K0300 integrates a reset
controller that provides reset signals represented by contiguous,
distinct register bits for almost every SoC function block. This series
adds its dt-binding and implements its support through reset-simple
driver.

Reset functionalities are tested with UARTs and GPIO module, it's
verified the module won't work with the corresponding reset asserted.

The devicetree patch (PATCH 3) depends on series "Support pinctrl for
Loongson 2K0300 SoC" for a clean apply. Thanks for your time and review.

[1]: https://lore.kernel.org/all/20250811163749.47028-2-ziyao@disroot.org/

Yao Zi (3):
  dt-bindings: reset: Document reset controller of Loongson 2K0300 SoC
  reset: simple: Support Loongson 2K0300 SoC
  LoongArch: dts: Add reset controller for Loongson 2K0300

 .../reset/loongson,ls2k0300-reset.yaml        | 35 ++++++++++
 arch/loongarch/boot/dts/loongson-2k0300.dtsi  | 17 +++++
 drivers/reset/reset-simple.c                  |  2 +
 .../reset/loongson,ls2k0300-reset.h           | 70 +++++++++++++++++++
 4 files changed, 124 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/loongson,ls2k0300-reset.yaml
 create mode 100644 include/dt-bindings/reset/loongson,ls2k0300-reset.h

-- 
2.50.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] dt-bindings: reset: Document reset controller of Loongson 2K0300 SoC
  2025-08-16  3:33 [PATCH 0/3] Support reset controller of Loongson 2K0300 SoC Yao Zi
@ 2025-08-16  3:33 ` Yao Zi
  2025-08-16  9:48   ` Krzysztof Kozlowski
  2025-08-16  3:33 ` [PATCH 2/3] reset: simple: Support " Yao Zi
  2025-08-16  3:33 ` [PATCH 3/3] LoongArch: dts: Add reset controller for Loongson 2K0300 Yao Zi
  2 siblings, 1 reply; 6+ messages in thread
From: Yao Zi @ 2025-08-16  3:33 UTC (permalink / raw)
  To: Philipp Zabel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Huacai Chen, WANG Xuerui
  Cc: devicetree, linux-kernel, loongarch, Mingcong Bai, Kexy Biscuit,
	Yao Zi

Add bindings for the reset controller of Loongson 2K0300 SoC.

Signed-off-by: Yao Zi <ziyao@disroot.org>
---
 .../reset/loongson,ls2k0300-reset.yaml        | 35 ++++++++++
 .../reset/loongson,ls2k0300-reset.h           | 70 +++++++++++++++++++
 2 files changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reset/loongson,ls2k0300-reset.yaml
 create mode 100644 include/dt-bindings/reset/loongson,ls2k0300-reset.h

diff --git a/Documentation/devicetree/bindings/reset/loongson,ls2k0300-reset.yaml b/Documentation/devicetree/bindings/reset/loongson,ls2k0300-reset.yaml
new file mode 100644
index 000000000000..23c90b892673
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/loongson,ls2k0300-reset.yaml
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/reset/loongson,ls2k0300-reset.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson 2K0300 SoC Reset Controller
+
+maintainers:
+  - Yao Zi <ziyao@disroot.org>
+
+properties:
+  compatible:
+    const: loongson,ls2k0300-reset
+
+  reg:
+    maxItems: 1
+
+  "#reset-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - "#reset-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    rst: reset-controller@1600011c {
+        compatible = "loongson,ls2k0300-reset";
+        reg = <0x1600011c 0x8>;
+        #reset-cells = <1>;
+    };
diff --git a/include/dt-bindings/reset/loongson,ls2k0300-reset.h b/include/dt-bindings/reset/loongson,ls2k0300-reset.h
new file mode 100644
index 000000000000..d425411e6d19
--- /dev/null
+++ b/include/dt-bindings/reset/loongson,ls2k0300-reset.h
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
+/*
+ * Copyright (C) 2025 Yao Zi <ziyao@disroot.org>
+ */
+#ifndef _DT_BINDINGS_RESET_LOONGSON_LS2K0300_H_
+#define _DT_BINDINGS_RESET_LOONGSON_LS2K0300_H_
+
+#define RST_DDR			0
+#define RST_SPI0		1
+#define RST_SPI1		2
+#define RST_LIO			3
+#define RST_DC			4
+#define RST_GMAC0		5
+#define RST_GMAC1		6
+#define RST_USBM		7
+#define RST_USB			8
+#define RST_OTG			9
+#define RST_GPIO		10
+#define RST_I2S			11
+#define RST_ADC			12
+#define RST_WDT			13
+#define RST_RTC			14
+#define RST_OTP			15
+#define RST_DMA			16
+#define RST_SPI2		17
+#define RST_SPI3		18
+#define RST_CAN0		19
+#define RST_CAN1		20
+#define RST_CAN2		21
+#define RST_CAN3		22
+#define RST_I2C0		23
+#define RST_I2C1		24
+#define RST_I2C2		25
+#define RST_I2C3		26
+#define RST_HPET0		27
+#define RST_HPET1		28
+#define RST_HPET2		29
+#define RST_HPET3		30
+#define RST_ATIMER		31
+#define RST_GTIMER		32
+#define RST_BTIMER		33
+#define RST_PWM			34
+#define RST_UART0		35
+#define RST_UART1		36
+#define RST_UART2		37
+#define RST_UART3		38
+#define RST_UART4		39
+#define RST_UART5		40
+#define RST_UART6		41
+#define RST_UART7		42
+#define RST_UART8		43
+#define RST_UART9		44
+#define RST_SDIO0		45
+#define RST_SDIO1		46
+#define RST_CANBUF0		47
+#define RST_CANBUF1		48
+#define RST_CANBUF2		49
+#define RST_CANBUF3		50
+#define RST_CANRAM		51
+#define RST_ENCDMA		52
+#define RST_SM2			53
+#define RST_RNG			54
+#define RST_AES			55
+#define RST_DES			56
+#define RST_SM3			57
+#define RST_SM4			58
+#define RST_SDIOM		59
+#define RST_APBM		60
+
+#endif /* _DT_BINDINGS_RESET_LOONGSON_LS2K0300_H_ */
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] reset: simple: Support Loongson 2K0300 SoC
  2025-08-16  3:33 [PATCH 0/3] Support reset controller of Loongson 2K0300 SoC Yao Zi
  2025-08-16  3:33 ` [PATCH 1/3] dt-bindings: reset: Document " Yao Zi
@ 2025-08-16  3:33 ` Yao Zi
  2025-08-16  3:33 ` [PATCH 3/3] LoongArch: dts: Add reset controller for Loongson 2K0300 Yao Zi
  2 siblings, 0 replies; 6+ messages in thread
From: Yao Zi @ 2025-08-16  3:33 UTC (permalink / raw)
  To: Philipp Zabel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Huacai Chen, WANG Xuerui
  Cc: devicetree, linux-kernel, loongarch, Mingcong Bai, Kexy Biscuit,
	Yao Zi

The controller has contiguous distinct control bits for each reset
signal, where setting to low represents reset assertion. Add support for
it through the reset-simple driver.

Signed-off-by: Yao Zi <ziyao@disroot.org>
---
 drivers/reset/reset-simple.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/reset/reset-simple.c b/drivers/reset/reset-simple.c
index 79e94ecfe4f5..03a19d4505e6 100644
--- a/drivers/reset/reset-simple.c
+++ b/drivers/reset/reset-simple.c
@@ -155,6 +155,8 @@ static const struct of_device_id reset_simple_dt_ids[] = {
 		.data = &reset_simple_active_low },
 	{ .compatible = "sophgo,sg2042-reset",
 		.data = &reset_simple_active_low },
+	{ .compatible = "loongson,ls2k0300-reset",
+		.data = &reset_simple_active_low },
 	{ /* sentinel */ },
 };
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] LoongArch: dts: Add reset controller for Loongson 2K0300
  2025-08-16  3:33 [PATCH 0/3] Support reset controller of Loongson 2K0300 SoC Yao Zi
  2025-08-16  3:33 ` [PATCH 1/3] dt-bindings: reset: Document " Yao Zi
  2025-08-16  3:33 ` [PATCH 2/3] reset: simple: Support " Yao Zi
@ 2025-08-16  3:33 ` Yao Zi
  2 siblings, 0 replies; 6+ messages in thread
From: Yao Zi @ 2025-08-16  3:33 UTC (permalink / raw)
  To: Philipp Zabel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Huacai Chen, WANG Xuerui
  Cc: devicetree, linux-kernel, loongarch, Mingcong Bai, Kexy Biscuit,
	Yao Zi

Describe the reset controller and add resets for UART nodes.

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

diff --git a/arch/loongarch/boot/dts/loongson-2k0300.dtsi b/arch/loongarch/boot/dts/loongson-2k0300.dtsi
index a8ad8bd43f5d..835d3c63537b 100644
--- a/arch/loongarch/boot/dts/loongson-2k0300.dtsi
+++ b/arch/loongarch/boot/dts/loongson-2k0300.dtsi
@@ -7,6 +7,7 @@
 /dts-v1/;
 
 #include <dt-bindings/clock/loongson,ls2k0300-clk.h>
+#include <dt-bindings/reset/loongson,ls2k0300-reset.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 
 #define PINMUX(pin, func)	(((pin) << 8) | func)
@@ -50,6 +51,12 @@ soc@10000000 {
 			 <0x00 0x02000000 0x00 0x02000000 0x0 0x04000000>,
 			 <0x00 0x40000000 0x00 0x40000000 0x0 0x40000000>;
 
+		rst: reset-controller@1600011c {
+			compatible = "loongson,ls2k0300-reset";
+			reg = <0x0 0x1600011c 0x0 0x8>;
+			#reset-cells = <1>;
+		};
+
 		clk: clock-controller@16000400 {
 			compatible = "loongson,ls2k0300-clk";
 			reg = <0x0 0x16000400 0x0 0x30>;
@@ -128,6 +135,7 @@ uart0: serial@16100000 {
 			compatible = "ns16550a";
 			reg = <0 0x16100000 0 0x10>;
 			clocks = <&clk LS2K0300_CLK_APB_GATE>;
+			resets = <&rst RST_UART0>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
 			no-loopback-test;
@@ -141,6 +149,7 @@ uart1: serial@16100400 {
 			reg = <0 0x16100400 0 0x10>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <1 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&rst RST_UART1>;
 			no-loopback-test;
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart1_pins>;
@@ -152,6 +161,7 @@ uart2: serial@16100800 {
 			reg = <0 0x16100800 0 0x10>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&rst RST_UART2>;
 			no-loopback-test;
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart2_pins>;
@@ -163,6 +173,7 @@ uart3: serial@16100c00 {
 			reg = <0 0x16100c00 0 0x10>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&rst RST_UART3>;
 			no-loopback-test;
 			pinctrl-names = "default";
 			pinctrl-0 = <&uart3_pins>;
@@ -174,6 +185,7 @@ uart4: serial@16101000 {
 			reg = <0 0x16101000 0 0x10>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&rst RST_UART4>;
 			no-loopback-test;
 			status = "disabled";
 		};
@@ -183,6 +195,7 @@ uart5: serial@16101400 {
 			reg = <0 0x16101400 0 0x10>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&rst RST_UART5>;
 			no-loopback-test;
 			status = "disabled";
 		};
@@ -192,6 +205,7 @@ uart6: serial@16101800 {
 			reg = <0 0x16101800 0 0x10>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <3 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&rst RST_UART6>;
 			no-loopback-test;
 			status = "disabled";
 		};
@@ -201,6 +215,7 @@ uart7: serial@16101c00 {
 			reg = <0 0x16101c00 0 0x10>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <3 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&rst RST_UART7>;
 			no-loopback-test;
 			status = "disabled";
 		};
@@ -210,6 +225,7 @@ uart8: serial@16102000 {
 			reg = <0 0x16102000 0 0x10>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <3 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&rst RST_UART8>;
 			no-loopback-test;
 			status = "disabled";
 		};
@@ -219,6 +235,7 @@ uart9: serial@16102400 {
 			reg = <0 0x16102400 0 0x10>;
 			interrupt-parent = <&liointc0>;
 			interrupts = <3 IRQ_TYPE_LEVEL_HIGH>;
+			resets = <&rst RST_UART9>;
 			no-loopback-test;
 			status = "disabled";
 		};
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] dt-bindings: reset: Document reset controller of Loongson 2K0300 SoC
  2025-08-16  3:33 ` [PATCH 1/3] dt-bindings: reset: Document " Yao Zi
@ 2025-08-16  9:48   ` Krzysztof Kozlowski
  2025-08-16 10:24     ` Yao Zi
  0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-08-16  9:48 UTC (permalink / raw)
  To: Yao Zi, Philipp Zabel, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Huacai Chen, WANG Xuerui
  Cc: devicetree, linux-kernel, loongarch, Mingcong Bai, Kexy Biscuit

On 16/08/2025 05:33, Yao Zi wrote:
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    rst: reset-controller@1600011c {

Drop unused label


> +        compatible = "loongson,ls2k0300-reset";
> +        reg = <0x1600011c 0x8>;
> +        #reset-cells = <1>;
> +    };
> diff --git a/include/dt-bindings/reset/loongson,ls2k0300-reset.h b/include/dt-bindings/reset/loongson,ls2k0300-reset.h
> new file mode 100644
> index 000000000000..d425411e6d19
> --- /dev/null
> +++ b/include/dt-bindings/reset/loongson,ls2k0300-reset.h
> @@ -0,0 +1,70 @@
> +/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */

Why not using same license as the binding?


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] dt-bindings: reset: Document reset controller of Loongson 2K0300 SoC
  2025-08-16  9:48   ` Krzysztof Kozlowski
@ 2025-08-16 10:24     ` Yao Zi
  0 siblings, 0 replies; 6+ messages in thread
From: Yao Zi @ 2025-08-16 10:24 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Philipp Zabel, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Huacai Chen, WANG Xuerui
  Cc: devicetree, linux-kernel, loongarch, Mingcong Bai, Kexy Biscuit

On Sat, Aug 16, 2025 at 11:48:46AM +0200, Krzysztof Kozlowski wrote:
> On 16/08/2025 05:33, Yao Zi wrote:
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +    rst: reset-controller@1600011c {
> 
> Drop unused label
> 
> 
> > +        compatible = "loongson,ls2k0300-reset";
> > +        reg = <0x1600011c 0x8>;
> > +        #reset-cells = <1>;
> > +    };
> > diff --git a/include/dt-bindings/reset/loongson,ls2k0300-reset.h b/include/dt-bindings/reset/loongson,ls2k0300-reset.h
> > new file mode 100644
> > index 000000000000..d425411e6d19
> > --- /dev/null
> > +++ b/include/dt-bindings/reset/loongson,ls2k0300-reset.h
> > @@ -0,0 +1,70 @@
> > +/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
> 
> Why not using same license as the binding?

I was referring to another binding's header when writing this, and yes
it's better to keep them the same.

> 
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Will fix these issues and carry the tag in v2, thanks.

> Best regards,
> Krzysztof

Best regards,
Yao Zi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-16 10:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-16  3:33 [PATCH 0/3] Support reset controller of Loongson 2K0300 SoC Yao Zi
2025-08-16  3:33 ` [PATCH 1/3] dt-bindings: reset: Document " Yao Zi
2025-08-16  9:48   ` Krzysztof Kozlowski
2025-08-16 10:24     ` Yao Zi
2025-08-16  3:33 ` [PATCH 2/3] reset: simple: Support " Yao Zi
2025-08-16  3:33 ` [PATCH 3/3] LoongArch: dts: Add reset controller for Loongson 2K0300 Yao Zi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).