Skip to contentSkip to conversation

imx: mx7dsabresd: move mmc_get_env_devno to soc code

PATCH New Peng Fan 3 participants 7 messages Dec 17, 2015 – Feb 4, 2016 Arm (32-bit)

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH v2 1/4 imx: mx7dsabresd: move mmc_get_env_devno to soc code

Move mmc_get_env_devno to soc.c
Introduce a weak function board_mmc_get_env_devno. Different boards can implement this according to sdhc controller which is used by the board.

Cc Stefano Babic <[email protected]>

---

Changes V2:
new patch. mx7dsabresd implemented mmc_get_env_devno. So need to refactor it for patch 2/4

 arch/arm/cpu/armv7/mx7/soc.c              | 19 +++++++++++++++++++
 board/freescale/mx7dsabresd/mx7dsabresd.c | 18 ++++--------------
 2 files changed, 23 insertions(+), 14 deletions(-)
arch/arm/cpu/armv7/mx7/soc.c +19 -0
index c777922..d0891ea 100644
@@ -268,6 +268,25 @@ enum boot_device get_boot_device(void)
 	return boot_dev;
 }
 
+__weak int board_mmc_get_env_devno(int devno)
+{
+	return CONFIG_SYS_MMC_ENV_DEV;
+}
+
+int mmc_get_env_devno(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_devno(devno);
+}
+
 void s_init(void)
 {
 #if !defined CONFIG_SPL_BUILD
board/freescale/mx7dsabresd/mx7dsabresd.c +4 -14
index f8ae973..12327c2 100644
@@ -293,22 +293,12 @@ static struct fsl_esdhc_cfg usdhc_cfg[3] = {
 	{USDHC3_BASE_ADDR},
 };
 
-static int mmc_get_env_devno(void)
+int board_mmc_get_env_devno(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)
Signature · 1 line
2.6.2
author
#1 lore raw

PATCH v2 2/4 common: env_mmc: support loading env from different cards

Some boards support booting from different SD card slots. For example, mx6dpsabresd board supports booting from SD2, SD3, EMMC4, using different boot switch. And the index numbers are SD2(0), SD3(1), EMMC4(2).
But CONFIG_SYS_MMC_ENV_DEV is hardcoded to 1(for SD3), so when booting from SD2(using 0), uboot complains "MMC: no card present", since there is no card in SD3 slot.

This patch introduces a weak function which still returns CONFIG_SYS_MMC_ENV_DEV to avoid break other boards. Then different boards can implement mmc_get_env_devno to read env from the correct sd/emmc.

Cc Stefano Babic <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tim Harvey <[email protected]>
Cc Hans de Goede <[email protected]>

---

Changes V2:
none.

 common/env_mmc.c | 22 ++++++++++++++--------
 include/mmc.h    |  1 +
 2 files changed, 15 insertions(+), 8 deletions(-)
common/env_mmc.c +14 -8
index 9639822..857e20c 100644
@@ -63,6 +63,11 @@ int env_init(void)
 	return 0;
 }
 
+__weak int mmc_get_env_devno(void)
+{
+	return CONFIG_SYS_MMC_ENV_DEV;
+}
+
 #ifdef CONFIG_SYS_MMC_ENV_PART
 __weak uint mmc_get_env_part(struct mmc *mmc)
 {
@@ -72,7 +77,7 @@ __weak uint mmc_get_env_part(struct mmc *mmc)
 static int mmc_set_env_part(struct mmc *mmc)
 {
 	uint part = mmc_get_env_part(mmc);
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 	int ret = 0;
 
 #ifdef CONFIG_SPL_BUILD
@@ -108,7 +113,7 @@ static const char *init_mmc_for_env(struct mmc *mmc)
 static void fini_mmc_for_env(struct mmc *mmc)
 {
 #ifdef CONFIG_SYS_MMC_ENV_PART
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 
 #ifdef CONFIG_SPL_BUILD
 	dev = 0;
@@ -127,7 +132,7 @@ static inline int write_env(struct mmc *mmc, unsigned long size,
 	blk_start	= ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
 	blk_cnt		= ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
 
-	n = mmc->block_dev.block_write(CONFIG_SYS_MMC_ENV_DEV, blk_start,
+	n = mmc->block_dev.block_write(mmc_get_env_devno(), blk_start,
 					blk_cnt, (u_char *)buffer);
 
 	return (n == blk_cnt) ? 0 : -1;
@@ -140,7 +145,8 @@ static unsigned char env_flags;
 int saveenv(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
-	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
+	int mmc_env_devno = mmc_get_env_devno();
+	struct mmc *mmc = find_mmc_device(mmc_env_devno);
 	u32	offset;
 	int	ret, copy = 0;
 	const char *errmsg;
@@ -168,7 +174,7 @@ int saveenv(void)
 	}
 
 	printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "",
-	       CONFIG_SYS_MMC_ENV_DEV);
+	       mmc_env_devno);
 	if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) {
 		puts("failed\n");
 		ret = 1;
@@ -192,7 +198,7 @@ static inline int read_env(struct mmc *mmc, unsigned long size,
 			   unsigned long offset, const void *buffer)
 {
 	uint blk_start, blk_cnt, n;
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 
 #ifdef CONFIG_SPL_BUILD
 	dev = 0;
@@ -216,7 +222,7 @@ void env_relocate_spec(void)
 	int crc1_ok = 0, crc2_ok = 0;
 	env_t *ep;
 	int ret;
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 	const char *errmsg = NULL;
 
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1);
@@ -302,7 +308,7 @@ void env_relocate_spec(void)
 	struct mmc *mmc;
 	u32 offset;
 	int ret;
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 	const char *errmsg;
 
 #ifdef CONFIG_SPL_BUILD
include/mmc.h +1 -0
index cda9a19..e70aedb 100644
@@ -475,6 +475,7 @@ void board_mmc_power_init(void);
 int board_mmc_init(bd_t *bis);
 int cpu_mmc_init(bd_t *bis);
 int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
+int mmc_get_env_devno(void);
 
 struct pci_device_id;
 
Signature · 1 line
2.6.2
#2 lore raw

PATCH v2 2/4 common: env_mmc: support loading env from different cards

Hi Peng,

Quoted 13 lines · Peng Fan

Some boards support booting from different SD card slots. For example, mx6dpsabresd board supports booting from SD2, SD3, EMMC4, using different boot switch. And the index numbers are SD2(0), SD3(1), EMMC4(2).
But CONFIG_SYS_MMC_ENV_DEV is hardcoded to 1(for SD3), so when booting from SD2(using 0), uboot complains "MMC: no card present", since there is no card in SD3 slot.

This patch introduces a weak function which still returns CONFIG_SYS_MMC_ENV_DEV to avoid break other boards. Then different boards can implement mmc_get_env_devno to read env from the correct sd/emmc.

Quoted 7 lines
Cc Stefano Babic <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tim Harvey <[email protected]>
Cc Hans de Goede <[email protected]>

---

Tom sets this patch as deferred - then applying the rest of the series makes no sense. Patchset should be rechecked later after next release.

Best regards,
Stefano Babic

Quoted 109 lines

Changes V2:
none.

 common/env_mmc.c | 22 ++++++++++++++--------
 include/mmc.h    |  1 +
 2 files changed, 15 insertions(+), 8 deletions(-)
common/env_mmc.c +14 -8
index 9639822..857e20c 100644
@@ -63,6 +63,11 @@ int env_init(void)
 	return 0;
 }
 
+__weak int mmc_get_env_devno(void)
+{
+	return CONFIG_SYS_MMC_ENV_DEV;
+}
+
 #ifdef CONFIG_SYS_MMC_ENV_PART
 __weak uint mmc_get_env_part(struct mmc *mmc)
 {
@@ -72,7 +77,7 @@ __weak uint mmc_get_env_part(struct mmc *mmc)
 static int mmc_set_env_part(struct mmc *mmc)
 {
 	uint part = mmc_get_env_part(mmc);
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 	int ret = 0;
 
 #ifdef CONFIG_SPL_BUILD
@@ -108,7 +113,7 @@ static const char *init_mmc_for_env(struct mmc *mmc)
 static void fini_mmc_for_env(struct mmc *mmc)
 {
 #ifdef CONFIG_SYS_MMC_ENV_PART
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 
 #ifdef CONFIG_SPL_BUILD
 	dev = 0;
@@ -127,7 +132,7 @@ static inline int write_env(struct mmc *mmc, unsigned long size,
 	blk_start	= ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
 	blk_cnt		= ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
 
-	n = mmc->block_dev.block_write(CONFIG_SYS_MMC_ENV_DEV, blk_start,
+	n = mmc->block_dev.block_write(mmc_get_env_devno(), blk_start,
 					blk_cnt, (u_char *)buffer);
 
 	return (n == blk_cnt) ? 0 : -1;
@@ -140,7 +145,8 @@ static unsigned char env_flags;
 int saveenv(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
-	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
+	int mmc_env_devno = mmc_get_env_devno();
+	struct mmc *mmc = find_mmc_device(mmc_env_devno);
 	u32	offset;
 	int	ret, copy = 0;
 	const char *errmsg;
@@ -168,7 +174,7 @@ int saveenv(void)
 	}
 
 	printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "",
-	       CONFIG_SYS_MMC_ENV_DEV);
+	       mmc_env_devno);
 	if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) {
 		puts("failed\n");
 		ret = 1;
@@ -192,7 +198,7 @@ static inline int read_env(struct mmc *mmc, unsigned long size,
 			   unsigned long offset, const void *buffer)
 {
 	uint blk_start, blk_cnt, n;
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 
 #ifdef CONFIG_SPL_BUILD
 	dev = 0;
@@ -216,7 +222,7 @@ void env_relocate_spec(void)
 	int crc1_ok = 0, crc2_ok = 0;
 	env_t *ep;
 	int ret;
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 	const char *errmsg = NULL;
 
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1);
@@ -302,7 +308,7 @@ void env_relocate_spec(void)
 	struct mmc *mmc;
 	u32 offset;
 	int ret;
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 	const char *errmsg;
 
 #ifdef CONFIG_SPL_BUILD
include/mmc.h +1 -0
index cda9a19..e70aedb 100644
@@ -475,6 +475,7 @@ void board_mmc_power_init(void);
 int board_mmc_init(bd_t *bis);
 int cpu_mmc_init(bd_t *bis);
 int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
+int mmc_get_env_devno(void);
 
 struct pci_device_id;
 
Signature · 5 lines
=====================================================================
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
=====================================================================
#3 lore raw

PATCH v2 2/4 common: env_mmc: support loading env from different cards

Hi Stefano,

Quoted 24 lines · Stefano Babic

Hi Peng,

Quoted 13 lines · Peng Fan

Some boards support booting from different SD card slots. For example, mx6dpsabresd board supports booting from SD2, SD3, EMMC4, using different boot switch. And the index numbers are SD2(0), SD3(1), EMMC4(2).
But CONFIG_SYS_MMC_ENV_DEV is hardcoded to 1(for SD3), so when booting from SD2(using 0), uboot complains "MMC: no card present", since there is no card in SD3 slot.

This patch introduces a weak function which still returns CONFIG_SYS_MMC_ENV_DEV to avoid break other boards. Then different boards can implement mmc_get_env_devno to read env from the correct sd/emmc.

Quoted 7 lines
Cc Stefano Babic <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tim Harvey <[email protected]>
Cc Hans de Goede <[email protected]>

---

Quoted 2 lines

Tom sets this patch as deferred - then applying the rest of the series makes no sense. Patchset should be rechecked later after next release.

Could you please check these three patches. I may missed to use V3, but still used V2. The three patches are new for the env no.

https://patchwork.ozlabs.org/patch/574586/
https://patchwork.ozlabs.org/patch/574587/
https://patchwork.ozlabs.org/patch/574588/

Thanks,
Peng

Quoted 123 lines

Best regards,
Stefano Babic

Quoted 109 lines

Changes V2:
none.

 common/env_mmc.c | 22 ++++++++++++++--------
 include/mmc.h    |  1 +
 2 files changed, 15 insertions(+), 8 deletions(-)
common/env_mmc.c +14 -8
index 9639822..857e20c 100644
@@ -63,6 +63,11 @@ int env_init(void)
 	return 0;
 }
 
+__weak int mmc_get_env_devno(void)
+{
+	return CONFIG_SYS_MMC_ENV_DEV;
+}
+
 #ifdef CONFIG_SYS_MMC_ENV_PART
 __weak uint mmc_get_env_part(struct mmc *mmc)
 {
@@ -72,7 +77,7 @@ __weak uint mmc_get_env_part(struct mmc *mmc)
 static int mmc_set_env_part(struct mmc *mmc)
 {
 	uint part = mmc_get_env_part(mmc);
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 	int ret = 0;
 
 #ifdef CONFIG_SPL_BUILD
@@ -108,7 +113,7 @@ static const char *init_mmc_for_env(struct mmc *mmc)
 static void fini_mmc_for_env(struct mmc *mmc)
 {
 #ifdef CONFIG_SYS_MMC_ENV_PART
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 
 #ifdef CONFIG_SPL_BUILD
 	dev = 0;
@@ -127,7 +132,7 @@ static inline int write_env(struct mmc *mmc, unsigned long size,
 	blk_start	= ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len;
 	blk_cnt		= ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
 
-	n = mmc->block_dev.block_write(CONFIG_SYS_MMC_ENV_DEV, blk_start,
+	n = mmc->block_dev.block_write(mmc_get_env_devno(), blk_start,
 					blk_cnt, (u_char *)buffer);
 
 	return (n == blk_cnt) ? 0 : -1;
@@ -140,7 +145,8 @@ static unsigned char env_flags;
 int saveenv(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
-	struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV);
+	int mmc_env_devno = mmc_get_env_devno();
+	struct mmc *mmc = find_mmc_device(mmc_env_devno);
 	u32	offset;
 	int	ret, copy = 0;
 	const char *errmsg;
@@ -168,7 +174,7 @@ int saveenv(void)
 	}
 
 	printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "",
-	       CONFIG_SYS_MMC_ENV_DEV);
+	       mmc_env_devno);
 	if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) {
 		puts("failed\n");
 		ret = 1;
@@ -192,7 +198,7 @@ static inline int read_env(struct mmc *mmc, unsigned long size,
 			   unsigned long offset, const void *buffer)
 {
 	uint blk_start, blk_cnt, n;
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 
 #ifdef CONFIG_SPL_BUILD
 	dev = 0;
@@ -216,7 +222,7 @@ void env_relocate_spec(void)
 	int crc1_ok = 0, crc2_ok = 0;
 	env_t *ep;
 	int ret;
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 	const char *errmsg = NULL;
 
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, tmp_env1, 1);
@@ -302,7 +308,7 @@ void env_relocate_spec(void)
 	struct mmc *mmc;
 	u32 offset;
 	int ret;
-	int dev = CONFIG_SYS_MMC_ENV_DEV;
+	int dev = mmc_get_env_devno();
 	const char *errmsg;
 
 #ifdef CONFIG_SPL_BUILD
include/mmc.h +1 -0
index cda9a19..e70aedb 100644
@@ -475,6 +475,7 @@ void board_mmc_power_init(void);
 int board_mmc_init(bd_t *bis);
 int cpu_mmc_init(bd_t *bis);
 int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr);
+int mmc_get_env_devno(void);
 
 struct pci_device_id;
 
Signature · 9 lines
=====================================================================
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
=====================================================================
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
#4 lore raw

PATCH v2 2/4 common: env_mmc: support loading env from different cards

Hi Peng,

Quoted 30 lines · Peng Fan

Hi Stefano,

Quoted 24 lines · Stefano Babic

Hi Peng,

Quoted 13 lines · Peng Fan

Some boards support booting from different SD card slots. For example, mx6dpsabresd board supports booting from SD2, SD3, EMMC4, using different boot switch. And the index numbers are SD2(0), SD3(1), EMMC4(2).
But CONFIG_SYS_MMC_ENV_DEV is hardcoded to 1(for SD3), so when booting from SD2(using 0), uboot complains "MMC: no card present", since there is no card in SD3 slot.

This patch introduces a weak function which still returns CONFIG_SYS_MMC_ENV_DEV to avoid break other boards. Then different boards can implement mmc_get_env_devno to read env from the correct sd/emmc.

Quoted 7 lines
Cc Stefano Babic <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tim Harvey <[email protected]>
Cc Hans de Goede <[email protected]>

---

Quoted 2 lines

Tom sets this patch as deferred - then applying the rest of the series makes no sense. Patchset should be rechecked later after next release.

Quoted 7 lines

Could you please check these three patches. I may missed to use V3, but still used V2. The three patches are new for the env no.

https://patchwork.ozlabs.org/patch/574586/
https://patchwork.ozlabs.org/patch/574587/
https://patchwork.ozlabs.org/patch/574588/

I have not tested, but they looks fine - I am picking them up before my PR.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
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
=====================================================================
author
#5 lore raw

PATCH v2 3/4 imx: mx6: implement mmc_get_env_devno

In reply to Peng Fan

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

Cc Stefano Babic <[email protected]>

---

Changes V2:
move mmc_get_env_devno into soc.c

 arch/arm/cpu/armv7/mx6/soc.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
arch/arm/cpu/armv7/mx6/soc.c +30 -0
index bf5ae8c..fd383f2 100644
@@ -349,6 +349,36 @@ int arch_cpu_init(void)
 	return 0;
 }
 
+__weak int board_mmc_get_env_devno(int devno)
+{
+	return CONFIG_SYS_MMC_ENV_DEV;
+}
+
+int mmc_get_env_devno(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_devno(devno);
+}
+
 int board_postclk_init(void)
 {
 	set_ldo_voltage(LDO_SOC, 1175);	/* Set VDDSOC to 1.175V */
Signature · 1 line
2.6.2
author
#6 lore raw

PATCH v2 4/4 imx: mx6: implement board_mmc_get_env_devno

In reply to Peng Fan

Implement board_mmc_get_env_devno 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;

Cc Stefano Babic <[email protected]>

---

Changes V2:
implement board_mmc_get_env_devno in different board files.

 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(+)
board/freescale/mx6qarm2/mx6qarm2.c +5 -0
index 98ccdb7..aa87ba9 100644
@@ -110,6 +110,11 @@ struct fsl_esdhc_cfg usdhc_cfg[2] = {
 	{USDHC4_BASE_ADDR},
 };
 
+int board_mmc_get_env_devno(int devno)
+{
+	return devno - 2;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
board/freescale/mx6sabresd/mx6sabresd.c +5 -0
index 581c9d5..6128462 100644
@@ -234,6 +234,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_devno(int devno)
+{
+	return devno - 1;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
board/freescale/mx6slevk/mx6slevk.c +5 -0
index 5eab4b5..84573f5 100644
@@ -170,6 +170,11 @@ static struct fsl_esdhc_cfg usdhc_cfg[3] = {
 	{USDHC3_BASE_ADDR, 0, 4},
 };
 
+int board_mmc_get_env_devno(int devno)
+{
+	return devno;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
board/freescale/mx6sxsabresd/mx6sxsabresd.c +5 -0
index 3ee4662..78f0151 100644
@@ -309,6 +309,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_devno(int devno)
+{
+	return devno - 1;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
Signature · 1 line
2.6.2