Skip to contentSkip to conversation

Add ethernet driver for StarFive JH7110 SoC

PATCH Superseded Yanhong Wang 3 participants 20 messages May 25, 2023 – Jun 7, 2023

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add ethernet driver for StarFive JH7110 SoC

This series of patches base on the latest branch/master,and adds ethernet support for the StarFive JH7110 RISC-V SoC. The series includes EEPROM, PHY and MAC drivers. The PHY model is YT8531 (from Motorcomm Inc), and the MAC version is dwmac-5.20 (from Synopsys DesignWare).

The implementation of the phy driver is ported from linux, but it has been adjusted for the u-boot framework.

EEPROM stores board-related information, such as DDR capacity, PCB version, MAC address, etc.

The main difference between StarFive VisionFive 2 1.2A and 1.3B is gmac, but the difference in gmac is not defined in DT, but reads the PCB version from EEPROM, and then dynamically configures the difference of gmac according to different PCB versions, which is compatible with 1.2A and 1.3B versions, which is more user-friendly.

The PHY and MAC driver has been tested on the StarFive VisionFive 2 1.2A and 1.3B boards and works normally.

For more information and support,you can visit RVspace wiki[1].
[1] https://wiki.rvspace.org/

v4:
- Reworded the definition of the 'pbuf' variable in visionfive2-i2c-eeprom.c from a const pointer to const union.
- Added the section (".data") attribute to the 'pbuf' and 'has_been_read' global variables in visionfive2-i2-eeprom.c.

v3:
- Added EEPROM support.
- Combine the board device tree of 1.2A and 1.3B into one.
- Removed the delay configuration of gmac phy clock from DT.
- Dynamically configure gmac differences of 1.2A and 1.3B to DT according to the PCB version.
- DDR capacity information is read from EEPROM first, if not, it is defined by default in DT.

v2:
- Reworded the phy driver. Added platform private data struct to save the configuration data read from dts.
- Reworded the MAC driver. Added platform private data struct to save the configuration data read from dts.

Previous versions:
v1 - https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v2 - https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/
v3 - https://patchwork.ozlabs.org/project/uboot/cover/[email protected]/

Yanhong Wang (11):
net: phy: Add driver for Motorcomm yt8531 gigabit ethernet phy
net: dwc_eth_qos: Add StarFive ethernet driver glue layer
eeprom: starfive: Enable ID EEPROM configuration
ram: starfive: Read memory size information from EEPROM
board: starfive: Dynamic configuration of DT for 1.2A and 1.3B
riscv: dts: jh7110: Add ethernet device tree nodes
riscv: dts: jh7110: Combine the board device tree files of 1.2A and

    1.3B

riscv: dts: starfive: Add support eeprom device tree node
doc: board: starfive: Reword the make defconfig information
configs: starfive: Enable ethernet configuration for StarFive
VisionFive2
configs: starfive: Enable ID EEPROM configuration

 arch/riscv/cpu/jh7110/spl.c                   |  32 +-
 arch/riscv/dts/Makefile                       |   3 +-
 ... jh7110-starfive-visionfive-2-u-boot.dtsi} |  39 +-
 .../jh7110-starfive-visionfive-2-v1.2a.dts    |  12 -
 ...10-starfive-visionfive-2-v1.3b-u-boot.dtsi |  69 ---
 ...b.dts => jh7110-starfive-visionfive-2.dts} |   3 +-
 .../dts/jh7110-starfive-visionfive-2.dtsi     |  40 ++
 arch/riscv/dts/jh7110.dtsi                    |  69 +++
 arch/riscv/include/asm/arch-jh7110/eeprom.h   |  13 +
 board/starfive/visionfive2/Makefile           |   1 +
 board/starfive/visionfive2/spl.c              | 157 +++++
 .../visionfive2/starfive_visionfive2.c        |  13 +
 .../visionfive2/visionfive2-i2c-eeprom.c      | 561 ++++++++++++++++++
 configs/starfive_visionfive2_defconfig        |  32 +-
 doc/board/starfive/visionfive2.rst            |   6 +-
 drivers/net/Kconfig                           |   7 +
 drivers/net/Makefile                          |   1 +
 drivers/net/dwc_eth_qos.c                     |   6 +
 drivers/net/dwc_eth_qos.h                     |   1 +
 drivers/net/dwc_eth_qos_starfive.c            | 249 ++++++++
 drivers/net/phy/Kconfig                       |   6 +
 drivers/net/phy/Makefile                      |   1 +
 drivers/net/phy/motorcomm.c                   | 437 ++++++++++++++
 drivers/ram/starfive/starfive_ddr.c           |   2 -
 24 files changed, 1665 insertions(+), 95 deletions(-)
 rename arch/riscv/dts/{jh7110-starfive-visionfive-2-v1.2a-u-boot.dtsi => jh7110-starfive-visionfive-2-u-boot.dtsi} (58%)
 delete mode 100644 arch/riscv/dts/jh7110-starfive-visionfive-2-v1.2a.dts
 delete mode 100644 arch/riscv/dts/jh7110-starfive-visionfive-2-v1.3b-u-boot.dtsi
 rename arch/riscv/dts/{jh7110-starfive-visionfive-2-v1.3b.dts => jh7110-starfive-visionfive-2.dts} (65%)
 create mode 100644 arch/riscv/include/asm/arch-jh7110/eeprom.h
 create mode 100644 board/starfive/visionfive2/visionfive2-i2c-eeprom.c
 create mode 100644 drivers/net/dwc_eth_qos_starfive.c
 create mode 100644 drivers/net/phy/motorcomm.c

base-commit: 62df7a39442902a71259568c13a4d496d5a514f4

Signature · 1 line
2.17.1
#1 lore raw

PATCH v4 1/11 net: phy: Add driver for Motorcomm yt8531 gigabit ethernet phy

Add a driver for the motorcomm yt8531 gigabit ethernet phy. We have verified the driver on StarFive VisionFive2 board.

---
 drivers/net/phy/Kconfig     |   6 +
 drivers/net/phy/Makefile    |   1 +
 drivers/net/phy/motorcomm.c | 437 ++++++++++++++++++++++++++++++++++++
 3 files changed, 444 insertions(+)
 create mode 100644 drivers/net/phy/motorcomm.c
drivers/net/phy/Kconfig +6 -0
index 24158776f5..0c3c39a550 100644
@@ -220,6 +220,12 @@ config PHY_MICREL_KSZ8XXX
 
 endif # PHY_MICREL
 
+config PHY_MOTORCOMM
+	tristate "Motorcomm PHYs"
+	help
+	  Enables support for Motorcomm network PHYs.
+	  Currently supports the YT8531 Gigabit Ethernet PHYs.
+
 config PHY_MSCC
 	bool "Microsemi Corp Ethernet PHYs support"
 
drivers/net/phy/Makefile +1 -0
index 85d17f109c..2487f366e1 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_PHY_MARVELL_10G) += marvell10g.o
 obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o
 obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o
 obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o
