[U-Boot] [PATCH 1/3] wandboard: Add card detection for SOM MicroSD card

This add support to identify if the card is connected or not; so it does not try to communicate with the controller if no card is available.
Signed-off-by: Otavio Salvador otavio@ossystems.com.br --- arch/arm/include/asm/arch-mx6/mx6dl_pins.h | 1 + board/wandboard/wandboard.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
diff --git a/arch/arm/include/asm/arch-mx6/mx6dl_pins.h b/arch/arm/include/asm/arch-mx6/mx6dl_pins.h index 9846f1b..b8e6bf0 100644 --- a/arch/arm/include/asm/arch-mx6/mx6dl_pins.h +++ b/arch/arm/include/asm/arch-mx6/mx6dl_pins.h @@ -93,6 +93,7 @@ enum { MX6_PAD_EIM_D28__I2C1_SDA = IOMUX_PAD(0x0544, 0x0174, 1 | IOMUX_CONFIG_SION, 0x086C, 1, 0), MX6_PAD_EIM_D28__GPIO_3_28 = IOMUX_PAD(0x0544, 0x0174, 5, 0x0000, 0, 0), MX6_PAD_EIM_D29__GPIO_3_29 = IOMUX_PAD(0x0548, 0x0178, 5, 0x0000, 0, 0), + MX6_PAD_EIM_DA9__GPIO_3_9 = IOMUX_PAD(0x0590, 0x01C0, 5, 0x0000, 0, 0), MX6_PAD_ENET_MDC__ENET_MDC = IOMUX_PAD(0x05B8, 0x01E8, 1, 0x0000, 0, 0), MX6_PAD_ENET_MDIO__ENET_MDIO = IOMUX_PAD(0x05BC, 0x01EC, 1, 0x0810, 0, 0), MX6_PAD_ENET_REF_CLK__ENET_TX_CLK = IOMUX_PAD(0x05C0, 0x01F0, 1, 0x0000, 0, 0), diff --git a/board/wandboard/wandboard.c b/board/wandboard/wandboard.c index ac7b89a..a8f6ba2 100644 --- a/board/wandboard/wandboard.c +++ b/board/wandboard/wandboard.c @@ -52,6 +52,8 @@ static iomux_v3_cfg_t const uart1_pads[] = { MX6_PAD_CSI0_DAT11__UART1_RXD | MUX_PAD_CTRL(UART_PAD_CTRL), };
+#define USDHC3_CD_GPIO IMX_GPIO_NR(3, 9) + static iomux_v3_cfg_t const usdhc3_pads[] = { MX6_PAD_SD3_CLK__USDHC3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), MX6_PAD_SD3_CMD__USDHC3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), @@ -59,6 +61,8 @@ static iomux_v3_cfg_t const usdhc3_pads[] = { MX6_PAD_SD3_DAT1__USDHC3_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), MX6_PAD_SD3_DAT2__USDHC3_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), MX6_PAD_SD3_DAT3__USDHC3_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + /* SOM MicroSD Card Detect */ + MX6_PAD_EIM_DA9__GPIO_3_9 | MUX_PAD_CTRL(NO_PAD_CTRL), };
static iomux_v3_cfg_t const enet_pads[] = { @@ -100,12 +104,27 @@ static struct fsl_esdhc_cfg usdhc_cfg[1] = { {USDHC3_BASE_ADDR}, };
+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 USDHC3_BASE_ADDR: + ret = !gpio_get_value(USDHC3_CD_GPIO); + break; + } + + return ret; +} + int board_mmc_init(bd_t *bis) { imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); usdhc_cfg[0].max_bus_width = 4; + gpio_direction_input(USDHC3_CD_GPIO);
return fsl_esdhc_initialize(bis, &usdhc_cfg[0]); }

