mtd/include/linux/mtd nand.h,1.74,1.75

Vitaly Wool vwool at ru.mvista.com
Wed Nov 2 11:54:46 EST 2005


Update of /home/cvs/mtd/include/linux/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv25697/include/linux/mtd

Modified Files:
	nand.h 
Log Message:
Adding layout-based handling of NAND flash pages for hardware ECC support

The problem:
For hardware ECC, the OOB may be spread across the page as opposed to being
a single block of data *after* the actual data. Current implementation cannot
handle this.

Solution:
The solution proposed is to provide the `page_layout' field in nand_chip 
structure, that will point to array of structures

struct page_layout_item {
       int length;
       enum {
               ITEM_TYPE_DATA,
               ITEM_TYPE_OOB,
               ITEM_TYPE_ECC,
       } type;
};

So all the flash page handling becomes layout-based.

If a driver doesn't supply this array and wants to use HW ECC, the layouts
array is generated basing on eccbytes/eccsize.

Also fixed is the shift offset for nand_block_bad() handling of
badblockpos in case it's odd and the access is 16bit.



Index: nand.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/nand.h,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- nand.h	15 Sep 2005 13:58:50 -0000	1.74
+++ nand.h	2 Nov 2005 16:54:43 -0000	1.75
@@ -52,6 +52,8 @@
  * 			for BBT_AUTO_REFRESH.
  *  01-20-2005 dmarlin	added optional pointer to hardware specific callback for 
  *			extra error status checks.
+ *
+ *  11-01-2005 vwool	NAND page layouts introduces for HW ECC handling
  */
 #ifndef __LINUX_MTD_NAND_H
 #define __LINUX_MTD_NAND_H
@@ -157,13 +159,22 @@
 #define NAND_ECC_HW3_256	2
 /* Hardware ECC 3 byte ECC per 512 Byte data */
 #define NAND_ECC_HW3_512	3
-/* Hardware ECC 3 byte ECC per 512 Byte data */
+/* Hardware ECC 6 byte ECC per 512 Byte data */
 #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
 
+struct page_layout_item {
+	int length;
+	enum {
+		ITEM_TYPE_DATA, 
+		ITEM_TYPE_OOB, 
+		ITEM_TYPE_ECC,
+	} type;
+}; 
+
 /*
  * Constants for Hardware ECC
  */
@@ -173,6 +184,9 @@
 #define NAND_ECC_WRITE		1
 /* Enable Hardware ECC before syndrom is read back from flash */
 #define NAND_ECC_READSYN	2
+#define NAND_ECC_WRITESYN	3
+#define NAND_ECC_READOOB	4
+#define NAND_ECC_WRITEOOB	5
 
 /* Bit mask for flags passed to do_nand_read_ecc */
 #define NAND_GET_DEVICE		0x80
@@ -370,6 +384,8 @@
 	int		pagemask;
 	int		pagebuf;
 	struct nand_oobinfo	*autooob;
+	struct page_layout_item *layout;
+	int		layout_allocated;
 	uint8_t		*bbt;
 	struct nand_bbt_descr	*bbt_td;
 	struct nand_bbt_descr	*bbt_md;





More information about the linux-mtd-cvs mailing list