Browse Source

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 <minda.chen@starfivetech.com>
Minda Chen 1 month ago
parent
commit
d3c1495750
1 changed files with 19 additions and 1 deletions
  1. 19 1
      board/starfive/visionfive2/starfive_visionfive2.c

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