All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] new version workaround for FSL's eSDHC controller
@ 2012-01-06  5:33 r66093
  2012-01-06  5:33 ` [PATCH 1/5 v2] ESDHC: add PIO mode support r66093
  0 siblings, 1 reply; 19+ messages in thread
From: r66093 @ 2012-01-06  5:33 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang

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

The below patches are the workaround for FSL's eSDHC controller.
the patches (3/5, 4/5, 5/5) are modified based on Chris's hook patch,
the other patches (1/5, 2/5) have no any change.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>


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

* [PATCH 1/5 v2] ESDHC: add PIO mode support
  2012-01-06  5:33 [PATCH 0/1] new version workaround for FSL's eSDHC controller r66093
@ 2012-01-06  5:33 ` r66093
  2012-01-06  5:33   ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value r66093
  2012-01-13  2:35   ` [PATCH 1/5 v2] ESDHC: add PIO mode support Huang Changming-R66093
  0 siblings, 2 replies; 19+ messages in thread
From: r66093 @ 2012-01-06  5:33 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Gao Guanhua, Chris Ball

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

For some FSL ESDHC controller(e.g. P2020E, Rev1.0), the SDHC can not work on
DMA mode because of the hardware bug, so we set a broken dma flag and use
PIO mode.

Signed-off-by: Gao Guanhua <B22826@freescale.com>
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- change the property to compatible for quirks

 drivers/mmc/host/sdhci-pltfm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index a9e12ea..ba36c36 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -2,7 +2,7 @@
  * sdhci-pltfm.c Support for SDHCI platform devices
  * Copyright (c) 2009 Intel Corporation
  *
- * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ * Copyright (c) 2007, 2011 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
  *
  * Authors: Xiaobo Xie <X.Xie@freescale.com>
@@ -71,6 +71,9 @@ void sdhci_get_of_property(struct platform_device *pdev)
 		if (sdhci_of_wp_inverted(np))
 			host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
 
+		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
+			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
+
 		clk = of_get_property(np, "clock-frequency", &size);
 		if (clk && size == sizeof(*clk) && *clk)
 			pltfm_host->clock = be32_to_cpup(clk);
-- 
1.7.5.4



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

* [PATCH 2/5 v2] ESDHC: set the timeout to the max value
  2012-01-06  5:33 ` [PATCH 1/5 v2] ESDHC: add PIO mode support r66093
@ 2012-01-06  5:33   ` r66093
  2012-01-06  5:33     ` [PATCH 3/5 v4] ESDHC: Power management for ESDHC r66093
  2012-01-13  2:36     ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value Huang Changming-R66093
  2012-01-13  2:35   ` [PATCH 1/5 v2] ESDHC: add PIO mode support Huang Changming-R66093
  1 sibling, 2 replies; 19+ messages in thread
From: r66093 @ 2012-01-06  5:33 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Gao Guanhua, Xie Xiaobo, Chris Ball

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

When access the card on some FSL platform board (e.g p2020, p1010, mpc8536),
the following error is reported with the timeout value calculated:

mmc0: Got data interrupt 0x00000020 even though no data operation was
in progress.
mmc0: Got data interrupt 0x00000020 even though no data operation was
in progress.

So we skip the calculation of timeout and use the max value to fix it.

Signed-off-by: Gao Guanhua <B22826@freescale.com>
Signed-off-by: Xie Xiaobo <X.Xie@freescale.com>
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- change the property to compatible for quirks

 drivers/mmc/host/sdhci-pltfm.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index ba36c36..1c254b1 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -74,6 +74,11 @@ void sdhci_get_of_property(struct platform_device *pdev)
 		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
 			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
 
+		if (of_device_is_compatible(np, "fsl,p2020-esdhc")
+			|| of_device_is_compatible(np, "fsl,p1010-esdhc")
+			|| of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
+			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
+
 		clk = of_get_property(np, "clock-frequency", &size);
 		if (clk && size == sizeof(*clk) && *clk)
 			pltfm_host->clock = be32_to_cpup(clk);
-- 
1.7.5.4



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

* [PATCH 3/5 v4] ESDHC: Power management for ESDHC
  2012-01-06  5:33   ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value r66093
@ 2012-01-06  5:33     ` r66093
  2012-01-06  5:33       ` [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb r66093
  2012-01-13  2:36       ` [PATCH 3/5 v4] ESDHC: Power management for ESDHC Huang Changming-R66093
  2012-01-13  2:36     ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value Huang Changming-R66093
  1 sibling, 2 replies; 19+ messages in thread
From: r66093 @ 2012-01-06  5:33 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Jiang Yutang, Chris Ball

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

For FSL ESDHC controllor, when enter the sleep, the controller will power off,
therefore the register will lost its valuse, and driver should save value of
register during suspend and used during resume.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
Signed-off-by: Jiang Yutang <b14898@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- change the property to compatible for quirks
changes for v3:
	- fix one compile error
changes for v4:
	- use hooks to suspend/resume the special platform

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

diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index c21be67..385a4ff 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -104,6 +104,21 @@ static int esdhc_of_get_cd(struct sdhci_host *host)
 	return present;
 }
 
