]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mmc/mmc.c
[ARM] Remove clk_use()/clk_unuse()
[linux-2.6-omap-h63xx.git] / drivers / mmc / mmc.c
index 0a117c61cd1809e4f2ee6d924ac716810c8c848e..eb41391e06e938a5a0607b90defab00f82fd9827 100644 (file)
@@ -679,7 +679,15 @@ static void mmc_idle_cards(struct mmc_host *host)
 }
 
 /*
- * Apply power to the MMC stack.
+ * Apply power to the MMC stack.  This is a two-stage process.
+ * First, we enable power to the card without the clock running.
+ * We then wait a bit for the power to stabilise.  Finally,
+ * enable the bus drivers and clock to the card.
+ *
+ * We must _NOT_ enable the clock prior to power stablising.
+ *
+ * If a host does all the power sequencing itself, ignore the
+ * initial MMC_POWER_UP stage.
  */
 static void mmc_power_up(struct mmc_host *host)
 {
@@ -816,7 +824,7 @@ static void mmc_discover_cards(struct mmc_host *host)
 
                        cmd.opcode = SD_SEND_RELATIVE_ADDR;
                        cmd.arg = 0;
-                       cmd.flags = MMC_RSP_R1;
+                       cmd.flags = MMC_RSP_R6;
 
                        err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
                        if (err != MMC_ERR_NONE)
@@ -932,8 +940,9 @@ static void mmc_read_scrs(struct mmc_host *host)
 
                sg_init_one(&sg, (u8*)card->raw_scr, 8);
 
-               err = mmc_wait_for_req(host, &mrq);
-               if (err != MMC_ERR_NONE) {
+               mmc_wait_for_req(host, &mrq);
+
+               if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
                        mmc_card_set_dead(card);
                        continue;
                }
@@ -1079,13 +1088,17 @@ static void mmc_setup(struct mmc_host *host)
 /**
  *     mmc_detect_change - process change of state on a MMC socket
  *     @host: host which changed state.
+ *     @delay: optional delay to wait before detection (jiffies)
  *
  *     All we know is that card(s) have been inserted or removed
  *     from the socket(s).  We don't know which socket or cards.
  */
-void mmc_detect_change(struct mmc_host *host)
+void mmc_detect_change(struct mmc_host *host, unsigned long delay)
 {
-       schedule_work(&host->detect);
+       if (delay)
+               schedule_delayed_work(&host->detect, delay);
+       else
+               schedule_work(&host->detect);
 }
 
 EXPORT_SYMBOL(mmc_detect_change);
@@ -1189,7 +1202,7 @@ int mmc_add_host(struct mmc_host *host)
        ret = mmc_add_host_sysfs(host);
        if (ret == 0) {
                mmc_power_off(host);
-               mmc_detect_change(host);
+               mmc_detect_change(host, 0);
        }
 
        return ret;
@@ -1259,7 +1272,7 @@ EXPORT_SYMBOL(mmc_suspend_host);
  */
 int mmc_resume_host(struct mmc_host *host)
 {
-       mmc_detect_change(host);
+       mmc_rescan(host);
 
        return 0;
 }