Skip to contentSkip to conversation

riscv: sophgo: cv18xx: dts rework, part 1

PATCH Applied Inochi Amaoto 3 participants 9 messages Apr 30, 2025 – May 13, 2025

Subsystems (3)
lore
Share & tools
lore

Inochi Amaoto

author maintainer
#0 lore raw

cover riscv: sophgo: cv18xx: dts rework, part 1

It is a hard time to maintain cv18xx/sg200x device tree file, as it uses something that dts override, shared peripheral header and something hard to migrate arm64 arch. So it is time to rework the device tree file and reduce potential problems.

The part 1 change mainly focus on the format of the current dts file, and try to make them easy to understand and adpat for the arm64 arch.

Inochi Amaoto (4):
riscv: dts: sophgo: Move all soc specific device into soc dtsi file
riscv: dts: sophgo: Move riscv cpu definition to a separate file
riscv: dts: sophgo: rename header file cv18xx.dtsi to cv180x.dtsi
riscv: dts: sopgho: use SOC_PERIPHERAL_IRQ to calculate interrupt
number

 arch/riscv/boot/dts/sophgo/cv1800b.dtsi       | 43 ++++++---
 arch/riscv/boot/dts/sophgo/cv180x-cpus.dtsi   | 36 +++++++
 .../dts/sophgo/{cv18xx.dtsi => cv180x.dtsi}   | 95 +++++--------------
 arch/riscv/boot/dts/sophgo/cv1812h.dtsi       | 43 ++++++---
 arch/riscv/boot/dts/sophgo/cv181x.dtsi        |  2 +-
 arch/riscv/boot/dts/sophgo/sg2002.dtsi        | 43 ++++++---
 6 files changed, 149 insertions(+), 113 deletions(-)
 create mode 100644 arch/riscv/boot/dts/sophgo/cv180x-cpus.dtsi
 rename arch/riscv/boot/dts/sophgo/{cv18xx.dtsi => cv180x.dtsi} (75%)

--
2.49.0

author maintainer
#1 lore raw

PATCH 1/4 riscv: dts: sophgo: Move all soc specific device into soc dtsi file

Although the cv1800b/cv1812h/sg2000/sg2002 share most peripherals, some basic peripherals, like clock, pinctrl, clint and plint, are not shared. These are caused by not only historical reason (plic, clint), but also the fact the device is not the same (clock, pinctrl).

It is good to override device compatible when the soc number is small, but now it is a burden for maintenance, and it is kind of annoyed to explain why using override. So it is time to move this out of the common peripheral header.

Move all soc related peripherla device from common peripheral header to the soc specific header to get rid of most compatible override.

---
 arch/riscv/boot/dts/sophgo/cv1800b.dtsi | 38 +++++++++++++++++--------
 arch/riscv/boot/dts/sophgo/cv1812h.dtsi | 38 +++++++++++++++++--------
 arch/riscv/boot/dts/sophgo/cv18xx.dtsi  | 22 --------------
 arch/riscv/boot/dts/sophgo/sg2002.dtsi  | 38 +++++++++++++++++--------
 4 files changed, 78 insertions(+), 58 deletions(-)
arch/riscv/boot/dts/sophgo/cv1800b.dtsi +26 -12
index aa1f5df100f0..fc9e6b56790f 100644
@@ -15,23 +15,37 @@ memory@80000000 {
 	};
 
 	soc {
+		interrupt-parent = <&plic>;
+		dma-noncoherent;
+
 		pinctrl: pinctrl@3001000 {
 			compatible = "sophgo,cv1800b-pinctrl";
 			reg = <0x03001000 0x1000>,
 			      <0x05027000 0x1000>;
 			reg-names = "sys", "rtc";
 		};
+
+		clk: clock-controller@3002000 {
+			compatible = "sophgo,cv1800-clk";
+			reg = <0x03002000 0x1000>;
+			clocks = <&osc>;
+			#clock-cells = <1>;
+		};
+
+		plic: interrupt-controller@70000000 {
+			compatible = "sophgo,cv1800b-plic", "thead,c900-plic";
+			reg = <0x70000000 0x4000000>;
+			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <2>;
+			riscv,ndev = <101>;
+		};
+
+		clint: timer@74000000 {
+			compatible = "sophgo,cv1800b-clint", "thead,c900-clint";
+			reg = <0x74000000 0x10000>;
+			interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
+		};
 	};
 };
