diff options
author | Rohan Garg <rohan.garg@collabora.com> | 2019-08-12 18:04:34 +0300 |
---|---|---|
committer | Kever Yang <kever.yang@rock-chips.com> | 2019-08-23 13:15:31 +0300 |
commit | 04825384999f81c08e820fe380e95b6325352a6d (patch) | |
tree | cb74d5404bffc277920dc2e4976a8261a7578648 /arch/arm/mach-rockchip/board.c | |
parent | cb8c492f2016d137c6ed887f4f3eff5df98b865c (diff) | |
download | u-boot-04825384999f81c08e820fe380e95b6325352a6d.tar.xz |
rockchip: rk3399: derive ethaddr from cpuid
Generate a MAC address based on the cpuid available in the efuse
block: Use the first 6 byte of the cpuid's SHA256 hash and set the
locally administered bits. Also ensure that the multicast bit is
cleared.
The MAC address is only generated and set if there is no ethaddr
present in the saved environment.
This is based off of Klaus Goger's work in 8adc9d
Signed-off-by: Rohan Garg <rohan.garg@collabora.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Diffstat (limited to 'arch/arm/mach-rockchip/board.c')
-rw-r--r-- | arch/arm/mach-rockchip/board.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index b2a88e789d..8ca3463731 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -11,6 +11,7 @@ #include <asm/arch-rockchip/boot_mode.h> #include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/periph.h> +#include <asm/arch-rockchip/misc.h> #include <power/regulator.h> DECLARE_GLOBAL_DATA_PTR; @@ -102,3 +103,25 @@ int fastboot_set_reboot_flag(void) return 0; } #endif + +#ifdef CONFIG_MISC_INIT_R +__weak int misc_init_r(void) +{ + const u32 cpuid_offset = 0x7; + const u32 cpuid_length = 0x10; + u8 cpuid[cpuid_length]; + int ret; + + ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid); + if (ret) + return ret; + + ret = rockchip_cpuid_set(cpuid, cpuid_length); + if (ret) + return ret; + + ret = rockchip_setup_macaddr(); + + return ret; +} +#endif |