mmc: msm_sdcc: Enable SDC host->clk only after setting the rate.
[pandora-kernel.git] / drivers / mmc / host / msm_sdcc.c
index a4c865a..de00001 100644 (file)
@@ -939,7 +939,7 @@ static void msmsdcc_setup_gpio(struct msmsdcc_host *host, bool enable)
        struct msm_mmc_gpio_data *curr;
        int i, rc = 0;
 
-       if (!host->plat->gpio_data && host->gpio_config_status == enable)
+       if (!host->plat->gpio_data || host->gpio_config_status == enable)
                return;
 
        curr = host->plat->gpio_data;
@@ -1052,10 +1052,19 @@ static void msmsdcc_enable_sdio_irq(struct mmc_host *mmc, int enable)
        spin_unlock_irqrestore(&host->lock, flags);
 }
 
+static void msmsdcc_init_card(struct mmc_host *mmc, struct mmc_card *card)
+{
+       struct msmsdcc_host *host = mmc_priv(mmc);
+
+       if (host->plat->init_card)
+               host->plat->init_card(card);
+}
+
 static const struct mmc_host_ops msmsdcc_ops = {
        .request        = msmsdcc_request,
        .set_ios        = msmsdcc_set_ios,
        .enable_sdio_irq = msmsdcc_enable_sdio_irq,
+       .init_card      = msmsdcc_init_card,
 };
 
 static void
@@ -1206,7 +1215,7 @@ msmsdcc_probe(struct platform_device *pdev)
        host->base = ioremap(memres->start, PAGE_SIZE);
        if (!host->base) {
                ret = -ENOMEM;
-               goto out;
+               goto host_free;
        }
 
        host->cmd_irqres = cmd_irqres;
@@ -1221,13 +1230,15 @@ msmsdcc_probe(struct platform_device *pdev)
        /*
         * Setup DMA
         */
-       msmsdcc_init_dma(host);
+       ret = msmsdcc_init_dma(host);
+       if (ret)
+               goto ioremap_free;
 
        /* Get our clocks */
        host->pclk = clk_get(&pdev->dev, "sdc_pclk");
        if (IS_ERR(host->pclk)) {
                ret = PTR_ERR(host->pclk);
-               goto host_free;
+               goto dma_free;
        }
 
        host->clk = clk_get(&pdev->dev, "sdc_clk");
@@ -1236,17 +1247,17 @@ msmsdcc_probe(struct platform_device *pdev)
                goto pclk_put;
        }
 
-       /* Enable clocks */
-       ret = msmsdcc_enable_clocks(host);
-       if (ret)
-               goto clk_put;
-
        ret = clk_set_rate(host->clk, msmsdcc_fmin);
        if (ret) {
                pr_err("%s: Clock rate set failed (%d)\n", __func__, ret);
-               goto clk_disable;
+               goto clk_put;
        }
 
+       /* Enable clocks */
+       ret = msmsdcc_enable_clocks(host);
+       if (ret)
+               goto clk_put;
+
        host->pclk_rate = clk_get_rate(host->pclk);
        host->clk_rate = clk_get_rate(host->clk);
 
@@ -1368,6 +1379,12 @@ msmsdcc_probe(struct platform_device *pdev)
        clk_put(host->clk);
  pclk_put:
        clk_put(host->pclk);
+dma_free:
+       dma_free_coherent(NULL, sizeof(struct msmsdcc_nc_dmadata),
+                               host->dma.nc, host->dma.nc_busaddr);
+ioremap_free:
+       tasklet_kill(&host->dma_tlet);
+       iounmap(host->base);
  host_free:
        mmc_free_host(mmc);
  out: