From d3c149575077bc5fd6b238f1a3d67f3c64f5fbeb Mon Sep 17 00:00:00 2001 From: Minda Chen Date: Fri, 12 Apr 2024 18:21:14 +0800 Subject: [PATCH] amp: Set mac addr to share ram while one gmac is disable. In AMP case, one GMAC is moved to RTOS side. u-boot dts node is disabled, RTOS need to get the MAC address. So u-boot write the MAC address to share RAM. Signed-off-by: Minda Chen --- .../visionfive2/starfive_visionfive2.c | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c index a6656dcce1..6b3fe62f94 100644 --- a/board/starfive/visionfive2/starfive_visionfive2.c +++ b/board/starfive/visionfive2/starfive_visionfive2.c @@ -32,6 +32,8 @@ #define CPU_VOL_BINNING_OFFSET 0x7fc +DECLARE_GLOBAL_DATA_PTR; + enum { BOOT_FLASH = 0, BOOT_SD, @@ -422,7 +424,9 @@ int board_init(void) int board_late_init(void) { struct udevice *dev; - int ret; + int ret, offset; + u8 mac0[6], mac1[6]; + u64 share_ram_addr; get_boot_mode(); @@ -443,6 +447,20 @@ int board_late_init(void) if (ret) goto err; + /* AMP case : write MAC to share ram */ + offset = fdt_path_offset(gd->fdt_blob, + "/chosen/opensbi-domains/rpmsg_shmem"); + if (offset >= 0) { + share_ram_addr = + fdtdec_get_uint64(gd->fdt_blob, offset, "base", 0); + if (share_ram_addr) { + eth_env_get_enetaddr("eth0addr", mac0); + eth_env_get_enetaddr("eth1addr", mac1); + memcpy((void *)share_ram_addr, mac0, 6); + memcpy((void *)(share_ram_addr + 8), mac1, 6); + } + } + err: return 0; }