mtd/drivers/mtd/onenand onenand_base.c,1.5,1.6

kyungmin.park at samsung.com kyungmin.park at samsung.com
Wed Sep 28 23:53:16 EDT 2005


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

Modified Files:
	onenand_base.c 
Log Message:
[OneNAND] More fancy handling of DDP

Add density mask


Index: onenand_base.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/onenand/onenand_base.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- onenand_base.c	29 Sep 2005 02:55:27 -0000	1.5
+++ onenand_base.c	29 Sep 2005 03:53:12 -0000	1.6
@@ -84,25 +84,23 @@
 
 /**
  * onenand_block_address - [DEFAULT] Get block address
- * @param device	the device id
+ * @param this		onenand chip data structure
  * @param block		the block
  * @return		translated block address if DDP, otherwise same
  *
  * Setup Start Address 1 Register (F100h)
  */
-static int onenand_block_address(int device, int block)
+static int onenand_block_address(struct onenand_chip *this, int block)
 {
-	if (device & ONENAND_DEVICE_IS_DDP) {
+	if (this->device_id & ONENAND_DEVICE_IS_DDP) {
 		/* Device Flash Core select, NAND Flash Block Address */
-		int dfs = 0, density, mask;
+		int dfs = 0;
 
-		density = device >> ONENAND_DEVICE_DENSITY_SHIFT;
-		mask = (1 << (density + 6));
-
-		if (block & mask)
+		if (block & this->density_mask)
 			dfs = 1;
 
-		return (dfs << ONENAND_DDP_SHIFT) | (block & (mask - 1));
+		return (dfs << ONENAND_DDP_SHIFT) |
+			(block & (this->density_mask - 1));
 	}
 
 	return block;
@@ -110,22 +108,19 @@
 
 /**
  * onenand_bufferram_address - [DEFAULT] Get bufferram address
- * @param device	the device id
+ * @param this		onenand chip data structure
  * @param block		the block
  * @return		set DBS value if DDP, otherwise 0
  *
  * Setup Start Address 2 Register (F101h) for DDP
  */
-static int onenand_bufferram_address(int device, int block)
+static int onenand_bufferram_address(struct onenand_chip *this, int block)
 {
-	if (device & ONENAND_DEVICE_IS_DDP) {
+	if (this->device_id & ONENAND_DEVICE_IS_DDP) {
 		/* Device BufferRAM Select */
-		int dbs = 0, density, mask;
-
-		density = device >> ONENAND_DEVICE_DENSITY_SHIFT;
-		mask = (1 << (density + 6));
+		int dbs = 0;
 
-		if (block & mask)
+		if (block & this->density_mask)
 			dbs = 1;
 
 		return (dbs << ONENAND_DDP_SHIFT);
@@ -223,7 +218,7 @@
 	/* NOTE: The setting order of the registers is very important! */
 	if (cmd == ONENAND_CMD_BUFFERRAM) {
 		/* Select DataRAM for DDP */
-		value = onenand_bufferram_address(this->device_id, block);
+		value = onenand_bufferram_address(this, block);
 		this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
 
 		/* Switch to the next data buffer */
@@ -234,7 +229,7 @@
 
 	if (block != -1) {
 		/* Write 'DFS, FBA' of Flash */
-		value = onenand_block_address(this->device_id, block);
+		value = onenand_block_address(this, block);
 		this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
 	}
 
@@ -263,7 +258,7 @@
 			
 		if (readcmd) {
 			/* Select DataRAM for DDP */
-			value = onenand_bufferram_address(this->device_id, block);
+			value = onenand_bufferram_address(this, block);
 			this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
 		}
 	}
@@ -1313,7 +1308,7 @@
 			continue;
 
 		/* Set block address for read block status */
-		value = onenand_block_address(this->device_id, block);
+		value = onenand_block_address(this, block);
 		this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
 
 		/* Check lock status */
@@ -1415,6 +1410,8 @@
 
 	density = dev_id >> ONENAND_DEVICE_DENSITY_SHIFT;
 	this->chipsize = (16 << density) << 20;
+	/* Set density mask. it is used for DDP */
+	this->density_mask = (1 << (density + 6));
 
 	/* OneNAND page size & block size */
 	/* The data buffer size is equal to page size */





More information about the linux-mtd-cvs mailing list