omap_hsmmc: try to avoid reading the card too early
authorGrazvydas Ignotas <notasas@gmail.com>
Sun, 22 May 2016 22:41:02 +0000 (01:41 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 3 Jul 2016 00:23:25 +0000 (03:23 +0300)
Pandora's SD sockets have card detect that triggers way before the card
is fully inserted, so sometimes the commands start before card has finished
moving and got locked in it's place. Try to delay more to deal with it.

drivers/mmc/host/omap_hsmmc.c

index 6a960c1..2844e01 100644 (file)
@@ -195,9 +195,16 @@ struct omap_hsmmc_host {
 static int omap_hsmmc_card_detect(struct device *dev, int slot)
 {
        struct omap_mmc_platform_data *mmc = dev->platform_data;
+       int val1, val2;
 
        /* NOTE: assumes card detect signal is active-low */
-       return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
+       do {
+               val1 = gpio_get_value_cansleep(mmc->slots[0].switch_pin);
+               val2 = gpio_get_value_cansleep(mmc->slots[0].switch_pin);
+       }
+       while (val1 != val2);
+
+       return !val1;
 }
 
 static int omap_hsmmc_get_wp(struct device *dev, int slot)
@@ -1358,7 +1365,7 @@ static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id)
        }
 
        if (carddetect)
-               mmc_detect_change(host->mmc, (HZ * 200) / 1000);
+               mmc_detect_change(host->mmc, (HZ * 500) / 1000);
        else
                mmc_detect_change(host->mmc, (HZ * 50) / 1000);
        return IRQ_HANDLED;