diff mbox

[1/3] mxc_nand: set spare size and pages per block

Message ID 80r5i63dn4.fsf@merkur.tec.linutronix.de
State New, archived
Headers show

Commit Message

John Ogness Aug. 10, 2010, 11:34 a.m. UTC
This patch sets the NFC registers for spare size and pages per block.

This patch is against the latest patches from Sascha Hauer.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 drivers/mtd/nand/mxc_nand.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

Sascha Hauer Aug. 10, 2010, 12:19 p.m. UTC | #1
Hi John,

Sorry, last time I sent only up to 09/12, so the patches I explicitely
mentioned to solve the things from your previous series were missing.
I just sent them. My versions of the patches differ slightly. For this
patch I decided to initialize every bit in NFC_V1_V2_CONFIG1 from
scratch so that we do not depend on any reset or bootloader values.
I think this is cleaner so I propose that we use my version of the
patch.

Sascha
Artem Bityutskiy Aug. 29, 2010, 12:08 p.m. UTC | #2
On Tue, 2010-08-10 at 13:34 +0200, John Ogness wrote:
> This patch sets the NFC registers for spare size and pages per block.
> 
> This patch is against the latest patches from Sascha Hauer.
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>
> ---
>  drivers/mtd/nand/mxc_nand.c |   32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)

I'm not picking your patches and assume they'll be sent by Sascha.
diff mbox

Patch

Index: linux-2.6-454a740/drivers/mtd/nand/mxc_nand.c
===================================================================
--- linux-2.6-454a740.orig/drivers/mtd/nand/mxc_nand.c
+++ linux-2.6-454a740/drivers/mtd/nand/mxc_nand.c
@@ -68,6 +68,8 @@ 
 #define NFC_V1_V2_CONFIG1_RST		(1 << 6)
 #define NFC_V1_V2_CONFIG1_CE		(1 << 7)
 #define NFC_V1_V2_CONFIG1_ONE_CYCLE	(1 << 8)
+#define NFC_V1_V2_CONFIG1_PPB_SHIFT	9
+#define NFC_V1_V2_CONFIG1_PPB_MASK	0x3
 
 #define NFC_V1_V2_CONFIG2_INT		(1 << 15)
 
@@ -749,7 +751,37 @@  static void preset_v1_v2(struct mtd_info
 		host->eccsize = 1;
 	}
 
+	if (nfc_is_v21() && mtd->writesize) {
+		/* setup pages per block */
+		tmp &= ~(NFC_V1_V2_CONFIG1_PPB_MASK <<
+					NFC_V1_V2_CONFIG1_PPB_SHIFT);
+		switch (mtd->erasesize / mtd->writesize) {
+		case 32:
+			/* PPB set to 0 */
+			break;
+		case 64:
+			tmp |= 1 << NFC_V1_V2_CONFIG1_PPB_SHIFT;
+			break;
+		case 256:
+			tmp |= 3 << NFC_V1_V2_CONFIG1_PPB_SHIFT;
+			break;
+		default:
+			/* 128 (reset value) */
+			tmp |= 2 << NFC_V1_V2_CONFIG1_PPB_SHIFT;
+			break;
+		}
+	}
+
 	writew(tmp, NFC_V1_V2_CONFIG1);
+
+	if (nfc_is_v21()) {
+		/* configure spare size (in 16-bit units) */
+		tmp = readw(NFC_V1_V2_RSLTSPARE_AREA);
+		tmp &= ~0xff;
+		tmp |= host->spare_len >> 1;
+		writew(tmp, NFC_V1_V2_RSLTSPARE_AREA);
+	}
+
 	/* preset operation */
 
 	/* Unlock the internal RAM Buffer */