mmc: sdhci: Add get_cd callback in host ops
Pavan Kunapuli [Mon, 5 Mar 2012 13:40:39 +0000 (18:40 +0530)]
Add get_cd callback in the host ops to get the
card presence status incase SDHCI_QUIRK_BROKEN_
CARD_DETECTION is enabled.

Bug 948943

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

drivers/mmc/host/sdhci.c
drivers/mmc/host/sdhci.h

index 96651c6..c6822c3 100644 (file)
@@ -1229,11 +1229,15 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
        host->mrq = mrq;
 
        /* If polling, assume that the card is always present. */
-       if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
-               present = true;
-       else
+       if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) {
+               if (host->ops->get_cd)
+                       present = host->ops->get_cd(host);
+               else
+                       present = true;
+       } else {
                present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
                                SDHCI_CARD_PRESENT;
+       }
 
        if (!present || host->flags & SDHCI_DEVICE_DEAD) {
                host->mrq->cmd->error = -ENOMEDIUM;
@@ -2627,7 +2631,7 @@ int sdhci_add_host(struct sdhci_host *host)
                mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
 
        if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
-           mmc_card_is_removable(mmc))
+           mmc_card_is_removable(mmc) && !(host->ops->get_cd))
                mmc->caps |= MMC_CAP_NEEDS_POLL;
 
        /* UHS-I mode(s) supported by the host controller. */
index bdf4b10..c00833d 100644 (file)
@@ -270,6 +270,7 @@ struct sdhci_ops {
        void (*platform_send_init_74_clocks)(struct sdhci_host *host,
                                             u8 power_mode);
        unsigned int    (*get_ro)(struct sdhci_host *host);
+       unsigned int    (*get_cd)(struct sdhci_host *host);
        void    (*platform_reset_enter)(struct sdhci_host *host, u8 mask);
        void    (*platform_reset_exit)(struct sdhci_host *host, u8 mask);
        int     (*set_uhs_signaling)(struct sdhci_host *host, unsigned int uhs);