Add routines to enable U-Boot SPL to be able to proceed with the boot from
MMC partitions.

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

diff --git a/arch/arm/mach-snapdragon/board_spl.c 
b/arch/arm/mach-snapdragon/board_spl.c
index 460d07ef0a3..2445ae8b17d 100644
--- a/arch/arm/mach-snapdragon/board_spl.c
+++ b/arch/arm/mach-snapdragon/board_spl.c
@@ -63,3 +63,60 @@ static int qcom_spl_populate_smem(void *ctx)
        return -ENOENT;
 }
 #endif /* IS_ENABLED(CONFIG_SPL_SMEM) */
+
+#if CONFIG_IS_ENABLED(MMC)
+
+#define QCOM_SPL_FIT_IMG_PARTITION     "0:BOOTLDR"
+
+/**
+ * spl_mmc_boot_mode() - Determine the boot mode for MMC
+ * @mmc:       Pointer to the MMC device
+ * @boot_device:       Boot device ID
+ *
+ * Return: MMCSD_MODE_RAW to use raw partition access
+ */
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
+{
+       return MMCSD_MODE_RAW;
+}
+
+/**
+ * spl_mmc_boot_partition() - Determine which partition to boot from
+ * @boot_device:       Boot device ID
+ *
+ * Return: Partition number to boot from, or default partition on error
+ */
+int spl_mmc_boot_partition(const u32 boot_device)
+{
+       int p_no;
+       struct blk_desc *desc;
+       struct disk_partition info;
+
+       desc = blk_get_devnum_by_uclass_id(UCLASS_MMC, 0);
+       if (!desc) {
+               pr_err("%s: Block device not found\n", __func__);
+               return -ENODEV;
+       }
+
+       p_no = part_get_info_by_name(desc, QCOM_SPL_FIT_IMG_PARTITION, &info);
+       if (p_no < 0) {
+               pr_err("Partition " QCOM_SPL_FIT_IMG_PARTITION " not found\n");
+               return -ENOENT;
+       }
+
+       pr_debug("Found " QCOM_SPL_FIT_IMG_PARTITION " at %d\n", p_no);
+
+       if (p_no < 0) {
+               printf("Using default MMC partition %d\n",
+                      CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
+               return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
+       }
+
+       return p_no;
+}
+
+unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, ulong raw_sect)
+{
+       return 0;
+}
+#endif /* CONFIG_IS_ENABLED(MMC) */

-- 
2.34.1

Reply via email to