aboutsummaryrefslogtreecommitdiff
path: root/board/dhelectronics
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2020-07-31 01:34:50 +0200
committerPatrice Chotard <patrice.chotard@st.com>2020-08-13 09:56:44 +0200
commit9ff770b497300c9c7ecf54165b0281cec4c8fca7 (patch)
tree54c9f4f1bfa0e154a7276ab4116dae2b96770bf6 /board/dhelectronics
parentb2a2911dadf028b5917e480312dc92f2e99e13d7 (diff)
downloadu-boot-9ff770b497300c9c7ecf54165b0281cec4c8fca7.zip
u-boot-9ff770b497300c9c7ecf54165b0281cec4c8fca7.tar.gz
u-boot-9ff770b497300c9c7ecf54165b0281cec4c8fca7.tar.bz2
ARM: dts: stm32: Update eth1addr from EEPROM if eth1 present
The STM32MP1 DHCOM has two ethernet interfaces, the on-SoM DWMAC and KS8851. Set eth1addr for the KS8851 to a MAC address of the DWMAC incremented by 1. The MAC of the DWMAC is set from on-SoM EEPROM already, but the MAC address of KS8851 was left uninitialized, so fix this. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Patrice Chotard <patrice.chotard@st.com> Cc: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Diffstat (limited to 'board/dhelectronics')
-rw-r--r--board/dhelectronics/dh_stm32mp1/board.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index eec51d2..c9abe3c 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -84,11 +84,26 @@ DECLARE_GLOBAL_DATA_PTR;
int setup_mac_address(void)
{
unsigned char enetaddr[6];
+ bool skip_eth0 = false;
+ bool skip_eth1 = false;
struct udevice *dev;
int off, ret;
ret = eth_env_get_enetaddr("ethaddr", enetaddr);
if (ret) /* ethaddr is already set */
+ skip_eth0 = true;
+
+ off = fdt_path_offset(gd->fdt_blob, "ethernet1");
+ if (off < 0) {
+ /* ethernet1 is not present in the system */
+ skip_eth1 = true;
+ } else {
+ ret = eth_env_get_enetaddr("eth1addr", enetaddr);
+ if (ret) /* eth1addr is already set */
+ skip_eth1 = true;
+ }
+
+ if (skip_eth0 && skip_eth1)
return 0;
off = fdt_path_offset(gd->fdt_blob, "eeprom0");
@@ -109,8 +124,14 @@ int setup_mac_address(void)
return ret;
}
- if (is_valid_ethaddr(enetaddr))
- eth_env_set_enetaddr("ethaddr", enetaddr);
+ if (is_valid_ethaddr(enetaddr)) {
+ if (!skip_eth0)
+ eth_env_set_enetaddr("ethaddr", enetaddr);
+
+ enetaddr[5]++;
+ if (!skip_eth1)
+ eth_env_set_enetaddr("eth1addr", enetaddr);
+ }
return 0;
}