Commit 738d61f5 authored by Kyungmin Park's avatar Kyungmin Park

[MTD] OneNAND: Reduce Double Density Package (DDP) operations

- DDP code clean-up
- Reduce block & bufferram operations in DDP
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
parent 9d032801
...@@ -94,16 +94,9 @@ static void onenand_writew(unsigned short value, void __iomem *addr) ...@@ -94,16 +94,9 @@ static void onenand_writew(unsigned short value, void __iomem *addr)
*/ */
static int onenand_block_address(struct onenand_chip *this, int block) static int onenand_block_address(struct onenand_chip *this, int block)
{ {
if (this->device_id & ONENAND_DEVICE_IS_DDP) { /* Device Flash Core select, NAND Flash Block Address */
/* Device Flash Core select, NAND Flash Block Address */ if (block & this->density_mask)
int dfs = 0; return ONENAND_DDP_CHIP1 | (block ^ this->density_mask);
if (block & this->density_mask)
dfs = 1;
return (dfs << ONENAND_DDP_SHIFT) |
(block & (this->density_mask - 1));
}
return block; return block;
} }
...@@ -118,17 +111,11 @@ static int onenand_block_address(struct onenand_chip *this, int block) ...@@ -118,17 +111,11 @@ static int onenand_block_address(struct onenand_chip *this, int block)
*/ */
static int onenand_bufferram_address(struct onenand_chip *this, int block) static int onenand_bufferram_address(struct onenand_chip *this, int block)
{ {
if (this->device_id & ONENAND_DEVICE_IS_DDP) { /* Device BufferRAM Select */
/* Device BufferRAM Select */ if (block & this->density_mask)
int dbs = 0; return ONENAND_DDP_CHIP1;
if (block & this->density_mask)
dbs = 1;
return (dbs << ONENAND_DDP_SHIFT); return ONENAND_DDP_CHIP0;
}
return 0;
} }
/** /**
...@@ -757,9 +744,9 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -757,9 +744,9 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
* Now we issued chip 1 read and pointed chip 1 * Now we issued chip 1 read and pointed chip 1
* bufferam so we have to point chip 0 bufferam. * bufferam so we have to point chip 0 bufferam.
*/ */
if (this->device_id & ONENAND_DEVICE_IS_DDP && if (ONENAND_IS_DDP(this) &&
unlikely(from == (this->chipsize >> 1))) { unlikely(from == (this->chipsize >> 1))) {
this->write_word(0, this->base + ONENAND_REG_START_ADDRESS2); this->write_word(ONENAND_DDP_CHIP0, this->base + ONENAND_REG_START_ADDRESS2);
boundary = 1; boundary = 1;
} else } else
boundary = 0; boundary = 0;
...@@ -773,7 +760,7 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len, ...@@ -773,7 +760,7 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
break; break;
/* Set up for next read from bufferRAM */ /* Set up for next read from bufferRAM */
if (unlikely(boundary)) if (unlikely(boundary))
this->write_word(0x8000, this->base + ONENAND_REG_START_ADDRESS2); this->write_word(ONENAND_DDP_CHIP1, this->base + ONENAND_REG_START_ADDRESS2);
ONENAND_SET_NEXT_BUFFERRAM(this); ONENAND_SET_NEXT_BUFFERRAM(this);
buf += thislen; buf += thislen;
thislen = min_t(int, mtd->writesize, len - read); thislen = min_t(int, mtd->writesize, len - read);
...@@ -1508,7 +1495,7 @@ static int onenand_unlock_all(struct mtd_info *mtd) ...@@ -1508,7 +1495,7 @@ static int onenand_unlock_all(struct mtd_info *mtd)
continue; continue;
/* Workaround for all block unlock in DDP */ /* Workaround for all block unlock in DDP */
if (this->device_id & ONENAND_DEVICE_IS_DDP) { if (ONENAND_IS_DDP(this)) {
/* 1st block on another chip */ /* 1st block on another chip */
loff_t ofs = this->chipsize >> 1; loff_t ofs = this->chipsize >> 1;
size_t len = mtd->erasesize; size_t len = mtd->erasesize;
...@@ -1963,7 +1950,10 @@ static int onenand_probe(struct mtd_info *mtd) ...@@ -1963,7 +1950,10 @@ static int onenand_probe(struct mtd_info *mtd)
density = dev_id >> ONENAND_DEVICE_DENSITY_SHIFT; density = dev_id >> ONENAND_DEVICE_DENSITY_SHIFT;
this->chipsize = (16 << density) << 20; this->chipsize = (16 << density) << 20;
/* Set density mask. it is used for DDP */ /* Set density mask. it is used for DDP */
this->density_mask = (1 << (density + 6)); if (ONENAND_IS_DDP(this))
this->density_mask = (1 << (density + 6));
else
this->density_mask = 0;
/* OneNAND page size & block size */ /* OneNAND page size & block size */
/* The data buffer size is equal to page size */ /* The data buffer size is equal to page size */
......
...@@ -150,6 +150,9 @@ struct onenand_chip { ...@@ -150,6 +150,9 @@ struct onenand_chip {
#define ONENAND_SET_SYS_CFG1(v, this) \ #define ONENAND_SET_SYS_CFG1(v, this) \
(this->write_word(v, this->base + ONENAND_REG_SYS_CFG1)) (this->write_word(v, this->base + ONENAND_REG_SYS_CFG1))
#define ONENAND_IS_DDP(this) \
(this->device_id & ONENAND_DEVICE_IS_DDP)
/* Check byte access in OneNAND */ /* Check byte access in OneNAND */
#define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) #define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1)
......
...@@ -80,9 +80,11 @@ ...@@ -80,9 +80,11 @@
#define ONENAND_VERSION_PROCESS_SHIFT (8) #define ONENAND_VERSION_PROCESS_SHIFT (8)
/* /*
* Start Address 1 F100h (R/W) * Start Address 1 F100h (R/W) & Start Address 2 F101h (R/W)
*/ */
#define ONENAND_DDP_SHIFT (15) #define ONENAND_DDP_SHIFT (15)
#define ONENAND_DDP_CHIP0 (0)
#define ONENAND_DDP_CHIP1 (1 << ONENAND_DDP_SHIFT)
/* /*
* Start Address 8 F107h (R/W) * Start Address 8 F107h (R/W)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment