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