[PATCH] board: starfive: support Pine64 Star64 board

2024-05-06 Thread H Bell
Similar to the Milk-V Mars, The Star64 board contains few differences to the
VisionFive 2 boards, so can be part of the same U-boot build.

Signed-off-by: Henry Bell 
Cc: ycli...@andestech.com
Cc: heinrich.schucha...@canonical.com
---
 board/starfive/visionfive2/spl.c  | 52 +++
 .../visionfive2/starfive_visionfive2.c|  4 ++
 2 files changed, 56 insertions(+)

diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
index ca61b5be22..b8d29a02af 100644
--- a/board/starfive/visionfive2/spl.c
+++ b/board/starfive/visionfive2/spl.c
@@ -226,6 +226,56 @@ void spl_fdt_fixup_version_b(void *fdt)
}
 }
 
+void spl_fdt_fixup_star64(void *fdt)
+{
+   static const char compat[] = "starfive,star64\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",
+  "Pine64 Star64");
+
+   /* gmac0 */
+   offset = fdt_path_offset(fdt, "/soc/clock-controller@1700");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1603");
+
+   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@1302");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1604");
+
+   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;
@@ -252,6 +302,8 @@ void spl_perform_fixups(struct spl_image_info *spl_image)
spl_fdt_fixup_version_b(spl_image->fdt_addr);
break;
};
+   } else if (!strncmp(product_id, "STAR64", 6)) {
+   spl_fdt_fixup_star64(spl_image->fdt_addr);
} else {
pr_err("Unknown product %s\n", product_id);
};
diff --git a/board/starfive/visionfive2/starfive_visionfive2.c 
b/board/starfive/visionfive2/starfive_visionfive2.c
index a86bca533b..93bc8b5c55 100644
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -23,6 +23,8 @@ DECLARE_GLOBAL_DATA_PTR;
"starfive/jh7110-starfive-visionfive-2-v1.2a.dtb"
 #define FDTFILE_VISIONFIVE2_1_3B \
"starfive/jh7110-starfive-visionfive-2-v1.3b.dtb"
+#define FDTFILE_PINE64_STAR64 \
+   "starfive/pine64-star64.dtb"
 
 /* enable U74-mc hart1~hart4 prefetcher */
 static void enable_prefetcher(void)
@@ -78,6 +80,8 @@ static void set_fdtfile(void)
fdtfile = FDTFILE_VISIONFIVE2_1_3B;
break;
}
+   } else if (!strncmp(product_id, "STAR64", 6)) {
+   fdtfile = FDTFILE_PINE64_STAR64;
} else {
log_err("Unknown product\n");
return;
-- 
2.44.0



[PATCH 1/2 v2] board: starfive: support Pine64 Star64 board

2024-05-08 Thread H Bell
Similar to the Milk-V Mars, The Star64 board contains few differences to the
VisionFive 2 boards, so can be part of the same U-boot build.

Signed-off-by: Henry Bell 
Cc: ycli...@andestech.com
Cc: heinrich.schucha...@canonical.com
---

Changes since v1

- Fix typos on naming
- Create pine64_star64 struct to be populated with PHY values once confirmed
---
 board/starfive/visionfive2/spl.c  | 85 +++
 .../visionfive2/starfive_visionfive2.c|  4 +
 2 files changed, 89 insertions(+)

diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
index ca61b5be22..248c6ba01d 100644
--- a/board/starfive/visionfive2/spl.c
+++ b/board/starfive/visionfive2/spl.c
@@ -86,6 +86,39 @@ static const struct starfive_vf2_pro starfive_verb[] = {
"tx-internal-delay-ps", "0"},
 };
 
+static const struct starfive_vf2_pro star64_pine64[] = {
+   {"/soc/ethernet@1603", "starfive,tx-use-rgmii-clk", NULL},
+   {"/soc/ethernet@1604", "starfive,tx-use-rgmii-clk", NULL},
+
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-adj-enabled", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-100-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-1000-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,rx-clk-drv-microamp", "3970"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,rx-data-drv-microamp", "2910"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "rx-internal-delay-ps", "1900"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "tx-internal-delay-ps", "1500"},
+
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-adj-enabled", NULL},
+   { "/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-100-inverted", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,rx-clk-drv-microamp", "3970"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,rx-data-drv-microamp", "2910"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "rx-internal-delay-ps", "0"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "tx-internal-delay-ps", "0"},
+};
+
 void spl_fdt_fixup_mars(void *fdt)
 {
static const char compat[] = "milkv,mars\0starfive,jh7110";
@@ -226,6 +259,56 @@ void spl_fdt_fixup_version_b(void *fdt)
}
 }
 
