diff options
Diffstat (limited to 'board/dhelectronics/common')
-rw-r--r-- | board/dhelectronics/common/dh_common.c | 16 | ||||
-rw-r--r-- | board/dhelectronics/common/dh_common.h | 8 |
2 files changed, 24 insertions, 0 deletions
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); diff --git a/board/dhelectronics/common/dh_common.h b/board/dhelectronics/common/dh_common.h index 2b24637d96d..a2de5b1553e 100644 --- a/board/dhelectronics/common/dh_common.h +++ b/board/dhelectronics/common/dh_common.h @@ -12,6 +12,14 @@ bool dh_mac_is_in_env(const char *env); /* + * dh_get_mac_is_enabled - Test if ethernet MAC is enabled in DT + * + * @alias: alias for ethernet MAC device tree node + * Return: 0 if OK, other value on error + */ +int dh_get_mac_is_enabled(const char *alias); + +/* * dh_get_mac_from_eeprom - Get MAC address from eeprom and write it to enetaddr * * @enetaddr: buffer where address is to be stored |