summaryrefslogtreecommitdiff
path: root/drivers/mmc
diff options
context:
space:
mode:
authorPavan Kunapuli <pkunapuli@nvidia.com>2011-05-20 17:41:02 +0530
committerNiket Sirsi <nsirsi@nvidia.com>2011-05-24 16:26:07 -0700
commit59e90176334eee9bfc86c63c8bf29ef9f0ddbd9a (patch)
tree716ff9180dd33f2e200369d3bbf8580bde98bf09 /drivers/mmc
parent4af6b02c35e2d75765b9d1d020151dd6bb3e4030 (diff)
sdhci: Add card_detect callback in sdhci_ops
Added card_detect callback in sdhci_ops. When SDHCI_QUIRK_BROKEN_CARD_DETECTION is enabled, get the card present status from this callback. Bug 827470 Change-Id: Ifdd9576ff4e33a4be4c32a57e2d49d692ec95f36 Reviewed-on: http://git-master/r/31987 Reviewed-by: Pavan Kunapuli <pkunapuli@nvidia.com> Tested-by: Pavan Kunapuli <pkunapuli@nvidia.com> Reviewed-by: Suresh Mangipudi <smangipudi@nvidia.com> Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/sdhci.c25
-rw-r--r--drivers/mmc/host/sdhci.h1
2 files changed, 20 insertions, 6 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index d1180cc49bb8..fc941132b921 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1125,11 +1125,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->card_detect)
+ present = host->ops->card_detect(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;
@@ -1298,10 +1302,17 @@ static const struct mmc_host_ops sdhci_ops = {
void sdhci_card_detect_callback(struct sdhci_host *host)
{
unsigned long flags;
+ int present;
spin_lock_irqsave(&host->lock, flags);
- if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
+ if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
+ host->ops->card_detect)
+ present = host->ops->card_detect(host);
+ else
+ present = (sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
+
+ if (!present) {
if (host->mrq) {
printk(KERN_ERR "%s: Card removed during transfer!\n",
mmc_hostname(host->mmc));
@@ -1895,8 +1906,10 @@ int sdhci_add_host(struct sdhci_host *host)
if (host->quirks & SDHCI_QUIRK_FORCE_HIGH_SPEED_MODE)
mmc->caps |= MMC_CAP_FORCE_HS;
- if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
- mmc->caps |= MMC_CAP_NEEDS_POLL;
+ if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) {
+ if (!host->ops->card_detect)
+ mmc->caps |= MMC_CAP_NEEDS_POLL;
+ }
if (host->quirks & SDHCI_QUIRK_RUNTIME_DISABLE)
mmc->caps |= MMC_CAP_DISABLE;
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 781cd2a3e95d..a5f9c2f5e2b3 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -343,6 +343,7 @@ struct sdhci_ops {
unsigned int (*get_max_clock)(struct sdhci_host *host);
unsigned int (*get_min_clock)(struct sdhci_host *host);
unsigned int (*get_timeout_clock)(struct sdhci_host *host);
+ int (*card_detect)(struct sdhci_host *host);
};
#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS