Commit 91769986 authored by Daniel Willmann's avatar Daniel Willmann Committed by Chris Ball

mmc: mxs: fix card detection function for broken card detect

Return -ENOSYS in get_cd if broken-cd is specified in the device tree.

Commit a91fe279 (mmc: mxs: use standard flag for broken card
detection) sets MMC_CAP_NEEDS_POLL when broken-cd is specified. This
driver sets this flag unconditionally as it does not support a card
detect interrupt. Instead, broken-cd means that there is no card detect
signal connected.

The mmc core checks the get_cd function return value to determine if a
card is present. Only for a non-zero return value it will attempt to
initialize the card. So retuning -ENOSYS will allow the card to be
initialized.

For comparison, mmc_gpio_get_cd in slot-gpio.c also returns -ENOSYS if
the card detect GPIO is not valid.
Signed-off-by: default avatarDaniel Willmann <daniel@totalueberwachung.de>
Acked-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarChris Ball <chris@printf.net>
parent 1acee84b
...@@ -70,6 +70,7 @@ struct mxs_mmc_host { ...@@ -70,6 +70,7 @@ struct mxs_mmc_host {
unsigned char bus_width; unsigned char bus_width;
spinlock_t lock; spinlock_t lock;
int sdio_irq_en; int sdio_irq_en;
bool broken_cd;
}; };
static int mxs_mmc_get_cd(struct mmc_host *mmc) static int mxs_mmc_get_cd(struct mmc_host *mmc)
...@@ -78,6 +79,9 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc) ...@@ -78,6 +79,9 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
struct mxs_ssp *ssp = &host->ssp; struct mxs_ssp *ssp = &host->ssp;
int present, ret; int present, ret;
if (host->broken_cd)
return -ENOSYS;
ret = mmc_gpio_get_cd(mmc); ret = mmc_gpio_get_cd(mmc);
if (ret >= 0) if (ret >= 0)
return ret; return ret;
...@@ -568,6 +572,7 @@ static int mxs_mmc_probe(struct platform_device *pdev) ...@@ -568,6 +572,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
{ {
const struct of_device_id *of_id = const struct of_device_id *of_id =
of_match_device(mxs_mmc_dt_ids, &pdev->dev); of_match_device(mxs_mmc_dt_ids, &pdev->dev);
struct device_node *np = pdev->dev.of_node;
struct mxs_mmc_host *host; struct mxs_mmc_host *host;
struct mmc_host *mmc; struct mmc_host *mmc;
struct resource *iores; struct resource *iores;
...@@ -634,6 +639,8 @@ static int mxs_mmc_probe(struct platform_device *pdev) ...@@ -634,6 +639,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL; MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
host->broken_cd = of_property_read_bool(np, "broken-cd");
mmc->f_min = 400000; mmc->f_min = 400000;
mmc->f_max = 288000000; mmc->f_max = 288000000;
......
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