diff options
author | Jonas Karlman <jonas@kwiboo.se> | 2017-04-22 11:57:54 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-05-10 22:37:22 +0300 |
commit | ecc3bd73b35398d8337096b19493028a29ed038e (patch) | |
tree | 439f3ba0ddc72f0a4aa1f9c5b77ea059d645f21e /board/rockchip/tinker_rk3288 | |
parent | 8880efbd1ffd54bcddb427229ff925151a054257 (diff) | |
download | u-boot-ecc3bd73b35398d8337096b19493028a29ed038e.tar.xz |
rockchip: tinker: set ethaddr in late init
Set ethernet mac address in late init for Tinker Board,
prevents getting a random mac address each boot.
Read mac address from eeprom, first 6 bytes from m24c08@50.
Same as /etc/init.d/rockchip.sh on Tinker OS.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'board/rockchip/tinker_rk3288')
-rw-r--r-- | board/rockchip/tinker_rk3288/tinker-rk3288.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c b/board/rockchip/tinker_rk3288/tinker-rk3288.c index 79541a3939..c2872e7330 100644 --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c @@ -5,3 +5,31 @@ */ #include <common.h> +#include <dm.h> +#include <i2c_eeprom.h> +#include <netdev.h> + +static int get_ethaddr_from_eeprom(u8 *addr) +{ + int ret; + struct udevice *dev; + + ret = uclass_first_device_err(UCLASS_I2C_EEPROM, &dev); + if (ret) + return ret; + + return i2c_eeprom_read(dev, 0, addr, 6); +} + +int rk_board_late_init(void) +{ + u8 ethaddr[6]; + + if (get_ethaddr_from_eeprom(ethaddr)) + return 0; + + if (is_valid_ethaddr(ethaddr)) + eth_setenv_enetaddr("ethaddr", ethaddr); + + return 0; +} |