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");
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;
}