All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] riscv: add support for Milk-V Mars board
@ 2024-03-21 18:11 Heinrich Schuchardt
  2024-03-21 18:11 ` [PATCH v2 1/6] riscv: do not set default fdt for VisionFive 2 Heinrich Schuchardt
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-03-21 18:11 UTC (permalink / raw)
  To: Minda Chen, Rick Chen, Leo
  Cc: Lukasz Tekieli, Aurelien Jarno, Chanho Park, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot,
	Heinrich Schuchardt

The Milk-V Mars board is technically very close to the StarFive
VisionFive 2 board.

With this patch series the VisionFive 2 U-Boot SPL will detect that it
is running on a Milk-V board and patch the device-tree accordingly.
This is the same approach that has been taken to handle the differences
between the Visionfive 2 1.2B and 1.3A revisions.

v2:
	do not set default fdt for VisionFive 2
	do not overwrite /soc/i2c@12050000/eeprom@50/compatible

*** BLURB HERE ***

Heinrich Schuchardt (6):
  riscv: do not set default fdt for VisionFive 2
  eeprom: starfive: function get_product_id_from_eeprom()
  riscv: set fdtfile on Milk-V Mars
  board: starfive: support Milk-V Mars board
  riscv: starfive: avoid including common.h
  doc: describe Milk-V Mars board

 arch/riscv/include/asm/arch-jh7110/eeprom.h   |   9 ++
 board/starfive/visionfive2/spl.c              | 100 ++++++++++++++--
 .../visionfive2/starfive_visionfive2.c        |  48 +++++---
 .../visionfive2/visionfive2-i2c-eeprom.c      |   9 +-
 configs/starfive_visionfive2_defconfig        |   1 -
 doc/board/starfive/index.rst                  |   1 +
 doc/board/starfive/milk-v_mars.rst            | 111 ++++++++++++++++++
 doc/board/starfive/visionfive2.rst            |  18 +++
 8 files changed, 268 insertions(+), 29 deletions(-)
 create mode 100644 doc/board/starfive/milk-v_mars.rst

-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 1/6] riscv: do not set default fdt for VisionFive 2
  2024-03-21 18:11 [PATCH v2 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
@ 2024-03-21 18:11 ` Heinrich Schuchardt
  2024-03-27  9:01   ` Leo Liang
  2024-03-21 18:11 ` [PATCH v2 2/6] eeprom: starfive: function get_product_id_from_eeprom() Heinrich Schuchardt
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-03-21 18:11 UTC (permalink / raw)
  To: Minda Chen, Rick Chen, Leo
  Cc: Lukasz Tekieli, Aurelien Jarno, Chanho Park, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot,
	Heinrich Schuchardt

Currently in set_fdtfile() we set the value of environment variable fdtfile
unconditionally. The implies that a value in the environment will be
ignored.

With the patch environment variable fdtfile will only be set if it does not
yet exist. This requires that CONFIG_DEFAULT_FDT_FILE is not set.

Now the user can either set and save fdtfile interactively or in the U-Boot
configuration to overrule the device-tree name chosen based on the
hardware in set_fdtfile().

Reported-by: E Shattow <lucent@gmail.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	new patch
---
 .../visionfive2/starfive_visionfive2.c         |  4 ++++
 configs/starfive_visionfive2_defconfig         |  1 -
 doc/board/starfive/visionfive2.rst             | 18 ++++++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c
index 78e118d5a05..76439179fa7 100644
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -49,6 +49,10 @@ static void set_fdtfile(void)
 	u8 version;
 	const char *fdtfile;
 
+	fdtfile = env_get("fdtfile");
+	if (fdtfile)
+		return;
+
 	version = get_pcb_revision_from_eeprom();
 	switch (version) {
 	case 'a':
diff --git a/configs/starfive_visionfive2_defconfig b/configs/starfive_visionfive2_defconfig
index 7a3f1d4dbdf..fa80d489f5e 100644
--- a/configs/starfive_visionfive2_defconfig
+++ b/configs/starfive_visionfive2_defconfig
@@ -40,7 +40,6 @@ CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 debug rootwait earlycon=sbi"
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="nvme scan; usb start; setenv fdt_addr ${fdtcontroladdr}; fdt addr ${fdtcontroladdr};"
-CONFIG_DEFAULT_FDT_FILE="starfive/jh7110-starfive-visionfive-2.dtb"
 CONFIG_SYS_CBSIZE=256
 CONFIG_SYS_PBSIZE=276
 CONFIG_DISPLAY_CPUINFO=y
diff --git a/doc/board/starfive/visionfive2.rst b/doc/board/starfive/visionfive2.rst
index abda8ac21bc..2e04c02dca5 100644
--- a/doc/board/starfive/visionfive2.rst
+++ b/doc/board/starfive/visionfive2.rst
@@ -71,6 +71,24 @@ Program the SD card
 This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as well
 as the FIT image (u-boot.itb) with OpenSBI and U-Boot.
 
+Device-tree selection
+~~~~~~~~~~~~~~~~~~~~~
+
+Depending on the board version U-Boot set variable $fdtfile to either
+starfive/jh7110-starfive-visionfive-2-v1.2a.dtb or
+starfive/jh7110-starfive-visionfive-2-v1.3b.dtb.
+
+To overrule this selection the variable can be set manually and saved in the
+environment
+
+::
+
+    setenv fdtfile my_device-tree.dtb
+    env save
+
+or the configuration variable CONFIG_DEFAULT_FDT_FILE can be used to set to
+provide a default value.
+
 Flashing
 ~~~~~~~~
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 2/6] eeprom: starfive: function get_product_id_from_eeprom()
  2024-03-21 18:11 [PATCH v2 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
  2024-03-21 18:11 ` [PATCH v2 1/6] riscv: do not set default fdt for VisionFive 2 Heinrich Schuchardt
@ 2024-03-21 18:11 ` Heinrich Schuchardt
  2024-03-27  9:13   ` Leo Liang
  2024-03-21 18:11 ` [PATCH v2 3/6] riscv: set fdtfile on Milk-V Mars Heinrich Schuchardt
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-03-21 18:11 UTC (permalink / raw)
  To: Minda Chen, Rick Chen, Leo
  Cc: Lukasz Tekieli, Aurelien Jarno, Chanho Park, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot,
	Heinrich Schuchardt

Export a function get_product_id_from_eeprom() to read the product ID.
This value can be used for fixing up the device-tree on JH7110 based
products.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	no change
---
 arch/riscv/include/asm/arch-jh7110/eeprom.h         | 9 +++++++++
 board/starfive/visionfive2/visionfive2-i2c-eeprom.c | 8 ++++++++
 2 files changed, 17 insertions(+)

diff --git a/arch/riscv/include/asm/arch-jh7110/eeprom.h b/arch/riscv/include/asm/arch-jh7110/eeprom.h
index d2776d5b6cb..62d184aeb57 100644
--- a/arch/riscv/include/asm/arch-jh7110/eeprom.h
+++ b/arch/riscv/include/asm/arch-jh7110/eeprom.h
@@ -12,4 +12,13 @@
 u8 get_pcb_revision_from_eeprom(void);
 u32 get_ddr_size_from_eeprom(void);
 
+/**
+ * get_product_id_from_eeprom - get product ID string
+ *
+ * A string like "VF7110A1-2228-D008E000-00000001" is returned.
+ *
+ * Return:	product ID string
+ */
+const char *get_product_id_from_eeprom(void);
+
 #endif /* _ASM_RISCV_EEPROM_H */
diff --git a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
index c36de1a5125..a9f4376c8e1 100644
--- a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
+++ b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
@@ -405,6 +405,14 @@ static void set_product_id(char *string)
 	update_crc();
 }
 
