From 1d3ed9920a193e5d99d651d6ec1dbbe215ca172f Mon Sep 17 00:00:00 2001 From: "Anton D. Stavinskii" Date: Wed, 26 Nov 2025 21:21:16 +0400 Subject: [PATCH 1/6] riscv: dts: sophgo: cv180x: fix USB dwc2 FIFO sizes I've tested the current dwc2 FIFO configuration and found that USB device mode breaks in ECM mode when transmitting frames larger than 128 bytes. For example, large ICMP packets or iperf3 traffic cause the USB link to hang and eventually disconnect without any messages in dmesg. After switching to more conservative FIFO sizes, ECM becomes stable and no longer drops the connection. iperf3 now shows ~130 Mbit/s RX and ~100 Mbit/s TX on SG2002 (MilkV Duo 256M). Fix the FIFO sizes accordingly. Signed-off-by: Anton D. Stavinskii Reviewed-by: Inochi Amaoto Fixes: e307248a3c2d ("riscv: dts: sophgo: Add USB support for cv18xx") Link: https://lore.kernel.org/r/20251126172115.1894190-2-stavinsky@gmail.com Signed-off-by: Inochi Amaoto Signed-off-by: Chen Wang Signed-off-by: Chen Wang --- arch/riscv/boot/dts/sophgo/cv180x.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/boot/dts/sophgo/cv180x.dtsi b/arch/riscv/boot/dts/sophgo/cv180x.dtsi index 1b2b1969a6484e..06b0ce5a2db7af 100644 --- a/arch/riscv/boot/dts/sophgo/cv180x.dtsi +++ b/arch/riscv/boot/dts/sophgo/cv180x.dtsi @@ -438,8 +438,8 @@ clocks = <&clk CLK_AXI4_USB>, <&clk CLK_APB_USB>; clock-names = "otg", "utmi"; g-np-tx-fifo-size = <32>; - g-rx-fifo-size = <536>; - g-tx-fifo-size = <768 512 512 384 128 128>; + g-rx-fifo-size = <1536>; + g-tx-fifo-size = <128 128 64 64 64 64 32 32>; interrupts = ; phys = <&usbphy>; phy-names = "usb2-phy"; From a18b1d9c7c10bbd751a85e88a8cde64bee4fbf1f Mon Sep 17 00:00:00 2001 From: system64fumo Date: Tue, 2 Dec 2025 09:44:53 +0200 Subject: [PATCH 2/6] dt-bindings: riscv: add MilkV Duo256M bindings --- Documentation/devicetree/bindings/soc/sophgo/sophgo.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/sophgo/sophgo.yaml b/Documentation/devicetree/bindings/soc/sophgo/sophgo.yaml index 1c502618de51f3..fcb1d905da7d88 100644 --- a/Documentation/devicetree/bindings/soc/sophgo/sophgo.yaml +++ b/Documentation/devicetree/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 From 43e3be9045dc9990344b2b931b45085bf841a6db Mon Sep 17 00:00:00 2001 From: system64fumo Date: Tue, 2 Dec 2025 09:45:53 +0200 Subject: [PATCH 3/6] riscv: dts: sophgo: Add MilkV Duo256M device tree --- arch/riscv/boot/dts/sophgo/Makefile | 1 + .../boot/dts/sophgo/sg2002-milkv-duo-256m.dts | 100 ++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 arch/riscv/boot/dts/sophgo/sg2002-milkv-duo-256m.dts diff --git a/arch/riscv/boot/dts/sophgo/Makefile b/arch/riscv/boot/dts/sophgo/Makefile index 6f65526d4193b3..f722ac5f17d408 100644 --- a/arch/riscv/boot/dts/sophgo/Makefile +++ b/arch/riscv/boot/dts/sophgo/Makefile @@ -2,6 +2,7 @@ dtb-$(CONFIG_ARCH_SOPHGO) += cv1800b-milkv-duo.dtb dtb-$(CONFIG_ARCH_SOPHGO) += cv1812h-huashan-pi.dtb dtb-$(CONFIG_ARCH_SOPHGO) += sg2002-licheerv-nano-b.dtb +dtb-$(CONFIG_ARCH_SOPHGO) += sg2002-milkv-duo-256m.dtb dtb-$(CONFIG_ARCH_SOPHGO) += sg2042-milkv-pioneer.dtb dtb-$(CONFIG_ARCH_SOPHGO) += sg2042-evb-v1.dtb dtb-$(CONFIG_ARCH_SOPHGO) += sg2042-evb-v2.dtb diff --git a/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo-256m.dts b/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo-256m.dts new file mode 100644 index 00000000000000..d418f079582cdc --- /dev/null +++ b/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo-256m.dts @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2025 Amir Dahan + */ + +/dts-v1/; + +#include "sg2002.dtsi" + +/ { + model = "Milk-V Duo256M"; + compatible = "milkv,duo256m", "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>; +}; + +&pinctrl { + uart0_cfg: uart0-cfg { + uart0-pins { + pinmux = , + ; + bias-pull-up; + drive-strength-microamp = <10800>; + power-source = <3300>; + }; + }; + + sdhci0_cfg: sdhci0-cfg { + sdhci0-clk-pins { + pinmux = ; + bias-pull-up; + drive-strength-microamp = <16100>; + power-source = <3300>; + }; + + sdhci0-cmd-pins { + pinmux = ; + bias-pull-up; + drive-strength-microamp = <10800>; + power-source = <3300>; + }; + + sdhci0-data-pins { + pinmux = , + , + , + ; + bias-pull-up; + drive-strength-microamp = <10800>; + power-source = <3300>; + }; + + sdhci0-cd-pins { + pinmux = ; + 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"; +}; From 6e0d5512d3cd6895648e0fc436b9ed4c61364f3a Mon Sep 17 00:00:00 2001 From: system64fumo Date: Tue, 2 Dec 2025 09:53:05 +0200 Subject: [PATCH 4/6] riscv: dts: sophgo: cv180x: Add gpio4 (PWR_GPIO) --- arch/riscv/boot/dts/sophgo/cv180x.dtsi | 19 +++++++++++++++++++ arch/riscv/boot/dts/sophgo/cv18xx-reset.h | 1 + 2 files changed, 20 insertions(+) diff --git a/arch/riscv/boot/dts/sophgo/cv180x.dtsi b/arch/riscv/boot/dts/sophgo/cv180x.dtsi index 06b0ce5a2db7af..6b11a24a4d169b 100644 --- a/arch/riscv/boot/dts/sophgo/cv180x.dtsi +++ b/arch/riscv/boot/dts/sophgo/cv180x.dtsi @@ -160,6 +160,25 @@ }; }; + gpio4: gpio@5021000 { + compatible = "snps,dw-apb-gpio"; + reg = <0x5021000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + resets = <&rst RST_GPIO4>; + + 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 = ; + }; + }; + saradc: adc@30f0000 { compatible = "sophgo,cv1800b-saradc"; reg = <0x030f0000 0x1000>; diff --git a/arch/riscv/boot/dts/sophgo/cv18xx-reset.h b/arch/riscv/boot/dts/sophgo/cv18xx-reset.h index 7e7c5ca2dbbd78..04a93057939259 100644 --- a/arch/riscv/boot/dts/sophgo/cv18xx-reset.h +++ b/arch/riscv/boot/dts/sophgo/cv18xx-reset.h @@ -38,6 +38,7 @@ #define RST_PWM1 33 #define RST_PWM2 34 #define RST_PWM3 35 +#define RST_GPIO4 36 #define RST_SPI0 40 #define RST_SPI1 41 #define RST_SPI2 42 From c44ca5403ecf307bc4402592fb208dfc202d353f Mon Sep 17 00:00:00 2001 From: system64fumo Date: Tue, 2 Dec 2025 09:58:27 +0200 Subject: [PATCH 5/6] riscv: dts: sophgo: Add MilkV Duo LEDs --- arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts | 9 +++++++++ arch/riscv/boot/dts/sophgo/sg2002-milkv-duo-256m.dts | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts b/arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts index 0e6d79e6e3a4aa..853e18559699e5 100644 --- a/arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts +++ b/arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts @@ -5,6 +5,7 @@ /dts-v1/; +#include #include "cv1800b.dtsi" / { @@ -33,6 +34,14 @@ no-map; }; }; + + gpio-leds { + compatible = "gpio-leds"; + + blue_led { + gpios = <&porta 24 GPIO_ACTIVE_HIGH>; + }; + }; }; &osc { diff --git a/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo-256m.dts b/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo-256m.dts index d418f079582cdc..b278721675b40f 100644 --- a/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo-256m.dts +++ b/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo-256m.dts @@ -5,6 +5,7 @@ /dts-v1/; +#include #include "sg2002.dtsi" / { @@ -26,6 +27,14 @@ chosen { stdout-path = "serial0:115200n8"; }; + + gpio-leds { + compatible = "gpio-leds"; + + blue_led { + gpios = <&porte 2 GPIO_ACTIVE_HIGH>; + }; + }; }; &osc { From 7108f1676593139800958295fefb87da8c346a39 Mon Sep 17 00:00:00 2001 From: system64fumo Date: Tue, 2 Dec 2025 11:28:30 +0200 Subject: [PATCH 6/6] riscv: dts: sophgo: cv1800b-milkv-duo: Correct LED gpios --- arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts b/arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts index 853e18559699e5..efcbbdc9bd35c1 100644 --- a/arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts +++ b/arch/riscv/boot/dts/sophgo/cv1800b-milkv-duo.dts @@ -39,7 +39,7 @@ compatible = "gpio-leds"; blue_led { - gpios = <&porta 24 GPIO_ACTIVE_HIGH>; + gpios = <&portc 22 GPIO_ACTIVE_HIGH>; }; }; };