1 // SPDX-License-Identifier: GPL-2.0+
3 * Miscellaneous Snapdragon functionality
5 * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
11 #include <asm/arch/misc.h>
13 /* UNSTUFF_BITS macro taken from Linux Kernel: drivers/mmc/core/sd.c */
14 #define UNSTUFF_BITS(resp, start, size) \
16 const int __size = size; \
17 const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1; \
18 const int __off = 3 - ((start) / 32); \
19 const int __shft = (start) & 31; \
22 __res = resp[__off] >> __shft; \
23 if (__size + __shft > 32) \
24 __res |= resp[__off - 1] << ((32 - __shft) % 32); \
28 u32 msm_board_serial(void)
32 mmc_dev = find_mmc_device(0);
36 return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
39 void msm_generate_mac_addr(u8 *mac)
44 snprintf(sn, 8, "%08x", msm_board_serial());
46 /* fill in the mac with serialno, use locally adminstrated pool */
49 for (i = 3; i >= 0; i--) {
50 mac[i + 2] = simple_strtoul(&sn[2 * i], NULL, 16);