[PATCH v3 07/10] mach-snapdragon: spl: Update SMEM with boot details
Varadarajan Narayanan
varadarajan.narayanan at oss.qualcomm.com
Thu Apr 16 07:39:25 CEST 2026
Update SMEM with the storage medium from which the system booted.
Signed-off-by: Varadarajan Narayanan <varadarajan.narayanan at oss.qualcomm.com>
---
v3: Move SMEM init from previous patch to this new patch
---
arch/arm/mach-snapdragon/spl.c | 65 ++++++++++++++++++++++++++++++++++
include/smem.h | 3 ++
2 files changed, 68 insertions(+)
diff --git a/arch/arm/mach-snapdragon/spl.c b/arch/arm/mach-snapdragon/spl.c
index 8cc28bbee82..82b390ba3d7 100644
--- a/arch/arm/mach-snapdragon/spl.c
+++ b/arch/arm/mach-snapdragon/spl.c
@@ -11,6 +11,7 @@
#include <asm/io.h>
#include <asm/system.h>
#include <asm/sections.h>
+#include <smem.h>
#include <atf_common.h>
#include <linux/err.h>
#include <dm/device-internal.h>
@@ -169,6 +170,46 @@ static int qcom_spl_get_fit_img_entry_point(void *fit, int node,
return ret;
}
+#if IS_ENABLED(CONFIG_SPL_SMEM)
+/**
+ * qcom_spl_populate_smem() - Populate shared memory (SMEM) information.
+ * @ctx: Pointer to the global SPL context.
+ *
+ * This function initializes and populates various SMEM items with boot-related
+ * information, such as flash type, try-mode status, and ATF enable status.
+ * Return: 0 on success, or a negative error code on failure.
+ */
+static int qcom_spl_populate_smem(void *ctx)
+{
+ int ret;
+ size_t size;
+ struct udevice *smem;
+ u32 *fltype;
+
+ ret = uclass_get_device(UCLASS_SMEM, 0, &smem);
+ if (ret) {
+ pr_err("Failed to find SMEM node (%d)\n", ret);
+ return ret;
+ }
+
+ size = sizeof(u32);
+ ret = smem_alloc(smem, -1, SMEM_BOOT_FLASH_TYPE, size);
+ if (ret) {
+ pr_err("Failed to alloc item: SMEM_BOOT_FLASH_TYPE (%d)\n", ret);
+ return ret;
+ }
+
+ fltype = (u32 *)smem_get(smem, -1, SMEM_BOOT_FLASH_TYPE, &size);
+ if (!fltype) {
+ pr_err("Failed to get item: SMEM_BOOT_FLASH_TYPE\n");
+ return -ENOENT;
+ }
+
+ if (IS_ENABLED(CONFIG_SPL_MMC))
+ *fltype = SMEM_BOOT_MMC_FLASH;
+ return 0;
+}
+#endif /* IS_ENABLED(CONFIG_SPL_SMEM) */
/**
* qcom_spl_get_iftbl_entry_by_name() - Get an interface table entry by name.
* @if_tbl: Pointer to the QCLIB interface table.
@@ -330,6 +371,30 @@ int qclib_post_process_from_spl(void)
return 0;
}
+#if IS_ENABLED(CONFIG_SPL_SMEM)
+/**
+ * spl_board_prepare_for_boot() - Prepare board for boot
+ *
+ * This function is called by SPL before jumping to the next stage.
+ * It populates SMEM during coldboot.
+ */
+void spl_board_prepare_for_boot(void)
+{
+ int ret;
+
+ /*
+ * Populate SMEM in coldboot (Dload bit not set)
+ */
+ if (!QCOM_SPL_IS_DLOAD_BIT_SET) {
+ printf("Populating SMEM\n");
+ ret = qcom_spl_populate_smem(NULL);
+ if (ret) {
+ pr_err("Failed to populate SMEM (%d)\n", ret);
+ qcom_spl_error_handler(NULL);
+ }
+ }
+}
+#endif /* IS_ENABLED(CONFIG_SPL_SMEM) */
/**
* spl_get_load_buffer() - Allocate a cache-aligned buffer for image loading.
diff --git a/include/smem.h b/include/smem.h
index b19c534ebc4..f16ba7d63dc 100644
--- a/include/smem.h
+++ b/include/smem.h
@@ -87,4 +87,7 @@ void *smem_get(struct udevice *dev, unsigned int host, unsigned int item, size_t
*/
int smem_get_free_space(struct udevice *dev, unsigned int host);
+#define SMEM_BOOT_FLASH_TYPE 498
+#define SMEM_BOOT_MMC_FLASH 5
+
#endif /* _smem_h_ */
--
2.34.1
More information about the U-Boot
mailing list