-
-&plic {
-	compatible = "sophgo,cv1800b-plic", "thead,c900-plic";
-};
-
-&clint {
-	compatible = "sophgo,cv1800b-clint", "thead,c900-clint";
-};
-
-&clk {
-	compatible = "sophgo,cv1800-clk";
-};
arch/riscv/boot/dts/sophgo/cv1812h.dtsi +26 -12
index 8a1b95c5116b..fcea4376fb79 100644
@@ -17,23 +17,37 @@ memory@80000000 {
 	};
 
 	soc {
+		interrupt-parent = <&plic>;
+		dma-noncoherent;
+
 		pinctrl: pinctrl@3001000 {
 			compatible = "sophgo,cv1812h-pinctrl";
 			reg = <0x03001000 0x1000>,
 			      <0x05027000 0x1000>;
 			reg-names = "sys", "rtc";
 		};
+
+		clk: clock-controller@3002000 {
+			compatible = "sophgo,cv1810-clk";
+			reg = <0x03002000 0x1000>;
+			clocks = <&osc>;
+			#clock-cells = <1>;
+		};
+
+		plic: interrupt-controller@70000000 {
+			compatible = "sophgo,cv1812h-plic", "thead,c900-plic";
+			reg = <0x70000000 0x4000000>;
+			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <2>;
+			riscv,ndev = <101>;
+		};
+
+		clint: timer@74000000 {
+			compatible = "sophgo,cv1812h-clint", "thead,c900-clint";
+			reg = <0x74000000 0x10000>;
+			interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
+		};
 	};
 };
-
-&plic {
-	compatible = "sophgo,cv1812h-plic", "thead,c900-plic";
-};
-
-&clint {
-	compatible = "sophgo,cv1812h-clint", "thead,c900-clint";
-};
-
-&clk {
-	compatible = "sophgo,cv1810-clk";
-};
arch/riscv/boot/dts/sophgo/cv18xx.dtsi +0 -22
index c18822ec849f..805b694aa814 100644
@@ -49,18 +49,10 @@ osc: oscillator {
 
 	soc {
 		compatible = "simple-bus";
-		interrupt-parent = <&plic>;
 		#address-cells = <1>;
 		#size-cells = <1>;
-		dma-noncoherent;
 		ranges;
 
-		clk: clock-controller@3002000 {
-			reg = <0x03002000 0x1000>;
-			clocks = <&osc>;
-			#clock-cells = <1>;
-		};
-
 		gpio0: gpio@3020000 {
 			compatible = "snps,dw-apb-gpio";
 			reg = <0x3020000 0x1000>;
@@ -344,19 +336,5 @@ dmac: dma-controller@4330000 {
 			snps,data-width = <4>;
 			status = "disabled";
 		};
-
-		plic: interrupt-controller@70000000 {
-			reg = <0x70000000 0x4000000>;
-			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
-			interrupt-controller;
-			#address-cells = <0>;
-			#interrupt-cells = <2>;
-			riscv,ndev = <101>;
-		};
-
-		clint: timer@74000000 {
-			reg = <0x74000000 0x10000>;
-			interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
-		};
 	};
 };
arch/riscv/boot/dts/sophgo/sg2002.dtsi +26 -12
index 7f79de33163c..df133831bd3e 100644
@@ -17,27 +17,41 @@ memory@80000000 {
 	};
 
 	soc {
+		interrupt-parent = <&plic>;
+		dma-noncoherent;
+
 		pinctrl: pinctrl@3001000 {
 			compatible = "sophgo,sg2002-pinctrl";
 			reg = <0x03001000 0x1000>,
 			      <0x05027000 0x1000>;
 			reg-names = "sys", "rtc";
 		};
+
+		clk: clock-controller@3002000 {
+			compatible = "sophgo,sg2000-clk";
+			reg = <0x03002000 0x1000>;
+			clocks = <&osc>;
+			#clock-cells = <1>;
+		};
+
+		plic: interrupt-controller@70000000 {
+			compatible = "sophgo,sg2002-plic", "thead,c900-plic";
+			reg = <0x70000000 0x4000000>;
+			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <2>;
+			riscv,ndev = <101>;
+		};
+
+		clint: timer@74000000 {
+			compatible = "sophgo,sg2002-clint", "thead,c900-clint";
+			reg = <0x74000000 0x10000>;
+			interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
+		};
 	};
 };
 
-&plic {
-	compatible = "sophgo,sg2002-plic", "thead,c900-plic";
-};
-
-&clint {
-	compatible = "sophgo,sg2002-clint", "thead,c900-clint";
-};
-
-&clk {
-	compatible = "sophgo,sg2000-clk";
-};
-
 &sdhci0 {
 	compatible = "sophgo,sg2002-dwcmshc";
 };
Signature · 1 line
2.49.0
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] riscv: dts: sophgo: Move all soc specific device into soc dtsi file

Hi Inochi!

Quoted 10 lines · Inochi Amaoto

Although the cv1800b/cv1812h/sg2000/sg2002 share most peripherals, some basic peripherals, like clock, pinctrl, clint and plint, are not shared. These are caused by not only historical reason (plic, clint), but also the fact the device is not the same (clock, pinctrl).

It is good to override device compatible when the soc number is small, but now it is a burden for maintenance, and it is kind of annoyed to explain why using override. So it is time to move this out of the common peripheral header.

Quoted 4 lines

Move all soc related peripherla device from common peripheral header to the soc specific header to get rid of most compatible override.

Quoted 6 lines

---
 arch/riscv/boot/dts/sophgo/cv1800b.dtsi | 38 +++++++++++++++++-------- arch/riscv/boot/dts/sophgo/cv1812h.dtsi | 38 +++++++++++++++++-------- arch/riscv/boot/dts/sophgo/cv18xx.dtsi  | 22 -------------- arch/riscv/boot/dts/sophgo/sg2002.dtsi  | 38 +++++++++++++++++--------

 4 files changed, 78 insertions(+), 58 deletions(-)
Signature · 1 line
Alexander Sverdlin.
Reviewed-by on v1 1/4
#3 lore raw

Re: [PATCH 1/4] riscv: dts: sophgo: Move all soc specific device into soc dtsi file

In reply to Inochi Amaoto
Quoted 6 lines · Inochi Amaoto

Although the cv1800b/cv1812h/sg2000/sg2002 share most peripherals, some basic peripherals, like clock, pinctrl, clint and plint, are not shared. These are caused by not only historical reason (plic, clint), but also the fact the device is not the same (clock, pinctrl).

It is good to override device compatible when the soc number is small,

~~~SoC, we usually

Quoted 5 lines

but now it is a burden for maintenance, and it is kind of annoyed to explain why using override. So it is time to move this out of the common peripheral header.

Move all soc related peripherla device from common peripheral header

                       ~~~~~~~~~~typo, peripheral
Quoted 3 lines

to the soc specific header to get rid of most compatible override.

otherwise, looks good

Quoted 219 lines
---
 arch/riscv/boot/dts/sophgo/cv1800b.dtsi | 38 +++++++++++++++++--------
 arch/riscv/boot/dts/sophgo/cv1812h.dtsi | 38 +++++++++++++++++--------
 arch/riscv/boot/dts/sophgo/cv18xx.dtsi  | 22 --------------
 arch/riscv/boot/dts/sophgo/sg2002.dtsi  | 38 +++++++++++++++++--------
 4 files changed, 78 insertions(+), 58 deletions(-)
arch/riscv/boot/dts/sophgo/cv1800b.dtsi +26 -12
index aa1f5df100f0..fc9e6b56790f 100644
@@ -15,23 +15,37 @@ memory@80000000 {
 	};
 
 	soc {
+		interrupt-parent = <&plic>;
+		dma-noncoherent;
+
 		pinctrl: pinctrl@3001000 {
 			compatible = "sophgo,cv1800b-pinctrl";
 			reg = <0x03001000 0x1000>,
 			      <0x05027000 0x1000>;
 			reg-names = "sys", "rtc";
 		};
+
+		clk: clock-controller@3002000 {
+			compatible = "sophgo,cv1800-clk";
+			reg = <0x03002000 0x1000>;
+			clocks = <&osc>;
+			#clock-cells = <1>;
+		};
+
+		plic: interrupt-controller@70000000 {
+			compatible = "sophgo,cv1800b-plic", "thead,c900-plic";
+			reg = <0x70000000 0x4000000>;
+			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <2>;
+			riscv,ndev = <101>;
+		};
+
+		clint: timer@74000000 {
+			compatible = "sophgo,cv1800b-clint", "thead,c900-clint";
+			reg = <0x74000000 0x10000>;
+			interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
+		};
 	};
 };
