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 02/13] ARM i.MX nand layout: make multisoc safe
Date: Thu, 11 Oct 2012 09:13:30 +0200	[thread overview]
Message-ID: <1349939621-17793-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1349939621-17793-1-git-send-email-s.hauer@pengutronix.de>

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

diff --git a/arch/arm/mach-imx/nand.c b/arch/arm/mach-imx/nand.c
index fff9a12..b347664 100644
--- a/arch/arm/mach-imx/nand.c
+++ b/arch/arm/mach-imx/nand.c
@@ -12,20 +12,20 @@
  */
 
 #include <common.h>
+#include <mach/generic.h>
 #include <mach/imx-regs.h>
 #include <io.h>
 
-#if defined(CONFIG_ARCH_IMX35) || defined (CONFIG_ARCH_IMX25)
-
 #define RCSR_NFC_FMS		(1 << 8)
 #define RCSR_NFC_4K		(1 << 9)
 #define RCSR_NFC_16BIT_SEL	(1 << 14)
 
-void imx_nand_set_layout(int writesize, int datawidth)
+static __maybe_unused void imx25_35_nand_set_layout(void __iomem *reg_rcsr,
+		int writesize, int datawidth)
 {
 	unsigned int rcsr;
 
-	rcsr = readl(IMX_CCM_BASE + CCM_RCSR);
+	rcsr = readl(reg_rcsr);
 
 	switch (writesize) {
 	case 512:
@@ -52,19 +52,18 @@ void imx_nand_set_layout(int writesize, int datawidth)
 		break;
 	}
 
-	writel(rcsr, IMX_CCM_BASE + CCM_RCSR);
+	writel(rcsr, reg_rcsr);
 }
 
-#elif defined(CONFIG_ARCH_IMX21) || defined (CONFIG_ARCH_IMX27)
-
 #define FMCR_NF_FMS		(1 << 5)
 #define FMCR_NF_16BIT_SEL	(1 << 4)
 
-void imx_nand_set_layout(int writesize, int datawidth)
+static __maybe_unused void imx21_27_nand_set_layout(void __iomem *reg_fmcr,
+		int writesize, int datawidth)
 {
 	unsigned int fmcr;
 
-	fmcr = FMCR;
+	fmcr = readl(reg_fmcr);
 
 	switch (writesize) {
 	case 512:
@@ -88,23 +87,29 @@ void imx_nand_set_layout(int writesize, int datawidth)
 		break;
 	}
 
-	FMCR = fmcr;
-}
-
-#elif defined CONFIG_ARCH_IMX51 || defined CONFIG_ARCH_IMX53
-
-void imx_nand_set_layout(int writesize, int datawidth)
-{
-	/* Just silence the compiler warning below. On i.MX51 we don't
-	 * have external boot.
-	 */
+	writel(fmcr, reg_fmcr);
 }
 
-#else
-#warning using empty imx_nand_set_layout(). NAND flash will not work properly if not booting from it
-
 void imx_nand_set_layout(int writesize, int datawidth)
 {
-}
-
+#ifdef CONFIG_ARCH_IMX21
+	if (cpu_is_mx21())
+		imx21_27_nand_set_layout((void *)(MX21_SYSCTRL_BASE_ADDR +
+					0x14), writesize, datawidth);
 #endif
+#ifdef CONFIG_ARCH_IMX27
+	if (cpu_is_mx27())
+		imx21_27_nand_set_layout((void *)(MX27_SYSCTRL_BASE_ADDR +
+					0x14), writesize, datawidth);
+#endif
+#ifdef CONFIG_ARCH_IMX25
+	if (cpu_is_mx25())
+		imx25_35_nand_set_layout((void *)MX25_CCM_BASE_ADDR +
+				CCM_RCSR, writesize, datawidth);
+#endif
+#ifdef CONFIG_ARCH_IMX35
+	if (cpu_is_mx35())
+		imx25_35_nand_set_layout((void *)MX35_CCM_BASE_ADDR +
+				CCM_RCSR, writesize, datawidth);
+#endif
+}
-- 
1.7.10.4


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

  parent reply	other threads:[~2012-10-11  7:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-11  7:13 [PATCH] Final i.MX register cleanup Sascha Hauer
2012-10-11  7:13 ` [PATCH 01/13] ARM i.MX: Use SoC specific base to access sdram controller registers Sascha Hauer
2012-10-11  7:13 ` Sascha Hauer [this message]
2012-10-11  7:13 ` [PATCH 03/13] ARM i.MX31: Cleanup remaining unprefixed registers Sascha Hauer
2012-10-11  7:13 ` [PATCH 04/13] ARM i.MX25: " Sascha Hauer
2012-10-11  7:13 ` [PATCH 05/13] ARM i.MX35: " Sascha Hauer
2012-10-11  7:13 ` [PATCH 06/13] ARM i.MX external nand boot: Use SoC specific base addresses Sascha Hauer
2012-10-11  7:13 ` [PATCH 07/13] ARM i.MX: remove unused improperly prefixed register defines Sascha Hauer
2012-10-11  7:13 ` [PATCH 08/13] ARM i.MX1: Cleanup remaining unprefixed registers Sascha Hauer
2012-10-11  7:13 ` [PATCH 09/13] ARM i.MX21: " Sascha Hauer
2012-10-11  7:13 ` [PATCH 10/13] ARM i.MX27: " Sascha Hauer
2012-10-11  7:13 ` [PATCH 11/13] ARM i.MX27: move PCCR gate registers to its only user Sascha Hauer
2012-10-11  7:13 ` [PATCH 12/13] ARM i.MX27: remove duplicate ESDCTL registers Sascha Hauer
2012-10-11  7:13 ` [PATCH 13/13] ARM i.MX: get rid of imx-regs.h 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=1349939621-17793-3-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