+const char *get_product_id_from_eeprom(void)
+{
+	if (read_eeprom())
+		return NULL;
+
+	return pbuf.eeprom.atom1.data.pstr;
+}
+
 int do_mac(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
 	char *cmd;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 3/6] riscv: set fdtfile on Milk-V Mars
  2024-03-21 18:11 [PATCH v2 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
  2024-03-21 18:11 ` [PATCH v2 1/6] riscv: do not set default fdt for VisionFive 2 Heinrich Schuchardt
  2024-03-21 18:11 ` [PATCH v2 2/6] eeprom: starfive: function get_product_id_from_eeprom() Heinrich Schuchardt
@ 2024-03-21 18:11 ` Heinrich Schuchardt
  2024-03-28  3:35   ` Leo Liang
  2024-03-21 18:11 ` [PATCH v2 4/6] board: starfive: support Milk-V Mars board Heinrich Schuchardt
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-03-21 18:11 UTC (permalink / raw)
  To: Minda Chen, Rick Chen, Leo
  Cc: Lukasz Tekieli, Aurelien Jarno, Chanho Park, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot,
	Heinrich Schuchardt

Set environment variable fdtfile to the correct value for the Milk-V Mars
board.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	rebase patch
---
 .../visionfive2/starfive_visionfive2.c        | 43 +++++++++++++------
 1 file changed, 30 insertions(+), 13 deletions(-)

diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c
index 76439179fa7..5ae8b850280 100644
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -9,6 +9,7 @@
 #include <dm.h>
 #include <fdt_support.h>
 #include <env.h>
+#include <log.h>
 #include <asm/arch/eeprom.h>
 #include <asm/io.h>
 #include <asm/sections.h>
@@ -17,6 +18,8 @@
 DECLARE_GLOBAL_DATA_PTR;
 #define JH7110_L2_PREFETCHER_BASE_ADDR		0x2030000
 #define JH7110_L2_PREFETCHER_HART_OFFSET	0x2000
+#define FDTFILE_MILK_V_MARS \
+	"starfive/jh7110-milkv-mars.dtb"
 #define FDTFILE_VISIONFIVE2_1_2A \
 	"starfive/jh7110-starfive-visionfive-2-v1.2a.dtb"
 #define FDTFILE_VISIONFIVE2_1_3B \
@@ -48,24 +51,38 @@ static void set_fdtfile(void)
 {
 	u8 version;
 	const char *fdtfile;
+	const char *product_id;
 
 	fdtfile = env_get("fdtfile");
 	if (fdtfile)
 		return;
 
-	version = get_pcb_revision_from_eeprom();
-	switch (version) {
-	case 'a':
-	case 'A':
-		fdtfile = FDTFILE_VISIONFIVE2_1_2A;
-	        break;
-
-	case 'b':
-	case 'B':
-	default:
-		fdtfile = FDTFILE_VISIONFIVE2_1_3B;
-	        break;
-	};
+	product_id = get_product_id_from_eeprom();
+	if (!product_id) {
+		log_err("Can't read EEPROM\n");
+		return;
+	}
+	if (!strncmp(product_id, "MARS", 4)) {
+		fdtfile = FDTFILE_MILK_V_MARS;
+	} else if (!strncmp(product_id, "VF7110", 6)) {
+		version = get_pcb_revision_from_eeprom();
+
+		switch (version) {
+		case 'a':
+		case 'A':
+			fdtfile = FDTFILE_VISIONFIVE2_1_2A;
+			break;
+
+		case 'b':
+		case 'B':
+		default:
+			fdtfile = FDTFILE_VISIONFIVE2_1_3B;
+			break;
+		}
+	} else {
+		log_err("Unknown product\n");
+		return;
+	}
 
 	env_set("fdtfile", fdtfile);
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 4/6] board: starfive: support Milk-V Mars board
  2024-03-21 18:11 [PATCH v2 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
                   ` (2 preceding siblings ...)
  2024-03-21 18:11 ` [PATCH v2 3/6] riscv: set fdtfile on Milk-V Mars Heinrich Schuchardt
@ 2024-03-21 18:11 ` Heinrich Schuchardt
  2024-03-24 15:00   ` Aurelien Jarno
  2024-03-28  5:24   ` Leo Liang
  2024-03-21 18:11 ` [PATCH v2 5/6] riscv: starfive: avoid including common.h Heinrich Schuchardt
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-03-21 18:11 UTC (permalink / raw)
  To: Minda Chen, Rick Chen, Leo
  Cc: Lukasz Tekieli, Aurelien Jarno, Chanho Park, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot,
	Heinrich Schuchardt

The differences between the Milk-V Mars board and the VisionFive 2 board
are small enough that we can support both using the same U-Boot build.

* The model and compatible property are taken from proposed Linux patches.
* The EEPROM is atmel,24c02 according to the vendor U-Boot.
* The second Ethernet port is not available.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	do not overwrite /soc/i2c@12050000/eeprom@50/compatible
	
---
 board/starfive/visionfive2/spl.c | 99 ++++++++++++++++++++++++++++----
 1 file changed, 87 insertions(+), 12 deletions(-)

diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
index 1b49945d11b..e0e33cb37ba 100644
--- a/board/starfive/visionfive2/spl.c
+++ b/board/starfive/visionfive2/spl.c
@@ -27,6 +27,26 @@ struct starfive_vf2_pro {
 	const char *value;
 };
 
+static const struct starfive_vf2_pro milk_v_mars[] = {
+	{"/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",
+		"motorcomm,rx-clk-drv-microamp", "3970"},
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0",
+		"motorcomm,rx-data-drv-microamp", "2910"},
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0",
+		"rx-internal-delay-ps", "1900"},
+	{"/soc/ethernet@16030000/mdio/ethernet-phy@0",
+		"tx-internal-delay-ps", "1500"},
+};
+
 static const struct starfive_vf2_pro starfive_vera[] = {
 	{"/soc/ethernet@16030000/mdio/ethernet-phy@0", "rx-internal-delay-ps",
 		"1900"},
@@ -67,6 +87,49 @@ static const struct starfive_vf2_pro starfive_verb[] = {
 		"tx-internal-delay-ps", "0"},
 };
 
+void spl_fdt_fixup_mars(void *fdt)
+{
+	static const char compat[] = "milkv,mars\0starfive,jh7110";
+	u32 phandle;
+	u8 i;
+	int offset;
+	int ret;
+
+	fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
+	fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
+			   "Milk-V Mars");
+
+	/* 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 */
+	fdt_setprop_string(fdt, fdt_path_offset(fdt, "/soc/ethernet@16040000"),
+			   "status", "disabled");
+
+	for (i = 0; i < ARRAY_SIZE(milk_v_mars); i++) {
+		offset = fdt_path_offset(fdt, milk_v_mars[i].path);
+
+		if (starfive_verb[i].value)
+			ret = fdt_setprop_u32(fdt, offset, milk_v_mars[i].name,
+					      dectoul(milk_v_mars[i].value, NULL));
+		else
+			ret = fdt_setprop_empty(fdt, offset, milk_v_mars[i].name);
+
+		if (ret) {
+			pr_err("%s set prop %s fail.\n", __func__, milk_v_mars[i].name);
+				break;
+		}
+	}
+}
+
 void spl_fdt_fixup_version_a(void *fdt)
 {
 	static const char compat[] = "starfive,visionfive-2-v1.2a\0starfive,jh7110";
@@ -167,22 +230,34 @@ void spl_fdt_fixup_version_b(void *fdt)
 void spl_perform_fixups(struct spl_image_info *spl_image)
 {
 	u8 version;
+	const char *product_id;
 
-	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);
+	product_id = get_product_id_from_eeprom();
+	if (!product_id) {
+		pr_err("Can't read EEPROM\n");
+		return;
+	}
+	if (!strncmp(product_id, "MARS", 4)) {
+		spl_fdt_fixup_mars(spl_image->fdt_addr);
+	} else if (!strncmp(product_id, "VF7110", 6)) {
+		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;
+		};
+	} else {
+		pr_err("Unknown product %s\n", product_id);
 	};
 
-	/* Update the memory size which read form eeprom or DT */
+	/* Update the memory size which read from eeprom or DT */
 	fdt_fixup_memory(spl_image->fdt_addr, 0x40000000, gd->ram_size);
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 5/6] riscv: starfive: avoid including common.h
  2024-03-21 18:11 [PATCH v2 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
                   ` (3 preceding siblings ...)
  2024-03-21 18:11 ` [PATCH v2 4/6] board: starfive: support Milk-V Mars board Heinrich Schuchardt
@ 2024-03-21 18:11 ` Heinrich Schuchardt
  2024-03-28  3:09   ` Leo Liang
  2024-03-21 18:11 ` [PATCH v2 6/6] doc: describe Milk-V Mars board Heinrich Schuchardt
  2024-03-25  3:10 ` 回复: [PATCH v2 0/6] riscv: add support for " Minda Chen
  6 siblings, 1 reply; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-03-21 18:11 UTC (permalink / raw)
  To: Minda Chen, Rick Chen, Leo
  Cc: Lukasz Tekieli, Aurelien Jarno, Chanho Park, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot,
	Heinrich Schuchardt

The usage of common.h is deprecated. Remove it from board files.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	no change
---
 board/starfive/visionfive2/spl.c                    | 1 -
 board/starfive/visionfive2/starfive_visionfive2.c   | 1 -
 board/starfive/visionfive2/visionfive2-i2c-eeprom.c | 1 -
 3 files changed, 3 deletions(-)

diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
index e0e33cb37ba..1683bb99a51 100644
--- a/board/starfive/visionfive2/spl.c
+++ b/board/starfive/visionfive2/spl.c
@@ -4,7 +4,6 @@
  * Author: Yanhong Wang<yanhong.wang@starfivetech.com>
  */
 
-#include <common.h>
 #include <asm/arch/eeprom.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/regs.h>
diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c
index 5ae8b850280..a86bca533b2 100644
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -4,7 +4,6 @@
  * Author: Yanhong Wang<yanhong.wang@starfivetech.com>
  */
 
-#include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
 #include <fdt_support.h>
diff --git a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
index a9f4376c8e1..ddef7d61235 100644
--- a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
+++ b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
@@ -4,7 +4,6 @@
  * Author: Yanhong Wang<yanhong.wang@starfivetech.com>
  */
 
-#include <common.h>
 #include <command.h>
 #include <env.h>
 #include <i2c.h>
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 6/6] doc: describe Milk-V Mars board
  2024-03-21 18:11 [PATCH v2 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
                   ` (4 preceding siblings ...)
  2024-03-21 18:11 ` [PATCH v2 5/6] riscv: starfive: avoid including common.h Heinrich Schuchardt
@ 2024-03-21 18:11 ` Heinrich Schuchardt
  2024-03-25  3:10 ` 回复: [PATCH v2 0/6] riscv: add support for " Minda Chen
  6 siblings, 0 replies; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-03-21 18:11 UTC (permalink / raw)
  To: Minda Chen, Rick Chen, Leo
  Cc: Lukasz Tekieli, Aurelien Jarno, Chanho Park, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot,
	Heinrich Schuchardt

Add instructions to build U-Boot for the Milk-V Mars board

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	describe how to preset fdtfile
---
 doc/board/starfive/index.rst       |   1 +
 doc/board/starfive/milk-v_mars.rst | 111 +++++++++++++++++++++++++++++
 2 files changed, 112 insertions(+)
 create mode 100644 doc/board/starfive/milk-v_mars.rst

diff --git a/doc/board/starfive/index.rst b/doc/board/starfive/index.rst
index 0c52dc7b095..2762bf74c11 100644
--- a/doc/board/starfive/index.rst
+++ b/doc/board/starfive/index.rst
@@ -6,4 +6,5 @@ StarFive
 .. toctree::
    :maxdepth: 1
 
+   milk-v_mars.rst
    visionfive2
diff --git a/doc/board/starfive/milk-v_mars.rst b/doc/board/starfive/milk-v_mars.rst
new file mode 100644
index 00000000000..9cfd5d7bddd
--- /dev/null
+++ b/doc/board/starfive/milk-v_mars.rst
@@ -0,0 +1,111 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Milk-V Mars
+===========
+
+U-Boot for the Milk-V Mars uses the same U-Boot binaries as the VisionFive 2
+board. In U-Boot SPL the actual board is detected and the device-tree patched
+accordingly.
+
+Building
+~~~~~~~~
+
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation environment variable:
+
+.. code-block:: none
+
+   export CROSS_COMPILE=<riscv64 toolchain prefix>
+
+The M-mode software OpenSBI provides the supervisor binary interface (SBI) and
+is responsible for the switch to S-Mode. It is a prerequisite to build U-Boot.
+Support for the JH7110 was introduced in OpenSBI 1.2. It is recommended to use
+a current release.
+
+.. code-block:: console
+
+	git clone https://github.com/riscv/opensbi.git
+	cd opensbi
+	make PLATFORM=generic FW_TEXT_START=0x40000000 FW_OPTIONS=0
+
+Now build the U-Boot SPL and U-Boot proper.
+
+.. code-block:: console
+
+	cd <U-Boot-dir>
+	make starfive_visionfive2_defconfig
+	make OPENSBI=$(opensbi_dir)/build/platform/generic/firmware/fw_dynamic.bin
+
+This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as well
+as the FIT image (u-boot.itb) with OpenSBI and U-Boot.
+
+Device-tree selection
+~~~~~~~~~~~~~~~~~~~~~
+
+Depending on the board version U-Boot set variable $fdtfile to either
+starfive/jh7110-starfive-visionfive-2-v1.2a.dtb or
+starfive/jh7110-starfive-visionfive-2-v1.3b.dtb.
+
+To overrule this selection the variable can be set manually and saved in the
+environment
+
+::
+
+    setenv fdtfile my_device-tree.dtb
+    env save
+
+or the configuration variable CONFIG_DEFAULT_FDT_FILE can be used to set to
+provide a default value.
+
+Boot source selection
+~~~~~~~~~~~~~~~~~~~~~
+
+The board provides the DIP switches MSEL[1:0] to select the boot device out of
+SPI flash, eMMC, SD-card, UART. To select booting from SD-card set the DIP
+switches MSEL[1:0] to 10.
+
+Preparing the SD-Card
+~~~~~~~~~~~~~~~~~~~~~
+
+The device firmware loads U-Boot SPL (u-boot-spl.bin.normal.out) from the
+partition with type GUID 2E54B353-1271-4842-806F-E436D6AF6985. You are free
+to choose any partition number.
+
+With the default configuration U-Boot SPL loads the U-Boot FIT image
+(u-boot.itb) from partition 2 (CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x2).
+When formatting it is recommended to use GUID
+BC13C2FF-59E6-4262-A352-B275FD6F7172 for this partition.
+
+The FIT image (u-boot.itb) is a combination of OpenSBI's fw_dynamic.bin,
+u-boot-nodtb.bin and the device tree blob.
+
+Format the SD card (make sure the disk has GPT, otherwise use gdisk to switch)
+
+.. code-block:: bash
+
+	sudo sgdisk --clear \
+	  --set-alignment=2 \
+	  --new=1:4096:8191 --change-name=1:spl --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985\
+	  --new=2:8192:16383 --change-name=2:uboot --typecode=2:BC13C2FF-59E6-4262-A352-B275FD6F7172  \
+	  --new=3:16384:1654784 --change-name=3:system --typecode=3:EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 \
+	  /dev/sdb
+
+Copy U-Boot to the SD card
+
+.. code-block:: bash
+
+	sudo dd if=u-boot-spl.bin.normal.out of=/dev/sdb1
+	sudo dd if=u-boot.itb of=/dev/sdb2
+
+	sudo mount /dev/sdb3 /mnt/
+	sudo cp u-boot-spl.bin.normal.out /mnt/
+	sudo cp u-boot.itb /mnt/
+	sudo cp Image.gz /mnt/
+	sudo cp initramfs.cpio.gz /mnt/
+	sudo cp jh7110-starfive-visionfive-2.dtb /mnt/
+	sudo umount /mnt
+
+Booting
+~~~~~~~
+
+Once you plugin the sdcard and power up, you should see the U-Boot prompt.
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/6] board: starfive: support Milk-V Mars board
  2024-03-21 18:11 ` [PATCH v2 4/6] board: starfive: support Milk-V Mars board Heinrich Schuchardt
@ 2024-03-24 15:00   ` Aurelien Jarno
  2024-03-27 11:03     ` Heinrich Schuchardt
  2024-03-28 16:01     ` Heinrich Schuchardt
  2024-03-28  5:24   ` Leo Liang
  1 sibling, 2 replies; 20+ messages in thread
From: Aurelien Jarno @ 2024-03-24 15:00 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Minda Chen, Rick Chen, Leo, Lukasz Tekieli, Chanho Park,
	Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot

On 2024-03-21 19:11, Heinrich Schuchardt wrote:
> The differences between the Milk-V Mars board and the VisionFive 2 board
> are small enough that we can support both using the same U-Boot build.
> 
> * The model and compatible property are taken from proposed Linux patches.
> * The EEPROM is atmel,24c02 according to the vendor U-Boot.
> * The second Ethernet port is not available.

From the device tree that have been submitted to the kernel [1] it seems
another difference is that there is a CD gpio for mmc1.

From the schematics, it also seems that the usb0 port is not in
peripheral mode, but in host mode. That said on the submitted kernel
device tree it seems simply disabled.

Aurelien

[1] https://lore.kernel.org/linux-kernel/20240131132600.4067-2-jszhang@kernel.org/T/

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                     http://aurel32.net

^ permalink raw reply	[flat|nested] 20+ messages in thread

* 回复: [PATCH v2 0/6] riscv: add support for Milk-V Mars board
  2024-03-21 18:11 [PATCH v2 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
                   ` (5 preceding siblings ...)
  2024-03-21 18:11 ` [PATCH v2 6/6] doc: describe Milk-V Mars board Heinrich Schuchardt
@ 2024-03-25  3:10 ` Minda Chen
  6 siblings, 0 replies; 20+ messages in thread
From: Minda Chen @ 2024-03-25  3:10 UTC (permalink / raw)
  To: Heinrich Schuchardt, Rick Chen, Leo, Hal Feng
  Cc: Lukasz Tekieli, Aurelien Jarno, Chanho Park, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot



> 
> The Milk-V Mars board is technically very close to the StarFive VisionFive 2
> board.
> 
> With this patch series the VisionFive 2 U-Boot SPL will detect that it is running on
> a Milk-V board and patch the device-tree accordingly.
> This is the same approach that has been taken to handle the differences
> between the Visionfive 2 1.2B and 1.3A revisions.
> 
> v2:
> 	do not set default fdt for VisionFive 2
> 	do not overwrite /soc/i2c@12050000/eeprom@50/compatible
> 

Hi Heinrich
    I will test this series patch first. Next version please cc Hal,He will help
to review this series patch.

Minda 

> *** BLURB HERE ***
> 
> Heinrich Schuchardt (6):
>   riscv: do not set default fdt for VisionFive 2
>   eeprom: starfive: function get_product_id_from_eeprom()
>   riscv: set fdtfile on Milk-V Mars
>   board: starfive: support Milk-V Mars board
>   riscv: starfive: avoid including common.h
>   doc: describe Milk-V Mars board
> 
>  arch/riscv/include/asm/arch-jh7110/eeprom.h   |   9 ++
>  board/starfive/visionfive2/spl.c              | 100 ++++++++++++++--
>  .../visionfive2/starfive_visionfive2.c        |  48 +++++---
>  .../visionfive2/visionfive2-i2c-eeprom.c      |   9 +-
>  configs/starfive_visionfive2_defconfig        |   1 -
>  doc/board/starfive/index.rst                  |   1 +
>  doc/board/starfive/milk-v_mars.rst            | 111 ++++++++++++++++++
>  doc/board/starfive/visionfive2.rst            |  18 +++
>  8 files changed, 268 insertions(+), 29 deletions(-)  create mode 100644
> doc/board/starfive/milk-v_mars.rst
> 
> --
> 2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 1/6] riscv: do not set default fdt for VisionFive 2
  2024-03-21 18:11 ` [PATCH v2 1/6] riscv: do not set default fdt for VisionFive 2 Heinrich Schuchardt
@ 2024-03-27  9:01   ` Leo Liang
  0 siblings, 0 replies; 20+ messages in thread
From: Leo Liang @ 2024-03-27  9:01 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Minda Chen, Rick Chen, Lukasz Tekieli, Aurelien Jarno,
	Chanho Park, Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow,
	u-boot

On Thu, Mar 21, 2024 at 07:11:44PM +0100, Heinrich Schuchardt wrote:
> Currently in set_fdtfile() we set the value of environment variable fdtfile
> unconditionally. The implies that a value in the environment will be
> ignored.
> 
> With the patch environment variable fdtfile will only be set if it does not
> yet exist. This requires that CONFIG_DEFAULT_FDT_FILE is not set.
> 
> Now the user can either set and save fdtfile interactively or in the U-Boot
> configuration to overrule the device-tree name chosen based on the
> hardware in set_fdtfile().
> 
> Reported-by: E Shattow <lucent@gmail.com>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	new patch
> ---
>  .../visionfive2/starfive_visionfive2.c         |  4 ++++
>  configs/starfive_visionfive2_defconfig         |  1 -
>  doc/board/starfive/visionfive2.rst             | 18 ++++++++++++++++++
>  3 files changed, 22 insertions(+), 1 deletion(-)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/6] eeprom: starfive: function get_product_id_from_eeprom()
  2024-03-21 18:11 ` [PATCH v2 2/6] eeprom: starfive: function get_product_id_from_eeprom() Heinrich Schuchardt
@ 2024-03-27  9:13   ` Leo Liang
  0 siblings, 0 replies; 20+ messages in thread
From: Leo Liang @ 2024-03-27  9:13 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Minda Chen, Rick Chen, Lukasz Tekieli, Aurelien Jarno,
	Chanho Park, Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow,
	u-boot

On Thu, Mar 21, 2024 at 07:11:45PM +0100, Heinrich Schuchardt wrote:
> Export a function get_product_id_from_eeprom() to read the product ID.
> This value can be used for fixing up the device-tree on JH7110 based
> products.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	no change
> ---
>  arch/riscv/include/asm/arch-jh7110/eeprom.h         | 9 +++++++++
>  board/starfive/visionfive2/visionfive2-i2c-eeprom.c | 8 ++++++++
>  2 files changed, 17 insertions(+)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/6] board: starfive: support Milk-V Mars board
  2024-03-24 15:00   ` Aurelien Jarno
@ 2024-03-27 11:03     ` Heinrich Schuchardt
  2024-03-28  6:24       ` Leo Liang
  2024-03-28 16:01     ` Heinrich Schuchardt
  1 sibling, 1 reply; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-03-27 11:03 UTC (permalink / raw)
  To: Aurelien Jarno
  Cc: Minda Chen, Rick Chen, Leo, Lukasz Tekieli, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot, Hal Feng

On 24.03.24 16:00, Aurelien Jarno wrote:
> On 2024-03-21 19:11, Heinrich Schuchardt wrote:
>> The differences between the Milk-V Mars board and the VisionFive 2 board
>> are small enough that we can support both using the same U-Boot build.
>>
>> * The model and compatible property are taken from proposed Linux patches.
>> * The EEPROM is atmel,24c02 according to the vendor U-Boot.
>> * The second Ethernet port is not available.
> 
>  From the device tree that have been submitted to the kernel [1] it seems
> another difference is that there is a CD gpio for mmc1.

Yes, the Mars board has

     cd-gpios = <&sysgpio 41 GPIO_ACTIVE_LOW>;

while the VisionFive 2 has

    broken-cd;

We could add the cd-gpios to the VF2 dts and then set broken-cd in 
spl_fdt_fixup_*().

What I would really like to understand from the reviewers is if the 
approach with patching the device-tree is what we are targeting for.

Or should we try to keep the device-trees in sync with Linux, package 
all JH7110 device-trees into the FIT image and in SPL choose the 
device-tree from the fit image and only patch the memory size.

The device-tree for the Milk-V CM module differs a lot in GPIO routing. 
I am not sure that patching the VF2 device-tree is future proof.

Best regards

Heinrich


> 
>  From the schematics, it also seems that the usb0 port is not in
> peripheral mode, but in host mode. That said on the submitted kernel
> device tree it seems simply disabled.
> 
> Aurelien
> 
> [1] https://lore.kernel.org/linux-kernel/20240131132600.4067-2-jszhang@kernel.org/T/
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 5/6] riscv: starfive: avoid including common.h
  2024-03-21 18:11 ` [PATCH v2 5/6] riscv: starfive: avoid including common.h Heinrich Schuchardt
@ 2024-03-28  3:09   ` Leo Liang
  0 siblings, 0 replies; 20+ messages in thread
From: Leo Liang @ 2024-03-28  3:09 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Minda Chen, Rick Chen, Lukasz Tekieli, Aurelien Jarno,
	Chanho Park, Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow,
	u-boot

On Thu, Mar 21, 2024 at 07:11:48PM +0100, Heinrich Schuchardt wrote:
> The usage of common.h is deprecated. Remove it from board files.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	no change
> ---
>  board/starfive/visionfive2/spl.c                    | 1 -
>  board/starfive/visionfive2/starfive_visionfive2.c   | 1 -
>  board/starfive/visionfive2/visionfive2-i2c-eeprom.c | 1 -
>  3 files changed, 3 deletions(-)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 3/6] riscv: set fdtfile on Milk-V Mars
  2024-03-21 18:11 ` [PATCH v2 3/6] riscv: set fdtfile on Milk-V Mars Heinrich Schuchardt
@ 2024-03-28  3:35   ` Leo Liang
  0 siblings, 0 replies; 20+ messages in thread
From: Leo Liang @ 2024-03-28  3:35 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Minda Chen, Rick Chen, Lukasz Tekieli, Aurelien Jarno,
	Chanho Park, Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow,
	u-boot

On Thu, Mar 21, 2024 at 07:11:46PM +0100, Heinrich Schuchardt wrote:
> Set environment variable fdtfile to the correct value for the Milk-V Mars
> board.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	rebase patch
> ---
>  .../visionfive2/starfive_visionfive2.c        | 43 +++++++++++++------
>  1 file changed, 30 insertions(+), 13 deletions(-)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/6] board: starfive: support Milk-V Mars board
  2024-03-21 18:11 ` [PATCH v2 4/6] board: starfive: support Milk-V Mars board Heinrich Schuchardt
  2024-03-24 15:00   ` Aurelien Jarno
@ 2024-03-28  5:24   ` Leo Liang
  1 sibling, 0 replies; 20+ messages in thread
From: Leo Liang @ 2024-03-28  5:24 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Minda Chen, Rick Chen, Lukasz Tekieli, Aurelien Jarno,
	Chanho Park, Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow,
	u-boot

Hi Heinrich,

On Thu, Mar 21, 2024 at 07:11:47PM +0100, Heinrich Schuchardt wrote:
> The differences between the Milk-V Mars board and the VisionFive 2 board
> are small enough that we can support both using the same U-Boot build.
> 
> * The model and compatible property are taken from proposed Linux patches.
> * The EEPROM is atmel,24c02 according to the vendor U-Boot.
> * The second Ethernet port is not available.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	do not overwrite /soc/i2c@12050000/eeprom@50/compatible
> 	
> ---
>  board/starfive/visionfive2/spl.c | 99 ++++++++++++++++++++++++++++----
>  1 file changed, 87 insertions(+), 12 deletions(-)
> 
> diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
> index 1b49945d11b..e0e33cb37ba 100644
> --- a/board/starfive/visionfive2/spl.c
> +++ b/board/starfive/visionfive2/spl.c
> @@ -67,6 +87,49 @@ static const struct starfive_vf2_pro starfive_verb[] = {
>  		"tx-internal-delay-ps", "0"},
>  };
>  
> +void spl_fdt_fixup_mars(void *fdt)
> +{
> +	static const char compat[] = "milkv,mars\0starfive,jh7110";
> +	u32 phandle;
> +	u8 i;
> +	int offset;
> +	int ret;
> +
> +	fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat));
> +	fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model",
> +			   "Milk-V Mars");
> +
> +	/* 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 */
> +	fdt_setprop_string(fdt, fdt_path_offset(fdt, "/soc/ethernet@16040000"),
> +			   "status", "disabled");
> +
> +	for (i = 0; i < ARRAY_SIZE(milk_v_mars); i++) {
> +		offset = fdt_path_offset(fdt, milk_v_mars[i].path);
> +
> +		if (starfive_verb[i].value)

Should this be milk_v_mars[i].value ?

> +			ret = fdt_setprop_u32(fdt, offset, milk_v_mars[i].name,
> +					      dectoul(milk_v_mars[i].value, NULL));
> +		else
> +			ret = fdt_setprop_empty(fdt, offset, milk_v_mars[i].name);
> +
> +		if (ret) {
> +			pr_err("%s set prop %s fail.\n", __func__, milk_v_mars[i].name);
> +				break;
> +		}
> +	}
> +}
> +

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/6] board: starfive: support Milk-V Mars board
  2024-03-27 11:03     ` Heinrich Schuchardt
@ 2024-03-28  6:24       ` Leo Liang
  0 siblings, 0 replies; 20+ messages in thread
From: Leo Liang @ 2024-03-28  6:24 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Aurelien Jarno, Minda Chen, Rick Chen, Lukasz Tekieli,
	Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot,
	Hal Feng

Hi Heinrich,

On Wed, Mar 27, 2024 at 12:03:01PM +0100, Heinrich Schuchardt wrote:
> [EXTERNAL MAIL]
> 
> On 24.03.24 16:00, Aurelien Jarno wrote:
> > On 2024-03-21 19:11, Heinrich Schuchardt wrote:
> > > The differences between the Milk-V Mars board and the VisionFive 2 board
> > > are small enough that we can support both using the same U-Boot build.
> > > 
> > > * The model and compatible property are taken from proposed Linux patches.
> > > * The EEPROM is atmel,24c02 according to the vendor U-Boot.
> > > * The second Ethernet port is not available.
> > 
> >  From the device tree that have been submitted to the kernel [1] it seems
> > another difference is that there is a CD gpio for mmc1.
> 
> Yes, the Mars board has
> 
>     cd-gpios = <&sysgpio 41 GPIO_ACTIVE_LOW>;
> 
> while the VisionFive 2 has
> 
>    broken-cd;
> 
> We could add the cd-gpios to the VF2 dts and then set broken-cd in
> spl_fdt_fixup_*().
> 
> What I would really like to understand from the reviewers is if the
> approach with patching the device-tree is what we are targeting for.
> 
> Or should we try to keep the device-trees in sync with Linux, package
> all JH7110 device-trees into the FIT image and in SPL choose the
> device-tree from the fit image and only patch the memory size.
> 
> The device-tree for the Milk-V CM module differs a lot in GPIO routing.
> I am not sure that patching the VF2 device-tree is future proof.

