diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/u-boot/arch/arm/mach-snapdragon/misc.c | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/u-boot/arch/arm/mach-snapdragon/misc.c')
-rw-r--r-- | roms/u-boot/arch/arm/mach-snapdragon/misc.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/roms/u-boot/arch/arm/mach-snapdragon/misc.c b/roms/u-boot/arch/arm/mach-snapdragon/misc.c new file mode 100644 index 000000000..aaa561c2c --- /dev/null +++ b/roms/u-boot/arch/arm/mach-snapdragon/misc.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Miscellaneous Snapdragon functionality + * + * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com> + * + */ + +#include <common.h> +#include <mmc.h> +#include <asm/arch/misc.h> + +/* UNSTUFF_BITS macro taken from Linux Kernel: drivers/mmc/core/sd.c */ +#define UNSTUFF_BITS(resp, start, size) \ + ({ \ + const int __size = size; \ + const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1; \ + const int __off = 3 - ((start) / 32); \ + const int __shft = (start) & 31; \ + u32 __res; \ + \ + __res = resp[__off] >> __shft; \ + if (__size + __shft > 32) \ + __res |= resp[__off - 1] << ((32 - __shft) % 32); \ + __res & __mask; \ + }) + +u32 msm_board_serial(void) +{ + struct mmc *mmc_dev; + + mmc_dev = find_mmc_device(0); + if (!mmc_dev) + return 0; + + return UNSTUFF_BITS(mmc_dev->cid, 16, 32); +} + +void msm_generate_mac_addr(u8 *mac) +{ + int i; + char sn[9]; + + snprintf(sn, 9, "%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; + } +} |