+void spl_fdt_fixup_star64(void *fdt)
+{
+   static const char compat[] = "pine64,star64\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",
+  "Pine64 Star64");
+
+   /* gmac0 */
+   offset = fdt_path_offset(fdt, "/soc/clock-controller@1700");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1603");
+
+   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@1302");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1604");
+
+   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(star64_pine64); i++) {
+   offset = fdt_path_offset(fdt, star64_pine64[i].path);
+
+   if (star64_pine64[i].value)
+   ret = fdt_setprop_u32(fdt, offset,  
star64_pine64[i].name,
+ dectoul(star64_pine64[i].value, 
NULL));
+   else
+   ret = fdt_setprop_empty(fdt, offset, 
star64_pine64[i].name);
+
+   if (ret) {
+   pr_err("%s set prop %s fail.\n", __func__, 
star64_pine64[i].name);
+   break;
+   }
+   }
+}
+
 void spl_perform_fixups(struct spl_image_info *spl_image)
 {
u8 version;
@@ -252,6 +335,8 @@ void spl_perform_fixups(struct spl_image_info *spl_image)
spl

[PATCH 2/2 v2] board: starfive: support Pine64 Star64 board

2024-05-08 Thread H Bell


Add documentation files

Signed-off-by: Henry Bell 
Cc: ycli...@andestech.com
Cc: heinrich.schucha...@canonical.com
---

Changes since v1

- New patch
---
 doc/board/starfive/index.rst |   1 +
 doc/board/starfive/pine64_star64.rst | 109 +++
 2 files changed, 110 insertions(+)
 create mode 100644 doc/board/starfive/pine64_star64.rst

diff --git a/doc/board/starfive/index.rst b/doc/board/starfive/index.rst
index 2762bf74c1..f05f8a0765 100644
--- a/doc/board/starfive/index.rst
+++ b/doc/board/starfive/index.rst
@@ -7,4 +7,5 @@ StarFive
:maxdepth: 1
 
milk-v_mars.rst
+   pine64_star64
visionfive2
diff --git a/doc/board/starfive/pine64_star64.rst 
b/doc/board/starfive/pine64_star64.rst
new file mode 100644
index 00..047f109028
--- /dev/null
+++ b/doc/board/starfive/pine64_star64.rst
@@ -0,0 +1,109 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Pine64 Star64
+===
+
+U-Boot for the Star64 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=
+
+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=0x4000 FW_OPTIONS=0
+
+Now build the U-Boot SPL and U-Boot proper.
+
+.. code-block:: console
+
+   cd 
+   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
+~
+
+U-Boot will set variable $fdtfile to starfive/jh7110-pine64-star64.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.44.0


[PATCH] board: starfive: support Pine64 Star64 board

2024-05-08 Thread H Bell
On Tuesday, May 7th, 2024 at 12:31 AM, E Shattow  wrote:
> On Mon, May 6, 2024 at 8:30 AM H Bell  wrote:
> > + static const char compat[] = "starfive,star64\0starfive,jh7110";
> Should be "pine64,star64\nstarfive,jh7110" ?
changed to "pine64,star64\0starfive,jh7110" in v2

On Tuesday, May 7th, 2024 at 12:31 AM, E Shattow  wrote:
> New property names are not made clear to me how to choose these
> different delays for 10/100 Mbps vs 1000 Mbps operation. If the
> fishwaldo repo is a valid reference then it seems different than the
> content in starfive_vf2_pro starfive_verb[]. No Star64 here to test
> with, does this work as-is for both network interfaces?
Agreed. I've created a separate object in v2 for some further investigations
with the delays/timings to make sure they're both working

On Tuesday, May 7th, 2024 at 12:31 AM, E Shattow  wrote:
> On Mon, May 6, 2024 at 8:30 AM H Bell  wrote:
> > +#define FDTFILE_PINE64_STAR64 \
> > + "starfive/pine64-star64.dtb"
> Should be "starfive/jh7110-pine64-star64.dtb" ?
fixed in v2




[PATCH 1/2 v3] board: starfive: support Pine64 Star64 board

2024-05-19 Thread H Bell
Similar to the Milk-V Mars, The Star64 board contains few differences to the
VisionFive 2 boards, so can be part of the same U-boot build.

Signed-off-by: Henry Bell 
Cc: ycli...@andestech.com
Cc: heinrich.schucha...@canonical.com
---

Changes since v1

- Fix typos on naming
- Create pine64_star64 struct to be populated with PHY values once confirmed

Changes since v2

- Set delays to 0
- Add missing 10/100/1000 clocks across the two devices
- Set all uA values to 2910
---
 board/starfive/visionfive2/spl.c  | 91 +++
 .../visionfive2/starfive_visionfive2.c|  4 +
 2 files changed, 95 insertions(+)

diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
index ca61b5be22..ad30c06f99 100644
--- a/board/starfive/visionfive2/spl.c
+++ b/board/starfive/visionfive2/spl.c
@@ -86,6 +86,45 @@ static const struct starfive_vf2_pro starfive_verb[] = {
"tx-internal-delay-ps", "0"},
 };
 
+static const struct starfive_vf2_pro star64_pine64[] = {
+   {"/soc/ethernet@1603", "starfive,tx-use-rgmii-clk", NULL},
+   {"/soc/ethernet@1604", "starfive,tx-use-rgmii-clk", NULL},
+
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-adj-enabled", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-10-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-100-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-1000-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,rx-clk-drv-microamp", "2910"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,rx-data-drv-microamp", "2910"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "rx-internal-delay-ps", "0"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "tx-internal-delay-ps", "0"},
+
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-adj-enabled", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-10-inverted", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-100-inverted", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-1000-inverted", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,rx-clk-drv-microamp", "2910"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,rx-data-drv-microamp", "2910"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "rx-internal-delay-ps", "0"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "tx-internal-delay-ps", "0"},
+};
+
 void spl_fdt_fixup_mars(void *fdt)
 {
static const char compat[] = "milkv,mars\0starfive,jh7110";
@@ -226,6 +265,56 @@ void spl_fdt_fixup_version_b(void *fdt)
}
 }
 
+void spl_fdt_fixup_star64(void *fdt)
+{
+   static const char compat[] = "pine64,star64\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",
+  "Pine64 Star64");
+
+   /* gmac0 */
+   offset = fdt_path_offset(fdt, "/soc/clock-controller@1700");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1603");
+
+   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@1302");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1604");
+
+   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(star64_pine64); i++) {
+   offset = fdt_path_offset(fdt, star64_pine64[i].path);
+
+   if (star64_pine64[i].value)
+   ret = fdt_setprop_u32(fdt, offset,  
star64_pine64[i].name,
+ dectoul(star64_pine64[i].value, 
NULL));
+   else
+   

[PATCH 2/2 v3] board: starfive: support Pine64 Star64 board

2024-05-19 Thread H Bell
Add documentation files

Signed-off-by: Henry Bell 
Cc: ycli...@andestech.com
Cc: heinrich.schucha...@canonical.com
---

Changes since v1

- New patch

Changes since v2

- Remove extra params to
- Clarification on boot section
- Add entry on MAC adresses and how to correct them
---
 doc/board/starfive/index.rst |   1 +
 doc/board/starfive/pine64_star64.rst | 136 +++
 2 files changed, 137 insertions(+)
 create mode 100644 doc/board/starfive/pine64_star64.rst

diff --git a/doc/board/starfive/index.rst b/doc/board/starfive/index.rst
index 2762bf74c1..f05f8a0765 100644
--- a/doc/board/starfive/index.rst
+++ b/doc/board/starfive/index.rst
@@ -7,4 +7,5 @@ StarFive
:maxdepth: 1
 
milk-v_mars.rst
+   pine64_star64
visionfive2
diff --git a/doc/board/starfive/pine64_star64.rst 
b/doc/board/starfive/pine64_star64.rst
new file mode 100644
index 00..567d1207ba
--- /dev/null
+++ b/doc/board/starfive/pine64_star64.rst
@@ -0,0 +1,136 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Pine64 Star64
+===
+
+U-Boot for the Star64 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=
+
+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=0x4000
+
+Now build the U-Boot SPL and U-Boot proper.
+
+.. code-block:: console
+
+   cd 
+   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
+~
+
+U-Boot will set variable $fdtfile to starfive/jh7110-pine64-star64.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 (marked S1804) adjacent to the 40pin GPIO
+Bus for boot selection. The ``L`` (0) and ``H`` (1) silk screening to the side
+of the should be used to determine state (not the ``ON/ONKE`` markings
+physically on the component). ``GPIO_0`` is channel 2 on the switch, while
+``GPIO_1`` is channel 1.
+
++ (QSPI) Flash: 00 ``??``
++ SD: 01 ``??``
++ EMMC: 10 ``??``
++ UART: 11 ``??``
+
+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.
+
+MAC address issues
+~~
+
+The Star64 does not currently ship with unique serial numbers per-device.
+Devices tested (all 4GiB RAM) have the same serial number of
+``STAR64V1-2310-D004E000-0005`` and the mac addresses of
+``6c:cf:39:00:75:61`` (lower) and ``6c:cf:39:00:75:62`` (upper) port will be
+assigned. Shipped

[PATCH 1/2 v4] board: starfive: support Pine64 Star64 board

2024-05-19 Thread H Bell
Similar to the Milk-V Mars, The Star64 board contains few differences to the
VisionFive 2 boards, so can be part of the same U-boot build.

Signed-off-by: Henry Bell 
Cc: ycli...@andestech.com
Cc: heinrich.schucha...@canonical.com
---

Changes since v1

- Fix typos on naming
- Create pine64_star64 struct to be populated with PHY values once confirmed

Changes since v2

- Set delays to 0
- Add missing 10/100/1000 clocks across the two devices
- Set all uA values to 2910

Changes since v3

- Rebase against d678a59d2d
---
 board/starfive/visionfive2/spl.c  | 91 +++
 .../visionfive2/starfive_visionfive2.c|  4 +
 2 files changed, 95 insertions(+)

diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
index b555189556..becc178c38 100644
--- a/board/starfive/visionfive2/spl.c
+++ b/board/starfive/visionfive2/spl.c
@@ -86,6 +86,45 @@ static const struct starfive_vf2_pro starfive_verb[] = {
"tx-internal-delay-ps", "0"},
 };
 