+obj-$(CONFIG_PHY_MOTORCOMM) += motorcomm.o
 obj-$(CONFIG_PHY_NATSEMI) += natsemi.o
 obj-$(CONFIG_PHY_NXP_C45_TJA11XX) += nxp-c45-tja11xx.o
 obj-$(CONFIG_PHY_NXP_TJA11XX) += nxp-tja11xx.o
drivers/net/phy/motorcomm.c new file +437 -0

437 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v4 2/11 net: dwc_eth_qos: Add StarFive ethernet driver glue layer

In reply to Yanhong Wang

The StarFive ETHQOS hardware has its own clock and reset,so add a corresponding glue driver to configure them.

---
 drivers/net/Kconfig                |   7 +
 drivers/net/Makefile               |   1 +
 drivers/net/dwc_eth_qos.c          |   6 +
 drivers/net/dwc_eth_qos.h          |   1 +
 drivers/net/dwc_eth_qos_starfive.c | 249 +++++++++++++++++++++++++++++
 5 files changed, 264 insertions(+)
 create mode 100644 drivers/net/dwc_eth_qos_starfive.c
drivers/net/Kconfig +7 -0
index 09039a283e..5540f0ea18 100644
@@ -249,6 +249,13 @@ config DWC_ETH_QOS_QCOM
 	  The Synopsys Designware Ethernet QOS IP block with specific
 	  configuration used in Qcom QCS404 SoC.
 
+config DWC_ETH_QOS_STARFIVE
+	bool "Synopsys DWC Ethernet QOS device support for STARFIVE"
+	depends on DWC_ETH_QOS
+	help
+	  The Synopsys Designware Ethernet QOS IP block with specific
+	  configuration used in STARFIVE  JH7110 soc.
+
 config E1000
 	bool "Intel PRO/1000 Gigabit Ethernet support"
 	depends on PCI
drivers/net/Makefile +1 -0
index 46a40e2ed9..d4af253b6f 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_DSA_SANDBOX) += dsa_sandbox.o
 obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o
 obj-$(CONFIG_DWC_ETH_QOS_IMX) += dwc_eth_qos_imx.o
 obj-$(CONFIG_DWC_ETH_QOS_QCOM) += dwc_eth_qos_qcom.o
+obj-$(CONFIG_DWC_ETH_QOS_STARFIVE) += dwc_eth_qos_starfive.o
 obj-$(CONFIG_E1000) += e1000.o
 obj-$(CONFIG_E1000_SPI) += e1000_spi.o
 obj-$(CONFIG_EEPRO100) += eepro100.o
drivers/net/dwc_eth_qos.c +6 -0
index 9bbba6eed0..1e92bd9ca9 100644
@@ -1725,6 +1725,12 @@ static const struct udevice_id eqos_ids[] = {
 		.data = (ulong)&eqos_qcom_config
 	},
 #endif
+#if IS_ENABLED(CONFIG_DWC_ETH_QOS_STARFIVE)
+	{
+		.compatible = "starfive,jh7110-dwmac",
+		.data = (ulong)&eqos_jh7110_config
+	},
+#endif
 
 	{ }
 };
drivers/net/dwc_eth_qos.h +1 -0
index fddbe9336c..a6b719af80 100644
@@ -289,3 +289,4 @@ int eqos_null_ops(struct udevice *dev);
 
 extern struct eqos_config eqos_imx_config;
 extern struct eqos_config eqos_qcom_config;
+extern struct eqos_config eqos_jh7110_config;
drivers/net/dwc_eth_qos_starfive.c new file +249 -0

249 lines not on this page · raw message

Signature · 1 line
2.17.1
#3 lore raw

PATCH v4 3/11 eeprom: starfive: Enable ID EEPROM configuration

In reply to Yanhong Wang

Enabled ID_EEPROM configuration for StarFive VisionFive2 board.

---
 arch/riscv/include/asm/arch-jh7110/eeprom.h   |  13 +
 board/starfive/visionfive2/Makefile           |   1 +
 .../visionfive2/visionfive2-i2c-eeprom.c      | 561 ++++++++++++++++++
 3 files changed, 575 insertions(+)
 create mode 100644 arch/riscv/include/asm/arch-jh7110/eeprom.h
 create mode 100644 board/starfive/visionfive2/visionfive2-i2c-eeprom.c
arch/riscv/include/asm/arch-jh7110/eeprom.h new file +13 -0
new file mode 100644
index 0000000000..f354d5c60c
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2023 StarFive Technology Co., Ltd.
+ * Author: Yanhong Wang<[email protected]>
+ */
+
+#ifndef _ASM_RISCV_EEPROM_H
+#define _ASM_RISCV_EEPROM_H
+
+u8 get_pcb_revision_from_eeprom(void);
+u32 get_ddr_size_from_eeprom(void);
+
+#endif /* _ASM_RISCV_EEPROM_H */
board/starfive/visionfive2/Makefile +1 -0
index 66c854df39..c7ba4f7ed6 100644
@@ -5,3 +5,4 @@
 
 obj-y	:= starfive_visionfive2.o
 obj-$(CONFIG_SPL_BUILD) += spl.o
+obj-$(CONFIG_ID_EEPROM) += visionfive2-i2c-eeprom.o
board/starfive/visionfive2/visionfive2-i2c-eeprom.c new file +561 -0

561 lines not on this page · raw message

Signature · 1 line
2.17.1
#4 lore raw

PATCH v4 4/11 ram: starfive: Read memory size information from EEPROM

In reply to Yanhong Wang

StarFive VisionFive 2 has two versions, 1.2A and 1.3B, each version of DDR capacity includes 2G/4G/8G, a DT can not support multiple capacities, so the capacity size information is recorded to EEPROM, when DDR initialization required capacity size information is read from EEPROM.

If there is no information in EEPROM, it is initialized with the default size defined in DT.

---
 arch/riscv/cpu/jh7110/spl.c         | 32 ++++++++++++++++++++++++++++-
 drivers/ram/starfive/starfive_ddr.c |  2 --
 2 files changed, 31 insertions(+), 3 deletions(-)
arch/riscv/cpu/jh7110/spl.c +31 -1
index 104f0fe949..72adcefa0e 100644
@@ -3,19 +3,49 @@
  * Copyright (C) 2022 StarFive Technology Co., Ltd.
  * Author: Yanhong Wang<[email protected]>
  */
-
+#include <common.h>
+#include <asm/arch/eeprom.h>
 #include <asm/csr.h>
 #include <asm/sections.h>
 #include <dm.h>
+#include <linux/sizes.h>
 #include <log.h>
+#include <init.h>
 
 #define CSR_U74_FEATURE_DISABLE	0x7c1
 #define L2_LIM_MEM_END	0x81FFFFFUL
 
