From: Peng Fan Date: Thu, 28 Jan 2016 08:51:25 +0000 (+0800) Subject: imx: mx7dsabresd: move mmc_get_env_devno to soc code X-Git-Tag: v2016.03-rc2~134 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=62d8cce9f37c12ff92a47414484997a74d038440;p=u-boot imx: mx7dsabresd: move mmc_get_env_devno to soc code Move mmc_get_env_devno to soc.c and rename to mmc_get_env_dev to match the one in common/env_mmc.c. Introduce a weak function board_mmc_get_env_dev. Different boards can implement this according to sdhc controller which is used by the board. Signed-off-by: Peng Fan Cc: Stefano Babic --- diff --git a/arch/arm/cpu/armv7/mx7/soc.c b/arch/arm/cpu/armv7/mx7/soc.c index 1d8e470971..a6ab551a4a 100644 --- a/arch/arm/cpu/armv7/mx7/soc.c +++ b/arch/arm/cpu/armv7/mx7/soc.c @@ -288,6 +288,27 @@ enum boot_device get_boot_device(void) return boot_dev; } +#ifdef CONFIG_ENV_IS_IN_MMC +__weak int board_mmc_get_env_dev(int devno) +{ + return CONFIG_SYS_MMC_ENV_DEV; +} + +int mmc_get_env_dev(void) +{ + struct bootrom_sw_info **p = + (struct bootrom_sw_info **)ROM_SW_INFO_ADDR; + int devno = (*p)->boot_dev_instance; + u8 boot_type = (*p)->boot_dev_type; + + /* If not boot from sd/mmc, use default value */ + if ((boot_type != BOOT_TYPE_SD) && (boot_type != BOOT_TYPE_MMC)) + return CONFIG_SYS_MMC_ENV_DEV; + + return board_mmc_get_env_dev(devno); +} +#endif + void s_init(void) { #if !defined CONFIG_SPL_BUILD diff --git a/board/freescale/mx7dsabresd/mx7dsabresd.c b/board/freescale/mx7dsabresd/mx7dsabresd.c index bbcc5bb0c6..20e56f281b 100644 --- a/board/freescale/mx7dsabresd/mx7dsabresd.c +++ b/board/freescale/mx7dsabresd/mx7dsabresd.c @@ -328,22 +328,12 @@ static struct fsl_esdhc_cfg usdhc_cfg[3] = { {USDHC3_BASE_ADDR}, }; -static int mmc_get_env_devno(void) +int board_mmc_get_env_dev(int devno) { - struct bootrom_sw_info **p = - (struct bootrom_sw_info **)ROM_SW_INFO_ADDR; + if (devno == 2) + devno--; - u8 boot_type = (*p)->boot_dev_type; - u8 dev_no = (*p)->boot_dev_instance; - - /* If not boot from sd/mmc, use default value */ - if ((boot_type != BOOT_TYPE_SD) && (boot_type != BOOT_TYPE_MMC)) - return CONFIG_SYS_MMC_ENV_DEV; - - if (dev_no == 2) - dev_no--; - - return dev_no; + return devno; } static int mmc_map_to_kernel_blk(int dev_no) @@ -432,7 +422,7 @@ static void mmc_late_init(void) { char cmd[32]; char mmcblk[32]; - u32 dev_no = mmc_get_env_devno(); + u32 dev_no = mmc_get_env_dev(); if (!check_mmc_autodetect()) return;