-
-&plic {
-	compatible = "sophgo,cv1800b-plic", "thead,c900-plic";
-};
-
-&clint {
-	compatible = "sophgo,cv1800b-clint", "thead,c900-clint";
-};
-
-&clk {
-	compatible = "sophgo,cv1800-clk";
-};
arch/riscv/boot/dts/sophgo/cv1812h.dtsi +26 -12
index 8a1b95c5116b..fcea4376fb79 100644
@@ -17,23 +17,37 @@ memory@80000000 {
 	};
 
 	soc {
+		interrupt-parent = <&plic>;
+		dma-noncoherent;
+
 		pinctrl: pinctrl@3001000 {
 			compatible = "sophgo,cv1812h-pinctrl";
 			reg = <0x03001000 0x1000>,
 			      <0x05027000 0x1000>;
 			reg-names = "sys", "rtc";
 		};
+
+		clk: clock-controller@3002000 {
+			compatible = "sophgo,cv1810-clk";
+			reg = <0x03002000 0x1000>;
+			clocks = <&osc>;
+			#clock-cells = <1>;
+		};
+
+		plic: interrupt-controller@70000000 {
+			compatible = "sophgo,cv1812h-plic", "thead,c900-plic";
+			reg = <0x70000000 0x4000000>;
+			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <2>;
+			riscv,ndev = <101>;
+		};
+
+		clint: timer@74000000 {
+			compatible = "sophgo,cv1812h-clint", "thead,c900-clint";
+			reg = <0x74000000 0x10000>;
+			interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
+		};
 	};
 };
-
-&plic {
-	compatible = "sophgo,cv1812h-plic", "thead,c900-plic";
-};
-
-&clint {
-	compatible = "sophgo,cv1812h-clint", "thead,c900-clint";
-};
-
-&clk {
-	compatible = "sophgo,cv1810-clk";
-};
arch/riscv/boot/dts/sophgo/cv18xx.dtsi +0 -22
index c18822ec849f..805b694aa814 100644
@@ -49,18 +49,10 @@ osc: oscillator {
 
 	soc {
 		compatible = "simple-bus";
-		interrupt-parent = <&plic>;
 		#address-cells = <1>;
 		#size-cells = <1>;
-		dma-noncoherent;
 		ranges;
 
-		clk: clock-controller@3002000 {
-			reg = <0x03002000 0x1000>;
-			clocks = <&osc>;
-			#clock-cells = <1>;
-		};
-
 		gpio0: gpio@3020000 {
 			compatible = "snps,dw-apb-gpio";
 			reg = <0x3020000 0x1000>;
@@ -344,19 +336,5 @@ dmac: dma-controller@4330000 {
 			snps,data-width = <4>;
 			status = "disabled";
 		};
-
-		plic: interrupt-controller@70000000 {
-			reg = <0x70000000 0x4000000>;
-			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
-			interrupt-controller;
-			#address-cells = <0>;
-			#interrupt-cells = <2>;
-			riscv,ndev = <101>;
-		};
-
-		clint: timer@74000000 {
-			reg = <0x74000000 0x10000>;
-			interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
-		};
 	};
 };
arch/riscv/boot/dts/sophgo/sg2002.dtsi +26 -12
index 7f79de33163c..df133831bd3e 100644
@@ -17,27 +17,41 @@ memory@80000000 {
 	};
 
 	soc {
+		interrupt-parent = <&plic>;
+		dma-noncoherent;
+
 		pinctrl: pinctrl@3001000 {
 			compatible = "sophgo,sg2002-pinctrl";
 			reg = <0x03001000 0x1000>,
 			      <0x05027000 0x1000>;
 			reg-names = "sys", "rtc";
 		};
+
+		clk: clock-controller@3002000 {
+			compatible = "sophgo,sg2000-clk";
+			reg = <0x03002000 0x1000>;
+			clocks = <&osc>;
+			#clock-cells = <1>;
+		};
+
+		plic: interrupt-controller@70000000 {
+			compatible = "sophgo,sg2002-plic", "thead,c900-plic";
+			reg = <0x70000000 0x4000000>;
+			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
+			interrupt-controller;
+			#address-cells = <0>;
+			#interrupt-cells = <2>;
+			riscv,ndev = <101>;
+		};
+
+		clint: timer@74000000 {
+			compatible = "sophgo,sg2002-clint", "thead,c900-clint";
+			reg = <0x74000000 0x10000>;
+			interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
+		};
 	};
 };
 
