2022-11-30 09:05:00

by Wenchao Chen

[permalink] [raw]
Subject: [PATCH] mmc: sdhci-sprd: Fix no reset data and command after voltage switch

After switching the voltage, no reset data and command will cause
CMD2 timeout.

Fixes: 29ca763fc26f ("mmc: sdhci-sprd: Add pin control support for voltage switch")
Signed-off-by: Wenchao Chen <[email protected]>
---
drivers/mmc/host/sdhci-sprd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index b92a408f138d..464508be8ec8 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -470,7 +470,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
}

if (IS_ERR(sprd_host->pinctrl))
- return 0;
+ goto reset;

switch (ios->signal_voltage) {
case MMC_SIGNAL_VOLTAGE_180:
@@ -496,6 +496,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
break;
}

+reset:
/* Wait for 300 ~ 500 us for pin state stable */
usleep_range(300, 500);
sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
--
2.17.1


2022-11-30 10:22:43

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH] mmc: sdhci-sprd: Fix no reset data and command after voltage switch

On 30/11/22 10:02, Wenchao Chen wrote:
> After switching the voltage, no reset data and command will cause
> CMD2 timeout.
>
> Fixes: 29ca763fc26f ("mmc: sdhci-sprd: Add pin control support for voltage switch")
> Signed-off-by: Wenchao Chen <[email protected]>

Acked-by: Adrian Hunter <[email protected]>


> ---
> drivers/mmc/host/sdhci-sprd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
> index b92a408f138d..464508be8ec8 100644
> --- a/drivers/mmc/host/sdhci-sprd.c
> +++ b/drivers/mmc/host/sdhci-sprd.c
> @@ -470,7 +470,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> }
>
> if (IS_ERR(sprd_host->pinctrl))
> - return 0;
> + goto reset;
>
> switch (ios->signal_voltage) {
> case MMC_SIGNAL_VOLTAGE_180:
> @@ -496,6 +496,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> break;
> }
>
> +reset:
> /* Wait for 300 ~ 500 us for pin state stable */
> usleep_range(300, 500);
> sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);

2022-11-30 10:49:52

by Baolin Wang

[permalink] [raw]
Subject: Re: [PATCH] mmc: sdhci-sprd: Fix no reset data and command after voltage switch



On 11/30/2022 4:02 PM, Wenchao Chen wrote:
> After switching the voltage, no reset data and command will cause
> CMD2 timeout.
>
> Fixes: 29ca763fc26f ("mmc: sdhci-sprd: Add pin control support for voltage switch")
> Signed-off-by: Wenchao Chen <[email protected]>
> ---
> drivers/mmc/host/sdhci-sprd.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
> index b92a408f138d..464508be8ec8 100644
> --- a/drivers/mmc/host/sdhci-sprd.c
> +++ b/drivers/mmc/host/sdhci-sprd.c
> @@ -470,7 +470,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> }
>
> if (IS_ERR(sprd_host->pinctrl))
> - return 0;
> + goto reset;
>
> switch (ios->signal_voltage) {
> case MMC_SIGNAL_VOLTAGE_180:
> @@ -496,6 +496,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> break;
> }
>
> +reset:
> /* Wait for 300 ~ 500 us for pin state stable */
> usleep_range(300, 500);

If no pin state switching, still need stable time? Otherwise looks good
to me.

> sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);

2022-11-30 12:24:50

by Wenchao Chen

[permalink] [raw]
Subject: Re: [PATCH] mmc: sdhci-sprd: Fix no reset data and command after voltage switch

On Wed, Nov 30, 2022 at 6:48 PM Baolin Wang
<[email protected]> wrote:
>
>
>
> On 11/30/2022 4:02 PM, Wenchao Chen wrote:
> > After switching the voltage, no reset data and command will cause
> > CMD2 timeout.
> >
> > Fixes: 29ca763fc26f ("mmc: sdhci-sprd: Add pin control support for voltage switch")
> > Signed-off-by: Wenchao Chen <[email protected]>
> > ---
> > drivers/mmc/host/sdhci-sprd.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
> > index b92a408f138d..464508be8ec8 100644
> > --- a/drivers/mmc/host/sdhci-sprd.c
> > +++ b/drivers/mmc/host/sdhci-sprd.c
> > @@ -470,7 +470,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> > }
> >
> > if (IS_ERR(sprd_host->pinctrl))
> > - return 0;
> > + goto reset;
> >
> > switch (ios->signal_voltage) {
> > case MMC_SIGNAL_VOLTAGE_180:
> > @@ -496,6 +496,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> > break;
> > }
> >
> > +reset:
> > /* Wait for 300 ~ 500 us for pin state stable */
> > usleep_range(300, 500);
>
> If no pin state switching, still need stable time? Otherwise looks good
> to me.
>

Thank you for your review. I will update it in the next version.

> > sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);