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 <[email protected]>
> ---
>  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 <[email protected]>
> + */
> +
> +/*
> + * 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 <[email protected]>
> - */
> -
> -/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 <[email protected]>
>  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

Reply via email to