All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 1/3 ] mmc: add support for H/W clock gating of SD controller
@ 2010-12-07 22:46 Philip Rakity
  2010-12-08  0:16 ` Chris Ball
  0 siblings, 1 reply; 12+ messages in thread
From: Philip Rakity @ 2010-12-07 22:46 UTC (permalink / raw)
  To: linux-mmc; +Cc: Nicolas Pitre, Mark Brown, Chris Ball


Revised based on Nico comments.

8 bit width support dependency removed.  Code applies directly to mmc-next
Patches 2/3 and 3/3 unchanged

>From fd6b01ae41eaf3d26755bb263f7af59a029c5d83 Mon Sep 17 00:00:00 2001
From: Philip Rakity <prakity@marvell.com>
Date: Tue, 7 Dec 2010 08:58:56 -0800
Subject: [PATCH] mmc: add support for H/W clock gating of SD controller

This code extends software clock gating in the MMC layer by adding the ability
to indicate that the SD controller supports hardware clock gating.

Hardware clock gating is enabled by setting the MMC capability
MMC_CAP_HW_CLOCK_GATING in the SD driver.

eg: host->mmc->caps |= MMC_CAP_HW_CLOCK_GATING

The approach follows the suggestion of Nico Pitre.

SD/MMC/eMMC cards use dynamic clocks
SDIO uses continuous clocks to properly detect SDIO card interrupts

The code has been tested using marvell linux for MMP2.  The Marvell
controller support H/W clock gating.

Signed-off-by: Philip Rakity <prakity@marvell.com>
Signed-off-by: Mark F. Brown <markb@marvell.com>
---
 drivers/mmc/core/core.c  |   32 ++++++++++++++++++++++++++++++++
 drivers/mmc/core/core.h  |   13 +++++++++++++
 drivers/mmc/core/host.c  |   12 ++++++++++++
 include/linux/mmc/host.h |    1 +
 4 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 6286898..de867d1 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -682,6 +682,28 @@ void mmc_ungate_clock(struct mmc_host *host)
 	}
 }
 
+/*
+ * Let hardware automatically gate the clock when the card becomes idle
+ */
+void mmc_hwgate_clock(struct mmc_host *host)
+{
+	if (host->caps & MMC_CAP_HW_CLOCK_GATING) {
+		host->clk_gated = true;
+		mmc_set_ios(host);
+	}
+}
+
+/*
+ * This ungates the clock by turning off h/w gating
+ */
+void mmc_hwungate_clock(struct mmc_host *host)
+{
+	if (host->caps & MMC_CAP_HW_CLOCK_GATING) {
+		host->clk_gated = false;
+		mmc_set_ios(host);
+	}
+}
+
 void mmc_set_ungated(struct mmc_host *host)
 {
 	unsigned long flags;
@@ -1548,6 +1570,8 @@ void mmc_rescan(struct work_struct *work)
 			mmc_hostname(host), __func__, host->f_init);
 #endif
 		mmc_power_up(host);
+
+		mmc_hwungate_clock(host);
 		sdio_reset(host);
 		mmc_go_idle(host);
 
@@ -1569,6 +1593,10 @@ void mmc_rescan(struct work_struct *work)
 
 				if (mmc_attach_sd(host, ocr))
 					mmc_power_off(host);
+
+				/* hw clock gating is off when we get here */
+				/* do not enable clock gating for sdio cards */
+				/* sdio cards can miss interrupts */
 			}
 			goto out;
 		}
@@ -1580,6 +1608,8 @@ void mmc_rescan(struct work_struct *work)
 		if (!err) {
 			if (mmc_attach_sd(host, ocr))
 				mmc_power_off(host);
+			else
+				mmc_hwgate_clock(host);
 			goto out;
 		}
 
@@ -1590,6 +1620,8 @@ void mmc_rescan(struct work_struct *work)
 		if (!err) {
 			if (mmc_attach_mmc(host, ocr))
 				mmc_power_off(host);
+			else
+				mmc_hwgate_clock(host);
 			goto out;
 		}
 
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 026c975..3810e28 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -35,6 +35,19 @@ void mmc_set_chip_select(struct mmc_host *host, int mode);
 void mmc_set_clock(struct mmc_host *host, unsigned int hz);
 void mmc_gate_clock(struct mmc_host *host);
 void mmc_ungate_clock(struct mmc_host *host);
+
+#ifdef CONFIG_MMC_CLKGATE
+void mmc_hwgate_clock(struct mmc_host *host);
+void mmc_hwungate_clock(struct mmc_host *host);
+#else
+static inline void mmc_hwgate_clock(struct mmc_host *host)
+{
+}
+
+static inline void mmc_hwungate_clock(struct mmc_host *host)
+{
+}
+#endif
 void mmc_set_ungated(struct mmc_host *host);
 void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode);
 void mmc_set_bus_width(struct mmc_host *host, unsigned int width);
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 92e3370..f4b4c2f 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -130,6 +130,9 @@ void mmc_host_clk_ungate(struct mmc_host *host)
 {
 	unsigned long flags;
 
+	if (host->caps & MMC_CAP_HW_CLOCK_GATING)
+		return;
+
 	mutex_lock(&host->clk_gate_mutex);
 	spin_lock_irqsave(&host->clk_lock, flags);
 	if (host->clk_gated) {
@@ -178,6 +181,9 @@ void mmc_host_clk_gate(struct mmc_host *host)
 {
 	unsigned long flags;
 
+	if (host->caps & MMC_CAP_HW_CLOCK_GATING)
+		return;
+
 	spin_lock_irqsave(&host->clk_lock, flags);
 	host->clk_requests--;
 	if (mmc_host_may_gate_card(host->card) &&
@@ -212,6 +218,9 @@ unsigned int mmc_host_clk_rate(struct mmc_host *host)
  */
 static inline void mmc_host_clk_init(struct mmc_host *host)
 {
+	if (host->caps & MMC_CAP_HW_CLOCK_GATING)
+		return;
+
 	host->clk_requests = 0;
 	/* Hold MCI clock for 8 cycles by default */
 	host->clk_delay = 8;
@@ -231,6 +240,9 @@ static inline void mmc_host_clk_exit(struct mmc_host *host)
 	 * Wait for any outstanding gate and then make sure we're
 	 * ungated before exiting.
 	 */
+	if (host->caps & MMC_CAP_HW_CLOCK_GATING)
+		return;
+
 	if (cancel_work_sync(&host->clk_gate_work))
 		mmc_host_clk_gate_delayed(host);
 	if (host->clk_gated)
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 381c77f..b9b3a2b 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -169,6 +169,7 @@ struct mmc_host {
 #define MMC_CAP_1_2V_DDR	(1 << 12)	/* can support */
 						/* DDR mode at 1.2V */
 #define MMC_CAP_POWER_OFF_CARD	(1 << 13)	/* Can power off after boot */
+#define MMC_CAP_HW_CLOCK_GATING	(1 << 14)	/* h/w supports clock gating */
 
 	mmc_pm_flag_t		pm_caps;	/* supported pm features */
 
-- 
1.6.0.4


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

* Re: [PATCH V3 1/3 ] mmc: add support for H/W clock gating of SD controller
  2010-12-07 22:46 [PATCH V3 1/3 ] mmc: add support for H/W clock gating of SD controller Philip Rakity
@ 2010-12-08  0:16 ` Chris Ball
  2010-12-08  0:20   ` [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend) Philip Rakity
  0 siblings, 1 reply; 12+ messages in thread
From: Chris Ball @ 2010-12-08  0:16 UTC (permalink / raw)
  To: Philip Rakity; +Cc: linux-mmc, Nicolas Pitre, Mark Brown

Hi Philip,

On Tue, Dec 07, 2010 at 02:46:25PM -0800, Philip Rakity wrote:
> 8 bit width support dependency removed.  Code applies directly to mmc-next
> Patches 2/3 and 3/3 unchanged

The submitted patches 2/3 and 3/3 are identical -- is there a separate
third patch that's unsent so far, or did you mean to send only two?

Thanks,

-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

* [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-08  0:16 ` Chris Ball
@ 2010-12-08  0:20   ` Philip Rakity
  2010-12-08  1:49     ` zhangfei gao
  0 siblings, 1 reply; 12+ messages in thread
