All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] SDHCI: add sdhci_get_cd callback to detect the card
@ 2011-05-20  7:35 r66093
  2011-05-20  7:35 ` [PATCH 2/3] MMC/SD: add callback function to detect card r66093
  0 siblings, 1 reply; 5+ messages in thread
From: r66093 @ 2011-05-20  7:35 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang

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



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

* [PATCH 2/3] MMC/SD: add callback function to detect card
  2011-05-20  7:35 [PATCH 1/3] SDHCI: add sdhci_get_cd callback to detect the card r66093
@ 2011-05-20  7:35 ` r66093
  2011-05-20  7:35   ` [PATCH 3/3] SDHC/MMC: add f_min to mmc_power_on r66093
  0 siblings, 1 reply; 5+ messages in thread
From: r66093 @ 2011-05-20  7:35 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang

From: Jerry Huang <r66093@freescale.com>

Add callback function to check if the card has been removed.

in order to check if the card has been removed, the function mmc_send_status
will send commad CMD13 to card and ask the card to send its status register
to sdhc driver, which will generate interrupt repeatly and make the performance
of the system bad.
Therefore, get_cd callback is used to detect the card if the driver has.

Signed-off-by: Jerry Huang <r66093@freescale.com>
---
 drivers/mmc/core/mmc.c |    5 ++++-
 drivers/mmc/core/sd.c  |    5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 772d0d0..137d529 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -713,7 +713,10 @@ static void mmc_detect(struct mmc_host *host)
 	/*
 	 * Just check if our card has been removed.
 	 */
-	err = mmc_send_status(host->card, NULL);
+	if (host->ops->get_cd)
+		err = !host->ops->get_cd(host);
+	else
+		err = mmc_send_status(host->card, NULL);
 
 	mmc_release_host(host);
 
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 6dac89f..b85df32 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -673,7 +673,10 @@ static void mmc_sd_detect(struct mmc_host *host)
 	/*
 	 * Just check if our card has been removed.
 	 */
-	err = mmc_send_status(host->card, NULL);
+	if (host->ops->get_cd)
+		err = !host->ops->get_cd(host);
+	else
+		err = mmc_send_status(host->card, NULL);
 
 	mmc_release_host(host);
 
-- 
1.7.4.1



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

* [PATCH 3/3] SDHC/MMC: add f_min to mmc_power_on
  2011-05-20  7:35 ` [PATCH 2/3] MMC/SD: add callback function to detect card r66093
@ 2011-05-20  7:35   ` r66093
  0 siblings, 0 replies; 5+ messages in thread
From: r66093 @ 2011-05-20  7:35 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang

From: Jerry Huang <r66093@freescale.com>

1. when f_init is zero, the SDHC can't work correctly, so f_min will replace it.
2. Before running get_cd recall function to detect if the card is present,
   must make sure the power is up.

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

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 1f453ac..5a22b85 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -993,7 +993,10 @@ static void mmc_power_up(struct mmc_host *host)
 	 */
 	mmc_delay(10);
 
-	host->ios.clock = host->f_init;
+	if (host->f_init)
+		host->ios.clock = host->f_init;
+	else
+		host->ios.clock = host->f_min;
 
 	host->ios.power_mode = MMC_POWER_ON;
 	mmc_set_ios(host);
@@ -1571,8 +1574,10 @@ void mmc_rescan(struct work_struct *work)
 	 */
 	mmc_bus_put(host);
 
+	mmc_power_up(host);
 	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
 		goto out;
+	mmc_power_off(host);
 
 	mmc_claim_host(host);
 	for (i = 0; i < ARRAY_SIZE(freqs); i++) {
-- 
1.7.4.1



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

* [PATCH 1/3] SDHCI: add sdhci_get_cd callback to detect the card
@ 2011-05-12  5:24 r66093
  0 siblings, 0 replies; 5+ messages in thread
From: r66093 @ 2011-05-12  5:24 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 bit15.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@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



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

* [PATCH 1/3] SDHCI: add sdhci_get_cd callback to detect the card
@ 2011-05-11  9:32 Chang-Ming.Huang
  0 siblings, 0 replies; 5+ messages in thread
From: Chang-Ming.Huang @ 2011-05-11  9:32 UTC (permalink / raw)
  To: linux-mmc; +Cc: linuxppc-dev, 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 bit15.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@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



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

end of thread, other threads:[~2011-05-20  8:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-20  7:35 [PATCH 1/3] SDHCI: add sdhci_get_cd callback to detect the card r66093
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

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.