Skip to contentSkip to conversation

powerpc/esdhc: disable CMD23 for some Freescale SoCs

PATCH Superseded [email protected] 3 participants 7 messages Sep 26, 2012 – Oct 25, 2012

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 powerpc/esdhc: disable CMD23 for some Freescale SoCs

From: Jerry Huang <[email protected]>

CMD23 causes lots of errors in kernel on some freescale SoCs (P1020, P1021, P1022, P1024, P1025 and P4080) when MMC card used, which is because these controllers does not support CMD23, even on the SoCs which declares CMD23 is supported. Therefore, we'll not use CMD23.

---
changes for v5:
- change the error to warning information
changes for v4:
- change to detect the IP version
- don't use callback function
changes for v3:
- move the limitation detect function to eSDHC file
- add the callback funtion to do this limitation detect
changes for v2:
- discard the property mode and add the processor detection

 drivers/mmc/host/sdhci-of-esdhc.c |   33 +++++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-pltfm.c    |    4 +++-
 drivers/mmc/host/sdhci-pltfm.h    |    1 +
 drivers/mmc/host/sdhci.c          |    3 +++
 include/linux/mmc/sdhci.h         |    1 +
 5 files changed, 41 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-esdhc.c +33 -0
index ae5fcbf..ffc1226 100644
@@ -169,6 +169,38 @@ static void esdhc_of_resume(struct sdhci_host *host)
 }
 #endif
 
+static void esdhc_of_detect_limitation(struct platform_device *pdev,
+	struct sdhci_pltfm_data *pdata)
+{
+	void __iomem *ioaddr;
+	struct resource *iomem;
+	u32 vvn;
+
+	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!iomem) {
+		dev_warn(&pdev->dev, "failed to get resource\n");
+		goto end;
+	}
+	if (resource_size(iomem) < 0x100)
+		dev_warn(&pdev->dev, "Invalid iomem size!\n");
+
+	ioaddr = ioremap(iomem->start, resource_size(iomem));
+	if (!ioaddr) {
+		dev_warn(&pdev->dev, "failed to remap registers\n");
+		goto end;
+	}
+
+	/* P102x and P4080 has IP version VVN2.2, CMD23 is not supported */
+	vvn = in_be32(ioaddr + SDHCI_SLOT_INT_STATUS);
+	vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT;
+	if (vvn == VENDOR_V_22)
+		pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
+
+	iounmap(ioaddr);
+end:
+	return;
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
 	.read_l = esdhc_readl,
 	.read_w = esdhc_readw,
@@ -199,6 +231,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata = {
 
 static int __devinit sdhci_esdhc_probe(struct platform_device *pdev)
 {
+	esdhc_of_detect_limitation(pdev, &sdhci_esdhc_pdata);
 	return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata);
 }
 
drivers/mmc/host/sdhci-pltfm.c +3 -1
index 65551a9..4dd5770 100644
@@ -132,8 +132,10 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
 		host->ops = pdata->ops;
 	else
 		host->ops = &sdhci_pltfm_ops;
