public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Peng Fan <Peng.Fan@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/5] imx: mx6sabresd: implement mmc_get_env_devno
Date: Tue, 15 Dec 2015 16:26:12 +0800	[thread overview]
Message-ID: <1450167975-13265-2-git-send-email-Peng.Fan@freescale.com> (raw)
In-Reply-To: <1450167975-13265-1-git-send-email-Peng.Fan@freescale.com>

Implement mmc_get_env_devno, support loading env successfully
when booting from different slots.

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
---
 board/freescale/mx6sabresd/mx6sabresd.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
index 581c9d5..22ed331 100644
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -234,6 +234,35 @@ struct fsl_esdhc_cfg usdhc_cfg[3] = {
 #define USDHC2_CD_GPIO	IMX_GPIO_NR(2, 2)
 #define USDHC3_CD_GPIO	IMX_GPIO_NR(2, 0)
 
+int mmc_get_env_devno(void)
+{
+	struct src *src_regs = (struct src *)SRC_BASE_ADDR;
+	u32 soc_sbmr = readl(&src_regs->sbmr1);
+	u32 dev_no;
+	u32 bootsel;
+
+	/*
+	 * Refer to
+	 * "i.MX 6Dual/6Quad Applications Processor Reference Manual"
+	 * Chapter "8.5.3.1 Expansion Device eFUSE Configuration"
+	 */
+	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

  reply	other threads:[~2015-12-15  8:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-15  8:26 [U-Boot] [PATCH 1/5] common: env_mmc: support loading env from different cards Peng Fan
2015-12-15  8:26 ` Peng Fan [this message]
2015-12-15  8:26 ` [U-Boot] [PATCH 3/5] imx: mx6qarm2: implement mmc_get_env_devno Peng Fan
2015-12-15  8:26 ` [U-Boot] [PATCH 4/5] imx: mx6slevk: " Peng Fan
2015-12-15  8:26 ` [U-Boot] [PATCH 5/5] imx: mx6sxsabresd: " Peng Fan
2015-12-15 14:58 ` [U-Boot] [PATCH 1/5] common: env_mmc: support loading env from different cards Stefano Babic
2015-12-16  2:04   ` Peng Fan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450167975-13265-2-git-send-email-Peng.Fan@freescale.com \
    --to=peng.fan@freescale.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox