1 /*
2  * (C) Copyright 2016 Rockchip Electronics Co., Ltd
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <dm.h>
9 #include <environment.h>
10 #include <i2c_eeprom.h>
11 #include <netdev.h>
12 
13 static int get_ethaddr_from_eeprom(u8 *addr)
14 {
15 	int ret;
16 	struct udevice *dev;
17 
18 	ret = uclass_first_device_err(UCLASS_I2C_EEPROM, &dev);
19 	if (ret)
20 		return ret;
21 
22 	return i2c_eeprom_read(dev, 0, addr, 6);
23 }
24 
25 int rk_board_late_init(void)
26 {
27 	u8 ethaddr[6];
28 
29 	if (get_ethaddr_from_eeprom(ethaddr))
30 		return 0;
31 
32 	if (is_valid_ethaddr(ethaddr))
33 		eth_env_set_enetaddr("ethaddr", ethaddr);
34 
35 	return 0;
36 }
37