[PATCH 3/3] ARM: at91: xload-mmc: add prominent note about PBL MMC limitation

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Jun 2 03:25:24 PDT 2021


The PBL driver has an assumption about only being used with
high capacity cards. When using a default capacity card, the sama5d3
MCI controller hang when doing unaligned accesses.

This heuristic could add some support default capacity card support
without risking unaligned accesses:

  at91_mci_set_highcapacity(false);

  sector0 = read_sector(0);
  if (!is_mbr(sector0, &fatsect)
         abort();

  fatsector1 = read_sector(fatsect);
  at91_mci_set_highcapacity(false);

  if (is_fat(fatsect))
	goto default_cap;
  else
	goto high_cap;

This, of course, fails if fatsect * 512 on a high capacity card
happens to have a FAT signature. As it's unclear whether supporting
<= 2 GiB is worth the effort, hardcode it in xload-mmc.c and add
a note about the limitation to conserve future debugging effort.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 arch/arm/mach-at91/xload-mmc.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-at91/xload-mmc.c b/arch/arm/mach-at91/xload-mmc.c
index 1b641f3a47ac..89766cf6b910 100644
--- a/arch/arm/mach-at91/xload-mmc.c
+++ b/arch/arm/mach-at91/xload-mmc.c
@@ -76,8 +76,18 @@ void __noreturn sama5d2_sdhci_start_image(u32 r4)
 	if (ret)
 		goto out_panic;
 
-	/* TODO: eMMC boot partition handling: they are not FAT-formatted */
+	/*
+	 * There seems to be no definitive way to find out whether we are
+	 * connected to a default or high capacity card without resetting
+	 * the card. The PBL driver assumes however that the card is already
+	 * in transfer mode. For now assume all cards to be high capacity.
+	 * If support for cards smaller or equal to 2GiB becomes relevant,
+	 * this assumption can be revisited.
+	 */
+	pr_debug("Assuming high capacity card\n");
+	at91_sdhci_set_highcapacity(&bio, true);
 
+	/* TODO: eMMC boot partition handling: they are not FAT-formatted */
 	at91_fat_start_image(&bio, buf, SZ_16M, r4);
 
 out_panic:
@@ -128,6 +138,18 @@ void __noreturn sama5d3_atmci_start_image(u32 boot_src, unsigned int clock,
 	if (ret)
 		goto out_panic;
 
+	/*
+	 * There seems to be no definitive way to find out whether we are
+	 * connected to a default or high capacity card without resetting
+	 * the card. The PBL driver assumes however that the card is already
+	 * in transfer mode. For now assume all cards to be high capacity.
+	 * If support for cards smaller or equal to 2GiB becomes relevant,
+	 * this assumption can be revisited.
+	 */
+	pr_debug("Assuming high capacity card\n");
+	at91_mci_set_highcapacity(&bio, true);
+
+	/* TODO: eMMC boot partition handling: they are not FAT-formatted */
 	at91_fat_start_image(&bio, buf, SZ_16M, boot_src);
 
 out_panic:
-- 
2.29.2




More information about the barebox mailing list