]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
spl: mmc: add support for BOOT_DEVICE_MMC2
authorNikita Kiryanov <nikita@compulab.co.il>
Sun, 8 Nov 2015 15:11:54 +0000 (17:11 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 18 Nov 2015 19:50:05 +0000 (14:50 -0500)
Currently the mmc device that SPL looks at is always mmc0, regardless
of the BOOT_DEVICE_MMCx value. This forces some boards to
implement hacks in order to boot from other mmc devices.

Make SPL take into account the correct mmc device.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Reviewed-by: Tom Rini <trini@konsulko.com>
arch/arm/cpu/armv7/sunxi/board.c
common/spl/spl.c
common/spl/spl_mmc.c
include/spl.h

index 9b5c46b354796a8165383531099f1a1f209346f5..794b829e1c976a51b252f756322d0fde43feb5be 100644 (file)
@@ -173,16 +173,8 @@ u32 spl_boot_device(void)
 #ifdef CONFIG_MMC
        if (CONFIG_MMC_SUNXI_SLOT_EXTRA == 2) {
                mmc1 = find_mmc_device(1);
-               if (sunxi_mmc_has_egon_boot_signature(mmc1)) {
-                       /*
-                        * spl_mmc.c: spl_mmc_load_image() is hard-coded to
-                        * use find_mmc_device(0), no matter what we
-                        * return. Swap mmc0 and mmc2 to make this work.
-                        */
-                       mmc0->block_dev.dev = 1;
-                       mmc1->block_dev.dev = 0;
+               if (sunxi_mmc_has_egon_boot_signature(mmc1))
                        return BOOT_DEVICE_MMC2;
-               }
        }
 #endif
 
index b522c8b3855dd26522d5eff22efdbef6589fe6a4..7a393dc078291d3fec81b88cf4c17cebaa4e27d1 100644 (file)
@@ -284,7 +284,7 @@ static int spl_load_image(u32 boot_device)
        case BOOT_DEVICE_MMC1:
        case BOOT_DEVICE_MMC2:
        case BOOT_DEVICE_MMC2_2:
-               return spl_mmc_load_image();
+               return spl_mmc_load_image(boot_device);
 #endif
 #ifdef CONFIG_SPL_NAND_SUPPORT
        case BOOT_DEVICE_NAND:
index b68190a265bc1956902508efe18f7b934531a335..b3c2c642e4ab7f8387ddec80906b103d2ade936d 100644 (file)
@@ -61,11 +61,32 @@ end:
        return 0;
 }
 
+int spl_mmc_get_device_index(u32 boot_device)
+{
+       switch (boot_device) {
+       case BOOT_DEVICE_MMC1:
+               return 0;
+       case BOOT_DEVICE_MMC2:
+       case BOOT_DEVICE_MMC2_2:
+               return 1;
+       }
+
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+       printf("spl: unsupported mmc boot device.\n");
+#endif
+
+       return -ENODEV;
+}
+
 #ifdef CONFIG_DM_MMC
-static int spl_mmc_find_device(struct mmc **mmc)
+static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device)
 {
        struct udevice *dev;
-       int err;
+       int err, mmc_dev;
+
+       mmc_dev = spl_mmc_get_device_index(boot_device);
+       if (mmc_dev < 0)
+               return mmc_dev;
 
        err = mmc_initialize(NULL);
        if (err) {
@@ -75,7 +96,7 @@ static int spl_mmc_find_device(struct mmc **mmc)
                return err;
        }
 
-       err = uclass_get_device(UCLASS_MMC, 0, &dev);
+       err = uclass_get_device(UCLASS_MMC, mmc_dev, &dev);
        if (err) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
                printf("spl: could not find mmc device. error: %d\n", err);
@@ -88,9 +109,13 @@ static int spl_mmc_find_device(struct mmc **mmc)
        return *mmc != NULL ? 0 : -ENODEV;
 }
 #else
-static int spl_mmc_find_device(struct mmc **mmc)
+static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device)
 {
-       int err;
+       int err, mmc_dev;
+
+       mmc_dev = spl_mmc_get_device_index(boot_device);
+       if (mmc_dev < 0)
+               return mmc_dev;
 
        err = mmc_initialize(gd->bd);
        if (err) {
@@ -101,7 +126,7 @@ static int spl_mmc_find_device(struct mmc **mmc)
        }
 
        /* We register only one device. So, the dev id is always 0 */
-       *mmc = find_mmc_device(0);
+       *mmc = find_mmc_device(mmc_dev);
        if (!*mmc) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
                puts("spl: mmc device not found\n");
@@ -221,14 +246,14 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)
 }
 #endif
 
-int spl_mmc_load_image(void)
+int spl_mmc_load_image(u32 boot_device)
 {
        struct mmc *mmc;
        u32 boot_mode;
        int err = 0;
        __maybe_unused int part;
 
-       err = spl_mmc_find_device(&mmc);
+       err = spl_mmc_find_device(&mmc, boot_device);
        if (err)
                return err;
 
index 46fc454c22e6a53bc1176753d11f55fde84691f8..92cdc049d45382f11fe5cd1539f57c8f7e445bf3 100644 (file)
@@ -54,7 +54,7 @@ int spl_onenand_load_image(void);
 int spl_nor_load_image(void);
 
 /* MMC SPL functions */
-int spl_mmc_load_image(void);
+int spl_mmc_load_image(u32 boot_device);
 
 /* YMODEM SPL functions */
 int spl_ymodem_load_image(void);