mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/6] ARM: i.MX: External Nand boot: move pagesize detection into SoC specific code
Date: Tue,  9 Jul 2013 11:54:39 +0200	[thread overview]
Message-ID: <1373363682-24449-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1373363682-24449-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/external-nand-boot.c | 90 ++++++++++++++++++----------------
 1 file changed, 47 insertions(+), 43 deletions(-)

diff --git a/arch/arm/mach-imx/external-nand-boot.c b/arch/arm/mach-imx/external-nand-boot.c
index 1f35e72..2e4e4d0 100644
--- a/arch/arm/mach-imx/external-nand-boot.c
+++ b/arch/arm/mach-imx/external-nand-boot.c
@@ -121,40 +121,6 @@ static void __bare_init __memcpy32(void *trg, const void *src, int size)
 		*t++ = *s++;
 }
 
-static int __maybe_unused is_pagesize_2k(void)
-{
-#ifdef CONFIG_ARCH_IMX21
-	if (readl(MX21_SYSCTRL_BASE_ADDR + 0x14) & (1 << 5))
-		return 1;
-	else
-		return 0;
-#endif
-#if defined(CONFIG_ARCH_IMX25)
-	if (readl(MX25_CCM_BASE_ADDR + MX25_CCM_RCSR) & (1 << 8))
-		return 1;
-	else
-		return 0;
-#endif
-#ifdef CONFIG_ARCH_IMX27
-	if (readl(MX27_SYSCTRL_BASE_ADDR + 0x14) & (1 << 5))
-		return 1;
-	else
-		return 0;
-#endif
-#ifdef CONFIG_ARCH_IMX31
-	if (readl(MX31_CCM_BASE_ADDR + MX31_CCM_RCSR) & MX31_RCSR_NFMS)
-		return 1;
-	else
-		return 0;
-#endif
-#if defined(CONFIG_ARCH_IMX35)
-	if (readl(MX35_CCM_BASE_ADDR + MX35_CCM_RCSR) & (1 << 8))
-		return 1;
-	else
-		return 0;
-#endif
-}
-
 static noinline void __bare_init imx_nandboot_get_page(void *regs,
 		u32 offs, int pagesize_2k)
 {
@@ -163,14 +129,12 @@ static noinline void __bare_init imx_nandboot_get_page(void *regs,
 	imx_nandboot_send_page(regs, NFC_OUTPUT, pagesize_2k);
 }
 
-void __bare_init imx_nand_load_image(void *dest, int size)
+void __bare_init imx_nand_load_image(void *dest, int size, int pagesize_2k)
 {
 	u32 tmp, page, block, blocksize, pagesize, badblocks;
-	int pagesize_2k = 1, bbt = 0;
+	int bbt = 0;
 	void *regs, *base, *spare0;
 
-	pagesize_2k = is_pagesize_2k();
-
 	if (pagesize_2k) {
 		pagesize = 2048;
 		blocksize = 128 * 1024;
@@ -336,11 +300,19 @@ int __bare_init imx_barebox_boot_nand_external(unsigned long nfc_base)
 void __bare_init __noreturn imx21_barebox_boot_nand_external(void)
 {
 	unsigned long nfc_base = MX21_NFC_BASE_ADDR;
+	int pagesize_2k;
 
 	if (imx_barebox_boot_nand_external(nfc_base)) {
 		jump_sdram(nfc_base - ld_var(_text));
+
+		if (readl(MX21_SYSCTRL_BASE_ADDR + 0x14) & (1 << 5))
+			pagesize_2k = 1;
+		else
+			pagesize_2k = 0;
+
 		imx_nand_load_image((void *)ld_var(_text),
-				ld_var(barebox_image_size));
+				ld_var(barebox_image_size),
+				pagesize_2k);
 	}
 
 	imx21_barebox_entry(0);
@@ -351,11 +323,19 @@ void __bare_init __noreturn imx21_barebox_boot_nand_external(void)
 void __bare_init __noreturn imx25_barebox_boot_nand_external(void)
 {
 	unsigned long nfc_base = MX25_NFC_BASE_ADDR;
+	int pagesize_2k;
 
 	if (imx_barebox_boot_nand_external(nfc_base)) {
 		jump_sdram(nfc_base - ld_var(_text));
+
+		if (readl(MX25_CCM_BASE_ADDR + MX25_CCM_RCSR) & (1 << 8))
+			pagesize_2k = 1;
+		else
+			pagesize_2k = 0;
+
 		imx_nand_load_image((void *)ld_var(_text),
-				ld_var(_barebox_image_size));
+				ld_var(_barebox_image_size),
+				pagesize_2k);
 	}
 
 	imx25_barebox_entry(0);
@@ -366,11 +346,19 @@ void __bare_init __noreturn imx25_barebox_boot_nand_external(void)
 void __bare_init __noreturn imx27_barebox_boot_nand_external(void)
 {
 	unsigned long nfc_base = MX27_NFC_BASE_ADDR;
+	int pagesize_2k;
 
 	if (imx_barebox_boot_nand_external(nfc_base)) {
 		jump_sdram(nfc_base - ld_var(_text));
+
+		if (readl(MX27_SYSCTRL_BASE_ADDR + 0x14) & (1 << 5))
+			pagesize_2k = 1;
+		else
+			pagesize_2k = 0;
+
 		imx_nand_load_image((void *)ld_var(_text),
-				ld_var(_barebox_image_size));
+				ld_var(_barebox_image_size),
+				pagesize_2k);
 	}
 
 	imx27_barebox_entry(0);
@@ -381,11 +369,19 @@ void __bare_init __noreturn imx27_barebox_boot_nand_external(void)
 void __bare_init __noreturn imx31_barebox_boot_nand_external(void)
 {
 	unsigned long nfc_base = MX31_NFC_BASE_ADDR;
+	int pagesize_2k;
 
 	if (imx_barebox_boot_nand_external(nfc_base)) {
 		jump_sdram(nfc_base - ld_var(_text));
+
+		if (readl(MX31_CCM_BASE_ADDR + MX31_CCM_RCSR) & MX31_RCSR_NFMS)
+			pagesize_2k = 1;
+		else
+			pagesize_2k = 0;
+
 		imx_nand_load_image((void *)ld_var(_text),
-				ld_var(_barebox_image_size));
+				ld_var(_barebox_image_size),
+				pagesize_2k);
 	}
 
 	imx31_barebox_entry(0);
@@ -396,11 +392,19 @@ void __bare_init __noreturn imx31_barebox_boot_nand_external(void)
 void __bare_init __noreturn imx35_barebox_boot_nand_external(void)
 {
 	unsigned long nfc_base = MX35_NFC_BASE_ADDR;
+	int pagesize_2k;
 
 	if (imx_barebox_boot_nand_external(nfc_base)) {
 		jump_sdram(nfc_base - ld_var(_text));
+
+		if (readl(MX35_CCM_BASE_ADDR + MX35_CCM_RCSR) & (1 << 8))
+			pagesize_2k = 1;
+		else
+			pagesize_2k = 0;
+
 		imx_nand_load_image((void *)ld_var(_text),
-				ld_var(_barebox_image_size));
+				ld_var(_barebox_image_size),
+				pagesize_2k);
 	}
 
 	imx35_barebox_entry(0);
-- 
1.8.3.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2013-07-09  9:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09  9:54 [PATCH] i.MX external nand boot Sascha Hauer
2013-07-09  9:54 ` [PATCH 1/6] Revert "ARM: i.MX27 pcm038: switch to multi image" Sascha Hauer
2013-07-09  9:54 ` [PATCH 2/6] ARM: i.MX: External Nand boot: make 2k support nonoptional Sascha Hauer
2013-07-09  9:54 ` Sascha Hauer [this message]
2013-07-09  9:54 ` [PATCH 4/6] ARM: i.MX: External Nand boot: remove debug command Sascha Hauer
2013-07-09  9:54 ` [PATCH 5/6] ARM: i.MX: External Nand boot: remove ifdefs Sascha Hauer
2013-07-09  9:54 ` [PATCH 6/6] ARM: i.MX: External Nand boot: remove ifdefs around SoC functions 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=1373363682-24449-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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