-&plic {
-	compatible = "sophgo,sg2002-plic", "thead,c900-plic";
-};
-
-&clint {
-	compatible = "sophgo,sg2002-clint", "thead,c900-clint";
-};
-
-&clk {
-	compatible = "sophgo,sg2000-clk";
-};
-
 &sdhci0 {
 	compatible = "sophgo,sg2002-dwcmshc";
 };
Signature · 1 line
2.49.0
Signature · 1 line
Yixun Lan (dlan)
author maintainer
#4 lore raw

PATCH 2/4 riscv: dts: sophgo: Move riscv cpu definition to a separate file

In reply to Inochi Amaoto

As sg2000 and sg2002 can boot from an arm a53 core, it is not suitable to left the riscv cpu definition in the common peripheral header.

Move the riscv related device into a separate header file, so the arm subsystem can reuse the common peripheral header.

---
 arch/riscv/boot/dts/sophgo/cv1800b.dtsi     |  1 +
 arch/riscv/boot/dts/sophgo/cv180x-cpus.dtsi | 36 +++++++++++++++++++++
 arch/riscv/boot/dts/sophgo/cv1812h.dtsi     |  1 +
 arch/riscv/boot/dts/sophgo/cv18xx.dtsi      | 29 -----------------
 arch/riscv/boot/dts/sophgo/sg2002.dtsi      |  1 +
 5 files changed, 39 insertions(+), 29 deletions(-)
 create mode 100644 arch/riscv/boot/dts/sophgo/cv180x-cpus.dtsi
arch/riscv/boot/dts/sophgo/cv1800b.dtsi +1 -0
index fc9e6b56790f..91bf4563e1f9 100644
@@ -4,6 +4,7 @@
  */
 
 #include <dt-bindings/pinctrl/pinctrl-cv1800b.h>
+#include "cv180x-cpus.dtsi"
 #include "cv18xx.dtsi"
 
 / {
arch/riscv/boot/dts/sophgo/cv180x-cpus.dtsi new file +36 -0
new file mode 100644
index 000000000000..93fd9e47a195
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2023 Jisheng Zhang <[email protected]>
+ * Copyright (C) 2023 Inochi Amaoto <[email protected]>
+ */
+
+/ {
+	cpus: cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		timebase-frequency = <25000000>;
+
+		cpu0: cpu@0 {
+			compatible = "thead,c906", "riscv";
+			device_type = "cpu";
+			reg = <0>;
+			d-cache-block-size = <64>;
+			d-cache-sets = <512>;
+			d-cache-size = <65536>;
+			i-cache-block-size = <64>;
+			i-cache-sets = <128>;
+			i-cache-size = <32768>;
+			mmu-type = "riscv,sv39";
+			riscv,isa = "rv64imafdc";
+			riscv,isa-base = "rv64i";
+			riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
+					       "zifencei", "zihpm";
+
+			cpu0_intc: interrupt-controller {
+				compatible = "riscv,cpu-intc";
+				interrupt-controller;
+				#interrupt-cells = <1>;
+			};
+		};
+	};
+};
arch/riscv/boot/dts/sophgo/cv1812h.dtsi +1 -0
index fcea4376fb79..cc094b3f585f 100644
@@ -5,6 +5,7 @@
 
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/pinctrl-cv1812h.h>
+#include "cv180x-cpus.dtsi"
 #include "cv18xx.dtsi"
 #include "cv181x.dtsi"
 
