blob: 7a0c3c997d9bddb483777e1c7762ac0ad7645877 [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>
10#include <netdev.h>
Michael Trimarchi0ae07f62019-11-15 22:07:24 +010011#include <asm/arch-rockchip/bootrom.h>
12#include <asm/io.h>
Jonas Karlman269a37f2017-04-22 08:57:54 +000013
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}
Michael Trimarchi0ae07f62019-11-15 22:07:24 +010038
39int mmc_get_env_dev(void)
40{
41 u32 bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
42
43 if (bootdevice_brom_id == BROM_BOOTSOURCE_EMMC)
44 return 0;
45
46 return 1;
47}