+DECLARE_GLOBAL_DATA_PTR;
+
+static bool check_ddr_size(phys_size_t size)
+{
+	switch (size) {
+	case SZ_2:
+	case SZ_4:
+	case SZ_8:
+	case SZ_16:
+		return true;
+	default:
+		return false;
+	}
+}
+
 int spl_soc_init(void)
 {
 	int ret;
 	struct udevice *dev;
+	phys_size_t size;
+
+	ret = fdtdec_setup_mem_size_base();
+	if (ret)
+		return ret;
+
+	/* Read the definition of the DDR size from eeprom, and if not,
+	 * use the definition in DT
+	 */
+	size = (get_ddr_size_from_eeprom() >> 16) & 0xFF;
+	if (check_ddr_size(size))
+		gd->ram_size = size << 30;
 
 	/* DDR init */
 	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
drivers/ram/starfive/starfive_ddr.c +0 -2
index 553f2ce6f4..a0a3d6b33d 100644
@@ -72,8 +72,6 @@ static int starfive_ddr_probe(struct udevice *dev)
 	u64 rate;
 	int ret;
 
-	/* Read memory base and size from DT */
-	fdtdec_setup_mem_size_base();
 	priv->info.base = gd->ram_base;
 	priv->info.size = gd->ram_size;
 
Signature · 1 line
2.17.1
#5 lore raw

PATCH v4 5/11 board: starfive: Dynamic configuration of DT for 1.2A and 1.3B

In reply to Yanhong Wang

The main difference between StarFive VisionFive 2 1.2A and 1.3B is gmac. You can read the PCB version of the current board by get_pcb_revision_from_eeprom(), and then dynamically configure the difference of gmac in spl_perform_fixups() according to different PCB versions, so that one DT and one defconfig can support both 1.2A and 1.3B versions, which is more user-friendly.

---
 board/starfive/visionfive2/spl.c              | 157 ++++++++++++++++++
 .../visionfive2/starfive_visionfive2.c        |  13 ++
 2 files changed, 170 insertions(+)
board/starfive/visionfive2/spl.c +157 -0
index db0b4cb433..7acd3995aa 100644
@@ -5,16 +5,173 @@
  */
 
 #include <common.h>
+#include <asm/arch/eeprom.h>
 #include <asm/arch/regs.h>
 #include <asm/arch/spl.h>
 #include <asm/io.h>
+#include <dt-bindings/clock/starfive,jh7110-crg.h>
+#include <fdt_support.h>
+#include <linux/libfdt.h>
 #include <log.h>
 #include <spl.h>
 
+DECLARE_GLOBAL_DATA_PTR;
 #define JH7110_CLK_CPU_ROOT_OFFSET		0x0U
 #define JH7110_CLK_CPU_ROOT_SHIFT		24
 #define JH7110_CLK_CPU_ROOT_MASK		GENMASK(29, 24)
 
+struct starfive_vf2_pro {
+	const char *path;
+	const char *name;
+	const char *value;
+};
+
+static const struct starfive_vf2_pro starfive_vera[] = {
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0", "rx-internal-delay-ps",
+		"1900"},
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0", "tx-internal-delay-ps",
+		"1350"}
+};
+
+static const struct starfive_vf2_pro starfive_verb[] = {
+	{"/soc/ethernet@16030000", "starfive,tx-use-rgmii-clk", NULL},
+	{"/soc/ethernet@16040000", "starfive,tx-use-rgmii-clk", NULL},
+
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0",
+		"motorcomm,tx-clk-adj-enabled", NULL},
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0",
+		"motorcomm,tx-clk-100-inverted", NULL},
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0",
+		"motorcomm,tx-clk-1000-inverted", NULL},
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0",
+		"rx-internal-delay-ps", "1900"},
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0",
+		"tx-internal-delay-ps", "1500"},
+
+	{"/soc/ethernet@16040000/mdio/ethernet-phy@1",
+		"motorcomm,tx-clk-adj-enabled", NULL},
+	{ "/soc/ethernet@16040000/mdio/ethernet-phy@1",
+		"motorcomm,tx-clk-100-inverted", NULL},
+	{"/soc/ethernet@16040000/mdio/ethernet-phy@1",
+		"rx-internal-delay-ps", "0"},
+	{"/soc/ethernet@16040000/mdio/ethernet-phy@1",
+		"tx-internal-delay-ps", "0"},
+};
+
+void spl_fdt_fixup_version_a(void *fdt)
+{
+	u32 phandle;
+	u8 i;
+	int offset;
+	int ret;
+
+	fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
+			   "StarFive VisionFive 2 v1.2A");
+
+	offset = fdt_path_offset(fdt, "/soc/clock-controller@13020000");
+	phandle = fdt_get_phandle(fdt, offset);
+	offset = fdt_path_offset(fdt, "/soc/ethernet@16040000");
+
+	fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
+	fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_TX);
+	fdt_appendprop_u32(fdt, offset, "assigned-clocks", phandle);
+	fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_RX);
+
+	fdt_setprop_u32(fdt, offset,  "assigned-clock-parents", phandle);
+	fdt_appendprop_u32(fdt, offset,  "assigned-clock-parents",
+			   JH7110_SYSCLK_GMAC1_RMII_RTX);
+	fdt_appendprop_u32(fdt, offset,  "assigned-clock-parents", phandle);
+	fdt_appendprop_u32(fdt, offset,  "assigned-clock-parents",
+			   JH7110_SYSCLK_GMAC1_RMII_RTX);
+
+	fdt_setprop_string(fdt, fdt_path_offset(fdt, "/soc/ethernet@16040000"),
+			   "phy-mode", "rmii");
+
+	for (i = 0; i < ARRAY_SIZE(starfive_vera); i++) {
+		offset = fdt_path_offset(fdt, starfive_vera[i].path);
+
+		if (starfive_vera[i].value)
+			ret = fdt_setprop_u32(fdt, offset,  starfive_vera[i].name,
+					      dectoul(starfive_vera[i].value, NULL));
+		else
+			ret = fdt_setprop_empty(fdt, offset, starfive_vera[i].name);
+
+		if (ret) {
+			pr_err("%s set prop %s fail.\n", __func__, starfive_vera[i].name);
+				break;
+		}
+	}
+}
+
+void spl_fdt_fixup_version_b(void *fdt)
+{
+	u32 phandle;
+	u8 i;
+	int offset;
+	int ret;
+
+	fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
+			   "StarFive VisionFive 2 v1.3B");
+
+	/* gmac0 */
+	offset = fdt_path_offset(fdt, "/soc/clock-controller@17000000");
+	phandle = fdt_get_phandle(fdt, offset);
+	offset = fdt_path_offset(fdt, "/soc/ethernet@16030000");
+
+	fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
+	fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_AONCLK_GMAC0_TX);
+	fdt_setprop_u32(fdt, offset,  "assigned-clock-parents", phandle);
+	fdt_appendprop_u32(fdt, offset,  "assigned-clock-parents",
+			   JH7110_AONCLK_GMAC0_RMII_RTX);
+
+	/* gmac1 */
+	offset = fdt_path_offset(fdt, "/soc/clock-controller@13020000");
+	phandle = fdt_get_phandle(fdt, offset);
+	offset = fdt_path_offset(fdt, "/soc/ethernet@16040000");
+
+	fdt_setprop_u32(fdt, offset, "assigned-clocks", phandle);
+	fdt_appendprop_u32(fdt, offset, "assigned-clocks", JH7110_SYSCLK_GMAC1_TX);
+	fdt_setprop_u32(fdt, offset,  "assigned-clock-parents", phandle);
+	fdt_appendprop_u32(fdt, offset,  "assigned-clock-parents",
+			   JH7110_SYSCLK_GMAC1_RMII_RTX);
+
+	for (i = 0; i < ARRAY_SIZE(starfive_verb); i++) {
+		offset = fdt_path_offset(fdt, starfive_verb[i].path);
+
+		if (starfive_verb[i].value)
+			ret = fdt_setprop_u32(fdt, offset,  starfive_verb[i].name,
+					      dectoul(starfive_verb[i].value, NULL));
+		else
+			ret = fdt_setprop_empty(fdt, offset, starfive_verb[i].name);
+
+		if (ret) {
+			pr_err("%s set prop %s fail.\n", __func__, starfive_verb[i].name);
+				break;
+		}
+	}
+}
+
+void spl_perform_fixups(struct spl_image_info *spl_image)
+{
+	u8 version;
+
+	version = get_pcb_revision_from_eeprom();
+	switch (version) {
+	case 'a':
+	case 'A':
+		spl_fdt_fixup_version_a(spl_image->fdt_addr);
+		break;
+
+	case 'b':
+	case 'B':
+	default:
+		spl_fdt_fixup_version_b(spl_image->fdt_addr);
+		break;
+	};
+
+	/* Update the memory size which read form eeprom or DT */
+	fdt_fixup_memory(spl_image->fdt_addr, 0x40000000, gd->ram_size);
+}
 int spl_board_init_f(void)
 {
 	int ret;
board/starfive/visionfive2/starfive_visionfive2.c +13 -0
index 613fe793c4..748f40ec8a 100644
@@ -8,6 +8,8 @@
 #include <asm/io.h>
 #include <cpu_func.h>
 #include <linux/bitops.h>
+#include <asm/sections.h>
+#include <dm.h>
 
 #define JH7110_L2_PREFETCHER_BASE_ADDR		0x2030000
 #define JH7110_L2_PREFETCHER_HART_OFFSET	0x2000
@@ -38,3 +40,14 @@ int board_init(void)
 
 	return 0;
 }
