From: Peng Fan Date: Tue, 15 Dec 2015 16:26:15 +0800 Subject: [U-Boot] [PATCH 5/5] imx: mx6sxsabresd: implement mmc_get_env_devno In-Reply-To: <1450167975-13265-1-git-send-email-Peng.Fan@freescale.com> References: <1450167975-13265-1-git-send-email-Peng.Fan@freescale.com> Message-ID: <1450167975-13265-5-git-send-email-Peng.Fan@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Implement mmc_get_env_devno, support loading env successfully when booting from different slots. Signed-off-by: Peng Fan Cc: Stefano Babic --- board/freescale/mx6sxsabresd/mx6sxsabresd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/board/freescale/mx6sxsabresd/mx6sxsabresd.c b/board/freescale/mx6sxsabresd/mx6sxsabresd.c index 3ee4662..f524e71 100644 --- a/board/freescale/mx6sxsabresd/mx6sxsabresd.c +++ b/board/freescale/mx6sxsabresd/mx6sxsabresd.c @@ -309,6 +309,30 @@ static struct fsl_esdhc_cfg usdhc_cfg[3] = { #define USDHC3_PWR_GPIO IMX_GPIO_NR(2, 11) #define USDHC4_CD_GPIO IMX_GPIO_NR(6, 21) +int mmc_get_env_devno(void) +{ + struct src *src_regs = (struct src *)SRC_BASE_ADDR; + u32 soc_sbmr = readl(&src_regs->sbmr1); + int dev_no; + u32 bootsel; + + bootsel = (soc_sbmr & 0x000000FF) >> 6 ; + + /* If not boot from sd/mmc, use default value */ + if (bootsel != 1) + return CONFIG_SYS_MMC_ENV_DEV; + + /* BOOT_CFG2[3] and BOOT_CFG2[4] */ + dev_no = (soc_sbmr & 0x00001800) >> 11; + + /* + * need ubstract 1 to map to the mmc device id + * see the comments in board_mmc_init function + */ + + return --dev_no; +} + int board_mmc_getcd(struct mmc *mmc) { struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; -- 2.6.2