Identify the boot media loader driver and load the FIT image that has the
binaries to initialize the DDR, U-Boot proper etc.

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 | 59 ++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/arch/arm/mach-snapdragon/board_spl.c 
b/arch/arm/mach-snapdragon/board_spl.c
index 25b1779391a..716a21156e7 100644
--- a/arch/arm/mach-snapdragon/board_spl.c
+++ b/arch/arm/mach-snapdragon/board_spl.c
@@ -253,3 +253,62 @@ void qcom_spl_malloc_init_f(void)
        mem_malloc_init(gd->malloc_base, gd->malloc_limit);
        gd->flags |= GD_FLG_FULL_MALLOC_INIT;
 }
+
+/**
+ * spl_get_load_buffer() - Allocate a cache-aligned buffer for image loading.
+ * @offset:    Offset (unused, typically 0 for SPL).
+ * @size:      Size of the buffer to allocate.
+ *
+ * Return: Pointer to the allocated buffer, or NULL on failure.
+ */
+struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size)
+{
+#ifdef CONFIG_SPL_LOAD_FIT_ADDRESS
+       return (void *)CONFIG_SPL_LOAD_FIT_ADDRESS;
+#else
+       return NULL;
+#endif
+}
+
+/**
+ * board_spl_fit_buffer_addr() - Get the address of the FIT image buffer.
+ * @fit_size:  Size of the FIT image.
+ * @sectors:   Number of sectors.
+ * @bl_len:    Block length.
+ *
+ * Return: Address of the FIT image buffer.
+ */
+void *board_spl_fit_buffer_addr(ulong fit_size, int sectors, int bl_len)
+{
+       return spl_get_load_buffer(0, sectors * bl_len);
+}
+
+/**
+ * qcom_spl_loader_pre_ddr() - SPL loader for pre-DDR stage.
+ * @boot_device: Type of boot device.
+ *
+ * Return: 0 on success, or a negative error code on failure.
+ */
+int qcom_spl_loader_pre_ddr(u8 boot_device)
+{
+       struct spl_image_loader *loader, *drv;
+       struct spl_image_info spl_image = { 0 };
+       struct spl_boot_device boot_dev = { .boot_device = boot_device, };
+       int ret = -ENODEV, n_ents;
+
+       drv = ll_entry_start(struct spl_image_loader, spl_image_loader);
+       n_ents = ll_entry_count(struct spl_image_loader, spl_image_loader);
+
+       for (loader = drv; loader && (loader != drv + n_ents); loader++) {
+               if (boot_device != loader->boot_device)
+                       continue;
+
+               ret = loader->load_image(&spl_image, &boot_dev);
+               if (!ret)
+                       break;
+
+               printf("%s: Error: %d\n", __func__, ret);
+       }
+
+       return ret;
+}

-- 
2.34.1

Reply via email to