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