diff options
author | Dongjin Kim <tobetter@gmail.com> | 2018-12-18 16:14:30 +0900 |
---|---|---|
committer | Dongjin Kim <tobetter@gmail.com> | 2018-12-18 16:16:10 +0900 |
commit | bcef1935c434662cd850815e4684ee7fbb30949b (patch) | |
tree | 4b9650d0ae6a66499bdd3a8f5c3b6707c1e40565 /net | |
parent | a3c32433a87a6496b13e462669fbd6597a176402 (diff) | |
download | u-boot-odroid-c1-bcef1935c434662cd850815e4684ee7fbb30949b.tar.gz |
ODROID-COMMON: net/eth: obtain hardware MAC address from eFuse
Change-Id: I9240cf517ded3eaed6224fcd775dc308238ad231
Signed-off-by: Dongjin Kim <tobetter@gmail.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/eth.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -186,6 +186,7 @@ static inline void eth_hw_addr_random(struct eth_device *dev) } #endif +#if !defined(CONFIG_ODROID_COMMON) static int eth_get_efuse_mac(struct eth_device *dev) { #ifndef CONFIG_UNIFY_KEY_MANAGE @@ -228,6 +229,35 @@ static int eth_get_efuse_mac(struct eth_device *dev) return key_unify_uninit(); #endif } +#else +#include <asm/arch/efuse.h> + +static int eth_get_efuse_mac(struct eth_device *dev) +{ + char buf[6 * 2]; // MAC address buffer + loff_t pos = 0x14; // offset of the first byte for MAC address + int ret; + + ret = efuse_read_usr(buf, sizeof(buf), &pos); + if (ret < 0) { + memset(buf, 0, sizeof(buf)); + return -EINVAL; + } + + int i; + char s[3]; + char *p = buf; + for (i = 0; i < 6; i++) { + s[0] = *p++; + s[1] = *p++; + s[2] = 0; + dev->enetaddr[i] = simple_strtoul(s, NULL, 16); + } + + return 0; +} +#endif + int eth_write_hwaddr(struct eth_device *dev, const char *base_name, int eth_number) { |