+static const struct starfive_vf2_pro star64_pine64[] = {
+   {"/soc/ethernet@1603", "starfive,tx-use-rgmii-clk", NULL},
+   {"/soc/ethernet@1604", "starfive,tx-use-rgmii-clk", NULL},
+
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-adj-enabled", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-10-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-100-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-1000-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,rx-clk-drv-microamp", "2910"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,rx-data-drv-microamp", "2910"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "rx-internal-delay-ps", "0"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "tx-internal-delay-ps", "0"},
+
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-adj-enabled", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-10-inverted", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-100-inverted", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-1000-inverted", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,rx-clk-drv-microamp", "2910"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,rx-data-drv-microamp", "2910"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "rx-internal-delay-ps", "0"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "tx-internal-delay-ps", "0"},
+};
+
 void spl_fdt_fixup_mars(void *fdt)
 {
static const char compat[] = "milkv,mars\0starfive,jh7110";
@@ -250,6 +289,56 @@ void spl_fdt_fixup_version_b(void *fdt)
}
 }
 
+void spl_fdt_fixup_star64(void *fdt)
+{
+   static const char compat[] = "pine64,star64\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",
+  "Pine64 Star64");
+
+   /* gmac0 */
+   offset = fdt_path_offset(fdt, "/soc/clock-controller@1700");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1603");
+
+   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@1302");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1604");
+
+   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(star64_pine64); i++) {
+   offset = fdt_path_offset(fdt, star64_pine64[i].path);
+
+   if (star64_pine64[i].value)
+   ret = fdt_setprop_u32(fdt, offset,  
star64_pine64[i].name,
+ dectoul(star64_pine64[i].value, 
NU

[PATCH 2/2 v4] board: starfive: support Pine64 Star64 board

2024-05-19 Thread H Bell
Add documentation files

Signed-off-by: Henry Bell 
Cc: ycli...@andestech.com
Cc: heinrich.schucha...@canonical.com
---

Changes since v1

- New patch

Changes since v2

- Remove extra params to
- Clarification on boot section
- Add entry on MAC adresses and how to correct them

Changes since v3

- Rebase against d678a59d2d
---
 doc/board/starfive/index.rst |   1 +
 doc/board/starfive/pine64_star64.rst | 136 +++
 2 files changed, 137 insertions(+)
 create mode 100644 doc/board/starfive/pine64_star64.rst

diff --git a/doc/board/starfive/index.rst b/doc/board/starfive/index.rst
index d369b986cc..72ab6ddfbf 100644
--- a/doc/board/starfive/index.rst
+++ b/doc/board/starfive/index.rst
@@ -8,4 +8,5 @@ StarFive
 
milk-v_mars
milk-v_mars_cm
+   pine64_star64
visionfive2
diff --git a/doc/board/starfive/pine64_star64.rst 
b/doc/board/starfive/pine64_star64.rst
new file mode 100644
index 00..567d1207ba
--- /dev/null
+++ b/doc/board/starfive/pine64_star64.rst
@@ -0,0 +1,136 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Pine64 Star64
+===
+
+U-Boot for the Star64 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=
+
+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=0x4000
+
+Now build the U-Boot SPL and U-Boot proper.
+
+.. code-block:: console
+
+   cd 
+   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
+~
+
+U-Boot will set variable $fdtfile to starfive/jh7110-pine64-star64.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 (marked S1804) adjacent to the 40pin GPIO
+Bus for boot selection. The ``L`` (0) and ``H`` (1) silk screening to the side
+of the should be used to determine state (not the ``ON/ONKE`` markings
+physically on the component). ``GPIO_0`` is channel 2 on the switch, while
+``GPIO_1`` is channel 1.
+
++ (QSPI) Flash: 00 ``??``
++ SD: 01 ``??``
++ EMMC: 10 ``??``
++ UART: 11 ``??``
+
+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.
+
+MAC address issues
+~~
+
+The Star64 does not currently ship with unique serial numbers per-device.
+Devices tested (all 4GiB RAM) have the same serial number of
+``STAR64V1-2310-D004E000-0005`` and the mac addresses of
+``6c:cf:39:00:75:61`` (lower) and ``6c:cf:39:00:75

[PATCH 1/2 v5] board: starfive: support Pine64 Star64 board

2024-05-22 Thread H Bell
Similar to the Milk-V Mars, The Star64 board contains few differences to the
VisionFive 2 boards, so can be part of the same U-boot build.

Signed-off-by: Henry Bell 
Cc: ycli...@andestech.com
Cc: heinrich.schucha...@canonical.com
---

Changes since v1

- Fix typos on naming
- Create pine64_star64 struct to be populated with PHY values once confirmed

Changes since v2

- Set delays to 0
- Add missing 10/100/1000 clocks across the two devices
- Set all uA values to 2910

Changes since v3

- Rebase against d678a59d2d

Changes since v4

- Fix up delay values
---
 board/starfive/visionfive2/spl.c  | 89 +++
 .../visionfive2/starfive_visionfive2.c|  4 +
 2 files changed, 93 insertions(+)

diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
index b555189556..b794b73b6b 100644
--- a/board/starfive/visionfive2/spl.c
+++ b/board/starfive/visionfive2/spl.c
@@ -86,6 +86,43 @@ static const struct starfive_vf2_pro starfive_verb[] = {
"tx-internal-delay-ps", "0"},
 };
 
+static const struct starfive_vf2_pro star64_pine64[] = {
+   {"/soc/ethernet@1603", "starfive,tx-use-rgmii-clk", NULL},
+   {"/soc/ethernet@1604", "starfive,tx-use-rgmii-clk", NULL},
+
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-adj-enabled", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-10-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-100-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,tx-clk-1000-inverted", NULL},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,rx-clk-drv-microamp", "2910"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "motorcomm,rx-data-drv-microamp", "2910"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "rx-internal-delay-ps", "1900"},
+   {"/soc/ethernet@1603/mdio/ethernet-phy@0",
+   "tx-internal-delay-ps", "1500"},
+
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-adj-enabled", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-10-inverted", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,tx-clk-100-inverted", NULL},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,rx-clk-drv-microamp", "2910"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "motorcomm,rx-data-drv-microamp", "2910"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "rx-internal-delay-ps", "0"},
+   {"/soc/ethernet@1604/mdio/ethernet-phy@1",
+   "tx-internal-delay-ps", "300"},
+};
+
 void spl_fdt_fixup_mars(void *fdt)
 {
static const char compat[] = "milkv,mars\0starfive,jh7110";
@@ -250,6 +287,56 @@ void spl_fdt_fixup_version_b(void *fdt)
}
 }
 