From: Philip Rakity @ 2010-12-08  0:20 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Nicolas Pitre, Mark Brown


>From 4f521dd851066e6f65cbf3b866502a2a308eb980 Mon Sep 17 00:00:00 2001
From: Philip Rakity <prakity@marvell.com>
Date: Tue, 7 Dec 2010 09:05:39 -0800
Subject: [PATCH V2] sdhci: support H/W clock gating in Marvell PXA driver

This code is based on sdhci-pxa in mmc-next on Dec 2, 2010.

If cpu_is_mmp2() then enable MMC capability MMC_CAP_HW_CLOCK_GATING

Code may need changing based on the ongoing work on sdhci-pxa but since that
code is NOT in mmc-next better to have something that can work.

This code tested on Marvell Linux

Signed-off-by: Philip Rakity <prakity@marvell.com>
Signed-off-by: Mark F. Brown <markb@marvell.com>
---
 drivers/mmc/host/sdhci-pxa.c |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
index 5a61208..5cf47fd 100644
--- a/drivers/mmc/host/sdhci-pxa.c
+++ b/drivers/mmc/host/sdhci-pxa.c
@@ -25,6 +25,7 @@
 #include <linux/io.h>
 #include <linux/err.h>
 #include <plat/sdhci.h>
+#include <mach/cputype.h>
 #include "sdhci.h"
 
 #define DRIVER_NAME	"sdhci-pxa"
@@ -46,10 +47,27 @@ struct sdhci_pxa {
  * SDHCI core callbacks                                                      *
  *                                                                           *
 \*****************************************************************************/
+#ifdef CONFIG_MMC_CLKGATE
+static void hardware_clk_gating(struct sdhci_host *host)
+{
+	unsigned short tmp;
+	int enable;
+
+	enable = host->mmc->clk_gated;
+	tmp = readw(host->ioaddr + SD_FIFO_PARAM);
+
+	if (enable)
+		tmp &= ~DIS_PAD_SD_CLK_GATE;
+	else
+		tmp |= DIS_PAD_SD_CLK_GATE;
+
+	writew(tmp, host->ioaddr + SD_FIFO_PARAM);
+}
+#endif
+
 static void set_clock(struct sdhci_host *host, unsigned int clock)
 {
 	struct sdhci_pxa *pxa = sdhci_priv(host);
-	u32 tmp = 0;
 
 	if (clock == 0) {
 		if (pxa->clk_enable) {
@@ -58,11 +76,6 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
 		}
 	} else {
 		if (0 == pxa->clk_enable) {
-			if (pxa->pdata->flags & PXA_FLAG_DISABLE_CLOCK_GATING) {
-				tmp = readl(host->ioaddr + SD_FIFO_PARAM);
-				tmp |= DIS_PAD_SD_CLK_GATE;
-				writel(tmp, host->ioaddr + SD_FIFO_PARAM);
-			}
 			clk_enable(pxa->clk);
 			pxa->clk_enable = 1;
 		}
@@ -71,6 +84,9 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
 
 static struct sdhci_ops sdhci_pxa_ops = {
 	.set_clock = set_clock,
+#ifdef CONFIG_MMC_CLKGATE
+	.platform_hw_clk_gate =  hardware_clk_gating,
+#endif
 };
 
 /*****************************************************************************\
@@ -145,6 +161,11 @@ static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
 	if (pdata->flags & PXA_FLAG_SD_8_BIT_CAPABLE_SLOT)
 		host->mmc->caps |= MMC_CAP_8_BIT_DATA;
 
+#ifdef CONFIG_MMC_CLKGATE
+	if (cpu_is_mmp2())
+		host->mmc->caps |= MMC_CAP_HW_CLOCK_GATING;
+#endif
+
 	ret = sdhci_add_host(host);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add host\n");
-- 
1.6.0.4




On Dec 7, 2010, at 4:16 PM, Chris Ball wrote:

> Hi Philip,
> 
> On Tue, Dec 07, 2010 at 02:46:25PM -0800, Philip Rakity wrote:
>> 8 bit width support dependency removed.  Code applies directly to mmc-next
>> Patches 2/3 and 3/3 unchanged
> 
> The submitted patches 2/3 and 3/3 are identical -- is there a separate
> third patch that's unsent so far, or did you mean to send only two?
> 
> Thanks,
> 
> -- 
> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
> One Laptop Per Child
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-08  0:20   ` [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend) Philip Rakity
@ 2010-12-08  1:49     ` zhangfei gao
  2010-12-08  2:50       ` Philip Rakity
  0 siblings, 1 reply; 12+ messages in thread
From: zhangfei gao @ 2010-12-08  1:49 UTC (permalink / raw)
  To: Philip Rakity
  Cc: Chris Ball, linux-mmc, Nicolas Pitre, Mark Brown, Zhangfei Gao,
	Haojian Zhuang

On Tue, Dec 7, 2010 at 7:20 PM, Philip Rakity <prakity@marvell.com> wrote:
>
> From 4f521dd851066e6f65cbf3b866502a2a308eb980 Mon Sep 17 00:00:00 2001
> From: Philip Rakity <prakity@marvell.com>
> Date: Tue, 7 Dec 2010 09:05:39 -0800
> Subject: [PATCH V2] sdhci: support H/W clock gating in Marvell PXA driver
>
> This code is based on sdhci-pxa in mmc-next on Dec 2, 2010.
>
> If cpu_is_mmp2() then enable MMC capability MMC_CAP_HW_CLOCK_GATING
>
> Code may need changing based on the ongoing work on sdhci-pxa but since that
> code is NOT in mmc-next better to have something that can work.
>
> This code tested on Marvell Linux
>
> Signed-off-by: Philip Rakity <prakity@marvell.com>
> Signed-off-by: Mark F. Brown <markb@marvell.com>
> ---
>  drivers/mmc/host/sdhci-pxa.c |   33 +++++++++++++++++++++++++++------
>  1 files changed, 27 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
> index 5a61208..5cf47fd 100644
> --- a/drivers/mmc/host/sdhci-pxa.c
> +++ b/drivers/mmc/host/sdhci-pxa.c
> @@ -25,6 +25,7 @@
>  #include <linux/io.h>
>  #include <linux/err.h>
>  #include <plat/sdhci.h>
> +#include <mach/cputype.h>
>  #include "sdhci.h"
>
>  #define DRIVER_NAME    "sdhci-pxa"
> @@ -46,10 +47,27 @@ struct sdhci_pxa {
>  * SDHCI core callbacks                                                      *
>  *                                                                           *
>  \*****************************************************************************/
> +#ifdef CONFIG_MMC_CLKGATE
> +static void hardware_clk_gating(struct sdhci_host *host)
> +{
> +       unsigned short tmp;
> +       int enable;
> +
> +       enable = host->mmc->clk_gated;
> +       tmp = readw(host->ioaddr + SD_FIFO_PARAM);
> +
> +       if (enable)
> +               tmp &= ~DIS_PAD_SD_CLK_GATE;
> +       else
> +               tmp |= DIS_PAD_SD_CLK_GATE;
> +
> +       writew(tmp, host->ioaddr + SD_FIFO_PARAM);
> +}
> +#endif
> +
>  static void set_clock(struct sdhci_host *host, unsigned int clock)
>  {
>        struct sdhci_pxa *pxa = sdhci_priv(host);
> -       u32 tmp = 0;
>
>        if (clock == 0) {
>                if (pxa->clk_enable) {
> @@ -58,11 +76,6 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
>                }
>        } else {
>                if (0 == pxa->clk_enable) {
> -                       if (pxa->pdata->flags & PXA_FLAG_DISABLE_CLOCK_GATING) {
> -                               tmp = readl(host->ioaddr + SD_FIFO_PARAM);
> -                               tmp |= DIS_PAD_SD_CLK_GATE;
> -                               writel(tmp, host->ioaddr + SD_FIFO_PARAM);
> -                       }
>                        clk_enable(pxa->clk);
>                        pxa->clk_enable = 1;
>                }
> @@ -71,6 +84,9 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
>
>  static struct sdhci_ops sdhci_pxa_ops = {
>        .set_clock = set_clock,
> +#ifdef CONFIG_MMC_CLKGATE
> +       .platform_hw_clk_gate =  hardware_clk_gating,
> +#endif
>  };
>
>  /*****************************************************************************\
> @@ -145,6 +161,11 @@ static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
>        if (pdata->flags & PXA_FLAG_SD_8_BIT_CAPABLE_SLOT)
>                host->mmc->caps |= MMC_CAP_8_BIT_DATA;
>
> +#ifdef CONFIG_MMC_CLKGATE
> +       if (cpu_is_mmp2())
> +               host->mmc->caps |= MMC_CAP_HW_CLOCK_GATING;
> +#endif
> +
>        ret = sdhci_add_host(host);
>        if (ret) {
>                dev_err(&pdev->dev, "failed to add host\n");
> --
> 1.6.0.4
>
1. could you pls follow the interface we discussed before in order to
prevent the register's difference,  .platform_hw_clk_gate could be
overwrited and transfered from platform, example send before, like
get_ro.
2. we have to fully verify the hardware clk gating internally before
sending the code.
>
>
>
> On Dec 7, 2010, at 4:16 PM, Chris Ball wrote:
>
>> Hi Philip,
>>
>> On Tue, Dec 07, 2010 at 02:46:25PM -0800, Philip Rakity wrote:
>>> 8 bit width support dependency removed.  Code applies directly to mmc-next
>>> Patches 2/3 and 3/3 unchanged
>>
>> The submitted patches 2/3 and 3/3 are identical -- is there a separate
>> third patch that's unsent so far, or did you mean to send only two?
>>
>> Thanks,
>>
>> --
>> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
>> One Laptop Per Child
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-08  1:49     ` zhangfei gao
@ 2010-12-08  2:50       ` Philip Rakity
  2010-12-08  7:13         ` zhangfei gao
  2010-12-08 10:11         ` Wolfram Sang
  0 siblings, 2 replies; 12+ messages in thread
From: Philip Rakity @ 2010-12-08  2:50 UTC (permalink / raw)
  To: zhangfei gao
  Cc: Chris Ball, linux-mmc, Nicolas Pitre, Mark Brown, Zhangfei Gao,
	Haojian Zhuang


On Dec 7, 2010, at 5:49 PM, zhangfei gao wrote:

> On Tue, Dec 7, 2010 at 7:20 PM, Philip Rakity <prakity@marvell.com> wrote:
>> 
>> From 4f521dd851066e6f65cbf3b866502a2a308eb980 Mon Sep 17 00:00:00 2001
>> From: Philip Rakity <prakity@marvell.com>
>> Date: Tue, 7 Dec 2010 09:05:39 -0800
>> Subject: [PATCH V2] sdhci: support H/W clock gating in Marvell PXA driver
>> 
>> This code is based on sdhci-pxa in mmc-next on Dec 2, 2010.
>> 
>> If cpu_is_mmp2() then enable MMC capability MMC_CAP_HW_CLOCK_GATING
>> 
>> Code may need changing based on the ongoing work on sdhci-pxa but since that
>> code is NOT in mmc-next better to have something that can work.
>> 
>> This code tested on Marvell Linux
>> 
>> Signed-off-by: Philip Rakity <prakity@marvell.com>
>> Signed-off-by: Mark F. Brown <markb@marvell.com>
>> ---
>>  drivers/mmc/host/sdhci-pxa.c |   33 +++++++++++++++++++++++++++------
>>  1 files changed, 27 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
>> index 5a61208..5cf47fd 100644
>> --- a/drivers/mmc/host/sdhci-pxa.c
>> +++ b/drivers/mmc/host/sdhci-pxa.c
>> @@ -25,6 +25,7 @@
>>  #include <linux/io.h>
>>  #include <linux/err.h>
>>  #include <plat/sdhci.h>
>> +#include <mach/cputype.h>
>>  #include "sdhci.h"
>> 
>>  #define DRIVER_NAME    "sdhci-pxa"
>> @@ -46,10 +47,27 @@ struct sdhci_pxa {
>>  * SDHCI core callbacks                                                      *
>>  *                                                                           *
>>  \*****************************************************************************/
>> +#ifdef CONFIG_MMC_CLKGATE
>> +static void hardware_clk_gating(struct sdhci_host *host)
>> +{
>> +       unsigned short tmp;
>> +       int enable;
>> +
>> +       enable = host->mmc->clk_gated;
>> +       tmp = readw(host->ioaddr + SD_FIFO_PARAM);
>> +
>> +       if (enable)
>> +               tmp &= ~DIS_PAD_SD_CLK_GATE;
>> +       else
>> +               tmp |= DIS_PAD_SD_CLK_GATE;
>> +
>> +       writew(tmp, host->ioaddr + SD_FIFO_PARAM);
>> +}
>> +#endif
>> +
>>  static void set_clock(struct sdhci_host *host, unsigned int clock)
>>  {
>>        struct sdhci_pxa *pxa = sdhci_priv(host);
>> -       u32 tmp = 0;
>> 
>>        if (clock == 0) {
>>                if (pxa->clk_enable) {
>> @@ -58,11 +76,6 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
>>                }
>>        } else {
>>                if (0 == pxa->clk_enable) {
>> -                       if (pxa->pdata->flags & PXA_FLAG_DISABLE_CLOCK_GATING) {
>> -                               tmp = readl(host->ioaddr + SD_FIFO_PARAM);
>> -                               tmp |= DIS_PAD_SD_CLK_GATE;
>> -                               writel(tmp, host->ioaddr + SD_FIFO_PARAM);
>> -                       }
>>                        clk_enable(pxa->clk);
>>                        pxa->clk_enable = 1;
>>                }
>> @@ -71,6 +84,9 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
>> 
>>  static struct sdhci_ops sdhci_pxa_ops = {
>>        .set_clock = set_clock,
>> +#ifdef CONFIG_MMC_CLKGATE
>> +       .platform_hw_clk_gate =  hardware_clk_gating,
>> +#endif
>>  };
>> 
>>  /*****************************************************************************\
>> @@ -145,6 +161,11 @@ static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
>>        if (pdata->flags & PXA_FLAG_SD_8_BIT_CAPABLE_SLOT)
>>                host->mmc->caps |= MMC_CAP_8_BIT_DATA;
>> 
>> +#ifdef CONFIG_MMC_CLKGATE
>> +       if (cpu_is_mmp2())
>> +               host->mmc->caps |= MMC_CAP_HW_CLOCK_GATING;
>> +#endif
>> +
>>        ret = sdhci_add_host(host);
>>        if (ret) {
>>                dev_err(&pdev->dev, "failed to add host\n");
>> --
>> 1.6.0.4
>> 
> 1. could you pls follow the interface we discussed before in order to
> prevent the register's difference,  .platform_hw_clk_gate could be
> overwrited and transfered from platform, example send before, like
> get_ro.

We are not in agreement with your proposed  implementation.   The callbacks in the 
driver specific code calling callbacks in the arch code makes the code
difficult to follow.

It would be much simpler to create 3 entries in kConfig
one for mmp2
one for pxa910
one for pxa168
then factor out the common code.  The could then be reused and put it into
a separate file and linked  with the SOC specific code to provide the functionality needed.
Rather than the approach of moving
everything into the arch directory.  

It is not clear to us that the approach that you are following can handle the differences
in silicon between the pxa168 and pxa910/mmp2.


> 2. we have to fully verify the hardware clk gating internally before
> sending the code.

code tested under marvell 2.6.32 linux.

>> 
>> 
>> 
>> On Dec 7, 2010, at 4:16 PM, Chris Ball wrote:
>> 
>>> Hi Philip,
>>> 
>>> On Tue, Dec 07, 2010 at 02:46:25PM -0800, Philip Rakity wrote:
>>>> 8 bit width support dependency removed.  Code applies directly to mmc-next
>>>> Patches 2/3 and 3/3 unchanged
>>> 
>>> The submitted patches 2/3 and 3/3 are identical -- is there a separate
>>> third patch that's unsent so far, or did you mean to send only two?
>>> 
>>> Thanks,
>>> 
>>> --
>>> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
>>> One Laptop Per Child
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> 


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

* Re: [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-08  2:50       ` Philip Rakity
@ 2010-12-08  7:13         ` zhangfei gao
  2010-12-08 14:09           ` Philip Rakity
  2010-12-08 17:02           ` Nicolas Pitre
  2010-12-08 10:11         ` Wolfram Sang
  1 sibling, 2 replies; 12+ messages in thread
From: zhangfei gao @ 2010-12-08  7:13 UTC (permalink / raw)
  To: Philip Rakity
  Cc: Chris Ball, linux-mmc, Nicolas Pitre, Mark Brown, Zhangfei Gao,
	Haojian Zhuang

On Tue, Dec 7, 2010 at 9:50 PM, Philip Rakity <prakity@marvell.com> wrote:
>
> On Dec 7, 2010, at 5:49 PM, zhangfei gao wrote:
>
>> On Tue, Dec 7, 2010 at 7:20 PM, Philip Rakity <prakity@marvell.com> wrote:
>>>
>>> From 4f521dd851066e6f65cbf3b866502a2a308eb980 Mon Sep 17 00:00:00 2001
>>> From: Philip Rakity <prakity@marvell.com>
>>> Date: Tue, 7 Dec 2010 09:05:39 -0800
>>> Subject: [PATCH V2] sdhci: support H/W clock gating in Marvell PXA driver
>>>
>>> This code is based on sdhci-pxa in mmc-next on Dec 2, 2010.
>>>
>>> If cpu_is_mmp2() then enable MMC capability MMC_CAP_HW_CLOCK_GATING
>>>
>>> Code may need changing based on the ongoing work on sdhci-pxa but since that
>>> code is NOT in mmc-next better to have something that can work.
>>>
>>> This code tested on Marvell Linux
>>>
>>> Signed-off-by: Philip Rakity <prakity@marvell.com>
>>> Signed-off-by: Mark F. Brown <markb@marvell.com>
>>> ---
>>>  drivers/mmc/host/sdhci-pxa.c |   33 +++++++++++++++++++++++++++------
>>>  1 files changed, 27 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
>>> index 5a61208..5cf47fd 100644
>>> --- a/drivers/mmc/host/sdhci-pxa.c
>>> +++ b/drivers/mmc/host/sdhci-pxa.c
>>> @@ -25,6 +25,7 @@
>>>  #include <linux/io.h>
>>>  #include <linux/err.h>
>>>  #include <plat/sdhci.h>
>>> +#include <mach/cputype.h>
>>>  #include "sdhci.h"
>>>
>>>  #define DRIVER_NAME    "sdhci-pxa"
>>> @@ -46,10 +47,27 @@ struct sdhci_pxa {
>>>  * SDHCI core callbacks                                                      *
>>>  *                                                                           *
>>>  \*****************************************************************************/
>>> +#ifdef CONFIG_MMC_CLKGATE
>>> +static void hardware_clk_gating(struct sdhci_host *host)
>>> +{
>>> +       unsigned short tmp;
>>> +       int enable;
>>> +
>>> +       enable = host->mmc->clk_gated;
>>> +       tmp = readw(host->ioaddr + SD_FIFO_PARAM);
>>> +
>>> +       if (enable)
>>> +               tmp &= ~DIS_PAD_SD_CLK_GATE;
>>> +       else
>>> +               tmp |= DIS_PAD_SD_CLK_GATE;
>>> +
>>> +       writew(tmp, host->ioaddr + SD_FIFO_PARAM);
>>> +}
>>> +#endif
>>> +
>>>  static void set_clock(struct sdhci_host *host, unsigned int clock)
>>>  {
>>>        struct sdhci_pxa *pxa = sdhci_priv(host);
>>> -       u32 tmp = 0;
>>>
>>>        if (clock == 0) {
>>>                if (pxa->clk_enable) {
>>> @@ -58,11 +76,6 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
>>>                }
>>>        } else {
>>>                if (0 == pxa->clk_enable) {
>>> -                       if (pxa->pdata->flags & PXA_FLAG_DISABLE_CLOCK_GATING) {
>>> -                               tmp = readl(host->ioaddr + SD_FIFO_PARAM);
>>> -                               tmp |= DIS_PAD_SD_CLK_GATE;
>>> -                               writel(tmp, host->ioaddr + SD_FIFO_PARAM);
>>> -                       }
>>>                        clk_enable(pxa->clk);
>>>                        pxa->clk_enable = 1;
>>>                }
>>> @@ -71,6 +84,9 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
>>>
>>>  static struct sdhci_ops sdhci_pxa_ops = {
>>>        .set_clock = set_clock,
>>> +#ifdef CONFIG_MMC_CLKGATE
>>> +       .platform_hw_clk_gate =  hardware_clk_gating,
>>> +#endif
>>>  };
>>>
>>>  /*****************************************************************************\
>>> @@ -145,6 +161,11 @@ static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
>>>        if (pdata->flags & PXA_FLAG_SD_8_BIT_CAPABLE_SLOT)
>>>                host->mmc->caps |= MMC_CAP_8_BIT_DATA;
>>>
>>> +#ifdef CONFIG_MMC_CLKGATE
>>> +       if (cpu_is_mmp2())
>>> +               host->mmc->caps |= MMC_CAP_HW_CLOCK_GATING;
>>> +#endif
>>> +
>>>        ret = sdhci_add_host(host);
>>>        if (ret) {
>>>                dev_err(&pdev->dev, "failed to add host\n");
>>> --
>>> 1.6.0.4
>>>
>> 1. could you pls follow the interface we discussed before in order to
>> prevent the register's difference,  .platform_hw_clk_gate could be
>> overwrited and transfered from platform, example send before, like
>> get_ro.
>
> We are not in agreement with your proposed  implementation.   The callbacks in the
> driver specific code calling callbacks in the arch code makes the code
> difficult to follow.
>
> It would be much simpler to create 3 entries in kConfig
> one for mmp2
> one for pxa910
> one for pxa168
> then factor out the common code.  The could then be reused and put it into
> a separate file and linked  with the SOC specific code to provide the functionality needed.
> Rather than the approach of moving
> everything into the arch directory.
>
> It is not clear to us that the approach that you are following can handle the differences
> in silicon between the pxa168 and pxa910/mmp2.
>
>
>> 2. we have to fully verify the hardware clk gating internally before
>> sending the code.
>
> code tested under marvell 2.6.32 linux.

Thanks a lot, just wander could sdio be supported, since marvell8787
requires around 10 clock cycles after cmd53 finished.

>
>>>
>>>
>>>
>>> On Dec 7, 2010, at 4:16 PM, Chris Ball wrote:
>>>
>>>> Hi Philip,
>>>>
>>>> On Tue, Dec 07, 2010 at 02:46:25PM -0800, Philip Rakity wrote:
>>>>> 8 bit width support dependency removed.  Code applies directly to mmc-next
>>>>> Patches 2/3 and 3/3 unchanged
>>>>
>>>> The submitted patches 2/3 and 3/3 are identical -- is there a separate
>>>> third patch that's unsent so far, or did you mean to send only two?
>>>>
>>>> Thanks,
>>>>
>>>> --
>>>> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
>>>> One Laptop Per Child
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>
>

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

* Re: [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-08  2:50       ` Philip Rakity
  2010-12-08  7:13         ` zhangfei gao
@ 2010-12-08 10:11         ` Wolfram Sang
  2010-12-08 14:05           ` Philip Rakity
  1 sibling, 1 reply; 12+ messages in thread
From: Wolfram Sang @ 2010-12-08 10:11 UTC (permalink / raw)
  To: Philip Rakity
  Cc: zhangfei gao, Chris Ball, linux-mmc, Nicolas Pitre, Mark Brown,
	Zhangfei Gao, Haojian Zhuang

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]


> code tested under marvell 2.6.32 linux.

Any chance of testing it agains mmc-next, some 2.6.37-rc or at least
2.6.36? A lot of stuff has happened since 2.6.32.

Kind regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-08 10:11         ` Wolfram Sang
@ 2010-12-08 14:05           ` Philip Rakity
  0 siblings, 0 replies; 12+ messages in thread
From: Philip Rakity @ 2010-12-08 14:05 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: zhangfei gao, Chris Ball, linux-mmc, Nicolas Pitre, Mark Brown,
	Zhangfei Gao, Haojian Zhuang


On Dec 8, 2010, at 2:11 AM, Wolfram Sang wrote:

> 
>> code tested under marvell 2.6.32 linux.
> 
> Any chance of testing it agains mmc-next, some 2.6.37-rc or at least
> 2.6.36? A lot of stuff has happened since 2.6.32.
> 


The 2.6.32 mmc implementation has a lot of patches from upstream linux and is very close to what is in mmc-next.

Agree it is not the same -- and -- working on getting it tested but not that bad.


> Kind regards,
> 
>   Wolfram
> 
> -- 
> Pengutronix e.K.                           | Wolfram Sang                |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |


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

* Re: [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-08  7:13         ` zhangfei gao
@ 2010-12-08 14:09           ` Philip Rakity
  2010-12-08 17:02           ` Nicolas Pitre
  1 sibling, 0 replies; 12+ messages in thread
From: Philip Rakity @ 2010-12-08 14:09 UTC (permalink / raw)
  To: zhangfei gao
  Cc: Chris Ball, linux-mmc, Nicolas Pitre, Mark Brown, Zhangfei Gao,
	Haojian Zhuang


On Dec 7, 2010, at 11:13 PM, zhangfei gao wrote:

> On Tue, Dec 7, 2010 at 9:50 PM, Philip Rakity <prakity@marvell.com> wrote:
>> 
>> On Dec 7, 2010, at 5:49 PM, zhangfei gao wrote:
>> 
>>> On Tue, Dec 7, 2010 at 7:20 PM, Philip Rakity <prakity@marvell.com> wrote:
>>>> 
>>>> From 4f521dd851066e6f65cbf3b866502a2a308eb980 Mon Sep 17 00:00:00 2001
>>>> From: Philip Rakity <prakity@marvell.com>
>>>> Date: Tue, 7 Dec 2010 09:05:39 -0800
>>>> Subject: [PATCH V2] sdhci: support H/W clock gating in Marvell PXA driver
>>>> 
>>>> This code is based on sdhci-pxa in mmc-next on Dec 2, 2010.
>>>> 
>>>> If cpu_is_mmp2() then enable MMC capability MMC_CAP_HW_CLOCK_GATING
>>>> 
>>>> Code may need changing based on the ongoing work on sdhci-pxa but since that
>>>> code is NOT in mmc-next better to have something that can work.
>>>> 
>>>> This code tested on Marvell Linux
>>>> 
>>>> Signed-off-by: Philip Rakity <prakity@marvell.com>
>>>> Signed-off-by: Mark F. Brown <markb@marvell.com>
>>>> ---
>>>>  drivers/mmc/host/sdhci-pxa.c |   33 +++++++++++++++++++++++++++------
>>>>  1 files changed, 27 insertions(+), 6 deletions(-)
>>>> 
>>>> diff --git a/drivers/mmc/host/sdhci-pxa.c b/drivers/mmc/host/sdhci-pxa.c
>>>> index 5a61208..5cf47fd 100644
>>>> --- a/drivers/mmc/host/sdhci-pxa.c
>>>> +++ b/drivers/mmc/host/sdhci-pxa.c
>>>> @@ -25,6 +25,7 @@
>>>>  #include <linux/io.h>
>>>>  #include <linux/err.h>
>>>>  #include <plat/sdhci.h>
>>>> +#include <mach/cputype.h>
>>>>  #include "sdhci.h"
>>>> 
>>>>  #define DRIVER_NAME    "sdhci-pxa"
>>>> @@ -46,10 +47,27 @@ struct sdhci_pxa {
>>>>  * SDHCI core callbacks                                                      *
>>>>  *                                                                           *
>>>>  \*****************************************************************************/
>>>> +#ifdef CONFIG_MMC_CLKGATE
>>>> +static void hardware_clk_gating(struct sdhci_host *host)
>>>> +{
>>>> +       unsigned short tmp;
>>>> +       int enable;
>>>> +
>>>> +       enable = host->mmc->clk_gated;
>>>> +       tmp = readw(host->ioaddr + SD_FIFO_PARAM);
>>>> +
>>>> +       if (enable)
>>>> +               tmp &= ~DIS_PAD_SD_CLK_GATE;
>>>> +       else
>>>> +               tmp |= DIS_PAD_SD_CLK_GATE;
>>>> +
>>>> +       writew(tmp, host->ioaddr + SD_FIFO_PARAM);
>>>> +}
>>>> +#endif
>>>> +
>>>>  static void set_clock(struct sdhci_host *host, unsigned int clock)
>>>>  {
>>>>        struct sdhci_pxa *pxa = sdhci_priv(host);
>>>> -       u32 tmp = 0;
>>>> 
>>>>        if (clock == 0) {
>>>>                if (pxa->clk_enable) {
>>>> @@ -58,11 +76,6 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
>>>>                }
>>>>        } else {
>>>>                if (0 == pxa->clk_enable) {
>>>> -                       if (pxa->pdata->flags & PXA_FLAG_DISABLE_CLOCK_GATING) {
>>>> -                               tmp = readl(host->ioaddr + SD_FIFO_PARAM);
>>>> -                               tmp |= DIS_PAD_SD_CLK_GATE;
>>>> -                               writel(tmp, host->ioaddr + SD_FIFO_PARAM);
>>>> -                       }
>>>>                        clk_enable(pxa->clk);
>>>>                        pxa->clk_enable = 1;
>>>>                }
>>>> @@ -71,6 +84,9 @@ static void set_clock(struct sdhci_host *host, unsigned int clock)
>>>> 
>>>>  static struct sdhci_ops sdhci_pxa_ops = {
>>>>        .set_clock = set_clock,
>>>> +#ifdef CONFIG_MMC_CLKGATE
>>>> +       .platform_hw_clk_gate =  hardware_clk_gating,
>>>> +#endif
>>>>  };
>>>> 
>>>>  /*****************************************************************************\
>>>> @@ -145,6 +161,11 @@ static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
>>>>        if (pdata->flags & PXA_FLAG_SD_8_BIT_CAPABLE_SLOT)
>>>>                host->mmc->caps |= MMC_CAP_8_BIT_DATA;
>>>> 
>>>> +#ifdef CONFIG_MMC_CLKGATE
>>>> +       if (cpu_is_mmp2())
>>>> +               host->mmc->caps |= MMC_CAP_HW_CLOCK_GATING;
>>>> +#endif
>>>> +
>>>>        ret = sdhci_add_host(host);
>>>>        if (ret) {
>>>>                dev_err(&pdev->dev, "failed to add host\n");
>>>> --
>>>> 1.6.0.4
>>>> 
>>> 1. could you pls follow the interface we discussed before in order to
>>> prevent the register's difference,  .platform_hw_clk_gate could be
>>> overwrited and transfered from platform, example send before, like
>>> get_ro.
>> 
>> We are not in agreement with your proposed  implementation.   The callbacks in the
>> driver specific code calling callbacks in the arch code makes the code
>> difficult to follow.
>> 
>> It would be much simpler to create 3 entries in kConfig
>> one for mmp2
>> one for pxa910
>> one for pxa168
>> then factor out the common code.  The could then be reused and put it into
>> a separate file and linked  with the SOC specific code to provide the functionality needed.
>> Rather than the approach of moving
>> everything into the arch directory.
>> 
>> It is not clear to us that the approach that you are following can handle the differences
>> in silicon between the pxa168 and pxa910/mmp2.
>> 
>> 
>>> 2. we have to fully verify the hardware clk gating internally before
>>> sending the code.
>> 
>> code tested under marvell 2.6.32 linux.
> 
> Thanks a lot, just wander could sdio be supported, since marvell8787
> requires around 10 clock cycles after cmd53 finished.

my understanding is that the 8787 requires 12 clocks not 10.  The spec calls for 8 clocks.
Hardware clock gating sdio does not work with 8787. We have tested this and know it fails. 

> 
>> 
>>>> 
>>>> 
>>>> 
>>>> On Dec 7, 2010, at 4:16 PM, Chris Ball wrote:
>>>> 
>>>>> Hi Philip,
>>>>> 
>>>>> On Tue, Dec 07, 2010 at 02:46:25PM -0800, Philip Rakity wrote:
>>>>>> 8 bit width support dependency removed.  Code applies directly to mmc-next
>>>>>> Patches 2/3 and 3/3 unchanged
>>>>> 
>>>>> The submitted patches 2/3 and 3/3 are identical -- is there a separate
>>>>> third patch that's unsent so far, or did you mean to send only two?
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> --
>>>>> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
>>>>> One Laptop Per Child
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>>>> the body of a message to majordomo@vger.kernel.org
>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>> 
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>> 
>> 
>> 


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

* Re: [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-08  7:13         ` zhangfei gao
  2010-12-08 14:09           ` Philip Rakity
@ 2010-12-08 17:02           ` Nicolas Pitre
  2010-12-13 14:50             ` David Vrabel
  1 sibling, 1 reply; 12+ messages in thread
From: Nicolas Pitre @ 2010-12-08 17:02 UTC (permalink / raw)
  To: zhangfei gao
  Cc: Philip Rakity, Chris Ball, linux-mmc, Mark Brown, Zhangfei Gao,
	Haojian Zhuang

On Wed, 8 Dec 2010, zhangfei gao wrote:

> On Tue, Dec 7, 2010 at 9:50 PM, Philip Rakity <prakity@marvell.com> wrote:
> >
> > On Dec 7, 2010, at 5:49 PM, zhangfei gao wrote:
> >> 2. we have to fully verify the hardware clk gating internally before
> >> sending the code.
> >
> > code tested under marvell 2.6.32 linux.
> 
> Thanks a lot, just wander could sdio be supported, since marvell8787
> requires around 10 clock cycles after cmd53 finished.

SDIO is currently left out as this is not clear if all SDIO cards still 
can send interrupts if their clock is disabled, or even function 
properly.  This might have to be a property that the SDIO function 
drivers could provide to the core.


Nicolas

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

* Re: [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-08 17:02           ` Nicolas Pitre
@ 2010-12-13 14:50             ` David Vrabel
  2010-12-13 15:54               ` Philip Rakity
  0 siblings, 1 reply; 12+ messages in thread
From: David Vrabel @ 2010-12-13 14:50 UTC (permalink / raw)
  To: Nicolas Pitre
  Cc: zhangfei gao, Philip Rakity, Chris Ball, linux-mmc, Mark Brown,
	Zhangfei Gao, Haojian Zhuang

Nicolas Pitre wrote:
> On Wed, 8 Dec 2010, zhangfei gao wrote:
> 
>> On Tue, Dec 7, 2010 at 9:50 PM, Philip Rakity <prakity@marvell.com> wrote:
>>> On Dec 7, 2010, at 5:49 PM, zhangfei gao wrote:
>>>> 2. we have to fully verify the hardware clk gating internally before
>>>> sending the code.
>>> code tested under marvell 2.6.32 linux.
>> Thanks a lot, just wander could sdio be supported, since marvell8787
>> requires around 10 clock cycles after cmd53 finished.

The specification requires only 8 clocks after end bit of a CMD53 data
block.  (SD physical spec 3.01 section 4.4, clock control).  It is
possible that the controller sends more than the minimum.

> SDIO is currently left out as this is not clear if all SDIO cards still 
> can send interrupts if their clock is disabled, or even function 
> properly.  This might have to be a property that the SDIO function 
> drivers could provide to the core.

It's a minefield.

Cards in 1-bit mode may interrupt at any time whether there is a clock
or not.

Cards compliant to SDIO v2.00 should require the clock to generate
interrupts when in 4-bit mode as this is what's specified in the
specification.  As a vendor-specific extension, some v2.00 cards (e.g.,
all CSR devices) do not require the clock.

Cards compliant to SDIO v3.00 may optionally have the clock turned off
if the card indicates support for asynchronous interrupts and support
has been enabled (via CCCR register bits).

Some host controllers will not detect interrupts if the clock is off and
4-bit mode is enabled.

I would suggest:

* Cards have a property: auto-clock-disable which indicates if the the
clock can be switched off automatically by mmc core or if hardware clock
gating may be used.

a. Memory cards would set this to true.
b. SDIO v2.00 cards would set this to false.
c. SDIO v3.00 cards would set this to true if asynchronous interrupts
are supported and enabled, otherwise false.
d. combo cards set this based on the SDIO function.

* If necessary, host controllers switch to 1-bit mode if the clock is
turned off and switch back to 4-bit mode when the clock is turned back
on (e.g., some sdhci controllers require this).

* SDIO function drivers can set auto-clock-disable to true if they're
for a v2.00 card that supports asynchronous interrupts.

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ                 http://www.csr.com/


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom

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

* Re: [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend)
  2010-12-13 14:50             ` David Vrabel
@ 2010-12-13 15:54               ` Philip Rakity
  0 siblings, 0 replies; 12+ messages in thread
From: Philip Rakity @ 2010-12-13 15:54 UTC (permalink / raw)
  To: David Vrabel
  Cc: Nicolas Pitre, zhangfei gao, Chris Ball, linux-mmc, Mark Brown,
	Zhangfei Gao, Haojian Zhuang


On Dec 13, 2010, at 6:50 AM, David Vrabel wrote:

> Nicolas Pitre wrote:
>> On Wed, 8 Dec 2010, zhangfei gao wrote:
>> 
>>> On Tue, Dec 7, 2010 at 9:50 PM, Philip Rakity <prakity@marvell.com> wrote:
>>>> On Dec 7, 2010, at 5:49 PM, zhangfei gao wrote:
>>>>> 2. we have to fully verify the hardware clk gating internally before
>>>>> sending the code.
>>>> code tested under marvell 2.6.32 linux.
>>> Thanks a lot, just wander could sdio be supported, since marvell8787
>>> requires around 10 clock cycles after cmd53 finished.
> 
> The specification requires only 8 clocks after end bit of a CMD53 data
> block.  (SD physical spec 3.01 section 4.4, clock control).  It is
> possible that the controller sends more than the minimum.
> 

hardware was designed before sdio 3.0

>> SDIO is currently left out as this is not clear if all SDIO cards still 
>> can send interrupts if their clock is disabled, or even function 
>> properly.  This might have to be a property that the SDIO function 
>> drivers could provide to the core.
> 
> It's a minefield.
> 
> Cards in 1-bit mode may interrupt at any time whether there is a clock
> or not.
> 
> Cards compliant to SDIO v2.00 should require the clock to generate
> interrupts when in 4-bit mode as this is what's specified in the
> specification.  As a vendor-specific extension, some v2.00 cards (e.g.,
> all CSR devices) do not require the clock.
> 
> Cards compliant to SDIO v3.00 may optionally have the clock turned off
> if the card indicates support for asynchronous interrupts and support
> has been enabled (via CCCR register bits).
> 
> Some host controllers will not detect interrupts if the clock is off and
> 4-bit mode is enabled.
> 
> I would suggest:
> 
> * Cards have a property: auto-clock-disable which indicates if the the
> clock can be switched off automatically by mmc core or if hardware clock
> gating may be used.
> 
> a. Memory cards would set this to true.
> b. SDIO v2.00 cards would set this to false.
> c. SDIO v3.00 cards would set this to true if asynchronous interrupts
> are supported and enabled, otherwise false.
> d. combo cards set this based on the SDIO function.
> 
> * If necessary, host controllers switch to 1-bit mode if the clock is
> turned off and switch back to 4-bit mode when the clock is turned back
> on (e.g., some sdhci controllers require this).
> 
> * SDIO function drivers can set auto-clock-disable to true if they're
> for a v2.00 card that supports asynchronous interrupts.
> 
> David
> -- 
> David Vrabel, Senior Software Engineer, Drivers
> CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
> Cowley Road, Cambridge, CB4 0WZ                 http://www.csr.com/
> 
> 
> Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


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

end of thread, other threads:[~2010-12-13 15:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-07 22:46 [PATCH V3 1/3 ] mmc: add support for H/W clock gating of SD controller Philip Rakity
2010-12-08  0:16 ` Chris Ball
2010-12-08  0:20   ` [PATCH V3 3/3 ] mmc: add support for H/W clock gating of SD controller (resend) Philip Rakity
2010-12-08  1:49     ` zhangfei gao
2010-12-08  2:50       ` Philip Rakity
2010-12-08  7:13         ` zhangfei gao
2010-12-08 14:09           ` Philip Rakity
2010-12-08 17:02           ` Nicolas Pitre
2010-12-13 14:50             ` David Vrabel
2010-12-13 15:54               ` Philip Rakity
2010-12-08 10:11         ` Wolfram Sang
2010-12-08 14:05           ` Philip Rakity

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.