From: lintao Date: Wed, 28 May 2014 00:18:14 +0000 (+0800) Subject: mmc: host: rk_sdmmc.c X-Git-Tag: firefly_0821_release~5213 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ed35a474e90dd9bb14d2b094d509e2d6558791b0;p=firefly-linux-kernel-4.4.55.git mmc: host: rk_sdmmc.c Fix 67f4bf0667d and move sdio-relative clk managerment in dw_mci_set_sdio_status. --- diff --git a/drivers/mmc/host/rk_sdmmc.c b/drivers/mmc/host/rk_sdmmc.c index 6889476634c7..6ba6bf6d2e87 100755 --- a/drivers/mmc/host/rk_sdmmc.c +++ b/drivers/mmc/host/rk_sdmmc.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "rk_sdmmc.h" #include "rk_sdmmc_of.h" @@ -1217,12 +1218,7 @@ EXIT_POWER: slot->host->pdata->setpower(slot->id, 0); regs = mci_readl(slot->host, PWREN); regs &= ~(1 << slot->id); - mci_writel(slot->host, PWREN, regs); - /* SD card should wake clk system for CD int */ - if(!(mmc->restrict_caps & RESTRICT_CARD_TYPE_SD)){ - clk_disable_unprepare(slot->host->clk_mmc); - clk_disable_unprepare(slot->host->hclk_mmc); - } + mci_writel(slot->host, PWREN, regs); break; default: break; @@ -1254,25 +1250,30 @@ static int dw_mci_get_ro(struct mmc_host *mmc) static int dw_mci_set_sdio_status(struct mmc_host *mmc, int val) { - struct dw_mci_slot *slot = mmc_priv(mmc); - struct dw_mci_board *brd = slot->host->pdata; + struct dw_mci_slot *slot = mmc_priv(mmc); + struct dw_mci_board *brd = slot->host->pdata; struct dw_mci *host = slot->host; - if (!(mmc->restrict_caps & RESTRICT_CARD_TYPE_SDIO)) - return 0; - - spin_lock_bh(&host->lock); - if(val){ - set_bit(DW_MMC_CARD_PRESENT, &slot->flags); - clk_prepare_enable(host->hclk_mmc); - clk_prepare_enable(host->clk_mmc); - }else{ - clear_bit(DW_MMC_CARD_PRESENT, &slot->flags); - } - spin_unlock_bh(&host->lock); - - mmc_detect_change(slot->mmc, 20); + if (!(mmc->restrict_caps & RESTRICT_CARD_TYPE_SDIO)) + return 0; + + spin_lock_bh(&host->lock); + if(val){ + set_bit(DW_MMC_CARD_PRESENT, &slot->flags); + if(host->hclk_mmc->enable_count == 0) + clk_prepare_enable(host->hclk_mmc); + if(host->clk_mmc->enable_count == 0) + clk_prepare_enable(host->clk_mmc); + }else{ + clear_bit(DW_MMC_CARD_PRESENT, &slot->flags); + if(host->clk_mmc->enable_count != 0) + clk_disable_unprepare(slot->host->clk_mmc); + if(host->hclk_mmc->enable_count != 0) + clk_disable_unprepare(slot->host->hclk_mmc); + } + spin_unlock_bh(&host->lock); + mmc_detect_change(slot->mmc, 20); - return 0; + return 0; }