-	if (pdata)
+	if (pdata) {
 		host->quirks = pdata->quirks;
+		host->quirks2 = pdata->quirks2;
+	}
 	host->irq = platform_get_irq(pdev, 0);
 
 	if (!request_mem_region(iomem->start, resource_size(iomem),
drivers/mmc/host/sdhci-pltfm.h +1 -0
index 37e0e18..283d54a 100644
@@ -18,6 +18,7 @@
 struct sdhci_pltfm_data {
 	struct sdhci_ops *ops;
 	unsigned int quirks;
+	unsigned int quirks2;
 };
 
 struct sdhci_pltfm_host {
drivers/mmc/host/sdhci.c +3 -0
index 0e15c79..b0b7cad 100644
@@ -2837,6 +2837,9 @@ int sdhci_add_host(struct sdhci_host *host)
 	if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
 		mmc->caps |= MMC_CAP_4_BIT_DATA;
 
+	if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
+		mmc->caps &= ~MMC_CAP_CMD23;
+
 	if (caps[0] & SDHCI_CAN_DO_HISPD)
 		mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
 
include/linux/mmc/sdhci.h +1 -0
index fa8529a..1edcb4d 100644
@@ -91,6 +91,7 @@ struct sdhci_host {
 	unsigned int quirks2;	/* More deviations from spec. */
 
 #define SDHCI_QUIRK2_HOST_OFF_CARD_ON			(1<<0)
+#define SDHCI_QUIRK2_HOST_NO_CMD23			(1<<1)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */
Signature · 1 line
1.7.9.5
#1 lore raw

Looks good
Reviewed By:- Girish K S <[email protected]>

Quoted 144 lines · On 26 September 2012 15:02, <[email protected]> wrote:

From: Jerry Huang <[email protected]>

CMD23 causes lots of errors in kernel on some freescale SoCs (P1020, P1021, P1022, P1024, P1025 and P4080) when MMC card used, which is because these controllers does not support CMD23, even on the SoCs which declares CMD23 is supported. Therefore, we'll not use CMD23.

---
changes for v5:
- change the error to warning information
changes for v4:
- change to detect the IP version
- don't use callback function
changes for v3:
- move the limitation detect function to eSDHC file
- add the callback funtion to do this limitation detect
changes for v2:
- discard the property mode and add the processor detection

 drivers/mmc/host/sdhci-of-esdhc.c |   33 +++++++++++++++++++++++++++++++++
 drivers/mmc/host/sdhci-pltfm.c    |    4 +++-
 drivers/mmc/host/sdhci-pltfm.h    |    1 +
 drivers/mmc/host/sdhci.c          |    3 +++
 include/linux/mmc/sdhci.h         |    1 +
 5 files changed, 41 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-esdhc.c +33 -0
index ae5fcbf..ffc1226 100644
@@ -169,6 +169,38 @@ static void esdhc_of_resume(struct sdhci_host *host)
 }
 #endif
 
+static void esdhc_of_detect_limitation(struct platform_device *pdev,
+       struct sdhci_pltfm_data *pdata)
+{
+       void __iomem *ioaddr;
+       struct resource *iomem;
+       u32 vvn;
+
+       iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!iomem) {
+               dev_warn(&pdev->dev, "failed to get resource\n");
+               goto end;
+       }
+       if (resource_size(iomem) < 0x100)
+               dev_warn(&pdev->dev, "Invalid iomem size!\n");
+
+       ioaddr = ioremap(iomem->start, resource_size(iomem));
+       if (!ioaddr) {
+               dev_warn(&pdev->dev, "failed to remap registers\n");
+               goto end;
+       }
+
+       /* P102x and P4080 has IP version VVN2.2, CMD23 is not supported */
+       vvn = in_be32(ioaddr + SDHCI_SLOT_INT_STATUS);
+       vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT;
+       if (vvn == VENDOR_V_22)
+               pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
+
+       iounmap(ioaddr);
+end:
+       return;
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
        .read_l = esdhc_readl,
        .read_w = esdhc_readw,
@@ -199,6 +231,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata = {
 
 static int __devinit sdhci_esdhc_probe(struct platform_device *pdev)
 {
+       esdhc_of_detect_limitation(pdev, &sdhci_esdhc_pdata);
        return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata);
 }
 
drivers/mmc/host/sdhci-pltfm.c +3 -1
index 65551a9..4dd5770 100644
@@ -132,8 +132,10 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
                host->ops = pdata->ops;
        else
                host->ops = &sdhci_pltfm_ops;
-       if (pdata)
+       if (pdata) {
                host->quirks = pdata->quirks;
+               host->quirks2 = pdata->quirks2;
+       }
        host->irq = platform_get_irq(pdev, 0);
 
        if (!request_mem_region(iomem->start, resource_size(iomem),
drivers/mmc/host/sdhci-pltfm.h +1 -0
index 37e0e18..283d54a 100644
@@ -18,6 +18,7 @@
 struct sdhci_pltfm_data {
        struct sdhci_ops *ops;
        unsigned int quirks;
+       unsigned int quirks2;
 };
 
 struct sdhci_pltfm_host {
drivers/mmc/host/sdhci.c +3 -0
index 0e15c79..b0b7cad 100644
@@ -2837,6 +2837,9 @@ int sdhci_add_host(struct sdhci_host *host)
        if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
                mmc->caps |= MMC_CAP_4_BIT_DATA;
 
+       if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
+               mmc->caps &= ~MMC_CAP_CMD23;
+
        if (caps[0] & SDHCI_CAN_DO_HISPD)
                mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
 
include/linux/mmc/sdhci.h +1 -1
index fa8529a..1edcb4d 100644
@@ -91,6 +91,7 @@ struct sdhci_host {
        unsigned int quirks2;   /* More deviations from spec. */
 
 #define SDHCI_QUIRK2_HOST_OFF_CARD_ON                  (1<<0)
+#define SDHCI_QUIRK2_HOST_NO_CMD23                     (1<<1)
 
        int irq;                /* Device IRQ */
        void __iomem *ioaddr;   /* Mapped address */
--

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

Hi, Anto and Chris
This version was created with the feedback from Kumar and all of you. Have you any comment about this patch?
Could it be merged into kernel?

Best Regards
Jerry Huang

Quoted 159 lines

-----Original Message-----
From: Girish K S [mailto:[email protected]]
Sent: Wednesday, September 26, 2012 9:04 PM
To: Huang Changming-R66093
Cc: [email protected]; Huang Changming-R66093; Xie Shaohui-B21989; Anton Vorontsov; Chris Ball
Subject: Re: [PATCH v5] powerpc/esdhc: disable CMD23 for some Freescale SoCs

Looks good
Reviewed By:- Girish K S <[email protected]>

Quoted 23 lines · On 26 September 2012 15:02, <[email protected]> wrote:

From: Jerry Huang <[email protected]>

CMD23 causes lots of errors in kernel on some freescale SoCs (P1020, P1021, P1022, P1024, P1025 and P4080) when MMC card used, which is because these controllers does not support CMD23, even on the SoCs which declares CMD23 is supported.
Therefore, we'll not use CMD23.

---
changes for v5:
- change the error to warning information changes for v4:
- change to detect the IP version
- don't use callback function
changes for v3:
- move the limitation detect function to eSDHC file
- add the callback funtion to do this limitation detect
changes for v2:
- discard the property mode and add the processor detection

Quoted 1 line
 drivers/mmc/host/sdhci-of-esdhc.c |   33

+++++++++++++++++++++++++++++++++

Quoted 25 lines
 drivers/mmc/host/sdhci-pltfm.c    |    4 +++-
 drivers/mmc/host/sdhci-pltfm.h    |    1 +
 drivers/mmc/host/sdhci.c          |    3 +++
 include/linux/mmc/sdhci.h         |    1 +
 5 files changed, 41 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-esdhc.c +11 -0
index ae5fcbf..ffc1226 100644
@@ -169,6 +169,38 @@ static void esdhc_of_resume(struct sdhci_host
 *host)  }  #endif
 
+static void esdhc_of_detect_limitation(struct platform_device *pdev,
+       struct sdhci_pltfm_data *pdata) {
+       void __iomem *ioaddr;
+       struct resource *iomem;
+       u32 vvn;
+
+       iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!iomem) {
+               dev_warn(&pdev->dev, "failed to get resource\n");
+               goto end;
+       }

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_resume(struct sdhci_host · line 191

Quoted 10 lines
drivers/mmc/host/sdhci-of-esdhc.c +10 -0
+       if (resource_size(iomem) < 0x100)
+               dev_warn(&pdev->dev, "Invalid iomem size!\n");
+
+       ioaddr = ioremap(iomem->start, resource_size(iomem));
+       if (!ioaddr) {
+               dev_warn(&pdev->dev, "failed to remap registers\n");
+               goto end;
+       }
+
+       /* P102x and P4080 has IP version VVN2.2, CMD23 is not

supported */

drivers/mmc/host/sdhci-pltfm.c struct sdhci_host *sdhci_pltfm_init(struct

Quoted 26 lines
drivers/mmc/host/sdhci-of-esdhc.c +11 -0
+       vvn = in_be32(ioaddr + SDHCI_SLOT_INT_STATUS);
+       vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT;
+       if (vvn == VENDOR_V_22)
+               pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
+
+       iounmap(ioaddr);
+end:
+       return;
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
        .read_l = esdhc_readl,
        .read_w = esdhc_readw,
@@ -199,6 +231,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata =
 {
 
 static int __devinit sdhci_esdhc_probe(struct platform_device *pdev)
 {
+       esdhc_of_detect_limitation(pdev, &sdhci_esdhc_pdata);
        return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata);  }
 
(quoted diff) +0 -0

b/drivers/mmc/host/sdhci-pltfm.c index 65551a9..4dd5770 100644

drivers/mmc/host/sdhci-pltfm.c +0 -0
@@ -132,8 +132,10 @@ struct sdhci_host *sdhci_pltfm_init(struct

platform_device *pdev,

Quoted 58 lines
drivers/mmc/host/sdhci-pltfm.c +3 -1
                host->ops = pdata->ops;
        else
                host->ops = &sdhci_pltfm_ops;
-       if (pdata)
+       if (pdata) {
                host->quirks = pdata->quirks;
+               host->quirks2 = pdata->quirks2;
+       }
        host->irq = platform_get_irq(pdev, 0);
 
        if (!request_mem_region(iomem->start, resource_size(iomem),
(quoted diff) +0 -0

b/drivers/mmc/host/sdhci-pltfm.h index 37e0e18..283d54a 100644

drivers/mmc/host/sdhci-pltfm.h +1 -0
@@ -18,6 +18,7 @@
 struct sdhci_pltfm_data {
        struct sdhci_ops *ops;
        unsigned int quirks;
+       unsigned int quirks2;
 };
 
 struct sdhci_pltfm_host {
drivers/mmc/host/sdhci.c index renamed from drivers/mmc/host/sdhci.c +0 -0

0e15c79..b0b7cad 100644

drivers/mmc/host/sdhci.c +3 -0
@@ -2837,6 +2837,9 @@ int sdhci_add_host(struct sdhci_host *host)
        if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
                mmc->caps |= MMC_CAP_4_BIT_DATA;
 
+       if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
+               mmc->caps &= ~MMC_CAP_CMD23;
+
        if (caps[0] & SDHCI_CAN_DO_HISPD)
                mmc->caps |= MMC_CAP_SD_HIGHSPEED |
 MMC_CAP_MMC_HIGHSPEED;
include/linux/mmc/sdhci.h +1 -1
index fa8529a..1edcb4d 100644
@@ -91,6 +91,7 @@ struct sdhci_host {
        unsigned int quirks2;   /* More deviations from spec. */
 
 #define SDHCI_QUIRK2_HOST_OFF_CARD_ON                  (1<<0)
+#define SDHCI_QUIRK2_HOST_NO_CMD23                     (1<<1)
 
        int irq;                /* Device IRQ */
        void __iomem *ioaddr;   /* Mapped address */
--

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Anton,
Have you any comment about this patch?

Best Regards
Jerry Huang

Quoted 181 lines

-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Huang Changming-R66093
Sent: Tuesday, October 09, 2012 2:24 PM
To: Anton Vorontsov; Chris Ball
Cc: [email protected]; Xie Shaohui-B21989; Girish K S
Subject: RE: [PATCH v5] powerpc/esdhc: disable CMD23 for some Freescale SoCs

Hi, Anto and Chris
This version was created with the feedback from Kumar and all of you. Have you any comment about this patch?
Could it be merged into kernel?

Best Regards
Jerry Huang

Quoted 154 lines

-----Original Message-----
From: Girish K S [mailto:[email protected]]
Sent: Wednesday, September 26, 2012 9:04 PM
To: Huang Changming-R66093
Cc: [email protected]; Huang Changming-R66093; Xie Shaohui-B21989; Anton Vorontsov; Chris Ball
Subject: Re: [PATCH v5] powerpc/esdhc: disable CMD23 for some Freescale SoCs

Looks good
Reviewed By:- Girish K S <[email protected]>

Quoted 22 lines · On 26 September 2012 15:02, <[email protected]> wrote:

From: Jerry Huang <[email protected]>

CMD23 causes lots of errors in kernel on some freescale SoCs (P1020, P1021, P1022, P1024, P1025 and P4080) when MMC card used, which is because these controllers does not support CMD23, even on the SoCs which declares CMD23 is supported.
Therefore, we'll not use CMD23.

---
changes for v5:
- change the error to warning information changes for v4:
- change to detect the IP version
- don't use callback function changes for v3:
- move the limitation detect function to eSDHC file
- add the callback funtion to do this limitation detect
changes for v2:
- discard the property mode and add the processor detection

Quoted 1 line
 drivers/mmc/host/sdhci-of-esdhc.c |   33

+++++++++++++++++++++++++++++++++

Quoted 25 lines
 drivers/mmc/host/sdhci-pltfm.c    |    4 +++-
 drivers/mmc/host/sdhci-pltfm.h    |    1 +
 drivers/mmc/host/sdhci.c          |    3 +++
 include/linux/mmc/sdhci.h         |    1 +
 5 files changed, 41 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-esdhc.c +11 -0
index ae5fcbf..ffc1226 100644
@@ -169,6 +169,38 @@ static void esdhc_of_resume(struct sdhci_host
 *host)  }  #endif
 
+static void esdhc_of_detect_limitation(struct platform_device *pdev,
+       struct sdhci_pltfm_data *pdata) {
+       void __iomem *ioaddr;
+       struct resource *iomem;
+       u32 vvn;
+
+       iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!iomem) {
+               dev_warn(&pdev->dev, "failed to get resource\n");
+               goto end;
+       }

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_resume(struct sdhci_host · line 191

Quoted 10 lines
drivers/mmc/host/sdhci-of-esdhc.c +10 -0
+       if (resource_size(iomem) < 0x100)
+               dev_warn(&pdev->dev, "Invalid iomem size!\n");
+
+       ioaddr = ioremap(iomem->start, resource_size(iomem));
+       if (!ioaddr) {
+               dev_warn(&pdev->dev, "failed to remap registers\n");
+               goto end;
+       }
+
+       /* P102x and P4080 has IP version VVN2.2, CMD23 is not

supported */

drivers/mmc/host/sdhci-pltfm.c struct sdhci_host *sdhci_pltfm_init(struct

Quoted 26 lines
drivers/mmc/host/sdhci-of-esdhc.c +11 -0
+       vvn = in_be32(ioaddr + SDHCI_SLOT_INT_STATUS);
+       vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT;
+       if (vvn == VENDOR_V_22)
+               pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
+
+       iounmap(ioaddr);
+end:
+       return;
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
        .read_l = esdhc_readl,
        .read_w = esdhc_readw,
@@ -199,6 +231,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata
 = {
 
 static int __devinit sdhci_esdhc_probe(struct platform_device
 *pdev) {
+       esdhc_of_detect_limitation(pdev, &sdhci_esdhc_pdata);
        return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata);  }
 
(quoted diff) +0 -0

b/drivers/mmc/host/sdhci-pltfm.c index 65551a9..4dd5770 100644

drivers/mmc/host/sdhci-pltfm.c +0 -0
@@ -132,8 +132,10 @@ struct sdhci_host *sdhci_pltfm_init(struct

platform_device *pdev,

Quoted 54 lines
drivers/mmc/host/sdhci-pltfm.c +3 -1
                host->ops = pdata->ops;
        else
                host->ops = &sdhci_pltfm_ops;
-       if (pdata)
+       if (pdata) {
                host->quirks = pdata->quirks;
+               host->quirks2 = pdata->quirks2;
+       }
        host->irq = platform_get_irq(pdev, 0);
 
        if (!request_mem_region(iomem->start, resource_size(iomem),
(quoted diff) +0 -0

b/drivers/mmc/host/sdhci-pltfm.h index 37e0e18..283d54a 100644

drivers/mmc/host/sdhci-pltfm.h +1 -0
@@ -18,6 +18,7 @@
 struct sdhci_pltfm_data {
        struct sdhci_ops *ops;
        unsigned int quirks;
+       unsigned int quirks2;
 };
 
 struct sdhci_pltfm_host {
drivers/mmc/host/sdhci.c +3 -0
index 0e15c79..b0b7cad 100644
@@ -2837,6 +2837,9 @@ int sdhci_add_host(struct sdhci_host *host)
        if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
                mmc->caps |= MMC_CAP_4_BIT_DATA;
 
+       if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
+               mmc->caps &= ~MMC_CAP_CMD23;
+
        if (caps[0] & SDHCI_CAN_DO_HISPD)
                mmc->caps |= MMC_CAP_SD_HIGHSPEED |
 MMC_CAP_MMC_HIGHSPEED;
include/linux/mmc/sdhci.h +1 -1
index fa8529a..1edcb4d 100644
@@ -91,6 +91,7 @@ struct sdhci_host {
        unsigned int quirks2;   /* More deviations from spec. */
 
 #define SDHCI_QUIRK2_HOST_OFF_CARD_ON                  (1<<0)
+#define SDHCI_QUIRK2_HOST_NO_CMD23                     (1<<1)
 
        int irq;                /* Device IRQ */
        void __iomem *ioaddr;   /* Mapped address */
--

1.7.9.5

Quoted 4 lines
Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] 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 [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

#4 lore raw

Anton,
could you give some comment about this patch?
Reviewed by Girish last month.

Best Regards
Jerry Huang

Quoted 200 lines

-----Original Message-----
From: Huang Changming-R66093
Sent: Monday, October 15, 2012 11:07 AM
To: Huang Changming-R66093; Anton Vorontsov; Chris Ball
Cc: [email protected]; Xie Shaohui-B21989; Girish K S
Subject: RE: [PATCH v5] powerpc/esdhc: disable CMD23 for some Freescale SoCs

Anton,
Have you any comment about this patch?

Best Regards
Jerry Huang

Quoted 69 lines

-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Huang Changming-R66093
Sent: Tuesday, October 09, 2012 2:24 PM
To: Anton Vorontsov; Chris Ball
Cc: [email protected]; Xie Shaohui-B21989; Girish K S
Subject: RE: [PATCH v5] powerpc/esdhc: disable CMD23 for some Freescale SoCs

Hi, Anto and Chris
This version was created with the feedback from Kumar and all of you. Have you any comment about this patch?
Could it be merged into kernel?

Best Regards
Jerry Huang

Quoted 52 lines

-----Original Message-----
From: Girish K S [mailto:[email protected]]
Sent: Wednesday, September 26, 2012 9:04 PM
To: Huang Changming-R66093
Cc: [email protected]; Huang Changming-R66093; Xie Shaohui-B21989; Anton Vorontsov; Chris Ball
Subject: Re: [PATCH v5] powerpc/esdhc: disable CMD23 for some Freescale SoCs

Looks good
Reviewed By:- Girish K S <[email protected]>

Quoted 23 lines · On 26 September 2012 15:02, <[email protected]> wrote:

From: Jerry Huang <[email protected]>

CMD23 causes lots of errors in kernel on some freescale SoCs (P1020, P1021, P1022, P1024, P1025 and P4080) when MMC card used, which is because these controllers does not support CMD23, even on the SoCs which declares CMD23 is supported.
Therefore, we'll not use CMD23.

---
changes for v5:
- change the error to warning information changes for v4:
- change to detect the IP version
- don't use callback function changes for v3:
- move the limitation detect function to eSDHC file
- add the callback funtion to do this limitation detect
changes for v2:
- discard the property mode and add the processor
detection

Quoted 1 line
 drivers/mmc/host/sdhci-of-esdhc.c |   33

+++++++++++++++++++++++++++++++++

Quoted 14 lines
 drivers/mmc/host/sdhci-pltfm.c    |    4 +++-
 drivers/mmc/host/sdhci-pltfm.h    |    1 +
 drivers/mmc/host/sdhci.c          |    3 +++
 include/linux/mmc/sdhci.h         |    1 +
 5 files changed, 41 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-esdhc.c +0 -0
index ae5fcbf..ffc1226 100644
@@ -169,6 +169,38 @@ static void esdhc_of_resume(struct sdhci_host
 *host)  }  #endif
 
Quoted 1 line
Quoted 1 line

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_resume(struct sdhci_host · line 171

Quoted 1 line
drivers/mmc/host/sdhci-of-esdhc.c +1 -0
+static void esdhc_of_detect_limitation(struct platform_device

*pdev,

Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
drivers/mmc/host/sdhci-of-esdhc.c +10 -0
+       struct sdhci_pltfm_data *pdata) {
+       void __iomem *ioaddr;
+       struct resource *iomem;
+       u32 vvn;
+
+       iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!iomem) {
+               dev_warn(&pdev->dev, "failed to get resource\n");
+               goto end;
+       }

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_resume(struct sdhci_host *host)

Quoted 10 lines
drivers/mmc/host/sdhci-of-esdhc.c +10 -0
+       if (resource_size(iomem) < 0x100)
+               dev_warn(&pdev->dev, "Invalid iomem size!\n");
+
+       ioaddr = ioremap(iomem->start, resource_size(iomem));
+       if (!ioaddr) {
+               dev_warn(&pdev->dev, "failed to remap registers\n");
+               goto end;
+       }
+
+       /* P102x and P4080 has IP version VVN2.2, CMD23 is not

supported */

Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_resume(struct sdhci_host · line 193

Quoted 2 lines
drivers/mmc/host/sdhci-of-esdhc.c +2 -0
+       vvn = in_be32(ioaddr + SDHCI_SLOT_INT_STATUS);
+       vvn = (vvn & SDHCI_VENDOR_VER_MASK) >>

SDHCI_VENDOR_VER_SHIFT;

Quoted 73 lines
Quoted 73 lines

drivers/mmc/host/sdhci-pltfm.c struct sdhci_host *sdhci_pltfm_init(struct

Quoted 24 lines
drivers/mmc/host/sdhci-of-esdhc.c +9 -0
+       if (vvn == VENDOR_V_22)
+               pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
+
+       iounmap(ioaddr);
+end:
+       return;
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
        .read_l = esdhc_readl,
        .read_w = esdhc_readw,
@@ -199,6 +231,7 @@ static struct sdhci_pltfm_data
 sdhci_esdhc_pdata = {
 
 static int __devinit sdhci_esdhc_probe(struct platform_device
 *pdev) {
+       esdhc_of_detect_limitation(pdev, &sdhci_esdhc_pdata);
        return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata);  }
 
(quoted diff) +0 -0

b/drivers/mmc/host/sdhci-pltfm.c index 65551a9..4dd5770 100644

drivers/mmc/host/sdhci-pltfm.c +0 -0
@@ -132,8 +132,10 @@ struct sdhci_host *sdhci_pltfm_init(struct

platform_device *pdev,

Quoted 48 lines
drivers/mmc/host/sdhci-pltfm.c +3 -1
                host->ops = pdata->ops;
        else
                host->ops = &sdhci_pltfm_ops;
-       if (pdata)
+       if (pdata) {
                host->quirks = pdata->quirks;
+               host->quirks2 = pdata->quirks2;
+       }
        host->irq = platform_get_irq(pdev, 0);
 
        if (!request_mem_region(iomem->start,

resource_size(iomem), diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h index 37e0e18..283d54a 100644

drivers/mmc/host/sdhci-pltfm.h +1 -0
@@ -18,6 +18,7 @@
 struct sdhci_pltfm_data {
        struct sdhci_ops *ops;
        unsigned int quirks;
+       unsigned int quirks2;
 };
 
 struct sdhci_pltfm_host {
drivers/mmc/host/sdhci.c +3 -0
index 0e15c79..b0b7cad 100644
@@ -2837,6 +2837,9 @@ int sdhci_add_host(struct sdhci_host *host)
        if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
                mmc->caps |= MMC_CAP_4_BIT_DATA;
 
+       if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
+               mmc->caps &= ~MMC_CAP_CMD23;
+
        if (caps[0] & SDHCI_CAN_DO_HISPD)
                mmc->caps |= MMC_CAP_SD_HIGHSPEED |
 MMC_CAP_MMC_HIGHSPEED;
include/linux/mmc/sdhci.h +1 -0
index fa8529a..1edcb4d 100644
@@ -91,6 +91,7 @@ struct sdhci_host {
        unsigned int quirks2;   /* More deviations from spec. */
 
 #define SDHCI_QUIRK2_HOST_OFF_CARD_ON                  (1<<0)
+#define SDHCI_QUIRK2_HOST_NO_CMD23                     (1<<1)
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/mmc/sdhci.h +0 -1
        int irq;                /* Device IRQ */
        void __iomem *ioaddr;   /* Mapped address */
--

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-

mmc"

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

in the body of a message to [email protected] 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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to Huang Changming-R66093

Sorry for the late reply, Huang.

On Tue, Oct 09, 2012 at 06:24:13AM +0000, Huang Changming-R66093 wrote:
[...]

Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+static void esdhc_of_detect_limitation(struct platform_device *pdev,
+       struct sdhci_pltfm_data *pdata) {

Wrong indentation. Should be one more tab, at least (or align to opening brace).

Quoted 20 lines
Quoted 20 lines
Quoted 9 lines
drivers/mmc/host/sdhci-of-esdhc.c +9 -0
+       void __iomem *ioaddr;
+       struct resource *iomem;
+       u32 vvn;
+
+       iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!iomem) {
+               dev_warn(&pdev->dev, "failed to get resource\n");
+               goto end;
+       }

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_resume(struct sdhci_host *host)

Quoted 10 lines
drivers/mmc/host/sdhci-of-esdhc.c +10 -0
+       if (resource_size(iomem) < 0x100)
+               dev_warn(&pdev->dev, "Invalid iomem size!\n");
+
+       ioaddr = ioremap(iomem->start, resource_size(iomem));
+       if (!ioaddr) {
+               dev_warn(&pdev->dev, "failed to remap registers\n");
+               goto end;
+       }
+
+       /* P102x and P4080 has IP version VVN2.2, CMD23 is not

supported */

Quoted 8 lines
Quoted 8 lines

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_resume(struct sdhci_host *host) · line 201

Quoted 8 lines
drivers/mmc/host/sdhci-of-esdhc.c +8 -0
+       vvn = in_be32(ioaddr + SDHCI_SLOT_INT_STATUS);
+       vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT;
+       if (vvn == VENDOR_V_22)
+               pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
+
+       iounmap(ioaddr);
+end:
+       return;

No need for the 'end' label.

Quoted 11 lines
Quoted 11 lines

drivers/mmc/host/sdhci-of-esdhc.c static struct sdhci_pltfm_data sdhci_esdhc_pdata = · line 235

Quoted 11 lines
drivers/mmc/host/sdhci-of-esdhc.c +3 -0
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
        .read_l = esdhc_readl,
        .read_w = esdhc_readw,
@@ -199,6 +231,7 @@ static struct sdhci_pltfm_data sdhci_esdhc_pdata =
 {
 
 static int __devinit sdhci_esdhc_probe(struct platform_device *pdev)
 {
+       esdhc_of_detect_limitation(pdev, &sdhci_esdhc_pdata);

I would rather prefer it to be in sdhci_ops (i.e. introduce sdhci_ops->platform_init), so that way you wouldn't need to ioremap() stuff by yourself. And make drivers/mmc/host/sdhci-pltfm.c call platform_init after ioremap().

Then your detect_limitation() function would only need to check revision and set additional quirks.

Thanks,
Anton.

#6 lore raw

Hi, anton,
I have resent this patch according to your suggestion. Please review.
Thanks.

Best Regards
Jerry Huang

Quoted 73 lines

-----Original Message-----
From: Anton Vorontsov [mailto:[email protected]]
Sent: Wednesday, October 24, 2012 4:39 PM
To: Huang Changming-R66093
Cc: Chris Ball; [email protected]; Xie Shaohui-B21989; Girish K S
Subject: Re: [PATCH v5] powerpc/esdhc: disable CMD23 for some Freescale SoCs

Sorry for the late reply, Huang.

On Tue, Oct 09, 2012 at 06:24:13AM +0000, Huang Changming-R66093 wrote:
[...]

Quoted 1 line
Quoted 1 line
Quoted 1 line

+static void esdhc_of_detect_limitation(struct platform_device

*pdev,

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ struct sdhci_pltfm_data *pdata) {

Wrong indentation. Should be one more tab, at least (or align to opening brace).

Quoted 20 lines
Quoted 20 lines
Quoted 9 lines
drivers/mmc/host/sdhci-of-esdhc.c +9 -0
+       void __iomem *ioaddr;
+       struct resource *iomem;
+       u32 vvn;
+
+       iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!iomem) {
+               dev_warn(&pdev->dev, "failed to get resource\n");
+               goto end;
+       }

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_resume(struct sdhci_host *host)

Quoted 10 lines
drivers/mmc/host/sdhci-of-esdhc.c +10 -0
+       if (resource_size(iomem) < 0x100)
+               dev_warn(&pdev->dev, "Invalid iomem size!\n");
+
+       ioaddr = ioremap(iomem->start, resource_size(iomem));
+       if (!ioaddr) {
+               dev_warn(&pdev->dev, "failed to remap registers\n");
+               goto end;
+       }
+
+       /* P102x and P4080 has IP version VVN2.2, CMD23 is not

supported */

Quoted 2 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       vvn = in_be32(ioaddr + SDHCI_SLOT_INT_STATUS);
+       vvn = (vvn & SDHCI_VENDOR_VER_MASK) >>

SDHCI_VENDOR_VER_SHIFT;

Quoted 6 lines
Quoted 6 lines

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_resume(struct sdhci_host *host) · line 201

Quoted 6 lines
drivers/mmc/host/sdhci-of-esdhc.c +6 -0
+       if (vvn == VENDOR_V_22)
+               pdata->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
+
+       iounmap(ioaddr);
+end:
+       return;

No need for the 'end' label.

Quoted 11 lines
Quoted 11 lines

drivers/mmc/host/sdhci-of-esdhc.c static struct sdhci_pltfm_data · line 235

Quoted 11 lines
drivers/mmc/host/sdhci-of-esdhc.c +3 -0
+}
+
 static struct sdhci_ops sdhci_esdhc_ops = {
        .read_l = esdhc_readl,
        .read_w = esdhc_readw,
@@ -199,6 +231,7 @@ static struct sdhci_pltfm_data
 sdhci_esdhc_pdata = {
 
 static int __devinit sdhci_esdhc_probe(struct platform_device
 *pdev) {
+       esdhc_of_detect_limitation(pdev, &sdhci_esdhc_pdata);

I would rather prefer it to be in sdhci_ops (i.e. introduce sdhci_ops-

Quoted 1 line

platform_init), so that way you wouldn't need to ioremap() stuff by

yourself. And make drivers/mmc/host/sdhci-pltfm.c call platform_init after ioremap().

Then your detect_limitation() function would only need to check revision and set additional quirks.

Thanks,
Anton.