mmc: tegra: Enable SDHCI_QUIRK_BROKEN_CARD_DETECTION
Pavan Kunapuli [Mon, 5 Mar 2012 13:49:16 +0000 (18:49 +0530)]
Enable quirk SDHCI_QUIRK_BROKEN_CARD_DETECTION.
Also, implemented tegra_sdhci_get_cd() to return
the card presence status.

Bug 948943

Change-Id: I42eed23f951304e331a235f5a9199b70ba5e96b5
Signed-off-by: Pavan Kunapuli <pkunapuli@nvidia.com>
Reviewed-on: http://git-master/r/87766
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

drivers/mmc/host/sdhci-tegra.c

index fb72829..2276fde 100644 (file)
@@ -162,6 +162,14 @@ static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg)
 #endif
 }
 
+static unsigned int tegra_sdhci_get_cd(struct sdhci_host *sdhci)
+{
+       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(sdhci);
+       struct tegra_sdhci_host *tegra_host = pltfm_host->priv;
+
+       return tegra_host->card_present;
+}
+
 static unsigned int tegra_sdhci_get_ro(struct sdhci_host *sdhci)
 {
        struct platform_device *pdev = to_platform_device(mmc_dev(sdhci->mmc));
@@ -861,6 +869,7 @@ static int tegra_sdhci_resume(struct sdhci_host *sdhci)
 
 static struct sdhci_ops tegra_sdhci_ops = {
        .get_ro     = tegra_sdhci_get_ro,
+       .get_cd     = tegra_sdhci_get_cd,
        .read_l     = tegra_sdhci_readl,
        .read_w     = tegra_sdhci_readw,
        .write_l    = tegra_sdhci_writel,
@@ -887,7 +896,8 @@ static struct sdhci_pltfm_data sdhci_tegra_pdata = {
                  SDHCI_QUIRK_SINGLE_POWER_WRITE |
                  SDHCI_QUIRK_NO_HISPD_BIT |
                  SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC |
-                 SDHCI_QUIRK_NO_CALC_MAX_DISCARD_TO,
+                 SDHCI_QUIRK_NO_CALC_MAX_DISCARD_TO |
+                 SDHCI_QUIRK_BROKEN_CARD_DETECTION,
        .ops  = &tegra_sdhci_ops,
 };
 
@@ -987,6 +997,12 @@ static int __devinit sdhci_tegra_probe(struct platform_device *pdev)
                gpio_direction_input(plat->wp_gpio);
        }
 
+       /*
+        * If there is no card detect gpio, assume that the
+        * card is always present.
+        */
+       if (!gpio_is_valid(plat->cd_gpio))
+               tegra_host->card_present = 1;
 
        if (!plat->mmc_data.built_in) {
                if (plat->mmc_data.ocr_mask & SDHOST_1V8_OCR_MASK) {