MMC: Poll card status after rescanning cards
authorTimo Teras <timo.teras@solidboot.com>
Wed, 25 Oct 2006 06:37:41 +0000 (09:37 +0300)
committerPierre Ossman <drzeus@drzeus.cx>
Thu, 9 Nov 2006 06:23:37 +0000 (07:23 +0100)
Some broken cards seem to process CMD1 even in stand-by state. The result is
that the card replies with ILLEGAL_COMMAND error for the next command sent
after rescanning. Currently the next command is select card, which would
return the error. But CMD7 does actually succeed and retries of the command
will timeout. The workaround is to poll card status after CMD1 to clear the
pending error.

Signed-off-by: Timo Teras <timo.teras@solidboot.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
drivers/mmc/mmc.c

index ee8863c..ec8168a 100644 (file)
@@ -1178,14 +1178,29 @@ static void mmc_rescan(void *data)
 {
        struct mmc_host *host = data;
        struct list_head *l, *n;
+       unsigned char power_mode;
 
        mmc_claim_host(host);
 
-       if (host->ios.power_mode == MMC_POWER_ON)
+       /*
+        * Check for removed cards and newly inserted ones. We check for
+        * removed cards first so we can intelligently re-select the VDD.
+        */
+       power_mode = host->ios.power_mode;
+       if (power_mode == MMC_POWER_ON)
                mmc_check_cards(host);
 
        mmc_setup(host);
 
+       /*
+        * Some broken cards process CMD1 even in stand-by state. There is
+        * no reply, but an ILLEGAL_COMMAND error is cached and returned
+        * after next command. We poll for card status here to clear any
+        * possibly pending error.
+        */
+       if (power_mode == MMC_POWER_ON)
+               mmc_check_cards(host);
+
        if (!list_empty(&host->cards)) {
                /*
                 * (Re-)calculate the fastest clock rate which the