public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Soeren Moch <smoch@web.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] imx: mx6: Implement mmc_get_env_part
Date: Thu,  4 Feb 2016 14:41:15 +0100	[thread overview]
Message-ID: <1454593276-3883-1-git-send-email-smoch@web.de> (raw)

commit 216d286c7e3d3d83d4d8ccaf0415192e1b1040c0 [imx: mx6: implement
mmc_get_env_dev] introduced selection of the environment device according
to the boot device when booting from SD/MMC.

Extend this functionality for also selecting the device partition.

Signed-off-by: Soeren Moch <smoch@web.de>
---
Cc: Stefano Babic <sbabic@denx.de>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: u-boot at lists.denx.de
---
 arch/arm/cpu/armv7/mx6/soc.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
index 8aeeaec..db6eabf 100644
--- a/arch/arm/cpu/armv7/mx6/soc.c
+++ b/arch/arm/cpu/armv7/mx6/soc.c
@@ -21,6 +21,7 @@
 #include <asm/arch/crm_regs.h>
 #include <dm.h>
 #include <imx_thermal.h>
+#include <mmc.h>
 
 enum ldo_reg {
 	LDO_ARM,
@@ -355,7 +356,7 @@ __weak int board_mmc_get_env_dev(int devno)
 	return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-int mmc_get_env_dev(void)
+static int mmc_get_boot_dev(void)
 {
 	struct src *src_regs = (struct src *)SRC_BASE_ADDR;
 	u32 soc_sbmr = readl(&src_regs->sbmr1);
@@ -370,15 +371,44 @@ int mmc_get_env_dev(void)
 	 */
 	bootsel = (soc_sbmr & 0x000000FF) >> 6;
 
-	/* If not boot from sd/mmc, use default value */
+	/* No boot from sd/mmc */
 	if (bootsel != 1)
-		return CONFIG_SYS_MMC_ENV_DEV;
+		return -1;
 
 	/* BOOT_CFG2[3] and BOOT_CFG2[4] */
 	devno = (soc_sbmr & 0x00001800) >> 11;
 
+	return devno;
+}
+
+int mmc_get_env_dev(void)
+{
+	int devno = mmc_get_boot_dev();
+
+	/* If not boot from sd/mmc, use default value */
+	if (devno < 0)
+		return CONFIG_SYS_MMC_ENV_DEV;
+
 	return board_mmc_get_env_dev(devno);
 }
+
+#ifdef CONFIG_SYS_MMC_ENV_PART
+__weak int board_mmc_get_env_part(int devno)
+{
+	return CONFIG_SYS_MMC_ENV_PART;
+}
+
+uint mmc_get_env_part(struct mmc *mmc)
+{
+	int devno = mmc_get_boot_dev();
+
+	/* If not boot from sd/mmc, use default value */
+	if (devno < 0)
+		return CONFIG_SYS_MMC_ENV_PART;
+
+	return board_mmc_get_env_part(devno);
+}
+#endif
 #endif
 
 int board_postclk_init(void)
-- 
1.9.1

             reply	other threads:[~2016-02-04 13:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 13:41 Soeren Moch [this message]
2016-02-04 13:41 ` [U-Boot] [PATCH 2/2] board: tbs2910: Autoselect environment device when booting from SD Soeren Moch
2016-02-21 10:35 ` [U-Boot] [PATCH 1/2] imx: mx6: Implement mmc_get_env_part Stefano Babic

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=1454593276-3883-1-git-send-email-smoch@web.de \
    --to=smoch@web.de \
    --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