All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 01/11] clk: sophgo: cv1800b: Add SoC-specific compatible strings
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
@ 2026-09-22 14:59 ` Zhuxu Ran
  2026-09-22 14:59 ` [PATCH v4 02/11] mmc: cv1800b: Add SG2002 compatible string Zhuxu Ran
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 14:59 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Tim Ouyang,
	Leo Liang, Thomas Bonnefille, Guodong Xu, Quentin Schulz,
	Johan Jonker, Casey Connolly, Varadarajan Narayanan,
	Alexander Koch, Andreas Schwab, Junhui Liu, Marek Vasut,
	Sumit Garg, Peter Robinson, Ilias Apalodimas

The upstream CV1800B and SG2002 devicetrees use
"sophgo,cv1800b-clk" and "sophgo,sg2002-clk" respectively.

Add both compatible strings to the existing CV1800B clock driver.

Reviewed-by: Leo Yu-Chi Liang <leo.liang@sifive.com>
Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
---
 drivers/clk/sophgo/clk-cv1800b.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/sophgo/clk-cv1800b.c b/drivers/clk/sophgo/clk-cv1800b.c
index 248a69321fc..57051c1ec0a 100644
--- a/drivers/clk/sophgo/clk-cv1800b.c
+++ b/drivers/clk/sophgo/clk-cv1800b.c
@@ -744,6 +744,8 @@ const struct clk_ops cv1800b_clk_ops = {
 
 static const struct udevice_id cv1800b_clk_of_match[] = {
 	{ .compatible = "sophgo,cv1800-clk" },
+	{ .compatible = "sophgo,cv1800b-clk" },
+	{ .compatible = "sophgo,sg2002-clk" },
 	{ },
 };
 

-- 
2.55.0


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

* [PATCH v4 02/11] mmc: cv1800b: Add SG2002 compatible string
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
  2026-09-22 14:59 ` [PATCH v4 01/11] clk: sophgo: cv1800b: Add SoC-specific compatible strings Zhuxu Ran
@ 2026-09-22 14:59 ` Zhuxu Ran
  2026-09-22 14:59 ` [PATCH v4 03/11] dt-bindings: soc: sophgo: add Milk-V Duo 256M board Zhuxu Ran
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 14:59 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Tim Ouyang,
	Leo Liang, Thomas Bonnefille, Guodong Xu, Quentin Schulz,
	Johan Jonker, Casey Connolly, Varadarajan Narayanan,
	Alexander Koch, Andreas Schwab, Junhui Liu, Marek Vasut,
	Sumit Garg, Peter Robinson, Ilias Apalodimas

The upstream SG2002 devicetree uses "sophgo,sg2002-dwcmshc"
for the SDHCI controller.

Add the compatible string to the existing CV1800B SDHCI driver.

Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
---
 drivers/mmc/cv1800b_sdhci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/cv1800b_sdhci.c b/drivers/mmc/cv1800b_sdhci.c
index b756649f90f..f8d94232170 100644
--- a/drivers/mmc/cv1800b_sdhci.c
+++ b/drivers/mmc/cv1800b_sdhci.c
@@ -110,6 +110,7 @@ static int cv1800b_sdhci_probe(struct udevice *dev)
 
 static const struct udevice_id cv1800b_sdhci_match[] = {
 	{ .compatible = "sophgo,cv1800b-dwcmshc" },
+	{ .compatible = "sophgo,sg2002-dwcmshc" },
 	{ }
 };
 

-- 
2.55.0


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

* [PATCH v4 03/11] dt-bindings: soc: sophgo: add Milk-V Duo 256M board
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
  2026-09-22 14:59 ` [PATCH v4 01/11] clk: sophgo: cv1800b: Add SoC-specific compatible strings Zhuxu Ran
  2026-09-22 14:59 ` [PATCH v4 02/11] mmc: cv1800b: Add SG2002 compatible string Zhuxu Ran
@ 2026-09-22 14:59 ` Zhuxu Ran
  2026-09-22 14:59 ` [PATCH v4 04/11] riscv: dts: sophgo: cv180x: Add PWR_GPIO controller Zhuxu Ran
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 14:59 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Tim Ouyang,
	Leo Liang, Thomas Bonnefille, Guodong Xu, Quentin Schulz,
	Johan Jonker, Casey Connolly, Varadarajan Narayanan,
	Alexander Koch, Andreas Schwab, Junhui Liu, Marek Vasut,
	Sumit Garg, Peter Robinson, Ilias Apalodimas

From: Chen-Yu Yeh <chenyou910331@gmail.com>

Add compatible string for the Milk-V Duo 256M board.

Signed-off-by: Chen-Yu Yeh <chenyou910331@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20260725175346.139173-2-chenyou910331@gmail.com
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Chen Wang <chen.wang@linux.dev>

[ upstream commit: 06c236909705fcc92f59b0f2dd05a45b22902769 ]

(cherry picked from commit 39c49b7fc7a33b3af1c6fd80e599bd7d6db947be)
---
 dts/upstream/Bindings/soc/sophgo/sophgo.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/dts/upstream/Bindings/soc/sophgo/sophgo.yaml b/dts/upstream/Bindings/soc/sophgo/sophgo.yaml
index 1c502618de5..fcb1d905da7 100644
--- a/dts/upstream/Bindings/soc/sophgo/sophgo.yaml
+++ b/dts/upstream/Bindings/soc/sophgo/sophgo.yaml
@@ -31,6 +31,10 @@ properties:
               - milkv,duo-module-01-evb
           - const: milkv,duo-module-01
           - const: sophgo,sg2000
+      - items:
+          - enum:
+              - milkv,duo256m
+          - const: sophgo,sg2002
       - items:
           - enum:
               - sipeed,licheerv-nano-b

-- 
2.55.0


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

* [PATCH v4 04/11] riscv: dts: sophgo: cv180x: Add PWR_GPIO controller
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
                   ` (2 preceding siblings ...)
  2026-09-22 14:59 ` [PATCH v4 03/11] dt-bindings: soc: sophgo: add Milk-V Duo 256M board Zhuxu Ran
@ 2026-09-22 14:59 ` Zhuxu Ran
  2026-09-22 14:59 ` [PATCH v4 05/11] riscv: dts: sophgo: Add Milk-V Duo 256M board support Zhuxu Ran
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 14:59 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Tim Ouyang,
	Leo Liang, Thomas Bonnefille, Guodong Xu, Quentin Schulz,
	Johan Jonker, Casey Connolly, Varadarajan Narayanan,
	Alexander Koch, Andreas Schwab, Junhui Liu, Marek Vasut,
	Sumit Garg, Peter Robinson, Ilias Apalodimas

From: Chen-Yu Yeh <chenyou910331@gmail.com>

The CV180x/CV181x family has an additional DesignWare APB GPIO
controller (PWR_GPIO) located in the always-on power domain at
0x5021000. Add the node so that boards can reference GPIOs in this
bank, such as status LEDs.

Signed-off-by: Chen-Yu Yeh <chenyou910331@gmail.com>
Link: https://patch.msgid.link/20260725175346.139173-3-chenyou910331@gmail.com
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Chen Wang <chen.wang@linux.dev>

[ upstream commit: 76237a509a0e91665c4d9c96b72a78ec66ea3fe4 ]

(cherry picked from commit dc28678310443c294191632f6ec175a62d53e767)
---
 dts/upstream/src/riscv/sophgo/cv180x.dtsi | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/dts/upstream/src/riscv/sophgo/cv180x.dtsi b/dts/upstream/src/riscv/sophgo/cv180x.dtsi
index 06b0ce5a2db..8bf67ee4eca 100644
--- a/dts/upstream/src/riscv/sophgo/cv180x.dtsi
+++ b/dts/upstream/src/riscv/sophgo/cv180x.dtsi
@@ -448,6 +448,24 @@
 			status = "disabled";
 		};
 
+		gpio4: gpio@5021000 {
+			compatible = "snps,dw-apb-gpio";
+			reg = <0x5021000 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			porte: gpio-controller@0 {
+				compatible = "snps,dw-apb-gpio-port";
+				gpio-controller;
+				#gpio-cells = <2>;
+				ngpios = <32>;
+				reg = <0>;
+				interrupt-controller;
+				#interrupt-cells = <2>;
+				interrupts = <SOC_PERIPHERAL_IRQ(54) IRQ_TYPE_LEVEL_HIGH>;
+			};
+		};
+
 		rtc@5025000 {
 			compatible = "sophgo,cv1800b-rtc", "syscon";
 			reg = <0x5025000 0x2000>;

-- 
2.55.0


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

* [PATCH v4 05/11] riscv: dts: sophgo: Add Milk-V Duo 256M board support
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
                   ` (3 preceding siblings ...)
  2026-09-22 14:59 ` [PATCH v4 04/11] riscv: dts: sophgo: cv180x: Add PWR_GPIO controller Zhuxu Ran
@ 2026-09-22 14:59 ` Zhuxu Ran
  2026-09-22 14:59 ` [PATCH v4 06/11] riscv: milkv_duo: Use upstream devicetree Zhuxu Ran
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 14:59 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Tim Ouyang,
	Leo Liang, Thomas Bonnefille, Guodong Xu, Quentin Schulz,
	Johan Jonker, Casey Connolly, Varadarajan Narayanan,
	Alexander Koch, Andreas Schwab, Junhui Liu, Marek Vasut,
	Sumit Garg, Peter Robinson, Ilias Apalodimas

From: Chen-Yu Yeh <chenyou910331@gmail.com>

The Milk-V Duo 256M is a small form factor development board based on
the Sophgo SG2002 SoC.

This patch adds basic device tree support for the board, including:
- UART console
- SD/MMC controller
- USB host
- Onboard blue status LED (connected to PWR_GPIO[2] / porte 2)

Tested on actual Milk-V Duo 256M hardware, verified boot to shell and
heartbeat LED functionality.

Signed-off-by: Chen-Yu Yeh <chenyou910331@gmail.com>
Link: https://patch.msgid.link/20260725175346.139173-4-chenyou910331@gmail.com
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Chen Wang <chen.wang@linux.dev>

[ upstream commit: 59c682ffc76ebda27ecbbbd1423e23ec482d61b9 ]

(cherry picked from commit ed2cfe3354c657cd7b6ed1b678169edd0f146f2f)
---
 .../src/riscv/sophgo/sg2002-milkv-duo256m.dts      | 121 +++++++++++++++++++++
 1 file changed, 121 insertions(+)

diff --git a/dts/upstream/src/riscv/sophgo/sg2002-milkv-duo256m.dts b/dts/upstream/src/riscv/sophgo/sg2002-milkv-duo256m.dts
new file mode 100644
index 00000000000..a2797c0bd76
--- /dev/null
+++ b/dts/upstream/src/riscv/sophgo/sg2002-milkv-duo256m.dts
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2023 Jisheng Zhang <jszhang@kernel.org>
+ * Copyright (C) 2026 Chen-Yu Yeh <chenyou910331@gmail.com>
+ */
+
+/dts-v1/;
+
+#include "sg2002.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+
+/ {
+	model = "Milk-V Duo 256M";
+	compatible = "milkv,duo256m", "sophgo,sg2002";
+
+	aliases {
+		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
+		serial3 = &uart3;
+		serial4 = &uart4;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		led-0 {
+			gpios = <&porte 2 GPIO_ACTIVE_HIGH>;
+			color = <LED_COLOR_ID_BLUE>;
+			function = LED_FUNCTION_STATUS;
+			linux,default-trigger = "heartbeat";
+		};
+	};
+
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		coprocessor_rtos: region@8fe00000 {
+			reg = <0x8fe00000 0x200000>;
+			no-map;
+		};
+	};
+};
+
+&osc {
+	clock-frequency = <25000000>;
+};
+
+&pinctrl {
+	uart0_cfg: uart0-cfg {
+		uart0-pins {
+			pinmux = <PINMUX(PIN_UART0_TX, 0)>,
+				 <PINMUX(PIN_UART0_RX, 0)>;
+			bias-pull-up;
+			drive-strength-microamp = <10800>;
+			power-source = <3300>;
+		};
+	};
+
+	sdhci0_cfg: sdhci0-cfg {
+		sdhci0-clk-pins {
+			pinmux = <PINMUX(PIN_SD0_CLK, 0)>;
+			bias-pull-up;
+			drive-strength-microamp = <16100>;
+			power-source = <3300>;
+		};
+
+		sdhci0-cmd-pins {
+			pinmux = <PINMUX(PIN_SD0_CMD, 0)>;
+			bias-pull-up;
+			drive-strength-microamp = <10800>;
+			power-source = <3300>;
+		};
+
+		sdhci0-data-pins {
+			pinmux = <PINMUX(PIN_SD0_D0, 0)>,
+				 <PINMUX(PIN_SD0_D1, 0)>,
+				 <PINMUX(PIN_SD0_D2, 0)>,
+				 <PINMUX(PIN_SD0_D3, 0)>;
+			bias-pull-up;
+			drive-strength-microamp = <10800>;
+			power-source = <3300>;
+		};
+
+		sdhci0-cd-pins {
+			pinmux = <PINMUX(PIN_SD0_CD, 0)>;
+			bias-pull-up;
+			drive-strength-microamp = <10800>;
+			power-source = <3300>;
+		};
+	};
+};
+
+&sdhci0 {
+	pinctrl-0 = <&sdhci0_cfg>;
+	pinctrl-names = "default";
+	status = "okay";
+	bus-width = <4>;
+	no-1-8-v;
+	no-mmc;
+	no-sdio;
+	disable-wp;
+};
+
+&uart0 {
+	pinctrl-0 = <&uart0_cfg>;
+	pinctrl-names = "default";
+	status = "okay";
+};
+
+&usb {
+	dr_mode = "host";
+	status = "okay";
+};

-- 
2.55.0


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

* [PATCH v4 06/11] riscv: milkv_duo: Use upstream devicetree
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
                   ` (4 preceding siblings ...)
  2026-09-22 14:59 ` [PATCH v4 05/11] riscv: dts: sophgo: Add Milk-V Duo 256M board support Zhuxu Ran
@ 2026-09-22 14:59 ` Zhuxu Ran
  2026-09-22 15:46 ` [PATCH v4 07/11] riscv: licheerv_nano: " Zhuxu Ran
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 14:59 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Tim Ouyang,
	Leo Liang, Thomas Bonnefille, Guodong Xu, Quentin Schulz,
	Johan Jonker, Casey Connolly, Varadarajan Narayanan,
	Alexander Koch, Andreas Schwab, Junhui Liu, Marek Vasut,
	Sumit Garg, Peter Robinson, Ilias Apalodimas

Switch Milk-V Duo to the upstream CV1800B devicetree by enabling
CONFIG_OF_UPSTREAM and selecting sophgo/cv1800b-milkv-duo.

The upstream devicetree keeps the Ethernet MAC disabled and does not
describe the CV1800B SPIF controller. Add U-Boot overrides to preserve
the existing networking and SPI NOR support.

Reviewed-by: Leo Yu-Chi Liang <leo.liang@sifive.com>
Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
---
 arch/riscv/dts/cv1800b-milkv-duo-u-boot.dtsi | 35 ++++++++++++++++++++++++++++
 board/sophgo/milkv_duo/MAINTAINERS           |  3 ++-
 configs/milkv_duo_defconfig                  |  3 ++-
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/dts/cv1800b-milkv-duo-u-boot.dtsi b/arch/riscv/dts/cv1800b-milkv-duo-u-boot.dtsi
new file mode 100644
index 00000000000..3a1d01e8940
--- /dev/null
+++ b/arch/riscv/dts/cv1800b-milkv-duo-u-boot.dtsi
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2023 Jisheng Zhang <jszhang@kernel.org>
+ * Copyright (C) 2023 Inochi Amaoto <inochiama@outlook.com>
+ * Copyright (C) 2026 Zhuxu Ran <zhuxu_ran@zohomail.com>
+ */
+
+/*
+ * The Ethernet signals are routed to the RJ45 connector on the optional
+ * IO Board. Keep Ethernet available in U-Boot when the IO Board is attached.
+ */
+&gmac0 {
+	status = "okay";
+};
+
+&{/soc} {
+	spif: spi@10000000 {
+		compatible = "sophgo,cv1800b-spif";
+		reg = <0x10000000 0x10000000>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		clocks = <&clk CLK_AHB_SF>;
+		interrupts = <95 IRQ_TYPE_LEVEL_HIGH>;
+		status = "okay";
+
+		flash@0 {
+			compatible = "jedec,spi-nor";
+			reg = <0>;
+			spi-max-frequency = <75000000>;
+			spi-tx-bus-width = <4>;
+			spi-rx-bus-width = <4>;
+			m25p,fast-read;
+		};
+	};
+};
diff --git a/board/sophgo/milkv_duo/MAINTAINERS b/board/sophgo/milkv_duo/MAINTAINERS
index 6941dc5b376..8ca551426ae 100644
--- a/board/sophgo/milkv_duo/MAINTAINERS
+++ b/board/sophgo/milkv_duo/MAINTAINERS
@@ -1,7 +1,8 @@
 Milk-V Duo
 M:	Kongyang Liu <seashell11234455@gmail.com>
 S:	Maintained
-F:	board/sophgo/milkv_duo/
+F:	arch/riscv/dts/cv1800b-milkv-duo-u-boot.dtsi
 F:	board/sophgo/common/
+F:	board/sophgo/milkv_duo/
 F:	configs/milkv_duo_defconfig
 F:	doc/board/sophgo/milkv_duo.rst
diff --git a/configs/milkv_duo_defconfig b/configs/milkv_duo_defconfig
index f1f3930564b..9d6b80362d5 100644
--- a/configs/milkv_duo_defconfig
+++ b/configs/milkv_duo_defconfig
@@ -4,7 +4,8 @@ CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x82300000
-CONFIG_DEFAULT_DEVICE_TREE="cv1800b-milkv-duo"
+CONFIG_DEFAULT_DEVICE_TREE="sophgo/cv1800b-milkv-duo"
+CONFIG_OF_UPSTREAM=y
 CONFIG_SYS_LOAD_ADDR=0x80080000
 CONFIG_IDENT_STRING="milkv_duo"
 CONFIG_TARGET_MILKV_DUO=y

-- 
2.55.0


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

* [PATCH v4 07/11] riscv: licheerv_nano: Use upstream devicetree
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
                   ` (5 preceding siblings ...)
  2026-09-22 14:59 ` [PATCH v4 06/11] riscv: milkv_duo: Use upstream devicetree Zhuxu Ran
@ 2026-09-22 15:46 ` Zhuxu Ran
  2026-09-22 15:46 ` [PATCH v4 08/11] riscv: milkv_duo_256m: " Zhuxu Ran
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 15:46 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Leo Liang,
	Thomas Bonnefille, Quentin Schulz, Johan Jonker, Casey Connolly,
	Varadarajan Narayanan, Alexander Koch, Andreas Schwab, Junhui Liu,
	Marek Vasut, Sumit Garg, Peter Robinson, Ilias Apalodimas

Switch LicheeRV Nano to the upstream SG2002 devicetree by enabling
CONFIG_OF_UPSTREAM and selecting sophgo/sg2002-licheerv-nano-b.

The SG2002 clock and MMC compatible strings used by the upstream
devicetree are now supported by the existing U-Boot drivers.

Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
---
 configs/sipeed_licheerv_nano_defconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configs/sipeed_licheerv_nano_defconfig b/configs/sipeed_licheerv_nano_defconfig
index 9aa3ede10c5..21b8fece201 100644
--- a/configs/sipeed_licheerv_nano_defconfig
+++ b/configs/sipeed_licheerv_nano_defconfig
@@ -4,7 +4,8 @@ CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x82300000
-CONFIG_DEFAULT_DEVICE_TREE="sg2002-licheerv-nano-b"
+CONFIG_DEFAULT_DEVICE_TREE="sophgo/sg2002-licheerv-nano-b"
+CONFIG_OF_UPSTREAM=y
 CONFIG_SYS_LOAD_ADDR=0x80080000
 CONFIG_IDENT_STRING="licheerv_nano"
 CONFIG_TARGET_LICHEERV_NANO=y

-- 
2.55.0

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

* [PATCH v4 08/11] riscv: milkv_duo_256m: Use upstream devicetree
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
                   ` (6 preceding siblings ...)
  2026-09-22 15:46 ` [PATCH v4 07/11] riscv: licheerv_nano: " Zhuxu Ran
@ 2026-09-22 15:46 ` Zhuxu Ran
  2026-09-24 12:45   ` Hiago De Franco
  2026-09-22 15:46 ` [PATCH v4 09/11] rtc: cv1800: Add RTC and system reset support Zhuxu Ran
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 15:46 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Leo Liang,
	Thomas Bonnefille, Quentin Schulz, Johan Jonker, Casey Connolly,
	Varadarajan Narayanan, Alexander Koch, Andreas Schwab, Junhui Liu,
	Marek Vasut, Sumit Garg, Peter Robinson, Ilias Apalodimas

Switch Milk-V Duo 256M to the upstream SG2002 devicetree by enabling
CONFIG_OF_UPSTREAM and selecting sophgo/sg2002-milkv-duo256m.

The upstream devicetree keeps the Ethernet MAC disabled. Add a U-Boot
override to preserve the existing networking support when the optional
IO board is attached.

Remove the local board devicetree and update the OpenSBI build
instructions to use the upstream DTB.

Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
---
 arch/riscv/dts/Makefile                         |  1 -
 arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi | 16 +++++++++
 arch/riscv/dts/sg2002-milkv-duo256m.dts         | 46 -------------------------
 board/sophgo/milkv_duo_256m/MAINTAINERS         |  1 +
 configs/milkv_duo_256m_defconfig                |  3 +-
 doc/board/sophgo/milkv_duo_256m.rst             |  2 +-
 6 files changed, 20 insertions(+), 49 deletions(-)

diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile
index 8ba75fdb9f5..71c5c13d221 100644
--- a/arch/riscv/dts/Makefile
+++ b/arch/riscv/dts/Makefile
@@ -5,7 +5,6 @@ dtb-$(CONFIG_TARGET_ANDES_VOYAGER) += qilai-voyager.dtb
 dtb-$(CONFIG_TARGET_K230_CANMV) += k230-canmv.dtb
 dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += mpfs-icicle-kit.dtb
 dtb-$(CONFIG_TARGET_MILKV_DUO) += cv1800b-milkv-duo.dtb
-dtb-$(CONFIG_TARGET_MILKV_DUO_256M) += sg2002-milkv-duo256m.dtb
 dtb-$(CONFIG_TARGET_LICHEERV_NANO) += sg2002-licheerv-nano-b.dtb
 dtb-$(CONFIG_TARGET_QEMU_VIRT) += qemu-virt32.dtb qemu-virt64.dtb
 dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) += openpiton-riscv64.dtb
