diff mbox series

[14/20] imx8ulp: Update ethernet mac to get from fuse

Message ID 20211029014634.20949-15-peng.fan@oss.nxp.com
State Accepted
Commit 484b306b9e53d39c87b54376fc4468ff5aa34297
Delegated to: Stefano Babic
Headers show
Series i.MX8ULP misc update | expand

Commit Message

Peng Fan (OSS) Oct. 29, 2021, 1:46 a.m. UTC
From: Ye Li <ye.li@nxp.com>

Get the MAC address from fuse bank5 word 3 and 4. It has
MSB first at lowest address, so have a reverse order with other
iMX used in mac.c

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/mach-imx/imx8ulp/soc.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Stefano Babic Feb. 5, 2022, 4:40 p.m. UTC | #1
> From: Ye Li <ye.li@nxp.com>
> Get the MAC address from fuse bank5 word 3 and 4. It has
> MSB first at lowest address, so have a reverse order with other
> iMX used in mac.c
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/imx8ulp/soc.c b/arch/arm/mach-imx/imx8ulp/soc.c
index e12e28d9e7..943ea7fb7e 100644
--- a/arch/arm/mach-imx/imx8ulp/soc.c
+++ b/arch/arm/mach-imx/imx8ulp/soc.c
@@ -588,7 +588,30 @@  __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 
 void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 {
+	u32 val[2] = {};
+	int ret;
+
+	ret = fuse_read(5, 3, &val[0]);
+	if (ret)
+		goto err;
+
+	ret = fuse_read(5, 4, &val[1]);
+	if (ret)
+		goto err;
+
+	mac[0] = val[0];
+	mac[1] = val[0] >> 8;
+	mac[2] = val[0] >> 16;
+	mac[3] = val[0] >> 24;
+	mac[4] = val[1];
+	mac[5] = val[1] >> 8;
+
+	debug("%s: MAC%d: %02x.%02x.%02x.%02x.%02x.%02x\n",
+	      __func__, dev_id, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+	return;
+err:
 	memset(mac, 0, 6);
+	printf("%s: fuse read err: %d\n", __func__, ret);
 }
 
 int (*card_emmc_is_boot_part_en)(void) = (void *)0x67cc;