blob: f85209c6498dc54f764897617da5b67c24182133 [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 Glasseba6b8d2019-11-14 12:57:50 -07008#include <eeprom.h>
Simon Glass5e6201b2019-08-01 09:46:51 -06009#include <env.h>
Jonas Karlman269a37f2017-04-22 08:57:54 +000010#include <i2c_eeprom.h>
Simon Glassa7b51302019-11-14 12:57:46 -070011#include <init.h>
Simon Glass274e0b02020-05-10 11:39:56 -060012#include <net.h>
Jonas Karlman269a37f2017-04-22 08:57:54 +000013#include <netdev.h>
Michael Trimarchi0ae07f62019-11-15 22:07:24 +010014#include <asm/arch-rockchip/bootrom.h>
15#include <asm/io.h>
Jonas Karlman269a37f2017-04-22 08:57:54 +000016
17static 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
Kever Yangb7da2712019-07-22 20:02:14 +080029int rk3288_board_late_init(void)
Jonas Karlman269a37f2017-04-22 08:57:54 +000030{
31 u8 ethaddr[6];
32
33 if (get_ethaddr_from_eeprom(ethaddr))
34 return 0;
35
36 if (is_valid_ethaddr(ethaddr))
Simon Glass8551d552017-08-03 12:22:11 -060037 eth_env_set_enetaddr("ethaddr", ethaddr);
Jonas Karlman269a37f2017-04-22 08:57:54 +000038
39 return 0;
40}
Michael Trimarchi0ae07f62019-11-15 22:07:24 +010041
42int 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}