* [PATCH 1/2] ti: Do not try to read the mac address if no NET is enabled
@ 2025-09-01 16:06 Maarten Brock
2025-09-01 18:24 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Maarten Brock @ 2025-09-01 16:06 UTC (permalink / raw)
To: u-boot@lists.denx.de
Cc: Ilias Apalodimas, Jerome Forissier, Kory Maincent, Simon Glass,
Tom Rini, Maarten Brock
It is pointless to fetch the mac address if it will never be used.
Signed-off-by: Maarten Brock <maarten.brock@sttls.nl>
---
board/ti/am335x/board.c | 72 ++++++++++++++++++++---------------------
1 file changed, 36 insertions(+), 36 deletions(-)
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 4ada8b534c1..739b23b8554 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -801,10 +801,6 @@ int board_init(void)
int board_late_init(void)
{
struct udevice *dev;
-#if !defined(CONFIG_XPL_BUILD)
- uint8_t mac_addr[6];
- uint32_t mac_hi, mac_lo;
-#endif
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
char *name = NULL;
@@ -852,40 +848,44 @@ int board_late_init(void)
env_set("boot_fit", "1");
#endif
-#if !defined(CONFIG_XPL_BUILD)
- /* try reading mac address from efuse */
- mac_lo = readl(&cdev->macid0l);
- mac_hi = readl(&cdev->macid0h);
- mac_addr[0] = mac_hi & 0xFF;
- mac_addr[1] = (mac_hi & 0xFF00) >> 8;
- mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
- mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
- mac_addr[4] = mac_lo & 0xFF;
- mac_addr[5] = (mac_lo & 0xFF00) >> 8;
-
- if (!env_get("ethaddr")) {
- printf("<ethaddr> not set. Validating first E-fuse MAC\n");
-
- if (is_valid_ethaddr(mac_addr))
- eth_env_set_enetaddr("ethaddr", mac_addr);
- }
+ if ((CONFIG_IS_ENABLED(NET) || CONFIG_IS_ENABLED(NET_LWIP)) &&
+ !IS_ENABLED(CONFIG_XPL_BUILD)) {
+ uint8_t mac_addr[6];
+ uint32_t mac_hi, mac_lo;
+
+ /* try reading mac address from efuse */
+ mac_lo = readl(&cdev->macid0l);
+ mac_hi = readl(&cdev->macid0h);
+ mac_addr[0] = mac_hi & 0xFF;
+ mac_addr[1] = (mac_hi & 0xFF00) >> 8;
+ mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
+ mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
+ mac_addr[4] = mac_lo & 0xFF;
+ mac_addr[5] = (mac_lo & 0xFF00) >> 8;
+
+ if (!env_get("ethaddr")) {
+ printf("<ethaddr> not set. Validating first E-fuse MAC\n");
+
+ if (is_valid_ethaddr(mac_addr))
+ eth_env_set_enetaddr("ethaddr", mac_addr);
+ }
- mac_lo = readl(&cdev->macid1l);
- mac_hi = readl(&cdev->macid1h);
- mac_addr[0] = mac_hi & 0xFF;
- mac_addr[1] = (mac_hi & 0xFF00) >> 8;
- mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
- mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
- mac_addr[4] = mac_lo & 0xFF;
- mac_addr[5] = (mac_lo & 0xFF00) >> 8;
-
- if (!env_get("eth1addr")) {
- if (is_valid_ethaddr(mac_addr))
- eth_env_set_enetaddr("eth1addr", mac_addr);
- }
+ mac_lo = readl(&cdev->macid1l);
+ mac_hi = readl(&cdev->macid1h);
+ mac_addr[0] = mac_hi & 0xFF;
+ mac_addr[1] = (mac_hi & 0xFF00) >> 8;
+ mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
+ mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
+ mac_addr[4] = mac_lo & 0xFF;
+ mac_addr[5] = (mac_lo & 0xFF00) >> 8;
+
+ if (!env_get("eth1addr")) {
+ if (is_valid_ethaddr(mac_addr))
+ eth_env_set_enetaddr("eth1addr", mac_addr);
+ }
- env_set("ice_mii", prueth_is_mii ? "mii" : "rmii");
-#endif
+ env_set("ice_mii", prueth_is_mii ? "mii" : "rmii");
+ }
if (!env_get("serial#")) {
char *board_serial = env_get("board_serial");
--
2.34.1
base-commit: e4c8b32d03d7ecffd586b7d33336603ad639d7c0
branch: am335x-no-net
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] ti: Do not try to read the mac address if no NET is enabled
2025-09-01 16:06 [PATCH 1/2] ti: Do not try to read the mac address if no NET is enabled Maarten Brock
@ 2025-09-01 18:24 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2025-09-01 18:24 UTC (permalink / raw)
To: Maarten Brock
Cc: u-boot@lists.denx.de, Ilias Apalodimas, Jerome Forissier,
Kory Maincent, Simon Glass
[-- Attachment #1: Type: text/plain, Size: 649 bytes --]
On Mon, Sep 01, 2025 at 04:06:04PM +0000, Maarten Brock wrote:
> It is pointless to fetch the mac address if it will never be used.
>
> Signed-off-by: Maarten Brock <maarten.brock@sttls.nl>
> ---
>
> board/ti/am335x/board.c | 72 ++++++++++++++++++++---------------------
> 1 file changed, 36 insertions(+), 36 deletions(-)
The problem with doing this is I believe that we pass this information
on to the linux kernel, which at least in the past has assumed it would
be provided correctly by us, even if U-Boot didn't use the networking.
These fuses will always be populated so it's not a problem to be reading
them.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-01 18:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 16:06 [PATCH 1/2] ti: Do not try to read the mac address if no NET is enabled Maarten Brock
2025-09-01 18:24 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).