diff options
author | Nikita Kiryanov <nikita@compulab.co.il> | 2015-11-08 17:11:54 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2015-11-18 14:50:05 -0500 |
commit | a1e56cf6d430d78db3a4dc08a422311145e32315 (patch) | |
tree | fbb5d3da1633eda25681e83e0cd6e4ec04fd785f /common/spl | |
parent | 7b9e980e870294ab36f5b0f36abcb034a4955d29 (diff) | |
download | u-boot-imx-a1e56cf6d430d78db3a4dc08a422311145e32315.zip u-boot-imx-a1e56cf6d430d78db3a4dc08a422311145e32315.tar.gz u-boot-imx-a1e56cf6d430d78db3a4dc08a422311145e32315.tar.bz2 |
spl: mmc: add support for BOOT_DEVICE_MMC2
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>
Diffstat (limited to 'common/spl')
-rw-r--r-- | common/spl/spl.c | 2 | ||||
-rw-r--r-- | common/spl/spl_mmc.c | 41 |
2 files changed, 34 insertions, 9 deletions
diff --git a/common/spl/spl.c b/common/spl/spl.c index b522c8b..7a393dc 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -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: diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index b68190a..b3c2c64 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -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; |