mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Alexander Shiyan <eagle.alexander923@gmail.com>,
	barebox@lists.infradead.org
Subject: Re: [PATCH] mci: atmel_mci: Merge at91_mci_bio_set_highcapacity() with at91_mci_bio_init()
Date: Thu, 27 Mar 2025 07:41:42 +0100	[thread overview]
Message-ID: <03e0271b-8912-4c26-86d8-064236350268@pengutronix.de> (raw)
In-Reply-To: <20250327053801.52356-1-eagle.alexander923@gmail.com>

Hello Alexander,

On 27.03.25 06:38, Alexander Shiyan wrote:
> The high-capacity parameter is always set to one of the possible values
> at initialization, so there is no need to have a separate function to
> configure it.

here's an idea from IRC by the way to get rid of the parameter:

ye, that [checking CSD] is what is used normally, but the problem is doing it
while in transmission state.

  I looked into Part1_Physical_Layer_Simplified_Specification_Ver9.00.pdf
  again and for the first time I see
  "Figure 4-13 : SD Memory Card State Diagram (data transfer mode)"

  Apparently, you don't necessarily need CMD0 (Go idle) to be able to get to a
  state where you can execute CMD9 (SEND CSD), but one could also execute CMD7
  (SELECT CARD) to deselect card and then run CMD9 and get back to transmission mode

  One would need to issue a CMD3 (SEND_RELATIVE_ADDR) to get the RCA to communicate
  with the correct SD (it's argument to CMD9), but this might work.

Perhaps you're interested in trying this out :D

Cheers,
Ahmad

> 
> Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
> ---
>  arch/arm/mach-at91/at91sam9_xload_mmc.c |  5 +----
>  arch/arm/mach-at91/xload.c              |  2 +-
>  drivers/mci/atmel_mci_pbl.c             | 10 +++-------
>  include/mach/at91/xload.h               |  4 ++--
>  4 files changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/at91sam9_xload_mmc.c b/arch/arm/mach-at91/at91sam9_xload_mmc.c
> index 26f268ae91..e8cd72bd56 100644
> --- a/arch/arm/mach-at91/at91sam9_xload_mmc.c
> +++ b/arch/arm/mach-at91/at91sam9_xload_mmc.c
> @@ -94,15 +94,12 @@ void __noreturn sam9263_atmci_start_image(u32 mmc_id, unsigned int clock,
>  		at91_pmc_enable_periph_clock(IOMEM(AT91SAM926X_BASE_PMC),  AT91SAM9263_ID_MCI1);
>  	}
>  
> -	ret = at91_mci_bio_init(&bio, base, clock, (int)slot_b);
> +	ret = at91_mci_bio_init(&bio, base, clock, (int)slot_b, false);
>  	if (ret) {
>  		pr_err("atmci_start_image: bio init faild: %d\n", ret);
>  		goto out_panic;
>  	}
>  
> -	/* at91sam9x do not support high capacity */
> -	at91_mci_bio_set_highcapacity(false);
> -
>  	ret = pbl_fat_load(&bio, "barebox.bin", buf, SZ_16M);
>  	if (ret < 0) {
>  		pr_err("pbl_fat_load: error %d\n", ret);
> diff --git a/arch/arm/mach-at91/xload.c b/arch/arm/mach-at91/xload.c
> index 5d8105f07f..effe8802ee 100644
> --- a/arch/arm/mach-at91/xload.c
> +++ b/arch/arm/mach-at91/xload.c
> @@ -228,7 +228,7 @@ void __noreturn sama5d3_atmci_start_image(u32 r4, unsigned int clock,
>  
>  	sama5d3_pmc_enable_periph_clock(instance->id);
>  
> -	ret = at91_mci_bio_init(&bio, instance->base, clock, slot);
> +	ret = at91_mci_bio_init(&bio, instance->base, clock, slot, true);
>  	if (ret)
>  		goto out_panic;
>  
> diff --git a/drivers/mci/atmel_mci_pbl.c b/drivers/mci/atmel_mci_pbl.c
> index bd4faa4de5..c94a4240db 100644
> --- a/drivers/mci/atmel_mci_pbl.c
> +++ b/drivers/mci/atmel_mci_pbl.c
> @@ -83,7 +83,8 @@ static int at91_mci_bio_read(struct pbl_bio *bio, off_t start,
>  }
>  
>  int at91_mci_bio_init(struct pbl_bio *bio, void __iomem *base,
> -		      unsigned int clock, unsigned int slot)
> +		      unsigned int clock, unsigned int slot,
> +		      bool highcapacity_card)
>  {
>  	struct atmel_mci_priv *priv = &atmci_sdcard;
>  	struct atmel_mci *host = &priv->host;
> @@ -111,12 +112,7 @@ int at91_mci_bio_init(struct pbl_bio *bio, void __iomem *base,
>  
>  	atmci_common_set_ios(host, &ios);
>  
> -	priv->highcapacity_card = 1;
> +	priv->highcapacity_card = highcapacity_card;
>  
>  	return 0;
>  }
> -
> -void at91_mci_bio_set_highcapacity(bool highcapacity_card)
> -{
> -	atmci_sdcard.highcapacity_card = highcapacity_card;
> -}
> diff --git a/include/mach/at91/xload.h b/include/mach/at91/xload.h
> index d5fc7596fd..329ccc98eb 100644
> --- a/include/mach/at91/xload.h
> +++ b/include/mach/at91/xload.h
> @@ -12,8 +12,8 @@ void __noreturn sama5d3_atmci_start_image(u32 r4, unsigned int clock,
>  
>  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_bio_set_highcapacity(bool highcapacity_card);
> +		      unsigned int clock, unsigned int slot,
> +		      bool highcapacity_card);
>  
>  void __noreturn sam9263_atmci_start_image(u32 mmc_id, unsigned int clock,
>  					  bool slot_b);


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



      parent reply	other threads:[~2025-03-27  6:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-27  5:38 Alexander Shiyan
2025-03-27  5:38 ` [PATCH] reset: Fix name of exported symbol Alexander Shiyan
2025-03-31  7:29   ` Sascha Hauer
2025-03-27  6:41 ` Ahmad Fatoum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03e0271b-8912-4c26-86d8-064236350268@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=eagle.alexander923@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox