public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] imx: mx6: Implement mmc_get_env_part
@ 2016-02-04 13:41 Soeren Moch
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Soeren Moch @ 2016-02-04 13:41 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 2/2] board: tbs2910: Autoselect environment device when booting from SD
  2016-02-04 13:41 [U-Boot] [PATCH 1/2] imx: mx6: Implement mmc_get_env_part Soeren Moch
@ 2016-02-04 13:41 ` Soeren Moch
  2016-02-21 10:35 ` [U-Boot] [PATCH 1/2] imx: mx6: Implement mmc_get_env_part Stefano Babic
  1 sibling, 0 replies; 3+ messages in thread
From: Soeren Moch @ 2016-02-04 13:41 UTC (permalink / raw)
  To: u-boot

Implement board specific functions to select the environment device and
partition when booting from SD/MMC.

SD2:  mmc 0 0
SD3:  mmc 1 0
eMMC: mmc 2 1

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
---
 board/tbs/tbs2910/tbs2910.c | 11 +++++++++++
 include/configs/tbs2910.h   |  4 ++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/board/tbs/tbs2910/tbs2910.c b/board/tbs/tbs2910/tbs2910.c
index 0b509b6..d302fc2 100644
--- a/board/tbs/tbs2910/tbs2910.c
+++ b/board/tbs/tbs2910/tbs2910.c
@@ -257,6 +257,17 @@ int board_mmc_init(bd_t *bis)
 	}
 	return 0;
 }
+
+/* set environment device to boot device when booting from SD */
+int board_mmc_get_env_dev(int devno)
+{
+	return devno - 1;
+}
+
+int board_mmc_get_env_part(int devno)
+{
+	return (devno == 3) ? 1 : 0; /* part 0 for SD2 / SD3, part 1 for eMMC */
+}
 #endif /* CONFIG_FSL_ESDHC */
 
 #ifdef CONFIG_VIDEO_IPUV3
diff --git a/include/configs/tbs2910.h b/include/configs/tbs2910.h
index 17b0213..0f23034 100644
--- a/include/configs/tbs2910.h
+++ b/include/configs/tbs2910.h
@@ -176,8 +176,8 @@
 
 /* Environment organization */
 #define CONFIG_ENV_IS_IN_MMC
-#define CONFIG_SYS_MMC_ENV_DEV		2
-#define CONFIG_SYS_MMC_ENV_PART		1
+#define CONFIG_SYS_MMC_ENV_DEV		2 /* overwritten on SD boot */
+#define CONFIG_SYS_MMC_ENV_PART		1 /* overwritten on SD boot */
 #define CONFIG_ENV_SIZE			(8 * 1024)
 #define CONFIG_ENV_OFFSET		(384 * 1024)
 #define CONFIG_ENV_OVERWRITE
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/2] imx: mx6: Implement mmc_get_env_part
  2016-02-04 13:41 [U-Boot] [PATCH 1/2] imx: mx6: Implement mmc_get_env_part Soeren Moch
  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 ` Stefano Babic
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Babic @ 2016-02-21 10:35 UTC (permalink / raw)
  To: u-boot

On 04/02/2016 14:41, Soeren Moch wrote:
> 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
> ---

Applied (both patches) to u-boot-imx, thanks !

Best regards,
Stefano Babic


-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-21 10:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-04 13:41 [U-Boot] [PATCH 1/2] imx: mx6: Implement mmc_get_env_part Soeren Moch
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox