make some adjustments to adapt to new kernel version
authorxbw <xbw@rock-chips.com>
Fri, 12 Aug 2011 02:33:16 +0000 (10:33 +0800)
committerxbw <xbw@rock-chips.com>
Fri, 12 Aug 2011 02:33:16 +0000 (10:33 +0800)
drivers/mmc/card/block.c [changed mode: 0644->0755]
drivers/mmc/core/core.c [changed mode: 0644->0755]
drivers/mmc/host/rk29_sdmmc.c
drivers/mmc/host/rk29_sdmmc_old.c

old mode 100644 (file)
new mode 100755 (executable)
index 1d96e4a..d50a23b
@@ -117,9 +117,9 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
        
 #if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
        mutex_lock(&block_mutex); //added by xbw at 2011-04-21
-#endif
-
-       lock_kernel();
+#else
+       //lock_kernel(); // The feature of block_mutex is same with lock_kernel£¬but the better. noted by xbw at 2011-08-09 
+#endif 
        if (md) {
                if (md->usage == 2)
                        check_disk_change(bdev);
@@ -130,11 +130,12 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode)
                        ret = -EROFS;
                }
        }
-       unlock_kernel();
-
 #if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
        mutex_unlock(&block_mutex);
-#endif 
+#else  
+       unlock_kernel();
+#endif
+       
 
        return ret;
 }
@@ -145,14 +146,15 @@ static int mmc_blk_release(struct gendisk *disk, fmode_t mode)
        
 #if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
        mutex_lock(&block_mutex); //added by xbw at 2011-04-21
-#endif
-
-       lock_kernel();
+#else
+       //lock_kernel(); // The feature of block_mutex is same with lock_kernel£¬but the better. noted by xbw at 2011-08-09
+#endif 
        mmc_blk_put(md);
-       unlock_kernel();
-
+       
 #if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)      
        mutex_unlock(&block_mutex);
+#else
+    unlock_kernel();
 #endif
 
        return 0;
old mode 100644 (file)
new mode 100755 (executable)
index e8497c4..3c7d5d2
@@ -1432,16 +1432,25 @@ int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from,
 }
 EXPORT_SYMBOL(mmc_erase_group_aligned);
 
-#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
 void mmc_rescan(struct work_struct *work)
 {
        struct mmc_host *host =
                container_of(work, struct mmc_host, detect.work);
        u32 ocr;
        int err;
+       unsigned long flags;
        int extend_wakelock = 0;
 
-    
+       spin_lock_irqsave(&host->lock, flags);
+
+       if (host->rescan_disable) {
+               spin_unlock_irqrestore(&host->lock, flags);
+               return;
+       }
+
+       spin_unlock_irqrestore(&host->lock, flags);
+
+
        mmc_bus_get(host);
 
        /* if there is a card registered, check whether it is still present */
@@ -1472,32 +1481,36 @@ void mmc_rescan(struct work_struct *work)
         * release the lock here.
         */
        mmc_bus_put(host);
+       
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) 
     printk("\n%s...%d..  ===== mmc_rescan Begin....======xbw[%s]=====\n",__FILE__, __LINE__, mmc_hostname(host));
+#endif
 
        if (host->ops->get_cd && host->ops->get_cd(host) == 0)
        {
-           printk("\n=================\n%s..%d..  ====find no SDMMC host.====xbw[%s]=====\n", \
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) 
+        printk("\n=================\n%s..%d..  ====find no SDMMC host.====xbw[%s]=====\n", \
                __FUNCTION__, __LINE__, mmc_hostname(host));
-               
+#endif
                goto out;
        }
 
        mmc_claim_host(host);
-       
+
        mmc_power_up(host);
        
-       mmc_go_idle(host);
-
-    /*
-        In oder to improve the initialization process in rockchip IC, I modify the following code about the the initialization process of SDIO-SD-MMC.
-        So I deleted the CMD8 and add a conditional to distinguish between the two card type,i.e.SDMMC process and SDIO process.
-        For detail,please refer to "RK29XX Technical Reference Manual" and "SD-MMC-SDIO Specifications".
-        Noted by xbw@2011-04-09
-    */
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)  
+       //sdio_reset(host);  //This does not make sense ,  deleted by xbw at 2011-08-08
+#else
+    sdio_reset(host);
+#endif
 
-    //mmc_send_if_cond(host, host->ocr_avail); //deleted by xbw@2011-04-09
+       mmc_go_idle(host);
+       
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) 
+       //mmc_send_if_cond(host, host->ocr_avail); //This does not make sense, deleted by xbw at 2011-08-08
 
-     if( strncmp( mmc_hostname(host) ,"mmc0" , strlen("mmc0")) ){
+    if( strncmp( mmc_hostname(host) ,"mmc0" , strlen("mmc0")) ){
        /*
         * First we search for SDIO...
         */
@@ -1520,126 +1533,8 @@ void mmc_rescan(struct work_struct *work)
                goto out;
        }
     }
-
-
-    /*
-     * ...then normal SD...
-     */
-    err = mmc_send_app_op_cond(host, 0, &ocr);
-    if (!err) {
-       printk("\n%s..%d..  ===== Begin to identify card as SD-card ===xbw[%s]===\n",__FUNCTION__, __LINE__, mmc_hostname(host));
-
-       if (mmc_attach_sd(host, ocr))
-       {
-           printk("\n=====\n%s..%d..  ===== Initialize SD-card unsuccessfully!!! ===xbw[%s]===\n====\n",\
-               __FUNCTION__,  __LINE__, mmc_hostname(host));
-               
-               mmc_power_off(host);
-       }
-       else
-       {
-           printk("%s..%d..  ===== Initialize SD-card successfully. ===xbw[%s]===\n",__FUNCTION__,  __LINE__, mmc_hostname(host));
-       }
-       extend_wakelock = 1;
-       goto out;
-    }
-
-    /*
-     * ...and finally MMC.
-     */
-    err = mmc_send_op_cond(host, 0, &ocr);
-    if (!err) {
-        printk("\n%s..%d..  ===== Begin to identify card as MMC-card ===xbw[%s]===\n", __FUNCTION__, __LINE__, mmc_hostname(host));
-
-       if (mmc_attach_mmc(host, ocr))
-       {
-           printk("\n =====\n%s..%d..  ===== Initialize MMC-card unsuccessfully!!! ===xbw[%s]===\n======\n",\
-               __FUNCTION__,  __LINE__, mmc_hostname(host));
-               
-               mmc_power_off(host);
-       }
-       else
-       {
-           printk("%s...%d..  ===== Initialize MMC-card successfully. ===xbw[%s]===\n",__FUNCTION__,  __LINE__, mmc_hostname(host));
-       }
-       extend_wakelock = 1;
-       goto out;
-    }
-
-       mmc_release_host(host);
-       mmc_power_off(host);
-
-out:
-
-       if (extend_wakelock)
-               wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
-       else
-               wake_unlock(&mmc_delayed_work_wake_lock);
-
-       if (host->caps & MMC_CAP_NEEDS_POLL)
-               mmc_schedule_delayed_work(&host->detect, HZ);
-}
-
+       
 #else
-void mmc_rescan(struct work_struct *work)
-{
-       struct mmc_host *host =
-               container_of(work, struct mmc_host, detect.work);
-       u32 ocr;
-       int err;
-       unsigned long flags;
-       int extend_wakelock = 0;
-
-       spin_lock_irqsave(&host->lock, flags);
-
-       if (host->rescan_disable) {
-               spin_unlock_irqrestore(&host->lock, flags);
-               return;
-       }
-
-       spin_unlock_irqrestore(&host->lock, flags);
-
-
-       mmc_bus_get(host);
-
-       /* if there is a card registered, check whether it is still present */
-       if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead)
-               host->bus_ops->detect(host);
-
-       /* If the card was removed the bus will be marked
-        * as dead - extend the wakelock so userspace
-        * can respond */
-       if (host->bus_dead)
-               extend_wakelock = 1;
-
-       mmc_bus_put(host);
-
-
-       mmc_bus_get(host);
-
-       /* if there still is a card present, stop here */
-       if (host->bus_ops != NULL) {
-               mmc_bus_put(host);
-               goto out;
-       }
-
-       /* detect a newly inserted card */
-
-       /*
-        * Only we can add a new handler, so it's safe to
-        * release the lock here.
-        */
-       mmc_bus_put(host);
-
-       if (host->ops->get_cd && host->ops->get_cd(host) == 0)
-               goto out;
-
-       mmc_claim_host(host);
-
-       mmc_power_up(host);
-       sdio_reset(host);
-       mmc_go_idle(host);
-
        mmc_send_if_cond(host, host->ocr_avail);
 
        /*
@@ -1659,14 +1554,32 @@ void mmc_rescan(struct work_struct *work)
                }
                goto out;
        }
+#endif
 
        /*
         * ...then normal SD...
         */
        err = mmc_send_app_op_cond(host, 0, &ocr);
        if (!err) {
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)      
+           printk("\n%s..%d..  ===== Begin to identify card as SD-card ===xbw[%s]===\n",\
+               __FUNCTION__, __LINE__, mmc_hostname(host));
+#endif
                if (mmc_attach_sd(host, ocr))
+               {
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)                      
+               printk("\n=====\n%s..%d..  ===== Initialize SD-card unsuccessfully!!! ===xbw[%s]===\n====\n",\
+                       __FUNCTION__,  __LINE__, mmc_hostname(host));
+#endif                 
                        mmc_power_off(host);
+               }
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)                                      
+               else
+               {
+                   printk("%s..%d..  ===== Initialize SD-card successfully. ===xbw[%s]===\n",\
+                       __FUNCTION__,  __LINE__, mmc_hostname(host));
+               }
+#endif         
                extend_wakelock = 1;
                goto out;
        }
@@ -1676,8 +1589,25 @@ void mmc_rescan(struct work_struct *work)
         */
        err = mmc_send_op_cond(host, 0, &ocr);
        if (!err) {
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)      
+           printk("\n%s..%d..  ===== Begin to identify card as MMC-card ===xbw[%s]===\n",\
+               __FUNCTION__, __LINE__, mmc_hostname(host));
+#endif
                if (mmc_attach_mmc(host, ocr))
+               {
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)
+            printk("\n =====\n%s..%d..  ===== Initialize MMC-card unsuccessfully!!! ===xbw[%s]===\n======\n",\
+               __FUNCTION__,  __LINE__, mmc_hostname(host));
+#endif         
                        mmc_power_off(host);
+               }
+#if defined(CONFIG_SDMMC_RK29) && !defined(CONFIG_SDMMC_RK29_OLD)              
+               else
+               {
+                   printk("%s...%d..  ===== Initialize MMC-card successfully. ===xbw[%s]===\n",\
+                       __FUNCTION__,  __LINE__, mmc_hostname(host));
+               }
+#endif         
                extend_wakelock = 1;
                goto out;
        }
@@ -1695,7 +1625,6 @@ out:
        if (host->caps & MMC_CAP_NEEDS_POLL)
                mmc_schedule_delayed_work(&host->detect, HZ);
 }
-#endif
 
 void mmc_start_host(struct mmc_host *host)
 {
index 0e8de6d7c1bdde23a7c794628d3c0f078f1d9d75..ad3702a2d0fdf6df504220bc940779b11f86832f 100755 (executable)
@@ -2787,7 +2787,7 @@ static int rk29_sdmmc_probe(struct platform_device *pdev)
        clk_enable(clk_get(&pdev->dev, "hclk_mmc"));
 
        ret = -ENOMEM;
-       host->regs = ioremap(regs->start, regs->end - regs->start);
+       host->regs = ioremap(regs->start, regs->end - regs->start + 1);
        if (!host->regs)
        {
            host->errorstep = 0x8A;
index d2ebee3e0b2c0941f000bc3d7f3859e45c0ac62c..e3c845751fe3d691e52541a0304625a43a10543b 100755 (executable)
@@ -1307,7 +1307,7 @@ static int rk29_sdmmc_probe(struct platform_device *pdev)
                goto err_mmc_free_host;
        }
        
-       host->regs = ioremap(regs->start, regs->end - regs->start);
+       host->regs = ioremap(regs->start, regs->end - regs->start + 1);
        if (!host->regs){
                dev_err(&pdev->dev, "ioremap error\n");
                ret = ENXIO;