mtd/drivers/mtd/nand nand.c,1.85,1.86

gleixner at infradead.org gleixner at infradead.org
Wed May 19 16:17:43 EDT 2004


Update of /home/cvs/mtd/drivers/mtd/nand
In directory phoenix.infradead.org:/tmp/cvs-serv30935

Modified Files:
	nand.c 
Log Message:
Basic AND FLASH support

Index: nand.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- nand.c	6 May 2004 08:22:19 -0000	1.85
+++ nand.c	19 May 2004 20:17:40 -0000	1.86
@@ -4,6 +4,7 @@
  *  Overview:
  *   This is the generic MTD driver for NAND flash devices. It should be
  *   capable of working with almost all NAND chips currently available.
+ *   Basic support for AG-AND chips is provided.
  *   
  *	Additional technical information is available on
  *	http://www.linux-mtd.infradead.org/tech/nand.html
@@ -20,17 +21,21 @@
  *		Make reads over block boundaries work too
  *
  *  04-14-2004	tglx: first working version for 2k page size chips
+ *  
+ *  05-19-2004  tglx: Basic support for Renesas AG-AND chips
  *
  * Credits:
  *	David Woodhouse for adding multichip support  
  *	
  *	Aleph One Ltd. and Toby Churchill Ltd. for supporting the
- *	rework for 2K page size chips	
+ *	rework for 2K page size chips
  *
  * TODO:
  *	Enable cached programming for 2k page size chips
  *	Check, if mtd->ecctype should be set to MTD_ECC_HW
  *	if we have HW ecc support.
+ *	The AG-AND chips have nice features for speed improvement,
+ *	which are not supported yet. Read / program 4 pages in one go.
  *
  * $Id$
  *
@@ -1631,6 +1636,31 @@
 	return ret;
 }
 
+/* 
+ * NAND standard block erase command function
+ * 
+ */
+static void single_erase_cmd (struct mtd_info *mtd, int page)
+{
+	/* Send commands to erase a block */
+	this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page);
+	this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1);
+}
+
+/* 
+ * AND multi block erase command function
+ * Erase 4 consecutive blocks
+ */
+static void multi_erase_cmd (struct mtd_info *mtd, int page)
+{
+	/* Send commands to erase a block */
+	this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++);
+	this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++);
+	this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++);
+	this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page);
+	this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1);
+}
+ 
 /*
  * NAND erase a block
  * 
@@ -1702,10 +1732,8 @@
 		if (page >= this->pagebuf && this->pagebuf < (page + pages_per_block))  
 			this->pagebuf = -1;
 
-		/* Send commands to erase a page */
-		this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page & this->pagemask);
-		this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1);
-
+		this->erase_cmd (mtd, page & this->pagemask);
+		
 		status = this->waitfunc (mtd, this, FL_ERASING);
 
 		/* See if block erase succeeded */
@@ -1913,9 +1941,6 @@
 			/* Get buswidth information */
 			busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0;
 		
-			/* Do not replace user supplied command function ! */
-			if (this->cmdfunc == nand_command)
-				this->cmdfunc = nand_command_lp;
 		} else {
 			/* Old devices have this data hardcoded in the
 			 * device id table */
@@ -1949,10 +1974,22 @@
 
 		/* Get chip options */
 		this->options = nand_flash_ids[i].options;
-		/* Check if this is a not a samsung device */	
-		if (nand_maf_id != NAND_MFR_SAMSUNG)
+		/* Check if this is a not a samsung device. Do not clear the options
+		 * for chips which are not having an extended id.
+		 */	
+		if (nand_maf_id != NAND_MFR_SAMSUNG && !nand_flash_ids[i].pagesize)
 			this->options &= ~NAND_SAMSUNG_LP_OPTIONS;
 		
+		/* Check for AND chips with 4 page planes */
+		if (this->options & NAND_4PAGE_ARRAY)
+			this->erase_cmd = multi_erase_cmd;
+		else
+			this->erase_cmd = single_erase_cmd;
+
+		/* Do not replace user supplied command function ! */
+		if (this->pagesize > 512 && this->cmdfunc == nand_command)
+			this->cmdfunc = nand_command_lp;
+				
 		/* Try to identify manufacturer */
 		for (i = 0; nand_manuf_ids[i].id != 0x0; i++) {
 			if (nand_manuf_ids[i].id == nand_maf_id)




More information about the linux-mtd-cvs mailing list