[PATCH 06/12] mci: sdhci: Use Linux defines for SDHCI_HOST_CONTROL register

Antony Pavlov antonynpavlov at gmail.com
Tue Jan 25 22:32:33 PST 2022


On Mon,  7 Jun 2021 12:44:05 +0200
Sascha Hauer <s.hauer at pengutronix.de> wrote:

Hi Sascha!

> To ease porting and comparing of Linux code.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  drivers/mci/arasan-sdhci.c       | 12 ++++++------
>  drivers/mci/atmel-sdhci-common.c | 14 +++++++-------
>  drivers/mci/dove-sdhci.c         | 10 +++++-----
>  drivers/mci/sdhci.h              | 17 ++++++++++++-----
>  4 files changed, 30 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/mci/arasan-sdhci.c b/drivers/mci/arasan-sdhci.c
> index e22db4cfa3..e02f222345 100644
> --- a/drivers/mci/arasan-sdhci.c
> +++ b/drivers/mci/arasan-sdhci.c

...

> @@ -200,21 +200,21 @@ static void arasan_sdhci_set_ios(struct mci_host *mci, struct mci_ios *ios)
>  	}
>  
>  	val = sdhci_read8(&host->sdhci, SDHCI_HOST_CONTROL) &
> -			~(SDHCI_DATA_WIDTH_4BIT | SDHCI_DATA_WIDTH_8BIT);
> +			~(SDHCI_CTRL_8BITBUS | SDHCI_CTRL_8BITBUS);
>  
>  	switch (ios->bus_width) {
>  	case MMC_BUS_WIDTH_8:
> -		val |= SDHCI_DATA_WIDTH_8BIT;
> +		val |= SDHCI_CTRL_8BITBUS;
>  		break;
>  	case MMC_BUS_WIDTH_4:
                     ^^^^^^^^
> -		val |= SDHCI_DATA_WIDTH_4BIT;
                                  ^^^^^^^^^^^
> +		val |= SDHCI_CTRL_8BITBUS;
                                  ^^^^^^^
Is this correct?

>  		break;
>  	}
>  
>  	if (ios->clock > 26000000)
> -		val |= SDHCI_HIGHSPEED_EN;
> +		val |= SDHCI_CTRL_HISPD;
>  	else
> -		val &= ~SDHCI_HIGHSPEED_EN;
> +		val &= ~SDHCI_CTRL_HISPD;
>  
>  	sdhci_write8(&host->sdhci, SDHCI_HOST_CONTROL, val);
>  }
> diff --git a/drivers/mci/atmel-sdhci-common.c b/drivers/mci/atmel-sdhci-common.c
> index b391775b00..d2b777a93c 100644
> --- a/drivers/mci/atmel-sdhci-common.c
> +++ b/drivers/mci/atmel-sdhci-common.c

...

> @@ -297,15 +297,15 @@ static int at91_sdhci_set_bus_width(struct at91_sdhci *host, unsigned bus_width)
>  
>  	switch(bus_width) {
>  	case MMC_BUS_WIDTH_8:
> -		reg |= SDHCI_DATA_WIDTH_8BIT;
> +		reg |= SDHCI_CTRL_8BITBUS;
>  		break;
>  	case MMC_BUS_WIDTH_4:
                     ^^^^^^^

> -		reg &= ~SDHCI_DATA_WIDTH_8BIT;
> -		reg |= SDHCI_DATA_WIDTH_4BIT;
                                  ^^^^^^^^^^^
> +		reg &= ~SDHCI_CTRL_8BITBUS;
> +		reg |= SDHCI_CTRL_8BITBUS;
                                  ^^^^^^^^

just the same question here

>  		break;
>  	default:
> -		reg &= ~SDHCI_DATA_WIDTH_8BIT;
> -		reg &= ~SDHCI_DATA_WIDTH_4BIT;
> +		reg &= ~SDHCI_CTRL_8BITBUS;
> +		reg &= ~SDHCI_CTRL_8BITBUS;

and here

>  	}
>  
>  	sdhci_write8(sdhci, SDHCI_HOST_CONTROL, reg);
> diff --git a/drivers/mci/dove-sdhci.c b/drivers/mci/dove-sdhci.c
> index 9c10e67eb8..cafc9dc579 100644
> --- a/drivers/mci/dove-sdhci.c
> +++ b/drivers/mci/dove-sdhci.c
> @@ -224,20 +224,20 @@ static void dove_sdhci_mci_set_ios(struct mci_host *mci, struct mci_ios *ios)
>  
>  	/* set bus width */
>  	val = sdhci_read8(&host->sdhci, SDHCI_HOST_CONTROL) &
> -		~(SDHCI_DATA_WIDTH_4BIT | SDHCI_DATA_WIDTH_8BIT);
> +		~(SDHCI_CTRL_8BITBUS | SDHCI_CTRL_8BITBUS);
>  	switch (ios->bus_width) {
>  	case MMC_BUS_WIDTH_8:
> -		val |= SDHCI_DATA_WIDTH_8BIT;
> +		val |= SDHCI_CTRL_8BITBUS;
>  		break;
>  	case MMC_BUS_WIDTH_4:
> -		val |= SDHCI_DATA_WIDTH_4BIT;
> +		val |= SDHCI_CTRL_8BITBUS;

and here

>  		break;
>  	}
>  
>  	if (ios->clock > 26000000)
> -		val |= SDHCI_HIGHSPEED_EN;
> +		val |= SDHCI_CTRL_HISPD;
>  	else
> -		val &= ~SDHCI_HIGHSPEED_EN;
> +		val &= ~SDHCI_CTRL_HISPD;
>  
>  	sdhci_write8(&host->sdhci, SDHCI_HOST_CONTROL, val);
>  

-- 
Best regards,
  Antony Pavlov



More information about the barebox mailing list