I think we could patch the VF2 device-tree currently with this few differeces,
and create a new device tree for Milk-V Mars CM module if patching the VF2 device tree
is too much of an effort.

Does this sound reasonable ?
Do you have any preference over which scheme we should use ?

Best regards,
Leo

> 
> Best regards
> 
> Heinrich
> 
> 
> > 
> >  From the schematics, it also seems that the usb0 port is not in
> > peripheral mode, but in host mode. That said on the submitted kernel
> > device tree it seems simply disabled.
> > 
> > Aurelien
> > 
> > [1] https://lore.kernel.org/linux-kernel/20240131132600.4067-2-jszhang@kernel.org/T/
> > 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/6] board: starfive: support Milk-V Mars board
  2024-03-24 15:00   ` Aurelien Jarno
  2024-03-27 11:03     ` Heinrich Schuchardt
@ 2024-03-28 16:01     ` Heinrich Schuchardt
  2024-04-01 15:28       ` Aurelien Jarno
  1 sibling, 1 reply; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-03-28 16:01 UTC (permalink / raw)
  To: Aurelien Jarno
  Cc: Minda Chen, Rick Chen, Leo, Lukasz Tekieli, Chanho Park,
	Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot

On 24.03.24 16:00, Aurelien Jarno wrote:
> On 2024-03-21 19:11, Heinrich Schuchardt wrote:
>> The differences between the Milk-V Mars board and the VisionFive 2 board
>> are small enough that we can support both using the same U-Boot build.
>>
>> * The model and compatible property are taken from proposed Linux patches.
>> * The EEPROM is atmel,24c02 according to the vendor U-Boot.
>> * The second Ethernet port is not available.
> 
>  From the device tree that have been submitted to the kernel [1] it seems
> another difference is that there is a CD gpio for mmc1.

Thank you for reviewing.

On all of Milk-V Mars, VisionFive 2 1.2B, and 1.3A I see GPIO 41 level 
changing when removing or inserting an SD card using U-Boot command 
'gpio status -a'. So this seems not to be Milk-V specific.

Could you, please, check.

> 
>  From the schematics, it also seems that the usb0 port is not in
> peripheral mode, but in host mode. That said on the submitted kernel
> device tree it seems simply disabled.

All three blue-colored USB 3.0 ports are able to read an SD-card in U-Boot.

The black port provides 5V but I could not make it work.

On the schema I found:

USB20: Do not support OTG mode and AVSS_USB0-AVSS_USB2 attached to ground.

Could you, please, specify which node in the device-tree you want to 
disable. I cannot see anything disabled for usb@10100000 and usb@0 in 
the kernel device-tree.

Best regards

Heinrich

> 
> Aurelien
> 
> [1] https://lore.kernel.org/linux-kernel/20240131132600.4067-2-jszhang@kernel.org/T/
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/6] board: starfive: support Milk-V Mars board
  2024-03-28 16:01     ` Heinrich Schuchardt
@ 2024-04-01 15:28       ` Aurelien Jarno
  2024-04-01 15:54         ` Heinrich Schuchardt
  0 siblings, 1 reply; 20+ messages in thread
From: Aurelien Jarno @ 2024-04-01 15:28 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Minda Chen, Rick Chen, Leo, Lukasz Tekieli, Chanho Park,
	Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot

On 2024-03-28 17:01, Heinrich Schuchardt wrote:
> On 24.03.24 16:00, Aurelien Jarno wrote:
> > On 2024-03-21 19:11, Heinrich Schuchardt wrote:
> > > The differences between the Milk-V Mars board and the VisionFive 2 board
> > > are small enough that we can support both using the same U-Boot build.
> > > 
> > > * The model and compatible property are taken from proposed Linux patches.
> > > * The EEPROM is atmel,24c02 according to the vendor U-Boot.
> > > * The second Ethernet port is not available.
> > 
> >  From the device tree that have been submitted to the kernel [1] it seems
> > another difference is that there is a CD gpio for mmc1.
> 
> Thank you for reviewing.
> 
> On all of Milk-V Mars, VisionFive 2 1.2B, and 1.3A I see GPIO 41 level
> changing when removing or inserting an SD card using U-Boot command 'gpio
> status -a'. So this seems not to be Milk-V specific.
> 
> Could you, please, check.

This already have been answered by others, thanks.

> >  From the schematics, it also seems that the usb0 port is not in
> > peripheral mode, but in host mode. That said on the submitted kernel
> > device tree it seems simply disabled.
> 
> All three blue-colored USB 3.0 ports are able to read an SD-card in U-Boot.
> 
> The black port provides 5V but I could not make it work.
> 
> On the schema I found:
> 
> USB20: Do not support OTG mode and AVSS_USB0-AVSS_USB2 attached to ground.
> 
> Could you, please, specify which node in the device-tree you want to
> disable. I cannot see anything disabled for usb@10100000 and usb@0 in the
> kernel device-tree.

Disclaimer, I have no such board, but I remember people on IRC trying to
use the device tree from the VF2 on a Milk-V Mars and getting an error
with the USB being in a wrong mode.

The difference I have noticed is not a node but the dr_mode property:

&usb0 { 
        dr_mode = "peripheral";
        status = "okay";
};

This does not appear on the patches submitted on the Linux side for the MilkV
Mars.

Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                     http://aurel32.net

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/6] board: starfive: support Milk-V Mars board
  2024-04-01 15:28       ` Aurelien Jarno
@ 2024-04-01 15:54         ` Heinrich Schuchardt
  2024-04-02  1:19           ` Minda Chen
  0 siblings, 1 reply; 20+ messages in thread
From: Heinrich Schuchardt @ 2024-04-01 15:54 UTC (permalink / raw)
  To: Aurelien Jarno
  Cc: Minda Chen, Rick Chen, Leo, Lukasz Tekieli, Shiji Yang,
	Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot, Hal Feng

On 4/1/24 17:28, Aurelien Jarno wrote:
> On 2024-03-28 17:01, Heinrich Schuchardt wrote:
>> On 24.03.24 16:00, Aurelien Jarno wrote:
>>> On 2024-03-21 19:11, Heinrich Schuchardt wrote:
>>>> The differences between the Milk-V Mars board and the VisionFive 2 board
>>>> are small enough that we can support both using the same U-Boot build.
>>>>
>>>> * The model and compatible property are taken from proposed Linux patches.
>>>> * The EEPROM is atmel,24c02 according to the vendor U-Boot.
>>>> * The second Ethernet port is not available.
>>>
>>>   From the device tree that have been submitted to the kernel [1] it seems
>>> another difference is that there is a CD gpio for mmc1.
>>
>> Thank you for reviewing.
>>
>> On all of Milk-V Mars, VisionFive 2 1.2B, and 1.3A I see GPIO 41 level
>> changing when removing or inserting an SD card using U-Boot command 'gpio
>> status -a'. So this seems not to be Milk-V specific.
>>
>> Could you, please, check.
> 
> This already have been answered by others, thanks.
> 
>>>   From the schematics, it also seems that the usb0 port is not in
>>> peripheral mode, but in host mode. That said on the submitted kernel
>>> device tree it seems simply disabled.
>>
>> All three blue-colored USB 3.0 ports are able to read an SD-card in U-Boot.
>>
>> The black port provides 5V but I could not make it work.
>>
>> On the schema I found:
>>
>> USB20: Do not support OTG mode and AVSS_USB0-AVSS_USB2 attached to ground.
>>
>> Could you, please, specify which node in the device-tree you want to
>> disable. I cannot see anything disabled for usb@10100000 and usb@0 in the
>> kernel device-tree.
> 
> Disclaimer, I have no such board, but I remember people on IRC trying to
> use the device tree from the VF2 on a Milk-V Mars and getting an error
> with the USB being in a wrong mode.
> 
> The difference I have noticed is not a node but the dr_mode property:
> 
> &usb0 {
>          dr_mode = "peripheral";
>          status = "okay";
> };