+
+void *board_fdt_blob_setup(int *err)
+{
+	*err = 0;
+	if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) {
+		if (gd->arch.firmware_fdt_addr)
+			return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
+	}
+
+	return (ulong *)&_end;
+}
Signature · 1 line
2.17.1
#6 lore raw

PATCH v4 6/11 riscv: dts: jh7110: Add ethernet device tree nodes

In reply to Yanhong Wang

Add ethernet device tree node to support StarFive ethernet driver for the JH7110 RISC-V SoC.

---
 .../dts/jh7110-starfive-visionfive-2.dtsi     | 34 +++++++++
 arch/riscv/dts/jh7110.dtsi                    | 69 +++++++++++++++++++
 2 files changed, 103 insertions(+)
arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi +34 -0
index c6b6dfa940..0272369b24 100644
@@ -17,6 +17,8 @@
 		i2c2 = &i2c2;
 		i2c5 = &i2c5;
 		i2c6 = &i2c6;
+		ethernet0 = &gmac0;
+		ethernet1 = &gmac1;
 	};
 
 	chosen {
@@ -317,3 +319,35 @@
 	assigned-clock-parents = <&osc>;
 	assigned-clock-rates = <0>;
 };
+
+&gmac0 {
+	phy-handle = <&phy0>;
+	phy-mode = "rgmii-id";
+	status = "okay";
+
+	mdio {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "snps,dwmac-mdio";
+
+		phy0: ethernet-phy@0 {
+			reg = <0>;
+		};
+	};
+};
+
+&gmac1 {
+	phy-handle = <&phy1>;
+	phy-mode = "rgmii-id";
+	status = "okay";
+
+	mdio {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "snps,dwmac-mdio";
+
+		phy1: ethernet-phy@1 {
+			reg = <0>;
+		};
+	};
+};
\ No newline at end of file
arch/riscv/dts/jh7110.dtsi +69 -0

81 lines not on this page · raw message

Signature · 1 line
2.17.1
#7 lore raw

PATCH v4 7/11 riscv: dts: jh7110: Combine the board device tree files of 1.2A and 1.3B

In reply to Yanhong Wang

The difference between 1.2A and 1.3B is dynamically configured according to the PCB version, and there is no difference on the board device tree, so the same DT file can be used.

---
 arch/riscv/dts/Makefile                       |  3 +-
 ... jh7110-starfive-visionfive-2-u-boot.dtsi} | 25 ++++++-
 .../jh7110-starfive-visionfive-2-v1.2a.dts    | 12 ----
 ...10-starfive-visionfive-2-v1.3b-u-boot.dtsi | 69 -------------------
 ...b.dts => jh7110-starfive-visionfive-2.dts} |  3 +-
 5 files changed, 26 insertions(+), 86 deletions(-)
 rename arch/riscv/dts/{jh7110-starfive-visionfive-2-v1.2a-u-boot.dtsi => jh7110-starfive-visionfive-2-u-boot.dtsi} (66%)
 delete mode 100644 arch/riscv/dts/jh7110-starfive-visionfive-2-v1.2a.dts
 delete mode 100644 arch/riscv/dts/jh7110-starfive-visionfive-2-v1.3b-u-boot.dtsi
 rename arch/riscv/dts/{jh7110-starfive-visionfive-2-v1.3b.dts => jh7110-starfive-visionfive-2.dts} (65%)
arch/riscv/dts/Makefile +1 -2
index 79a58694f5..7940fe466d 100644
@@ -7,8 +7,7 @@ dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) += openpiton-riscv64.dtb
 dtb-$(CONFIG_TARGET_SIFIVE_UNLEASHED) += hifive-unleashed-a00.dtb
 dtb-$(CONFIG_TARGET_SIFIVE_UNMATCHED) += hifive-unmatched-a00.dtb
 dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb
-dtb-$(CONFIG_TARGET_STARFIVE_VISIONFIVE2) += jh7110-starfive-visionfive-2-v1.3b.dtb
-dtb-$(CONFIG_TARGET_STARFIVE_VISIONFIVE2) += jh7110-starfive-visionfive-2-v1.2a.dtb
+dtb-$(CONFIG_TARGET_STARFIVE_VISIONFIVE2) += jh7110-starfive-visionfive-2.dtb
 include $(srctree)/scripts/Makefile.dts
 
 targets += $(dtb-y)
arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi renamed from arch/riscv/dts/jh7110-starfive-visionfive-2-v1.2a-u-boot.dtsi +24 -1
similarity index 66%
rename from arch/riscv/dts/jh7110-starfive-visionfive-2-v1.2a-u-boot.dtsi
rename to arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
index 3c322c5c97..2afcec30b8 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /*
- * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ * Copyright (C) 2023 StarFive Technology Co., Ltd.
  */
 
 #include "binman.dtsi"
@@ -67,3 +67,26 @@
 	};
 };
 
+&binman {
+	itb {
+		fit {
+			images {
+				fdt-1 {
+					description = "NAME";
+					load = <0x40400000>;
+					compression = "none";
+
+					uboot_fdt_blob: blob-ext {
+						filename = "u-boot.dtb";
+					};
+				};
+			};
+
+			configurations {
+				conf-1 {
+					fdt = "fdt-1";
+				};
+			};
+		};
+	};
+};
arch/riscv/dts/jh7110-starfive-visionfive-2-v1.2a.dts deleted +0 -12
deleted file mode 100644
index b9d26d7af7..0000000000
@@ -1,12 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0 OR MIT
-/*
- * Copyright (C) 2022 StarFive Technology Co., Ltd.
- */
-
-/dts-v1/;
-#include "jh7110-starfive-visionfive-2.dtsi"
-
-/ {
-	model = "StarFive VisionFive 2 v1.2A";
-	compatible = "starfive,visionfive-2-v1.2a", "starfive,jh7110";
-};
arch/riscv/dts/jh7110-starfive-visionfive-2-v1.3b-u-boot.dtsi deleted +0 -69

69 lines not on this page · raw message

arch/riscv/dts/jh7110-starfive-visionfive-2.dts renamed from arch/riscv/dts/jh7110-starfive-visionfive-2-v1.3b.dts +1 -2
similarity index 65%
rename from arch/riscv/dts/jh7110-starfive-visionfive-2-v1.3b.dts
rename to arch/riscv/dts/jh7110-starfive-visionfive-2.dts
index 3b3b3453a1..288ea39493 100644
@@ -1,12 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0 OR MIT
 /*
- * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ * Copyright (C) 2023 StarFive Technology Co., Ltd.
  */
 
 /dts-v1/;
 #include "jh7110-starfive-visionfive-2.dtsi"
 
 / {
-	model = "StarFive VisionFive 2 v1.3B";
 	compatible = "starfive,visionfive-2-v1.3b", "starfive,jh7110";
 };
Signature · 1 line
2.17.1
#8 lore raw

PATCH v4 8/11 riscv: dts: starfive: Add support eeprom device tree node

In reply to Yanhong Wang

Add support "atmel,24c04" eeprom for StarFive VisionFive2 board.

---
 .../dts/jh7110-starfive-visionfive-2-u-boot.dtsi   | 14 ++++++++++++++
 arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi   |  8 +++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi +14 -0
index 2afcec30b8..13f69da31e 100644
@@ -67,6 +67,20 @@
 	};
 };
 
+&i2c5_pins {
+	bootph-pre-ram;
+	i2c-pins {
+		bootph-pre-ram;
+	};
+};
+
+&i2c5 {
+	bootph-pre-ram;
+	eeprom@50 {
+		bootph-pre-ram;
+	};
+};
+
 &binman {
 	itb {
 		fit {
arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi +7 -1
index 0272369b24..710b082766 100644
@@ -120,6 +120,12 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&i2c5_pins>;
 	status = "okay";
+
+	eeprom@50 {
+		compatible = "atmel,24c04";
+		reg = <0x50>;
+		pagesize = <16>;
+	};
 };
 
 &i2c6 {
@@ -350,4 +356,4 @@
 			reg = <0>;
 		};
 	};
-};
\ No newline at end of file
+};
Signature · 1 line
2.17.1
#9 lore raw

PATCH v4 9/11 doc: board: starfive: Reword the make defconfig information

In reply to Yanhong Wang

The defconfig file name for StarFive VisionFive2 has been changed, and the documentation description has also changed.

---
 doc/board/starfive/visionfive2.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
doc/board/starfive/visionfive2.rst +3 -3
index 4d43ac9729..951e0d80fb 100644
@@ -62,7 +62,7 @@ Now build the U-Boot SPL and U-Boot proper
 .. code-block:: console
 
 	cd <U-Boot-dir>
-	make starfive_visionfive2_13b_defconfig
+	make starfive_visionfive2_defconfig
 	make OPENSBI=$(opensbi_dir)/opensbi/build/platform/generic/firmware/fw_dynamic.bin
 
 This will generate spl/u-boot-spl.bin and FIT image (u-boot.itb)
@@ -118,7 +118,7 @@ Program the SD card
 	sudo cp u-boot.itb /mnt/
 	sudo cp Image.gz /mnt/
 	sudo cp initramfs.cpio.gz /mnt/
-	sudo cp jh7110-starfive-visionfive-2-v1.3b.dtb /mnt/
+	sudo cp jh7110-starfive-visionfive-2.dtb /mnt/
 	sudo umount /mnt
 
 Booting
@@ -264,7 +264,7 @@ Sample boot log from StarFive VisionFive2 board
 
 	StarFive #fatload mmc 1:3 ${kernel_addr_r} Image.gz
 	6429424 bytes read in 394 ms (15.6 MiB/s)
-	StarFive #fatload mmc 1:3 ${fdt_addr_r} jh7110-starfive-visionfive-2-v1.3b.dtb
+	StarFive #fatload mmc 1:3 ${fdt_addr_r} jh7110-starfive-visionfive-2.dtb
 	11285 bytes read in 5 ms (2.2 MiB/s)
 	StarFive #fatload mmc 1:3 ${ramdisk_addr_r} initramfs.cpio.gz
 	152848495 bytes read in 9271 ms (15.7 MiB/s)
Signature · 1 line
2.17.1
#10 lore raw

PATCH v4 10/11 configs: starfive: Enable ethernet configuration for StarFive VisionFive2

In reply to Yanhong Wang

Enable DWC_ETH_QOS and PHY_MOTORCOMM configuration to support ethernet function for StarFive VisionFive 2 board,including versions 1.2A and 1.3B.

---
 configs/starfive_visionfive2_defconfig | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
configs/starfive_visionfive2_defconfig +11 -2
index ffbc4b9476..c57708199d 100644
@@ -7,7 +7,7 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80000000
 CONFIG_SF_DEFAULT_SPEED=100000000
 CONFIG_SPL_DM_SPI=y
-CONFIG_DEFAULT_DEVICE_TREE="jh7110-starfive-visionfive-2-v1.3b"
+CONFIG_DEFAULT_DEVICE_TREE="jh7110-starfive-visionfive-2"
 CONFIG_SPL_TEXT_BASE=0x8000000
 CONFIG_SYS_PROMPT="StarFive #"
 CONFIG_OF_LIBFDT_OVERLAY=y
