From 5a3a9f63795a4da5aee2466a79d23b7b2ba6d3bf Mon Sep 17 00:00:00 2001 From: xbw Date: Fri, 12 Aug 2011 10:33:16 +0800 Subject: [PATCH] make some adjustments to adapt to new kernel version --- drivers/mmc/card/block.c | 24 ++-- drivers/mmc/core/core.c | 199 ++++++++++-------------------- drivers/mmc/host/rk29_sdmmc.c | 2 +- drivers/mmc/host/rk29_sdmmc_old.c | 2 +- 4 files changed, 79 insertions(+), 148 deletions(-) mode change 100644 => 100755 drivers/mmc/card/block.c mode change 100644 => 100755 drivers/mmc/core/core.c diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c old mode 100644 new mode 100755 index 1d96e4aba9a9..d50a23be1654 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -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; diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c old mode 100644 new mode 100755 index e8497c431718..3c7d5d224844 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -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) { diff --git a/drivers/mmc/host/rk29_sdmmc.c b/drivers/mmc/host/rk29_sdmmc.c index 0e8de6d7c1bd..ad3702a2d0fd 100755 --- a/drivers/mmc/host/rk29_sdmmc.c +++ b/drivers/mmc/host/rk29_sdmmc.c @@ -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; diff --git a/drivers/mmc/host/rk29_sdmmc_old.c b/drivers/mmc/host/rk29_sdmmc_old.c index d2ebee3e0b2c..e3c845751fe3 100755 --- a/drivers/mmc/host/rk29_sdmmc_old.c +++ b/drivers/mmc/host/rk29_sdmmc_old.c @@ -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; -- 2.34.1