blob: e6e75981c2d10803482d446830e3ab965de6d742 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Xu Ziyuan535b3dc2016-08-01 08:46:19 +08002/*
3 * (C) Copyright 2016 Rockchip Electronics Co., Ltd
Xu Ziyuan535b3dc2016-08-01 08:46:19 +08004 */
5
6#include <common.h>
Jonas Karlman269a37f2017-04-22 08:57:54 +00007#include <dm.h>
Simon Glass5e6201b2019-08-01 09:46:51 -06008#include <env.h>
Jonas Karlman269a37f2017-04-22 08:57:54 +00009#include <i2c_eeprom.h>
Simon Glassa7b51302019-11-14 12:57:46 -070010#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060011#include <net.h>
Jonas Karlman269a37f2017-04-22 08:57:54 +000012#include <netdev.h>
13
14static int get_ethaddr_from_eeprom(u8 *addr)
15{
16 int ret;
17 struct udevice *dev;
18
19 ret = uclass_first_device_err(UCLASS_I2C_EEPROM, &dev);
20 if (ret)
21 return ret;
22
23 return i2c_eeprom_read(dev, 0, addr, 6);
24}
25
Kever Yangb7da2712019-07-22 20:02:14 +080026int rk3288_board_late_init(void)
Jonas Karlman269a37f2017-04-22 08:57:54 +000027{
28 u8 ethaddr[6];
29
30 if (get_ethaddr_from_eeprom(ethaddr))
31 return 0;
32
33 if (is_valid_ethaddr(ethaddr))
Simon Glass8551d552017-08-03 12:22:11 -060034 eth_env_set_enetaddr("ethaddr", ethaddr);
Jonas Karlman269a37f2017-04-22 08:57:54 +000035
36 return 0;
37}