[PATCH 13/30] mci: imx-esdhc: implement esdhc_poll using sdhci_read32_poll_timeout

Sascha Hauer s.hauer at pengutronix.de
Mon May 5 23:25:53 PDT 2025


On Mon, May 05, 2025 at 02:06:16PM +0200, Ahmad Fatoum wrote:
> esdhc_match32 is not flexible enough for use in the upcoming HS200
> tuning code, so reimplement it in terms of sdhci_read32_poll_timeout
> to allow custom conditions.
> 
> No functional change.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
>  drivers/mci/imx-esdhc-common.c | 65 +++++++++++-----------------------
>  drivers/mci/imx-esdhc.c        | 15 ++++----
>  drivers/mci/imx-esdhc.h        | 29 +++++++++++++--
>  3 files changed, 53 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/mci/imx-esdhc-common.c b/drivers/mci/imx-esdhc-common.c
> index 7673220fe8d4..dae88bb977c6 100644
> --- a/drivers/mci/imx-esdhc-common.c
> +++ b/drivers/mci/imx-esdhc-common.c
> @@ -78,49 +78,24 @@ static int esdhc_setup_data(struct fsl_esdhc_host *host, struct mci_data *data,
>  	return 0;
>  }
>  
> -static bool esdhc_match32(struct fsl_esdhc_host *host, unsigned int off,
> -			  unsigned int mask, unsigned int val)
> +static u64 esdhc_compute_timeout(struct mci_cmd *cmd,
> +				 struct mci_data *data,
> +				 u64 default_value)
>  {
> -	const unsigned int reg = sdhci_read32(&host->sdhci, off) & mask;
> +	if (data && data->timeout_ns != 0)
> +		return data->timeout_ns;
>  
> -	return reg == val;
> -}
> +	if (cmd && cmd->busy_timeout != 0)
> +		return cmd->busy_timeout * NSEC_PER_MSEC;

You have the same code in "mci: sdhci: add support for struct mci_data::timeout_ns"
already. Can this be made a generic helper?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list