diff --git a/arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi b/arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi
new file mode 100644
index 00000000000..3872343636f
--- /dev/null
+++ b/arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2026 Zhuxu Ran <zhuxu_ran@zohomail.com>
+ */
+
+/*
+ * The Ethernet signals are routed to the RJ45 connector on the optional
+ * IO Board. Keep Ethernet available in U-Boot when the IO Board is attached.
+ */
+&gmac0 {
+	status = "okay";
+};
+
+&mdio {
+	status = "okay";
+};
diff --git a/arch/riscv/dts/sg2002-milkv-duo256m.dts b/arch/riscv/dts/sg2002-milkv-duo256m.dts
deleted file mode 100644
index 4ad86ce39ec..00000000000
--- a/arch/riscv/dts/sg2002-milkv-duo256m.dts
+++ /dev/null
@@ -1,46 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MIT)
-/*
- * Copyright (C) 2026 Hiago De Franco <hfranco@baylibre.com>
- */
-
-/dts-v1/;
-
-#include "sg2002.dtsi"
-
-/ {
-	model = "Milk-V Duo 256M";
-	compatible = "milkv,duo256m", "sophgo,sg2002";
-
-	aliases {
-		serial0 = &uart0;
-		serial1 = &uart1;
-		serial2 = &uart2;
-		serial3 = &uart3;
-		serial4 = &uart4;
-	};
-
-	chosen {
-		stdout-path = "serial0:115200n8";
-	};
-};
-
-&ethernet0 {
-	status = "okay";
-	phy-mode = "rmii";
-};
-
-&osc {
-	clock-frequency = <25000000>;
-};
-
-&sdhci0 {
-	status = "okay";
-	bus-width = <4>;
-	no-1-8-v;
-	no-mmc;
-	no-sdio;
-};
-
-&uart0 {
-	status = "okay";
-};
diff --git a/board/sophgo/milkv_duo_256m/MAINTAINERS b/board/sophgo/milkv_duo_256m/MAINTAINERS
index 929960e7251..3488db28145 100644
--- a/board/sophgo/milkv_duo_256m/MAINTAINERS
+++ b/board/sophgo/milkv_duo_256m/MAINTAINERS
@@ -1,5 +1,6 @@
 Milk-V Duo 256M
 M:	Hiago De Franco <hfranco@baylibre.com>
 S:	Maintained
