]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
1c62d999 XZ |
2 | /* |
3 | * (C) Copyright 2016 Rockchip Electronics Co., Ltd | |
1c62d999 XZ |
4 | */ |
5 | ||
6 | #include <common.h> | |
ecc3bd73 | 7 | #include <dm.h> |
cb3ef681 | 8 | #include <eeprom.h> |
9fb625ce | 9 | #include <env.h> |
ecc3bd73 | 10 | #include <i2c_eeprom.h> |
5255932f | 11 | #include <init.h> |
90526e9f | 12 | #include <net.h> |
ecc3bd73 | 13 | #include <netdev.h> |
59b01eb7 MT |
14 | #include <asm/arch-rockchip/bootrom.h> |
15 | #include <asm/io.h> | |
ecc3bd73 JK |
16 | |
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 | ||
271318a6 | 29 | int rk3288_board_late_init(void) |
ecc3bd73 JK |
30 | { |
31 | u8 ethaddr[6]; | |
32 | ||
33 | if (get_ethaddr_from_eeprom(ethaddr)) | |
34 | return 0; | |
35 | ||
36 | if (is_valid_ethaddr(ethaddr)) | |
fd1e959e | 37 | eth_env_set_enetaddr("ethaddr", ethaddr); |
ecc3bd73 JK |
38 | |
39 | return 0; | |
40 | } | |
59b01eb7 MT |
41 | |
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 | } |