Skip to contentSkip to conversation

Add initial Milk-V Duo S board support

PATCH Superseded Joshua Milas 2 participants 11 messages Mar 28 – Apr 2

Subsystems (6)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add initial Milk-V Duo S board support

This adds an initial device tree for the Milk-V Duo S board with support for reading from the SD card and network over Ethernet. This is continued work from Michael Opdenacker's v6 series [1] on the ARM64 and RISCV side. It has been tested with ARM64 and RISCV64 to boot from an SD card, have networking, and read I2C slave devices over i2c4.

---

v4
- Rebased to latest sophogo/for-next
- Added usb node to arm64 and riscv DTS
- Removed sg200x link in commit messages
- Added missing change to v3 and removed link from v2

v3: https://lore.kernel.org/sophgo/[email protected]/
- Added sg2000 interrupt controller and timer to documentation
- Added sg2000.dtsi for RISCV and moved DTS over to use it
- remove devices from DTS's to match what is available in the default pinmux config. spi0-2, i2c0-3, uart1-4
- Added i2c4 and spi3 aliases
- Removed milkv,duo-s from sophgo,cv1812h in documentation

v2: https://lore.kernel.org/sophgo/[email protected]/
- Made new entry in docs to avoid DTC error
- "Milk-V DuoS" -> "Milk-V Duo S"
- Sorting of aliases
- Added uart*, emmc, mdio, gmac0, i2c*, spi*, dmac, saradc
to device tree matching what is available on the pinout
- Removal of 'no-mmc' and 'no-sdio' for sdhci0 as it works without
- Added riscv device tree

v1: https://lore.kernel.org/sophgo/[email protected]/

Joshua Milas (5):
dt-bindings: soc: sophgo: add Milk-V Duo S board compatibles
arm64: dts: sophgo: add initial Milk-V Duo S board support
dt-bindings: soc: sophgo: add sg2000 plic and clint documentation
riscv64: dts: sophgo: add SG2000 dtsi
riscv64: dts: sophgo: add initial Milk-V Duo S board support

 .../sifive,plic-1.0.0.yaml                    |  1 +
 .../bindings/soc/sophgo/sophgo.yaml           |  4 +
 .../bindings/timer/sifive,clint.yaml          |  1 +
 arch/arm64/boot/dts/sophgo/Makefile           |  1 +
 .../boot/dts/sophgo/sg2000-milkv-duo-s.dts    | 85 +++++++++++++++++++
 arch/riscv/boot/dts/sophgo/Makefile           |  1 +
 .../boot/dts/sophgo/sg2000-milkv-duo-s.dts    | 85 +++++++++++++++++++
 arch/riscv/boot/dts/sophgo/sg2000.dtsi        | 53 ++++++++++++
 8 files changed, 231 insertions(+)
 create mode 100644 arch/arm64/boot/dts/sophgo/sg2000-milkv-duo-s.dts
 create mode 100644 arch/riscv/boot/dts/sophgo/sg2000-milkv-duo-s.dts
 create mode 100644 arch/riscv/boot/dts/sophgo/sg2000.dtsi

base-commit: 9aa6068586a9b4cd34cf04f8dee72a7283ab4ae4

Signature · 1 line
2.53.0
#1 lore raw

PATCH v4 1/5 dt-bindings: soc: sophgo: add Milk-V Duo S board compatibles

Document the compatible strings for the Milk-V Duo S board [1] which uses the SOPHGO SG2000 SoC.

---
 Documentation/devicetree/bindings/soc/sophgo/sophgo.yaml | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/soc/sophgo/sophgo.yaml +4 -0
index 1c502618de51f..0b6fbab48b743 100644
@@ -31,6 +31,10 @@ properties:
               - milkv,duo-module-01-evb
           - const: milkv,duo-module-01
           - const: sophgo,sg2000
+      - items:
+          - enum:
+              - milkv,duo-s
+          - const: sophgo,sg2000
       - items:
           - enum:
               - sipeed,licheerv-nano-b
Signature · 1 line
2.53.0
#2 lore raw

PATCH v4 2/5 arm64: dts: sophgo: add initial Milk-V Duo S board support

In reply to Joshua Milas

Adds initial arm64 support for the Milk-V Duo S board
[1] making it possible to boot Linux to the command line.

---
 arch/arm64/boot/dts/sophgo/Makefile           |  1 +
 .../boot/dts/sophgo/sg2000-milkv-duo-s.dts    | 85 +++++++++++++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 arch/arm64/boot/dts/sophgo/sg2000-milkv-duo-s.dts
arch/arm64/boot/dts/sophgo/Makefile +1 -0
index 94f52cd7d994b..68aace728223a 100644
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 dtb-$(CONFIG_ARCH_SOPHGO) += sg2000-milkv-duo-module-01-evb.dtb
+dtb-$(CONFIG_ARCH_SOPHGO) += sg2000-milkv-duo-s.dtb
arch/arm64/boot/dts/sophgo/sg2000-milkv-duo-s.dts new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
2.53.0
#3 lore raw

Re: [PATCH v4 2/5] arm64: dts: sophgo: add initial Milk-V Duo S board support

Hi Joshua

Thanks a lot for this new update!

Quoted 6 lines · Joshua Milas

Adds initial arm64 support for the Milk-V Duo S board
[1] making it possible to boot Linux to the command line.

...

Quoted 5 lines
arch/arm64/boot/dts/sophgo/sg2000-milkv-duo-s.dts new file +0 -0
new file mode 100644
index 0000000000000..4ae44b40f9edb

...

arch/arm64/boot/dts/sophgo/sg2000-milkv-duo-s.dts line 84

Quoted 5 lines
arch/arm64/boot/dts/sophgo/sg2000-milkv-duo-s.dts new file +5 -0
+
+&usb {
+       dr_mode = "host";
+       status = "okay";
+};

You have a small checkpatch.pl issue here:

./scripts/checkpatch.pl *.patch
...
WARNING: please, no spaces at the start of a line
#120: FILE: arch/riscv/boot/dts/sophgo/sg2000-milkv-duo-s.dts:82:
+       dr_mode = "host";$

WARNING: please, no spaces at the start of a line
#121: FILE: arch/riscv/boot/dts/sophgo/sg2000-milkv-duo-s.dts:83:
+       status = "okay";$

Replace the spaces by a tab as in the other entries in the DTS and you should be fine. Thanks again
Cheers
Michael.

Signature · 3 lines
Root Commit
Embedded Linux Training and Consulting
https://rootcommit.com
#4 lore raw

Re: [PATCH v4 2/5] arm64: dts: sophgo: add initial Milk-V Duo S board support

Hi Michael,

Just fixed in my latest set and will post v5 after debugging your eth0 issue.

Thanks,
- Joshua Milas

#5 lore raw

PATCH v4 3/5 dt-bindings: soc: sophgo: add sg2000 plic and clint documentation

In reply to Joshua Milas

Document the compatible strings for the sg2000 interrupt controller and timer.

---
 .../bindings/interrupt-controller/sifive,plic-1.0.0.yaml         | 1 +
 Documentation/devicetree/bindings/timer/sifive,clint.yaml        | 1 +
 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/interrupt-controller/sifive,plic-1.0.0.yaml +1 -0
index e0267223887ec..decc43df3c839 100644
@@ -73,6 +73,7 @@ properties:
               - allwinner,sun20i-d1-plic
               - sophgo,cv1800b-plic
               - sophgo,cv1812h-plic
+              - sophgo,sg2000-plic
               - sophgo,sg2002-plic
               - sophgo,sg2042-plic
               - sophgo,sg2044-plic
Documentation/devicetree/bindings/timer/sifive,clint.yaml +1 -0
index 3bab40500df9b..54266b3c2a185 100644
@@ -50,6 +50,7 @@ properties:
               - allwinner,sun20i-d1-clint
               - sophgo,cv1800b-clint
               - sophgo,cv1812h-clint
+              - sophgo,sg2000-clint
               - sophgo,sg2002-clint
               - thead,th1520-clint
           - const: thead,c900-clint
Signature · 1 line
2.53.0
#6 lore raw

PATCH v4 4/5 riscv64: dts: sophgo: add SG2000 dtsi

In reply to Joshua Milas

Adds sg2000.dtsi on the RISCV side.

---
 arch/riscv/boot/dts/sophgo/sg2000.dtsi | 53 ++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 arch/riscv/boot/dts/sophgo/sg2000.dtsi
arch/riscv/boot/dts/sophgo/sg2000.dtsi new file +53 -0
new file mode 100644
index 0000000000000..412adacc00576
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+
+#define SOC_PERIPHERAL_IRQ(nr)	((nr) + 16)
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/pinctrl/pinctrl-sg2000.h>
+#include "cv180x-cpus.dtsi"
+#include "cv180x.dtsi"
+#include "cv181x.dtsi"
+
+/ {
+	compatible = "sophgo,sg2000";
+
+	memory@80000000 {
+		device_type = "memory";
+		reg = <0x80000000 0x10000000>;
+	};
+
+	soc {
+		interrupt-parent = <&plic>;
+		dma-noncoherent;
+
+		pinctrl: pinctrl@3001000 {
+			compatible = "sophgo,sg2000-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,sg2000-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,sg2000-clint", "thead,c900-clint";
+			reg = <0x74000000 0x10000>;
+			interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>;
+		};
+	};
+};
Signature · 1 line
2.53.0
#7 lore raw

PATCH v4 5/5 riscv64: dts: sophgo: add initial Milk-V Duo S board support

In reply to Joshua Milas

