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 <eeprom.h>
9 #include <env.h>
10 #include <i2c_eeprom.h>
11 #include <init.h>
12 #include <net.h>
13 #include <netdev.h>
14 #include <asm/arch-rockchip/bootrom.h>
15 #include <asm/io.h>
16 
get_ethaddr_from_eeprom(u8 * addr)17 static int get_ethaddr_from_eeprom(u8 *addr)
18 {
19 	int ret;
20 	struct udevice *dev;
21 
22 	ret = uclass_first_device_err(UCLASS_I2C_EEPROM, &dev);
23 	if (ret)
24 		return ret;
25 
26 	return i2c_eeprom_read(dev, 0, addr, 6);
27 }
28 
rk3288_board_late_init(void)29 int rk3288_board_late_init(void)
30 {
31 	u8 ethaddr[6];
32 
33 	if (get_ethaddr_from_eeprom(ethaddr))
34 		return 0;
35 
36 	if (is_valid_ethaddr(ethaddr))
37 		eth_env_set_enetaddr("ethaddr", ethaddr);
38 
39 	return 0;
40 }
41 
mmc_get_env_dev(void)42 int mmc_get_env_dev(void)
43 {
44 	u32 bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
45 
46 	if (bootdevice_brom_id == BROM_BOOTSOURCE_EMMC)
47 		return 0;
48 
49 	return 1;
50 }
51