@@ -31,7 +31,7 @@ CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 debug rootwait earlycon=sbi"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="setenv fdt_addr ${fdtcontroladdr};fdt addr ${fdtcontroladdr};"
-CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2-v1.3b.dtb"
+CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2.dtb"
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
 CONFIG_SPL_MAX_SIZE=0x40000
@@ -54,6 +54,8 @@ CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
 CONFIG_SPL_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SPL_CLK_JH7110=y
@@ -66,6 +68,13 @@ CONFIG_SPI_FLASH_EON=y
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_ISSI=y
 CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_PHY_MOTORCOMM=y
+CONFIG_DM_MDIO=y
+CONFIG_DM_ETH_PHY=y
+CONFIG_DWC_ETH_QOS=y
+CONFIG_DWC_ETH_QOS_STARFIVE=y
+CONFIG_RGMII=y
+CONFIG_RMII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
 CONFIG_SPL_PINCTRL=y
Signature · 1 line
2.17.1
#11 lore raw

Re: [PATCH v4 10/11] configs: starfive: Enable ethernet configuration for StarFive VisionFive2

Quoted 23 lines · Yanhong Wang

Enable DWC_ETH_QOS and PHY_MOTORCOMM configuration to support ethernet function for StarFive VisionFive 2 board,including versions 1.2A and 1.3B.

---
 configs/starfive_visionfive2_defconfig | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
configs/starfive_visionfive2_defconfig +1 -1
index ffbc4b9476..c57708199d 100644
@@ -7,7 +7,7 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80000000
 CONFIG_SF_DEFAULT_SPEED=100000000
 CONFIG_SPL_DM_SPI=y
-CONFIG_DEFAULT_DEVICE_TREE="jh7110-starfive-visionfive-2-v1.3b"
+CONFIG_DEFAULT_DEVICE_TREE="jh7110-starfive-visionfive-2"
 CONFIG_SPL_TEXT_BASE=0x8000000
 CONFIG_SYS_PROMPT="StarFive #"
 CONFIG_OF_LIBFDT_OVERLAY=y

configs/starfive_visionfive2_defconfig CONFIG_USE_BOOTARGS=y · line 34

Quoted 5 lines
configs/starfive_visionfive2_defconfig +1 -1
@@ -31,7 +31,7 @@ CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 debug rootwait earlycon=sbi"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="setenv fdt_addr ${fdtcontroladdr};fdt addr ${fdtcontroladdr};"
-CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2-v1.3b.dtb"
+CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2.dtb"

These two hunks belong into patch 7.

Jan

Quoted 26 lines
configs/starfive_visionfive2_defconfig +9 -0
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
 CONFIG_SPL_MAX_SIZE=0x40000
@@ -54,6 +54,8 @@ CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
 CONFIG_SPL_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SPL_CLK_JH7110=y
@@ -66,6 +68,13 @@ CONFIG_SPI_FLASH_EON=y
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_ISSI=y
 CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_PHY_MOTORCOMM=y
+CONFIG_DM_MDIO=y
+CONFIG_DM_ETH_PHY=y
+CONFIG_DWC_ETH_QOS=y
+CONFIG_DWC_ETH_QOS_STARFIVE=y
+CONFIG_RGMII=y
+CONFIG_RMII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
 CONFIG_SPL_PINCTRL=y
Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#12 lore raw

Re: [PATCH v4 10/11] configs: starfive: Enable ethernet configuration for StarFive VisionFive2

Quoted 23 lines · Jan Kiszka
Quoted 22 lines · Yanhong Wang

Enable DWC_ETH_QOS and PHY_MOTORCOMM configuration to support ethernet function for StarFive VisionFive 2 board,including versions 1.2A and 1.3B.

---
 configs/starfive_visionfive2_defconfig | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
configs/starfive_visionfive2_defconfig +1 -1
index ffbc4b9476..c57708199d 100644
@@ -7,7 +7,7 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80000000
 CONFIG_SF_DEFAULT_SPEED=100000000
 CONFIG_SPL_DM_SPI=y
-CONFIG_DEFAULT_DEVICE_TREE="jh7110-starfive-visionfive-2-v1.3b"
+CONFIG_DEFAULT_DEVICE_TREE="jh7110-starfive-visionfive-2"
 CONFIG_SPL_TEXT_BASE=0x8000000
 CONFIG_SYS_PROMPT="StarFive #"
 CONFIG_OF_LIBFDT_OVERLAY=y
Quoted 9 lines

configs/starfive_visionfive2_defconfig CONFIG_USE_BOOTARGS=y · line 34

Quoted 6 lines
configs/starfive_visionfive2_defconfig +1 -1
@@ -31,7 +31,7 @@ CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 debug rootwait earlycon=sbi"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="setenv fdt_addr ${fdtcontroladdr};fdt addr ${fdtcontroladdr};"
-CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2-v1.3b.dtb"
+CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2.dtb"

These two hunks belong into patch 7.

Ok, I'll move the two chunks to patch 7.

Quoted 29 lines

Jan

Quoted 26 lines
configs/starfive_visionfive2_defconfig +9 -0
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
 CONFIG_SPL_MAX_SIZE=0x40000
@@ -54,6 +54,8 @@ CONFIG_SYS_BOOTM_LEN=0x4000000
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_TFTPPUT=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_REGMAP=y
+CONFIG_SYSCON=y
 CONFIG_SPL_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SPL_CLK_JH7110=y
@@ -66,6 +68,13 @@ CONFIG_SPI_FLASH_EON=y
 CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_ISSI=y
 CONFIG_SPI_FLASH_MACRONIX=y
+CONFIG_PHY_MOTORCOMM=y
+CONFIG_DM_MDIO=y
+CONFIG_DM_ETH_PHY=y
+CONFIG_DWC_ETH_QOS=y
+CONFIG_DWC_ETH_QOS_STARFIVE=y
+CONFIG_RGMII=y
+CONFIG_RMII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCONF=y
 CONFIG_SPL_PINCTRL=y
#13 lore raw

PATCH v4 11/11 configs: starfive: Enable ID EEPROM configuration

In reply to Yanhong Wang

Enabled ID_EEPROM and I2C configuration for StarFive VisionFive2 board.

---
 configs/starfive_visionfive2_defconfig | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
configs/starfive_visionfive2_defconfig +18 -1
index c57708199d..570a1f53a1 100644
@@ -13,6 +13,7 @@ CONFIG_SYS_PROMPT="StarFive #"
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_STACK=0x8180000
 CONFIG_SPL=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
@@ -23,6 +24,7 @@ CONFIG_SPL_OPENSBI_LOAD_ADDR=0x40000000
 CONFIG_ARCH_RV64I=y
 CONFIG_CMODEL_MEDANY=y
 CONFIG_RISCV_SMODE=y
