mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH] at91: sama5d2: Do not use the contents of BSC_CR if the DISABLE_BSCR bit is set in the fuse
Date: Wed,  5 Mar 2025 10:48:35 +0300	[thread overview]
Message-ID: <20250305074835.34782-1-eagle.alexander923@gmail.com> (raw)

The DISABLE_BSCR bit in Fuse means "Does not read BSC_CR content,
so the Boot settings are those from the Fuse".
Let's ignore BSC_CR it this case.

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 include/mach/at91/sama5d2.h | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/include/mach/at91/sama5d2.h b/include/mach/at91/sama5d2.h
index 90b566ffc4..d8a450255f 100644
--- a/include/mach/at91/sama5d2.h
+++ b/include/mach/at91/sama5d2.h
@@ -305,16 +305,18 @@ static inline void __iomem *sama5d2_pio_map_bank(int bank, unsigned *id)
 
 static inline u32 sama5d2_bootcfg(void)
 {
-	u32 __iomem *bureg = SAMA5D2_BASE_SECURAM + 0x1400;
-	u32 bsc_cr = readl(SAMA5D2_BASE_SYSC + 0x54);
-	u32 __iomem *bootcfg;
+	u32 bsc_cr, bootcfg = readl(SAMA5D2_SFC_DR(16));
 
-	if (bsc_cr & SAMA5D2_BUREG_VALID)
-		bootcfg = &bureg[FIELD_GET(SAMA5D2_BUREG_INDEX, bsc_cr)];
-	else
-		bootcfg = SAMA5D2_SFC_DR(512 / 32);
+	if (bootcfg & SAMA5D2_DISABLE_BSC_CR)
+		return bootcfg;
 
-	return readl(bootcfg);
+	bsc_cr = readl(SAMA5D2_BASE_SYSC + 0x54);
+	if (bsc_cr & SAMA5D2_BUREG_VALID) {
+		u32 __iomem *bureg = SAMA5D2_BASE_SECURAM + 0x1400;
+		bootcfg = readl(&bureg[FIELD_GET(SAMA5D2_BUREG_INDEX, bsc_cr)]);
+	}
+
+	return bootcfg;
 }
 
 #endif
-- 
2.39.1




             reply	other threads:[~2025-03-05  7:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05  7:48 Alexander Shiyan [this message]
2025-03-07  8:03 ` Sascha Hauer

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=20250305074835.34782-1-eagle.alexander923@gmail.com \
    --to=eagle.alexander923@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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