few fix for sdhci-esdhc-imx
Subsystems (4)
[email protected]
maintainerv4 cover few fix for sdhci-esdhc-imx
From: Haibo Chen <[email protected]>
---
Changes for v4:
Add Adrian's ack for patch 9~12
for patch 13, change to add the check for pinctrl error
for patch 14, change to judge the dev->dma_parms first, if it not exist, then alloc it.
Changes for v3:
Add Linus Walleij's ack for patch 2
for patch 9, drop the use of 'sdhci,auto-cmd23-broken' from dts, change to add flag ESDHC_FLAG_BROKEN_AUTO_CMD23 in the related esdhc_soc_data. for patch 10, add a new esdhc_soc_data for i.MX8MM
Changes for v2:
Add Adrian's ack for patch 1~8
Patch 9~10, change to use 'sdhci,auto-cmd23-broken' instead of 'fsl,auto-cmd23-broken' Patch 11, clear cqhci irq status and halt cqhci, move this change to sdhci_esdhc_imx_hwinit() and add some comment to explain the reason.
Patch 12, add error return check for pinctrl_pm_select_sleep_state()
Patch 13, clear the DMA_SEL in sdhci-esdhc-imx.c instead of sdhci.c
Patch 14, add the dev->dma_parms in core/queue.c, instead of host/sdhci.c.
Haibo Chen (14):
mmc: sdhci: do not enable card detect interrupt for gpio cd type
mmc: sdhci-esdhc-imx: no fail when no pinctrl available
mmc: sdhci-esdhci-imx: retune needed for Mega/Mix enabled SoCs
mmc: sdhci-esdhc-imx: restore the per_clk rate in PM_RUNTIME
doc: dt: fsl-imx-esdhc: add strobe-dll-delay-target binding
mmc: sdhci-esdhc-imx: add strobe-dll-delay-target support
mmc: sdhci-esdhc-imx: optimize the clock setting
mmc: sdhci-esdhc-imx: optimize the strobe dll setting
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_BROKEN_AUTO_CMD23
mmc: sdhci-esdhc-imx: Add an new esdhc_soc_data for i.MX8MM
mmc: sdhci-esdhc-imx: clear pending interrupt and halt cqhci
mmc: sdhci-esdhc-imx: clear DMA_SEL when disable DMA mode
mmc: sdhci-esdhc-imx: restore pin state when resume back
mmc: queue: create dev->dma_parms before call dma_set_max_seg_size()
.../devicetree/bindings/mmc/fsl-imx-esdhc.txt | 5 + drivers/mmc/core/queue.c | 11 +- drivers/mmc/host/sdhci-esdhc-imx.c | 167 +++++++++++++++--- drivers/mmc/host/sdhci-esdhc.h | 1 + drivers/mmc/host/sdhci.c | 2 +- include/linux/platform_data/mmc-esdhc-imx.h | 1 + 6 files changed, 161 insertions(+), 26 deletions(-)
Signature · 1 line
2.17.1
[email protected]
maintainerPATCH v4 1/14 mmc: sdhci: do not enable card detect interrupt for gpio cd type
From: Haibo Chen <[email protected]>
Except SDHCI_QUIRK_BROKEN_CARD_DETECTION and MMC_CAP_NONREMOVABLE, we also do not need to handle controller native card detect interrupt for gpio cd type.
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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +1 -1
@@ -153,7 +153,7 @@ static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)u32 present;if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || - !mmc_card_is_removable (host->mmc)) + !mmc_card_is_removable (host->mmc) ||mmc_can_gpio_cd (host->mmc))return ;if (enable) {
Signature · 1 line
2.17.1
[email protected]
maintainerPATCH v4 2/14 mmc: sdhci-esdhc-imx: no fail when no pinctrl available
In reply to [email protected]From: Haibo Chen <[email protected]>
When using jailhouse to support two Linux on i.MX8MQ EVK, we use the 1st Linux to configure pinctrl for the 2nd Linux. Then the 2nd Linux could use the mmc without pinctrl driver.
So give a warning message when no pinctrl available, but no fail probe.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
@@ -1488,7 +1488,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) imx_data->pinctrl =devm_pinctrl_get (&pdev->dev);if (IS_ERR (imx_data->pinctrl)) { err =PTR_ERR (imx_data->pinctrl); - goto disable_ahb_clk; +dev_warn (mmc_dev (host->mmc),"could not get pinctrl\n" ); }if (esdhc_is_usdhc (imx_data)) {
Signature · 1 line
2.17.1
[email protected]
maintainerPATCH v4 3/14 mmc: sdhci-esdhci-imx: retune needed for Mega/Mix enabled SoCs
In reply to [email protected]From: Haibo Chen <[email protected]>
For Mega/Mix enabled SoCs like MX7D and MX6SX, uSDHC will lost power in LP mode no matter whether the MMC_KEEP_POWER flag is set or not. This may cause state misalign between kernel and HW, especially for SDIO3.0 WiFi cards.
e.g. SDIO WiFi driver usually will keep power during system suspend. And after resume, no card re-enumeration called.
But the tuning state is lost due to Mega/Mix.
Then CRC error may happen during next data transfer.
So we should always fire a mmc_retune_needed() for such type SoC to tell MMC core retuning is needed for next data transfer.
mmc: sdhci-esdhci-imx: retune needed for Mega/Mix enabled SoCs
--- drivers/mmc/host/sdhci-esdhc-imx.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +20 -5
@@ -160,6 +160,8 @@#define ESDHC_FLAG_CQHCI BIT(12)/* need request pmqos during low power */ #define ESDHC_FLAG_PMQOS BIT(13) +/* The IP state got lost in low power mode */ +#define ESDHC_FLAG_STATE_LOST_IN_LPMODE BIT(14)struct esdhc_soc_data {u32 flags;
@@ -193,32 +195,37 @@ static const struct esdhc_soc_data usdhc_imx6sl_data = {static const struct esdhc_soc_data usdhc_imx6sx_data = { .flags =ESDHC_FLAG_USDHC |ESDHC_FLAG_STD_TUNING - |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_HS200 , + |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_HS200 + |ESDHC_FLAG_STATE_LOST_IN_LPMODE , };static const struct esdhc_soc_data usdhc_imx6ull_data = { .flags =ESDHC_FLAG_USDHC |ESDHC_FLAG_STD_TUNING |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_HS200 - |ESDHC_FLAG_ERR010450 , + |ESDHC_FLAG_ERR010450 + |ESDHC_FLAG_STATE_LOST_IN_LPMODE , };static const struct esdhc_soc_data usdhc_imx7d_data = { .flags =ESDHC_FLAG_USDHC |ESDHC_FLAG_STD_TUNING |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_HS200 - |ESDHC_FLAG_HS400 , + |ESDHC_FLAG_HS400 + |ESDHC_FLAG_STATE_LOST_IN_LPMODE , };static struct esdhc_soc_data usdhc_imx7ulp_data = { .flags =ESDHC_FLAG_USDHC |ESDHC_FLAG_STD_TUNING |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_HS200 - |ESDHC_FLAG_PMQOS |ESDHC_FLAG_HS400 , + |ESDHC_FLAG_PMQOS |ESDHC_FLAG_HS400 + |ESDHC_FLAG_STATE_LOST_IN_LPMODE , };static struct esdhc_soc_data usdhc_imx8qxp_data = { .flags =ESDHC_FLAG_USDHC |ESDHC_FLAG_STD_TUNING |ESDHC_FLAG_HAVE_CAP1 |ESDHC_FLAG_HS200 |ESDHC_FLAG_HS400 |ESDHC_FLAG_HS400_ES - |ESDHC_FLAG_CQHCI , + |ESDHC_FLAG_CQHCI + |ESDHC_FLAG_STATE_LOST_IN_LPMODE , };struct pltfm_imx_data {
@@ -1606,6 +1613,8 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev)static int sdhci_esdhc_suspend (struct device *dev) {struct sdhci_host *host =dev_get_drvdata (dev); +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct pltfm_imx_data *imx_data =sdhci_pltfm_priv (pltfm_host);int ret;if (host->mmc->caps2 &MMC_CAP2_CQE ) {
@@ -1614,6 +1623,12 @@ static int sdhci_esdhc_suspend(struct device *dev)return ret; } +if ((imx_data->socdata->flags &ESDHC_FLAG_STATE_LOST_IN_LPMODE ) && + (host->tuning_mode !=SDHCI_TUNING_MODE_1 )) { +mmc_retune_timer_stop (host->mmc); +mmc_retune_needed (host->mmc); + } +if (host->tuning_mode !=SDHCI_TUNING_MODE_3 )mmc_retune_needed (host->mmc);
Signature · 1 line
2.17.1
[email protected]
maintainerPATCH v4 4/14 mmc: sdhci-esdhc-imx: restore the per_clk rate in PM_RUNTIME
In reply to [email protected]From: Haibo Chen <[email protected]>
When pm_runtime_suspend is run, a call to SCFW power off the SS (SS is a power domain, usdhc belong to this SS power domain) in which the resource resides is made. The SCFW can power off the SS if no other resource in active in that SS. If so, all state associated with all the resources within the SS that is powered off is lost, this includes the clock rates, clock state etc. When pm_runtime_resume is called, the SS associated with that resource is powered up. But the clocks are left in the default state.
This patch restore clock rate in pm_runtime_resume, make sure the clock is right rather than depending on the default state setting by SCFW.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +7 -1
@@ -162,6 +162,8 @@#define ESDHC_FLAG_PMQOS BIT(13)/* The IP state got lost in low power mode */ #define ESDHC_FLAG_STATE_LOST_IN_LPMODE BIT(14) +/* The IP lost clock rate in PM_RUNTIME */ +#define ESDHC_FLAG_CLK_RATE_LOST_IN_PM_RUNTIME BIT(15)struct esdhc_soc_data {u32 flags;
@@ -225,7 +227,8 @@ static struct esdhc_soc_data usdhc_imx8qxp_data = { | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 | ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES | ESDHC_FLAG_CQHCI - | ESDHC_FLAG_STATE_LOST_IN_LPMODE, + | ESDHC_FLAG_STATE_LOST_IN_LPMODE + | ESDHC_FLAG_CLK_RATE_LOST_IN_PM_RUNTIME, };struct pltfm_imx_data {
@@ -1698,6 +1701,9 @@ static int sdhci_esdhc_runtime_resume(struct device *dev)pm_qos_add_request (&imx_data->pm_qos_req,PM_QOS_CPU_DMA_LATENCY ,0 ); +if (imx_data->socdata->flags &ESDHC_FLAG_CLK_RATE_LOST_IN_PM_RUNTIME ) +clk_set_rate (imx_data->clk_per, pltfm_host->clock); + err =clk_prepare_enable (imx_data->clk_ahb);if (err) goto remove_pm_qos_request;
Signature · 1 line
2.17.1
Quoted 8 lines · On Wed, 19 Feb 2020 at 09:30, <[email protected]> wrote:
From: Haibo Chen <[email protected]>
---
Changes for v4:
Add Adrian's ack for patch 9~12
for patch 13, change to add the check for pinctrl error
for patch 14, change to judge thedev->dma_parmsfirst, if it not exist, then alloc it.
Series applied for next, but waiting with patch14 for a while, thanks!
Kind regards
Uffe
Quoted 43 lines
Changes for v3:
Add Linus Walleij's ack for patch 2
for patch 9, drop the use of 'sdhci,auto-cmd23-broken' from dts, change to add flagESDHC_FLAG_BROKEN_AUTO_CMD23in the relatedesdhc_soc_data. for patch 10, add a newesdhc_soc_datafor i.MX8MMChanges for v2:
Add Adrian's ack for patch 1~8
Patch 9~10, change to use 'sdhci,auto-cmd23-broken' instead of 'fsl,auto-cmd23-broken' Patch 11, clear cqhci irq status and halt cqhci, move this change tosdhci_esdhc_imx_hwinit()and add some comment to explain the reason.
Patch 12, add error return check forpinctrl_pm_select_sleep_state()
Patch 13, clear theDMA_SELinsdhci-esdhc-imx.cinstead ofsdhci.c
Patch 14, add thedev->dma_parmsincore/queue.c, instead ofhost/sdhci.c.Haibo Chen (14):
mmc: sdhci: do not enable card detect interrupt for gpio cd type
mmc: sdhci-esdhc-imx: no fail when no pinctrl available
mmc: sdhci-esdhci-imx: retune needed for Mega/Mix enabled SoCs
mmc: sdhci-esdhc-imx: restore theper_clkrate inPM_RUNTIME
doc: dt: fsl-imx-esdhc: add strobe-dll-delay-target binding
mmc: sdhci-esdhc-imx: add strobe-dll-delay-target support
mmc: sdhci-esdhc-imx: optimize the clock setting
mmc: sdhci-esdhc-imx: optimize the strobe dll setting
mmc: sdhci-esdhc-imx: add flagESDHC_FLAG_BROKEN_AUTO_CMD23
mmc: sdhci-esdhc-imx: Add an newesdhc_soc_datafor i.MX8MM
mmc: sdhci-esdhc-imx: clear pending interrupt and halt cqhci
mmc: sdhci-esdhc-imx: clearDMA_SELwhen disable DMA mode
mmc: sdhci-esdhc-imx: restore pin state when resume back
mmc: queue: createdev->dma_parmsbefore calldma_set_max_seg_size().../devicetree/bindings/mmc/fsl-imx-esdhc.txt | 5 + drivers/mmc/core/queue.c | 11 +- drivers/mmc/host/sdhci-esdhc-imx.c | 167 +++++++++++++++--- drivers/mmc/host/sdhci-esdhc.h | 1 + drivers/mmc/host/sdhci.c | 2 +- include/linux/platform_data/mmc-esdhc-imx.h | 1 + 6 files changed, 161 insertions(+), 26 deletions(-)--
2.17.1