1cfde8365523c2fe655880611b50229e5da3438f
[openwrt/openwrt.git] / target / linux / mxs / patches-3.14 / 130-mxs-mmc-fix-card-detect.patch
1 From 91769986a724f63db52f3c78c79ac84a5b7045bf Mon Sep 17 00:00:00 2001
2 From: Daniel Willmann <daniel@totalueberwachung.de>
3 Date: Sat, 19 Apr 2014 23:59:18 +0200
4 Subject: [PATCH] mmc: mxs: fix card detection function for broken card detect
5
6 Return -ENOSYS in get_cd if broken-cd is specified in the device tree.
7
8 Commit a91fe279ae75 (mmc: mxs: use standard flag for broken card
9 detection) sets MMC_CAP_NEEDS_POLL when broken-cd is specified. This
10 driver sets this flag unconditionally as it does not support a card
11 detect interrupt. Instead, broken-cd means that there is no card detect
12 signal connected.
13
14 The mmc core checks the get_cd function return value to determine if a
15 card is present. Only for a non-zero return value it will attempt to
16 initialize the card. So retuning -ENOSYS will allow the card to be
17 initialized.
18
19 For comparison, mmc_gpio_get_cd in slot-gpio.c also returns -ENOSYS if
20 the card detect GPIO is not valid.
21
22 Signed-off-by: Daniel Willmann <daniel@totalueberwachung.de>
23 Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
24 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
25 Signed-off-by: Chris Ball <chris@printf.net>
26 ---
27 drivers/mmc/host/mxs-mmc.c | 7 +++++++
28 1 file changed, 7 insertions(+)
29
30 --- a/drivers/mmc/host/mxs-mmc.c
31 +++ b/drivers/mmc/host/mxs-mmc.c
32 @@ -70,6 +70,7 @@ struct mxs_mmc_host {
33 unsigned char bus_width;
34 spinlock_t lock;
35 int sdio_irq_en;
36 + bool broken_cd;
37 };
38
39 static int mxs_mmc_get_cd(struct mmc_host *mmc)
40 @@ -78,6 +79,9 @@ static int mxs_mmc_get_cd(struct mmc_hos
41 struct mxs_ssp *ssp = &host->ssp;
42 int present, ret;
43
44 + if (host->broken_cd)
45 + return -ENOSYS;
46 +
47 ret = mmc_gpio_get_cd(mmc);
48 if (ret >= 0)
49 return ret;
50 @@ -568,6 +572,7 @@ static int mxs_mmc_probe(struct platform
51 {
52 const struct of_device_id *of_id =
53 of_match_device(mxs_mmc_dt_ids, &pdev->dev);
54 + struct device_node *np = pdev->dev.of_node;
55 struct mxs_mmc_host *host;
56 struct mmc_host *mmc;
57 struct resource *iores;
58 @@ -634,6 +639,8 @@ static int mxs_mmc_probe(struct platform
59 mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
60 MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
61
62 + host->broken_cd = of_property_read_bool(np, "broken-cd");
63 +
64 mmc->f_min = 400000;
65 mmc->f_max = 288000000;
66