All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean MacLennan <smaclennan@pikatech.com>
Cc: linuxppc-dev@ozlabs.org, Stefan Roese <sr@denx.de>
Subject: Re: [PATCH] MTD for Taco
Date: Wed, 16 Jan 2008 16:25:23 -0500	[thread overview]
Message-ID: <478E7643.5040804@pikatech.com> (raw)
In-Reply-To: <478AEB39.70106@pikatech.com>

Sean MacLennan wrote:
> How about adding a config option that lets you specify 8 bit access? 
> Something like CONFIG_NDFC_8BIT_ACCESS. We could default it to no and 
> put a little blurb that says something like:
>
> On some platforms the 32bit read/writes cause a machine access 
> exception. If you get a machine access exception while reading the NAND 
> bad block table, try turning on 8 bit access.
>   
I know it would be better if 32 bit access just worked, but nobody 
actively objected to this idea, so here is a patch ;)

Cheers,
   Sean

Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
---
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 246d451..2809ded 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -153,11 +153,21 @@ config MTD_NAND_S3C2410_HWECC
 
 config MTD_NAND_NDFC
 	tristate "NDFC NanD Flash Controller"
-	depends on 4xx && !PPC_MERGE
+	depends on 4xx
 	select MTD_NAND_ECC_SMC
 	help
 	 NDFC Nand Flash Controllers are integrated in IBM/AMCC's 4xx SoCs
 
+config NDFC_8BIT_ACCESS
+	bool "NDFC 8-bit access only"
+	depends on MTD_NAND_NDFC
+	default n
+	help
+	 The NDFC supports 32 bit read/writes to the NAND to improve
+	 performance. On some platforms this does not work. If you get
+	 a machine access exception while reading the bad block table,
+	 try setting this to Y.
+
 config MTD_NAND_S3C2410_CLKSTOP
 	bool "S3C2410 NAND IDLE clock stop"
 	depends on MTD_NAND_S3C2410
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 1c0e89f..ac06099 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -24,11 +24,13 @@
 #include <linux/platform_device.h>
 
 #include <asm/io.h>
+#ifndef CONFIG_PPC_MERGE
 #ifdef CONFIG_40x
 #include <asm/ibm405.h>
 #else
 #include <asm/ibm44x.h>
 #endif
+#endif
 
 struct ndfc_nand_mtd {
 	struct mtd_info			mtd;
@@ -110,6 +112,37 @@ static int ndfc_calculate_ecc(struct mtd_info *mtd,
 	return 0;
 }
 
+#ifdef CONFIG_NDFC_8BIT_ACCESS
+static void ndfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
+{
+	struct ndfc_controller *ndfc = &ndfc_ctrl;
+	uint8_t *p = (uint8_t *) buf;
+
+	for (; len > 0; len--)
+		*p++ = __raw_readb(ndfc->ndfcbase + NDFC_DATA);
+}
+
+static void ndfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
+{
+	struct ndfc_controller *ndfc = &ndfc_ctrl;
+	uint8_t *p = (uint8_t *) buf;
+
+	for (; len > 0; len--)
+		__raw_writeb(*p++, ndfc->ndfcbase + NDFC_DATA);
+}
+
+static int ndfc_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
+{
+	struct ndfc_controller *ndfc = &ndfc_ctrl;
+	uint8_t *p = (uint8_t *) buf;
+
+	for (; len > 0; len--)
+		if (*p++ != __raw_readb(ndfc->ndfcbase + NDFC_DATA))
+			return -EFAULT;
+
+	return 0;
+}
+#else
 /*
  * Speedups for buffer read/write/verify
  *
@@ -145,6 +178,7 @@ static int ndfc_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
 			return -EFAULT;
 	return 0;
 }
+#endif
 
 /*
  * Initialize chip structure
@@ -236,6 +270,8 @@ static int ndfc_nand_probe(struct platform_device *pdev)
 
 #ifndef CONFIG_PHYS_64BIT
 	ndfc->ndfcbase = ioremap((phys_addr_t)phys, res->end - res->start + 1);
+#elif defined(CONFIG_PPC_MERGE)
+	ndfc->ndfcbase = ioremap(phys, res->end - res->start + 1);
 #else
 	ndfc->ndfcbase = ioremap64(phys, res->end - res->start + 1);
 #endif

  parent reply	other threads:[~2008-01-16 21:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-05  5:17 [PATCH] MTD for Taco Sean MacLennan
2008-01-05  9:41 ` Stefan Roese
2008-01-05 12:25   ` David Gibson
2008-01-06  3:20     ` Sean MacLennan
2008-01-06  3:44       ` David Gibson
2008-01-05 18:20   ` Sean MacLennan
2008-01-05 19:19     ` Arnd Bergmann
2008-01-09 18:05   ` Sean MacLennan
2008-01-09 18:42     ` Josh Boyer
2008-01-09 18:50       ` Sean MacLennan
2008-01-09 19:04         ` Josh Boyer
2008-01-14  4:55   ` Sean MacLennan
2008-01-14  8:44     ` Josh Boyer
2008-01-14 17:32       ` Sean MacLennan
2008-01-14 19:42         ` Stefan Roese
2008-01-14 20:04           ` Sean MacLennan
2008-01-15  5:15             ` Stefan Roese
2008-01-15  6:30               ` Sean MacLennan
2008-01-15  6:39                 ` Stefan Roese
2008-01-15 18:22                   ` Sean MacLennan
2008-01-16 21:25     ` Sean MacLennan [this message]
2008-01-16 23:34       ` Josh Boyer
2008-01-16 23:51         ` Sean MacLennan

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=478E7643.5040804@pikatech.com \
    --to=smaclennan@pikatech.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=sr@denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.