omap_hsmmc: ensure all clock enables and disables are paired
Subsystems (2)
PATCH 71/232 omap_hsmmc: ensure all clock enables and disables are paired
From: Adrian Hunter <[email protected]>
[[email protected]: fix for the db clock failure message]
Signed-off-by Adrian Hunter <[email protected]>
Acked-by Matt Fleming <[email protected]>
Cc Ian Molton <[email protected]>
Cc "Roberto A. Foglietta" <[email protected]>
Cc Jarkko Lavinen <[email protected]>
Cc Denis Karpov <[email protected]>
Cc Pierre Ossman <[email protected]>
Cc Philip Langdale <[email protected]>
Cc "Madhusudhan" <[email protected]>
Cc <[email protected]>
Signed-off-by Madhusudhan Chikkature <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
drivers/mmc/host/omap_hsmmc.c | 60 +++++++++++++++++--------------- 1 file changed, 33 insertions(+), 27 deletions(-)
drivers/mmc/host/omap_hsmmc.c renamed from drivers/mmc/host/omap_hsmmc.c~omap_hsmmc-ensure-all-clock-enables-and-disables-are-paired +33 -27
@@ -162,7 +162,7 @@ struct omap_hsmmc_host {int use_dma, dma_ch;int dma_line_tx, dma_line_rx;int slot_id; -int dbclk_enabled; +int got_dbclk;int response_busy;int context_loss;int dpm_state;
@@ -742,22 +742,24 @@ static int omap_hsmmc_switch_opcond(stru/* Disable the clocks */ clk_disable (host->fclk);clk_disable (host->iclk); -clk_disable (host->dbclk); +if (host->got_dbclk) +clk_disable (host->dbclk);/* Turn the power off */ ret =mmc_slot (host).set_power (host->dev, host->slot_id,0 ,0 ); -if (ret !=0 ) - goto err;/* Turn the power ON with given VDD 1.8 or 3.0v */ - ret =mmc_slot (host).set_power (host->dev, host->slot_id,1 , vdd); +if (!ret) + ret =mmc_slot (host).set_power (host->dev, host->slot_id,1 , + vdd); +clk_enable (host->iclk); +clk_enable (host->fclk); +if (host->got_dbclk) +clk_enable (host->dbclk); +if (ret !=0 ) goto err; -clk_enable (host->fclk); -clk_enable (host->iclk); -clk_enable (host->dbclk); -OMAP_HSMMC_WRITE (host->base,HCTL ,OMAP_HSMMC_READ (host->base,HCTL ) &SDVSCLR ); reg_val =OMAP_HSMMC_READ (host->base,HCTL );
@@ -1695,18 +1697,22 @@ static int __init omap_hsmmc_probe(struc goto err1; } - host->dbclk =clk_get (&pdev->dev,"mmchsdb_fck" ); -/* -* MMC can still work without debounce clock. -*/ -if (IS_ERR (host->dbclk)) -dev_warn (mmc_dev (host->mmc),"Failed to get debounce clock\n" ); -else -if (clk_enable (host->dbclk) !=0 ) -dev_dbg (mmc_dev (host->mmc),"Enabling debounce" -" clk failed\n" ); +if (cpu_is_omap2430 ()) { + host->dbclk =clk_get (&pdev->dev,"mmchsdb_fck" ); +/* +* MMC can still work without debounce clock. +*/ +if (IS_ERR (host->dbclk)) +dev_warn (mmc_dev (host->mmc), +"Failed to get debounce clock\n" );else - host->dbclk_enabled =1 ; + host->got_dbclk =1 ; + +if (host->got_dbclk) +if (clk_enable (host->dbclk) !=0 ) +dev_dbg (mmc_dev (host->mmc),"Enabling debounce" +" clk failed\n" ); + }/* Since we do only SG emulation, we can have as many segs * as we want. */
@@ -1820,7 +1826,7 @@ err_irq:clk_disable (host->iclk);clk_put (host->fclk);clk_put (host->iclk); -if (host->dbclk_enabled) { +if (host->got_dbclk) {clk_disable (host->dbclk);clk_put (host->dbclk); }
@@ -1854,7 +1860,7 @@ static int omap_hsmmc_remove(struct platclk_disable (host->iclk);clk_put (host->fclk);clk_put (host->iclk); -if (host->dbclk_enabled) { +if (host->got_dbclk) {clk_disable (host->dbclk);clk_put (host->dbclk); }
@@ -1905,7 +1911,8 @@ static int omap_hsmmc_suspend(struct pla OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);mmc_host_disable (host->mmc);clk_disable (host->iclk); -clk_disable (host->dbclk); +if (host->got_dbclk) +clk_disable (host->dbclk); }else { host->suspended =0 ;if (host->pdata->resume) {
@@ -1936,15 +1943,14 @@ static int omap_hsmmc_resume(struct platif (ret) goto clk_en_err; -if (clk_enable (host->dbclk) !=0 ) -dev_dbg (mmc_dev (host->mmc), -"Enabling debounce clk failed\n" ); -if (mmc_host_enable (host->mmc) !=0 ) {clk_disable (host->iclk); goto clk_en_err; } +if (host->got_dbclk) +clk_enable (host->dbclk); +omap_hsmmc_conf_bus_power (host);if (host->pdata->resume) {
_