+# CONFIG_OF_BOARD_FIXUP is not set
 CONFIG_FIT=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_QSPI_BOOT=y
@@ -34,6 +36,8 @@ CONFIG_PREBOOT="setenv fdt_addr ${fdtcontroladdr};fdt addr ${fdtcontroladdr};"
 CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2.dtb"
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_ID_EEPROM=y
+CONFIG_SYS_EEPROM_BUS_NUM=5
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x0
 CONFIG_SPL_BSS_START_ADDR=0x8040000
@@ -45,21 +49,34 @@ CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x80000000
 CONFIG_SYS_SPL_MALLOC_SIZE=0x400000
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x2
+CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_CBSIZE=256
 CONFIG_SYS_PBSIZE=276
 CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_CMD_EEPROM=y
+CONFIG_SYS_EEPROM_SIZE=512
+CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=4
+CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=5
 CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_TFTPPUT=y
+CONFIG_OF_BOARD=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_SPL_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SPL_CLK_JH7110=y
-# CONFIG_I2C is not set
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_DW=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
+CONFIG_SPL_I2C_EEPROM=y
+CONFIG_SYS_I2C_EEPROM_ADDR=0X50
 CONFIG_MMC_HS400_SUPPORT=y
 CONFIG_SPL_MMC_HS400_SUPPORT=y
 CONFIG_MMC_DW=y
Signature · 1 line
2.17.1
#14 lore raw

Re: [PATCH v4 11/11] configs: starfive: Enable ID EEPROM configuration

Quoted 62 lines · Yanhong Wang

Enabled ID_EEPROM and I2C configuration for StarFive VisionFive2 board.

---
 configs/starfive_visionfive2_defconfig | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
configs/starfive_visionfive2_defconfig +12 -0
index c57708199d..570a1f53a1 100644
@@ -13,6 +13,7 @@ CONFIG_SYS_PROMPT="StarFive #"
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_STACK=0x8180000
 CONFIG_SPL=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
@@ -23,6 +24,7 @@ CONFIG_SPL_OPENSBI_LOAD_ADDR=0x40000000
 CONFIG_ARCH_RV64I=y
 CONFIG_CMODEL_MEDANY=y
 CONFIG_RISCV_SMODE=y
+# CONFIG_OF_BOARD_FIXUP is not set
 CONFIG_FIT=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_QSPI_BOOT=y
@@ -34,6 +36,8 @@ CONFIG_PREBOOT="setenv fdt_addr ${fdtcontroladdr};fdt addr ${fdtcontroladdr};"
 CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2.dtb"
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_ID_EEPROM=y
+CONFIG_SYS_EEPROM_BUS_NUM=5
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x0
 CONFIG_SPL_BSS_START_ADDR=0x8040000
@@ -45,21 +49,34 @@ CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x80000000
 CONFIG_SYS_SPL_MALLOC_SIZE=0x400000
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x2
+CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_CBSIZE=256
 CONFIG_SYS_PBSIZE=276
 CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_CMD_EEPROM=y
+CONFIG_SYS_EEPROM_SIZE=512
+CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=4
+CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=5
 CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_TFTPPUT=y
+CONFIG_OF_BOARD=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_SPL_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SPL_CLK_JH7110=y

configs/starfive_visionfive2_defconfig CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x80000000 · line 82

Quoted 10 lines
configs/starfive_visionfive2_defconfig +6 -1
-# CONFIG_I2C is not set
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_DW=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
+CONFIG_SPL_I2C_EEPROM=y
+CONFIG_SYS_I2C_EEPROM_ADDR=0X50
 CONFIG_MMC_HS400_SUPPORT=y
 CONFIG_SPL_MMC_HS400_SUPPORT=y
 CONFIG_MMC_DW=y

This comes too late: Already patch 4 needs at least CONFIG_ID_EEPROM=y, if not more.

Make sure you don't leave non-bisectable commit series behind. Whenever something breaks (like 55171aedda88), people will use bisection to find the causing commit, and then they will appreciate not having to deal with such hick-ups.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#15 lore raw

Re: [PATCH v4 11/11] configs: starfive: Enable ID EEPROM configuration

Quoted 68 lines · Jan Kiszka
Quoted 67 lines · Yanhong Wang

Enabled ID_EEPROM and I2C configuration for StarFive VisionFive2 board.

---
 configs/starfive_visionfive2_defconfig | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
configs/starfive_visionfive2_defconfig +16 -1
index c57708199d..570a1f53a1 100644
@@ -13,6 +13,7 @@ CONFIG_SYS_PROMPT="StarFive #"
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_STACK=0x8180000
 CONFIG_SPL=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
@@ -23,6 +24,7 @@ CONFIG_SPL_OPENSBI_LOAD_ADDR=0x40000000
 CONFIG_ARCH_RV64I=y
 CONFIG_CMODEL_MEDANY=y
 CONFIG_RISCV_SMODE=y
+# CONFIG_OF_BOARD_FIXUP is not set
 CONFIG_FIT=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_QSPI_BOOT=y
@@ -34,6 +36,8 @@ CONFIG_PREBOOT="setenv fdt_addr ${fdtcontroladdr};fdt addr ${fdtcontroladdr};"
 CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2.dtb"
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_ID_EEPROM=y
+CONFIG_SYS_EEPROM_BUS_NUM=5
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x0
 CONFIG_SPL_BSS_START_ADDR=0x8040000
@@ -45,21 +49,34 @@ CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x80000000
 CONFIG_SYS_SPL_MALLOC_SIZE=0x400000
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x2
+CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_CBSIZE=256
 CONFIG_SYS_PBSIZE=276
 CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_CMD_EEPROM=y
+CONFIG_SYS_EEPROM_SIZE=512
+CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=4
+CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=5
 CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_TFTPPUT=y
+CONFIG_OF_BOARD=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_SPL_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SPL_CLK_JH7110=y
-# CONFIG_I2C is not set
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_DW=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
Quoted 9 lines

configs/starfive_visionfive2_defconfig CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x80000000 · line 82

Quoted 5 lines
configs/starfive_visionfive2_defconfig +2 -0
+CONFIG_SPL_I2C_EEPROM=y
+CONFIG_SYS_I2C_EEPROM_ADDR=0X50
 CONFIG_MMC_HS400_SUPPORT=y
 CONFIG_SPL_MMC_HS400_SUPPORT=y
 CONFIG_MMC_DW=y

This comes too late: Already patch 4 needs at least CONFIG_ID_EEPROM=y, if not more.

Moving patch 4 to the series end, is that okay?

Quoted 7 lines

Make sure you don't leave non-bisectable commit series behind. Whenever something breaks (like 55171aedda88), people will use bisection to find the causing commit, and then they will appreciate not having to deal with such hick-ups.

Jan

#16 lore raw

Re: [PATCH v4 11/11] configs: starfive: Enable ID EEPROM configuration