+void spl_fdt_fixup_star64(void *fdt)
+{
+   static const char compat[] = "pine64,star64\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",
+  "Pine64 Star64");
+
+   /* gmac0 */
+   offset = fdt_path_offset(fdt, "/soc/clock-controller@1700");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1603");
+
+   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@1302");
+   phandle = fdt_get_phandle(fdt, offset);
+   offset = fdt_path_offset(fdt, "/soc/ethernet@1604");
+
+   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(star64_pine64); i++) {
+   offset = fdt_path_offset(fdt, star64_pine64[i].path);
+
+   if (star64_pine64[i].value)
+   ret = fdt_setprop_u32(fdt, offset,  
star64_pine64[i].name,
+ dectoul(star64_pine64[i].value, 
NULL));
+   else
+   ret = fdt_se

[PATCH 2/2 v5] board: starfive: support Pine64 Star64 board

2024-05-22 Thread H Bell
Add documentation files

Signed-off-by: Henry Bell 
Cc: ycli...@andestech.com
Cc: heinrich.schucha...@canonical.com
---

Changes since v1

- New patch

Changes since v2

- Remove extra params to
- Clarification on boot section
- Add entry on MAC adresses and how to correct them

Changes since v3

- Rebase against d678a59d2d

Changes since v4

- Rework and expand docs on boot selection switches and overriding
  MAC addresses
- Fix warnings and underline width
---
 doc/board/starfive/index.rst |   1 +
 doc/board/starfive/pine64_star64.rst | 201 +++
 2 files changed, 202 insertions(+)
 create mode 100644 doc/board/starfive/pine64_star64.rst

diff --git a/doc/board/starfive/index.rst b/doc/board/starfive/index.rst
index d369b986cc..72ab6ddfbf 100644
--- a/doc/board/starfive/index.rst
+++ b/doc/board/starfive/index.rst
@@ -8,4 +8,5 @@ StarFive
 
milk-v_mars
milk-v_mars_cm
+   pine64_star64
visionfive2
diff --git a/doc/board/starfive/pine64_star64.rst 
b/doc/board/starfive/pine64_star64.rst
new file mode 100644
index 00..52e9a90791
--- /dev/null
+++ b/doc/board/starfive/pine64_star64.rst
@@ -0,0 +1,201 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Pine64 Star64
+=
+
+U-Boot for the Star64 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=
+
+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=0x4000
+
+Now build the U-Boot SPL and U-Boot proper.
+
+.. code-block:: console
+
+   cd 
+   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
+~
+
+U-Boot will set variable $fdtfile to starfive/jh7110-pine64-star64.dtb.
+
+To overrule this selection the variable can be set manually and saved in the
+environment
+
+::
+
+env set 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
+~
+
+Boot mode is selected by an MSEL-DIP marked S1804 and GPIO_0 position adjacent
+to the 40pin GPIO header. ON/ONKE and number markings of the MSEL-DIP are
+misleading; Instead refer to the ``L`` (0) and ``H`` (1) silkscreen for
+accurate selection.
+
++ (QSPI) Flash: 00
++ SD: 01
++ EMMC: 10
++ UART: 11
+
+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.
+
+Serial Number and MAC address issues
+
+
+U-Boot requires valid EEPROM data to determine which board-specific fix-up to
+apply at runtime. This affects the size of memory initialized, network mac
+address numbering, and tuning 

Re: [PATCH 1/2 v5] board: starfive: support Pine64 Star64 board

2024-05-23 Thread H Bell
On Wednesday, May 22nd, 2024 at 9:40 PM, E Shattow  wrote:

> On Wed, May 22, 2024 at 12:13?PM H Bell dmoo...@protonmail.com wrote:
> 
> > + {"/soc/ethernet@1604/mdio/ethernet-phy@1",
> > + "tx-internal-delay-ps", "300"},
> 
> 
> Note this 300uS value for tx-internal-delay-ps differs from
> pre-loaded firmware on Star64:
> ethernet-phy@1 tx_delay_sel = <0x00>;
> 
> 
> I would prefer to this (even if it is wrong) same as the pre-loaded
> firmware has done. Tuning patches can be applied in some
> future series. Is there a noticeable difference in function to change
> this value from how the pre-loaded firmware does this?

I agree that it should stick to the pre-loaded firmware wherever possible
but I found that using the 0 value on the tx_delay_sel meant that the device
would not properly send packets over the network (and would not get granted
an IP over DHCP), and found (going in steps of 150) that 300 worked.