Update the SMEM with the boot device information got from the boot rom.

Reviewed-by: Balaji Selvanathan <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Signed-off-by: Varadarajan Narayanan <[email protected]>
---
 arch/arm/mach-snapdragon/board_spl.c | 42 ++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/arch/arm/mach-snapdragon/board_spl.c 
b/arch/arm/mach-snapdragon/board_spl.c
index 41d8789a002..460d07ef0a3 100644
--- a/arch/arm/mach-snapdragon/board_spl.c
+++ b/arch/arm/mach-snapdragon/board_spl.c
@@ -21,3 +21,45 @@ __weak void reset_cpu(void)
        printf("reset_cpu called, going to hang()\n");
        hang();
 }
+
+#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.
+ * 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 = qcom_smem_init();
+       if (ret) {
+               pr_err("Failed init SMEM (%d)\n", ret);
+               return ret;
+       }
+
+       size = sizeof(u32);
+
+       fltype = (u32 *)smem_get(-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;
+               wmb();
+               return 0;
+       }
+
+       pr_err("Boot medium not specified\n");
+
+       return -ENOENT;
+}
+#endif /* IS_ENABLED(CONFIG_SPL_SMEM) */

-- 
2.34.1

Reply via email to