Merge remote-tracking branch 'aosp/android-3.0' into develop-3.0-jb
[firefly-linux-kernel-4.4.55.git] / drivers / mmc / core / core.c
index 21bca485be62d537b6413ed6ff881f3bb8615ee0..3f3615c0af90e415db97bc76ce48b1bc37551581 100755 (executable)
@@ -236,7 +236,7 @@ void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
         //calculate the timeout value for SDMMC; added by xbw at 2011-09-27
         if(mrq->data)
         {
-            unit = 3*(1<<20);// unit=3MB
+            unit = 2*(1<<20);// unit=2MB
             datasize = mrq->data->blksz*mrq->data->blocks;
             multi = datasize/unit;
             multi += (datasize%unit)?1:0;
@@ -260,8 +260,12 @@ void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
     {
         host->doneflag = 0;
         mrq->cmd->error = -EIO;
-        printk("%s..%d.. !!!!! wait for CMD%d timeout ===xbw[%s]===\n",\
-            __FUNCTION__, __LINE__, mrq->cmd->opcode, mmc_hostname(host));
+
+        if(0 == mrq->cmd->retries)
+        {
+            printk(KERN_WARNING "%s..%d.. !!!!! wait for CMD%d timeout [%s]\n",\
+                __FUNCTION__, __LINE__, mrq->cmd->opcode, mmc_hostname(host));
+        }
     }
 #else
        wait_for_completion(&complete);
@@ -1107,7 +1111,7 @@ static void mmc_power_up(struct mmc_host *host)
        mmc_host_clk_release(host);
 }
 
-static void mmc_power_off(struct mmc_host *host)
+void mmc_power_off(struct mmc_host *host)
 {
        mmc_host_clk_hold(host);
 
@@ -1227,8 +1231,7 @@ void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops)
 }
 
 /*
- * Remove the current bus handler from a host. Assumes that there are
- * no interesting cards left, so the bus is powered down.
+ * Remove the current bus handler from a host.
  */
 void mmc_detach_bus(struct mmc_host *host)
 {
@@ -1245,8 +1248,6 @@ void mmc_detach_bus(struct mmc_host *host)
 
        spin_unlock_irqrestore(&host->lock, flags);
 
-       mmc_power_off(host);
-
        mmc_bus_put(host);
 }
 
