Skip to contentSkip to conversation

board: amlogic: vim3: read ethernet MAC address from efuse

PATCH New Marek Szyprowski 3 participants 3 messages Dec 17, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20201217072655eucas1p123aa0a548e4de21a8ac580dbc990c760@eucas1p1.samsung.com

#1 lore raw

PATCH 1/1 board: amlogic: vim3: read ethernet MAC address from efuse

Add the board specific code for reading built-in ethernet MAC address from efuse.

---
 board/amlogic/vim3/vim3.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
board/amlogic/vim3/vim3.c +19 -0
index 09ef39ff30..a36df61583 100644
@@ -11,6 +11,7 @@
 #include <net.h>
 #include <asm/io.h>
 #include <asm/arch/eth.h>
+#include <asm/arch/sm.h>
 #include <i2c.h>
 #include "khadas-mcu.h"
 
@@ -129,9 +130,27 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd)
 	return 0;
 }
 
+#define EFUSE_MAC_OFFSET	0
+#define EFUSE_MAC_SIZE		6
+
 int misc_init_r(void)
 {
+	uint8_t mac_addr[EFUSE_MAC_SIZE];
+	ssize_t len;
+
 	meson_eth_init(PHY_INTERFACE_MODE_RGMII, 0);
 
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
+		len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
+					  mac_addr, EFUSE_MAC_SIZE);
+		if (len != EFUSE_MAC_SIZE)
+			return 0;
+
+		if (is_valid_ethaddr(mac_addr))
+			eth_env_set_enetaddr("ethaddr", mac_addr);
+		else
+			meson_generate_serial_ethaddr();
+	}
+
 	return 0;
 }
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/1 board: amlogic: vim3: read ethernet MAC address from efuse

Quoted 39 lines · Marek Szyprowski

Add the board specific code for reading built-in ethernet MAC address from efuse.

---
 board/amlogic/vim3/vim3.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
board/amlogic/vim3/vim3.c +11 -0
index 09ef39ff30..a36df61583 100644
@@ -11,6 +11,7 @@
 #include <net.h>
 #include <asm/io.h>
 #include <asm/arch/eth.h>
+#include <asm/arch/sm.h>
 #include <i2c.h>
 #include "khadas-mcu.h"
 
@@ -129,9 +130,27 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd)
 	return 0;
 }
 
+#define EFUSE_MAC_OFFSET	0
+#define EFUSE_MAC_SIZE		6
+
 int misc_init_r(void)
 {
+	uint8_t mac_addr[EFUSE_MAC_SIZE];
+	ssize_t len;
+
 	meson_eth_init(PHY_INTERFACE_MODE_RGMII, 0);
 
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
+		len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
+					  mac_addr, EFUSE_MAC_SIZE);
+		if (len != EFUSE_MAC_SIZE)

board/amlogic/vim3/vim3.c int meson_ft_board_setup(void *blob, struct bd_info *bd) · line 156

Quoted 10 lines
board/amlogic/vim3/vim3.c +8 -0
+			return 0;
+
+		if (is_valid_ethaddr(mac_addr))
+			eth_env_set_enetaddr("ethaddr", mac_addr);
+		else
+			meson_generate_serial_ethaddr();
+	}
+
 	return 0;
 }

Thx, I wasn't aware Khadas flashed the MAC address in the fuse

I'll do a quick test on my boards.

Neil

#3 lore raw

PATCH 1/1 board: amlogic: vim3: read ethernet MAC address from efuse

Quoted 53 lines · Neil Armstrong
Quoted 39 lines · Marek Szyprowski

Add the board specific code for reading built-in ethernet MAC address from efuse.

---
 board/amlogic/vim3/vim3.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
board/amlogic/vim3/vim3.c +11 -0
index 09ef39ff30..a36df61583 100644
@@ -11,6 +11,7 @@
 #include <net.h>
 #include <asm/io.h>
 #include <asm/arch/eth.h>
+#include <asm/arch/sm.h>
 #include <i2c.h>
 #include "khadas-mcu.h"
 
@@ -129,9 +130,27 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd)
 	return 0;
 }
 
+#define EFUSE_MAC_OFFSET	0
+#define EFUSE_MAC_SIZE		6
+
 int misc_init_r(void)
 {
+	uint8_t mac_addr[EFUSE_MAC_SIZE];
+	ssize_t len;
+
 	meson_eth_init(PHY_INTERFACE_MODE_RGMII, 0);
 
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
+		len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
+					  mac_addr, EFUSE_MAC_SIZE);
+		if (len != EFUSE_MAC_SIZE)

board/amlogic/vim3/vim3.c int meson_ft_board_setup(void *blob, struct bd_info *bd) · line 156

Quoted 10 lines
board/amlogic/vim3/vim3.c +8 -0
+			return 0;
+
+		if (is_valid_ethaddr(mac_addr))
+			eth_env_set_enetaddr("ethaddr", mac_addr);
+		else
+			meson_generate_serial_ethaddr();
+	}
+
 	return 0;
 }

Thx, I wasn't aware Khadas flashed the MAC address in the fuse

Quoted 3 lines

I'll do a quick test on my boards.

Best Regards,
Jaehoon Chung

Quoted 3 lines

Neil