Skip to contentSkip to conversation

i.MX6 SabreSD and SabreAUTO bmode support

PATCH New Otavio Salvador 2 participants 7 messages Mar 16, 2013 – Apr 3, 2013

lore
Share & tools
lore
#0 lore raw

v5 cover i.MX6 SabreSD and SabreAUTO bmode support

This adds the bmode support for i.MX6 SabreSD and SabreAUTO boards. This allows user to choose the boot mode at runtime making it easy to boot from USB or other media.

This patchset has been tested in SabreSD but only build tested in SabreAUTO as I don't have the board for testing.

Changes in v5:
- Improve comment in code for easier understanding (Fabio)
- Fix build failure in SabreAUTO
- Move include of boot_mode.h header to this patch

Changes in v4:
- Fix switch code to proper break (Stefano)

Changes in v3:
- Drop change in bootdelay; the change where done by me while testing it and I mistakenly included it.

Changes in v2:
- Improve commit log
- Rework code to use a 'ret' variable (Fabio)

Otavio Salvador (3):
mx6qsabresd: Document the mapping of USDHC[2-4]
mx6qsabresd: Fix card detection for invalid card id case mx6qsabre{sd,auto}: Add boot mode select

 board/freescale/mx6qsabreauto/mx6qsabreauto.c | 18 +++++++++++
 board/freescale/mx6qsabresd/mx6qsabresd.c     | 43 ++++++++++++++++++++++++---
 include/configs/mx6qsabre_common.h            |  2 ++
 3 files changed, 59 insertions(+), 4 deletions(-)
Signature · 1 line
1.8.1
#1 lore raw

PATCH v5 1/3 mx6qsabresd: Document the mapping of USDHC[2-4]

This documents the SD card identifier so it is easier for user to spot which card number will be used, if need.

---
Changes in v5:
- Improve comment in code for easier understanding (Fabio)

Changes in v4: None
Changes in v3: None
Changes in v2:
- Improve commit log

 board/freescale/mx6qsabresd/mx6qsabresd.c | 7 +++++++
 1 file changed, 7 insertions(+)
board/freescale/mx6qsabresd/mx6qsabresd.c +7 -0
index 2b3926a..5ebbff3 100644
@@ -160,6 +160,13 @@ int board_mmc_init(bd_t *bis)
 {
 	int i;
 
+	/*
+	 * According to the board_mmc_init() the following map is done:
+	 * (U-boot device node)    (Physical Port)
+	 * mmc0                    SD2
+	 * mmc1                    SD3
+	 * mmc2                    eMMC
+	 */
 	for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) {
 		switch (i) {
 		case 0:
Signature · 1 line
1.8.1
#2 lore raw

PATCH v5 1/3 mx6qsabresd: Document the mapping of USDHC[2-4]

Quoted 5 lines · Otavio Salvador

This documents the SD card identifier so it is easier for user to spot which card number will be used, if need.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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 v5 2/3 mx6qsabresd: Fix card detection for invalid card id case

In reply to Otavio Salvador

This changes the code so in case an unkown value is passed it will return as invalid.

---
Changes in v5: None
Changes in v4:
- Fix switch code to proper break (Stefano)

Changes in v3: None
Changes in v2:
- Rework code to use a 'ret' variable (Fabio)

 board/freescale/mx6qsabresd/mx6qsabresd.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
board/freescale/mx6qsabresd/mx6qsabresd.c +10 -4
index 5ebbff3..d3019e9 100644
@@ -145,15 +145,21 @@ struct fsl_esdhc_cfg usdhc_cfg[3] = {
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
+	int ret = 0;
 
 	switch (cfg->esdhc_base) {
 	case USDHC2_BASE_ADDR:
-		return !gpio_get_value(USDHC2_CD_GPIO);
+		ret = !gpio_get_value(USDHC2_CD_GPIO);
+		break;
 	case USDHC3_BASE_ADDR:
-		return !gpio_get_value(USDHC3_CD_GPIO);
-	default:
-		return 1; /* eMMC/uSDHC4 is always present */
+		ret = !gpio_get_value(USDHC3_CD_GPIO);
+		break;
+	case USDHC4_BASE_ADDR:
+		ret = 1; /* eMMC/uSDHC4 is always present */
+		break;
 	}
+
+	return ret;
 }
 
 int board_mmc_init(bd_t *bis)
Signature · 1 line
1.8.1
#4 lore raw

PATCH v5 2/3 mx6qsabresd: Fix card detection for invalid card id case

Quoted 5 lines · Otavio Salvador

This changes the code so in case an unkown value is passed it will return as invalid.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
=====================================================================
#5 lore raw

PATCH v5 3/3 mx6qsabre{sd,auto}: Add boot mode select

In reply to Otavio Salvador

Adds support for 'bmode' command which let user to choose where to boot from; this allows U-Boot to load system from another storage without messing with jumpers.

---
Changes in v5:
- Fix build failure in SabreAUTO
- Move include of boot_mode.h header to this patch

Changes in v4: None
Changes in v3:
- Drop change in bootdelay; the change where done by me while testing it and I mistakenly included it.

Changes in v2: None

 board/freescale/mx6qsabreauto/mx6qsabreauto.c | 18 ++++++++++++++++++
 board/freescale/mx6qsabresd/mx6qsabresd.c     | 22 ++++++++++++++++++++++
 include/configs/mx6qsabre_common.h            |  2 ++
 3 files changed, 42 insertions(+)
board/freescale/mx6qsabreauto/mx6qsabreauto.c +18 -0
index 91cc007..aec3286 100644
@@ -26,6 +26,7 @@
 #include <asm/errno.h>
 #include <asm/gpio.h>
 #include <asm/imx-common/iomux-v3.h>
+#include <asm/imx-common/boot_mode.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
 #include <miiphy.h>
@@ -216,6 +217,23 @@ int board_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_CMD_BMODE
+static const struct boot_mode board_boot_modes[] = {
+	/* 4 bit bus width */
+	{"mmc0", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)},
+	{NULL,   0},
+};
+#endif
+
+int board_late_init(void)
+{
+#ifdef CONFIG_CMD_BMODE
+	add_board_boot_modes(board_boot_modes);
+#endif
+
+	return 0;
+}
+
 int checkboard(void)
 {
 	int rev = mx6sabre_rev();
board/freescale/mx6qsabresd/mx6qsabresd.c +22 -0
index d3019e9..73ab448 100644
@@ -26,10 +26,12 @@
 #include <asm/errno.h>
 #include <asm/gpio.h>
 #include <asm/imx-common/iomux-v3.h>
+#include <asm/imx-common/boot_mode.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
 #include <miiphy.h>
 #include <netdev.h>
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #define UART_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |            \
@@ -272,6 +274,26 @@ int board_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_CMD_BMODE
+static const struct boot_mode board_boot_modes[] = {
+	/* 4 bit bus width */
+	{"sd2",	 MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)},
+	{"sd3",	 MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)},
+	/* 8 bit bus width */
+	{"emmc", MAKE_CFGVAL(0x40, 0x38, 0x00, 0x00)},
+	{NULL,	 0},
+};
+#endif
+
+int board_late_init(void)
+{
+#ifdef CONFIG_CMD_BMODE
+	add_board_boot_modes(board_boot_modes);
+#endif
+
+	return 0;
+}
+
 int checkboard(void)
 {
 	puts("Board: MX6Q-SabreSD\n");
include/configs/mx6qsabre_common.h +2 -0
index 9eda9ed..0965b8f 100644
@@ -36,6 +36,7 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 2 * 1024 * 1024)
 
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_BOARD_LATE_INIT
 #define CONFIG_MXC_GPIO
 
 #define CONFIG_MXC_UART
@@ -75,6 +76,7 @@
 /* Command definition */
 #include <config_cmd_default.h>
 
+#define CONFIG_CMD_BMODE
 #define CONFIG_CMD_BOOTZ
 #undef CONFIG_CMD_IMLS
 
Signature · 1 line
1.8.1
#6 lore raw

PATCH v5 3/3 mx6qsabre{sd, auto}: Add boot mode select

Quoted 6 lines · Otavio Salvador

Adds support for 'bmode' command which let user to choose where to boot from; this allows U-Boot to load system from another storage without messing with jumpers.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
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
=====================================================================