diff options
-rw-r--r-- | board/sunxi/board.c | 28 | ||||
-rw-r--r-- | include/configs/sunxi-common.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 8607eb3aa30..2179e234e21 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -19,9 +19,12 @@ #include <axp209.h> #endif #include <asm/arch/clock.h> +#include <asm/arch/cpu.h> #include <asm/arch/dram.h> #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> +#include <asm/io.h> +#include <net.h> DECLARE_GLOBAL_DATA_PTR; @@ -157,3 +160,28 @@ void sunxi_board_init(void) printf("Failed to set core voltage! Can't set CPU frequency\n"); } #endif + +#ifdef CONFIG_MISC_INIT_R +int misc_init_r(void) +{ + if (!getenv("ethaddr")) { + uint32_t reg_val = readl(SUNXI_SID_BASE); + + if (reg_val) { + uint8_t mac_addr[6]; + + mac_addr[0] = 0x02; /* Non OUI / registered MAC address */ + mac_addr[1] = (reg_val >> 0) & 0xff; + reg_val = readl(SUNXI_SID_BASE + 0x0c); + mac_addr[2] = (reg_val >> 24) & 0xff; + mac_addr[3] = (reg_val >> 16) & 0xff; + mac_addr[4] = (reg_val >> 8) & 0xff; + mac_addr[5] = (reg_val >> 0) & 0xff; + + eth_setenv_enetaddr("ethaddr", mac_addr); + } + } + + return 0; +} +#endif diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 40833885f71..13e72d5f02e 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -207,6 +207,8 @@ #define CONFIG_ENV_IS_NOWHERE #endif +#define CONFIG_MISC_INIT_R + #ifndef CONFIG_SPL_BUILD #include <config_distro_defaults.h> #endif |