Skip to content
Snippets Groups Projects
Commit 90bc2bf2 authored by Marek Vasut's avatar Marek Vasut Committed by Stefano Babic
Browse files

mxs: mmc: Allow overriding default card detect implementation


Some MXS based boards do not implement the card-detect signal. Allow
user to specify alternate card-detect implementation.

Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Cc: Otavio Salvador <otavio@ossystems.com.br>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
parent 8000d8a8
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ int mxs_wait_mask_clr(struct mxs_register_32 *reg, ...@@ -31,7 +31,7 @@ int mxs_wait_mask_clr(struct mxs_register_32 *reg,
uint32_t mask, uint32_t mask,
unsigned int timeout); unsigned int timeout);
int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int)); int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int));
#ifdef CONFIG_SPL_BUILD #ifdef CONFIG_SPL_BUILD
......
...@@ -69,7 +69,7 @@ int board_init(void) ...@@ -69,7 +69,7 @@ int board_init(void)
#ifdef CONFIG_CMD_MMC #ifdef CONFIG_CMD_MMC
int board_mmc_init(bd_t *bis) int board_mmc_init(bd_t *bis)
{ {
return mxsmmc_initialize(bis, 0, NULL); return mxsmmc_initialize(bis, 0, NULL, NULL);
} }
#endif #endif
......
...@@ -93,7 +93,7 @@ int board_mmc_init(bd_t *bis) ...@@ -93,7 +93,7 @@ int board_mmc_init(bd_t *bis)
/* Turn on the power to the card. */ /* Turn on the power to the card. */
gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0); gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0);
return mxsmmc_initialize(bis, 0, m28_mmc_wp); return mxsmmc_initialize(bis, 0, m28_mmc_wp, NULL);
} }
#endif #endif
......
...@@ -94,7 +94,7 @@ int board_mmc_init(bd_t *bis) ...@@ -94,7 +94,7 @@ int board_mmc_init(bd_t *bis)
/* Configure MMC0 Power Enable */ /* Configure MMC0 Power Enable */
gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0); gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0);
return mxsmmc_initialize(bis, 0, mx28evk_mmc_wp); return mxsmmc_initialize(bis, 0, mx28evk_mmc_wp, NULL);
} }
#endif #endif
......
...@@ -78,7 +78,7 @@ int dram_init(void) ...@@ -78,7 +78,7 @@ int dram_init(void)
#ifdef CONFIG_CMD_MMC #ifdef CONFIG_CMD_MMC
int board_mmc_init(bd_t *bis) int board_mmc_init(bd_t *bis)
{ {
return mxsmmc_initialize(bis, 0, NULL); return mxsmmc_initialize(bis, 0, NULL, NULL);
} }
#endif #endif
......
...@@ -49,12 +49,23 @@ struct mxsmmc_priv { ...@@ -49,12 +49,23 @@ struct mxsmmc_priv {
struct mxs_ssp_regs *regs; struct mxs_ssp_regs *regs;
uint32_t buswidth; uint32_t buswidth;
int (*mmc_is_wp)(int); int (*mmc_is_wp)(int);
int (*mmc_cd)(int);
struct mxs_dma_desc *desc; struct mxs_dma_desc *desc;
}; };
#define MXSMMC_MAX_TIMEOUT 10000 #define MXSMMC_MAX_TIMEOUT 10000
#define MXSMMC_SMALL_TRANSFER 512 #define MXSMMC_SMALL_TRANSFER 512
static int mxsmmc_cd(struct mxsmmc_priv *priv)
{
struct mxs_ssp_regs *ssp_regs = priv->regs;
if (priv->mmc_cd)
return priv->mmc_cd(priv->id);
return !(readl(&ssp_regs->hw_ssp_status) & SSP_STATUS_CARD_DETECT);
}
static int mxsmmc_send_cmd_pio(struct mxsmmc_priv *priv, struct mmc_data *data) static int mxsmmc_send_cmd_pio(struct mxsmmc_priv *priv, struct mmc_data *data)
{ {
struct mxs_ssp_regs *ssp_regs = priv->regs; struct mxs_ssp_regs *ssp_regs = priv->regs;
...@@ -166,7 +177,7 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) ...@@ -166,7 +177,7 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
} }
/* See if card is present */ /* See if card is present */
if (readl(&ssp_regs->hw_ssp_status) & SSP_STATUS_CARD_DETECT) { if (!mxsmmc_cd(priv)) {
printf("MMC%d: No card detected!\n", mmc->block_dev.dev); printf("MMC%d: No card detected!\n", mmc->block_dev.dev);
return NO_CARD_ERR; return NO_CARD_ERR;
} }
...@@ -357,7 +368,7 @@ static int mxsmmc_init(struct mmc *mmc) ...@@ -357,7 +368,7 @@ static int mxsmmc_init(struct mmc *mmc)
return 0; return 0;
} }
int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int)) int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int))
{ {
struct mmc *mmc = NULL; struct mmc *mmc = NULL;
struct mxsmmc_priv *priv = NULL; struct mxsmmc_priv *priv = NULL;
...@@ -395,6 +406,7 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int)) ...@@ -395,6 +406,7 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int))
return ret; return ret;
priv->mmc_is_wp = wp; priv->mmc_is_wp = wp;
priv->mmc_cd = cd;
priv->id = id; priv->id = id;
priv->regs = mxs_ssp_regs_by_bus(id); priv->regs = mxs_ssp_regs_by_bus(id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment