Skip to contentSkip to conversation

board: sophgo: milkv_duo: Add ethernet support for Milk-V Duo board

PATCH In review Kongyang Liu 3 participants 10 messages Mar 10, 2024 – Mar 15, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover board: sophgo: milkv_duo: Add ethernet support for Milk-V Duo board

This series add init code for cv1800b ethernet phy and enable ethernet support for Sophgo Milk-V Duo board.

In cv1800b, due to the PHY register phy_id being initialized to 0, it is necessary to initialize the PHY before the ethernet driver initialization. Therefore, the initialization code is placed in the board_init function.

Duo to modification of dts and defconfig, This series depends on the series:
https://lore.kernel.org/all/[email protected]/

Kongyang Liu (3):
board: milkv_duo: Add init code for Milk-V Duo ethernet
riscv: dts: sophgo: Add ethernet node
configs: milkv_duo: Add ethernet configs

 arch/riscv/dts/cv18xx.dtsi        |  6 +++
 board/sophgo/milkv_duo/Makefile   |  3 +-
 board/sophgo/milkv_duo/board.c    |  4 ++
 board/sophgo/milkv_duo/ethernet.c | 79 +++++++++++++++++++++++++++++++
 board/sophgo/milkv_duo/ethernet.h | 11 +++++
 configs/milkv_duo_defconfig       |  4 ++
 drivers/net/designware.c          |  1 +
 7 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 board/sophgo/milkv_duo/ethernet.c
 create mode 100644 board/sophgo/milkv_duo/ethernet.h
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/3 board: milkv_duo: Add init code for Milk-V Duo ethernet

Initialize register in cv1800b ethernet phy to make it compatible with generic phy driver

---

 board/sophgo/milkv_duo/Makefile   |  3 +-
 board/sophgo/milkv_duo/board.c    |  4 ++
 board/sophgo/milkv_duo/ethernet.c | 79 +++++++++++++++++++++++++++++++
 board/sophgo/milkv_duo/ethernet.h | 11 +++++
 drivers/net/designware.c          |  1 +
 5 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 board/sophgo/milkv_duo/ethernet.c
 create mode 100644 board/sophgo/milkv_duo/ethernet.h
board/sophgo/milkv_duo/Makefile +2 -1
index a087013f5c..d0525eba85 100644
@@ -2,4 +2,5 @@
 #
 # Copyright (c) 2024, Kongyang Liu <[email protected]>
 
-obj-y := board.o
+obj-y += board.o
+obj-$(CONFIG_NET) += ethernet.o
board/sophgo/milkv_duo/board.c +4 -0
index eaa47be173..311576fe1c 100644
@@ -3,7 +3,11 @@
  * Copyright (c) 2024, Kongyang Liu <[email protected]>
  */
 
+#include "ethernet.h"
+
 int board_init(void)
 {
+	if (IS_ENABLED(CONFIG_NET))
+		cv1800b_ephy_init();
 	return 0;
 }
board/sophgo/milkv_duo/ethernet.c new file +79 -0

79 lines not on this page · raw message

board/sophgo/milkv_duo/ethernet.h new file +11 -0
new file mode 100644
index 0000000000..7b21f1b0f6
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2024, Kongyang Liu <[email protected]>
+ */
+
+#ifndef __CV1800B_ETHERNET_H
+#define __CV1800B_ETHERNET_H
+
+void cv1800b_ephy_init(void);
+
+#endif
drivers/net/designware.c +1 -0
index c222197b11..e4e173f9fd 100644
@@ -861,6 +861,7 @@ static const struct udevice_id designware_eth_ids[] = {
 	{ .compatible = "amlogic,meson6-dwmac" },
 	{ .compatible = "st,stm32-dwmac" },
 	{ .compatible = "snps,arc-dwmac-3.70a" },
+	{ .compatible = "sophgo,cv1800b-ethernet" },
 	{ }
 };
 
Signature · 1 line
2.41.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] board: milkv_duo: Add init code for Milk-V Duo ethernet

Quoted 6 lines · Kongyang Liu

Initialize register in cv1800b ethernet phy to make it compatible with generic phy driver

---

Quoted 8 lines
 board/sophgo/milkv_duo/Makefile   |  3 +-
 board/sophgo/milkv_duo/board.c    |  4 ++
 board/sophgo/milkv_duo/ethernet.c | 79 +++++++++++++++++++++++++++++++
 board/sophgo/milkv_duo/ethernet.h | 11 +++++
 drivers/net/designware.c          |  1 +
 5 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 board/sophgo/milkv_duo/ethernet.c
 create mode 100644 board/sophgo/milkv_duo/ethernet.h