Quoted 81 lines · yanhong wang
Quoted 68 lines · Jan Kiszka
Quoted 67 lines · Yanhong Wang

Enabled ID_EEPROM and I2C configuration for StarFive VisionFive2 board.

---
 configs/starfive_visionfive2_defconfig | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
configs/starfive_visionfive2_defconfig +16 -1
index c57708199d..570a1f53a1 100644
@@ -13,6 +13,7 @@ CONFIG_SYS_PROMPT="StarFive #"
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DRIVERS_MISC=y
 CONFIG_SPL_STACK=0x8180000
 CONFIG_SPL=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
@@ -23,6 +24,7 @@ CONFIG_SPL_OPENSBI_LOAD_ADDR=0x40000000
 CONFIG_ARCH_RV64I=y
 CONFIG_CMODEL_MEDANY=y
 CONFIG_RISCV_SMODE=y
+# CONFIG_OF_BOARD_FIXUP is not set
 CONFIG_FIT=y
 CONFIG_DISTRO_DEFAULTS=y
 CONFIG_QSPI_BOOT=y
@@ -34,6 +36,8 @@ CONFIG_PREBOOT="setenv fdt_addr ${fdtcontroladdr};fdt addr ${fdtcontroladdr};"
 CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2.dtb"
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_ID_EEPROM=y
+CONFIG_SYS_EEPROM_BUS_NUM=5
 CONFIG_SPL_MAX_SIZE=0x40000
 CONFIG_SPL_PAD_TO=0x0
 CONFIG_SPL_BSS_START_ADDR=0x8040000
@@ -45,21 +49,34 @@ CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x80000000
 CONFIG_SYS_SPL_MALLOC_SIZE=0x400000
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x2
+CONFIG_SPL_I2C=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_DM_RESET=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SYS_CBSIZE=256
 CONFIG_SYS_PBSIZE=276
 CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_CMD_EEPROM=y
+CONFIG_SYS_EEPROM_SIZE=512
+CONFIG_SYS_EEPROM_PAGE_WRITE_BITS=4
+CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS=5
 CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_TFTPPUT=y
+CONFIG_OF_BOARD=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_SPL_CLK_COMPOSITE_CCF=y
 CONFIG_CLK_COMPOSITE_CCF=y
 CONFIG_SPL_CLK_JH7110=y
-# CONFIG_I2C is not set
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_DW=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
Quoted 9 lines

configs/starfive_visionfive2_defconfig CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x80000000 · line 82

Quoted 5 lines
configs/starfive_visionfive2_defconfig +2 -0
+CONFIG_SPL_I2C_EEPROM=y
+CONFIG_SYS_I2C_EEPROM_ADDR=0X50
 CONFIG_MMC_HS400_SUPPORT=y
 CONFIG_SPL_MMC_HS400_SUPPORT=y
 CONFIG_MMC_DW=y

This comes too late: Already patch 4 needs at least CONFIG_ID_EEPROM=y, if not more.

Quoted 2 lines

Moving patch 4 to the series end, is that okay?

I didn't try. I would recommend that you to run a quick build check after each patch being applied for the affected defconfig(s). Can be automated (git rebase --exec ...).

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#17 lore raw
In reply to Yanhong Wang

On Thu, 25 May 2023 17:36:26 +0800
Yanhong Wang <[email protected]> wrote:
[...]

Quoted 5 lines

The main difference between StarFive VisionFive 2 1.2A and 1.3B is gmac, but the difference in gmac is not defined in DT, but reads the PCB version from EEPROM, and then dynamically configures the difference of gmac according to different PCB versions, which is compatible with 1.2A and 1.3B versions, which is more user-friendly.

Big ACK from me so far, it is overdue to clean the duplication mess that is currently in master.

Quoted 2 lines

The PHY and MAC driver has been tested on the StarFive VisionFive 2 1.2A and 1.3B boards and works normally.

But for a complete test I'd like to see the respectively correct DTB passed to the OS, and that requires the other issue (base / clock support and single DT) to be resolved first.

Thanks!

Torsten

#18 lore raw
In reply to Yanhong Wang

On Thu, 25 May 2023 17:36:26 +0800
Yanhong Wang <[email protected]> wrote:
[...]

Quoted 2 lines

base-commit: 62df7a39442902a71259568c13a4d496d5a514f4

Have you tested this?

I get

| U-Boot SPL 2023.07-rc2-00170-g62df7a3944 (Jun 01 2023 - 18:58:50 +0200)
| DDR version: dc2e84f0.
| Trying to boot from MMC2
| 
| 
| U-Boot 2023.07-rc2-00170-g62df7a3944 (Jun 01 2023 - 18:58:50 +0200)
| 
| CPU:   rv64imafdc_zba_zbb
| Model: StarFive VisionFive 2 v1.3B
| DRAM:  8 GiB
| initcall sequence 00000000fffe0260 failed at call 00000000402160ec (err=-19)
| ### ERROR ### Please RESET the board ###

on that base rev already!
My compiler is gcc (SUSE Linux) 13.0.1 20230421 (prerelease) [revision f980561c60b0446cc427595198d7f3f4f90e0924], FWIW. OpenSBI is 1.2

A simple switch back to an older branch (based on 6a11fdf0536e02ac) produces a working U-Boot again.

Am I missing something?

Torsten

#19 lore raw
Quoted 8 lines · Torsten Duwe

On Thu, 25 May 2023 17:36:26 +0800
Yanhong Wang <[email protected]> wrote:
[...]

Quoted 2 lines

base-commit: 62df7a39442902a71259568c13a4d496d5a514f4

Have you tested this?

I also got the following error, which was caused by the recent
submission [commit ID: 55171aedda88d12666e2a1bbc661dea1bec65337].
The modifications in this submission '! (gd->flags & GD_FLG_RELOC)' [in drivers/core/root.c] causes this issue, I have emailed the author of this submission for more information. I commented this modification when I was testing.

The patch link:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Quoted 26 lines

I get

| U-Boot SPL 2023.07-rc2-00170-g62df7a3944 (Jun 01 2023 - 18:58:50 +0200)
| DDR version: dc2e84f0.
| Trying to boot from MMC2
| 
| 
| U-Boot 2023.07-rc2-00170-g62df7a3944 (Jun 01 2023 - 18:58:50 +0200)
| 
| CPU:   rv64imafdc_zba_zbb
| Model: StarFive VisionFive 2 v1.3B
| DRAM:  8 GiB
| initcall sequence 00000000fffe0260 failed at call 00000000402160ec (err=-19)
| ### ERROR ### Please RESET the board ###

on that base rev already!
My compiler is gcc (SUSE Linux) 13.0.1 20230421 (prerelease) [revision f980561c60b0446cc427595198d7f3f4f90e0924], FWIW. OpenSBI is 1.2

A simple switch back to an older branch (based on 6a11fdf0536e02ac) produces a working U-Boot again.

Am I missing something?

Torsten