]> git.sur5r.net Git - u-boot/blobdiff - common/spl/spl_mmc.c
Remove unnecessary instances of DECLARE_GLOBAL_DATA_PTR
[u-boot] / common / spl / spl_mmc.c
index d95f94ca15e0b4b07c4a894247044391be816c9d..e780b82fd2bfa0bfc1dd95d797fe60886aaa32dd 100644 (file)
@@ -16,8 +16,6 @@
 #include <mmc.h>
 #include <image.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
 static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
                           ulong sector, struct image_header *header)
 {
@@ -52,8 +50,9 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
        return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf);
 }
 
-static int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
-                                    struct mmc *mmc, unsigned long sector)
+static __maybe_unused
+int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
+                             struct mmc *mmc, unsigned long sector)
 {
        unsigned long count;
        struct image_header *header;
@@ -200,7 +199,7 @@ static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
                CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR,
                CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS,
                (void *) CONFIG_SYS_SPL_ARGS_ADDR);
-       if (count == 0) {
+       if (count != CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
                puts("mmc_load_image_raw_os: mmc block read error\n");
 #endif
@@ -280,6 +279,25 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
 }
 #endif
 
+u32 __weak spl_boot_mode(const u32 boot_device)
+{
+#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
+       return MMCSD_MODE_FS;
+#elif defined(CONFIG_SUPPORT_EMMC_BOOT)
+       return MMCSD_MODE_EMMCBOOT;
+#else
+       return MMCSD_MODE_RAW;
+#endif
+}
+
+#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
+__weak
+int spl_boot_partition(const u32 boot_device)
+{
+       return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
+}
+#endif
+
 int spl_mmc_load_image(struct spl_image_info *spl_image,
                       struct spl_boot_device *bootdev)
 {
@@ -335,8 +353,11 @@ int spl_mmc_load_image(struct spl_image_info *spl_image,
                                return err;
                }
 #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
-               err = mmc_load_image_raw_partition(spl_image, mmc,
-                       CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
+               err = spl_boot_partition(bootdev->boot_device);
+               if (!err)
+                       return err;
+
+               err = mmc_load_image_raw_partition(spl_image, mmc, err);
                if (!err)
                        return err;
 #endif