linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] SDHCI: add sdhci_get_cd callback to detect the card
@ 2011-12-05  9:23 r66093
  2011-12-05  9:23 ` [PATCH 2/4] MMC/SD: Add callback function to detect card r66093
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: r66093 @ 2011-12-05  9:23 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang

From: Jerry Huang <Chang-Ming.Huang@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 bit13(Card detect pin level) and bit15(CINS).

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
---
 drivers/mmc/host/sdhci.c |   20 ++++++++++++++++++++
 drivers/mmc/host/sdhci.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6d8eea3..66afd82 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2,6 +2,7 @@
  *  linux/drivers/mmc/host/sdhci.c - Secure Digital Host Controller Interface driver
  *
  *  Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
+ *  Copyright (C) 2011 Freescale Semiconductor Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1518,6 +1519,24 @@ static int sdhci_get_ro(struct mmc_host *mmc)
 	return ret;
 }
 
+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 | SDHCI_CARD_CDPL));
+}
+
 static void sdhci_enable_sdio_irq_nolock(struct sdhci_host *host, int enable)
 {
 	if (host->flags & SDHCI_DEVICE_DEAD)
@@ -1884,6 +1903,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,
 	.hw_reset	= sdhci_hw_reset,
 	.enable_sdio_irq = sdhci_enable_sdio_irq,
 	.start_signal_voltage_switch	= sdhci_start_signal_voltage_switch,
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 0a5b654..8ea7e00 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -69,6 +69,7 @@
 #define  SDHCI_SPACE_AVAILABLE	0x00000400
 #define  SDHCI_DATA_AVAILABLE	0x00000800
 #define  SDHCI_CARD_PRESENT	0x00010000
+#define  SDHCI_CARD_CDPL	0x00040000
 #define  SDHCI_WRITE_PROTECT	0x00080000
 #define  SDHCI_DATA_LVL_MASK	0x00F00000
 #define   SDHCI_DATA_LVL_SHIFT	20
-- 
1.7.5.4



^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2011-12-14  2:31 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-05  9:23 [PATCH 1/4] SDHCI: add sdhci_get_cd callback to detect the card r66093
2011-12-05  9:23 ` [PATCH 2/4] MMC/SD: Add callback function to detect card r66093
2011-12-05  9:23   ` [PATCH 3/4] MMC/core: Make sure the power is up, when detect the card r66093
2011-12-05  9:23     ` [PATCH 4/4] MMC/core: Add f_min to mmc_power_on() r66093
2011-12-05 15:48     ` [PATCH 3/4] MMC/core: Make sure the power is up, when detect the card Ulf Hansson
2011-12-06  5:40       ` Huang Changming-R66093
2011-12-07  9:04     ` Linus Walleij
2011-12-09  3:16       ` Huang Changming-R66093
2011-12-09 10:03   ` [PATCH 2/4] MMC/SD: Add callback function to detect card Adrian Hunter
2011-12-13  7:25     ` Huang Changming-R66093
2011-12-13  8:01       ` Adrian Hunter
2011-12-13  8:26         ` Huang Changming-R66093
2011-12-13  8:54           ` Adrian Hunter
2011-12-13  9:55             ` Huang Changming-R66093
2011-12-13 10:26               ` Adrian Hunter
2011-12-14  2:21                 ` Huang Changming-R66093
2011-12-05 11:25 ` [PATCH 1/4] SDHCI: add sdhci_get_cd callback to detect the card Dong, Chuanxiao
2011-12-06  5:43   ` Huang Changming-R66093
2011-12-05 18:48 ` Philip Rakity
2011-12-06  5:35   ` Huang Changming-R66093
2011-12-13 18:06   ` Chris Ball
2011-12-14  2:31     ` Huang Changming-R66093

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).