This adds initial riscv support for the Milk-V Duo S board
[1] making it possible to boot Linux to the command line.

---
 arch/riscv/boot/dts/sophgo/Makefile           |  1 +
 .../boot/dts/sophgo/sg2000-milkv-duo-s.dts    | 85 +++++++++++++++++++
 2 files changed, 86 insertions(+)
 create mode 100644 arch/riscv/boot/dts/sophgo/sg2000-milkv-duo-s.dts
arch/riscv/boot/dts/sophgo/Makefile +1 -0
index 6f65526d4193b..58cc6b70d8de4 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 dtb-$(CONFIG_ARCH_SOPHGO) += cv1800b-milkv-duo.dtb
 dtb-$(CONFIG_ARCH_SOPHGO) += cv1812h-huashan-pi.dtb
+dtb-$(CONFIG_ARCH_SOPHGO) += sg2000-milkv-duo-s.dtb
 dtb-$(CONFIG_ARCH_SOPHGO) += sg2002-licheerv-nano-b.dtb
 dtb-$(CONFIG_ARCH_SOPHGO) += sg2042-milkv-pioneer.dtb
 dtb-$(CONFIG_ARCH_SOPHGO) += sg2042-evb-v1.dtb
arch/riscv/boot/dts/sophgo/sg2000-milkv-duo-s.dts new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
2.53.0
#8 lore raw
In reply to Joshua Milas

Hi Joshua

Quoted 6 lines · Joshua Milas

This adds an initial device tree for the Milk-V Duo S board with support for reading from the SD card and network over Ethernet. This is continued work from Michael Opdenacker's v6 series [1] on the ARM64 and RISCV side. It has been tested with ARM64 and RISCV64 to boot from an SD card, have networking, and read I2C slave devices over i2c4.

I could test successfully on RISC-V, booting from MMC on a command line shell, and testing i2c4. However, I have an issue with Ethernet. When I add "ip=172.24.0.2" (for example) to the kernel command line, I'm getting this:

[    2.586984] stmmaceth 4070000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0 [    2.596428] stmmaceth 4070000.ethernet eth0: cannot attach to PHY (error: -ENODEV) [    2.627351] IP-Config: Failed to open eth0
[    2.631859] IP-Config: No network devices available

However, "eth0" appears in the list of networking devices. Does this work on your side?
Cheers
Michael.

Signature · 9 lines
Root Commit
Embedded Linux Training and Consulting
https://rootcommit.com


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#9 lore raw

Hi Michael,

Thanks for testing this. I am not seeing that issue on my arm64 or riscv side. I am able to add an IP and do anything I can think of on the arm64 side.

[   96.618687] stmmaceth 4070000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
[   96.633977] stmmaceth 4070000.ethernet eth0: PHY [mdio_mux-0.0:01] driver [Generic PHY] (irq=POLL)
[   96.676436] dwmac1000: Master AXI performs any burst length
[   96.702852] stmmaceth 4070000.ethernet eth0: No Safety Features support found
[   96.748740] stmmaceth 4070000.ethernet eth0: IEEE 1588-2002 Timestamp supported
[   96.772880] stmmaceth 4070000.ethernet eth0: configuring for phy/internal link mode
[ 1359.377528] stmmaceth 4070000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off

I can do the same on the riscv side but get a unhandled signal for TLS traffic which I believe is unrelated as it doesn't happen on adding an IP.

I'll send over my configs to see if that helps.

Have a great day,
- Joshua Milas

#10 lore raw

Hi Joshua

Quoted 13 lines · Joshua Milas

Hi Michael,

Thanks for testing this. I am not seeing that issue on my arm64 or riscv side. I am able to add an IP and do anything I can think of on the arm64 side.

[   96.618687] stmmaceth 4070000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
[   96.633977] stmmaceth 4070000.ethernet eth0: PHY [mdio_mux-0.0:01] driver [Generic PHY] (irq=POLL)
[   96.676436] dwmac1000: Master AXI performs any burst length
[   96.702852] stmmaceth 4070000.ethernet eth0: No Safety Features support found
[   96.748740] stmmaceth 4070000.ethernet eth0: IEEE 1588-2002 Timestamp supported
[   96.772880] stmmaceth 4070000.ethernet eth0: configuring for phy/internal link mode
[ 1359.377528] stmmaceth 4070000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
Quoted 4 lines

I can do the same on the riscv side but get a unhandled signal for TLS traffic which I believe is unrelated as it doesn't happen on adding an IP.

I'll send over my configs to see if that helps.

I confirmed I managed to test the eth0 network interface on the riscv side using the configuration you shared. It would take me more time to test on arm64 :D| You can send a update with your checkpatch fixes.

Thanks for everything!
Cheers
Michael.

Signature · 3 lines
Root Commit
Embedded Linux Training and Consulting
https://rootcommit.com