#3 lore raw

PATCH 2/3 riscv: dts: sophgo: Add ethernet node

In reply to Kongyang Liu

Add ethernet node for cv1800b SoC

---

 arch/riscv/dts/cv18xx.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/riscv/dts/cv18xx.dtsi +6 -0
index ec99c4deeb..013372a40c 100644
@@ -197,6 +197,12 @@
 			status = "disabled";
 		};
 
+		ethernet0: ethernet@4070000 {
+			compatible = "sophgo,cv1800b-ethernet";
+			reg = <0x04070000 0x10000>;
+			phy-mode = "rmii";
+		};
+
 		plic: interrupt-controller@70000000 {
 			reg = <0x70000000 0x4000000>;
 			interrupts-extended = <&cpu0_intc 11>, <&cpu0_intc 9>;
Signature · 1 line
2.41.0
#4 lore raw

Re: [PATCH 2/3] riscv: dts: sophgo: Add ethernet node

Quoted 7 lines · Kongyang Liu

Add ethernet node for cv1800b SoC

---

 arch/riscv/dts/cv18xx.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

Hi KongYang,

Will there be a patch adding this ethernet node for kernel as well ?

Best regards,
Leo

#5 lore raw

Re: [PATCH 2/3] riscv: dts: sophgo: Add ethernet node

Quoted 6 lines · Leo Liang
Quoted 5 lines · Kongyang Liu

Add ethernet node for cv1800b SoC

---

Quoted 6 lines
Quoted 2 lines
 arch/riscv/dts/cv18xx.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

Hi KongYang,

Will there be a patch adding this ethernet node for kernel as well ?

It's highly like that the compatible of "cv1800b-ethernet" will be requested to be changed to "cv1800b-dwmac" to match the designware IP used in other SoCs.

The added node also looks suspiciously missing any clocks or interrupts.

#6 lore raw

Re: [PATCH 2/3] riscv: dts: sophgo: Add ethernet node

Quoted 11 lines · Conor Dooley <[email protected]> 于2024年3月12日周二 21:20写道:
Quoted 9 lines · Leo Liang
Quoted 7 lines · Kongyang Liu

Add ethernet node for cv1800b SoC

---

 arch/riscv/dts/cv18xx.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
Quoted 8 lines
Quoted 3 lines

Hi KongYang,

Will there be a patch adding this ethernet node for kernel as well ?

It's highly like that the compatible of "cv1800b-ethernet" will be requested to be changed to "cv1800b-dwmac" to match the designware IP used in other SoCs.

I will change it in next version

Quoted 1 line

The added node also looks suspiciously missing any clocks or interrupts.

If we only consider u-boot, since u-boot does not utilize interrupts and clocks, this code can function properly. However, if compatibility with the kernel is a concern, I will discuss this issue with who is working on Milk-V Duo Ethernet support for the kernel.

Best regards
Kongyang Liu

#7 lore raw

Re: [PATCH 2/3] riscv: dts: sophgo: Add ethernet node

In reply to Leo Liang
Quoted 7 lines · Leo Liang <[email protected]> 于2024年3月12日周二 17:59写道:
Quoted 5 lines · Kongyang Liu

Add ethernet node for cv1800b SoC

---

Quoted 7 lines
Quoted 2 lines
 arch/riscv/dts/cv18xx.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

Hi KongYang,

Will there be a patch adding this ethernet node for kernel as well ?

Currently, I'm only focusing on the u-boot for the Milk-V Duo board, while the kernel part is being handled by others. Therefore, this patch will not be added to the kernel.

Best regards
Kongyang Liu

Quoted 2 lines

Best regards,
Leo

#8 lore raw

PATCH 3/3 configs: milkv_duo: Add ethernet configs

In reply to Kongyang Liu

Add configs related to ethernet and ethernet boot command for Sophgo Milk-V Duo board

---

 configs/milkv_duo_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
configs/milkv_duo_defconfig +4 -0
index e8413d7aa9..f66c4c5358 100644
@@ -19,14 +19,18 @@ CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="milkv_duo# "
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PXE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_MMC=y
 CONFIG_MMC_IO_VOLTAGE=y
 CONFIG_MMC_UHS_SUPPORT=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_CV1800B=y
+CONFIG_ETH_DESIGNWARE=y
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
Signature · 1 line
2.41.0