public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 0/3] i.MX6 SabreSD and SabreAUTO bmode support
@ 2013-03-06 15:46 Otavio Salvador
  2013-03-06 15:46 ` [U-Boot] [PATCH v3 1/3] mx6qsabresd: Fix card detection for invalid card id case Otavio Salvador
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Otavio Salvador @ 2013-03-06 15:46 UTC (permalink / raw)
  To: u-boot


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.

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

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

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

 board/freescale/mx6qsabreauto/mx6qsabreauto.c | 17 +++++++++++++
 board/freescale/mx6qsabresd/mx6qsabresd.c     | 35 ++++++++++++++++++++++++---
 include/configs/mx6qsabre_common.h            |  2 ++
 3 files changed, 50 insertions(+), 4 deletions(-)

-- 
1.8.1

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

* [U-Boot] [PATCH v3 1/3] mx6qsabresd: Fix card detection for invalid card id case
  2013-03-06 15:46 [U-Boot] [PATCH v3 0/3] i.MX6 SabreSD and SabreAUTO bmode support Otavio Salvador
@ 2013-03-06 15:46 ` Otavio Salvador
  2013-03-13  8:10   ` Stefano Babic
  2013-03-06 15:46 ` [U-Boot] [PATCH v3 2/3] mx6qsabresd: Document the mapping of USDHC[2-4] Otavio Salvador
  2013-03-06 15:46 ` [U-Boot] [PATCH v3 3/3] mx6qsabre{sd,auto}: Add boot mode select Otavio Salvador
  2 siblings, 1 reply; 6+ messages in thread
From: Otavio Salvador @ 2013-03-06 15:46 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
Changes in v3: None
Changes in v2:
- Rework code to use a 'ret' variable (Fabio)

 board/freescale/mx6qsabresd/mx6qsabresd.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/board/freescale/mx6qsabresd/mx6qsabresd.c b/board/freescale/mx6qsabresd/mx6qsabresd.c
index 65c4a1a..e556476 100644
--- a/board/freescale/mx6qsabresd/mx6qsabresd.c
+++ b/board/freescale/mx6qsabresd/mx6qsabresd.c
@@ -145,15 +145,18 @@ 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);
 	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);
+	case USDHC4_BASE_ADDR:
+		ret = 1; /* eMMC/uSDHC4 is always present */
 	}
+
+	return ret;
 }
 
 int board_mmc_init(bd_t *bis)
-- 
1.8.1

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

* [U-Boot] [PATCH v3 2/3] mx6qsabresd: Document the mapping of USDHC[2-4]
  2013-03-06 15:46 [U-Boot] [PATCH v3 0/3] i.MX6 SabreSD and SabreAUTO bmode support Otavio Salvador
  2013-03-06 15:46 ` [U-Boot] [PATCH v3 1/3] mx6qsabresd: Fix card detection for invalid card id case Otavio Salvador
@ 2013-03-06 15:46 ` Otavio Salvador
  2013-03-06 15:46 ` [U-Boot] [PATCH v3 3/3] mx6qsabre{sd,auto}: Add boot mode select Otavio Salvador
  2 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2013-03-06 15:46 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
Changes in v3: None
Changes in v2:
- Improve commit log

 board/freescale/mx6qsabresd/mx6qsabresd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/board/freescale/mx6qsabresd/mx6qsabresd.c b/board/freescale/mx6qsabresd/mx6qsabresd.c
index e556476..3fe8bb6 100644
--- a/board/freescale/mx6qsabresd/mx6qsabresd.c
+++ b/board/freescale/mx6qsabresd/mx6qsabresd.c
@@ -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>
@@ -165,18 +166,21 @@ int board_mmc_init(bd_t *bis)
 
 	for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) {
 		switch (i) {
+		/* SD2 - mmc0 */
 		case 0:
 			imx_iomux_v3_setup_multiple_pads(
 				usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
 			gpio_direction_input(USDHC2_CD_GPIO);
 			usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
 			break;
+		/* SD3 - mmc1 */
 		case 1:
 			imx_iomux_v3_setup_multiple_pads(
 				usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
 			gpio_direction_input(USDHC3_CD_GPIO);
 			usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
 			break;
+		/* eMMC - mmc2 */
 		case 2:
 			imx_iomux_v3_setup_multiple_pads(
 				usdhc4_pads, ARRAY_SIZE(usdhc4_pads));
-- 
1.8.1

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

* [U-Boot] [PATCH v3 3/3] mx6qsabre{sd,auto}: Add boot mode select
  2013-03-06 15:46 [U-Boot] [PATCH v3 0/3] i.MX6 SabreSD and SabreAUTO bmode support Otavio Salvador
  2013-03-06 15:46 ` [U-Boot] [PATCH v3 1/3] mx6qsabresd: Fix card detection for invalid card id case Otavio Salvador
  2013-03-06 15:46 ` [U-Boot] [PATCH v3 2/3] mx6qsabresd: Document the mapping of USDHC[2-4] Otavio Salvador
@ 2013-03-06 15:46 ` Otavio Salvador
  2 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2013-03-06 15:46 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---
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 | 17 +++++++++++++++++
 board/freescale/mx6qsabresd/mx6qsabresd.c     | 20 ++++++++++++++++++++
 include/configs/mx6qsabre_common.h            |  2 ++
 3 files changed, 39 insertions(+)

diff --git a/board/freescale/mx6qsabreauto/mx6qsabreauto.c b/board/freescale/mx6qsabreauto/mx6qsabreauto.c
index 9e3700e..9650563 100644
--- a/board/freescale/mx6qsabreauto/mx6qsabreauto.c
+++ b/board/freescale/mx6qsabreauto/mx6qsabreauto.c
@@ -216,6 +216,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();
diff --git a/board/freescale/mx6qsabresd/mx6qsabresd.c b/board/freescale/mx6qsabresd/mx6qsabresd.c
index 3fe8bb6..02f2924 100644
--- a/board/freescale/mx6qsabresd/mx6qsabresd.c
+++ b/board/freescale/mx6qsabresd/mx6qsabresd.c
@@ -266,6 +266,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");
diff --git a/include/configs/mx6qsabre_common.h b/include/configs/mx6qsabre_common.h
index f7e8779..63e73a7 100644
--- a/include/configs/mx6qsabre_common.h
+++ b/include/configs/mx6qsabre_common.h
@@ -33,6 +33,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
@@ -72,6 +73,7 @@
 /* Command definition */
 #include <config_cmd_default.h>
 
+#define CONFIG_CMD_BMODE
 #define CONFIG_CMD_BOOTZ
 #undef CONFIG_CMD_IMLS
 
-- 
1.8.1

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

* [U-Boot] [PATCH v3 1/3] mx6qsabresd: Fix card detection for invalid card id case
  2013-03-06 15:46 ` [U-Boot] [PATCH v3 1/3] mx6qsabresd: Fix card detection for invalid card id case Otavio Salvador
@ 2013-03-13  8:10   ` Stefano Babic
  2013-03-13 15:10     ` Otavio Salvador
  0 siblings, 1 reply; 6+ messages in thread
From: Stefano Babic @ 2013-03-13  8:10 UTC (permalink / raw)
  To: u-boot

On 06/03/2013 16:46, Otavio Salvador wrote:
> This changes the code so in case an unkown value is passed it will
> return as invalid.
> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---

Hi Otavio,

> Changes in v3: None
> Changes in v2:
> - Rework code to use a 'ret' variable (Fabio)
> 
>  board/freescale/mx6qsabresd/mx6qsabresd.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/board/freescale/mx6qsabresd/mx6qsabresd.c b/board/freescale/mx6qsabresd/mx6qsabresd.c
> index 65c4a1a..e556476 100644
> --- a/board/freescale/mx6qsabresd/mx6qsabresd.c
> +++ b/board/freescale/mx6qsabresd/mx6qsabresd.c
> @@ -145,15 +145,18 @@ 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);

I do not understand. Is there no "break" statement here ? ret will be
overwritten then.

>  	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);
> +	case USDHC4_BASE_ADDR:
> +		ret = 1; /* eMMC/uSDHC4 is always present */
>  	}
> +
> +	return ret;
>  }
>  
>  int board_mmc_init(bd_t *bis)
> 

Best regards,
Stefano Babic

-- 
=====================================================================
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
=====================================================================

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

* [U-Boot] [PATCH v3 1/3] mx6qsabresd: Fix card detection for invalid card id case
  2013-03-13  8:10   ` Stefano Babic
@ 2013-03-13 15:10     ` Otavio Salvador
  0 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2013-03-13 15:10 UTC (permalink / raw)
  To: u-boot

On Wed, Mar 13, 2013 at 5:10 AM, Stefano Babic <sbabic@denx.de> wrote:
> On 06/03/2013 16:46, Otavio Salvador wrote:
>> This changes the code so in case an unkown value is passed it will
>> return as invalid.
>>
>> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
>> ---
>
> Hi Otavio,
>
>> Changes in v3: None
>> Changes in v2:
>> - Rework code to use a 'ret' variable (Fabio)
>>
>>  board/freescale/mx6qsabresd/mx6qsabresd.c | 11 +++++++----
>>  1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/board/freescale/mx6qsabresd/mx6qsabresd.c b/board/freescale/mx6qsabresd/mx6qsabresd.c
>> index 65c4a1a..e556476 100644
>> --- a/board/freescale/mx6qsabresd/mx6qsabresd.c
>> +++ b/board/freescale/mx6qsabresd/mx6qsabresd.c
>> @@ -145,15 +145,18 @@ 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);
>
> I do not understand. Is there no "break" statement here ? ret will be
> overwritten then.

Good catch and this will indeed fail. I did the change when Fabio
asked but did not test it. I will rework it and test, before sending
new version of patchset.

>>       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);
>> +     case USDHC4_BASE_ADDR:
>> +             ret = 1; /* eMMC/uSDHC4 is always present */
>>       }
>> +
>> +     return ret;
>>  }
>>
>>  int board_mmc_init(bd_t *bis)
>>
>
> Best regards,
> Stefano Babic
>
> --
> =====================================================================
> 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
> =====================================================================



-- 
Otavio Salvador                             O.S. Systems
E-mail: otavio at ossystems.com.br  http://www.ossystems.com.br
Mobile: +55 53 9981-7854              http://projetos.ossystems.com.br

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

end of thread, other threads:[~2013-03-13 15:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-06 15:46 [U-Boot] [PATCH v3 0/3] i.MX6 SabreSD and SabreAUTO bmode support Otavio Salvador
2013-03-06 15:46 ` [U-Boot] [PATCH v3 1/3] mx6qsabresd: Fix card detection for invalid card id case Otavio Salvador
2013-03-13  8:10   ` Stefano Babic
2013-03-13 15:10     ` Otavio Salvador
2013-03-06 15:46 ` [U-Boot] [PATCH v3 2/3] mx6qsabresd: Document the mapping of USDHC[2-4] Otavio Salvador
2013-03-06 15:46 ` [U-Boot] [PATCH v3 3/3] mx6qsabre{sd,auto}: Add boot mode select Otavio Salvador

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