Allow use of the carrier board MicroSD card available in the Wandboard; this allow for loading alternative system from the other card for testing or upgrade proposes.
Signed-off-by: Otavio Salvador otavio@ossystems.com.br --- arch/arm/include/asm/arch-mx6/mx6dl_pins.h | 7 ++++ board/wandboard/wandboard.c | 58 ++++++++++++++++++++++++++---- include/configs/wandboard.h | 1 + 3 files changed, 59 insertions(+), 7 deletions(-)
diff --git a/arch/arm/include/asm/arch-mx6/mx6dl_pins.h b/arch/arm/include/asm/arch-mx6/mx6dl_pins.h index b8e6bf0..8cedbdc 100644 --- a/arch/arm/include/asm/arch-mx6/mx6dl_pins.h +++ b/arch/arm/include/asm/arch-mx6/mx6dl_pins.h @@ -103,6 +103,7 @@ enum { MX6_PAD_GPIO_17__GPIO_7_12 = IOMUX_PAD(0x05E8, 0x0218, 5, 0x0000, 0, 0), MX6_PAD_GPIO_18__GPIO_7_13 = IOMUX_PAD(0x05EC, 0x021C, 5, 0x0000, 0, 0), MX6_PAD_GPIO_19__GPIO_4_5 = IOMUX_PAD(0x05F0, 0x0220, 5, 0x0000, 0, 0), + MX6_PAD_GPIO_2__GPIO_1_2 = IOMUX_PAD(0x05F4, 0x0224, 5, 0x0000, 0, 0), MX6_PAD_GPIO_5__GPIO_1_5 = IOMUX_PAD(0x0600, 0x0230, 5, 0x0000, 0, 0), MX6_PAD_GPIO_5__I2C3_SCL = IOMUX_PAD(0x0600, 0x0230, 6 | IOMUX_CONFIG_SION, 0x0878, 2, 0), MX6_PAD_KEY_COL3__I2C2_SCL = IOMUX_PAD(0x0638, 0x0250, 4 | IOMUX_CONFIG_SION, 0x0870, 1, 0), @@ -135,8 +136,14 @@ enum { MX6_PAD_RGMII_TD3__ENET_RGMII_TD3 = IOMUX_PAD(0x06B8, 0x02D0, 1, 0x0000, 0, 0), MX6_PAD_RGMII_TX_CTL__RGMII_TX_CTL = IOMUX_PAD(0x06BC, 0x02D4, 1, 0x0000, 0, 0), MX6_PAD_RGMII_TXC__ENET_RGMII_TXC = IOMUX_PAD(0x06C0, 0x02D8, 1, 0x0000, 0, 0), + MX6_PAD_SD1_CLK__USDHC1_CLK = IOMUX_PAD(0x06C4, 0x02DC, 0, 0x0928, 1, 0), + MX6_PAD_SD1_CMD__USDHC1_CMD = IOMUX_PAD(0x06C8, 0x02E0, 0 | IOMUX_CONFIG_SION, 0x0000, 0, 0), MX6_PAD_SD1_CMD__GPIO_1_18 = IOMUX_PAD(0x06C8, 0x02E0, 5, 0x0000, 0, 0), MX6_PAD_SD1_DAT3__GPIO_1_21 = IOMUX_PAD(0x06D8, 0x02F0, 5, 0x0000, 0, 0), + MX6_PAD_SD1_DAT0__USDHC1_DAT0 = IOMUX_PAD(0x06CC, 0x02E4, 0, 0x0000, 0, 0), + MX6_PAD_SD1_DAT1__USDHC1_DAT1 = IOMUX_PAD(0x06D0, 0x02E8, 0, 0x0000, 0, 0), + MX6_PAD_SD1_DAT2__USDHC1_DAT2 = IOMUX_PAD(0x06D4, 0x02EC, 0, 0x0000, 0, 0), + MX6_PAD_SD1_DAT3__USDHC1_DAT3 = IOMUX_PAD(0x06D8, 0x02F0, 0, 0x0000, 0, 0), MX6_PAD_SD3_CLK__USDHC3_CLK = IOMUX_PAD(0x06F4, 0x030C, 0, 0x0934, 1, 0), MX6_PAD_SD3_CMD__USDHC3_CMD = IOMUX_PAD(0x06F8, 0x0310, 0 | IOMUX_CONFIG_SION, 0x0000, 0, 0), MX6_PAD_SD3_DAT0__USDHC3_DAT0 = IOMUX_PAD(0x06FC, 0x0314, 0, 0x0000, 0, 0), diff --git a/board/wandboard/wandboard.c b/board/wandboard/wandboard.c index a8f6ba2..5d98244 100644 --- a/board/wandboard/wandboard.c +++ b/board/wandboard/wandboard.c @@ -52,6 +52,18 @@ static iomux_v3_cfg_t const uart1_pads[] = { MX6_PAD_CSI0_DAT11__UART1_RXD | MUX_PAD_CTRL(UART_PAD_CTRL), };
+iomux_v3_cfg_t const usdhc1_pads[] = { + MX6_PAD_SD1_CLK__USDHC1_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD1_CMD__USDHC1_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD1_DAT0__USDHC1_DAT0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD1_DAT1__USDHC1_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD1_DAT2__USDHC1_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6_PAD_SD1_DAT3__USDHC1_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + /* Carrier MicroSD Card Detect */ + MX6_PAD_GPIO_2__GPIO_1_2 | MUX_PAD_CTRL(NO_PAD_CTRL), +}; + +#define USDHC1_CD_GPIO IMX_GPIO_NR(1, 2) #define USDHC3_CD_GPIO IMX_GPIO_NR(3, 9)
static iomux_v3_cfg_t const usdhc3_pads[] = { @@ -100,8 +112,9 @@ static void setup_iomux_enet(void) gpio_set_value(ETH_PHY_RESET, 1); }
-static struct fsl_esdhc_cfg usdhc_cfg[1] = { +static struct fsl_esdhc_cfg usdhc_cfg[2] = { {USDHC3_BASE_ADDR}, + {USDHC1_BASE_ADDR}, };
int board_mmc_getcd(struct mmc *mmc) @@ -110,6 +123,9 @@ int board_mmc_getcd(struct mmc *mmc) int ret = 0;
switch (cfg->esdhc_base) { + case USDHC1_BASE_ADDR: + ret = !gpio_get_value(USDHC1_CD_GPIO); + break; case USDHC3_BASE_ADDR: ret = !gpio_get_value(USDHC3_CD_GPIO); break; @@ -120,13 +136,41 @@ int board_mmc_getcd(struct mmc *mmc)
int board_mmc_init(bd_t *bis) { - imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads)); - - usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); - usdhc_cfg[0].max_bus_width = 4; - gpio_direction_input(USDHC3_CD_GPIO); + int i; + + /* + * According to the board_mmc_init() the following map is done: + * (U-boot device node) (Physical Port) + * mmc0 SOM MicroSD + * mmc1 Carrier board MicroSD + */ + for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) { + switch (i) { + case 0: + imx_iomux_v3_setup_multiple_pads( + usdhc3_pads, ARRAY_SIZE(usdhc3_pads)); + usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); + usdhc_cfg[0].max_bus_width = 4; + gpio_direction_input(USDHC3_CD_GPIO); + break; + case 1: + imx_iomux_v3_setup_multiple_pads( + usdhc1_pads, ARRAY_SIZE(usdhc1_pads)); + usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK); + usdhc_cfg[1].max_bus_width = 4; + gpio_direction_input(USDHC1_CD_GPIO); + break; + default: + printf("Warning: you configured more USDHC controllers" + "(%d) than supported by the board\n", i + 1); + return 0; + } + + if (fsl_esdhc_initialize(bis, &usdhc_cfg[i])) + printf("Warning: failed to initialize mmc dev %d\n", i); + }
- return fsl_esdhc_initialize(bis, &usdhc_cfg[0]); + return 0; }
static int mx6_rgmii_rework(struct phy_device *phydev) diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h index 120e3f6..161b400 100644 --- a/include/configs/wandboard.h +++ b/include/configs/wandboard.h @@ -57,6 +57,7 @@ /* MMC Configuration */ #define CONFIG_FSL_ESDHC #define CONFIG_FSL_USDHC +#define CONFIG_SYS_FSL_USDHC_NUM 2 #define CONFIG_SYS_FSL_ESDHC_ADDR 0
#define CONFIG_MMC

On Mon, Apr 15, 2013 at 10:35 AM, Otavio Salvador otavio@ossystems.com.br wrote:
int board_mmc_init(bd_t *bis) {
imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
usdhc_cfg[0].max_bus_width = 4;
gpio_direction_input(USDHC3_CD_GPIO);
int i;
/*
* According to the board_mmc_init() the following map is done:
* (U-boot device node) (Physical Port)
* mmc0 SOM MicroSD
* mmc1 Carrier board MicroSD
*/
for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) {
switch (i) {
case 0:
imx_iomux_v3_setup_multiple_pads(
usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
usdhc_cfg[0].max_bus_width = 4;
gpio_direction_input(USDHC3_CD_GPIO);
break;
case 1:
imx_iomux_v3_setup_multiple_pads(
usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
usdhc_cfg[1].max_bus_width = 4;
gpio_direction_input(USDHC1_CD_GPIO);
break;
default:
printf("Warning: you configured more USDHC controllers"
"(%d) than supported by the board\n", i + 1);
return 0;
This should be an error. What about return -EINVAL ?
}
if (fsl_esdhc_initialize(bis, &usdhc_cfg[i]))
printf("Warning: failed to initialize mmc dev %d\n", i);
}
return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
return 0;
With this change, you never return an error.

On Mon, Apr 15, 2013 at 10:54 AM, Fabio Estevam festevam@gmail.com wrote:
On Mon, Apr 15, 2013 at 10:35 AM, Otavio Salvador otavio@ossystems.com.br wrote:
int board_mmc_init(bd_t *bis) {
imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
usdhc_cfg[0].max_bus_width = 4;
gpio_direction_input(USDHC3_CD_GPIO);
int i;
/*
* According to the board_mmc_init() the following map is done:
* (U-boot device node) (Physical Port)
* mmc0 SOM MicroSD
* mmc1 Carrier board MicroSD
*/
for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) {
switch (i) {
case 0:
imx_iomux_v3_setup_multiple_pads(
usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
usdhc_cfg[0].max_bus_width = 4;
gpio_direction_input(USDHC3_CD_GPIO);
break;
case 1:
imx_iomux_v3_setup_multiple_pads(
usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
usdhc_cfg[1].max_bus_width = 4;
gpio_direction_input(USDHC1_CD_GPIO);
break;
default:
printf("Warning: you configured more USDHC controllers"
"(%d) than supported by the board\n", i + 1);
return 0;
This should be an error. What about return -EINVAL ?
Agreed, fixed locally.
}
if (fsl_esdhc_initialize(bis, &usdhc_cfg[i]))
printf("Warning: failed to initialize mmc dev %d\n", i);
}
return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
return 0;
With this change, you never return an error.
Should we fail if *any* fail?
-- Otavio Salvador O.S. Systems E-mail: otavio@ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br

On Mon, Apr 15, 2013 at 11:06 AM, Otavio Salvador otavio@ossystems.com.br wrote:
Should we fail if *any* fail?
Yes, I think so.

On Mon, Apr 15, 2013 at 12:00 PM, Fabio Estevam festevam@gmail.com wrote:
On Mon, Apr 15, 2013 at 11:06 AM, Otavio Salvador otavio@ossystems.com.br wrote:
Should we fail if *any* fail?
Yes, I think so.
--- a/board/wandboard/wandboard.c +++ b/board/wandboard/wandboard.c @@ -162,13 +162,15 @@ int board_mmc_init(bd_t *bis) gpio_direction_input(USDHC1_CD_GPIO); break; default: - printf("Warning: you configured more USDHC controllers" + printf("ERROR: you configured more USDHC controllers" "(%d) than supported by the board\n", i + 1); return -EINVAL; }
- if (fsl_esdhc_initialize(bis, &usdhc_cfg[i])) - printf("Warning: failed to initialize mmc dev %d\n", i); + if (fsl_esdhc_initialize(bis, &usdhc_cfg[i])) { + printf("ERROR: failed to initialize mmc dev %d\n", i); + return 1; + } }
Like this?
-- Otavio Salvador O.S. Systems E-mail: otavio@ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br

On Mon, Apr 15, 2013 at 1:18 PM, Otavio Salvador otavio@ossystems.com.br wrote:
--- a/board/wandboard/wandboard.c +++ b/board/wandboard/wandboard.c @@ -162,13 +162,15 @@ int board_mmc_init(bd_t *bis) gpio_direction_input(USDHC1_CD_GPIO); break; default:
printf("Warning: you configured more USDHC controllers"
printf("ERROR: you configured more USDHC controllers" "(%d) than supported by the board\n", i + 1); return -EINVAL; }
if (fsl_esdhc_initialize(bis, &usdhc_cfg[i]))
printf("Warning: failed to initialize mmc dev %d\n", i);
if (fsl_esdhc_initialize(bis, &usdhc_cfg[i])) {
printf("ERROR: failed to initialize mmc dev %d\n", i);
return 1;
1 is not an appropriate return value for an error.
What about doing like sabrelite? status |= fsl_esdhc_initialize(bis, &usdhc_cfg[i]);
and then you return status?

On Mon, Apr 15, 2013 at 1:40 PM, Fabio Estevam festevam@gmail.com wrote:
On Mon, Apr 15, 2013 at 1:18 PM, Otavio Salvador otavio@ossystems.com.br wrote:
--- a/board/wandboard/wandboard.c +++ b/board/wandboard/wandboard.c @@ -162,13 +162,15 @@ int board_mmc_init(bd_t *bis) gpio_direction_input(USDHC1_CD_GPIO); break; default:
printf("Warning: you configured more USDHC controllers"
printf("ERROR: you configured more USDHC controllers" "(%d) than supported by the board\n", i + 1); return -EINVAL; }
if (fsl_esdhc_initialize(bis, &usdhc_cfg[i]))
printf("Warning: failed to initialize mmc dev %d\n", i);
if (fsl_esdhc_initialize(bis, &usdhc_cfg[i])) {
printf("ERROR: failed to initialize mmc dev %d\n", i);
return 1;
1 is not an appropriate return value for an error.
What about doing like sabrelite? status |= fsl_esdhc_initialize(bis, &usdhc_cfg[i]);
and then you return status?
int board_mmc_init(bd_t *bis) { - imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads)); + int i; + int ret;
- usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); - usdhc_cfg[0].max_bus_width = 4; - gpio_direction_input(USDHC3_CD_GPIO); + /* + * According to the board_mmc_init() the following map is done: + * (U-boot device node) (Physical Port) + * mmc0 SOM MicroSD + * mmc1 Carrier board MicroSD + */ + for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) { + switch (i) { + case 0: + imx_iomux_v3_setup_multiple_pads( + usdhc3_pads, ARRAY_SIZE(usdhc3_pads)); + usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); + usdhc_cfg[0].max_bus_width = 4; + gpio_direction_input(USDHC3_CD_GPIO); + break; + case 1: + imx_iomux_v3_setup_multiple_pads( + usdhc1_pads, ARRAY_SIZE(usdhc1_pads)); + usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK); + usdhc_cfg[1].max_bus_width = 4; + gpio_direction_input(USDHC1_CD_GPIO); + break; + default: + printf("ERROR: you configured more USDHC controllers" + "(%d) than supported by the board\n", i + 1); + return -EINVAL; + } + + ret |= fsl_esdhc_initialize(bis, &usdhc_cfg[i]); + } + + if (ret) + printf("ERROR: failed to initialize mmc dev %d\n", i);
- return fsl_esdhc_initialize(bis, &usdhc_cfg[0]); + return ret; }
This would be the final patch than...
-- Otavio Salvador O.S. Systems E-mail: otavio@ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br

