From e0b04a15250a4aff28f1ab34812e9449098fa978 Mon Sep 17 00:00:00 2001 From: Ramon Fried Date: Fri, 3 Aug 2018 16:25:36 +0300 Subject: [PATCH] snapdragon: added MAC generation functions Add support for generation of unique MAC address that is derived from board serial. Algorithm for generation of MAC taken from LK. Signed-off-by: Ramon Fried --- arch/arm/mach-snapdragon/include/mach/misc.h | 1 + arch/arm/mach-snapdragon/misc.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/arm/mach-snapdragon/include/mach/misc.h b/arch/arm/mach-snapdragon/include/mach/misc.h index 5af6ae8da4..c60e3e4724 100644 --- a/arch/arm/mach-snapdragon/include/mach/misc.h +++ b/arch/arm/mach-snapdragon/include/mach/misc.h @@ -8,5 +8,6 @@ #define MISC_H u32 msm_board_serial(void); +void msm_generate_mac_addr(u8 *mac); #endif diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c index 678bd69f83..f6c87866c0 100644 --- a/arch/arm/mach-snapdragon/misc.c +++ b/arch/arm/mach-snapdragon/misc.c @@ -35,3 +35,19 @@ u32 msm_board_serial(void) return UNSTUFF_BITS(mmc_dev->cid, 16, 32); } + +void msm_generate_mac_addr(u8 *mac) +{ + int i; + char sn[9]; + + snprintf(sn, 8, "%08x", msm_board_serial()); + + /* fill in the mac with serialno, use locally adminstrated pool */ + mac[0] = 0x02; + mac[1] = 00; + for (i = 3; i >= 0; i--) { + mac[i + 2] = simple_strtoul(&sn[2 * i], NULL, 16); + sn[2 * i] = 0; + } +} -- 2.39.5