+F:	arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi
 F:	board/sophgo/milkv_duo_256m/
 F:	configs/milkv_duo_256m_defconfig
diff --git a/configs/milkv_duo_256m_defconfig b/configs/milkv_duo_256m_defconfig
index 9d92eec6394..436bdb1549a 100644
--- a/configs/milkv_duo_256m_defconfig
+++ b/configs/milkv_duo_256m_defconfig
@@ -4,7 +4,7 @@ CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x82300000
-CONFIG_DEFAULT_DEVICE_TREE="sg2002-milkv-duo256m"
+CONFIG_DEFAULT_DEVICE_TREE="sophgo/sg2002-milkv-duo256m"
 CONFIG_SYS_LOAD_ADDR=0x80080000
 CONFIG_IDENT_STRING="milkv_duo_256m"
 CONFIG_TARGET_MILKV_DUO_256M=y
@@ -25,6 +25,7 @@ CONFIG_CMD_POWEROFF=y
 CONFIG_CMD_EXT4_WRITE=y
 # CONFIG_ISO_PARTITION is not set
 # CONFIG_EFI_PARTITION is not set
+CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_CLK_SOPHGO_CV1800B=y
diff --git a/doc/board/sophgo/milkv_duo_256m.rst b/doc/board/sophgo/milkv_duo_256m.rst
index 9e2cbddf4db..9562e6c48fd 100644
--- a/doc/board/sophgo/milkv_duo_256m.rst
+++ b/doc/board/sophgo/milkv_duo_256m.rst
@@ -46,7 +46,7 @@ To run u-boot.bin on top of FSBL, follow these steps:
 .. code-block:: console
 
    cd open-sbi
-   PLATFORM=generic FW_FDT_PATH=../u-boot/arch/riscv/dts/sg2002-milkv-duo256m.dtb make
+   PLATFORM=generic FW_FDT_PATH=../u-boot/dts/upstream/src/riscv/sophgo/sg2002-milkv-duo256m.dtb make
 
 This will generate build/platform/generic/firmware/fw_dynamic.bin.
 

-- 
2.55.0

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

* [PATCH v4 09/11] rtc: cv1800: Add RTC and system reset support
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
                   ` (7 preceding siblings ...)
  2026-09-22 15:46 ` [PATCH v4 08/11] riscv: milkv_duo_256m: " Zhuxu Ran
@ 2026-09-22 15:46 ` Zhuxu Ran
  2026-09-23 17:51   ` Yao Zi
  2026-09-22 15:46 ` [PATCH v4 10/11] riscv: dts: sophgo: Drop local CV18xx devicetrees Zhuxu Ran
  2026-09-22 15:46 ` [PATCH v4 11/11] clk: sophgo: cv1800b: Drop legacy compatible string Zhuxu Ran
  10 siblings, 1 reply; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 15:46 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Leo Liang,
	Thomas Bonnefille, Quentin Schulz, Johan Jonker, Casey Connolly,
	Varadarajan Narayanan, Alexander Koch, Andreas Schwab, Junhui Liu,
	Marek Vasut, Sumit Garg, Peter Robinson, Ilias Apalodimas

The upstream devicetrees describe the CV1800 RTC subsystem with the
"sophgo,cv1800b-rtc" compatible string. The RTC seconds counter and the
system-reset controls share the same register range.

Add an RTC driver which directly matches this node, enables its clock,
and implements reading and setting the 32-bit seconds counter. Bind the
CV1800B sysreset driver as a child from the RTC driver's bind callback so
both functions can be instantiated from the same devicetree node.

Initialize the RTC and sysreset register maps from their shared devicetree
node instead of using hard-coded MMIO addresses. Remove the board-level
sysreset binding from Milk-V Duo. Boards using the upstream RTC node can
now instantiate both functions without board-specific binding code.

Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
---
 board/sophgo/milkv_duo/board.c         |   5 --
 configs/milkv_duo_256m_defconfig       |   2 +
 configs/milkv_duo_defconfig            |   2 +
 configs/sipeed_licheerv_nano_defconfig |   2 +
 drivers/rtc/Kconfig                    |   9 +++
 drivers/rtc/Makefile                   |   1 +
 drivers/rtc/rtc-cv1800.c               | 122 +++++++++++++++++++++++++++++++++
 drivers/sysreset/Kconfig               |   6 +-
 drivers/sysreset/sysreset_cv1800b.c    |  86 ++++++++++++++---------
 9 files changed, 194 insertions(+), 41 deletions(-)