Dear Otavio Salvador,
In message CAP9ODKqO8V1-WYZQ4_GXRZ5DJbD2xiXw59xKOzGY0ZjsUJJjXQ@mail.gmail.com you wrote:
default:
printf("ERROR: you configured more USDHC controllers"
"(%d) than supported by the board\n", i + 1);
return -EINVAL;
}
Can you please make this a compile time test and error?
Thanks.
Wolfgang Denk

On Tue, Apr 16, 2013 at 2:36 AM, Wolfgang Denk wd@denx.de wrote:
Dear Otavio Salvador,
In message CAP9ODKqO8V1-WYZQ4_GXRZ5DJbD2xiXw59xKOzGY0ZjsUJJjXQ@mail.gmail.com you wrote:
default:
printf("ERROR: you configured more USDHC controllers"
"(%d) than supported by the board\n", i + 1);
return -EINVAL;
}
Can you please make this a compile time test and error?
I will check how to do that.
-- Otavio Salvador O.S. Systems E-mail: otavio@ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br

On Wed, Apr 17, 2013 at 7:21 PM, Otavio Salvador otavio@ossystems.com.br wrote:
On Tue, Apr 16, 2013 at 2:36 AM, Wolfgang Denk wd@denx.de wrote:
Dear Otavio Salvador,
In message CAP9ODKqO8V1-WYZQ4_GXRZ5DJbD2xiXw59xKOzGY0ZjsUJJjXQ@mail.gmail.com you wrote:
default:
printf("ERROR: you configured more USDHC controllers"
"(%d) than supported by the board\n", i + 1);
return -EINVAL;
}
Can you please make this a compile time test and error?
I will check how to do that.
I checked and it will be a much bigger change as it should be done in all boards using this so I will look at it but won't hold the patches for now.
I will send a new revision without this change and work on this.
-- Otavio Salvador O.S. Systems E-mail: otavio@ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br

Dear Otavio Salvador,
In message CAP9ODKqFSMHot7tCTuxV+c14385GGd4v0onsocd4wDGcghDzKw@mail.gmail.com you wrote:
This should be an error. What about return -EINVAL ?
Agreed, fixed locally.
To make it more clear: this should be a compile-time error, not detected at runtime.
With this change, you never return an error.
Should we fail if *any* fail?
Yes, this is the good old rule of defensive programming: as soon as you detect any kind of (critical) error, you print an error message and bail out.
Best regards,
Wolfgang Denk

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 --- board/wandboard/wandboard.c | 19 +++++++++++++++++++ include/configs/wandboard.h | 3 +++ 2 files changed, 22 insertions(+)
diff --git a/board/wandboard/wandboard.c b/board/wandboard/wandboard.c index 5d98244..e7cf4a1 100644 --- a/board/wandboard/wandboard.c +++ b/board/wandboard/wandboard.c @@ -16,6 +16,7 @@ #include <asm/arch/sys_proto.h> #include <asm/gpio.h> #include <asm/imx-common/iomux-v3.h> +#include <asm/imx-common/boot_mode.h> #include <asm/io.h> #include <asm/sizes.h> #include <common.h> @@ -225,6 +226,24 @@ int board_early_init_f(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)}, + {"mmc1", MAKE_CFGVAL(0x40, 0x20, 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 board_init(void) { /* address of boot parameters */ diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h index 161b400..4cb9f8d 100644 --- a/include/configs/wandboard.h +++ b/include/configs/wandboard.h @@ -32,6 +32,7 @@ #define CONFIG_SYS_MALLOC_LEN (3 * SZ_1M)
#define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_BOARD_LATE_INIT #define CONFIG_MXC_GPIO
#define CONFIG_MXC_UART @@ -47,6 +48,8 @@
#undef CONFIG_CMD_IMLS
+#define CONFIG_CMD_BMODE + #define CONFIG_BOOTDELAY 5
#define CONFIG_SYS_MEMTEST_START 0x10000000
participants (3)
-
Fabio Estevam
-
Otavio Salvador
-
Wolfgang Denk