mmc: sdhci-brcmstb: Driver updates
Subsystems (5)
Al Cooper
maintainercover mmc: sdhci-brcmstb: Driver updates
The latest BRCMSTB SoC's now use a new Arasan controller along with a custom Broadcom PHY that supports HS200, HS400, SDR104, HS400E-ES and CQE. This series of commits adds support for these new features along with a few bug fixes. The 7216 is the first SoC to have this new hardware.
Al Cooper (6):
dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 7216b0
mmc: sdhci-brcmstb: Add ability to use HS400ES transfer mode
mmc: sdhci-brcmstb: Fix driver to defer on clk_get defer
mmc: sdhci-brcmstb: Add shutdown callback
mmc: sdhci-brcmstb: Add support for Command Queuing (CQE)
mmc: sdhci-brcmstb: Fix incorrect switch to HS mode
.../bindings/mmc/brcm,sdhci-brcmstb.txt | 41 ++- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-brcmstb.c | 270 +++++++++++++++++- 3 files changed, 284 insertions(+), 28 deletions(-)
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 1/6 dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 7216b0
Add 7216b0 with supports CQE, HS400, HS400-ES and SDR104.
--- .../bindings/mmc/brcm,sdhci-brcmstb.txt | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.txt +28 -13
@@ -11,28 +11,43 @@ Required properties: - compatible: should be one of the following - "brcm,bcm7425-sdhci" - "brcm,bcm7445-sdhci" + - "brcm,bcm7216-sdhci" Refer to clocks/clock-bindings.txt for generic clock consumer properties. Example: - sdhci@f03e0100 { - compatible = "brcm,bcm7425-sdhci"; - reg = <0xf03e0000 0x100>; - interrupts = <0x0 0x26 0x0>; - sdhci,auto-cmd12; - clocks = <&sw_sdio>; + sdhci@84b0000 { sd-uhs-sdr50; sd-uhs-ddr50; + sd-uhs-sdr104; + sdhci,auto-cmd12; + compatible = "brcm,bcm7216-sdhci", + "brcm,bcm7445-sdhci", + "brcm,sdhci-brcmstb"; + reg = <0x84b0000 0x260 0x84b0300 0x200>; + reg-names = "host", "cfg"; + interrupts = <0x0 0x26 0x4>; + interrupt-names = "sdio0_0"; + clocks = <&scmi_clk 245>; + clock-names = "sw_sdio"; }; - sdhci@f03e0300 { + sdhci@84b1000 { + mmc-ddr-1_8v; + mmc-hs200-1_8v; + mmc-hs400-1_8v; + mmc-hs400-enhanced-strobe; + supports-cqe; non-removable; bus-width = <0x8>; - compatible = "brcm,bcm7425-sdhci"; - reg = <0xf03e0200 0x100>; - interrupts = <0x0 0x27 0x0>; - sdhci,auto-cmd12; - clocks = <sw_sdio>; - mmc-hs200-1_8v; + compatible = "brcm,bcm7216-sdhci", + "brcm,bcm7445-sdhci", + "brcm,sdhci-brcmstb"; + reg = <0x84b1000 0x260 0x84b1300 0x200>; + reg-names = "host", "cfg"; + interrupts = <0x0 0x27 0x4>; + interrupt-names = "sdio1_0"; + clocks = <&scmi_clk 245>; + clock-names = "sw_sdio"; };
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 2/6 mmc: sdhci-brcmstb: Add ability to use HS400ES transfer mode
In reply to Al CooperThe latest eMMC JEDEC specification version 5.1 added a new transfer mode, HS400 with enhanced strobe (HS400ES). This mode will be selected if both the host controller and eMMC device support it. The latest Arasan 5.1 controller in the 7216a0 supports this mode. The "Host Controller Specification" has not been updated so the controller register bit used to enable this mode is not specified and varies the with controller vendor. The Linux SDHCI driver supplies a callback for enabling HS400ES mode and that callback will be used to supply a routine that will set the proper bit in the Arasan Vendor register.
--- drivers/mmc/host/sdhci-brcmstb.c | 97 ++++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 11 deletions(-)
drivers/mmc/host/sdhci-brcmstb.c +86 -11
@@ -9,9 +9,41 @@#include <linux/mmc/host.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/bitops.h> #include "sdhci-pltfm.h" +#define SDHCI_VENDOR 0x78 +#define SDHCI_VENDOR_ENHANCED_STRB 0x1 + +#define BRCMSTB_PRIV_FLAGS_NO_64BIT BIT(0) +#define BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT BIT(1) + +struct sdhci_brcmstb_priv { +void __iomem *cfg_regs; +}; + +struct brcmstb_match_priv { +void (*hs400es)(struct mmc_host *mmc,struct mmc_ios *ios); +unsigned int flags; +}; + +static void sdhci_brcmstb_hs400es (struct mmc_host *mmc,struct mmc_ios *ios) +{ +struct sdhci_host *host =mmc_priv (mmc); + +u32 reg; + +dev_dbg (mmc_dev (mmc),"%s(): Setting HS400-Enhanced-Strobe mode\n" , + __func__); + reg =readl (host->ioaddr +SDHCI_VENDOR ); +if (ios->enhanced_strobe) + reg |=SDHCI_VENDOR_ENHANCED_STRB ; +else + reg &= ~SDHCI_VENDOR_ENHANCED_STRB ; +writel (reg, host->ioaddr +SDHCI_VENDOR ); +} +static const struct sdhci_ops sdhci_brcmstb_ops = { .set_clock = sdhci_set_clock, .set_bus_width = sdhci_set_bus_width,
@@ -23,13 +55,40 @@ static const struct sdhci_pltfm_data sdhci_brcmstb_pdata = { .ops = &sdhci_brcmstb_ops, }; +static const struct brcmstb_match_priv match_priv_7425 = { + .flags =BRCMSTB_PRIV_FLAGS_NO_64BIT | +BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT , +}; + +static const struct brcmstb_match_priv match_priv_7445 = { + .flags =BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT , +}; + +static const struct brcmstb_match_priv match_priv_7216 = { + .hs400es = sdhci_brcmstb_hs400es, +}; + +static const struct of_device_id sdhci_brcm_of_match[] = { + { .compatible ="brcm,bcm7425-sdhci" , .data = &match_priv_7425 }, + { .compatible ="brcm,bcm7445-sdhci" , .data = &match_priv_7445 }, + { .compatible ="brcm,bcm7216-sdhci" , .data = &match_priv_7216 }, + {}, +}; +static int sdhci_brcmstb_probe (struct platform_device *pdev) { -struct sdhci_host *host; +const struct brcmstb_match_priv *match_priv;struct sdhci_pltfm_host *pltfm_host; +const struct of_device_id *match; +struct sdhci_brcmstb_priv *priv; +struct sdhci_host *host; +struct resource *iomem;struct clk *clk;int res; + match =of_match_node (sdhci_brcm_of_match, pdev->dev.of_node); + match_priv = match->data; + clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (clk)) {dev_err (&pdev->dev,"Clock not found in Device Tree\n" );
@@ -39,36 +98,57 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)if (res)return res; - host =sdhci_pltfm_init (pdev, &sdhci_brcmstb_pdata,0 ); + host =sdhci_pltfm_init (pdev, &sdhci_brcmstb_pdata, +sizeof (struct sdhci_brcmstb_priv ));if (IS_ERR (host)) { res =PTR_ERR (host); goto err_clk; } + pltfm_host =sdhci_priv (host); + priv =sdhci_pltfm_priv (pltfm_host); + +/* Map in the non-standard CFG registers */ + iomem =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); + priv->cfg_regs =devm_ioremap_resource (&pdev->dev, iomem); +if (IS_ERR (priv->cfg_regs)) { + res =PTR_ERR (priv->cfg_regs); + goto err; + } +sdhci_get_of_property (pdev); res =mmc_of_parse (host->mmc);if (res) goto err; +/* +* If the chip has enhanced strobe and it's enabled, add +* callback +*/ +if (match_priv->hs400es && + (host->mmc->caps2 &MMC_CAP2_HS400_ES )) + host->mmc_host_ops.hs400_enhanced_strobe = match_priv->hs400es; +/* * Supply the existing CAPS, but clear the UHS modes. This * will allow these modes to be specified by device tree * properties through mmc_of_parse(). */ host->caps =sdhci_readl (host,SDHCI_CAPABILITIES ); -if (of_device_is_compatible (pdev->dev.of_node,"brcm,bcm7425-sdhci" )) +if (match_priv->flags &BRCMSTB_PRIV_FLAGS_NO_64BIT ) host->caps &= ~SDHCI_CAN_64BIT ; host->caps1 =sdhci_readl (host,SDHCI_CAPABILITIES_1 ); host->caps1 &= ~(SDHCI_SUPPORT_SDR50 |SDHCI_SUPPORT_SDR104 |SDHCI_SUPPORT_DDR50 ); - host->quirks |=SDHCI_QUIRK_MISSING_CAPS | -SDHCI_QUIRK_BROKEN_TIMEOUT_VAL ; + host->quirks |=SDHCI_QUIRK_MISSING_CAPS ; + +if (match_priv->flags &BRCMSTB_PRIV_FLAGS_BROKEN_TIMEOUT ) + host->quirks |=SDHCI_QUIRK_BROKEN_TIMEOUT_VAL ; res =sdhci_add_host (host);if (res) goto err; - pltfm_host =sdhci_priv (host); pltfm_host->clk = clk;return res;
@@ -79,11 +159,6 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)return res; } -static const struct of_device_id sdhci_brcm_of_match[] = { - { .compatible ="brcm,bcm7425-sdhci" }, - { .compatible ="brcm,bcm7445-sdhci" }, - {}, -};MODULE_DEVICE_TABLE (of, sdhci_brcm_of_match);static struct platform_driver sdhci_brcmstb_driver = {
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 3/6 mmc: sdhci-brcmstb: Fix driver to defer on clk_get defer
In reply to Al CooperThe new SCMI clock protocol driver does not get probed that early in boot. Brcmstb drivers typically have the following code when getting a clock:
priv->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "Clock not found in Device Tree\n");
priv->clk = NULL;
}This commit changes the driver to do what is below.
priv->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(priv->clk)) {
if (PTR_ERR(priv->clk) == -EPROBE_DEFER)
return -EPROBE_DEFER;
dev_err(&pdev->dev, "Clock not found in Device Tree\n");
priv->clk = NULL;
}--- drivers/mmc/host/sdhci-brcmstb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mmc/host/sdhci-brcmstb.c +2 -0
@@ -91,6 +91,8 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (clk)) { +if (PTR_ERR (clk) == -EPROBE_DEFER ) +return -EPROBE_DEFER ;dev_err (&pdev->dev,"Clock not found in Device Tree\n" ); clk =NULL ; }
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 4/6 mmc: sdhci-brcmstb: Add shutdown callback
In reply to Al CooperShutdown controller and disable it's clocks to insure max power savings in S5 on systems that leave power on.
--- drivers/mmc/host/sdhci-brcmstb.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/mmc/host/sdhci-brcmstb.c +10 -0
@@ -161,6 +161,15 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)return res; } +static void sdhci_brcmstb_shutdown (struct platform_device *pdev) +{ +int ret; + + ret =sdhci_pltfm_unregister (pdev); +if (ret) +dev_err (&pdev->dev,"failed to shutdown\n" ); +} +MODULE_DEVICE_TABLE (of, sdhci_brcm_of_match);static struct platform_driver sdhci_brcmstb_driver = {
@@ -171,6 +180,7 @@ static struct platform_driver sdhci_brcmstb_driver = { }, .probe = sdhci_brcmstb_probe, .remove = sdhci_pltfm_unregister, + .shutdown = sdhci_brcmstb_shutdown, };module_platform_driver (sdhci_brcmstb_driver);
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 5/6 mmc: sdhci-brcmstb: Add support for Command Queuing (CQE)
In reply to Al CooperThe latest Arasan controller first used in the 7216 now supports CQE so enable this feature.
--- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-brcmstb.c | 140 +++++++++++++++++++++++++++++-- 2 files changed, 133 insertions(+), 8 deletions(-)
drivers/mmc/host/Kconfig +1 -0
@@ -990,6 +990,7 @@ config MMC_SDHCI_BRCMSTB tristate "Broadcom SDIO/SD/MMC support" depends on ARCH_BRCMSTB || BMIPS_GENERIC depends on MMC_SDHCI_PLTFM + select MMC_CQHCI default y help This selects support for the SDIO/SD/MMC Host Controller on
drivers/mmc/host/sdhci-brcmstb.c +132 -8
226 lines not on this page · raw message
Signature · 1 line
2.17.1
Al Cooper
maintainerPATCH 6/6 mmc: sdhci-brcmstb: Fix incorrect switch to HS mode
In reply to Al CooperWhen switching from any MMC speed mode that requires 1.8v (HS200, HS400 and HS400ES) to High Speed (HS) mode, the system ends up configured for SDR12 with a 50MHz clock which is an illegal mode.
This happens because the SDHCI_CTRL_VDD_180 bit in the SDHCI_HOST_CONTROL2 register is left set and when this bit is set, the speed mode is controlled by the SDHCI_CTRL_UHS field in the SDHCI_HOST_CONTROL2 register. The SDHCI_CTRL_UHS field will end up being set to 0 (SDR12) by sdhci_set_uhs_signaling() because there is no UHS mode being set.
The fix is to change sdhci_set_uhs_signaling() to set the SDHCI_CTRL_UHS field to SDR25 (which is the same as HS) for any switch to HS mode.
This was found on a new eMMC controller that does strict checking of the speed mode and the corresponding clock rate. It caused the switch to HS400 mode to fail because part of the sequence to switch to HS400 requires a switch from HS200 to HS before going to HS400.
This issue was previously fixed by commit c894e33ddc191 ("mmc: sdhci:
Fix incorrect switch to HS mode") and later removed by commit 07bcc411567c ("Revert \"mmc: sdhci: Fix incorrect switch to HS mode\"") because it caused failures with some SD cards on AM65X systems. The fix will now be done in a platform specific callback instead of common sdhci code.
--- drivers/mmc/host/sdhci-brcmstb.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-brcmstb.c +30 -1
@@ -65,6 +65,35 @@ static void sdhci_brcmstb_set_clock(struct sdhci_host *host, unsigned int clock)sdhci_enable_clk (host, clk); } +static void sdhci_brcmstb_set_uhs_signaling (struct sdhci_host *host, +unsigned int timing) +{ +u16 ctrl_2; + +dev_dbg (mmc_dev (host->mmc),"%s: Setting UHS signaling for %d timing\n" , + __func__, timing); + ctrl_2 =sdhci_readw (host,SDHCI_HOST_CONTROL2 ); +/* Select Bus Speed Mode for host */ + ctrl_2 &= ~SDHCI_CTRL_UHS_MASK ; +if ((timing ==MMC_TIMING_MMC_HS200 ) || + (timing ==MMC_TIMING_UHS_SDR104 )) + ctrl_2 |=SDHCI_CTRL_UHS_SDR104 ; +else if (timing ==MMC_TIMING_UHS_SDR12 ) + ctrl_2 |=SDHCI_CTRL_UHS_SDR12 ; +else if (timing ==MMC_TIMING_SD_HS || + timing ==MMC_TIMING_MMC_HS || + timing ==MMC_TIMING_UHS_SDR25 ) + ctrl_2 |=SDHCI_CTRL_UHS_SDR25 ; +else if (timing ==MMC_TIMING_UHS_SDR50 ) + ctrl_2 |=SDHCI_CTRL_UHS_SDR50 ; +else if ((timing ==MMC_TIMING_UHS_DDR50 ) || + (timing ==MMC_TIMING_MMC_DDR52 )) + ctrl_2 |=SDHCI_CTRL_UHS_DDR50 ; +else if (timing ==MMC_TIMING_MMC_HS400 ) + ctrl_2 |=SDHCI_CTRL_HS400 ;/* Non-standard */ +sdhci_writew (host, ctrl_2,SDHCI_HOST_CONTROL2 ); +} +static void sdhci_brcmstb_dumpregs (struct mmc_host *mmc) {sdhci_dumpregs (mmc_priv (mmc));
@@ -101,7 +130,7 @@ static struct sdhci_ops sdhci_brcmstb_ops_7216 = { .set_clock = sdhci_brcmstb_set_clock, .set_bus_width = sdhci_set_bus_width, .reset = sdhci_reset, - .set_uhs_signaling = sdhci_set_uhs_signaling, + .set_uhs_signaling = sdhci_brcmstb_set_uhs_signaling, };static struct brcmstb_match_priv match_priv_7425 = {
Signature · 1 line
2.17.1
Quoted 6 lines · Al Cooper
The latest BRCMSTB SoC's now use a new Arasan controller along with a custom Broadcom PHY that supports HS200, HS400, SDR104, HS400E-ES and CQE. This series of commits adds support for these new features along with a few bug fixes. The 7216 is the first SoC to have this new hardware.
Quoted 7 lines
Al Cooper (6):
dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 7216b0
mmc: sdhci-brcmstb: Add ability to use HS400ES transfer mode
mmc: sdhci-brcmstb: Fix driver to defer onclk_getdefer
mmc: sdhci-brcmstb: Add shutdown callback
mmc: sdhci-brcmstb: Add support for Command Queuing (CQE)
mmc: sdhci-brcmstb: Fix incorrect switch to HS mode
For patches 2-5
Quoted 6 lines
.../bindings/mmc/brcm,sdhci-brcmstb.txt | 41 ++- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-brcmstb.c | 270 +++++++++++++++++- 3 files changed, 284 insertions(+), 28 deletions(-)
Quoted 15 lines · Al Cooper
The latest BRCMSTB SoC's now use a new Arasan controller along with a custom Broadcom PHY that supports HS200, HS400, SDR104, HS400E-ES and CQE. This series of commits adds support for these new features along with a few bug fixes. The 7216 is the first SoC to have this new hardware.
Al Cooper (6):
dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 7216b0
mmc: sdhci-brcmstb: Add ability to use HS400ES transfer mode
mmc: sdhci-brcmstb: Fix driver to defer onclk_getdefer
mmc: sdhci-brcmstb: Add shutdown callback
mmc: sdhci-brcmstb: Add support for Command Queuing (CQE)
mmc: sdhci-brcmstb: Fix incorrect switch to HS mode
Quoted 8 lines
.../bindings/mmc/brcm,sdhci-brcmstb.txt | 41 ++- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-brcmstb.c | 270 +++++++++++++++++- 3 files changed, 284 insertions(+), 28 deletions(-)--
2.17.1
Applied for next, thanks!
Kind regards
Uffe