[PATCH 2/3] ARM: at91: mmc-xload: allow overriding card capacity

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Jun 2 03:30:19 PDT 2021


I see now that I botched, the title "mmc-xload" instead of "xload-mmc".
@Sascha, please tell me if I should resend.

On 02.06.21 12:25, Ahmad Fatoum wrote:
> The PBL MMC driver works with the assumption that the BootROM has left
> the SD-Card in transfer mode. There seems to be no definitive way
> to find out whether a running card is high capacity (> 2G) or not,
> but we need this info when reading, because default capacities accept
> their read offset in bytes while high capacity deal in 512 byte blocks.
> 
> For i.MX, this is elegantly solved by just reading from sector 0.
> For AT91, we chainload barebox from FAT, so we need to seek around.
> So far, we just had an assumption buried in the driver that we are
> always highcapacity.
> 
> Export a knob to change this, so we can move the hardcoding from
> driver to board code, where it's more prominent. This is done
> in a follow-up commit.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
>  arch/arm/mach-at91/include/mach/xload.h | 3 +++
>  drivers/mci/atmel-sdhci-pbl.c           | 8 +++++++-
>  drivers/mci/atmel_mci_pbl.c             | 8 +++++++-
>  3 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/include/mach/xload.h b/arch/arm/mach-at91/include/mach/xload.h
> index bbc70af2108a..038f32554568 100644
> --- a/arch/arm/mach-at91/include/mach/xload.h
> +++ b/arch/arm/mach-at91/include/mach/xload.h
> @@ -12,4 +12,7 @@ int at91_sdhci_bio_init(struct pbl_bio *bio, void __iomem *base);
>  int at91_mci_bio_init(struct pbl_bio *bio, void __iomem *base,
>  		      unsigned int clock, unsigned int slot);
>  
> +void at91_mci_set_highcapacity(struct pbl_bio *bio, bool highcap);
> +void at91_sdhci_set_highcapacity(struct pbl_bio *bio, bool highcap);
> +
>  #endif /* __MACH_XLOAD_H */
> diff --git a/drivers/mci/atmel-sdhci-pbl.c b/drivers/mci/atmel-sdhci-pbl.c
> index 626e4008fe85..317f26f8af0d 100644
> --- a/drivers/mci/atmel-sdhci-pbl.c
> +++ b/drivers/mci/atmel-sdhci-pbl.c
> @@ -99,6 +99,12 @@ static int at91_sdhci_bio_read(struct pbl_bio *bio, off_t start,
>  	return blocks_done;
>  }
>  
> +void at91_sdhci_set_highcapacity(struct pbl_bio *bio, bool highcap)
> +{
> +	struct at91_sdhci_priv *priv = bio->priv;
> +	priv->highcapacity_card = highcap;
> +}
> +
>  static struct at91_sdhci_priv atmel_sdcard;
>  
>  int at91_sdhci_bio_init(struct pbl_bio *bio, void __iomem *base)
> @@ -122,7 +128,7 @@ int at91_sdhci_bio_init(struct pbl_bio *bio, void __iomem *base)
>  	ret = at91_sdhci_set_ios(host, &ios);
>  
>  	 // FIXME can we determine this without leaving SD transfer mode?
> -	priv->highcapacity_card = 1;
> +	at91_sdhci_set_highcapacity(bio, true);
>  
>  	return 0;
>  }
> diff --git a/drivers/mci/atmel_mci_pbl.c b/drivers/mci/atmel_mci_pbl.c
> index 767d6f3ce2d7..82e45fd4e89e 100644
> --- a/drivers/mci/atmel_mci_pbl.c
> +++ b/drivers/mci/atmel_mci_pbl.c
> @@ -82,6 +82,12 @@ static int at91_mci_bio_read(struct pbl_bio *bio, off_t start,
>  	return blocks_done;
>  }
>  
> +void at91_mci_set_highcapacity(struct pbl_bio *bio, bool highcap)
> +{
> +	struct atmel_mci_priv *priv = bio->priv;
> +	priv->highcapacity_card = highcap;
> +}
> +
>  int at91_mci_bio_init(struct pbl_bio *bio, void __iomem *base,
>  		      unsigned int clock, unsigned int slot)
>  {
> @@ -110,7 +116,7 @@ int at91_mci_bio_init(struct pbl_bio *bio, void __iomem *base,
>  
>  	atmci_common_set_ios(host, &ios);
>  
> -	priv->highcapacity_card = 1;
> +	at91_mci_set_highcapacity(bio, true);
>  
>  	return 0;
>  }
> 

-- 
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