diff --git a/board/sophgo/milkv_duo/board.c b/board/sophgo/milkv_duo/board.c
index 34339c42925..3423f54012e 100644
--- a/board/sophgo/milkv_duo/board.c
+++ b/board/sophgo/milkv_duo/board.c
@@ -3,15 +3,10 @@
  * Copyright (c) 2024, Kongyang Liu <seashell11234455@gmail.com>
  */
 
-#include <dm/lists.h>
-
 #include "../common/ethernet.h"
 
 int board_init(void)
 {
-	if (IS_ENABLED(CONFIG_SYSRESET_CV1800B))
-		device_bind_driver(gd->dm_root, "cv1800b_sysreset", "sysreset", NULL);
-
 	if (IS_ENABLED(CONFIG_NET_LEGACY))
 		cv1800b_ephy_init();
 
diff --git a/configs/milkv_duo_256m_defconfig b/configs/milkv_duo_256m_defconfig
index 436bdb1549a..ea31b053672 100644
--- a/configs/milkv_duo_256m_defconfig
+++ b/configs/milkv_duo_256m_defconfig
@@ -36,6 +36,8 @@ CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_CV1800B=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_DM_RTC=y
+CONFIG_RTC_CV1800B=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
 CONFIG_SPI=y
diff --git a/configs/milkv_duo_defconfig b/configs/milkv_duo_defconfig
index 9d6b80362d5..77c8d89701d 100644
--- a/configs/milkv_duo_defconfig
+++ b/configs/milkv_duo_defconfig
@@ -35,6 +35,8 @@ CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_CV1800B=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_DM_RTC=y
+CONFIG_RTC_CV1800B=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
 CONFIG_SPI=y
diff --git a/configs/sipeed_licheerv_nano_defconfig b/configs/sipeed_licheerv_nano_defconfig
index 21b8fece201..75229787d2f 100644
--- a/configs/sipeed_licheerv_nano_defconfig
+++ b/configs/sipeed_licheerv_nano_defconfig
@@ -40,6 +40,8 @@ CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_CV1800B=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_DM_RTC=y
+CONFIG_RTC_CV1800B=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
 CONFIG_SPI=y
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 5b44cc99c97..f200d978937 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -54,6 +54,15 @@ config RTC_ARMADA38X
 	  This adds support for the in-chip RTC that can be found in the
 	  Armada 38x Marvell's SoC devices.
 
+config RTC_CV1800B
+	bool "Enable Sophgo CV1800B RTC driver"
+	depends on DM_RTC
+	select REGMAP
+	help
+	  Enable access to the RTC seconds counter found on Sophgo CV1800
+	  series SoCs. The driver also binds the system-reset function provided
+	  by the RTC subsystem when CONFIG_SYSRESET_CV1800B is enabled.
+
 config RTC_PCF2127
 	bool "Enable PCF2127 driver"
 	depends on DM_RTC
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 742481ce185..961fe5409f0 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -7,6 +7,7 @@
 obj-$(CONFIG_$(PHASE_)DM_RTC) += rtc-uclass.o
 
 obj-$(CONFIG_RTC_ARMADA38X) += armada38x.o
+obj-$(CONFIG_RTC_CV1800B) += rtc-cv1800.o
 obj-$(CONFIG_RTC_DAVINCI) += davinci.o
 obj-$(CONFIG_RTC_DS1307) += ds1307.o
 obj-$(CONFIG_RTC_DS1337) += ds1337.o
diff --git a/drivers/rtc/rtc-cv1800.c b/drivers/rtc/rtc-cv1800.c
new file mode 100644
index 00000000000..4a958e44de1
--- /dev/null
+++ b/drivers/rtc/rtc-cv1800.c
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2026 Zhuxu Ran <zhuxu_ran@zohomail.com>
+ *
+ * Based on the Linux driver by Jingbao Qiu <qiujingbao.dlmu@gmail.com>.
+ */
+
+#include <clk.h>
+#include <dm.h>
+#include <dm/lists.h>
+#include <regmap.h>
+#include <rtc.h>
+#include <linux/bitops.h>
+#include <linux/err.h>
+
+#define SEC_PULSE_GEN		0x1004
+#define SET_SEC_CNTR_VAL	0x1010
+#define SET_SEC_CNTR_TRIG	0x1014
+#define SEC_CNTR_VAL		0x1018
+#define MACRO_RG_SET_T		0x1498
+
+#define SEL_SEC_PULSE		BIT(31)
+
+struct cv1800_rtc_priv {
+	struct regmap *regmap;
+	struct clk clk;
+};
+
+static int cv1800_rtc_get(struct udevice *dev, struct rtc_time *time)
+{
+	struct cv1800_rtc_priv *priv = dev_get_priv(dev);
+	u32 value;
+	int ret;
+
+	ret = regmap_read(priv->regmap, SEC_PULSE_GEN, &value);
+	if (ret)
+		return ret;
+	if (value & SEL_SEC_PULSE)
+		return -EINVAL;
+
+	ret = regmap_read(priv->regmap, SEC_CNTR_VAL, &value);
+	if (ret)
+		return ret;
+
+	rtc_to_tm(value, time);
+
+	return 0;
+}
+
+static int cv1800_rtc_set(struct udevice *dev, const struct rtc_time *time)
+{
+	struct cv1800_rtc_priv *priv = dev_get_priv(dev);
+	time64_t seconds;
+	int ret;
+
+	if (time->tm_year < 1970)
+		return -EINVAL;
+
+	seconds = rtc_mktime(time);
+	if (seconds > U32_MAX)
+		return -ERANGE;
+
+	ret = regmap_write(priv->regmap, SET_SEC_CNTR_VAL, seconds);
+	if (ret)
+		return ret;
+
+	ret = regmap_write(priv->regmap, SET_SEC_CNTR_TRIG, 1);
+	if (ret)
+		return ret;
+
+	ret = regmap_write(priv->regmap, MACRO_RG_SET_T, seconds);
+	if (ret)
+		return ret;
+
+	return regmap_update_bits(priv->regmap, SEC_PULSE_GEN,
+				  SEL_SEC_PULSE, 0);
+}
+
+static int cv1800_rtc_bind(struct udevice *dev)
+{
+	if (!CONFIG_IS_ENABLED(SYSRESET_CV1800B))
+		return 0;
+
+	return device_bind_driver_to_node(dev, "cv1800b_sysreset",
+					  "sysreset", dev_ofnode(dev), NULL);
+}
+
+static int cv1800_rtc_probe(struct udevice *dev)
+{
+	struct cv1800_rtc_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	priv->regmap = devm_regmap_init(dev, NULL, NULL, NULL);
+	if (IS_ERR(priv->regmap))
+		return PTR_ERR(priv->regmap);
+
+	ret = clk_get_by_name(dev, "rtc", &priv->clk);
+	if (ret)
+		return ret;
+
+	return clk_enable(&priv->clk);
+}
+
+static const struct rtc_ops cv1800_rtc_ops = {
+	.get = cv1800_rtc_get,
+	.set = cv1800_rtc_set,
+};
+
+static const struct udevice_id cv1800_rtc_ids[] = {
+	{ .compatible = "sophgo,cv1800b-rtc" },
+	{ }
+};
+
+U_BOOT_DRIVER(cv1800b_rtc) = {
+	.name = "cv1800b_rtc",
+	.id = UCLASS_RTC,
+	.of_match = cv1800_rtc_ids,
+	.bind = cv1800_rtc_bind,
+	.probe = cv1800_rtc_probe,
+	.ops = &cv1800_rtc_ops,
+	.priv_auto = sizeof(struct cv1800_rtc_priv),
+};
diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index 16ef434a8d9..c3125d1921a 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -60,9 +60,11 @@ config SYSRESET_CMD_POWEROFF
 endif
 
 config SYSRESET_CV1800B
-	bool "Enable support for Sophgo cv1800b System Reset"
+	bool "Enable support for Sophgo CV1800B system reset"
+	depends on RTC_CV1800B
 	help
-	  Enable system reset support for Sophgo cv1800b SoC.
+	  Enable system reset and power control through the RTC subsystem found
+	  on Sophgo CV1800 series SoCs.
 
 config POWEROFF_GPIO
 	bool "Enable support for GPIO poweroff driver"
diff --git a/drivers/sysreset/sysreset_cv1800b.c b/drivers/sysreset/sysreset_cv1800b.c
index 9cd62772ef4..0836b018956 100644
--- a/drivers/sysreset/sysreset_cv1800b.c
+++ b/drivers/sysreset/sysreset_cv1800b.c
@@ -4,61 +4,79 @@
  */
 
 #include <dm.h>
-#include <stdbool.h>
+#include <regmap.h>
 #include <sysreset.h>
-#include <wait_bit.h>
-#include <linux/io.h>
+#include <linux/bitops.h>
 #include <linux/errno.h>
+#include <linux/err.h>
 
-#define REG_RTC_BASE             (void *)0x05026000
-#define REG_RTC_CTRL_BASE        (void *)0x05025000
-#define REG_RTC_EN_SHDN_REQ      (REG_RTC_BASE + 0xc0)
-#define REG_RTC_EN_PWR_CYC_REQ   (REG_RTC_BASE + 0xc8)
-#define REG_RTC_EN_WARM_RST_REQ  (REG_RTC_BASE + 0xcc)
-#define REG_RTC_CTRL_UNLOCKKEY   (REG_RTC_CTRL_BASE + 0x4)
-#define REG_RTC_CTRL             (REG_RTC_CTRL_BASE + 0x8)
+#define RTC_CTRL_UNLOCKKEY	0x0004
+#define RTC_CTRL		0x0008
+#define RTC_EN_SHDN_REQ		0x10c0
+#define RTC_EN_PWR_CYC_REQ	0x10c8
+#define RTC_EN_WARM_RST_REQ	0x10cc
 
-#define CTRL_UNLOCKKEY_MAGIC     0xAB18
+#define CTRL_UNLOCKKEY_MAGIC	0xab18
 
-/* REG_RTC_CTRL */
-#define BIT_REQ_SHDN       BIT(0)
-#define BIT_REQ_PWR_CYC    BIT(3)
-#define BIT_REQ_WARM_RST   BIT(4)
+#define BIT_REQ_SHDN		BIT(0)
+#define BIT_REQ_PWR_CYC		BIT(3)
+#define BIT_REQ_WARM_RST	BIT(4)
 
-static struct {
-	void *pre_req_reg;
+struct cv1800b_sysreset_priv {
+	struct regmap *regmap;
+};
+
+static const struct {
+	u32 pre_req_reg;
 	u32 req_bit;
 } reset_info[SYSRESET_COUNT] = {
-	[SYSRESET_WARM]      = { REG_RTC_EN_WARM_RST_REQ, BIT_REQ_WARM_RST },
-	[SYSRESET_COLD]      = { REG_RTC_EN_WARM_RST_REQ, BIT_REQ_WARM_RST },
-	[SYSRESET_POWER]     = { REG_RTC_EN_PWR_CYC_REQ, BIT_REQ_PWR_CYC },
-	[SYSRESET_POWER_OFF] = { REG_RTC_EN_SHDN_REQ, BIT_REQ_SHDN },
+	[SYSRESET_WARM]      = { RTC_EN_WARM_RST_REQ, BIT_REQ_WARM_RST },
+	[SYSRESET_COLD]      = { RTC_EN_WARM_RST_REQ, BIT_REQ_WARM_RST },
+	[SYSRESET_POWER]     = { RTC_EN_PWR_CYC_REQ, BIT_REQ_PWR_CYC },
+	[SYSRESET_POWER_OFF] = { RTC_EN_SHDN_REQ, BIT_REQ_SHDN },
 };
 
 static int cv1800b_sysreset_request(struct udevice *dev, enum sysreset_t type)
 {
-	u32 reg;
+	struct cv1800b_sysreset_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = regmap_write(priv->regmap, reset_info[type].pre_req_reg, 1);
+	if (ret)
+		return ret;
 
-	writel(1, reset_info[type].pre_req_reg);
-	writel(CTRL_UNLOCKKEY_MAGIC, REG_RTC_CTRL_UNLOCKKEY);
-	reg = readl(REG_RTC_CTRL);
-	writel(0xFFFF0800 | reset_info[type].req_bit, REG_RTC_CTRL);
+	ret = regmap_write(priv->regmap, RTC_CTRL_UNLOCKKEY,
+			   CTRL_UNLOCKKEY_MAGIC);
+	if (ret)
+		return ret;
+
+	ret = regmap_write(priv->regmap, RTC_CTRL,
+			   0xffff0800 | reset_info[type].req_bit);
+	if (ret)
+		return ret;
 
 	return -EINPROGRESS;
 }
 
+static int cv1800b_sysreset_probe(struct udevice *dev)
+{
+	struct cv1800b_sysreset_priv *priv = dev_get_priv(dev);
+
+	priv->regmap = devm_regmap_init(dev, NULL, NULL, NULL);
+	if (IS_ERR(priv->regmap))
+		return PTR_ERR(priv->regmap);
+
+	return 0;
+}
+
 static struct sysreset_ops cv1800b_sysreset = {
 	.request = cv1800b_sysreset_request,
 };
 
-static const struct udevice_id cv1800b_sysreset_ids[] = {
-	{ .compatible = "sophgo,cv1800b-sysreset", },
-	{},
-};
-
 U_BOOT_DRIVER(sysreset_cv1800b) = {
 	.name = "cv1800b_sysreset",
-	.id	  = UCLASS_SYSRESET,
-	.ops  = &cv1800b_sysreset,
-	.of_match = cv1800b_sysreset_ids
+	.id = UCLASS_SYSRESET,
+	.probe = cv1800b_sysreset_probe,
+	.ops = &cv1800b_sysreset,
+	.priv_auto = sizeof(struct cv1800b_sysreset_priv),
 };

-- 
2.55.0

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

* [PATCH v4 10/11] riscv: dts: sophgo: Drop local CV18xx devicetrees
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
                   ` (8 preceding siblings ...)
  2026-09-22 15:46 ` [PATCH v4 09/11] rtc: cv1800: Add RTC and system reset support Zhuxu Ran
@ 2026-09-22 15:46 ` Zhuxu Ran
  2026-09-22 15:46 ` [PATCH v4 11/11] clk: sophgo: cv1800b: Drop legacy compatible string Zhuxu Ran
  10 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 15:46 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Leo Liang,
	Thomas Bonnefille, Quentin Schulz, Johan Jonker, Casey Connolly,
	Varadarajan Narayanan, Alexander Koch, Andreas Schwab, Junhui Liu,
	Marek Vasut, Sumit Garg, Peter Robinson, Ilias Apalodimas

Milk-V Duo, Milk-V Duo 256M and LicheeRV Nano now use the upstream
CV1800B and SG2002 devicetrees.

Remove the remaining unused local devicetree files and their Makefile
entries.

Reviewed-by: Leo Yu-Chi Liang <leo.liang@sifive.com>
Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
---
 arch/riscv/dts/Makefile                   |   2 -
 arch/riscv/dts/cv1800b-milkv-duo.dts      |  64 ---------
 arch/riscv/dts/cv1800b.dtsi               |  22 ---
 arch/riscv/dts/cv18xx.dtsi                | 232 ------------------------------
 arch/riscv/dts/sg2002-licheerv-nano-b.dts |  45 ------
 arch/riscv/dts/sg2002.dtsi                |  34 -----
 6 files changed, 399 deletions(-)

diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile
index 71c5c13d221..c588ce546bf 100644
--- a/arch/riscv/dts/Makefile
+++ b/arch/riscv/dts/Makefile
@@ -4,8 +4,6 @@ dtb-$(CONFIG_TARGET_ANDES_AE350) += ae350_32.dtb ae350_64.dtb
 dtb-$(CONFIG_TARGET_ANDES_VOYAGER) += qilai-voyager.dtb
 dtb-$(CONFIG_TARGET_K230_CANMV) += k230-canmv.dtb
 dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += mpfs-icicle-kit.dtb
-dtb-$(CONFIG_TARGET_MILKV_DUO) += cv1800b-milkv-duo.dtb
-dtb-$(CONFIG_TARGET_LICHEERV_NANO) += sg2002-licheerv-nano-b.dtb
 dtb-$(CONFIG_TARGET_QEMU_VIRT) += qemu-virt32.dtb qemu-virt64.dtb
 dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) += openpiton-riscv64.dtb
 dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb
diff --git a/arch/riscv/dts/cv1800b-milkv-duo.dts b/arch/riscv/dts/cv1800b-milkv-duo.dts
deleted file mode 100644
index e7cc0e8bd14..00000000000
--- a/arch/riscv/dts/cv1800b-milkv-duo.dts
+++ /dev/null
@@ -1,64 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MIT)
-/*
- * Copyright (C) 2023 Jisheng Zhang <jszhang@kernel.org>
- */
-
-/dts-v1/;
-
-#include "cv1800b.dtsi"
-
-/ {
-	model = "Milk-V Duo";
-	compatible = "milkv,duo", "sophgo,cv1800b";
-
-	aliases {
-		serial0 = &uart0;
-		serial1 = &uart1;
-		serial2 = &uart2;
-		serial3 = &uart3;
-		serial4 = &uart4;
-	};
-
-	chosen {
-		stdout-path = "serial0:115200n8";
-	};
-
-	memory@80000000 {
-		device_type = "memory";
-		reg = <0x80000000 0x3f40000>;
-	};
-};
-
-&ethernet0 {
-	status = "okay";
-	phy-mode = "rmii";
-};
-
-&osc {
-	clock-frequency = <25000000>;
-};
-
-&sdhci0 {
-	status = "okay";
-	bus-width = <4>;
-	no-1-8-v;
-	no-mmc;
-	no-sdio;
-};
-
-&spif {
-	status = "okay";
-
-	spiflash@0 {
-		compatible = "jedec,spi-nor";
-		reg = <0>;
-		spi-max-frequency = <75000000>;
-		spi-tx-bus-width = <4>;
-		spi-rx-bus-width = <4>;
-		m25p,fast-read;
-	};
-};
-
-&uart0 {
-	status = "okay";
-};
diff --git a/arch/riscv/dts/cv1800b.dtsi b/arch/riscv/dts/cv1800b.dtsi
deleted file mode 100644
index baf641829e7..00000000000
--- a/arch/riscv/dts/cv1800b.dtsi
+++ /dev/null
@@ -1,22 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MIT)
-/*
- * Copyright (C) 2023 Jisheng Zhang <jszhang@kernel.org>
- */
-
-#include "cv18xx.dtsi"
-
-/ {
-	compatible = "sophgo,cv1800b";
-};
-
-&plic {
-	compatible = "sophgo,cv1800b-plic", "thead,c900-plic";
-};
-
-&clint {
-	compatible = "sophgo,cv1800b-clint", "thead,c900-clint";
-};
-
-&clk {
-	compatible = "sophgo,cv1800-clk";
-};
diff --git a/arch/riscv/dts/cv18xx.dtsi b/arch/riscv/dts/cv18xx.dtsi
deleted file mode 100644
index 8530527aa39..00000000000
--- a/arch/riscv/dts/cv18xx.dtsi
+++ /dev/null
@@ -1,232 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MIT)
-/*
- * Copyright (C) 2023 Jisheng Zhang <jszhang@kernel.org>
- * Copyright (C) 2023 Inochi Amaoto <inochiama@outlook.com>
- */
-
-#include <dt-bindings/interrupt-controller/irq.h>
-#include <dt-bindings/clock/sophgo,cv1800.h>
-
-/ {
-	#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";
-		#clock-cells = <0>;
-	};
-
-	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>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			porta: gpio-controller@0 {
-				compatible = "snps,dw-apb-gpio-port";
-				gpio-controller;
-				#gpio-cells = <2>;
-				ngpios = <32>;
-				reg = <0>;
-				interrupt-controller;
-				#interrupt-cells = <2>;
-				interrupts = <60 IRQ_TYPE_LEVEL_HIGH>;
-			};
-		};
-
-		gpio1: gpio@3021000 {
-			compatible = "snps,dw-apb-gpio";
-			reg = <0x3021000 0x1000>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			portb: gpio-controller@0 {
-				compatible = "snps,dw-apb-gpio-port";
-				gpio-controller;
-				#gpio-cells = <2>;
-				ngpios = <32>;
-				reg = <0>;
-				interrupt-controller;
-				#interrupt-cells = <2>;
-				interrupts = <61 IRQ_TYPE_LEVEL_HIGH>;
-			};
-		};
-
-		gpio2: gpio@3022000 {
-			compatible = "snps,dw-apb-gpio";
-			reg = <0x3022000 0x1000>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			portc: gpio-controller@0 {
-				compatible = "snps,dw-apb-gpio-port";
-				gpio-controller;
-				#gpio-cells = <2>;
-				ngpios = <32>;
-				reg = <0>;
-				interrupt-controller;
-				#interrupt-cells = <2>;
-				interrupts = <62 IRQ_TYPE_LEVEL_HIGH>;
-			};
-		};
-
-		gpio3: gpio@3023000 {
-			compatible = "snps,dw-apb-gpio";
-			reg = <0x3023000 0x1000>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-
-			portd: gpio-controller@0 {
-				compatible = "snps,dw-apb-gpio-port";
-				gpio-controller;
-				#gpio-cells = <2>;
-				ngpios = <32>;
-				reg = <0>;
-				interrupt-controller;
-				#interrupt-cells = <2>;
-				interrupts = <63 IRQ_TYPE_LEVEL_HIGH>;
-			};
-		};
-
-		ethernet0: ethernet@4070000 {
-			compatible = "sophgo,cv1800b-dwmac";
-			reg = <0x04070000 0x10000>;
-			interrupts = <31 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk CLK_ETH0_500M>, <&clk CLK_AXI4_ETH0>;
-			clock-names = "stmmaceth", "pclk";
-			status = "disabled";
-		};
-
-		uart0: serial@4140000 {
-			compatible = "snps,dw-apb-uart";
-			reg = <0x04140000 0x100>;
-			interrupts = <44 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk CLK_UART0>, <&clk CLK_APB_UART0>;
-			clock-names = "baudclk", "apb_pclk";
-			reg-shift = <2>;
-			reg-io-width = <4>;
-			status = "disabled";
-		};
-
-		uart1: serial@4150000 {
-			compatible = "snps,dw-apb-uart";
-			reg = <0x04150000 0x100>;
-			interrupts = <45 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk CLK_UART4>, <&clk CLK_APB_UART4>;
-			clock-names = "baudclk", "apb_pclk";
-			reg-shift = <2>;
-			reg-io-width = <4>;
-			status = "disabled";
-		};
-
-		uart2: serial@4160000 {
-			compatible = "snps,dw-apb-uart";
-			reg = <0x04160000 0x100>;
-			interrupts = <46 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk CLK_UART2>, <&clk CLK_APB_UART2>;
-			clock-names = "baudclk", "apb_pclk";
-			reg-shift = <2>;
-			reg-io-width = <4>;
-			status = "disabled";
-		};
-
-		uart3: serial@4170000 {
-			compatible = "snps,dw-apb-uart";
-			reg = <0x04170000 0x100>;
-			interrupts = <47 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk CLK_UART3>, <&clk CLK_APB_UART3>;
-			clock-names = "baudclk", "apb_pclk";
-			reg-shift = <2>;
-			reg-io-width = <4>;
-			status = "disabled";
-		};
-
-		uart4: serial@41c0000 {
-			compatible = "snps,dw-apb-uart";
-			reg = <0x041c0000 0x100>;
-			interrupts = <48 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk CLK_UART4>, <&clk CLK_APB_UART4>;
-			clock-names = "baudclk", "apb_pclk";
-			reg-shift = <2>;
-			reg-io-width = <4>;
-			status = "disabled";
-		};
-
-		sdhci0: mmc@4310000 {
-			compatible = "sophgo,cv1800b-dwcmshc";
-			reg = <0x4310000 0x1000>;
-			interrupts = <36 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&clk CLK_AXI4_SD0>, <&clk CLK_SD0>;
-			clock-names = "core", "bus";
-			status = "disabled";
-		};
-
-		spif: spi@10000000 {
-			compatible = "sophgo,cv1800b-spif";
-			reg = <0x10000000 0x10000000>;
-			#address-cells = <1>;
-			#size-cells = <0>;
-			clocks = <&clk CLK_AHB_SF>;
-			interrupts = <95 IRQ_TYPE_LEVEL_HIGH>;
-			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>;
-		};
-	};
-};
diff --git a/arch/riscv/dts/sg2002-licheerv-nano-b.dts b/arch/riscv/dts/sg2002-licheerv-nano-b.dts
deleted file mode 100644
index 9871a75836c..00000000000
--- a/arch/riscv/dts/sg2002-licheerv-nano-b.dts
+++ /dev/null
@@ -1,45 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MIT)
-/*
- * Copyright (C) 2024 Thomas Bonnefille <thomas.bonnefille@bootlin.com>
- */
-
-/dts-v1/;
-
-#include "sg2002.dtsi"
-
-/ {
-	model = "LicheeRV Nano B";
-	compatible = "sipeed,licheerv-nano-b", "sipeed,licheerv-nano", "sophgo,sg2002";
-
-	aliases {
-		gpio0 = &gpio0;
-		gpio1 = &gpio1;
-		gpio2 = &gpio2;
-		gpio3 = &gpio3;
-		serial0 = &uart0;
-		serial1 = &uart1;
-		serial2 = &uart2;
-		serial3 = &uart3;
-		serial4 = &uart4;
-	};
-
-	chosen {
-		stdout-path = "serial0:115200n8";
-	};
-};
-
-&osc {
-	clock-frequency = <25000000>;
-};
-
-&sdhci0 {
-	status = "okay";
-	bus-width = <4>;
-	no-1-8-v;
-	no-mmc;
-	no-sdio;
-};
-
-&uart0 {
-	status = "okay";
-};
diff --git a/arch/riscv/dts/sg2002.dtsi b/arch/riscv/dts/sg2002.dtsi
deleted file mode 100644
index 0f97000fa8b..00000000000
--- a/arch/riscv/dts/sg2002.dtsi
+++ /dev/null
@@ -1,34 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0 OR MIT)
-/*
- * Copyright (C) 2024 Thomas Bonnefille <thomas.bonnefille@bootlin.com>
- */
-
-/dts-v1/;
-
-#include <dt-bindings/interrupt-controller/irq.h>
-#include "cv18xx.dtsi"
-
-/ {
-	compatible = "sophgo,sg2002";
-
-	memory@80000000 {
-		device_type = "memory";
-		reg = <0x80000000 0x10000000>;
-	};
-};
-
-&plic {
-	compatible = "sophgo,sg2002-plic", "sophgo,cv1800b-plic", "thead,c900-plic";
-};
-
-&clint {
-	compatible = "sophgo,sg2002-plic", "sophgo,cv1800b-clint", "thead,c900-clint";
-};
-
-&clk {
-	compatible = "sophgo,sg2002-clk", "sophgo,cv1800-clk";
-};
-
-&sdhci0 {
-	compatible = "sophgo,sg2002-dwcmshc", "sophgo,cv1800b-dwcmshc";
-};

