From 786af90de8ceba3cee1818376b9d53421c5be598 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Tue, 12 Mar 2024 22:15:58 +0100 Subject: ARM: imx: stm32: Test whether ethernet node is enabled before reading MAC EEPROM on DHSOM Check whether the ethernet interface is enabled at all before reading MAC EEPROM. As a cost saving measure, it can happen that the MAC EEPROM is not populated on SoMs which do not use ethernet. Signed-off-by: Marek Vasut Reviewed-by: Patrice Chotard --- board/dhelectronics/common/dh_common.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'board/dhelectronics/common/dh_common.c') diff --git a/board/dhelectronics/common/dh_common.c b/board/dhelectronics/common/dh_common.c index 67e3d59b1f3..34094a020b0 100644 --- a/board/dhelectronics/common/dh_common.c +++ b/board/dhelectronics/common/dh_common.c @@ -18,6 +18,19 @@ bool dh_mac_is_in_env(const char *env) return eth_env_get_enetaddr(env, enetaddr); } +int dh_get_mac_is_enabled(const char *alias) +{ + ofnode node = ofnode_path(alias); + + if (!ofnode_valid(node)) + return -EINVAL; + + if (!ofnode_is_enabled(node)) + return -ENODEV; + + return 0; +} + int dh_get_mac_from_eeprom(unsigned char *enetaddr, const char *alias) { struct udevice *dev; @@ -57,6 +70,9 @@ __weak int dh_setup_mac_address(void) if (dh_mac_is_in_env("ethaddr")) return 0; + if (dh_get_mac_is_enabled("ethernet0")) + return 0; + if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0")) return eth_env_set_enetaddr("ethaddr", enetaddr); -- cgit v1.2.3