public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] Add NAND_ECC_HW12_2048
@ 2004-11-01  7:46 Juha Yrjölä
  0 siblings, 0 replies; only message in thread
From: Juha Yrjölä @ 2004-11-01  7:46 UTC (permalink / raw)
  To: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 139 bytes --]

Hi,

The attached patch adds support for ECC hardware that generates 12 bytes
of ECC per 2048 bytes of data.

Please apply.

Cheers,
Juha


[-- Attachment #2: mtd-nand-hw-ecc-2048.diff --]
[-- Type: text/x-patch, Size: 2905 bytes --]

===== include/linux/mtd/nand.h 1.6 vs edited =====
--- 1.6/include/linux/mtd/nand.h	2004-10-26 13:39:12 +03:00
+++ edited/include/linux/mtd/nand.h	2004-10-30 07:57:23 +03:00
@@ -138,6 +138,8 @@
 #define NAND_ECC_HW6_512	4
 /* Hardware ECC 8 byte ECC per 512 Byte data */
 #define NAND_ECC_HW8_512	6
+/* Hardware ECC 12 byte ECC per 2048 Byte data */
+#define NAND_ECC_HW12_2048	7
 
 /*
  * Constants for Hardware ECC
===== drivers/mtd/nand/nand_base.c 1.11 vs edited =====
--- 1.11/drivers/mtd/nand/nand_base.c	2004-10-26 13:39:12 +03:00
+++ edited/drivers/mtd/nand/nand_base.c	2004-10-31 21:06:36 +02:00
@@ -840,7 +840,10 @@
 		}
 		this->write_buf(mtd, this->data_poi, mtd->oobblock);
 		break;
-		
+
+	/* Hardware ECC 12 byte / 2048 byte data */
+	case NAND_ECC_HW12_2048:
+		eccbytes += 4;
 	/* Hardware ecc 8 byte / 512 byte data */	
 	case NAND_ECC_HW8_512:	
 		eccbytes += 2;
@@ -1099,6 +1102,9 @@
 	case NAND_ECC_HW8_512: /* Hardware ECC 8 byte / 512 byte data  */
 		eccbytes = 8;
 		break;
+	case NAND_ECC_HW12_2048: /* Hardware ECC 8 byte / 512 byte data  */
+		eccbytes = 12;
+		break;
 	case NAND_ECC_NONE:
 		compareecc = 0;
 		break;						
@@ -1164,13 +1170,14 @@
 			for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=3, datidx += ecc) 
 				this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]);
 			break;	
-			
-		case NAND_ECC_HW3_256: /* Hardware ECC 3 byte /256 byte data */
-		case NAND_ECC_HW3_512: /* Hardware ECC 3 byte /512 byte data */	
+
+		case NAND_ECC_HW12_2048: /* Hardware ECC 12 byte / 2048 byte data */
+		case NAND_ECC_HW3_256: /* Hardware ECC 3 byte / 256 byte data */
+		case NAND_ECC_HW3_512: /* Hardware ECC 3 byte / 512 byte data */
 		case NAND_ECC_HW6_512: /* Hardware ECC 6 byte / 512 byte data  */
 		case NAND_ECC_HW8_512: /* Hardware ECC 8 byte / 512 byte data  */
 			for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=eccbytes, datidx += ecc) {
-				this->enable_hwecc(mtd, NAND_ECC_READ);	
+				this->enable_hwecc(mtd, NAND_ECC_READ);
 				this->read_buf(mtd, &data_poi[datidx], ecc);
 
 				/* HW ecc with syndrome calculation must read the
@@ -2435,6 +2442,17 @@
 	this->eccsize = 256;	/* set default eccsize */	
 
 	switch (this->eccmode) {
+	case NAND_ECC_HW12_2048:
+		if (mtd->oobblock < 2048) {
+			printk(KERN_WARNING "2048 byte HW ECC not possible on %d byte page size, fallback to SW ECC\n",
+			       mtd->oobblock);
+			this->eccmode = NAND_ECC_SOFT;
+			this->calculate_ecc = nand_calculate_ecc;
+			this->correct_data = nand_correct_data;
+			break;
+		} else
+			this->eccsize = 2048;
+		break;
 
 	case NAND_ECC_HW3_512: 
 	case NAND_ECC_HW6_512: 
@@ -2473,6 +2491,9 @@
 	
 	/* Set the number of read / write steps for one page to ensure ECC generation */
 	switch (this->eccmode) {
+	case NAND_ECC_HW12_2048:
+		this->eccsteps = mtd->oobblock / 2048;
+		break;
 	case NAND_ECC_HW3_512:
 	case NAND_ECC_HW6_512:
 	case NAND_ECC_HW8_512:

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-01  7:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-01  7:46 [PATCH] Add NAND_ECC_HW12_2048 Juha Yrjölä

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox