All of lore.kernel.org
 help / color / mirror / Atom feed
From: <r66093@freescale.com>
To: linux-mmc@vger.kernel.org
Cc: Jerry Huang <r66093@freescale.com>
Subject: [PATCH 1/3] SDHCI: add sdhci_get_cd callback to detect the card
Date: Fri, 20 May 2011 15:35:12 +0800	[thread overview]
Message-ID: <1305876914-23714-1-git-send-email-r66093@freescale.com> (raw)

From: Jerry Huang <r66093@freescale.com>

Add callback function sdhci_get_cd to detect the card.

In order to check if the card is present,
we will read the PRESENT STATE register and check the bit15.

Signed-off-by: Jerry Huang <r66093@freescale.com>
---
 drivers/mmc/host/sdhci.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 9e15f41..2e60372 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1262,6 +1262,24 @@ static int sdhci_get_ro(struct mmc_host *mmc)
 		!is_readonly : is_readonly;
 }
 
+static int sdhci_get_cd(struct mmc_host *mmc)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	unsigned long flags;
+	int present;
+
+	spin_lock_irqsave(&host->lock, flags);
+
+	if (host->flags & SDHCI_DEVICE_DEAD)
+		present = 0;
+	else
+		present = sdhci_readl(host, SDHCI_PRESENT_STATE);
+
+	spin_unlock_irqrestore(&host->lock, flags);
+
+	return present & SDHCI_CARD_PRESENT;
+}
+
 static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)
 {
 	struct sdhci_host *host;
@@ -1288,6 +1306,7 @@ static const struct mmc_host_ops sdhci_ops = {
 	.request	= sdhci_request,
 	.set_ios	= sdhci_set_ios,
 	.get_ro		= sdhci_get_ro,
+	.get_cd		= sdhci_get_cd,
 	.enable_sdio_irq = sdhci_enable_sdio_irq,
 };
 
-- 
1.7.4.1



             reply	other threads:[~2011-05-20  8:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20  7:35 r66093 [this message]
2011-05-20  7:35 ` [PATCH 2/3] MMC/SD: add callback function to detect card r66093
2011-05-20  7:35   ` [PATCH 3/3] SDHC/MMC: add f_min to mmc_power_on r66093
  -- strict thread matches above, loose matches on Subject: below --
2011-05-12  5:24 [PATCH 1/3] SDHCI: add sdhci_get_cd callback to detect the card r66093
2011-05-11  9:32 Chang-Ming.Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305876914-23714-1-git-send-email-r66093@freescale.com \
    --to=r66093@freescale.com \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.