[PATCH] mci: sdhci: Add and use common sdhci_wait_for_done()

Rouven Czerwinski r.czerwinski at pengutronix.de
Tue Mar 28 05:33:02 PDT 2023


Hi,

On Tue, 2023-03-28 at 11:58 +0200, Sascha Hauer wrote:
> On Mon, Mar 27, 2023 at 03:01:31PM +0200, Rouven Czerwinski wrote:
> > Hi,
> > 
> > On Tue, 2023-03-21 at 10:50 +0100, Sascha Hauer wrote:
> > > We have different driver specific variants of functions polling
> > > for the
> > > device ready in the tree. Add a common sdhci_wait_for_done() and
> > > use
> > > it where appropriate. This fixes a few deficiencies with the
> > > driver
> > > specific variants.
> > > 
> > > rk_sdhci_wait_for_done() didn't check the SDHCI_INT_TIMEOUT bit
> > > and
> > > returned -EPERM instead when it ought to return -ETIMEDOUT. The
> > > core
> > > tries to detect a SD card first and expects a -ETIMEDOUT for the
> > > setup
> > > command when really a eMMC is connected. Only with a -ETIMEDOUT
> > > the core
> > > tries to detect a eMMC next.
> > > 
> > > at91_sdhci_wait_for_done() returned the status instead of the
> > > expected
> > > 0 value for success.
> > 
> > I had to revert this commit to run barebox_update on the CM3
> > RK3566.
> > Otherwise writes to the boot partition would hang indefinitely.
> 
> Same here. The following fixes this.
> 
> At some point during MMC initialization we probe for a SDIO card.
> This
> is expected to fail for non SDIO cards and we have to call
> sdhci_reset()
> in the error path then. It's a bit weird that the effect is that
> everything apparently works but writing to boot partitions does not.
> 
> Sascha

Jip, this fixes it, you can add a:

Tested-by: Rouven Czerwinski <r.czerwinski at pengutronix.de>

> 
> ---------------------------8<---------------------------
> 
> From db92d5c12080c0ad108bd1d8bb0481584a36ae4b Mon Sep 17 00:00:00
> 2001
> From: Sascha Hauer <s.hauer at pengutronix.de>
> Date: Tue, 28 Mar 2023 11:43:35 +0200
> Subject: [PATCH] fixup! mci: sdhci: Add and use common
> sdhci_wait_for_done()
> 
> ---
>  drivers/mci/rockchip-dwcmshc-sdhci.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/mci/rockchip-dwcmshc-sdhci.c
> b/drivers/mci/rockchip-dwcmshc-sdhci.c
> index e055a8ea71..a98600cc4c 100644
> --- a/drivers/mci/rockchip-dwcmshc-sdhci.c
> +++ b/drivers/mci/rockchip-dwcmshc-sdhci.c
> @@ -263,10 +263,8 @@ static int rk_sdhci_send_cmd(struct mci_host
> *mci, struct mci_cmd *cmd,
>         sdhci_write16(&host->sdhci, SDHCI_COMMAND, command);
>  
>         ret = sdhci_wait_for_done(&host->sdhci,
> SDHCI_INT_CMD_COMPLETE);
> -       if (ret == -EPERM)
> +       if (ret)
>                 goto error;
> -       else if (ret)
> -               return ret;
>  
>         sdhci_read_response(&host->sdhci, cmd);
>         sdhci_write32(&host->sdhci, SDHCI_INT_STATUS,
> SDHCI_INT_CMD_COMPLETE);
> -- 
> 2.39.2
> 




More information about the barebox mailing list