summaryrefslogtreecommitdiff
path: root/include/configs/sunxi-common.h
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2017-08-23 10:12:22 +0200
committerMaxime Ripard <maxime.ripard@free-electrons.com>2017-10-03 19:12:06 +0200
commitde86fc3859f9c9ae26faed6f9d8fc115e1329b4f (patch)
treeca874a378ccb688f362f703ac3bcdff258f8e63a /include/configs/sunxi-common.h
parentf4c3523c98588b528601f40c0c16106379ea6eda (diff)
sunxi: Remove the MMC index hack
The current code, if there's both an eMMC and an MMC slot available on the board, will swap the MMC indices based on whether we booted from the eMMC or the MMC. This way, the MMC we're supposed to boot on will always have the index 0. However, this causes various issues, for example when using other components that base their behaviour on the MMC index, such as fastboot. Let's remove that hack, and take the opposite approach. The MMC will always have the same index, but the bootcmd will pick the same device than the one we booted from. This is done through the introduction of the mmc_bootdev environment variable that will be filled by the board code based on the boot device informations we can get from the SoC. In order to not introduce regressions, we also need to adjust the fastboot MMC device and the environment device in order to set it to the eMMC, over the MMC, like it used to be the case. Tested-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Diffstat (limited to 'include/configs/sunxi-common.h')
-rw-r--r--include/configs/sunxi-common.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 02d7be0849..91751171ec 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -148,7 +148,13 @@
#endif
#if defined(CONFIG_ENV_IS_IN_MMC)
-#define CONFIG_SYS_MMC_ENV_DEV 0 /* first detected MMC controller */
+#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
+/* If we have two devices (most likely eMMC + MMC), favour the eMMC */
+#define CONFIG_SYS_MMC_ENV_DEV 1
+#else
+/* Otherwise, use the only device we have */
+#define CONFIG_SYS_MMC_ENV_DEV 0
+#endif
#define CONFIG_SYS_MMC_MAX_DEVICE 4
#elif defined(CONFIG_ENV_IS_NOWHERE)
#define CONFIG_ENV_SIZE (128 << 10)
@@ -382,15 +388,28 @@ extern int soft_i2c_gpio_scl;
"ramdisk ram " RAMDISK_ADDR_R " 0x4000000\0"
#ifdef CONFIG_MMC
-#define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
#if CONFIG_MMC_SUNXI_SLOT_EXTRA != -1
-#define BOOT_TARGET_DEVICES_MMC_EXTRA(func) func(MMC, mmc, 1)
+#define BOOTENV_DEV_MMC_AUTO(devtypeu, devtypel, instance) \
+ BOOTENV_DEV_MMC(MMC, mmc, 0) \
+ BOOTENV_DEV_MMC(MMC, mmc, 1) \
+ "bootcmd_mmc_auto=" \
+ "if test ${mmc_bootdev} -eq 1; then " \
+ "run bootcmd_mmc1; " \
+ "run bootcmd_mmc0; " \
+ "elif test ${mmc_bootdev} -eq 0; then " \
+ "run bootcmd_mmc0; " \
+ "run bootcmd_mmc1; " \
+ "fi\0"
+
+#define BOOTENV_DEV_NAME_MMC_AUTO(devtypeu, devtypel, instance) \
+ "mmc_auto "
+
+#define BOOT_TARGET_DEVICES_MMC(func) func(MMC_AUTO, mmc_auto, na)
#else
-#define BOOT_TARGET_DEVICES_MMC_EXTRA(func)
+#define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
#endif
#else
#define BOOT_TARGET_DEVICES_MMC(func)
-#define BOOT_TARGET_DEVICES_MMC_EXTRA(func)
#endif
#ifdef CONFIG_AHCI
@@ -418,7 +437,6 @@ extern int soft_i2c_gpio_scl;
#define BOOT_TARGET_DEVICES(func) \
func(FEL, fel, na) \
BOOT_TARGET_DEVICES_MMC(func) \
- BOOT_TARGET_DEVICES_MMC_EXTRA(func) \
BOOT_TARGET_DEVICES_SCSI(func) \
BOOT_TARGET_DEVICES_USB(func) \
func(PXE, pxe, na) \