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 4/5] imx: mx6slevk: implement mmc_get_env_devno
Date: Tue, 15 Dec 2015 16:26:14 +0800	[thread overview]
Message-ID: <1450167975-13265-4-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/mx6slevk/mx6slevk.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/board/freescale/mx6slevk/mx6slevk.c b/board/freescale/mx6slevk/mx6slevk.c
index 5eab4b5..7617c76 100644
--- a/board/freescale/mx6slevk/mx6slevk.c
+++ b/board/freescale/mx6slevk/mx6slevk.c
@@ -170,6 +170,22 @@ static struct fsl_esdhc_cfg usdhc_cfg[3] = {
 	{USDHC3_BASE_ADDR, 0, 4},
 };
 
+int mmc_get_env_devno(void)
+{
+	struct src *src_regs = (struct src *)SRC_BASE_ADDR;
+	u32 soc_sbmr = readl(&src_regs->sbmr1);
+	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] */
+	return (soc_sbmr & 0x00001800) >> 11;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
-- 
2.6.2

  parent 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 ` [U-Boot] [PATCH 2/5] imx: mx6sabresd: implement mmc_get_env_devno Peng Fan
2015-12-15  8:26 ` [U-Boot] [PATCH 3/5] imx: mx6qarm2: " Peng Fan
2015-12-15  8:26 ` Peng Fan [this message]
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-4-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