]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
mmc: sdhci: tegra: move wake irq calls
authorBitan Biswas <bbiswas@nvidia.com>
Wed, 14 May 2014 11:34:50 +0000 (17:04 +0530)
committerBitan Biswas <bbiswas@nvidia.com>
Mon, 26 May 2014 13:12:12 +0000 (06:12 -0700)
Wake irq enable/disable is done from
suspend/resume instead of probe/remove

bug 992448

Change-Id: Ic5fa9bad39aa176ab07f794c5c75031cb11a3273
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: http://git-master/r/410435
Reviewed-by: Pavan Kunapuli <pkunapuli@nvidia.com>
drivers/mmc/host/sdhci-tegra.c

index 86cbbbcdf5446331261ed299c25a882c8815749c..fb79ab33b1e7cd1d7affd80d5ee5b888faf7a699 100644 (file)
@@ -3325,6 +3325,9 @@ static int tegra_sdhci_suspend(struct sdhci_host *sdhci)
        struct sdhci_pltfm_host *pltfm_host = sdhci_priv(sdhci);
        struct sdhci_tegra *tegra_host = pltfm_host->priv;
        int err = 0;
+       struct platform_device *pdev = to_platform_device(mmc_dev(sdhci->mmc));
+       const struct tegra_sdhci_platform_data *plat;
+       unsigned int cd_irq;
 
        tegra_sdhci_set_clock(sdhci, 0);
 
@@ -3336,6 +3339,18 @@ static int tegra_sdhci_suspend(struct sdhci_host *sdhci)
                        dev_err(mmc_dev(sdhci->mmc),
                        "Regulators disable in suspend failed %d\n", err);
        }
+       plat = pdev->dev.platform_data;
+       if (plat && gpio_is_valid(plat->cd_gpio)) {
+               if (!plat->cd_wakeup_incapable) {
+                       /* Enable wake irq at end of suspend */
+                       cd_irq = gpio_to_irq(plat->cd_gpio);
+                       err = enable_irq_wake(cd_irq);
+                       if (err < 0)
+                               dev_err(mmc_dev(sdhci->mmc),
+                               "SD card wake-up event registration for irq=%d failed with error: %d\n",
+                               cd_irq, err);
+               }
+       }
        return err;
 }
 
@@ -3347,11 +3362,17 @@ static int tegra_sdhci_resume(struct sdhci_host *sdhci)
        struct tegra_sdhci_platform_data *plat;
        unsigned int signal_voltage = 0;
        int err;
+       unsigned int cd_irq;
 
        pdev = to_platform_device(mmc_dev(sdhci->mmc));
        plat = pdev->dev.platform_data;
 
-       if (gpio_is_valid(plat->cd_gpio)) {
+       if (plat && gpio_is_valid(plat->cd_gpio)) {
+               /* disable wake capability at start of resume */
+               if (!plat->cd_wakeup_incapable) {
+                       cd_irq = gpio_to_irq(plat->cd_gpio);
+                       disable_irq_wake(cd_irq);
+               }
                tegra_host->card_present =
                        (gpio_get_value_cansleep(plat->cd_gpio) == 0);
        }
@@ -3369,7 +3390,7 @@ static int tegra_sdhci_resume(struct sdhci_host *sdhci)
                        return err;
                }
                if (tegra_host->vdd_io_reg) {
-                       if (plat->mmc_data.ocr_mask & SDHOST_1V8_OCR_MASK)
+                       if (plat && (plat->mmc_data.ocr_mask & SDHOST_1V8_OCR_MASK))
                                signal_voltage = MMC_SIGNAL_VOLTAGE_180;
                        else
                                signal_voltage = MMC_SIGNAL_VOLTAGE_330;
@@ -4496,13 +4517,6 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
                        dev_err(mmc_dev(host->mmc), "request irq error\n");
                        goto err_cd_irq_req;
                }
-               if (!plat->cd_wakeup_incapable) {
-                       rc = enable_irq_wake(gpio_to_irq(plat->cd_gpio));
-                       if (rc < 0)
-                               dev_err(mmc_dev(host->mmc),
-                                       "SD card wake-up event registration "
-                                       "failed with error: %d\n", rc);
-               }
        }
        sdhci_tegra_error_stats_debugfs(host);
        device_create_file(&pdev->dev, &dev_attr_cmd_state);
@@ -4564,8 +4578,6 @@ static int sdhci_tegra_remove(struct platform_device *pdev)
 
        sdhci_remove_host(host, dead);
 
-       disable_irq_wake(gpio_to_irq(plat->cd_gpio));
-
        rc = tegra_sdhci_configure_regulators(tegra_host, CONFIG_REG_DIS, 0, 0);
        if (rc)
                dev_err(mmc_dev(host->mmc),