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 | 46 ++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/arch/arm/mach-snapdragon/board_spl.c
b/arch/arm/mach-snapdragon/board_spl.c
index 6ae59481ba9..69a32e5d8cf 100644
--- a/arch/arm/mach-snapdragon/board_spl.c
+++ b/arch/arm/mach-snapdragon/board_spl.c
@@ -85,3 +85,49 @@ u32 spl_boot_device(void)
pr_err("No boot device configured\n");
return BOOT_DEVICE_NONE;
}
+
+#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;
+ }
+
+ pr_err("Boot medium not specified\n");
+
+ return -ENOENT;
+}
+#endif /* IS_ENABLED(CONFIG_SPL_SMEM) */
--
2.34.1