mmc: dw_mmc: setpower on MMC_POWER_{UP,OFF}
authorJames Hogan <james.hogan@imgtec.com>
Tue, 12 Mar 2013 10:43:32 +0000 (10:43 +0000)
committerChris Ball <cjb@laptop.org>
Fri, 22 Mar 2013 16:41:54 +0000 (12:41 -0400)
Call the setpower platform callback in response to set_ios with
ios->power_mode == MMC_POWER_UP or MMC_POWER_OFF, instead of from the
card detect work function.

This appears to fix a problem I have where a card stuck in a funny state
doesn't get properly cleared by the power being turned off, presumably
due to lack of power sequencing. This resulted in the following log
messages after boot:

mmc0: error -110 whilst initialising SD card
mmc_host mmc0: Bus speed (slot 0) = 99840000Hz (slot req 300000Hz, actual 298922HZ div = 167)
mmc0: error -110 whilst initialising SD card
mmc_host mmc0: Bus speed (slot 0) = 99840000Hz (slot req 200000Hz, actual 199680HZ div = 250)
mmc0: error -110 whilst initialising SD card
mmc_host mmc0: Bus speed (slot 0) = 99840000Hz (slot req 195765Hz, actual 195764HZ div = 255)
mmc0: error -110 whilst initialising SD card
mmc_host mmc0: Bus speed (slot 0) = 99840000Hz (slot req 400000Hz, actual 399360HZ div = 125)
mmc0: error -110 whilst initialising SD card
mmc_host mmc0: Bus speed (slot 0) = 99840000Hz (slot req 300000Hz, actual 298922HZ div = 167)

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Acked-by: Seungwon Jeon <tgih.jun@samsung.com>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/host/dw_mmc.c

index 38732d85009d8db65f8dc9205bfae9924ca16d49..6891fd131b0aec9513d9b3bbf976f22ecddef037 100644 (file)
@@ -818,6 +818,14 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
        switch (ios->power_mode) {
        case MMC_POWER_UP:
                set_bit(DW_MMC_CARD_NEED_INIT, &slot->flags);
+               /* Power up slot */
+               if (slot->host->pdata->setpower)
+                       slot->host->pdata->setpower(slot->id, mmc->ocr_avail);
+               break;
+       case MMC_POWER_OFF:
+               /* Power down slot */
+               if (slot->host->pdata->setpower)
+                       slot->host->pdata->setpower(slot->id, 0);
                break;
        default:
                break;
@@ -1676,10 +1684,6 @@ static void dw_mci_work_routine_card(struct work_struct *work)
                        dev_dbg(&slot->mmc->class_dev, "card %s\n",
                                present ? "inserted" : "removed");
 
-                       /* Power up slot (before spin_lock, may sleep) */
-                       if (present != 0 && host->pdata->setpower)
-                               host->pdata->setpower(slot->id, mmc->ocr_avail);
-
                        spin_lock_bh(&host->lock);
 
                        /* Card change detected */
@@ -1762,10 +1766,6 @@ static void dw_mci_work_routine_card(struct work_struct *work)
 
                        spin_unlock_bh(&host->lock);
 
-                       /* Power down slot (after spin_unlock, may sleep) */
-                       if (present == 0 && host->pdata->setpower)
-                               host->pdata->setpower(slot->id, 0);
-
                        present = dw_mci_get_cd(mmc);
                }