Re: [PATCH v2 4/6] board: starfive: support Milk-V Mars board

Leo Liang
2024-03-28T05:24:47Z

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;
> + }
> + }
> +}
> +