+#ifdef CONFIG_PM
+static u32 esdhc_proctl;
+static void esdhc_of_suspend(struct sdhci_host *host)
+{
+	esdhc_proctl = sdhci_be32bs_readl(host, SDHCI_HOST_CONTROL);
+}
+
+static void esdhc_of_resume(struct sdhci_host *host)
+{
+	esdhc_of_enable_dma(host);
+	sdhci_be32bs_writel(host, esdhc_proctl, SDHCI_HOST_CONTROL);
+
+}
+#endif
+
 static struct sdhci_ops sdhci_esdhc_ops = {
 	.read_l = sdhci_be32bs_readl,
 	.read_w = esdhc_readw,
@@ -116,6 +131,10 @@ static struct sdhci_ops sdhci_esdhc_ops = {
 	.get_max_clock = esdhc_of_get_max_clock,
 	.get_min_clock = esdhc_of_get_min_clock,
 	.get_cd = esdhc_of_get_cd,
+#ifdef CONFIG_PM
+	.platform_suspend = esdhc_of_suspend,
+	.platform_resume = esdhc_of_resume,
+#endif
 };
 
 static struct sdhci_pltfm_data sdhci_esdhc_pdata = {
-- 
1.7.5.4



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

* [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb
  2012-01-06  5:33     ` [PATCH 3/5 v4] ESDHC: Power management for ESDHC r66093
@ 2012-01-06  5:33       ` r66093
  2012-01-06  5:33         ` [PATCH 5/5 v4] ESDHC: Fix DMA errors in kernel booting on P1010 r66093
  2012-01-13  2:37         ` [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb Huang Changming-R66093
  2012-01-13  2:36       ` [PATCH 3/5 v4] ESDHC: Power management for ESDHC Huang Changming-R66093
  1 sibling, 2 replies; 19+ messages in thread
From: r66093 @ 2012-01-06  5:33 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Priyanka Jain, Chris Ball

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

SD card read was failing (data crc error)on some cards at
maximum possible frequency on P1010(CCB frequency set to 400MHz).
Some clock deviations are also observed at this frequency.
Hence reduced the mmc clock freq.

Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
Singed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- change the property to compatible for quirks
changes for v3:
	- fix one compile error
changes for v4:
	- use hooks to suspend/resume the special platform

 drivers/mmc/host/sdhci-esdhc.h |    9 ++++++++-
 drivers/mmc/host/sdhci-pltfm.c |    3 +++
 include/linux/mmc/sdhci.h      |    2 ++
 3 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
index b97b2f5..8e00174 100644
--- a/drivers/mmc/host/sdhci-esdhc.h
+++ b/drivers/mmc/host/sdhci-esdhc.h
@@ -1,7 +1,7 @@
 /*
  * Freescale eSDHC controller driver generics for OF and pltfm.
  *
- * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ * Copyright (c) 2007,2011 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
  * Copyright (c) 2010 Pengutronix e.K.
  *   Author: Wolfram Sang <w.sang@pengutronix.de>
@@ -56,6 +56,13 @@ static inline void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
 	if (clock == 0)
 		goto out;
 
+	if (host->quirks2 & SDHCI_QUIRK2_RELAX_FREQ) {
+		if (clock > 20000000)
+			clock -= 5000000;
+		if (clock > 40000000)
+			clock -= 5000000;
+	}
+
 	while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
 		pre_div *= 2;
 
diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index e64f773..841ffc1 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -79,6 +79,9 @@ void sdhci_get_of_property(struct platform_device *pdev)
 			|| of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
 			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
 
+		if (of_device_is_compatible(np, "fsl,p1010-esdhc"))
+			host->quirks2 |= SDHCI_QUIRK2_RELAX_FREQ;
+
 		clk = of_get_property(np, "clock-frequency", &size);
 		if (clk && size == sizeof(*clk) && *clk)
 			pltfm_host->clock = be32_to_cpup(clk);
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index e4b6935..f7c1e13 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -91,6 +91,8 @@ struct sdhci_host {
 	unsigned int quirks2;	/* More deviations from spec. */
 
 #define SDHCI_QUIRK2_OWN_CARD_DETECTION			(1<<0)
+/* Controller operates the cards at reduced frequency */
+#define SDHCI_QUIRK2_RELAX_FREQ				(1<<1)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
-- 
1.7.5.4



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

* [PATCH 5/5 v4] ESDHC: Fix DMA errors in kernel booting on P1010
  2012-01-06  5:33       ` [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb r66093
@ 2012-01-06  5:33         ` r66093
  2012-01-06 15:00           ` Chris Ball
  2012-01-13  2:37         ` [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb Huang Changming-R66093
  1 sibling, 1 reply; 19+ messages in thread
From: r66093 @ 2012-01-06  5:33 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Priyanka Jain, Chris Ball

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

When linux is booted with DMA mode enabled in esdhc module on P1010,
there were following errors:

mmc0: ADMA error
mmc0: error -5 whilst initialising SD card

It is because FSL ESDHC controller has different bit setting for PROCTL
register, when kernel sets Power Control Register by method for standard
SD Host Specification, it would overwritten FSL ESDHC PROCTL[DMAS];
when it set Host Control Registers[DMAS], it sets PROCTL[EMODE] and
PROCTL[D3CD]. These operations will set bad bits for PROCTL Register
on FSL ESDHC Controller and cause errors, so this patch will make esdhc
driver access FSL PROCTL Register according to block guide instead of
standard SD Host Specification.

For some FSL chips, such as MPC8536/P2020, PROCTL[VOLT_SEL] and PROCTL[DMAS]
bits are reserved and even if they are set to wrong bits there is no error.
But considering that all FSL ESDHC Controller register map is not fully
compliant to standard SD Host Specification, we put the patch to all of
FSL ESDHC Controllers.

Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- change the property to compatible for quirks
changes for v3:
	- fix one compile error
changes for v4:
	- use hooks to suspend/resume the special platform

 drivers/mmc/host/sdhci-pltfm.c |    3 ++
 drivers/mmc/host/sdhci.c       |   61 ++++++++++++++++++++++++++++++++-------
 include/linux/mmc/sdhci.h      |    2 +
 3 files changed, 55 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index 841ffc1..047eb80 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -82,6 +82,9 @@ void sdhci_get_of_property(struct platform_device *pdev)
 		if (of_device_is_compatible(np, "fsl,p1010-esdhc"))
 			host->quirks2 |= SDHCI_QUIRK2_RELAX_FREQ;
 
+		if (of_device_is_compatible(np, "fsl,esdhc"))
+			host->quirks2 |= SDHCI_QUIRK2_QORIQ_PROCTL_WEIRD;
+
 		clk = of_get_property(np, "clock-frequency", &size);
 		if (clk && size == sizeof(*clk) && *clk)
 			pltfm_host->clock = be32_to_cpup(clk);
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 2db0d5c..d5a2259 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -832,14 +832,29 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
 	 * is ADMA.
 	 */
 	if (host->version >= SDHCI_SPEC_200) {
-		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
-		ctrl &= ~SDHCI_CTRL_DMA_MASK;
-		if ((host->flags & SDHCI_REQ_USE_DMA) &&
-			(host->flags & SDHCI_USE_ADMA))
-			ctrl |= SDHCI_CTRL_ADMA32;
-		else
-			ctrl |= SDHCI_CTRL_SDMA;
-		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+		if (host->quirks2 & SDHCI_QUIRK2_QORIQ_PROCTL_WEIRD) {
+#define ESDHCI_PROCTL_DMAS_MASK		0x00000300
+#define ESDHCI_PROCTL_ADMA32		0x00000200
+#define ESDHCI_PROCTL_SDMA		0x00000000
+			u32 ctrl;
+			ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
+			ctrl &= ~ESDHCI_PROCTL_DMAS_MASK;
+			if ((host->flags & SDHCI_REQ_USE_DMA) &&
+				(host->flags & SDHCI_USE_ADMA))
+				ctrl |= ESDHCI_PROCTL_ADMA32;
+			else
+				ctrl |= ESDHCI_PROCTL_SDMA;
+			sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
+		} else {
+			ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
+			ctrl &= ~SDHCI_CTRL_DMA_MASK;
+			if ((host->flags & SDHCI_REQ_USE_DMA) &&
+				(host->flags & SDHCI_USE_ADMA))
+				ctrl |= SDHCI_CTRL_ADMA32;
+			else
+				ctrl |= SDHCI_CTRL_SDMA;
+			sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+		}
 	}
 
 	if (!(host->flags & SDHCI_REQ_USE_DMA)) {
@@ -1175,17 +1190,29 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
 	u8 pwr = 0;
 
 	if (power != (unsigned short)-1) {
+#define	ESDHCI_FSL_POWER_MASK	0x40
+#define	ESDHCI_FSL_POWER_180	0x00
+#define	ESDHCI_FSL_POWER_300	0x40
 		switch (1 << power) {
 		case MMC_VDD_165_195:
-			pwr = SDHCI_POWER_180;
+			if (host->quirks2 & SDHCI_QUIRK2_QORIQ_PROCTL_WEIRD)
+				pwr = ESDHCI_FSL_POWER_180;
+			else
+				pwr = SDHCI_POWER_180;
 			break;
 		case MMC_VDD_29_30:
 		case MMC_VDD_30_31:
-			pwr = SDHCI_POWER_300;
+			if (host->quirks2 & SDHCI_QUIRK2_QORIQ_PROCTL_WEIRD)
+				pwr = ESDHCI_FSL_POWER_300;
+			else
+				pwr = SDHCI_POWER_300;
 			break;
 		case MMC_VDD_32_33:
 		case MMC_VDD_33_34:
-			pwr = SDHCI_POWER_330;
+			if (host->quirks2 & SDHCI_QUIRK2_QORIQ_PROCTL_WEIRD)
+				pwr = ESDHCI_FSL_POWER_300;
+			else
+				pwr = SDHCI_POWER_330;
 			break;
 		default:
 			BUG();
@@ -1195,6 +1222,18 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
 	if (host->pwr == pwr)
 		return;
 
+	/* Now FSL ESDHC Controller has no Bus Power bit,
+	 * and PROCTL[21] bit is for voltage selection */
+	if (host->quirks2 & SDHCI_QUIRK2_QORIQ_PROCTL_WEIRD) {
+		u8 volt = 0;
+		volt = sdhci_readb(host, SDHCI_POWER_CONTROL);
+		volt &= ~ESDHCI_FSL_POWER_MASK;
+		volt |= pwr;
+		sdhci_writeb(host, volt, SDHCI_POWER_CONTROL);
+
+		return;
+	}
+
 	host->pwr = pwr;
 
 	if (pwr == 0) {
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index f7c1e13..d025134 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -93,6 +93,8 @@ struct sdhci_host {
 #define SDHCI_QUIRK2_OWN_CARD_DETECTION			(1<<0)
 /* Controller operates the cards at reduced frequency */
 #define SDHCI_QUIRK2_RELAX_FREQ				(1<<1)
+/* Controller has weird bit setting for Protocol Control Register */
+#define SDHCI_QUIRK2_QORIQ_PROCTL_WEIRD			(1<<2)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
-- 
1.7.5.4



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

* Re: [PATCH 5/5 v4] ESDHC: Fix DMA errors in kernel booting on P1010
  2012-01-06  5:33         ` [PATCH 5/5 v4] ESDHC: Fix DMA errors in kernel booting on P1010 r66093
@ 2012-01-06 15:00           ` Chris Ball
  2012-01-09  2:59             ` Huang Changming-R66093
  0 siblings, 1 reply; 19+ messages in thread
From: Chris Ball @ 2012-01-06 15:00 UTC (permalink / raw)
  To: r66093; +Cc: linux-mmc, Jerry Huang, Priyanka Jain

Hi Jerry,

On Fri, Jan 06 2012, r66093@freescale.com wrote:
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 2db0d5c..d5a2259 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -832,14 +832,29 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
>  	 * is ADMA.
>  	 */
>  	if (host->version >= SDHCI_SPEC_200) {
> -		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
> -		ctrl &= ~SDHCI_CTRL_DMA_MASK;
> -		if ((host->flags & SDHCI_REQ_USE_DMA) &&
> -			(host->flags & SDHCI_USE_ADMA))
> -			ctrl |= SDHCI_CTRL_ADMA32;
> -		else
> -			ctrl |= SDHCI_CTRL_SDMA;
> -		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
> +		if (host->quirks2 & SDHCI_QUIRK2_QORIQ_PROCTL_WEIRD) {
> +#define ESDHCI_PROCTL_DMAS_MASK		0x00000300
> +#define ESDHCI_PROCTL_ADMA32		0x00000200
> +#define ESDHCI_PROCTL_SDMA		0x00000000
> +			u32 ctrl;
> +			ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
> +			ctrl &= ~ESDHCI_PROCTL_DMAS_MASK;
> +			if ((host->flags & SDHCI_REQ_USE_DMA) &&
> +				(host->flags & SDHCI_USE_ADMA))
> +				ctrl |= ESDHCI_PROCTL_ADMA32;
> +			else
> +				ctrl |= ESDHCI_PROCTL_SDMA;
> +			sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
> +		} else {
> +			ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
> +			ctrl &= ~SDHCI_CTRL_DMA_MASK;
> +			if ((host->flags & SDHCI_REQ_USE_DMA) &&
> +				(host->flags & SDHCI_USE_ADMA))
> +				ctrl |= SDHCI_CTRL_ADMA32;
> +			else
> +				ctrl |= SDHCI_CTRL_SDMA;
> +			sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
> +		}

drivers/mmc/host/sdhci.c must know nothing about ESDHC registers.
It's a generic driver.  We can add hooks so that your own driver
can run code in the right place instead.

Thanks,

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

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

* RE: [PATCH 5/5 v4] ESDHC: Fix DMA errors in kernel booting on P1010
  2012-01-06 15:00           ` Chris Ball
@ 2012-01-09  2:59             ` Huang Changming-R66093
  0 siblings, 0 replies; 19+ messages in thread
From: Huang Changming-R66093 @ 2012-01-09  2:59 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc, Jain Priyanka-B32167



> -----Original Message-----
> From: Chris Ball [mailto:cjb@laptop.org]
> Sent: Friday, January 06, 2012 11:00 PM
> To: Huang Changming-R66093
> Cc: linux-mmc@vger.kernel.org; Huang Changming-R66093; Jain Priyanka-
> B32167
> Subject: Re: [PATCH 5/5 v4] ESDHC: Fix DMA errors in kernel booting on
> P1010
> 
> Hi Jerry,
> 
> On Fri, Jan 06 2012, r66093@freescale.com wrote:
> > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index
> > 2db0d5c..d5a2259 100644
> > --- a/drivers/mmc/host/sdhci.c
> > +++ b/drivers/mmc/host/sdhci.c
> > @@ -832,14 +832,29 @@ static void sdhci_prepare_data(struct sdhci_host
> *host, struct mmc_command *cmd)
> >  	 * is ADMA.
> >  	 */
> >  	if (host->version >= SDHCI_SPEC_200) {
> > -		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
> > -		ctrl &= ~SDHCI_CTRL_DMA_MASK;
> > -		if ((host->flags & SDHCI_REQ_USE_DMA) &&
> > -			(host->flags & SDHCI_USE_ADMA))
> > -			ctrl |= SDHCI_CTRL_ADMA32;
> > -		else
> > -			ctrl |= SDHCI_CTRL_SDMA;
> > -		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
> > +		if (host->quirks2 & SDHCI_QUIRK2_QORIQ_PROCTL_WEIRD) {
> > +#define ESDHCI_PROCTL_DMAS_MASK		0x00000300
> > +#define ESDHCI_PROCTL_ADMA32		0x00000200
> > +#define ESDHCI_PROCTL_SDMA		0x00000000
> > +			u32 ctrl;
> > +			ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL);
> > +			ctrl &= ~ESDHCI_PROCTL_DMAS_MASK;
> > +			if ((host->flags & SDHCI_REQ_USE_DMA) &&
> > +				(host->flags & SDHCI_USE_ADMA))
> > +				ctrl |= ESDHCI_PROCTL_ADMA32;
> > +			else
> > +				ctrl |= ESDHCI_PROCTL_SDMA;
> > +			sdhci_writel(host, ctrl, SDHCI_HOST_CONTROL);
> > +		} else {
> > +			ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
> > +			ctrl &= ~SDHCI_CTRL_DMA_MASK;
> > +			if ((host->flags & SDHCI_REQ_USE_DMA) &&
> > +				(host->flags & SDHCI_USE_ADMA))
> > +				ctrl |= SDHCI_CTRL_ADMA32;
> > +			else
> > +				ctrl |= SDHCI_CTRL_SDMA;
> > +			sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
> > +		}
> 
> drivers/mmc/host/sdhci.c must know nothing about ESDHC registers.
> It's a generic driver.  We can add hooks so that your own driver can run
> code in the right place instead.
> 
Hi, Chris,
For the PROCTL register, the FSL ESDHC controller has different bit setting.
So I just redefined the related bit for this register.
I have thought about it, but I didn't find the better way to implement it.
If use the hook, but, how to handle the bit setting for SDHCI_POWER_CONTROL?


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

* RE: [PATCH 1/5 v2] ESDHC: add PIO mode support
  2012-01-06  5:33 ` [PATCH 1/5 v2] ESDHC: add PIO mode support r66093
  2012-01-06  5:33   ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value r66093
@ 2012-01-13  2:35   ` Huang Changming-R66093
  2012-01-13 11:56     ` Anton Vorontsov
  1 sibling, 1 reply; 19+ messages in thread
From: Huang Changming-R66093 @ 2012-01-13  2:35 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc

Hi, Anton,
Could you have any comment about this serial patch?

Thanks
Jerry Huang
> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Friday, January 06, 2012 1:33 PM
> To: linux-mmc@vger.kernel.org
> Cc: Huang Changming-R66093; Gao Guanhua-B22826; Chris Ball
> Subject: [PATCH 1/5 v2] ESDHC: add PIO mode support
> 
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> 
> For some FSL ESDHC controller(e.g. P2020E, Rev1.0), the SDHC can not work
> on DMA mode because of the hardware bug, so we set a broken dma flag and
> use PIO mode.
> 
> Signed-off-by: Gao Guanhua <B22826@freescale.com>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
> 	- change the property to compatible for quirks
> 
>  drivers/mmc/host/sdhci-pltfm.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-
> pltfm.c index a9e12ea..ba36c36 100644
> --- a/drivers/mmc/host/sdhci-pltfm.c
> +++ b/drivers/mmc/host/sdhci-pltfm.c
> @@ -2,7 +2,7 @@
>   * sdhci-pltfm.c Support for SDHCI platform devices
>   * Copyright (c) 2009 Intel Corporation
>   *
> - * Copyright (c) 2007 Freescale Semiconductor, Inc.
> + * Copyright (c) 2007, 2011 Freescale Semiconductor, Inc.
>   * Copyright (c) 2009 MontaVista Software, Inc.
>   *
>   * Authors: Xiaobo Xie <X.Xie@freescale.com> @@ -71,6 +71,9 @@ void
> sdhci_get_of_property(struct platform_device *pdev)
>  		if (sdhci_of_wp_inverted(np))
>  			host->quirks |= SDHCI_QUIRK_INVERTED_WRITE_PROTECT;
> 
> +		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
> +			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
> +
>  		clk = of_get_property(np, "clock-frequency", &size);
>  		if (clk && size == sizeof(*clk) && *clk)
>  			pltfm_host->clock = be32_to_cpup(clk);
> --
> 1.7.5.4



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

* RE: [PATCH 2/5 v2] ESDHC: set the timeout to the max value
  2012-01-06  5:33   ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value r66093
  2012-01-06  5:33     ` [PATCH 3/5 v4] ESDHC: Power management for ESDHC r66093
@ 2012-01-13  2:36     ` Huang Changming-R66093
  2012-01-13 11:54       ` Anton Vorontsov
  1 sibling, 1 reply; 19+ messages in thread
From: Huang Changming-R66093 @ 2012-01-13  2:36 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc

Hi, Anton,
Could you have any comment about this serial patch?

Thanks
Jerry Huang

> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Friday, January 06, 2012 1:33 PM
> To: linux-mmc@vger.kernel.org
> Cc: Huang Changming-R66093; Gao Guanhua-B22826; Xie Xiaobo-R63061; Chris
> Ball
> Subject: [PATCH 2/5 v2] ESDHC: set the timeout to the max value
> 
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> 
> When access the card on some FSL platform board (e.g p2020, p1010,
> mpc8536), the following error is reported with the timeout value
> calculated:
> 
> mmc0: Got data interrupt 0x00000020 even though no data operation was in
> progress.
> mmc0: Got data interrupt 0x00000020 even though no data operation was in
> progress.
> 
> So we skip the calculation of timeout and use the max value to fix it.
> 
> Signed-off-by: Gao Guanhua <B22826@freescale.com>
> Signed-off-by: Xie Xiaobo <X.Xie@freescale.com>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
> 	- change the property to compatible for quirks
> 
>  drivers/mmc/host/sdhci-pltfm.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-
> pltfm.c index ba36c36..1c254b1 100644
> --- a/drivers/mmc/host/sdhci-pltfm.c
> +++ b/drivers/mmc/host/sdhci-pltfm.c
> @@ -74,6 +74,11 @@ void sdhci_get_of_property(struct platform_device
> *pdev)
>  		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
>  			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
> 
> +		if (of_device_is_compatible(np, "fsl,p2020-esdhc")
> +			|| of_device_is_compatible(np, "fsl,p1010-esdhc")
> +			|| of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
> +			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
> +
>  		clk = of_get_property(np, "clock-frequency", &size);
>  		if (clk && size == sizeof(*clk) && *clk)
>  			pltfm_host->clock = be32_to_cpup(clk);
> --
> 1.7.5.4



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

* RE: [PATCH 3/5 v4] ESDHC: Power management for ESDHC
  2012-01-06  5:33     ` [PATCH 3/5 v4] ESDHC: Power management for ESDHC r66093
  2012-01-06  5:33       ` [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb r66093
@ 2012-01-13  2:36       ` Huang Changming-R66093
  2012-01-13 11:50         ` Anton Vorontsov
  1 sibling, 1 reply; 19+ messages in thread
From: Huang Changming-R66093 @ 2012-01-13  2:36 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc

Hi, Anton,
Could you have any comment about this serial patch?

Thanks
Jerry Huang

> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Friday, January 06, 2012 1:33 PM
> To: linux-mmc@vger.kernel.org
> Cc: Huang Changming-R66093; Jiang Yutang-B14898; Chris Ball
> Subject: [PATCH 3/5 v4] ESDHC: Power management for ESDHC
> 
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> 
> For FSL ESDHC controllor, when enter the sleep, the controller will power
> off,
> therefore the register will lost its valuse, and driver should save value
> of
> register during suspend and used during resume.
> 
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> Signed-off-by: Jiang Yutang <b14898@freescale.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
> 	- change the property to compatible for quirks
> changes for v3:
> 	- fix one compile error
> changes for v4:
> 	- use hooks to suspend/resume the special platform
> 
>  drivers/mmc/host/sdhci-of-esdhc.c |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-
> of-esdhc.c
> index c21be67..385a4ff 100644
> --- a/drivers/mmc/host/sdhci-of-esdhc.c
> +++ b/drivers/mmc/host/sdhci-of-esdhc.c
> @@ -104,6 +104,21 @@ static int esdhc_of_get_cd(struct sdhci_host *host)
>  	return present;
>  }
> 
> +#ifdef CONFIG_PM
> +static u32 esdhc_proctl;
> +static void esdhc_of_suspend(struct sdhci_host *host)
> +{
> +	esdhc_proctl = sdhci_be32bs_readl(host, SDHCI_HOST_CONTROL);
> +}
> +
> +static void esdhc_of_resume(struct sdhci_host *host)
> +{
> +	esdhc_of_enable_dma(host);
> +	sdhci_be32bs_writel(host, esdhc_proctl, SDHCI_HOST_CONTROL);
> +
> +}
> +#endif
> +
>  static struct sdhci_ops sdhci_esdhc_ops = {
>  	.read_l = sdhci_be32bs_readl,
>  	.read_w = esdhc_readw,
> @@ -116,6 +131,10 @@ static struct sdhci_ops sdhci_esdhc_ops = {
>  	.get_max_clock = esdhc_of_get_max_clock,
>  	.get_min_clock = esdhc_of_get_min_clock,
>  	.get_cd = esdhc_of_get_cd,
> +#ifdef CONFIG_PM
> +	.platform_suspend = esdhc_of_suspend,
> +	.platform_resume = esdhc_of_resume,
> +#endif
>  };
> 
>  static struct sdhci_pltfm_data sdhci_esdhc_pdata = {
> --
> 1.7.5.4



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

* RE: [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb
  2012-01-06  5:33       ` [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb r66093
  2012-01-06  5:33         ` [PATCH 5/5 v4] ESDHC: Fix DMA errors in kernel booting on P1010 r66093
@ 2012-01-13  2:37         ` Huang Changming-R66093
  2012-01-13 12:12           ` Anton Vorontsov
  1 sibling, 1 reply; 19+ messages in thread
From: Huang Changming-R66093 @ 2012-01-13  2:37 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc

Hi, Anton,
Could you have any comment about this serial patch?

Thanks
Jerry Huang

> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Friday, January 06, 2012 1:33 PM
> To: linux-mmc@vger.kernel.org
> Cc: Huang Changming-R66093; Jain Priyanka-B32167; Chris Ball
> Subject: [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb
> 
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> 
> SD card read was failing (data crc error)on some cards at
> maximum possible frequency on P1010(CCB frequency set to 400MHz).
> Some clock deviations are also observed at this frequency.
> Hence reduced the mmc clock freq.
> 
> Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
> Singed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Chris Ball <cjb@laptop.org>
> ---
> changes for v2:
> 	- change the property to compatible for quirks
> changes for v3:
> 	- fix one compile error
> changes for v4:
> 	- use hooks to suspend/resume the special platform
> 
>  drivers/mmc/host/sdhci-esdhc.h |    9 ++++++++-
>  drivers/mmc/host/sdhci-pltfm.c |    3 +++
>  include/linux/mmc/sdhci.h      |    2 ++
>  3 files changed, 13 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-
> esdhc.h
> index b97b2f5..8e00174 100644
> --- a/drivers/mmc/host/sdhci-esdhc.h
> +++ b/drivers/mmc/host/sdhci-esdhc.h
> @@ -1,7 +1,7 @@
>  /*
>   * Freescale eSDHC controller driver generics for OF and pltfm.
>   *
> - * Copyright (c) 2007 Freescale Semiconductor, Inc.
> + * Copyright (c) 2007,2011 Freescale Semiconductor, Inc.
>   * Copyright (c) 2009 MontaVista Software, Inc.
>   * Copyright (c) 2010 Pengutronix e.K.
>   *   Author: Wolfram Sang <w.sang@pengutronix.de>
> @@ -56,6 +56,13 @@ static inline void esdhc_set_clock(struct sdhci_host
> *host, unsigned int clock)
>  	if (clock == 0)
>  		goto out;
> 
> +	if (host->quirks2 & SDHCI_QUIRK2_RELAX_FREQ) {
> +		if (clock > 20000000)
> +			clock -= 5000000;
> +		if (clock > 40000000)
> +			clock -= 5000000;
> +	}
> +
>  	while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
>  		pre_div *= 2;
> 
> diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-
> pltfm.c
> index e64f773..841ffc1 100644
> --- a/drivers/mmc/host/sdhci-pltfm.c
> +++ b/drivers/mmc/host/sdhci-pltfm.c
> @@ -79,6 +79,9 @@ void sdhci_get_of_property(struct platform_device *pdev)
>  			|| of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
>  			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
> 
> +		if (of_device_is_compatible(np, "fsl,p1010-esdhc"))
> +			host->quirks2 |= SDHCI_QUIRK2_RELAX_FREQ;
> +
>  		clk = of_get_property(np, "clock-frequency", &size);
>  		if (clk && size == sizeof(*clk) && *clk)
>  			pltfm_host->clock = be32_to_cpup(clk);
> diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
> index e4b6935..f7c1e13 100644
> --- a/include/linux/mmc/sdhci.h
> +++ b/include/linux/mmc/sdhci.h
> @@ -91,6 +91,8 @@ struct sdhci_host {
>  	unsigned int quirks2;	/* More deviations from spec. */
> 
>  #define SDHCI_QUIRK2_OWN_CARD_DETECTION			(1<<0)
> +/* Controller operates the cards at reduced frequency */
> +#define SDHCI_QUIRK2_RELAX_FREQ				(1<<1)
> 
>  	int irq;		/* Device IRQ */
>  	void __iomem *ioaddr;	/* Mapped address */
> --
> 1.7.5.4



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

* Re: [PATCH 3/5 v4] ESDHC: Power management for ESDHC
  2012-01-13  2:36       ` [PATCH 3/5 v4] ESDHC: Power management for ESDHC Huang Changming-R66093
@ 2012-01-13 11:50         ` Anton Vorontsov
  0 siblings, 0 replies; 19+ messages in thread
From: Anton Vorontsov @ 2012-01-13 11:50 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: Chris Ball, linux-mmc

On Fri, Jan 13, 2012 at 02:36:50AM +0000, Huang Changming-R66093 wrote:
> Hi, Anton,
> Could you have any comment about this serial patch?

On this one,

Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>

Thanks,

> Thanks
> Jerry Huang
> 
> > -----Original Message-----
> > From: Huang Changming-R66093
> > Sent: Friday, January 06, 2012 1:33 PM
> > To: linux-mmc@vger.kernel.org
> > Cc: Huang Changming-R66093; Jiang Yutang-B14898; Chris Ball
> > Subject: [PATCH 3/5 v4] ESDHC: Power management for ESDHC
> > 
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > 
> > For FSL ESDHC controllor, when enter the sleep, the controller will power
> > off,
> > therefore the register will lost its valuse, and driver should save value
> > of
> > register during suspend and used during resume.
> > 
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > Signed-off-by: Jiang Yutang <b14898@freescale.com>
> > CC: Chris Ball <cjb@laptop.org>

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

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

* Re: [PATCH 2/5 v2] ESDHC: set the timeout to the max value
  2012-01-13  2:36     ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value Huang Changming-R66093
@ 2012-01-13 11:54       ` Anton Vorontsov
  2012-01-16  3:35         ` Huang Changming-R66093
  0 siblings, 1 reply; 19+ messages in thread
From: Anton Vorontsov @ 2012-01-13 11:54 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: Chris Ball, linux-mmc

On Fri, Jan 13, 2012 at 02:36:21AM +0000, Huang Changming-R66093 wrote:
> Hi, Anton,
> Could you have any comment about this serial patch?
> 
> Thanks
> Jerry Huang
> 
> > -----Original Message-----
> > From: Huang Changming-R66093
> > Sent: Friday, January 06, 2012 1:33 PM
> > To: linux-mmc@vger.kernel.org
> > Cc: Huang Changming-R66093; Gao Guanhua-B22826; Xie Xiaobo-R63061; Chris
> > Ball
> > Subject: [PATCH 2/5 v2] ESDHC: set the timeout to the max value
> > 
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > 
> > When access the card on some FSL platform board (e.g p2020, p1010,
> > mpc8536), the following error is reported with the timeout value
> > calculated:
> > 
> > mmc0: Got data interrupt 0x00000020 even though no data operation was in
> > progress.
> > mmc0: Got data interrupt 0x00000020 even though no data operation was in
> > progress.
> > 
> > So we skip the calculation of timeout and use the max value to fix it.
> > 
> > Signed-off-by: Gao Guanhua <B22826@freescale.com>
> > Signed-off-by: Xie Xiaobo <X.Xie@freescale.com>
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > CC: Chris Ball <cjb@laptop.org>
> > ---
> > changes for v2:
> > 	- change the property to compatible for quirks
> > 
> >  drivers/mmc/host/sdhci-pltfm.c |    5 +++++
> >  1 files changed, 5 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-
> > pltfm.c index ba36c36..1c254b1 100644
> > --- a/drivers/mmc/host/sdhci-pltfm.c
> > +++ b/drivers/mmc/host/sdhci-pltfm.c
> > @@ -74,6 +74,11 @@ void sdhci_get_of_property(struct platform_device
> > *pdev)
> >  		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
> >  			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
> > 
> > +		if (of_device_is_compatible(np, "fsl,p2020-esdhc")
> > +			|| of_device_is_compatible(np, "fsl,p1010-esdhc")
> > +			|| of_device_is_compatible(np, "fsl,mpc8536-esdhc"))

A would add one more tab on these two lines.

Otherwise, looks OK.

Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>

Thanks,

> > +			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
> > +

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

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

* Re: [PATCH 1/5 v2] ESDHC: add PIO mode support
  2012-01-13  2:35   ` [PATCH 1/5 v2] ESDHC: add PIO mode support Huang Changming-R66093
@ 2012-01-13 11:56     ` Anton Vorontsov
  0 siblings, 0 replies; 19+ messages in thread
From: Anton Vorontsov @ 2012-01-13 11:56 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: Chris Ball, linux-mmc

On Fri, Jan 13, 2012 at 02:35:57AM +0000, Huang Changming-R66093 wrote:
> Hi, Anton,
> Could you have any comment about this serial patch?

Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>

Thanks!

> Thanks
> Jerry Huang
> > -----Original Message-----
> > From: Huang Changming-R66093
> > Sent: Friday, January 06, 2012 1:33 PM
> > To: linux-mmc@vger.kernel.org
> > Cc: Huang Changming-R66093; Gao Guanhua-B22826; Chris Ball
> > Subject: [PATCH 1/5 v2] ESDHC: add PIO mode support
> > 
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > 
> > For some FSL ESDHC controller(e.g. P2020E, Rev1.0), the SDHC can not work
> > on DMA mode because of the hardware bug, so we set a broken dma flag and
> > use PIO mode.
> > 
> > Signed-off-by: Gao Guanhua <B22826@freescale.com>
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > CC: Chris Ball <cjb@laptop.org>
> > ---

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

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

* Re: [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb
  2012-01-13  2:37         ` [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb Huang Changming-R66093
@ 2012-01-13 12:12           ` Anton Vorontsov
  2012-01-16  4:43             ` Huang Changming-R66093
  0 siblings, 1 reply; 19+ messages in thread
From: Anton Vorontsov @ 2012-01-13 12:12 UTC (permalink / raw)
  To: Huang Changming-R66093; +Cc: Chris Ball, linux-mmc

On Fri, Jan 13, 2012 at 02:37:07AM +0000, Huang Changming-R66093 wrote:
> Hi, Anton,
> Could you have any comment about this serial patch?
> 
> Thanks
> Jerry Huang
> 
[...]
> > @@ -56,6 +56,13 @@ static inline void esdhc_set_clock(struct sdhci_host
> > *host, unsigned int clock)
> >  	if (clock == 0)
> >  		goto out;
> > 
> > +	if (host->quirks2 & SDHCI_QUIRK2_RELAX_FREQ) {
> > +		if (clock > 20000000)
> > +			clock -= 5000000;
> > +		if (clock > 40000000)
> > +			clock -= 5000000;
> > +	}
> > +

That's weird. According to the code, you are underclocking a device
(i.e. the card actually expects higher clocks).

Did you check (with an oscilloscope) what clocks HW actually generates?
Maybe it just generates higher than expected clocks, then this code
would be a correct workaround.

Otherwise, if HW generates correct/precise clock, then you probably
would rather not permit high clocks at all... but then you limit max
freq to 20 MHz. :-(

Oh well, if the patch works for your HW, I'm fine with it.

Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>

> >  	while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
> >  		pre_div *= 2;
> > 
> > diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-
> > pltfm.c
> > index e64f773..841ffc1 100644
> > --- a/drivers/mmc/host/sdhci-pltfm.c
> > +++ b/drivers/mmc/host/sdhci-pltfm.c
> > @@ -79,6 +79,9 @@ void sdhci_get_of_property(struct platform_device *pdev)
> >  			|| of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
> >  			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
> > 
> > +		if (of_device_is_compatible(np, "fsl,p1010-esdhc"))
> > +			host->quirks2 |= SDHCI_QUIRK2_RELAX_FREQ;
> > +
> >  		clk = of_get_property(np, "clock-frequency", &size);
> >  		if (clk && size == sizeof(*clk) && *clk)
> >  			pltfm_host->clock = be32_to_cpup(clk);
> > diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
> > index e4b6935..f7c1e13 100644
> > --- a/include/linux/mmc/sdhci.h
> > +++ b/include/linux/mmc/sdhci.h
> > @@ -91,6 +91,8 @@ struct sdhci_host {
> >  	unsigned int quirks2;	/* More deviations from spec. */
> > 
> >  #define SDHCI_QUIRK2_OWN_CARD_DETECTION			(1<<0)
> > +/* Controller operates the cards at reduced frequency */
> > +#define SDHCI_QUIRK2_RELAX_FREQ				(1<<1)
> > 
> >  	int irq;		/* Device IRQ */
> >  	void __iomem *ioaddr;	/* Mapped address */
> > --
> > 1.7.5.4
> 
> 

-- 
Anton Vorontsov
Email: cbouatmailru@gmail.com

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

* RE: [PATCH 2/5 v2] ESDHC: set the timeout to the max value
  2012-01-13 11:54       ` Anton Vorontsov
@ 2012-01-16  3:35         ` Huang Changming-R66093
  0 siblings, 0 replies; 19+ messages in thread
From: Huang Changming-R66093 @ 2012-01-16  3:35 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc

Thanks, Anton.

I will post it again.

> -----Original Message-----
> From: Anton Vorontsov [mailto:cbouatmailru@gmail.com]
> Sent: Friday, January 13, 2012 7:55 PM
> To: Huang Changming-R66093
> Cc: Chris Ball; linux-mmc@vger.kernel.org
> Subject: Re: [PATCH 2/5 v2] ESDHC: set the timeout to the max value
> 
> On Fri, Jan 13, 2012 at 02:36:21AM +0000, Huang Changming-R66093 wrote:
> > Hi, Anton,
> > Could you have any comment about this serial patch?
> >
> > Thanks
> > Jerry Huang
> >
> > > -----Original Message-----
> > > From: Huang Changming-R66093
> > > Sent: Friday, January 06, 2012 1:33 PM
> > > To: linux-mmc@vger.kernel.org
> > > Cc: Huang Changming-R66093; Gao Guanhua-B22826; Xie Xiaobo-R63061;
> > > Chris Ball
> > > Subject: [PATCH 2/5 v2] ESDHC: set the timeout to the max value
> > >
> > > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > >
> > > When access the card on some FSL platform board (e.g p2020, p1010,
> > > mpc8536), the following error is reported with the timeout value
> > > calculated:
> > >
> > > mmc0: Got data interrupt 0x00000020 even though no data operation
> > > was in progress.
> > > mmc0: Got data interrupt 0x00000020 even though no data operation
> > > was in progress.
> > >
> > > So we skip the calculation of timeout and use the max value to fix it.
> > >
> > > Signed-off-by: Gao Guanhua <B22826@freescale.com>
> > > Signed-off-by: Xie Xiaobo <X.Xie@freescale.com>
> > > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > > CC: Chris Ball <cjb@laptop.org>
> > > ---
> > > changes for v2:
> > > 	- change the property to compatible for quirks
> > >
> > >  drivers/mmc/host/sdhci-pltfm.c |    5 +++++
> > >  1 files changed, 5 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/drivers/mmc/host/sdhci-pltfm.c
> > > b/drivers/mmc/host/sdhci- pltfm.c index ba36c36..1c254b1 100644
> > > --- a/drivers/mmc/host/sdhci-pltfm.c
> > > +++ b/drivers/mmc/host/sdhci-pltfm.c
> > > @@ -74,6 +74,11 @@ void sdhci_get_of_property(struct platform_device
> > > *pdev)
> > >  		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
> > >  			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
> > >
> > > +		if (of_device_is_compatible(np, "fsl,p2020-esdhc")
> > > +			|| of_device_is_compatible(np, "fsl,p1010-esdhc")
> > > +			|| of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
> 
> A would add one more tab on these two lines.
> 
> Otherwise, looks OK.
> 
> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>
> 
> Thanks,
> 
> > > +			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
> > > +
> 
> --
> Anton Vorontsov
> Email: cbouatmailru@gmail.com


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

* RE: [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb
  2012-01-13 12:12           ` Anton Vorontsov
@ 2012-01-16  4:43             ` Huang Changming-R66093
  0 siblings, 0 replies; 19+ messages in thread
From: Huang Changming-R66093 @ 2012-01-16  4:43 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Chris Ball, linux-mmc



> -----Original Message-----
> From: Anton Vorontsov [mailto:cbouatmailru@gmail.com]
> Sent: Friday, January 13, 2012 8:13 PM
> To: Huang Changming-R66093
> Cc: Chris Ball; linux-mmc@vger.kernel.org
> Subject: Re: [PATCH 4/5 v4] ESDHC: Workaround for data crc error on
> p1010rdb
> 
> On Fri, Jan 13, 2012 at 02:37:07AM +0000, Huang Changming-R66093 wrote:
> > Hi, Anton,
> > Could you have any comment about this serial patch?
> >
> > Thanks
> > Jerry Huang
> >
> [...]
> > > @@ -56,6 +56,13 @@ static inline void esdhc_set_clock(struct
> > > sdhci_host *host, unsigned int clock)
> > >  	if (clock == 0)
> > >  		goto out;
> > >
> > > +	if (host->quirks2 & SDHCI_QUIRK2_RELAX_FREQ) {
> > > +		if (clock > 20000000)
> > > +			clock -= 5000000;
> > > +		if (clock > 40000000)
> > > +			clock -= 5000000;
> > > +	}
> > > +
> 
> That's weird. According to the code, you are underclocking a device (i.e.
> the card actually expects higher clocks).
> 
> Did you check (with an oscilloscope) what clocks HW actually generates?
> Maybe it just generates higher than expected clocks, then this code would
> be a correct workaround.
> 
> Otherwise, if HW generates correct/precise clock, then you probably would
> rather not permit high clocks at all... but then you limit max freq to 20
> MHz. :-(
> 
> Oh well, if the patch works for your HW, I'm fine with it.
> 
> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>
Yes, it is very weird.
Due to the limitation of some FSL platform's eSDHC controller, we must decrease the bus frequency for some SD card, otherwise, the card can't work correctly.

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

* [PATCH 2/5 v2] ESDHC: set the timeout to the max value
  2011-12-22 10:21 r66093
@ 2011-12-22 10:21 ` r66093
  0 siblings, 0 replies; 19+ messages in thread
From: r66093 @ 2011-12-22 10:21 UTC (permalink / raw)
  To: linux-mmc; +Cc: Jerry Huang, Gao Guanhua, Xie Xiaobo, Chris Ball

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

When access the card on some FSL platform board (e.g p2020, p1010, mpc8536),
the following error is reported with the timeout value calculated:

mmc0: Got data interrupt 0x00000020 even though no data operation was
in progress.
mmc0: Got data interrupt 0x00000020 even though no data operation was
in progress.

So we skip the calculation of timeout and use the max value to fix it.

Signed-off-by: Gao Guanhua <B22826@freescale.com>
Signed-off-by: Xie Xiaobo <X.Xie@freescale.com>
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Chris Ball <cjb@laptop.org>
---
changes for v2:
	- change the property to compatible for quirks

 drivers/mmc/host/sdhci-pltfm.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index ba36c36..1c254b1 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -74,6 +74,11 @@ void sdhci_get_of_property(struct platform_device *pdev)
 		if (of_device_is_compatible(np, "fsl,p2020-rev1-esdhc"))
 			host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
 
+		if (of_device_is_compatible(np, "fsl,p2020-esdhc")
+			|| of_device_is_compatible(np, "fsl,p1010-esdhc")
+			|| of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
+			host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
+
 		clk = of_get_property(np, "clock-frequency", &size);
 		if (clk && size == sizeof(*clk) && *clk)
 			pltfm_host->clock = be32_to_cpup(clk);
-- 
1.7.5.4



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

end of thread, other threads:[~2012-01-16  4:43 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-06  5:33 [PATCH 0/1] new version workaround for FSL's eSDHC controller r66093
2012-01-06  5:33 ` [PATCH 1/5 v2] ESDHC: add PIO mode support r66093
2012-01-06  5:33   ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value r66093
2012-01-06  5:33     ` [PATCH 3/5 v4] ESDHC: Power management for ESDHC r66093
2012-01-06  5:33       ` [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb r66093
2012-01-06  5:33         ` [PATCH 5/5 v4] ESDHC: Fix DMA errors in kernel booting on P1010 r66093
2012-01-06 15:00           ` Chris Ball
2012-01-09  2:59             ` Huang Changming-R66093
2012-01-13  2:37         ` [PATCH 4/5 v4] ESDHC: Workaround for data crc error on p1010rdb Huang Changming-R66093
2012-01-13 12:12           ` Anton Vorontsov
2012-01-16  4:43             ` Huang Changming-R66093
2012-01-13  2:36       ` [PATCH 3/5 v4] ESDHC: Power management for ESDHC Huang Changming-R66093
2012-01-13 11:50         ` Anton Vorontsov
2012-01-13  2:36     ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value Huang Changming-R66093
2012-01-13 11:54       ` Anton Vorontsov
2012-01-16  3:35         ` Huang Changming-R66093
2012-01-13  2:35   ` [PATCH 1/5 v2] ESDHC: add PIO mode support Huang Changming-R66093
2012-01-13 11:56     ` Anton Vorontsov
  -- strict thread matches above, loose matches on Subject: below --
2011-12-22 10:21 r66093
2011-12-22 10:21 ` [PATCH 2/5 v2] ESDHC: set the timeout to the max value 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.