All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] MMC/core: Make sure the power is up, when detect the card
@ 2011-12-06  9:15 r66093
  2011-12-06  9:15 ` [PATCH 2/5] MMC/core: Add f_min to mmc_power_on() r66093
  0 siblings, 1 reply; 7+ messages in thread
From: r66093 @ 2011-12-06  9:15 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

Before running get_cd() recall function to detect whether the card is
present, must make sure the power is up.

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

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 5278ffb..a08e6b1 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2066,8 +2066,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.5.4



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

* [PATCH 2/5] MMC/core: Add f_min to mmc_power_on()
  2011-12-06  9:15 [PATCH 1/5] MMC/core: Make sure the power is up, when detect the card r66093
@ 2011-12-06  9:15 ` r66093
  2011-12-06  9:15   ` [PATCH 3/5 v2] MMC/SD: Add callback function to detect card r66093
  0 siblings, 1 reply; 7+ messages in thread
From: r66093 @ 2011-12-06  9:15 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

When f_init is zero, the SDHC can't work correctly. So f_min will replace
f_init, when f_init is zero.

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

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index a08e6b1..2d40c04 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1253,7 +1253,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);
-- 
1.7.5.4



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

* [PATCH 3/5 v2] MMC/SD: Add callback function to detect card
  2011-12-06  9:15 ` [PATCH 2/5] MMC/core: Add f_min to mmc_power_on() r66093
@ 2011-12-06  9:15   ` r66093
  2011-12-06  9:15     ` [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card r66093
  0 siblings, 1 reply; 7+ messages in thread
From: r66093 @ 2011-12-06  9:15 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Chris Ball

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

In order to check whether the card has been removed, the function
mmc_send_status() will send command CMD13 to card and ask the card
to send its status register to sdhc driver, which will generate
many interrupts repeatedly and make the system performance bad.

Therefore, add callback function get_cd() to check whether
the card has been removed when the driver has this callback function.

If the card is present, 1 will return, if the card is absent, 0 will return.
If the controller will not support this feature, -ENOSYS will return.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- when controller don't support get_cd, return -ENOSYS
	- add the CC

 drivers/mmc/core/mmc.c |   10 ++++++++--
 drivers/mmc/core/sd.c  |   10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index dbf421a..e03860e 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1105,7 +1105,7 @@ static void mmc_remove(struct mmc_host *host)
  */
 static void mmc_detect(struct mmc_host *host)
 {
-	int err;
+	int err = -ENOSYS;
 
 	BUG_ON(!host);
 	BUG_ON(!host->card);
@@ -1115,7 +1115,13 @@ 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);
+		if (err >= 0)
+			err = !err;
+	}
+	if (err < 0)
+		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 f2a05ea..7e61bf0 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1023,7 +1023,7 @@ static void mmc_sd_remove(struct mmc_host *host)
  */
 static void mmc_sd_detect(struct mmc_host *host)
 {
-	int err;
+	int err = -ENOSYS;
 
 	BUG_ON(!host);
 	BUG_ON(!host->card);
@@ -1033,7 +1033,13 @@ 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);
+		if (err >= 0)
+			err = !err;
+	}
+	if (err < 0)
+		err = mmc_send_status(host->card, NULL);
 
 	mmc_release_host(host);
 
-- 
1.7.5.4



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

