Commit a5dd1efd authored by Ye Li's avatar Ye Li

MLK-18288 imx8mm_evk: Fix USDHC2 CD issue

The CD pin on SD2 socket is not connected by hardware, because this pin
is used as ALERT pin of PTN5110. So we have to use DAT3 for CD detection.

Since the USDHC driver does not support using DAT3 for CD, we have set this
port to non-removable in DTS. In SPL, we switch the pad setting of DAT3 for
CD detecting.
Signed-off-by: 's avatarYe Li <ye.li@nxp.com>
Reviewed-by: 's avatarPeng Fan <peng.fan@nxp.com>
parent 6ca671d3
......@@ -30,29 +30,12 @@ void spl_dram_init(void)
ddr_init();
}
#define USDHC2_CD_GPIO IMX_GPIO_NR(2, 12)
#define USDHC2_CD_GPIO IMX_GPIO_NR(2, 18)
#define USDHC2_PWR_GPIO IMX_GPIO_NR(2, 19)
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 = 1;
break;
case USDHC2_BASE_ADDR:
ret = !gpio_get_value(USDHC2_CD_GPIO);
return ret;
}
return 1;
}
#define USDHC_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_HYS | PAD_CTL_PUE |PAD_CTL_PE | \
PAD_CTL_FSEL2)
#define USDHC_GPIO_PAD_CTRL (PAD_CTL_PUE | PAD_CTL_PE | PAD_CTL_DSE1)
#define USDHC_GPIO_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE1)
static iomux_v3_cfg_t const usdhc3_pads[] = {
IMX8MM_PAD_NAND_WE_B_USDHC3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
......@@ -74,10 +57,21 @@ static iomux_v3_cfg_t const usdhc2_pads[] = {
IMX8MM_PAD_SD2_DATA1_USDHC2_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
IMX8MM_PAD_SD2_DATA2_USDHC2_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
IMX8MM_PAD_SD2_DATA3_USDHC2_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
IMX8MM_PAD_SD2_CD_B_GPIO2_IO12 | MUX_PAD_CTRL(USDHC_GPIO_PAD_CTRL),
IMX8MM_PAD_SD2_RESET_B_GPIO2_IO19 | MUX_PAD_CTRL(USDHC_GPIO_PAD_CTRL),
};
/*
* The evk board uses DAT3 to detect CD card plugin,
* in u-boot we mux the pin to GPIO when doing board_mmc_getcd.
*/
static iomux_v3_cfg_t const usdhc2_cd_pad =
IMX8MM_PAD_SD2_DATA3_GPIO2_IO18 | MUX_PAD_CTRL(USDHC_GPIO_PAD_CTRL);
static iomux_v3_cfg_t const usdhc2_dat3_pad =
IMX8MM_PAD_SD2_DATA3_USDHC2_DATA3 |
MUX_PAD_CTRL(USDHC_PAD_CTRL);
static struct fsl_esdhc_cfg usdhc_cfg[2] = {
{USDHC2_BASE_ADDR, 0, 1},
{USDHC3_BASE_ADDR, 0, 1},
......@@ -122,6 +116,34 @@ int board_mmc_init(bd_t *bis)
return 0;
}
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 = 1;
break;
case USDHC2_BASE_ADDR:
imx_iomux_v3_setup_pad(usdhc2_cd_pad);
gpio_request(USDHC2_CD_GPIO, "usdhc2 cd");
gpio_direction_input(USDHC2_CD_GPIO);
/*
* Since it is the DAT3 pin, this pin is pulled to
* low voltage if no card
*/
ret = gpio_get_value(USDHC2_CD_GPIO);
imx_iomux_v3_setup_pad(usdhc2_dat3_pad);
return ret;
}
return 1;
}
void spl_board_init(void)
{
/* TODO */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment