public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V2 1/3] imx: mx7dsabresd: move mmc_get_env_devno to soc code
@ 2016-01-28  8:51 Peng Fan
  2016-01-28  8:51 ` [U-Boot] [PATCH V2 2/3] imx: mx6: implement mmc_get_env_dev Peng Fan
  2016-01-28  8:51 ` [U-Boot] [PATCH V2 3/3] imx: mx6: implement board_mmc_get_env_dev Peng Fan
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan @ 2016-01-28  8:51 UTC (permalink / raw)
  To: u-boot

From: Peng Fan <peng.fan@nxp.com>

Move mmc_get_env_devno to soc.c and rename to mmc_get_env_dev to
match the one in common/env_mmc.c.
Introduce a weak function board_mmc_get_env_dev. Different
boards can implement this according to sdhc controller which
is used by the board.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
---

V2:
 Use CONFIG_ENV_IS_IN_MMC to wrap soc code.
 Since mmc_get_env_dev already upstreamed by this commit:
 "
 commit e92029c0f4e88ae3e738d83b25ef2d3c178ea082
 Author: Clemens Gruber <clemens.gruber@pqgruber.com>
 Date:   Wed Jan 20 15:43:37 2016 +0100

     env_mmc: support overriding mmc dev from board code
 "
 I discard the V1 2/4 patch in my patch set.

 This patch set depends on https://patchwork.ozlabs.org/patch/573336/

 arch/arm/cpu/armv7/mx7/soc.c              | 21 +++++++++++++++++++++
 board/freescale/mx7dsabresd/mx7dsabresd.c | 20 +++++---------------
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/arch/arm/cpu/armv7/mx7/soc.c b/arch/arm/cpu/armv7/mx7/soc.c
index ede7d53..ba6cfb9 100644
--- a/arch/arm/cpu/armv7/mx7/soc.c
+++ b/arch/arm/cpu/armv7/mx7/soc.c
@@ -388,6 +388,27 @@ enum boot_device get_boot_device(void)
 	return boot_dev;
 }
 
+#ifdef CONFIG_ENV_IS_IN_MMC
+__weak int board_mmc_get_env_dev(int devno)
+{
+	return CONFIG_SYS_MMC_ENV_DEV;
+}
+
+int mmc_get_env_dev(void)
+{
+	struct bootrom_sw_info **p =
+		(struct bootrom_sw_info **)ROM_SW_INFO_ADDR;
+	int devno = (*p)->boot_dev_instance;
+	u8 boot_type = (*p)->boot_dev_type;
+
+	/* If not boot from sd/mmc, use default value */
+	if ((boot_type != BOOT_TYPE_SD) && (boot_type != BOOT_TYPE_MMC))
+		return CONFIG_SYS_MMC_ENV_DEV;
+
+	return board_mmc_get_env_dev(devno);
+}
+#endif
+
 void s_init(void)
 {
 #if !defined CONFIG_SPL_BUILD
diff --git a/board/freescale/mx7dsabresd/mx7dsabresd.c b/board/freescale/mx7dsabresd/mx7dsabresd.c
index bbcc5bb..20e56f2 100644
--- a/board/freescale/mx7dsabresd/mx7dsabresd.c
+++ b/board/freescale/mx7dsabresd/mx7dsabresd.c
@@ -328,22 +328,12 @@ static struct fsl_esdhc_cfg usdhc_cfg[3] = {
 	{USDHC3_BASE_ADDR},
 };
 
-static int mmc_get_env_devno(void)
+int board_mmc_get_env_dev(int devno)
 {
-	struct bootrom_sw_info **p =
-		(struct bootrom_sw_info **)ROM_SW_INFO_ADDR;
+	if (devno == 2)
+		devno--;
 
-	u8 boot_type = (*p)->boot_dev_type;
-	u8 dev_no = (*p)->boot_dev_instance;
-
-	/* If not boot from sd/mmc, use default value */
-	if ((boot_type != BOOT_TYPE_SD) && (boot_type != BOOT_TYPE_MMC))
-		return CONFIG_SYS_MMC_ENV_DEV;
-
-	if (dev_no == 2)
-		dev_no--;
-
-	return dev_no;
+	return devno;
 }
 
 static int mmc_map_to_kernel_blk(int dev_no)
@@ -432,7 +422,7 @@ static void mmc_late_init(void)
 {
 	char cmd[32];
 	char mmcblk[32];
-	u32 dev_no = mmc_get_env_devno();
+	u32 dev_no = mmc_get_env_dev();
 
 	if (!check_mmc_autodetect())
 		return;
-- 
2.6.2

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

* [U-Boot] [PATCH V2 2/3] imx: mx6: implement mmc_get_env_dev
  2016-01-28  8:51 [U-Boot] [PATCH V2 1/3] imx: mx7dsabresd: move mmc_get_env_devno to soc code Peng Fan
@ 2016-01-28  8:51 ` Peng Fan
  2016-01-28  8:51 ` [U-Boot] [PATCH V2 3/3] imx: mx6: implement board_mmc_get_env_dev Peng Fan
  1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2016-01-28  8:51 UTC (permalink / raw)
  To: u-boot

From: Peng Fan <peng.fan@nxp.com>

Implement mmc_get_env_dev, devno can be got from smbr1 of SRC.
Introduce a weak function board_mmc_get_env_dev, different
boards can implement it according to different sdhc controllers
that used by the board.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
---

V2:
 Use CONFIG_ENV_IS_IN_MMC to wrap code

 arch/arm/cpu/armv7/mx6/soc.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
index ab0ccb0..80a4828 100644
--- a/arch/arm/cpu/armv7/mx6/soc.c
+++ b/arch/arm/cpu/armv7/mx6/soc.c
@@ -349,6 +349,38 @@ int arch_cpu_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_ENV_IS_IN_MMC
+__weak int board_mmc_get_env_dev(int devno)
+{
+	return CONFIG_SYS_MMC_ENV_DEV;
+}
+
+int mmc_get_env_dev(void)
+{
+	struct src *src_regs = (struct src *)SRC_BASE_ADDR;
+	u32 soc_sbmr = readl(&src_regs->sbmr1);
+	u32 bootsel;
+	int devno;
+
+	/*
+	 * Refer to
+	 * "i.MX 6Dual/6Quad Applications Processor Reference Manual"
+	 * Chapter "8.5.3.1 Expansion Device eFUSE Configuration"
+	 * i.MX6SL/SX/UL has same layout.
+	 */
+	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] */
+	devno = (soc_sbmr & 0x00001800) >> 11;
+
+	return board_mmc_get_env_dev(devno);
+}
+#endif
+
 int board_postclk_init(void)
 {
 	set_ldo_voltage(LDO_SOC, 1175);	/* Set VDDSOC to 1.175V */
-- 
2.6.2

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

* [U-Boot] [PATCH V2 3/3] imx: mx6: implement board_mmc_get_env_dev
  2016-01-28  8:51 [U-Boot] [PATCH V2 1/3] imx: mx7dsabresd: move mmc_get_env_devno to soc code Peng Fan
  2016-01-28  8:51 ` [U-Boot] [PATCH V2 2/3] imx: mx6: implement mmc_get_env_dev Peng Fan
@ 2016-01-28  8:51 ` Peng Fan
  1 sibling, 0 replies; 3+ messages in thread
From: Peng Fan @ 2016-01-28  8:51 UTC (permalink / raw)
  To: u-boot

From: Peng Fan <peng.fan@nxp.com>

Implement board_mmc_get_env_dev for the boards.

Following is examples:
SD1/SD2/SD3: return devno;
SD2/SD3: return devno - 1;
SD2/SD4: if (devno == 2), return dev - 2; return dev - 1;

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
---

V2:
 no change

 board/freescale/mx6qarm2/mx6qarm2.c         | 5 +++++
 board/freescale/mx6sabresd/mx6sabresd.c     | 5 +++++
 board/freescale/mx6slevk/mx6slevk.c         | 5 +++++
 board/freescale/mx6sxsabresd/mx6sxsabresd.c | 5 +++++
 4 files changed, 20 insertions(+)

diff --git a/board/freescale/mx6qarm2/mx6qarm2.c b/board/freescale/mx6qarm2/mx6qarm2.c
index 98ccdb7..5aae721 100644
--- a/board/freescale/mx6qarm2/mx6qarm2.c
+++ b/board/freescale/mx6qarm2/mx6qarm2.c
@@ -110,6 +110,11 @@ struct fsl_esdhc_cfg usdhc_cfg[2] = {
 	{USDHC4_BASE_ADDR},
 };
 
+int board_mmc_get_env_dev(int devno)
+{
+	return devno - 2;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
index d20953d..4af0e3e 100644
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -235,6 +235,11 @@ 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 board_mmc_get_env_dev(int devno)
+{
+	return devno - 1;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
diff --git a/board/freescale/mx6slevk/mx6slevk.c b/board/freescale/mx6slevk/mx6slevk.c
index 5eab4b5..295b781 100644
--- a/board/freescale/mx6slevk/mx6slevk.c
+++ b/board/freescale/mx6slevk/mx6slevk.c
@@ -170,6 +170,11 @@ static struct fsl_esdhc_cfg usdhc_cfg[3] = {
 	{USDHC3_BASE_ADDR, 0, 4},
 };
 
+int board_mmc_get_env_dev(int devno)
+{
+	return devno;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
diff --git a/board/freescale/mx6sxsabresd/mx6sxsabresd.c b/board/freescale/mx6sxsabresd/mx6sxsabresd.c
index 56dc020..0c664b5 100644
--- a/board/freescale/mx6sxsabresd/mx6sxsabresd.c
+++ b/board/freescale/mx6sxsabresd/mx6sxsabresd.c
@@ -313,6 +313,11 @@ 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 board_mmc_get_env_dev(int devno)
+{
+	return devno - 1;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
-- 
2.6.2

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

end of thread, other threads:[~2016-01-28  8:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-28  8:51 [U-Boot] [PATCH V2 1/3] imx: mx7dsabresd: move mmc_get_env_devno to soc code Peng Fan
2016-01-28  8:51 ` [U-Boot] [PATCH V2 2/3] imx: mx6: implement mmc_get_env_dev Peng Fan
2016-01-28  8:51 ` [U-Boot] [PATCH V2 3/3] imx: mx6: implement board_mmc_get_env_dev Peng Fan

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