env: Move env_set() to env.h
[oweals/u-boot.git] / board / rockchip / tinker_rk3288 / tinker-rk3288.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2016 Rockchip Electronics Co., Ltd
4  */
5
6 #include <common.h>
7 #include <dm.h>
8 #include <env.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 rk3288_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 }