* [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card
  2011-12-06  9:15   ` [PATCH 3/5 v2] MMC/SD: Add callback function to detect card r66093
@ 2011-12-06  9:15     ` r66093
  2011-12-06  9:15       ` [PATCH 5/5 v2] ESDHC: add callback esdhc_of_get_cd to detect card r66093
  2011-12-06 12:11       ` [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card Hein_Tibosch
  0 siblings, 2 replies; 7+ messages in thread
From: r66093 @ 2011-12-06  9:15 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Chris Ball

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

Add callback function sdhci_get_cd to detect the card.
And one new callback added to implement the card detect in sdhci struncture.
If special platform has the card detect callback, it will return the card
state, the value zero is for absent cardi and one is for present card.
If the controller don't support card detect, sdhci_get_cd will return -ENOSYS.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- when controller don't support get_cd, return -ENOSYS
	- add new callback for sdhci to detect the card
	- add the CC

 drivers/mmc/host/sdhci.c |   21 +++++++++++++++++++++
 drivers/mmc/host/sdhci.h |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6d8eea3..2196c5e 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,25 @@ static int sdhci_get_ro(struct mmc_host *mmc)
 	return ret;
 }
 
+/* Return values for the sdjco_get_cd callback:
+ *   0 for a absent card
+ *   1 for a present card
+ *   -ENOSYS when not supported (equal to NULL callback)
+ */
+static int sdhci_get_cd(struct mmc_host *mmc)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	unsigned long flags;
+	int present = -ENOSYS;
+
+	spin_lock_irqsave(&host->lock, flags);
+	if (host->ops->get_cd)
+		present = host->ops->get_cd(host);
+	spin_unlock_irqrestore(&host->lock, flags);
+
+	return present;
+}
+
 static void sdhci_enable_sdio_irq_nolock(struct sdhci_host *host, int enable)
 {
 	if (host->flags & SDHCI_DEVICE_DEAD)
@@ -1884,6 +1904,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..82f4d27 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
@@ -261,6 +262,7 @@ struct sdhci_ops {
 
 	void	(*set_clock)(struct sdhci_host *host, unsigned int clock);
 
+	int		(*get_cd)(struct sdhci_host *host);
 	int		(*enable_dma)(struct sdhci_host *host);
 	unsigned int	(*get_max_clock)(struct sdhci_host *host);
 	unsigned int	(*get_min_clock)(struct sdhci_host *host);
-- 
1.7.5.4



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

* [PATCH 5/5 v2] ESDHC: add callback esdhc_of_get_cd to detect card
  2011-12-06  9:15     ` [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card r66093
@ 2011-12-06  9:15       ` r66093
  2011-12-06 12:11       ` [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card Hein_Tibosch
  1 sibling, 0 replies; 7+ messages in thread
From: r66093 @ 2011-12-06  9:15 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Chris Ball

From: Jerry Huang <Chang-Ming.Huang@freescale.com>

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>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- add new callback for esdhc to detect the card state
	- add the CC

 drivers/mmc/host/sdhci-of-esdhc.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 59e9d00..cb71810 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -1,7 +1,7 @@
 /*
  * Freescale eSDHC controller driver.
  *
- * Copyright (c) 2007, 2010 Freescale Semiconductor, Inc.
+ * Copyright (c) 2007, 2010-2011 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
  *
  * Authors: Xiaobo Xie <X.Xie@freescale.com>
@@ -82,6 +82,21 @@ static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host)
 	return pltfm_host->clock / 256 / 16;
 }
 
+/* Return: none zero - the card is presetn; 0 - card is absent */
+static int esdhc_of_get_cd(struct sdhci_host *host)
+{
+	int present;
+
+	if (host->flags & SDHCI_DEVICE_DEAD)
+		present = 0;
+	else {
+		present = sdhci_be32bs_readl(host, SDHCI_PRESENT_STATE);
+		present &= (SDHCI_CARD_PRESENT | SDHCI_CARD_CDPL);
+	}
+
+	return present;
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
 	.read_l = sdhci_be32bs_readl,
 	.read_w = esdhc_readw,
@@ -93,6 +108,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
 	.enable_dma = esdhc_of_enable_dma,
 	.get_max_clock = esdhc_of_get_max_clock,
 	.get_min_clock = esdhc_of_get_min_clock,
+	.get_cd = esdhc_of_get_cd,
 };
 
 static struct sdhci_pltfm_data sdhci_esdhc_pdata = {
-- 
1.7.5.4



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

* Re: [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card
  2011-12-06  9:15     ` [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card r66093
  2011-12-06  9:15       ` [PATCH 5/5 v2] ESDHC: add callback esdhc_of_get_cd to detect card r66093
@ 2011-12-06 12:11       ` Hein_Tibosch
  2011-12-07  2:35         ` Huang Changming-R66093
  1 sibling, 1 reply; 7+ messages in thread
From: Hein_Tibosch @ 2011-12-06 12:11 UTC (permalink / raw)
  To: r66093; +Cc: linux-mmc, Jerry Huang, Chris Ball

Hi Jerry,

On 12/6/2011 5:15 PM, r66093@freescale.com wrote:
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>
> Add callback function sdhci_get_cd to detect the card.
> And one new callback added to implement the card detect in sdhci struncture.
> If special platform has the card detect callback, it will return the card
> state, the value zero is for absent cardi and one is for present card.
> If the controller don't support card detect, sdhci_get_cd will return -ENOSYS.
>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
> 	- when controller don't support get_cd, return -ENOSYS
> 	- add new callback for sdhci to detect the card
> 	- add the CC
>
>  drivers/mmc/host/sdhci.c |   21 +++++++++++++++++++++
>  drivers/mmc/host/sdhci.h |    2 ++
>  2 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 6d8eea3..2196c5e 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,25 @@ static int sdhci_get_ro(struct mmc_host *mmc)
>  	return ret;
>  }
>  
> +/* Return values for the sdjco_get_cd callback:
> + *   0 for a absent card
> + *   1 for a present card
> + *   -ENOSYS when not supported (equal to NULL callback)
> + */
> +static int sdhci_get_cd(struct mmc_host *mmc)
> +{
> +	struct sdhci_host *host = mmc_priv(mmc);
> +	unsigned long flags;
> +	int present = -ENOSYS;
> +
> +	spin_lock_irqsave(&host->lock, flags);
> +	if (host->ops->get_cd)
> +		present = host->ops->get_cd(host);
> +	spin_unlock_irqrestore(&host->lock, flags);

Maybe only use spin-lock if get_cd is defined?

> +
> +	return present;
> +}
> +
>  static void sdhci_enable_sdio_irq_nolock(struct sdhci_host *host, int enable)
>  {
>  	if (host->flags & SDHCI_DEVICE_DEAD)
> @@ -1884,6 +1904,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..82f4d27 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
> @@ -261,6 +262,7 @@ struct sdhci_ops {
>  
>  	void	(*set_clock)(struct sdhci_host *host, unsigned int clock);
>  
> +	int		(*get_cd)(struct sdhci_host *host);
>  	int		(*enable_dma)(struct sdhci_host *host);
>  	unsigned int	(*get_max_clock)(struct sdhci_host *host);
>  	unsigned int	(*get_min_clock)(struct sdhci_host *host);

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

* RE: [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card
  2011-12-06 12:11       ` [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card Hein_Tibosch
@ 2011-12-07  2:35         ` Huang Changming-R66093
  0 siblings, 0 replies; 7+ messages in thread
From: Huang Changming-R66093 @ 2011-12-07  2:35 UTC (permalink / raw)
  To: Hein_Tibosch; +Cc: linux-mmc, Chris Ball



> -----Original Message-----
> From: Hein_Tibosch [mailto:hein_tibosch@yahoo.es]
> Sent: Tuesday, December 06, 2011 8:11 PM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Huang Changming-R66093; Chris Ball
> Subject: Re: [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect
> the card
> 
> Hi Jerry,
> 
> On 12/6/2011 5:15 PM, r66093@freescale.com wrote:
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> >
> > Add callback function sdhci_get_cd to detect the card.
> > And one new callback added to implement the card detect in sdhci
> struncture.
> > If special platform has the card detect callback, it will return the
> > card state, the value zero is for absent cardi and one is for present
> card.
> > If the controller don't support card detect, sdhci_get_cd will return -
> ENOSYS.
> >
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > CC: Chris Ball <cjb@laptop.org>
> > ---
> > changes for v2:
> > 	- when controller don't support get_cd, return -ENOSYS
> > 	- add new callback for sdhci to detect the card
> > 	- add the CC
> >
> >  drivers/mmc/host/sdhci.c |   21 +++++++++++++++++++++
> >  drivers/mmc/host/sdhci.h |    2 ++
> >  2 files changed, 23 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index
> > 6d8eea3..2196c5e 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,25 @@ static int sdhci_get_ro(struct mmc_host *mmc)
> >  	return ret;
> >  }
> >
> > +/* Return values for the sdjco_get_cd callback:
> > + *   0 for a absent card
> > + *   1 for a present card
> > + *   -ENOSYS when not supported (equal to NULL callback)
> > + */
> > +static int sdhci_get_cd(struct mmc_host *mmc) {
> > +	struct sdhci_host *host = mmc_priv(mmc);
> > +	unsigned long flags;
> > +	int present = -ENOSYS;
> > +
> > +	spin_lock_irqsave(&host->lock, flags);
> > +	if (host->ops->get_cd)
> > +		present = host->ops->get_cd(host);
> > +	spin_unlock_irqrestore(&host->lock, flags);
> 
> Maybe only use spin-lock if get_cd is defined?
> 
Yes, I will move it.


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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-06  9:15 [PATCH 1/5] MMC/core: Make sure the power is up, when detect the card r66093
2011-12-06  9:15 ` [PATCH 2/5] MMC/core: Add f_min to mmc_power_on() r66093
2011-12-06  9:15   ` [PATCH 3/5 v2] MMC/SD: Add callback function to detect card r66093
2011-12-06  9:15     ` [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card r66093
2011-12-06  9:15       ` [PATCH 5/5 v2] ESDHC: add callback esdhc_of_get_cd to detect card r66093
2011-12-06 12:11       ` [PATCH 4/5 v2] SDHCI: add sdhci_get_cd callback to detect the card Hein_Tibosch
2011-12-07  2:35         ` Huang Changming-R66093

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.