Thanks Aurelien for the explanation.

The node usb@10100000 (aka usb0) does not exist in the U-Boot 
VisionFive2 device-tree, yet. There isn't any dr_mode property either.

We will have to consider this node once we merge the Linux device-tree.

Best regards

Heinrich

> 
> This does not appear on the patches submitted on the Linux side for the MilkV
> Mars.
> 
> Aurelien
> 


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/6] board: starfive: support Milk-V Mars board
  2024-04-01 15:54         ` Heinrich Schuchardt
@ 2024-04-02  1:19           ` Minda Chen
  0 siblings, 0 replies; 20+ messages in thread
From: Minda Chen @ 2024-04-02  1:19 UTC (permalink / raw)
  To: Heinrich Schuchardt, Aurelien Jarno
  Cc: Rick Chen, Leo, Lukasz Tekieli, Shiji Yang, Shengyu Qu,
	Seung-Woo Kim, E Shattow, u-boot, Hal Feng

> 
> On 4/1/24 17:28, Aurelien Jarno wrote:
> > On 2024-03-28 17:01, Heinrich Schuchardt wrote:
> >> On 24.03.24 16:00, Aurelien Jarno wrote:
> >>> On 2024-03-21 19:11, Heinrich Schuchardt wrote:
> >>>> The differences between the Milk-V Mars board and the VisionFive 2
> >>>> board are small enough that we can support both using the same U-Boot
> build.
> >>>>
> >>>> * The model and compatible property are taken from proposed Linux
> patches.
> >>>> * The EEPROM is atmel,24c02 according to the vendor U-Boot.
> >>>> * The second Ethernet port is not available.
> >>>
> >>>   From the device tree that have been submitted to the kernel [1] it
> >>> seems another difference is that there is a CD gpio for mmc1.
> >>
> >> Thank you for reviewing.
> >>
> >> On all of Milk-V Mars, VisionFive 2 1.2B, and 1.3A I see GPIO 41
> >> level changing when removing or inserting an SD card using U-Boot
> >> command 'gpio status -a'. So this seems not to be Milk-V specific.
> >>
> >> Could you, please, check.
> >
> > This already have been answered by others, thanks.
> >
> >>>   From the schematics, it also seems that the usb0 port is not in
> >>> peripheral mode, but in host mode. That said on the submitted kernel
> >>> device tree it seems simply disabled.
> >>
> >> All three blue-colored USB 3.0 ports are able to read an SD-card in U-Boot.
> >>
> >> The black port provides 5V but I could not make it work.
> >>
> >> On the schema I found:
> >>
> >> USB20: Do not support OTG mode and AVSS_USB0-AVSS_USB2 attached to
> ground.
> >>
> >> Could you, please, specify which node in the device-tree you want to
> >> disable. I cannot see anything disabled for usb@10100000 and usb@0 in
> >> the kernel device-tree.
> >
> > Disclaimer, I have no such board, but I remember people on IRC trying
> > to use the device tree from the VF2 on a Milk-V Mars and getting an
> > error with the USB being in a wrong mode.
> >
> > The difference I have noticed is not a node but the dr_mode property:
> >
> > &usb0 {
> >          dr_mode = "peripheral";
> >          status = "okay";
> > };
> 
> Thanks Aurelien for the explanation.
> 
> The node usb@10100000 (aka usb0) does not exist in the U-Boot
> VisionFive2 device-tree, yet. There isn't any dr_mode property either.
> 
> We will have to consider this node once we merge the Linux device-tree.
> 
> Best regards
> 
> Heinrich
> 
usb@10100000 is cadence usb controller. In VF2, dr mode is usb peripheral and 
seldom used in u-boot. So the cadence usb wrapper codes not in uboot upstream.
I don't know the dr mode in milkv 7110 board. But if it its dr mode is host, I think I
need develop cadence usb wrapper code upstream.

Minda 
> >
> > This does not appear on the patches submitted on the Linux side for
> > the MilkV Mars.
> >
> > Aurelien
> >


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2024-04-02  1:19 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-21 18:11 [PATCH v2 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
2024-03-21 18:11 ` [PATCH v2 1/6] riscv: do not set default fdt for VisionFive 2 Heinrich Schuchardt
2024-03-27  9:01   ` Leo Liang
2024-03-21 18:11 ` [PATCH v2 2/6] eeprom: starfive: function get_product_id_from_eeprom() Heinrich Schuchardt
2024-03-27  9:13   ` Leo Liang
2024-03-21 18:11 ` [PATCH v2 3/6] riscv: set fdtfile on Milk-V Mars Heinrich Schuchardt
2024-03-28  3:35   ` Leo Liang
2024-03-21 18:11 ` [PATCH v2 4/6] board: starfive: support Milk-V Mars board Heinrich Schuchardt
2024-03-24 15:00   ` Aurelien Jarno
2024-03-27 11:03     ` Heinrich Schuchardt
2024-03-28  6:24       ` Leo Liang
2024-03-28 16:01     ` Heinrich Schuchardt
2024-04-01 15:28       ` Aurelien Jarno
2024-04-01 15:54         ` Heinrich Schuchardt
2024-04-02  1:19           ` Minda Chen
2024-03-28  5:24   ` Leo Liang
2024-03-21 18:11 ` [PATCH v2 5/6] riscv: starfive: avoid including common.h Heinrich Schuchardt
2024-03-28  3:09   ` Leo Liang
2024-03-21 18:11 ` [PATCH v2 6/6] doc: describe Milk-V Mars board Heinrich Schuchardt
2024-03-25  3:10 ` 回复: [PATCH v2 0/6] riscv: add support for " Minda Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.