@@ -1665,12 +1666,12 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
 #if !defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)
     if( strncmp( mmc_hostname(host) ,"mmc0" , strlen("mmc0")) )
     {
-           sdio_reset(host);
+           //sdio_reset(host);//make no sense; noteed by xbw at 2011-12-14
        mmc_go_idle(host);
 
        if (!(init_ret=mmc_attach_sdio(host)))
        {
-           printk("%s..%d..  ===== Initialize SDIO successfully. ===xbw[%s]===\n",\
+           printk(KERN_INFO "%s..%d..  ===== Initialize SDIO successfully. [%s]\n",\
                __FUNCTION__,  __LINE__, mmc_hostname(host));
                return 0;
        }
@@ -1678,7 +1679,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
        {
            if(0xFF!=init_ret)
            {
-                printk("\n=====\n %s..%d..  ===== Initialize SDIO-card unsuccessfully!!! ===xbw[%s]===\n=====\n",\
+                printk(KERN_WARNING "\n=====\n %s..%d..  ===== Initialize SDIO-card unsuccessfully!!! [%s]\n=====\n",\
                        __FUNCTION__,  __LINE__, mmc_hostname(host));
 
                     goto freq_out;   
@@ -1690,12 +1691,12 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
         mmc_go_idle(host);
     }
 #else
-    sdio_reset(host);
+    //sdio_reset(host); //make no sense; noteed by xbw at 2011-12-14
        mmc_go_idle(host);
 
        if (!(init_ret=mmc_attach_sdio(host)))
        {
-           printk("%s..%d..  ===== Initialize SDIO successfully. ===xbw[%s]===\n",\
+           printk(KERN_INFO "%s..%d..  ===== Initialize SDIO successfully. [%s]\n",\
                __FUNCTION__,  __LINE__, mmc_hostname(host));
                return 0;
        }
@@ -1703,7 +1704,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
        {
            if(0xFF!=init_ret)
            {
-                printk("\n=====\n %s..%d..  ===== Initialize SDIO-card unsuccessfully!!! ===xbw[%s]===\n=====\n",\
+                printk(KERN_WARNING "\n=====\n %s..%d..  ===== Initialize SDIO-card unsuccessfully!!! [%s]\n=====\n",\
                        __FUNCTION__,  __LINE__, mmc_hostname(host));
 
                     goto freq_out;   
@@ -1713,7 +1714,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
 
     if (!(init_ret=mmc_attach_sd(host)))
     {
-        printk("%s..%d..  ===== Initialize SD-card successfully. ===xbw[%s]===\n",\
+        printk(KERN_INFO "%s..%d..  ===== Initialize SD-card successfully. [%s]\n",\
             __FUNCTION__,  __LINE__, mmc_hostname(host));
             
            return 0;
@@ -1722,7 +1723,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
        {
            if(0xFF!=init_ret)
            {
-                 printk("\n=====\n%s..%d..  ===== Initialize SD-card unsuccessfully!!! ===xbw[%s]===\n====\n",\
+                 printk(KERN_WARNING "\n=====\n%s..%d..  ===== Initialize SD-card unsuccessfully! [%s]\n====\n",\
                        __FUNCTION__,  __LINE__, mmc_hostname(host));
 
                     goto freq_out;   
@@ -1732,7 +1733,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
 
        if (!(init_ret=mmc_attach_mmc(host)))
        {
-           printk("%s...%d..  ===== Initialize MMC-card successfully. ===xbw[%s]===\n",\
+           printk(KERN_INFO "%s...%d..  ===== Initialize MMC-card successfully. [%s]\n",\
                __FUNCTION__,  __LINE__, mmc_hostname(host));
 
            return 0;
@@ -1741,7 +1742,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
        {
            if(0xFF!=init_ret)
            {
-                printk("\n =====\n%s..%d..  ===== Initialize MMC-card unsuccessfully!!! ===xbw[%s]===\n======\n",\
+                printk(KERN_WARNING "\n =====\n%s..%d..  ===== Initialize MMC-card unsuccessfully!!! [%s]\n======\n",\
                    __FUNCTION__,  __LINE__, mmc_hostname(host));
                    
                     goto freq_out;   
@@ -1820,13 +1821,13 @@ void mmc_rescan(struct work_struct *work)
        mmc_bus_put(host);
 
 #if defined(CONFIG_SDMMC_RK29) || !defined(CONFIG_SDMMC_RK29_OLD)   //Modifyed by xbw at 2011-11-17
-    printk("\n%s...%d..  ===== mmc_rescan Begin....======xbw[%s]=====\n",__FILE__, __LINE__, mmc_hostname(host));
+    printk(KERN_INFO "\n%s...%d..  ===== mmc_rescan Begin....[%s]\n",__FILE__, __LINE__, mmc_hostname(host));
 #endif
 
        if (host->ops->get_cd && host->ops->get_cd(host) == 0)
        {
 #if defined(CONFIG_SDMMC_RK29) || !defined(CONFIG_SDMMC_RK29_OLD)   //Modifyed by xbw at 2011-11-17
-        printk("\n=================\n%s..%d..  ====find no SDMMC host.====xbw[%s]=====\n", \
+        printk(KERN_WARNING "\n=================\n%s..%d..  ====find no SDMMC host. [%s]\n", \
                __FUNCTION__, __LINE__, mmc_hostname(host));
 #endif
 
@@ -1894,6 +1895,7 @@ void mmc_stop_host(struct mmc_host *host)
 
                mmc_claim_host(host);
                mmc_detach_bus(host);
+               mmc_power_off(host);
                mmc_release_host(host);
                mmc_bus_put(host);
                return;
@@ -2010,6 +2012,10 @@ int mmc_suspend_host(struct mmc_host *host)
        if (host->bus_ops && !host->bus_dead) {
                if (host->bus_ops->suspend)
                        err = host->bus_ops->suspend(host);
+
+#if defined(CONFIG_SDMMC_RK29) && defined(CONFIG_SDMMC_RK29_OLD)
+               //deleted all detail code. //fix the crash bug when error occur during suspend. Modiefyed by xbw at 2012-08-09
+#else
                if (err == -ENOSYS || !host->bus_ops->resume) {
                        /*
                         * We simply "remove" the card in this case.
@@ -2019,10 +2025,13 @@ int mmc_suspend_host(struct mmc_host *host)
                                host->bus_ops->remove(host);
                        mmc_claim_host(host);
                        mmc_detach_bus(host);
+                       mmc_power_off(host);
                        mmc_release_host(host);
                        host->pm_flags = 0;
                        err = 0;
                }
+#endif
+               flush_delayed_work(&host->disable);
        }
        mmc_bus_put(host);
 
@@ -2123,6 +2132,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,
                        host->bus_ops->remove(host);
 
                mmc_detach_bus(host);
+               mmc_power_off(host);
                mmc_release_host(host);
                host->pm_flags = 0;
                break;