mmc: sdhci/imx: a few clean up and fixes
Subsystems (5)
v2 cover mmc: sdhci/imx: a few clean up and fixes
Change since v1:
Add patch 6 which resolves a checkpatch warning like below in v1:
0005-mmc-sdhci-do-not-enable-card-cd-wakeup-for-gpio-case.patch has no obvious style problems and is ready for submission.
WARNING: DT compatible string "fsl,imx6sx-usdhc" appears un-documented -- check ./Documentation/devicetree/bindings/
+ { .compatible = "fsl,imx6sx-usdhc", .data = &usdhc_imx6sx_data, },
total: 0 errors, 1 warnings, 18 lines checked
Dong Aisheng (8):
mmc: sdhci-esdhc-imx: remove duplicated lines
mmc: sdhci-esdhc-imx: usdhc does not have missing card interrupt
issue
mmc: sdhci-esdhc-imx: add ADMA Length Mismatch errata fix
mmc: sdhci: do not enable card detect interrupt for gpio cd type
mmc: sdhci: do not enable card cd wakeup for gpio case
mmc: sdhci-esdhc-imx: using specific compatible string in binding doc
mmc: sdhci-esdhc-imx: add imx6sx support
mmc: sdhci-esdhc-imx: add quirk SDHCI_QUIRK2_BROKEN_HS200 for imx6qdl
.../devicetree/bindings/mmc/fsl-imx-esdhc.txt | 9 ++++- drivers/mmc/host/sdhci-esdhc-imx.c | 44 ++++++++++++++++---- drivers/mmc/host/sdhci.c | 8 +++- 3 files changed, 49 insertions(+), 12 deletions(-)
Signature · 1 line
1.7.8
PATCH v2 1/8 mmc: sdhci-esdhc-imx: remove duplicated lines
There is already the same register check above, no need the later one. Move them into one place and delete the later one.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +5 -7
@@ -315,6 +315,11 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg) data |=ESDHC_CTRL_D3CD ;writel (data, host->ioaddr +SDHCI_HOST_CONTROL ); } + +if (val &SDHCI_INT_ADMA_ERROR ) { + val &= ~SDHCI_INT_ADMA_ERROR ; + val |=ESDHC_INT_VENDOR_SPEC_DMA_ERR ; + } } if (unlikely((imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
@@ -335,13 +340,6 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg) } } -if (unlikely (reg ==SDHCI_INT_ENABLE || reg ==SDHCI_SIGNAL_ENABLE )) { -if (val &SDHCI_INT_ADMA_ERROR ) { - val &= ~SDHCI_INT_ADMA_ERROR ; - val |=ESDHC_INT_VENDOR_SPEC_DMA_ERR ; - } - } -writel (val, host->ioaddr + reg); }
Signature · 1 line
1.7.8
PATCH v2 2/8 mmc: sdhci-esdhc-imx: usdhc does not have missing card interrupt issue
In reply to Dong AishengThe usdhc does not have missing card interrupt issue, so execute the workaround conditionally.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
@@ -300,7 +300,7 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)u32 data;if (unlikely (reg ==SDHCI_INT_ENABLE || reg ==SDHCI_SIGNAL_ENABLE )) { -if (val &SDHCI_INT_CARD_INT ) { +if ((val &SDHCI_INT_CARD_INT ) && !esdhc_is_usdhc (imx_data)) {/* * Clear and then set D3CD bit to avoid missing the * card interrupt. This is a eSDHC controller problem
Signature · 1 line
1.7.8
PATCH v2 3/8 mmc: sdhci-esdhc-imx: add ADMA Length Mismatch errata fix
In reply to Dong AishengThe uSDHC has an ADMA Length Mismatch errata ERR004536 which may cause ADMA work abnormally. The errata has already been fixed for i.MX6Q TO1.2 and i.MX6DL TO1.1 by enable the bit 7 in 0x6c register. Unfortunately this fix is not included in i.MX6SL.
So we disable ADMA for i.MX6SL and use SDMA instead.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +17 -1
@@ -114,6 +114,12 @@#define ESDHC_FLAG_STD_TUNING BIT(5)/* The IP has SDHCI_CAPABILITIES_1 register */ #define ESDHC_FLAG_HAVE_CAP1 BIT(6) +/* +* The IP has errata ERR004536 +* uSDHC: ADMA Length Mismatch Error occurs if the AHB read access is slow, +* when reading data from the card +*/ +#define ESDHC_FLAG_ERR004536 BIT(7)struct esdhc_soc_data {u32 flags;
@@ -141,7 +147,7 @@ static struct esdhc_soc_data usdhc_imx6q_data = {static struct esdhc_soc_data usdhc_imx6sl_data = { .flags =ESDHC_FLAG_USDHC |ESDHC_FLAG_STD_TUNING - |ESDHC_FLAG_HAVE_CAP1 , + |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_ERR004536 , };struct pltfm_imx_data {
@@ -1050,6 +1056,13 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)writel (0x08100810 , host->ioaddr +ESDHC_WTMK_LVL ); host->quirks2 |=SDHCI_QUIRK2_PRESET_VALUE_BROKEN ; host->mmc->caps |=MMC_CAP_1_8V_DDR ; + +/* +* errata ESDHC_FLAG_ERR004536 fix for MX6Q TO1.2 and MX6DL +* TO1.1, it's harmless for MX6SL +*/ +writel (readl (host->ioaddr +0x6c ) |BIT (7 ), + host->ioaddr +0x6c ); }if (imx_data->socdata->flags &ESDHC_FLAG_MAN_TUNING )
@@ -1061,6 +1074,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)ESDHC_STD_TUNING_EN |ESDHC_TUNING_START_TAP , host->ioaddr + ESDHC_TUNING_CTRL); +if (imx_data->socdata->flags &ESDHC_FLAG_ERR004536 ) + host->quirks |=SDHCI_QUIRK_BROKEN_ADMA ; + boarddata = &imx_data->boarddata;if (sdhci_esdhc_imx_probe_dt (pdev, boarddata) <0 ) {if (!host->mmc->parent->platform_data) {
Signature · 1 line
1.7.8
PATCH v2 4/8 mmc: sdhci: do not enable card detect interrupt for gpio cd type
In reply to Dong AishengExcept SDHCI_QUIRK_BROKEN_CARD_DETECTION and MMC_CAP_NONREMOVABLE, we also do not need to handle controller native card detect interrupt for gpio as card detect case.
If we wrong enabled the card detect interrupt for gpio case,
it will cause a lot of unexpected card detect interrupts during data transfer which should not happen.
--- drivers/mmc/host/sdhci.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci.c +2 -1
@@ -136,9 +136,10 @@ static void sdhci_dumpregs(struct sdhci_host *host)static void sdhci_set_card_detection (struct sdhci_host *host,bool enable) {u32 present; +int gpio_cd =mmc_gpio_get_cd (host->mmc);if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || - (host->mmc->caps &MMC_CAP_NONREMOVABLE )) + (host->mmc->caps &MMC_CAP_NONREMOVABLE ) || !IS_ERR_VALUE (gpio_cd))return ;if (enable) {
Signature · 1 line
1.7.8
PATCH v2 4/8 mmc: sdhci: do not enable card detect interrupt for gpio cd type
Quoted 17 lines · Dong Aisheng
Except
SDHCI_QUIRK_BROKEN_CARD_DETECTIONandMMC_CAP_NONREMOVABLE, we also do not need to handle controller native card detect interrupt for gpio as card detect case.
If we wrong enabled the card detect interrupt for gpio case,
it will cause a lot of unexpected card detect interrupts during data transfer which should not happen.Signed-off-by Dong Aisheng <[email protected]>--- drivers/mmc/host/sdhci.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)drivers/mmc/host/sdhci.c +0
-0
drivers/mmc/host/sdhci.c static void sdhci_dumpregs(struct sdhci_host *host) · line 142
Quoted 8 lines
drivers/mmc/host/sdhci.c +2
-1@@ -136,9 +136,10 @@ static void sdhci_dumpregs(struct sdhci_host *host)static void sdhci_set_card_detection (struct sdhci_host *host,bool enable) {u32 present; +int gpio_cd =mmc_gpio_get_cd (host->mmc);if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || - (host->mmc->caps &MMC_CAP_NONREMOVABLE )) + (host->mmc->caps &MMC_CAP_NONREMOVABLE ) || !IS_ERR_VALUE (gpio_cd))
If you have a properly working gpio_cd, then why does you also have SDHCI_QUIRK_BROKEN_CARD_DETECTION set? Isn't that the actual problem?
Kind regards
Uffe
Quoted 6 lines
drivers/mmc/host/sdhci.c +0
-1return ;if (enable) { --1.7.8
PATCH v2 4/8 mmc: sdhci: do not enable card detect interrupt for gpio cd type
Quoted 23 lines · Ulf Hansson
Quoted 22 lines · Dong Aisheng
Except
SDHCI_QUIRK_BROKEN_CARD_DETECTIONandMMC_CAP_NONREMOVABLE, we also do not need to handle controller native card detect interrupt for gpio as card detect case.
If we wrong enabled the card detect interrupt for gpio case,
it will cause a lot of unexpected card detect interrupts during data transfer which should not happen.Signed-off-by Dong Aisheng <[email protected]>--- drivers/mmc/host/sdhci.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)drivers/mmc/host/sdhci.c +1
-0@@ -136,9 +136,10 @@ static void sdhci_dumpregs(struct sdhci_host *host)static void sdhci_set_card_detection (struct sdhci_host *host,bool enable) {u32 present; +int gpio_cd =mmc_gpio_get_cd (host->mmc);
Quoted 7 lines
drivers/mmc/host/sdhci.c static void sdhci_dumpregs(struct sdhci_host *host) · line 142
Quoted 3 lines
drivers/mmc/host/sdhci.c +1
-1if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || - (host->mmc->caps &MMC_CAP_NONREMOVABLE )) + (host->mmc->caps &MMC_CAP_NONREMOVABLE ) || !IS_ERR_VALUE (gpio_cd))If you have a properly working
gpio_cd, then why does you also haveSDHCI_QUIRK_BROKEN_CARD_DETECTIONset? Isn't that the actual problem?
SDHCI_QUIRK_BROKEN_CARD_DETECTION seems only for controller CD function. Thus even we're using gpio_cd, we still have this quirk set for controller to avoid enable controller cd interrupts.
Does it make sense?
Regards
Dong Aisheng
Quoted 9 lines
Kind regards
UffeQuoted 6 lines
drivers/mmc/host/sdhci.c +0
-1return ;if (enable) { --1.7.8
PATCH v2 4/8 mmc: sdhci: do not enable card detect interrupt for gpio cd type
Quoted 8 lines · Dong Aisheng
Quoted 7 lines · Ulf Hansson
Quoted 6 lines · Dong Aisheng
Except
SDHCI_QUIRK_BROKEN_CARD_DETECTIONandMMC_CAP_NONREMOVABLE, we also do not need to handle controller native card detect interrupt for gpio as card detect case.
If we wrong enabled the card detect interrupt for gpio case,
it will cause a lot of unexpected card detect interrupts during data transfer which should not happen.
I see. But shouldn't you then check for MMC_CAP_NEEDS_POLL instead of reading the current state of the gpio_cd pin?
Kind regards
Uffe
Quoted 41 lines
Quoted 16 lines
Quoted 16 lines
Signed-off-by Dong Aisheng <[email protected]>--- drivers/mmc/host/sdhci.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)drivers/mmc/host/sdhci.c +1
-0@@ -136,9 +136,10 @@ static void sdhci_dumpregs(struct sdhci_host *host)static void sdhci_set_card_detection (struct sdhci_host *host,bool enable) {u32 present; +int gpio_cd =mmc_gpio_get_cd (host->mmc);Quoted 7 lines
drivers/mmc/host/sdhci.c static void sdhci_dumpregs(struct sdhci_host *host) · line 142
Quoted 3 lines
drivers/mmc/host/sdhci.c +1
-1if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || - (host->mmc->caps &MMC_CAP_NONREMOVABLE )) + (host->mmc->caps &MMC_CAP_NONREMOVABLE ) || !IS_ERR_VALUE (gpio_cd))If you have a properly working
gpio_cd, then why does you also haveSDHCI_QUIRK_BROKEN_CARD_DETECTIONset? Isn't that the actual problem?
SDHCI_QUIRK_BROKEN_CARD_DETECTIONseems only for controller CD function. Thus even we're usinggpio_cd, we still have this quirk set for controller to avoid enable controller cd interrupts.
Does it make sense?Regards
Dong AishengQuoted 9 lines
Kind regards
UffeQuoted 6 lines
drivers/mmc/host/sdhci.c +0
-1return ;if (enable) { --1.7.8
PATCH v2 5/8 mmc: sdhci: do not enable card cd wakeup for gpio case
In reply to Dong AishengDo not need to enable the controller card cd interrupt wakeup if using GPIO as card detect since it's meaningless.
--- drivers/mmc/host/sdhci.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci.c +4 -1
@@ -2561,13 +2561,16 @@ static irqreturn_t sdhci_thread_irq(int irq, void *dev_id)void sdhci_enable_irq_wakeups (struct sdhci_host *host) {u8 val; +int gpio_cd =mmc_gpio_get_cd (host->mmc); +u8 mask =SDHCI_WAKE_ON_INSERT |SDHCI_WAKE_ON_REMOVE |SDHCI_WAKE_ON_INT ; val =sdhci_readb (host,SDHCI_WAKE_UP_CONTROL ); val |= mask ;/* Avoid fake wake up */ -if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) +if (host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION || + !IS_ERR_VALUE (gpio_cd)) val &= ~(SDHCI_WAKE_ON_INSERT |SDHCI_WAKE_ON_REMOVE );sdhci_writeb (host, val,SDHCI_WAKE_UP_CONTROL ); }
Signature · 1 line
1.7.8
PATCH v2 6/8 mmc: sdhci-esdhc-imx: using specific compatible string in binding doc
In reply to Dong AishengUsing specific compatible string in binding doc to make the binding
more clear.
It's also used to avoid checkpatch warning in the future like follows:
0005-mmc-sdhci-do-not-enable-card-cd-wakeup-for-gpio-case.patch has no obvious style problems and is ready for submission.
WARNING: DT compatible string "fsl,imx6sx-usdhc" appears un-documented -- check ./Documentation/devicetree/bindings/
+ { .compatible = "fsl,imx6sx-usdhc", .data = &usdhc_imx6sx_data, },
total: 0 errors, 1 warnings, 18 lines checked
--- .../devicetree/bindings/mmc/fsl-imx-esdhc.txt | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt +8 -1
@@ -7,7 +7,14 @@ This file documents differences between the core properties described by mmc.txt and the properties used by the sdhci-esdhc-imx driver. Required properties: -- compatible : Should be "fsl,<chip>-esdhc" +- compatible : Should be "fsl,<chip>-esdhc", the supported chips include + "fsl,imx25-esdhc" + "fsl,imx35-esdhc" + "fsl,imx51-esdhc" + "fsl,imx53-esdhc" + "fsl,imx6q-usdhc" + "fsl,imx6sl-usdhc" + "fsl,imx6sx-usdhc" Optional properties: - fsl,cd-controller : Indicate to use controller internal card detection
Signature · 1 line
1.7.8
PATCH v2 7/8 mmc: sdhci-esdhc-imx: add imx6sx support
In reply to Dong AishengThe imx6sx usdhc is derived from imx6sl, the difference is minor. imx6sx have the errata ESDHC_FLAG_ERR004536 fixed.
So introduce a new compatible string for imx6sx to distinguish them.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +6 -0
@@ -150,6 +150,11 @@ static struct esdhc_soc_data usdhc_imx6sl_data = { | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_ERR004536, }; +static struct esdhc_soc_data usdhc_imx6sx_data = { + .flags =ESDHC_FLAG_USDHC |ESDHC_FLAG_STD_TUNING + |ESDHC_FLAG_HAVE_CAP1 , +}; +struct pltfm_imx_data {u32 scratchpad;struct pinctrl *pinctrl;
@@ -190,6 +195,7 @@ static const struct of_device_id imx_esdhc_dt_ids[] = { { .compatible = "fsl,imx35-esdhc", .data = &esdhc_imx35_data, }, { .compatible = "fsl,imx51-esdhc", .data = &esdhc_imx51_data, }, { .compatible = "fsl,imx53-esdhc", .data = &esdhc_imx53_data, }, + { .compatible = "fsl,imx6sx-usdhc", .data = &usdhc_imx6sx_data, }, { .compatible = "fsl,imx6sl-usdhc", .data = &usdhc_imx6sl_data, }, { .compatible = "fsl,imx6q-usdhc", .data = &usdhc_imx6q_data, }, { /* sentinel */ }
Signature · 1 line
1.7.8
PATCH v2 8/8 mmc: sdhci-esdhc-imx: add quirk SDHCI_QUIRK2_BROKEN_HS200 for imx6qdl
In reply to Dong AishengThe iMX6Q/DL can not support HS200 mode while iMX6SL and iMX6SX can, so introduce a new flag to distinguish them.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +8 -2
@@ -120,6 +120,8 @@* when reading data from the card */ #define ESDHC_FLAG_ERR004536 BIT(7) +/* The IP supports HS200 mode */ +#define ESDHC_FLAG_HS200 BIT(8)struct esdhc_soc_data {u32 flags;
@@ -147,12 +149,13 @@ static struct esdhc_soc_data usdhc_imx6q_data = {static struct esdhc_soc_data usdhc_imx6sl_data = { .flags =ESDHC_FLAG_USDHC |ESDHC_FLAG_STD_TUNING - |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_ERR004536 , + |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_ERR004536 + |ESDHC_FLAG_HS200 , };static struct esdhc_soc_data usdhc_imx6sx_data = { .flags =ESDHC_FLAG_USDHC |ESDHC_FLAG_STD_TUNING - |ESDHC_FLAG_HAVE_CAP1 , + |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_HS200 , };struct pltfm_imx_data {
@@ -1063,6 +1066,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) host->quirks2 |=SDHCI_QUIRK2_PRESET_VALUE_BROKEN ; host->mmc->caps |=MMC_CAP_1_8V_DDR ; +if (!(imx_data->socdata->flags &ESDHC_FLAG_HS200 )) + host->quirks2 |=SDHCI_QUIRK2_BROKEN_HS200 ; +/* * errata ESDHC_FLAG_ERR004536 fix for MX6Q TO1.2 and MX6DL * TO1.1, it's harmless for MX6SL
Signature · 1 line
1.7.8