-- 
2.55.0

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

* [PATCH v4 11/11] clk: sophgo: cv1800b: Drop legacy compatible string
       [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
                   ` (9 preceding siblings ...)
  2026-09-22 15:46 ` [PATCH v4 10/11] riscv: dts: sophgo: Drop local CV18xx devicetrees Zhuxu Ran
@ 2026-09-22 15:46 ` Zhuxu Ran
  10 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-22 15:46 UTC (permalink / raw)
  To: u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Zhuxu Ran, Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung,
	Stefan Roese, Hiago De Franco, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Leo Liang,
	Thomas Bonnefille, Quentin Schulz, Johan Jonker, Casey Connolly,
	Varadarajan Narayanan, Alexander Koch, Andreas Schwab, Junhui Liu,
	Marek Vasut, Sumit Garg, Peter Robinson, Ilias Apalodimas

Milk-V Duo, Milk-V Duo 256M and LicheeRV Nano now use upstream
devicetrees with the SoC-specific "sophgo,cv1800b-clk" and
"sophgo,sg2002-clk" compatible strings.

Remove the now-unused legacy "sophgo,cv1800-clk" compatible string.

Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
---
 drivers/clk/sophgo/clk-cv1800b.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clk/sophgo/clk-cv1800b.c b/drivers/clk/sophgo/clk-cv1800b.c
index 57051c1ec0a..2270a076ce2 100644
--- a/drivers/clk/sophgo/clk-cv1800b.c
+++ b/drivers/clk/sophgo/clk-cv1800b.c
@@ -743,7 +743,6 @@ const struct clk_ops cv1800b_clk_ops = {
 };
 
 static const struct udevice_id cv1800b_clk_of_match[] = {
-	{ .compatible = "sophgo,cv1800-clk" },
 	{ .compatible = "sophgo,cv1800b-clk" },
 	{ .compatible = "sophgo,sg2002-clk" },
 	{ },

-- 
2.55.0

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

* Re: [PATCH v4 09/11] rtc: cv1800: Add RTC and system reset support
  2026-09-22 15:46 ` [PATCH v4 09/11] rtc: cv1800: Add RTC and system reset support Zhuxu Ran
@ 2026-09-23 17:51   ` Yao Zi
  2026-09-24  4:05     ` Zhuxu Ran
  0 siblings, 1 reply; 15+ messages in thread
From: Yao Zi @ 2026-09-23 17:51 UTC (permalink / raw)
  To: Zhuxu Ran, u-boot, Chao Wei, Chen Wang, Yao Zi
  Cc: Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung, Stefan Roese,
	Hiago De Franco, Sumit Garg, Inochi Amaoto, Conor Dooley,
	Chen-Yu Yeh, Chen Wang, Kongyang Liu, Leo Liang,
	Thomas Bonnefille, Quentin Schulz, Johan Jonker, Casey Connolly,
	Varadarajan Narayanan, Alexander Koch, Andreas Schwab, Junhui Liu,
	Marek Vasut, Sumit Garg, Peter Robinson, Ilias Apalodimas

On Tue, Sep 22, 2026 at 11:46:24PM +0800, Zhuxu Ran wrote:
> The upstream devicetrees describe the CV1800 RTC subsystem with the
> "sophgo,cv1800b-rtc" compatible string. The RTC seconds counter and the
> system-reset controls share the same register range.
> 
> Add an RTC driver which directly matches this node, enables its clock,
> and implements reading and setting the 32-bit seconds counter. Bind the
> CV1800B sysreset driver as a child from the RTC driver's bind callback so
> both functions can be instantiated from the same devicetree node.
> 
> Initialize the RTC and sysreset register maps from their shared devicetree
> node instead of using hard-coded MMIO addresses. Remove the board-level
> sysreset binding from Milk-V Duo. Boards using the upstream RTC node can
> now instantiate both functions without board-specific binding code.
> 
> Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>

This patch looks quite large, and comparing to other parts of the
series, it adds new drivers and modifies existing driver massively, so
I think it makes sense to separate it out of the series, i.e., send a
separate series converting sysreset-related ABI to match upstream first.

> ---
>  board/sophgo/milkv_duo/board.c         |   5 --
>  configs/milkv_duo_256m_defconfig       |   2 +
>  configs/milkv_duo_defconfig            |   2 +
>  configs/sipeed_licheerv_nano_defconfig |   2 +
>  drivers/rtc/Kconfig                    |   9 +++
>  drivers/rtc/Makefile                   |   1 +
>  drivers/rtc/rtc-cv1800.c               | 122 +++++++++++++++++++++++++++++++++
>  drivers/sysreset/Kconfig               |   6 +-
>  drivers/sysreset/sysreset_cv1800b.c    |  86 ++++++++++++++---------

This involves multiple subsystems, please separate rtc/sysreset/
board-level changes into different patches. Bisectability might be
broken for one or two commits, but I think it would be much clear to
handle.

Regards,
Yao Zi

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

* Re: [PATCH v4 09/11] rtc: cv1800: Add RTC and system reset support
  2026-09-23 17:51   ` Yao Zi
@ 2026-09-24  4:05     ` Zhuxu Ran
  0 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-24  4:05 UTC (permalink / raw)
  To: Yao Zi, Zhuxu Ran, u-boot, Chao Wei, Chen Wang
  Cc: Lukasz Majewski, Tom Rini, Peng Fan, Jaehoon Chung, Stefan Roese,
	Hiago De Franco, Sumit Garg, Inochi Amaoto, Conor Dooley,
	Chen-Yu Yeh, Chen Wang, Kongyang Liu, Leo Liang,
	Thomas Bonnefille, Quentin Schulz, Johan Jonker, Casey Connolly,
	Varadarajan Narayanan, Alexander Koch, Andreas Schwab, Junhui Liu,
	Marek Vasut, Sumit Garg, Peter Robinson, Ilias Apalodimas

On Thu Sep 24, 2026 at 1:51 AM CST, Yao Zi wrote:
> On Tue, Sep 22, 2026 at 11:46:24PM +0800, Zhuxu Ran wrote:
>> The upstream devicetrees describe the CV1800 RTC subsystem with the
>> "sophgo,cv1800b-rtc" compatible string. The RTC seconds counter and the
>> system-reset controls share the same register range.
>> 
>> Add an RTC driver which directly matches this node, enables its clock,
>> and implements reading and setting the 32-bit seconds counter. Bind the
>> CV1800B sysreset driver as a child from the RTC driver's bind callback so
>> both functions can be instantiated from the same devicetree node.
>> 
>> Initialize the RTC and sysreset register maps from their shared devicetree
>> node instead of using hard-coded MMIO addresses. Remove the board-level
>> sysreset binding from Milk-V Duo. Boards using the upstream RTC node can
>> now instantiate both functions without board-specific binding code.
>> 
>> Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
>
> This patch looks quite large, and comparing to other parts of the
> series, it adds new drivers and modifies existing driver massively, so
> I think it makes sense to separate it out of the series, i.e., send a
> separate series converting sysreset-related ABI to match upstream first.
>
>> ---
>>  board/sophgo/milkv_duo/board.c         |   5 --
>>  configs/milkv_duo_256m_defconfig       |   2 +
>>  configs/milkv_duo_defconfig            |   2 +
>>  configs/sipeed_licheerv_nano_defconfig |   2 +
>>  drivers/rtc/Kconfig                    |   9 +++
>>  drivers/rtc/Makefile                   |   1 +
>>  drivers/rtc/rtc-cv1800.c               | 122 +++++++++++++++++++++++++++++++++
>>  drivers/sysreset/Kconfig               |   6 +-
>>  drivers/sysreset/sysreset_cv1800b.c    |  86 ++++++++++++++---------
>
> This involves multiple subsystems, please separate rtc/sysreset/
> board-level changes into different patches. Bisectability might be
> broken for one or two commits, but I think it would be much clear to
> handle.
>
> Regards,
> Yao Zi

Hi Yao,

Thanks for the review.

I agree that the RTC and sysreset changes should be handled separately
from the devicetree conversion. I will prepare that work as a separate
series first, with the RTC driver, sysreset changes, and board-level
changes split into individual patches.

The next revision of this series will keep the existing board-level
sysreset setup and focus on the devicetree conversion.

-- 
Best regards,
Zhuxu Ran


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

* Re: [PATCH v4 08/11] riscv: milkv_duo_256m: Use upstream devicetree
  2026-09-22 15:46 ` [PATCH v4 08/11] riscv: milkv_duo_256m: " Zhuxu Ran
@ 2026-09-24 12:45   ` Hiago De Franco
  2026-09-24 14:47     ` Zhuxu Ran
  0 siblings, 1 reply; 15+ messages in thread
From: Hiago De Franco @ 2026-09-24 12:45 UTC (permalink / raw)
  To: Zhuxu Ran
  Cc: u-boot, Chao Wei, Chen Wang, Yao Zi, Lukasz Majewski, Tom Rini,
	Peng Fan, Jaehoon Chung, Stefan Roese, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Leo Liang,
	Thomas Bonnefille, Quentin Schulz, Johan Jonker, Casey Connolly,
	Varadarajan Narayanan, Alexander Koch, Andreas Schwab, Junhui Liu,
	Marek Vasut, Sumit Garg, Peter Robinson, Ilias Apalodimas

Hi Zhuxu,

On Tue, Sep 22, 2026 at 11:46:23PM +0800, Zhuxu Ran wrote:
> Switch Milk-V Duo 256M to the upstream SG2002 devicetree by enabling
> CONFIG_OF_UPSTREAM and selecting sophgo/sg2002-milkv-duo256m.
> 
> The upstream devicetree keeps the Ethernet MAC disabled. Add a U-Boot
> override to preserve the existing networking support when the optional
> IO board is attached.
> 
> Remove the local board devicetree and update the OpenSBI build
> instructions to use the upstream DTB.
> 
> Signed-off-by: Zhuxu Ran <zhuxu_ran@zohomail.com>
> ---
>  arch/riscv/dts/Makefile                         |  1 -
>  arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi | 16 +++++++++
>  arch/riscv/dts/sg2002-milkv-duo256m.dts         | 46 -------------------------
>  board/sophgo/milkv_duo_256m/MAINTAINERS         |  1 +
>  configs/milkv_duo_256m_defconfig                |  3 +-
>  doc/board/sophgo/milkv_duo_256m.rst             |  2 +-
>  6 files changed, 20 insertions(+), 49 deletions(-)
> 
> diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile
> index 8ba75fdb9f5..71c5c13d221 100644
> --- a/arch/riscv/dts/Makefile
> +++ b/arch/riscv/dts/Makefile
> @@ -5,7 +5,6 @@ dtb-$(CONFIG_TARGET_ANDES_VOYAGER) += qilai-voyager.dtb
>  dtb-$(CONFIG_TARGET_K230_CANMV) += k230-canmv.dtb
>  dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += mpfs-icicle-kit.dtb
>  dtb-$(CONFIG_TARGET_MILKV_DUO) += cv1800b-milkv-duo.dtb
> -dtb-$(CONFIG_TARGET_MILKV_DUO_256M) += sg2002-milkv-duo256m.dtb
>  dtb-$(CONFIG_TARGET_LICHEERV_NANO) += sg2002-licheerv-nano-b.dtb
>  dtb-$(CONFIG_TARGET_QEMU_VIRT) += qemu-virt32.dtb qemu-virt64.dtb
>  dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) += openpiton-riscv64.dtb
> diff --git a/arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi b/arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi
> new file mode 100644
> index 00000000000..3872343636f
> --- /dev/null
> +++ b/arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi
> @@ -0,0 +1,16 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +/*
> + * Copyright (C) 2026 Zhuxu Ran <zhuxu_ran@zohomail.com>
> + */
> +
> +/*
> + * The Ethernet signals are routed to the RJ45 connector on the optional
> + * IO Board. Keep Ethernet available in U-Boot when the IO Board is attached.
> + */
> +&gmac0 {
> +	status = "okay";
> +};
> +
> +&mdio {
> +	status = "okay";
> +};

I see that milkv_duo_256m_defconfig doesn't enable DM_MDIO, DM_MDIO_MUX
or MDIO_MUX_MMIOREG, so nothing binds to the mdio-mux node.

Note that the upstream gmac0 node uses phy-mode = "internal" and a
phy-handle into the mdio mux, while the old local DT used phy-mode =
"rmii".

Can you check this? Have you tested the ethernet port on Duo 256M?

> diff --git a/arch/riscv/dts/sg2002-milkv-duo256m.dts b/arch/riscv/dts/sg2002-milkv-duo256m.dts
> deleted file mode 100644
> index 4ad86ce39ec..00000000000
> --- a/arch/riscv/dts/sg2002-milkv-duo256m.dts
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> -/*
> - * Copyright (C) 2026 Hiago De Franco <hfranco@baylibre.com>
> - */
> -
> -/dts-v1/;
> -
> -#include "sg2002.dtsi"
> -
> -/ {
> -	model = "Milk-V Duo 256M";
> -	compatible = "milkv,duo256m", "sophgo,sg2002";
> -
> -	aliases {
> -		serial0 = &uart0;
> -		serial1 = &uart1;
> -		serial2 = &uart2;
> -		serial3 = &uart3;
> -		serial4 = &uart4;
> -	};
> -
> -	chosen {
> -		stdout-path = "serial0:115200n8";
> -	};
> -};
> -
> -&ethernet0 {
> -	status = "okay";
> -	phy-mode = "rmii";
> -};
> -
> -&osc {
> -	clock-frequency = <25000000>;
> -};
> -
> -&sdhci0 {
> -	status = "okay";
> -	bus-width = <4>;
> -	no-1-8-v;
> -	no-mmc;
> -	no-sdio;
> -};
> -
> -&uart0 {
> -	status = "okay";
> -};
> diff --git a/board/sophgo/milkv_duo_256m/MAINTAINERS b/board/sophgo/milkv_duo_256m/MAINTAINERS
> index 929960e7251..3488db28145 100644
> --- a/board/sophgo/milkv_duo_256m/MAINTAINERS
> +++ b/board/sophgo/milkv_duo_256m/MAINTAINERS
> @@ -1,5 +1,6 @@
>  Milk-V Duo 256M
>  M:	Hiago De Franco <hfranco@baylibre.com>
>  S:	Maintained
> +F:	arch/riscv/dts/sg2002-milkv-duo256m-u-boot.dtsi
>  F:	board/sophgo/milkv_duo_256m/
>  F:	configs/milkv_duo_256m_defconfig
> diff --git a/configs/milkv_duo_256m_defconfig b/configs/milkv_duo_256m_defconfig
> index 9d92eec6394..436bdb1549a 100644
> --- a/configs/milkv_duo_256m_defconfig
> +++ b/configs/milkv_duo_256m_defconfig
> @@ -4,7 +4,7 @@ CONFIG_SYS_MALLOC_F_LEN=0x8000
>  CONFIG_NR_DRAM_BANKS=1
>  CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
>  CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x82300000
> -CONFIG_DEFAULT_DEVICE_TREE="sg2002-milkv-duo256m"
> +CONFIG_DEFAULT_DEVICE_TREE="sophgo/sg2002-milkv-duo256m"
>  CONFIG_SYS_LOAD_ADDR=0x80080000
>  CONFIG_IDENT_STRING="milkv_duo_256m"
>  CONFIG_TARGET_MILKV_DUO_256M=y
> @@ -25,6 +25,7 @@ CONFIG_CMD_POWEROFF=y
>  CONFIG_CMD_EXT4_WRITE=y
>  # CONFIG_ISO_PARTITION is not set
>  # CONFIG_EFI_PARTITION is not set
> +CONFIG_OF_UPSTREAM=y
>  CONFIG_ENV_OVERWRITE=y
>  CONFIG_NET_RANDOM_ETHADDR=y
>  CONFIG_CLK_SOPHGO_CV1800B=y
> diff --git a/doc/board/sophgo/milkv_duo_256m.rst b/doc/board/sophgo/milkv_duo_256m.rst
> index 9e2cbddf4db..9562e6c48fd 100644
> --- a/doc/board/sophgo/milkv_duo_256m.rst
> +++ b/doc/board/sophgo/milkv_duo_256m.rst
> @@ -46,7 +46,7 @@ To run u-boot.bin on top of FSBL, follow these steps:
>  .. code-block:: console
>  
>     cd open-sbi
> -   PLATFORM=generic FW_FDT_PATH=../u-boot/arch/riscv/dts/sg2002-milkv-duo256m.dtb make
> +   PLATFORM=generic FW_FDT_PATH=../u-boot/dts/upstream/src/riscv/sophgo/sg2002-milkv-duo256m.dtb make
>  
>  This will generate build/platform/generic/firmware/fw_dynamic.bin.
>  
> 
> -- 
> 2.55.0

Regards,
-- 
Hiago

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

* Re: [PATCH v4 08/11] riscv: milkv_duo_256m: Use upstream devicetree
  2026-09-24 12:45   ` Hiago De Franco
@ 2026-09-24 14:47     ` Zhuxu Ran
  0 siblings, 0 replies; 15+ messages in thread
From: Zhuxu Ran @ 2026-09-24 14:47 UTC (permalink / raw)
  To: Hiago De Franco, Zhuxu Ran
  Cc: u-boot, Chao Wei, Chen Wang, Yao Zi, Lukasz Majewski, Tom Rini,
	Peng Fan, Jaehoon Chung, Stefan Roese, Sumit Garg, Inochi Amaoto,
	Conor Dooley, Chen-Yu Yeh, Chen Wang, Kongyang Liu, Leo Liang,
	Thomas Bonnefille, Quentin Schulz, Johan Jonker, Casey Connolly,
	Varadarajan Narayanan, Alexander Koch, Andreas Schwab, Junhui Liu,
	Marek Vasut, Sumit Garg, Peter Robinson, Ilias Apalodimas

> I see that milkv_duo_256m_defconfig doesn't enable DM_MDIO, DM_MDIO_MUX
> or MDIO_MUX_MMIOREG, so nothing binds to the mdio-mux node.
>
> Note that the upstream gmac0 node uses phy-mode = "internal" and a
> phy-handle into the mdio mux, while the old local DT used phy-mode =
> "rmii".
>
> Can you check this? Have you tested the ethernet port on Duo 256M?

Hi Hiago,

Thanks for catching this. You are right that the upstream devicetree
requires the DM MDIO mux support.

My earlier Ethernet test passed, but the mdio-mux node was not bound,
so it did not verify the MDIO topology described by the upstream
devicetree.

After enabling CONFIG_DM_MDIO, CONFIG_DM_MDIO_MUX, and
CONFIG_MDIO_MUX_MMIOREG, the MMIO mux, the internal MDIO bus, and the
DesignWare MDIO bus are all probed. I tested this on the Milk-V Duo 256M
after a cold boot; the link negotiated at 100 Mbps full duplex, and both
DHCP and TFTP worked.

I will add these options to milkv_duo_256m_defconfig in the next revision.

-- 
Best regards,
Zhuxu Ran


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

end of thread, other threads:[~2026-09-24 17:45 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260922-milkv-duo-upstream-dts-v4-0-d45b74dfad36@zohomail.com>
2026-09-22 14:59 ` [PATCH v4 01/11] clk: sophgo: cv1800b: Add SoC-specific compatible strings Zhuxu Ran
2026-09-22 14:59 ` [PATCH v4 02/11] mmc: cv1800b: Add SG2002 compatible string Zhuxu Ran
2026-09-22 14:59 ` [PATCH v4 03/11] dt-bindings: soc: sophgo: add Milk-V Duo 256M board Zhuxu Ran
2026-09-22 14:59 ` [PATCH v4 04/11] riscv: dts: sophgo: cv180x: Add PWR_GPIO controller Zhuxu Ran
2026-09-22 14:59 ` [PATCH v4 05/11] riscv: dts: sophgo: Add Milk-V Duo 256M board support Zhuxu Ran
2026-09-22 14:59 ` [PATCH v4 06/11] riscv: milkv_duo: Use upstream devicetree Zhuxu Ran
2026-09-22 15:46 ` [PATCH v4 07/11] riscv: licheerv_nano: " Zhuxu Ran
2026-09-22 15:46 ` [PATCH v4 08/11] riscv: milkv_duo_256m: " Zhuxu Ran
2026-09-24 12:45   ` Hiago De Franco
2026-09-24 14:47     ` Zhuxu Ran
2026-09-22 15:46 ` [PATCH v4 09/11] rtc: cv1800: Add RTC and system reset support Zhuxu Ran
2026-09-23 17:51   ` Yao Zi
2026-09-24  4:05     ` Zhuxu Ran
2026-09-22 15:46 ` [PATCH v4 10/11] riscv: dts: sophgo: Drop local CV18xx devicetrees Zhuxu Ran
2026-09-22 15:46 ` [PATCH v4 11/11] clk: sophgo: cv1800b: Drop legacy compatible string Zhuxu Ran

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.