Skip to contentSkip to conversation

mmc: Add quirk to disable SDR50 mode

PATCH In review Al Cooper 4 participants 10 messages Nov 5, 2015 – Nov 9, 2015

Subsystems (5)
lore
Share & tools
lore

Al Cooper

author maintainer
#0 lore raw

PATCH 1/4 mmc: Add quirk to disable SDR50 mode

Add quirk to disable SDR50 mode for controllers/boards that have problems with this mode.

---
 drivers/mmc/host/sdhci.c | 3 +++
 drivers/mmc/host/sdhci.h | 2 ++
 2 files changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +3 -0
index b48565e..71067c7 100644
@@ -3176,6 +3176,9 @@ int sdhci_add_host(struct sdhci_host *host)
 	} else if (caps[1] & SDHCI_SUPPORT_SDR50)
 		mmc->caps |= MMC_CAP_UHS_SDR50;
 
+	if (host->quirks2 & SDHCI_QUIRK2_BROKEN_SDR50)
+		mmc->caps &= ~MMC_CAP_UHS_SDR50;
+
 	if (host->quirks2 & SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 &&
 	    (caps[1] & SDHCI_SUPPORT_HS400))
 		mmc->caps2 |= MMC_CAP2_HS400;
drivers/mmc/host/sdhci.h +2 -0
index 9d4aa31..0941c94 100644
@@ -412,6 +412,8 @@ struct sdhci_host {
 #define SDHCI_QUIRK2_ACMD23_BROKEN			(1<<14)
 /* Broken Clock divider zero in controller */
 #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN		(1<<15)
+/* Controller does not support SDR50 */
+#define SDHCI_QUIRK2_BROKEN_SDR50			(1<<16)
 /*
  * When internal clock is disabled, a delay is needed before modifying the
  * SD clock frequency or enabling back the internal clock.
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#1 lore raw

PATCH 2/4 mmc: sdhci-pltfm: Add DT properties to set various QUIRKS

Add support for "broken-sdr50", "broken-ddr50", "broken-64-bit-dma" and "broken-timeout-value" device tree properties.
The properties will cause the corresponding quirks bits to be set. This allows some of the platform specific QUIRKS setting to be moved out of the driver and into the Device Tree node.

---
 drivers/mmc/host/sdhci-pltfm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-pltfm.c +9 -1
index 87fb5ea..81eb4d2 100644
@@ -90,10 +90,14 @@ void sdhci_get_of_property(struct platform_device *pdev)
 	if (of_get_property(np, "no-1-8-v", NULL))
 		host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
 
+	if (of_get_property(np, "broken-64-bit-dma", NULL))
+		host->quirks2 |= SDHCI_QUIRK2_BROKEN_64_BIT_DMA;
+
 	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") ||
+	if (of_get_property(np, "broken-timeout-value", NULL) ||
+	    of_device_is_compatible(np, "fsl,p2020-esdhc") ||
 	    of_device_is_compatible(np, "fsl,p1010-esdhc") ||
 	    of_device_is_compatible(np, "fsl,t4240-esdhc") ||
 	    of_device_is_compatible(np, "fsl,mpc8536-esdhc"))
@@ -106,6 +110,10 @@ void sdhci_get_of_property(struct platform_device *pdev)
 
 	if (of_find_property(np, "enable-sdio-wakeup", NULL))
 		host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
+	if (of_find_property(np, "broken-sdr50", NULL))
+		host->quirks2 |= SDHCI_QUIRK2_BROKEN_SDR50;
+	if (of_find_property(np, "broken-ddr50", NULL))
+		host->quirks2 |= SDHCI_QUIRK2_BROKEN_DDR50;
 }
 #else
 void sdhci_get_of_property(struct platform_device *pdev) {}
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#2 lore raw

PATCH 3/4 mmc: Add Device Tree binding supported by sdhci-pltfm.c

In reply to Al Cooper

This includes both newly added and previously undocumented properties.

---
 Documentation/devicetree/bindings/mmc/mmc.txt | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/mmc/mmc.txt +8 -0
index f693baf..516fdf9 100644
@@ -48,6 +48,14 @@ Optional properties:
 - mmc-hs400-1_2v: eMMC HS400 mode(1.2V I/O) is supported
 - dsr: Value the card's (optional) Driver Stage Register (DSR) should be
   programmed with. Valid range: [0 .. 0xffff].
+- sdhci,auto-cmd12: the controller supports Auto-CMD12 to stop multiblock
+  transfers.
+- broken-64-bit-dma: the controller does not support 64-bit DMA even if
+  the controller claims it does.
+- broken-timeout-value: the timeout value specified by the controller is
+  incorrect and the MAX timeout will be used instead.
+- broken-sdr50: SDR50 mode is broken.
+- broken-ddr50: DDR50 mode is broken.
 
 *NOTE* on CD and WP polarity. To use common for all SD/MMC host controllers line
 polarity properties, we have to fix the meaning of the "normal" and "inverted"
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#3 lore raw

PATCH 4/4 mmc: sdhci-brcmstb: Add sdhci driver for Broadcom BRCMSTB/BMIPS SOCs

In reply to Al Cooper
---
 .../devicetree/bindings/mmc/sdhci-brcmstb.txt      |  16 +++
 drivers/mmc/host/Kconfig                           |  12 ++
 drivers/mmc/host/Makefile                          |   1 +
 drivers/mmc/host/sdhci-brcmstb.c                   | 143 +++++++++++++++++++++
 4 files changed, 172 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-brcmstb.txt
 create mode 100644 drivers/mmc/host/sdhci-brcmstb.c
Documentation/devicetree/bindings/mmc/sdhci-brcmstb.txt new file +16 -0
new file mode 100644
index 0000000..df08173
@@ -0,0 +1,16 @@
+* BROADCOM BRCMSTB/BMIPS SDHCI Controller
+
+This file documents differences between the core properties in mmc.txt
+and the properties used by the sdhci-brcmstb driver.
+
+Required properties:
+- compatible: "brcm,sdhci-brcmstb"
+
+Example:
+
+	sdhci@f03e0100 {
+		compatible = "brcm,sdhci-brcmstb";
+		reg = <0xf03e0000 0x100>;
+		interrupts = <0x0 0x26 0x0>;
+		sdhci,auto-cmd12;
+	};
drivers/mmc/host/Kconfig +12 -0
index af71de5..d99f84a 100644
@@ -784,3 +784,15 @@ config MMC_MTK
 	  If you have a machine with a integrated SD/MMC card reader, say Y or M here.
 	  This is needed if support for any SD/SDIO/MMC devices is required.
 	  If unsure, say N.
+
+config MMC_SDHCI_BRCMSTB
+	tristate "Broadcom SDIO/SD/MMC support"
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC
+	depends on MMC_SDHCI_PLTFM
+	default y
+	select MMC_SDHCI_IO_ACCESSORS
+	help
+	  This selects support for the SDIO/SD/MMC Host Controller on
+	  Broadcom STB SoCs.
+
+	  If unsure, say Y.
drivers/mmc/host/Makefile +1 -0
index 3595f83..e3e163f 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_MMC_SDHCI_BCM2835)		+= sdhci-bcm2835.o
 obj-$(CONFIG_MMC_SDHCI_IPROC)		+= sdhci-iproc.o
 obj-$(CONFIG_MMC_SDHCI_MSM)		+= sdhci-msm.o
 obj-$(CONFIG_MMC_SDHCI_ST)		+= sdhci-st.o
+obj-$(CONFIG_MMC_SDHCI_BRCMSTB)		+= sdhci-brcmstb.o
 
 ifeq ($(CONFIG_CB710_DEBUG),y)
 	CFLAGS-cb710-mmc	+= -DDEBUG
drivers/mmc/host/sdhci-brcmstb.c new file +143 -0

143 lines not on this page · raw message

Signature · 1 line
1.9.0.138.g2de3478
#4 lore raw
In reply to Al Cooper
Quoted 2 lines · Al Cooper

Add quirk to disable SDR50 mode for controllers/boards that have problems with this mode.

No thanks! No more quirks please!

Kind regards
Uffe

Quoted 37 lines
---
 drivers/mmc/host/sdhci.c | 3 +++
 drivers/mmc/host/sdhci.h | 2 ++
 2 files changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +3 -0
index b48565e..71067c7 100644
@@ -3176,6 +3176,9 @@ int sdhci_add_host(struct sdhci_host *host)
        } else if (caps[1] & SDHCI_SUPPORT_SDR50)
                mmc->caps |= MMC_CAP_UHS_SDR50;
 
+       if (host->quirks2 & SDHCI_QUIRK2_BROKEN_SDR50)
+               mmc->caps &= ~MMC_CAP_UHS_SDR50;
+
        if (host->quirks2 & SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 &&
            (caps[1] & SDHCI_SUPPORT_HS400))
                mmc->caps2 |= MMC_CAP2_HS400;
drivers/mmc/host/sdhci.h +2 -1
index 9d4aa31..0941c94 100644
@@ -412,6 +412,8 @@ struct sdhci_host {
 #define SDHCI_QUIRK2_ACMD23_BROKEN                     (1<<14)
 /* Broken Clock divider zero in controller */
 #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN             (1<<15)
+/* Controller does not support SDR50 */
+#define SDHCI_QUIRK2_BROKEN_SDR50                      (1<<16)
 /*
  * When internal clock is disabled, a delay is needed before modifying the
  * SD clock frequency or enabling back the internal clock.
--

1.9.0.138.g2de3478

author maintainer
#5 lore raw
Quoted 1 line · Ulf Hansson

No thanks! No more quirks please!

OK, I'll move this functionality into the sdhci-brcmstb driver and re-submit the patch set.

Thanks
Al

#6 lore raw
In reply to Ulf Hansson

Hi Ulf,

Quoted 6 lines · Ulf Hansson
Quoted 2 lines · Al Cooper

Add quirk to disable SDR50 mode for controllers/boards that have problems with this mode.

No thanks! No more quirks please!

I'm fine with not having this quirk added (I don't need this one but use multiple of the other quirks in the driver) But, what if I also needed it in my driver? When do we determine when a quirk should be added to sdhci.c or not. What about existing quirks - should the current ones be moved to multiple existing drivers?

Quoted 18 lines

Kind regards
Uffe

Quoted 15 lines
---
  drivers/mmc/host/sdhci.c | 3 +++
  drivers/mmc/host/sdhci.h | 2 ++
  2 files changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +0 -0
index b48565e..71067c7 100644
@@ -3176,6 +3176,9 @@ int sdhci_add_host(struct sdhci_host *host)
         } else if (caps[1] & SDHCI_SUPPORT_SDR50)
                 mmc->caps |= MMC_CAP_UHS_SDR50;
 
Quoted 3 lines

drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3181

Quoted 3 lines
drivers/mmc/host/sdhci.c +3 -0
+       if (host->quirks2 & SDHCI_QUIRK2_BROKEN_SDR50)
+               mmc->caps &= ~MMC_CAP_UHS_SDR50;
+

Perhaps a lot of these quirks can be solved by having a generic mechanism to override any of the values in the caps registers rather than adding all these quirks?

Quoted 11 lines
Quoted 11 lines
drivers/mmc/host/sdhci.c +0 -0
         if (host->quirks2 & SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 &&
             (caps[1] & SDHCI_SUPPORT_HS400))
                 mmc->caps2 |= MMC_CAP2_HS400;
drivers/mmc/host/sdhci.h +0 -0
index 9d4aa31..0941c94 100644
@@ -412,6 +412,8 @@ struct sdhci_host {
  #define SDHCI_QUIRK2_ACMD23_BROKEN                     (1<<14)
  /* Broken Clock divider zero in controller */
  #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN             (1<<15)
Quoted 8 lines
Quoted 8 lines
drivers/mmc/host/sdhci.h +2 -1
+/* Controller does not support SDR50 */
+#define SDHCI_QUIRK2_BROKEN_SDR50                      (1<<16)
  /*
   * When internal clock is disabled, a delay is needed before modifying the
   * SD clock frequency or enabling back the internal clock.
--

1.9.0.138.g2de3478

Regards,
Scott

#7 lore raw
Quoted 33 lines · Scott Branden

Hi Ulf,

Quoted 6 lines · Ulf Hansson
Quoted 2 lines · Al Cooper

Add quirk to disable SDR50 mode for controllers/boards that have problems with this mode.

No thanks! No more quirks please!

I'm fine with not having this quirk added (I don't need this one but use multiple of the other quirks in the driver) But, what if I also needed it in my driver? When do we determine when a quirk should be added to sdhci.c or not. What about existing quirks - should the current ones be moved to multiple existing drivers?

Quoted 18 lines

Kind regards
Uffe

Quoted 15 lines
---
  drivers/mmc/host/sdhci.c | 3 +++
  drivers/mmc/host/sdhci.h | 2 ++
  2 files changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +0 -0
index b48565e..71067c7 100644
@@ -3176,6 +3176,9 @@ int sdhci_add_host(struct sdhci_host *host)
         } else if (caps[1] & SDHCI_SUPPORT_SDR50)
                 mmc->caps |= MMC_CAP_UHS_SDR50;
 
Quoted 6 lines
Quoted 3 lines

drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3181

Quoted 3 lines
drivers/mmc/host/sdhci.c +3 -0
+       if (host->quirks2 & SDHCI_QUIRK2_BROKEN_SDR50)
+               mmc->caps &= ~MMC_CAP_UHS_SDR50;
+

Perhaps a lot of these quirks can be solved by having a generic mechanism to override any of the values in the caps registers rather than adding all these quirks?

Are the capabilities register override specific to the Arasan controller or is there a generic and well define SDIO configuration register for these registers? The register information I am looking at seems to suggest this is part of how you glue your SDIO controller to your SoC.

The entire purpose of Al's changes were precisely so we do not have to fiddle with these capabilities register like we are currently doing in some versions of our downstream kernel.

Signature · 1 line
Florian
#8 lore raw
In reply to Scott Branden
Quoted 10 lines · Scott Branden

Hi Ulf,

Quoted 7 lines · Ulf Hansson
Quoted 3 lines · Al Cooper

Add quirk to disable SDR50 mode for controllers/boards that have problems with this mode.

Quoted 8 lines
Quoted 2 lines

No thanks! No more quirks please!

I'm fine with not having this quirk added (I don't need this one but use multiple of the other quirks in the driver) But, what if I also needed it in my driver? When do we determine when a quirk should be added to sdhci.c or not. What about existing quirks - should the current ones be moved to multiple existing drivers?

The sdhci driver should turn into a library providing generic helper functions. Each host can then pick which functions to use and also deal with its own "quirks", instead of managing those in generic code.

I guess we might end up getting a bit more code in total, but on the other hand the code would be better optimized and also maintainable.

Quoted 19 lines
Quoted 19 lines

Kind regards
Uffe

Quoted 15 lines
---
  drivers/mmc/host/sdhci.c | 3 +++
  drivers/mmc/host/sdhci.h | 2 ++
  2 files changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +0 -0
index b48565e..71067c7 100644
@@ -3176,6 +3176,9 @@ int sdhci_add_host(struct sdhci_host *host)
         } else if (caps[1] & SDHCI_SUPPORT_SDR50)
                 mmc->caps |= MMC_CAP_UHS_SDR50;
 
Quoted 7 lines
Quoted 3 lines

drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3181

Quoted 3 lines
drivers/mmc/host/sdhci.c +3 -0
+       if (host->quirks2 & SDHCI_QUIRK2_BROKEN_SDR50)
+               mmc->caps &= ~MMC_CAP_UHS_SDR50;
+

Perhaps a lot of these quirks can be solved by having a generic mechanism to override any of the values in the caps registers rather than adding all these quirks?

Sure, it makes sense if it can decreases the number of quirks!

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/mmc/host/sdhci.c +0 -0
         if (host->quirks2 & SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 &&
             (caps[1] & SDHCI_SUPPORT_HS400))
                 mmc->caps2 |= MMC_CAP2_HS400;
drivers/mmc/host/sdhci.h +2 -0
index 9d4aa31..0941c94 100644
@@ -412,6 +412,8 @@ struct sdhci_host {
  #define SDHCI_QUIRK2_ACMD23_BROKEN                     (1<<14)
  /* Broken Clock divider zero in controller */
  #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN             (1<<15)
+/* Controller does not support SDR50 */
+#define SDHCI_QUIRK2_BROKEN_SDR50                      (1<<16)
  /*
   * When internal clock is disabled, a delay is needed before modifying
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

the
* SD clock frequency or enabling back the internal clock.
--
1.9.0.138.g2de3478

Regards,
Scott

Kind regards
Uffe

#9 lore raw
Quoted 20 lines · Ulf Hansson
Quoted 10 lines · Scott Branden

Hi Ulf,

Quoted 7 lines · Ulf Hansson
Quoted 3 lines · Al Cooper

Add quirk to disable SDR50 mode for controllers/boards that have problems with this mode.

Quoted 8 lines
Quoted 2 lines

No thanks! No more quirks please!

I'm fine with not having this quirk added (I don't need this one but use multiple of the other quirks in the driver) But, what if I also needed it in my driver? When do we determine when a quirk should be added to sdhci.c or not. What about existing quirks - should the current ones be moved to multiple existing drivers?

Quoted 7 lines

The sdhci driver should turn into a library providing generic helper functions. Each host can then pick which functions to use and also deal with its own "quirks", instead of managing those in generic code.

I guess we might end up getting a bit more code in total, but on the other hand the code would be better optimized and also maintainable.

OK, if I need to add any new quirks I will look into this a bit more and see if it can be done. I don't have a need to do this right now so if anyone else wants to have a look feel free to.

Quoted 27 lines
Quoted 19 lines
Quoted 19 lines

Kind regards
Uffe

Quoted 15 lines
---
   drivers/mmc/host/sdhci.c | 3 +++
   drivers/mmc/host/sdhci.h | 2 ++
   2 files changed, 5 insertions(+)
drivers/mmc/host/sdhci.c +0 -0
index b48565e..71067c7 100644
@@ -3176,6 +3176,9 @@ int sdhci_add_host(struct sdhci_host *host)
          } else if (caps[1] & SDHCI_SUPPORT_SDR50)
                  mmc->caps |= MMC_CAP_UHS_SDR50;
 
Quoted 7 lines
Quoted 3 lines

drivers/mmc/host/sdhci.c int sdhci_add_host(struct sdhci_host *host) · line 3181

Quoted 3 lines
drivers/mmc/host/sdhci.c +3 -0
+       if (host->quirks2 & SDHCI_QUIRK2_BROKEN_SDR50)
+               mmc->caps &= ~MMC_CAP_UHS_SDR50;
+

Perhaps a lot of these quirks can be solved by having a generic mechanism to override any of the values in the caps registers rather than adding all these quirks?

Quoted 2 lines

Sure, it makes sense if it can decreases the number of quirks!

I think it can in some cases. In fact - the hardware designers do not even set the correct settings in the caps register on some of the SoCs.
The caps register does not appear to be used in the hardware other
than for "info" purposes to read by the driver - and when the info is wrong this may lead to many of the quirks that have been added by others over the years.

Quoted 25 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/mmc/host/sdhci.c +0 -0
          if (host->quirks2 & SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 &&
              (caps[1] & SDHCI_SUPPORT_HS400))
                  mmc->caps2 |= MMC_CAP2_HS400;
drivers/mmc/host/sdhci.h +2 -0
index 9d4aa31..0941c94 100644
@@ -412,6 +412,8 @@ struct sdhci_host {
   #define SDHCI_QUIRK2_ACMD23_BROKEN                     (1<<14)
   /* Broken Clock divider zero in controller */
   #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN             (1<<15)
+/* Controller does not support SDR50 */
+#define SDHCI_QUIRK2_BROKEN_SDR50                      (1<<16)
   /*
    * When internal clock is disabled, a delay is needed before modifying
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

the
* SD clock frequency or enabling back the internal clock.
--
1.9.0.138.g2de3478

Regards,
Scott

Quoted 3 lines

Kind regards
Uffe

Thanks,
Scott