]> git.sur5r.net Git - u-boot/commitdiff
ot1200: add support for usdhc4
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Thu, 23 Oct 2014 11:46:42 +0000 (13:46 +0200)
committerStefano Babic <sbabic@denx.de>
Thu, 30 Oct 2014 09:46:28 +0000 (10:46 +0100)
On the 'mr' variant switching to 'mmc dev 1' will result
in "MMC: no card present".

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
board/bachmann/ot1200/ot1200.c

index a2fb3cf63c031fb18dafde12130f31c25710ec52..45d761ff39ce01ebba6d5c2664dcb630f6fdcd01 100644 (file)
@@ -141,23 +141,67 @@ static iomux_v3_cfg_t const usdhc3_pads[] = {
        MX6_PAD_SD3_RST__SD3_RESET | MUX_PAD_CTRL(USDHC_PAD_CTRL),
 };
 
+iomux_v3_cfg_t const usdhc4_pads[] = {
+       MX6_PAD_SD4_CLK__SD4_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD4_CMD__SD4_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD4_DAT0__SD4_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD4_DAT1__SD4_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD4_DAT2__SD4_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+       MX6_PAD_SD4_DAT3__SD4_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+};
+
 int board_mmc_getcd(struct mmc *mmc)
 {
-       return 1;
+       struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
+       int ret;
+
+       if (cfg->esdhc_base == USDHC3_BASE_ADDR)
+               ret = 1;
+       else {
+               gpio_direction_input(IMX_GPIO_NR(1, 4));
+               ret = !gpio_get_value(IMX_GPIO_NR(1, 4));
+       }
+
+       return ret;
 }
 
-struct fsl_esdhc_cfg usdhc_cfg[] = {
+struct fsl_esdhc_cfg usdhc_cfg[2] = {
        {USDHC3_BASE_ADDR},
+       {USDHC4_BASE_ADDR},
 };
 
 int board_mmc_init(bd_t *bis)
 {
+       s32 status = 0;
+       u32 index = 0;
+
        usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
-       usdhc_cfg[0].max_bus_width = 8;
+       usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK);
 
-       imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
+       usdhc_cfg[0].max_bus_width = 8;
+       usdhc_cfg[1].max_bus_width = 4;
+
+       for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) {
+               switch (index) {
+               case 0:
+                       imx_iomux_v3_setup_multiple_pads(
+                               usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
+                       break;
+               case 1:
+                       imx_iomux_v3_setup_multiple_pads(
+                               usdhc4_pads, ARRAY_SIZE(usdhc4_pads));
+                       break;
+               default:
+                       printf("Warning: you configured more USDHC controllers"
+                               "(%d) then supported by the board (%d)\n",
+                               index + 1, CONFIG_SYS_FSL_USDHC_NUM);
+                       return status;
+               }
+
+               status |= fsl_esdhc_initialize(bis, &usdhc_cfg[index]);
+       }
 
-       return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
+       return status;
 }
 
 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)