* [PATCH v3 1/6] riscv: do not set default fdt for VisionFive 2
2024-04-02 8:49 [PATCH v3 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
@ 2024-04-02 8:49 ` Heinrich Schuchardt
2024-04-08 10:10 ` Leo Liang
2024-04-02 8:49 ` [PATCH v3 2/6] eeprom: starfive: function get_product_id_from_eeprom() Heinrich Schuchardt
` (4 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Heinrich Schuchardt @ 2024-04-02 8:49 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Rick Chen, Leo
Cc: Aurelien Jarno, Lukasz Tekieli, 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>
---
v3:
Rephrase last added sentence in doc/board/starfive/visionfive2.rst
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..2c68df3ce4d 100644
--- a/doc/board/starfive/visionfive2.rst
+++ b/doc/board/starfive/visionfive2.rst
@@ -71,6 +71,24 @@ Now build the U-Boot SPL and U-Boot proper
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 provide
+a default value.
+
Flashing
~~~~~~~~
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v3 1/6] riscv: do not set default fdt for VisionFive 2
2024-04-02 8:49 ` [PATCH v3 1/6] riscv: do not set default fdt for VisionFive 2 Heinrich Schuchardt
@ 2024-04-08 10:10 ` Leo Liang
0 siblings, 0 replies; 10+ messages in thread
From: Leo Liang @ 2024-04-08 10:10 UTC (permalink / raw)
To: Heinrich Schuchardt
Cc: Minda Chen, Hal Feng, Rick Chen, Aurelien Jarno, Lukasz Tekieli,
Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot
On Tue, Apr 02, 2024 at 10:49:07AM +0200, 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>
> ---
> v3:
> Rephrase last added sentence in doc/board/starfive/visionfive2.rst
> 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] 10+ messages in thread
* [PATCH v3 2/6] eeprom: starfive: function get_product_id_from_eeprom()
2024-04-02 8:49 [PATCH v3 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
2024-04-02 8:49 ` [PATCH v3 1/6] riscv: do not set default fdt for VisionFive 2 Heinrich Schuchardt
@ 2024-04-02 8:49 ` Heinrich Schuchardt
2024-04-02 8:49 ` [PATCH v3 3/6] riscv: set fdtfile on Milk-V Mars Heinrich Schuchardt
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Heinrich Schuchardt @ 2024-04-02 8:49 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Rick Chen, Leo
Cc: Aurelien Jarno, Lukasz Tekieli, 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>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
v3:
no change
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] 10+ messages in thread* [PATCH v3 3/6] riscv: set fdtfile on Milk-V Mars
2024-04-02 8:49 [PATCH v3 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
2024-04-02 8:49 ` [PATCH v3 1/6] riscv: do not set default fdt for VisionFive 2 Heinrich Schuchardt
2024-04-02 8:49 ` [PATCH v3 2/6] eeprom: starfive: function get_product_id_from_eeprom() Heinrich Schuchardt
@ 2024-04-02 8:49 ` Heinrich Schuchardt
2024-04-02 8:49 ` [PATCH v3 4/6] board: starfive: support Milk-V Mars board Heinrich Schuchardt
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Heinrich Schuchardt @ 2024-04-02 8:49 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Rick Chen, Leo
Cc: Aurelien Jarno, Lukasz Tekieli, 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>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
v3:
no change
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] 10+ messages in thread* [PATCH v3 4/6] board: starfive: support Milk-V Mars board
2024-04-02 8:49 [PATCH v3 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
` (2 preceding siblings ...)
2024-04-02 8:49 ` [PATCH v3 3/6] riscv: set fdtfile on Milk-V Mars Heinrich Schuchardt
@ 2024-04-02 8:49 ` Heinrich Schuchardt
2024-04-08 10:44 ` Leo Liang
2024-04-02 8:49 ` [PATCH v3 5/6] riscv: starfive: avoid including common.h Heinrich Schuchardt
2024-04-02 8:49 ` [PATCH v3 6/6] doc: describe Milk-V Mars board Heinrich Schuchardt
5 siblings, 1 reply; 10+ messages in thread
From: Heinrich Schuchardt @ 2024-04-02 8:49 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Rick Chen, Leo
Cc: Aurelien Jarno, Lukasz Tekieli, 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.
usb@10100000 does not exist in U-Boot yet. So we don't have to reflect
differences in usage here.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
For the mmc card-detect a separate patch has been created:
https://lore.kernel.org/u-boot/20240328214615.21501-1-heinrich.schuchardt@canonical.com/
v3:
Replace misplaced starfive_verb[i] by milk_v_mars[i].
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..e8f97d963a0 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 (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;
+ }
+ }
+}
+
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] 10+ messages in thread* Re: [PATCH v3 4/6] board: starfive: support Milk-V Mars board
2024-04-02 8:49 ` [PATCH v3 4/6] board: starfive: support Milk-V Mars board Heinrich Schuchardt
@ 2024-04-08 10:44 ` Leo Liang
0 siblings, 0 replies; 10+ messages in thread
From: Leo Liang @ 2024-04-08 10:44 UTC (permalink / raw)
To: Heinrich Schuchardt
Cc: Minda Chen, Hal Feng, Rick Chen, Aurelien Jarno, Lukasz Tekieli,
Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot
On Tue, Apr 02, 2024 at 10:49:10AM +0200, 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.
>
> usb@10100000 does not exist in U-Boot yet. So we don't have to reflect
> differences in usage here.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> For the mmc card-detect a separate patch has been created:
> https://lore.kernel.org/u-boot/20240328214615.21501-1-heinrich.schuchardt@canonical.com/
>
> v3:
> Replace misplaced starfive_verb[i] by milk_v_mars[i].
> v2:
> do not overwrite /soc/i2c@12050000/eeprom@50/compatible
> ---
> board/starfive/visionfive2/spl.c | 99 ++++++++++++++++++++++++++++----
> 1 file changed, 87 insertions(+), 12 deletions(-)
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 5/6] riscv: starfive: avoid including common.h
2024-04-02 8:49 [PATCH v3 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
` (3 preceding siblings ...)
2024-04-02 8:49 ` [PATCH v3 4/6] board: starfive: support Milk-V Mars board Heinrich Schuchardt
@ 2024-04-02 8:49 ` Heinrich Schuchardt
2024-04-02 8:49 ` [PATCH v3 6/6] doc: describe Milk-V Mars board Heinrich Schuchardt
5 siblings, 0 replies; 10+ messages in thread
From: Heinrich Schuchardt @ 2024-04-02 8:49 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Rick Chen, Leo
Cc: Aurelien Jarno, Lukasz Tekieli, 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>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
v3:
no change
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 e8f97d963a0..45848db6d8b 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] 10+ messages in thread* [PATCH v3 6/6] doc: describe Milk-V Mars board
2024-04-02 8:49 [PATCH v3 0/6] riscv: add support for Milk-V Mars board Heinrich Schuchardt
` (4 preceding siblings ...)
2024-04-02 8:49 ` [PATCH v3 5/6] riscv: starfive: avoid including common.h Heinrich Schuchardt
@ 2024-04-02 8:49 ` Heinrich Schuchardt
2024-04-08 10:34 ` Leo Liang
5 siblings, 1 reply; 10+ messages in thread
From: Heinrich Schuchardt @ 2024-04-02 8:49 UTC (permalink / raw)
To: Minda Chen, Hal Feng, Rick Chen, Leo
Cc: Aurelien Jarno, Lukasz Tekieli, 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>
---
v3:
no change
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..554932ecfd4
--- /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] 10+ messages in thread* Re: [PATCH v3 6/6] doc: describe Milk-V Mars board
2024-04-02 8:49 ` [PATCH v3 6/6] doc: describe Milk-V Mars board Heinrich Schuchardt
@ 2024-04-08 10:34 ` Leo Liang
0 siblings, 0 replies; 10+ messages in thread
From: Leo Liang @ 2024-04-08 10:34 UTC (permalink / raw)
To: Heinrich Schuchardt, g
Cc: Minda Chen, Hal Feng, Rick Chen, Aurelien Jarno, Lukasz Tekieli,
Shiji Yang, Shengyu Qu, Seung-Woo Kim, E Shattow, u-boot
On Tue, Apr 02, 2024 at 10:49:12AM +0200, Heinrich Schuchardt wrote:
> Add instructions to build U-Boot for the Milk-V Mars board
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v3:
> no change
> 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
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
^ permalink raw reply [flat|nested] 10+ messages in thread