blob: 0f2abe2f539223ece0c219f12133851037bab830 [file] [log] [blame]
Xu Ziyuan535b3dc2016-08-01 08:46:19 +08001/*
2 * (C) Copyright 2016 Rockchip Electronics Co., Ltd
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
Jonas Karlman269a37f2017-04-22 08:57:54 +00008#include <dm.h>
Alex Kiernan9c215492018-04-01 09:22:38 +00009#include <environment.h>
Jonas Karlman269a37f2017-04-22 08:57:54 +000010#include <i2c_eeprom.h>
11#include <netdev.h>
12
13static 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
25int 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))
Simon Glass8551d552017-08-03 12:22:11 -060033 eth_env_set_enetaddr("ethaddr", ethaddr);
Jonas Karlman269a37f2017-04-22 08:57:54 +000034
35 return 0;
36}