diff mbox

[V2,06/11] mmc: sdhci-esdhc-imx: fix cd regression for dt platform

Message ID 1437569590-5228-7-git-send-email-aisheng.dong@freescale.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dong Aisheng July 22, 2015, 12:53 p.m. UTC
Current card detect probe process is that when driver finds a valid
ESDHC_CD_GPIO, it will clear the quirk SDHCI_QUIRK_BROKEN_CARD_DETECTION
which is set by default for all esdhc/usdhc controllers.
Then host driver will know there's a valid card detect function.

Commit 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()")
breaks GPIO CD function for dt platform that it will return directly
when find ESDHC_CD_GPIO for dt platform which result in the later wrongly
to keep SDHCI_QUIRK_BROKEN_CARD_DETECTION for all dt platforms.
Then MMC_CAP_NEEDS_POLL will be used instead even there's a valid
GPIO card detect.

This patch adds back this function and follows the original approach to
clear the quirk if find an valid CD GPIO for dt platforms.

Fixes: 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()")
Signed-off-by: Dong Aisheng <aisheng.dong@freescale.com>
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Stefan Agner Oct. 6, 2015, 10:15 p.m. UTC | #1
Hi Dong,

Just hit that issue in 4.1, could we add that patch also to stable?

--
Stefan

On 2015-07-22 05:53, Dong Aisheng wrote:
> Current card detect probe process is that when driver finds a valid
> ESDHC_CD_GPIO, it will clear the quirk SDHCI_QUIRK_BROKEN_CARD_DETECTION
> which is set by default for all esdhc/usdhc controllers.
> Then host driver will know there's a valid card detect function.
> 
> Commit 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()")
> breaks GPIO CD function for dt platform that it will return directly
> when find ESDHC_CD_GPIO for dt platform which result in the later wrongly
> to keep SDHCI_QUIRK_BROKEN_CARD_DETECTION for all dt platforms.
> Then MMC_CAP_NEEDS_POLL will be used instead even there's a valid
> GPIO card detect.
> 
> This patch adds back this function and follows the original approach to
> clear the quirk if find an valid CD GPIO for dt platforms.
> 
> Fixes: 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()")
> Signed-off-by: Dong Aisheng <aisheng.dong@freescale.com>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c
> b/drivers/mmc/host/sdhci-esdhc-imx.c
> index faf0cb9..4815391 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -881,6 +881,7 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
>  			 struct esdhc_platform_data *boarddata)
>  {
>  	struct device_node *np = pdev->dev.of_node;
> +	int ret;
>  
>  	if (!np)
>  		return -ENODEV;
> @@ -917,7 +918,14 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
>  	mmc_of_parse_voltage(np, &host->ocr_mask);
>  
>  	/* call to generic mmc_of_parse to support additional capabilities */
> -	return mmc_of_parse(host->mmc);
> +	ret = mmc_of_parse(host->mmc);
> +	if (ret)
> +		return ret;
> +
> +	if (!IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc)))
> +		host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
> +
> +	return 0;
>  }
>  #else
>  static inline int
Fabio Estevam Oct. 6, 2015, 10:21 p.m. UTC | #2
Hi Stefan,

On Tue, Oct 6, 2015 at 7:15 PM, Stefan Agner <stefan@agner.ch> wrote:
> Hi Dong,
>
> Just hit that issue in 4.1, could we add that patch also to stable?

I sent the series to stable, but Greg has not applied it yet.
Fabio Estevam Oct. 24, 2015, 1:06 p.m. UTC | #3
On Tue, Oct 6, 2015 at 7:21 PM, Fabio Estevam <festevam@gmail.com> wrote:
> Hi Stefan,
>
> On Tue, Oct 6, 2015 at 7:15 PM, Stefan Agner <stefan@agner.ch> wrote:
>> Hi Dong,
>>
>> Just hit that issue in 4.1, could we add that patch also to stable?
>
> I sent the series to stable, but Greg has not applied it yet.

Greg applied the series and it appears now in 4.1.11.
Robert Nelson Oct. 25, 2015, 8:52 p.m. UTC | #4
On Sat, Oct 24, 2015 at 8:06 AM, Fabio Estevam <festevam@gmail.com> wrote:
> On Tue, Oct 6, 2015 at 7:21 PM, Fabio Estevam <festevam@gmail.com> wrote:
>> Hi Stefan,
>>
>> On Tue, Oct 6, 2015 at 7:15 PM, Stefan Agner <stefan@agner.ch> wrote:
>>> Hi Dong,
>>>
>>> Just hit that issue in 4.1, could we add that patch also to stable?
>>
>> I sent the series to stable, but Greg has not applied it yet.
>
> Greg applied the series and it appears now in 4.1.11.

I need to finish a full bisect run, but one of these sdhci-esdhci-imx
fixes broke the wandboard..

v4.1.10:

voodoo@a3-imx6q-wandboard-2gb:~$ dmesg | grep mmc2
[    4.844563] mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc]
using ADMA
[    5.132859] mmc2: host does not support reading read-only switch,
assuming write-enable
[    5.147150] mmc2: new high speed SDHC card at address 0007
[    5.153245] mmcblk0: mmc2:0007 SD8GB 7.42 GiB
voodoo@a3-imx6q-wandboard-2gb:~$ dmesg | grep 2198000.usdhc
[    4.779415] sdhci-esdhc-imx 2198000.usdhc: could not get ultra high
speed state, work on normal mode
[    4.788589] sdhci-esdhc-imx 2198000.usdhc: Got CD GPIO
[    4.793910] sdhci-esdhc-imx 2198000.usdhc: No vmmc regulator found
[    4.800133] sdhci-esdhc-imx 2198000.usdhc: No vqmmc regulator found
[    4.844563] mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc]
using ADMA

v4.1.11:

root@a4-imx6q-wandboard-2gb:~# dmesg | grep mmc2
[    4.854721] mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc]
using ADMA
root@a4-imx6q-wandboard-2gb:~# dmesg | grep 2198000.usdhc
[    4.781491] sdhci-esdhc-imx 2198000.usdhc: Got CD GPIO
[    4.786689] sdhci-esdhc-imx 2198000.usdhc: could not get ultra high
speed state, work on normal mode
[    4.796023] sdhci-esdhc-imx 2198000.usdhc: No vmmc regulator found
[    4.802229] sdhci-esdhc-imx 2198000.usdhc: No vqmmc regulator found
[    4.854721] mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc]
using ADMA

Regards,
diff mbox

Patch

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index faf0cb9..4815391 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -881,6 +881,7 @@  sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 			 struct esdhc_platform_data *boarddata)
 {
 	struct device_node *np = pdev->dev.of_node;
+	int ret;
 
 	if (!np)
 		return -ENODEV;
@@ -917,7 +918,14 @@  sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 	mmc_of_parse_voltage(np, &host->ocr_mask);
 
 	/* call to generic mmc_of_parse to support additional capabilities */
-	return mmc_of_parse(host->mmc);
+	ret = mmc_of_parse(host->mmc);
+	if (ret)
+		return ret;
+
+	if (!IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc)))
+		host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
+
+	return 0;
 }
 #else
 static inline int