mmc: host: sdhci: delayed clock gate update
Bitan Biswas [Tue, 19 Nov 2013 20:43:41 +0000 (01:43 +0530)]
Changes are:
 - cancel delayed clock gate work before suspend
 - sdhci disable does not schedule delayed clock
   gate work if clock is already disabled

bug 1372006

Change-Id: I55160b258d5a28b9e454420768a50ed70a127e9a
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: http://git-master/r/338618
(cherry picked from commit 3bbbfb7d97825c80fe0f667ce2c7c9062c1660da)
Reviewed-on: http://git-master/r/344119
Reviewed-by: Automatic_Commit_Validation_User
Tested-by: Harry Hong <hhong@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Harry Hong <hhong@nvidia.com>

drivers/mmc/host/sdhci-tegra.c
drivers/mmc/host/sdhci.c

index 8c38b69..5719624 100644 (file)
@@ -1138,10 +1138,11 @@ static void tegra_sdhci_set_clock(struct sdhci_host *sdhci, unsigned int clock)
                if (!tegra_host->clk_enabled) {
                        pm_runtime_get_sync(&pdev->dev);
                        clk_prepare_enable(pltfm_host->clk);
+                       tegra_host->clk_enabled = true;
+                       sdhci->is_clk_on = tegra_host->clk_enabled;
                        ctrl = sdhci_readb(sdhci, SDHCI_VNDR_CLK_CTRL);
                        ctrl |= SDHCI_VNDR_CLK_CTRL_SDMMC_CLK;
                        sdhci_writeb(sdhci, ctrl, SDHCI_VNDR_CLK_CTRL);
-                       tegra_host->clk_enabled = true;
                }
                tegra_sdhci_set_clk_rate(sdhci, clock);
 
@@ -1169,8 +1170,9 @@ static void tegra_sdhci_set_clock(struct sdhci_host *sdhci, unsigned int clock)
                ctrl &= ~SDHCI_VNDR_CLK_CTRL_SDMMC_CLK;
                sdhci_writeb(sdhci, ctrl, SDHCI_VNDR_CLK_CTRL);
                clk_disable_unprepare(pltfm_host->clk);
-               pm_runtime_put_sync(&pdev->dev);
                tegra_host->clk_enabled = false;
+               sdhci->is_clk_on = tegra_host->clk_enabled;
+               pm_runtime_put_sync(&pdev->dev);
        }
        sdhci->is_clk_on = tegra_host->clk_enabled;
 }
index cafcad2..f49cb1d 100644 (file)
@@ -2110,8 +2110,9 @@ int sdhci_disable(struct mmc_host *mmc)
                return 0;
 
        if (IS_DELAYED_CLK_GATE(host)) {
-               schedule_delayed_work(&host->delayed_clk_gate_wrk,
-                       DELAYED_CLK_GATING_TICK_TMOUT);
+               if (host->is_clk_on)
+                       schedule_delayed_work(&host->delayed_clk_gate_wrk,
+                               DELAYED_CLK_GATING_TICK_TMOUT);
                return 0;
        }
 
@@ -2680,6 +2681,9 @@ int sdhci_suspend_host(struct sdhci_host *host)
 
        sdhci_mask_irqs(host, SDHCI_INT_ALL_MASK);
 
+       /* cancel sdio clk gate work */
+       cancel_delayed_work_sync(&host->delayed_clk_gate_wrk);
+
        if (host->irq)
                disable_irq(host->irq);