arch/riscv/boot/dts/sophgo/cv18xx.dtsi +0 -29
index 805b694aa814..a4f957302094 100644
@@ -12,35 +12,6 @@ / {
 	#address-cells = <1>;
 	#size-cells = <1>;
 
-	cpus: cpus {
-		#address-cells = <1>;
-		#size-cells = <0>;
-		timebase-frequency = <25000000>;
-
-		cpu0: cpu@0 {
-			compatible = "thead,c906", "riscv";
-			device_type = "cpu";
-			reg = <0>;
-			d-cache-block-size = <64>;
-			d-cache-sets = <512>;
-			d-cache-size = <65536>;
-			i-cache-block-size = <64>;
-			i-cache-sets = <128>;
-			i-cache-size = <32768>;
-			mmu-type = "riscv,sv39";
-			riscv,isa = "rv64imafdc";
-			riscv,isa-base = "rv64i";
-			riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
-					       "zifencei", "zihpm";
-
-			cpu0_intc: interrupt-controller {
-				compatible = "riscv,cpu-intc";
-				interrupt-controller;
-				#interrupt-cells = <1>;
-			};
-		};
-	};
-
 	osc: oscillator {
 		compatible = "fixed-clock";
 		clock-output-names = "osc_25m";
arch/riscv/boot/dts/sophgo/sg2002.dtsi +1 -0
index df133831bd3e..6f02de9b0982 100644
@@ -5,6 +5,7 @@
 
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/pinctrl-sg2002.h>
+#include "cv180x-cpus.dtsi"
 #include "cv18xx.dtsi"
 #include "cv181x.dtsi"
 
Signature · 1 line
2.49.0
author maintainer
#5 lore raw

PATCH 3/4 riscv: dts: sophgo: rename header file cv18xx.dtsi to cv180x.dtsi

In reply to Inochi Amaoto

As the cv18xx.dtsi serves as a common peripheral header for all riscv cv180x/cv181x/sg200x SoCs, it not cover the entire cv18xx series as there is cv182x and cv183x. So rename the header file to make it precise.

---
 arch/riscv/boot/dts/sophgo/cv1800b.dtsi                 | 2 +-
 arch/riscv/boot/dts/sophgo/{cv18xx.dtsi => cv180x.dtsi} | 0
 arch/riscv/boot/dts/sophgo/cv1812h.dtsi                 | 2 +-
 arch/riscv/boot/dts/sophgo/sg2002.dtsi                  | 2 +-
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename arch/riscv/boot/dts/sophgo/{cv18xx.dtsi => cv180x.dtsi} (100%)
arch/riscv/boot/dts/sophgo/cv1800b.dtsi +1 -1
index 91bf4563e1f9..d0a627c086fb 100644
@@ -5,7 +5,7 @@
 
 #include <dt-bindings/pinctrl/pinctrl-cv1800b.h>
 #include "cv180x-cpus.dtsi"
-#include "cv18xx.dtsi"
+#include "cv180x.dtsi"
 
 / {
 	compatible = "sophgo,cv1800b";
arch/riscv/boot/dts/sophgo/cv180x.dtsi renamed from arch/riscv/boot/dts/sophgo/cv18xx.dtsi +0 -0
similarity index 100%
rename from arch/riscv/boot/dts/sophgo/cv18xx.dtsi
rename to arch/riscv/boot/dts/sophgo/cv180x.dtsi
arch/riscv/boot/dts/sophgo/cv1812h.dtsi +1 -1
index cc094b3f585f..d9580a2e1e7f 100644
@@ -6,7 +6,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/pinctrl-cv1812h.h>
 #include "cv180x-cpus.dtsi"
-#include "cv18xx.dtsi"
+#include "cv180x.dtsi"
 #include "cv181x.dtsi"
 
 / {
arch/riscv/boot/dts/sophgo/sg2002.dtsi +1 -1
index 6f02de9b0982..60709df12a22 100644
@@ -6,7 +6,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/pinctrl-sg2002.h>
 #include "cv180x-cpus.dtsi"
-#include "cv18xx.dtsi"
+#include "cv180x.dtsi"
 #include "cv181x.dtsi"
 
 / {
Signature · 1 line
2.49.0
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] riscv: dts: sophgo: rename header file cv18xx.dtsi to cv180x.dtsi

Hi Inochi!

Quoted 2 lines · Inochi Amaoto

As the cv18xx.dtsi serves as a common peripheral header for all riscv cv180x/cv181x/sg200x SoCs, it not cover the entire cv18xx

                                     ^
                                      does
Quoted 4 lines

series as there is cv182x and cv183x. So rename the header file to make it precise.

Quoted 7 lines

---
 arch/riscv/boot/dts/sophgo/cv1800b.dtsi                 | 2 +- arch/riscv/boot/dts/sophgo/{cv18xx.dtsi => cv180x.dtsi} | 0 arch/riscv/boot/dts/sophgo/cv1812h.dtsi                 | 2 +- arch/riscv/boot/dts/sophgo/sg2002.dtsi                  | 2 +-

 4 files changed, 3 insertions(+), 3 deletions(-)

 rename arch/riscv/boot/dts/sophgo/{cv18xx.dtsi => cv180x.dtsi} (100%)

Signature · 1 line
Alexander Sverdlin.
author maintainer
#7 lore raw

PATCH 4/4 riscv: dts: sopgho: use SOC_PERIPHERAL_IRQ to calculate interrupt number

In reply to Inochi Amaoto

Since riscv and arm architecture use different interrupt definitions, use a macro SOC_PERIPHERAL_IRQ mask this difference.

---
 arch/riscv/boot/dts/sophgo/cv1800b.dtsi |  2 ++
 arch/riscv/boot/dts/sophgo/cv180x.dtsi  | 44 ++++++++++++-------------
 arch/riscv/boot/dts/sophgo/cv1812h.dtsi |  2 ++
 arch/riscv/boot/dts/sophgo/cv181x.dtsi  |  2 +-
 arch/riscv/boot/dts/sophgo/sg2002.dtsi  |  2 ++
 5 files changed, 29 insertions(+), 23 deletions(-)
arch/riscv/boot/dts/sophgo/cv1800b.dtsi +2 -0
index d0a627c086fb..88707cc13fb4 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2023 Jisheng Zhang <[email protected]>
  */
 
+#define SOC_PERIPHERAL_IRQ(nr)	((nr) + 16)
+
 #include <dt-bindings/pinctrl/pinctrl-cv1800b.h>
 #include "cv180x-cpus.dtsi"
 #include "cv180x.dtsi"
arch/riscv/boot/dts/sophgo/cv180x.dtsi +22 -22

176 lines not on this page · raw message

arch/riscv/boot/dts/sophgo/cv1812h.dtsi +2 -0
index d9580a2e1e7f..0974955e4e05 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2023 Inochi Amaoto <[email protected]>
  */
 
+#define SOC_PERIPHERAL_IRQ(nr)	((nr) + 16)
+
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/pinctrl-cv1812h.h>
 #include "cv180x-cpus.dtsi"
arch/riscv/boot/dts/sophgo/cv181x.dtsi +1 -1
index 5fd14dd1b14f..bbdb30653e9a 100644
@@ -11,7 +11,7 @@ soc {
 		emmc: mmc@4300000 {
 			compatible = "sophgo,cv1800b-dwcmshc";
 			reg = <0x4300000 0x1000>;
-			interrupts = <34 IRQ_TYPE_LEVEL_HIGH>;
+			interrupts = <SOC_PERIPHERAL_IRQ(18) IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&clk CLK_AXI4_EMMC>,
 				 <&clk CLK_EMMC>;
 			clock-names = "core", "bus";
arch/riscv/boot/dts/sophgo/sg2002.dtsi +2 -0
index 60709df12a22..6f09c9199102 100644
@@ -3,6 +3,8 @@
  * Copyright (C) 2024 Thomas Bonnefille <[email protected]>
  */
 
+#define SOC_PERIPHERAL_IRQ(nr)	((nr) + 16)
+
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/pinctrl-sg2002.h>
 #include "cv180x-cpus.dtsi"
Signature · 1 line
2.49.0
author maintainer Applied
#8 lore raw
In reply to Inochi Amaoto
Quoted 10 lines · Inochi Amaoto

It is a hard time to maintain cv18xx/sg200x device tree file, as it uses something that dts override, shared peripheral header and something hard to migrate arm64 arch. So it is time to rework the device tree file and reduce potential problems.

The part 1 change mainly focus on the format of the current dts file, and try to make them easy to understand and adpat for the arm64 arch.

[...]

Applied to for-next, thanks!

[1/4] riscv: dts: sophgo: Move all soc specific device into soc dtsi file

      https://github.com/sophgo/linux/commit/e07daed2a1577ec5b9eafcfa0b690d4082661024
[2/4] riscv: dts: sophgo: Move riscv cpu definition to a separate file
      https://github.com/sophgo/linux/commit/4f6d5f22f94db169b58809de57db2fe95ce3fa35
[3/4] riscv: dts: sophgo: rename header file cv18xx.dtsi to cv180x.dtsi
      https://github.com/sophgo/linux/commit/4a7f2bba7bdb2d3afbca8d40268503d32868c325
[4/4] riscv: dts: sopgho: use SOC_PERIPHERAL_IRQ to calculate interrupt number
      https://github.com/sophgo/linux/commit/53cf91b37246948935de7147d09ae6a98070400f

Thanks,
Inochi