aboutsummaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorCaleb Connolly2024-02-26 17:26:22 +0000
committerCaleb Connolly2024-03-01 14:44:37 +0000
commit14868845db54b4f64701977385dc9a6e951e4139 (patch)
treeffa31e40c58989f720fe175f1d3b8669dd065c02 /board
parentc744e6308951d47f597e5dac450cab5555698246 (diff)
board: dragonboard410c: import board code from mach-snapdragon
Some of the db410c board support code was written to be generic and placed in mach-snapdragon. However, as the db410c is the only board using this, move the code out of mach-snapdragon. This makes is more obvious what code is relevant for which targets and helps tidy things up a little more. Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Tested-by: Sumit Garg <sumit.garg@linaro.org> #qcs404 Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Diffstat (limited to 'board')
-rw-r--r--board/qualcomm/dragonboard410c/Makefile2
-rw-r--r--board/qualcomm/dragonboard410c/dragonboard410c.c48
2 files changed, 45 insertions, 5 deletions
diff --git a/board/qualcomm/dragonboard410c/Makefile b/board/qualcomm/dragonboard410c/Makefile
index 1b99c8b0efe..189f8381332 100644
--- a/board/qualcomm/dragonboard410c/Makefile
+++ b/board/qualcomm/dragonboard410c/Makefile
@@ -2,4 +2,4 @@
#
# (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
-obj-y := dragonboard410c.o
+obj-y := dragonboard410c.o
diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
index 1adac07569a..40b5448c6ef 100644
--- a/board/qualcomm/dragonboard410c/dragonboard410c.c
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
@@ -12,14 +12,13 @@
#include <dm/pinctrl.h>
#include <env.h>
#include <init.h>
+#include <mmc.h>
#include <net.h>
#include <usb.h>
#include <asm/cache.h>
#include <asm/global_data.h>
#include <asm/gpio.h>
#include <fdt_support.h>
-#include <asm/arch/dram.h>
-#include <asm/arch/misc.h>
#include <linux/delay.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -55,6 +54,49 @@ int board_usb_init(int index, enum usb_init_type init)
return 0;
}
+/* 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; \
+ })
+
+static u32 msm_board_serial(void)
+{
+ struct mmc *mmc_dev;
+
+ mmc_dev = find_mmc_device(0);
+ if (!mmc_dev)
+ return 0;
+
+ if (mmc_init(mmc_dev))
+ return 0;
+
+ return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
+}
+
+static void msm_generate_mac_addr(u8 *mac)
+{
+ /* use locally adminstrated pool */
+ mac[0] = 0x02;
+ mac[1] = 0x00;
+
+ /*
+ * Put the 32-bit serial number in the last 32-bit of the MAC address.
+ * Use big endian order so it is consistent with the serial number
+ * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
+ */
+ put_unaligned_be32(msm_board_serial(), &mac[2]);
+}
+
/* Check for vol- button - if pressed - stop autoboot */
int misc_init_r(void)
{
@@ -103,8 +145,6 @@ int ft_board_setup(void *blob, struct bd_info *bd)
{
u8 mac[ARP_HLEN];
- msm_fixup_memory(blob);
-
if (!eth_env_get_enetaddr("wlanaddr", mac)) {
msm_generate_mac_addr(mac);
};