@@ -6,6 +6,4 @@ obj-$(CONFIG_SDM845) += sysmap-sdm845.o
obj-$(CONFIG_SDM845) += init_sdm845.o
obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o
obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
-obj-y += misc.o
-obj-y += dram.o
obj-$(CONFIG_TARGET_QCS404EVB) += sysmap-qcs404.o
deleted file mode 100644
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Snapdragon DRAM
- * Copyright (C) 2018 Ramon Fried <ramon.fried@gmail.com>
- */
-
-#ifndef DRAM_H
-#define DRAM_H
-
-int msm_fixup_memory(void *blob);
-
-#endif
deleted file mode 100644
@@ -1,55 +0,0 @@
-// 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>
-#include <asm/unaligned.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;
-
- if (mmc_init(mmc_dev))
- return 0;
-
- return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
-}
-
-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]);
-}
@@ -2,4 +2,5 @@
#
# (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
-obj-y := dragonboard410c.o
+obj-y += dragonboard410c.o
+obj-y += misc.o
@@ -17,10 +17,10 @@
#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>
+#include "misc.h"
+
DECLARE_GLOBAL_DATA_PTR;
int dram_init(void)
similarity index 64%
rename from arch/arm/mach-snapdragon/dram.c
rename to board/qualcomm/dragonboard410c/misc.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Onboard memory detection for Snapdragon boards
+ * Miscellaneous Snapdragon functionality
*
* (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
*
@@ -9,10 +9,56 @@
#include <common.h>
#include <dm.h>
#include <log.h>
+#include <mmc.h>
#include <part.h>
#include <smem.h>
#include <fdt_support.h>
-#include <asm/arch/dram.h>
+#include <asm/unaligned.h>
+
+#include "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;
+
+ if (mmc_init(mmc_dev))
+ return 0;
+
+ return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
+}
+
+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]);
+}
#define SMEM_USABLE_RAM_PARTITION_TABLE 402
#define RAM_PART_NAME_LENGTH 16
@@ -97,3 +143,4 @@ int msm_fixup_memory(void *blob)
return 0;
}
+
similarity index 87%
rename from arch/arm/mach-snapdragon/include/mach/misc.h
rename to board/qualcomm/dragonboard410c/misc.h
@@ -9,5 +9,6 @@
u32 msm_board_serial(void);
void msm_generate_mac_addr(u8 *mac);
+int msm_fixup_memory(void *blob);
#endif
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. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org> --- arch/arm/mach-snapdragon/Makefile | 2 - arch/arm/mach-snapdragon/include/mach/dram.h | 12 ----- arch/arm/mach-snapdragon/misc.c | 55 ---------------------- board/qualcomm/dragonboard410c/Makefile | 3 +- board/qualcomm/dragonboard410c/dragonboard410c.c | 4 +- .../qualcomm/dragonboard410c/misc.c | 51 +++++++++++++++++++- .../mach => board/qualcomm/dragonboard410c}/misc.h | 1 + 7 files changed, 54 insertions(+), 74 deletions(-)