aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorKyungmin Park <kyungmin.park@samsung.com>2010-12-01 19:24:16 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-12-03 11:35:50 -0500
commit8a8f632d8534d0c403831341450bd8db9e842f05 (patch)
tree6ab5690d9aa4c02395dc81bb154c4a679b1e1ac0 /drivers/mtd
parentb5602e86432aaf0cc90dd207bf74e3a2bfb5078b (diff)
mtd: OneNAND: Fix 4KiB pagesize OOB handling
Original 4KiB pagesize chip (SLC) doesn't support OOB operations at Spec. And it's also same at Flex-OneNAND. Remove the MLC macro if possible and use 4KiB pagesize macro since MLC has 4KiB pagesize. Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/onenand/onenand_base.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 4d6e6c54cc2c..c38bf9c54a11 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -400,8 +400,7 @@ static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t le
400 value = onenand_bufferram_address(this, block); 400 value = onenand_bufferram_address(this, block);
401 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2); 401 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
402 402
403 if (ONENAND_IS_MLC(this) || ONENAND_IS_2PLANE(this) || 403 if (ONENAND_IS_2PLANE(this) || ONENAND_IS_4KB_PAGE(this))
404 ONENAND_IS_4KB_PAGE(this))
405 /* It is always BufferRAM0 */ 404 /* It is always BufferRAM0 */
406 ONENAND_SET_BUFFERRAM0(this); 405 ONENAND_SET_BUFFERRAM0(this);
407 else 406 else
@@ -430,7 +429,7 @@ static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t le
430 case FLEXONENAND_CMD_RECOVER_LSB: 429 case FLEXONENAND_CMD_RECOVER_LSB:
431 case ONENAND_CMD_READ: 430 case ONENAND_CMD_READ:
432 case ONENAND_CMD_READOOB: 431 case ONENAND_CMD_READOOB:
433 if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this)) 432 if (ONENAND_IS_4KB_PAGE(this))
434 /* It is always BufferRAM0 */ 433 /* It is always BufferRAM0 */
435 dataram = ONENAND_SET_BUFFERRAM0(this); 434 dataram = ONENAND_SET_BUFFERRAM0(this);
436 else 435 else
@@ -1353,7 +1352,7 @@ static int onenand_read_oob_nolock(struct mtd_info *mtd, loff_t from,
1353 1352
1354 stats = mtd->ecc_stats; 1353 stats = mtd->ecc_stats;
1355 1354
1356 readcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB; 1355 readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1357 1356
1358 while (read < len) { 1357 while (read < len) {
1359 cond_resched(); 1358 cond_resched();
@@ -1429,7 +1428,7 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
1429 int ret; 1428 int ret;
1430 1429
1431 onenand_get_device(mtd, FL_READING); 1430 onenand_get_device(mtd, FL_READING);
1432 ret = ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this) ? 1431 ret = ONENAND_IS_4KB_PAGE(this) ?
1433 onenand_mlc_read_ops_nolock(mtd, from, &ops) : 1432 onenand_mlc_read_ops_nolock(mtd, from, &ops) :
1434 onenand_read_ops_nolock(mtd, from, &ops); 1433 onenand_read_ops_nolock(mtd, from, &ops);
1435 onenand_release_device(mtd); 1434 onenand_release_device(mtd);
@@ -1464,7 +1463,7 @@ static int onenand_read_oob(struct mtd_info *mtd, loff_t from,
1464 1463
1465 onenand_get_device(mtd, FL_READING); 1464 onenand_get_device(mtd, FL_READING);
1466 if (ops->datbuf) 1465 if (ops->datbuf)
1467 ret = ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this) ? 1466 ret = ONENAND_IS_4KB_PAGE(this) ?
1468 onenand_mlc_read_ops_nolock(mtd, from, ops) : 1467 onenand_mlc_read_ops_nolock(mtd, from, ops) :
1469 onenand_read_ops_nolock(mtd, from, ops); 1468 onenand_read_ops_nolock(mtd, from, ops);
1470 else 1469 else
@@ -1558,7 +1557,7 @@ int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from,
1558 1557
1559 column = from & (mtd->oobsize - 1); 1558 column = from & (mtd->oobsize - 1);
1560 1559
1561 readcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB; 1560 readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1562 1561
1563 while (read < len) { 1562 while (read < len) {
1564 cond_resched(); 1563 cond_resched();
@@ -1612,7 +1611,7 @@ static int onenand_verify_oob(struct mtd_info *mtd, const u_char *buf, loff_t to
1612 u_char *oob_buf = this->oob_buf; 1611 u_char *oob_buf = this->oob_buf;
1613 int status, i, readcmd; 1612 int status, i, readcmd;
1614 1613
1615 readcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB; 1614 readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB;
1616 1615
1617 this->command(mtd, readcmd, to, mtd->oobsize); 1616 this->command(mtd, readcmd, to, mtd->oobsize);
1618 onenand_update_bufferram(mtd, to, 0); 1617 onenand_update_bufferram(mtd, to, 0);
@@ -2079,7 +2078,7 @@ static int onenand_write_oob_nolock(struct mtd_info *mtd, loff_t to,
2079 2078
2080 oobbuf = this->oob_buf; 2079 oobbuf = this->oob_buf;
2081 2080
2082 oobcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_PROG : ONENAND_CMD_PROGOOB; 2081 oobcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_PROG : ONENAND_CMD_PROGOOB;
2083 2082
2084 /* Loop until all data write */ 2083 /* Loop until all data write */
2085 while (written < len) { 2084 while (written < len) {
@@ -2098,7 +2097,7 @@ static int onenand_write_oob_nolock(struct mtd_info *mtd, loff_t to,
2098 memcpy(oobbuf + column, buf, thislen); 2097 memcpy(oobbuf + column, buf, thislen);
2099 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize); 2098 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize);
2100 2099
2101 if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this)) { 2100 if (ONENAND_IS_4KB_PAGE(this)) {
2102 /* Set main area of DataRAM to 0xff*/ 2101 /* Set main area of DataRAM to 0xff*/
2103 memset(this->page_buf, 0xff, mtd->writesize); 2102 memset(this->page_buf, 0xff, mtd->writesize);
2104 this->write_bufferram(mtd, ONENAND_DATARAM, 2103 this->write_bufferram(mtd, ONENAND_DATARAM,
@@ -3041,7 +3040,7 @@ static int do_otp_read(struct mtd_info *mtd, loff_t from, size_t len,
3041 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); 3040 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
3042 this->wait(mtd, FL_OTPING); 3041 this->wait(mtd, FL_OTPING);
3043 3042
3044 ret = ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this) ? 3043 ret = ONENAND_IS_4KB_PAGE(this) ?
3045 onenand_mlc_read_ops_nolock(mtd, from, &ops) : 3044 onenand_mlc_read_ops_nolock(mtd, from, &ops) :
3046 onenand_read_ops_nolock(mtd, from, &ops); 3045 onenand_read_ops_nolock(mtd, from, &ops);
3047 3046
@@ -3413,7 +3412,11 @@ static void onenand_check_features(struct mtd_info *mtd)
3413 break; 3412 break;
3414 } 3413 }
3415 3414
3416 if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this)) 3415 /* The MLC has 4KiB pagesize. */
3416 if (ONENAND_IS_MLC(this))
3417 this->options |= ONENAND_HAS_4KB_PAGE;
3418
3419 if (ONENAND_IS_4KB_PAGE(this))
3417 this->options &= ~ONENAND_HAS_2PLANE; 3420 this->options &= ~ONENAND_HAS_2PLANE;
3418 3421
3419 if (FLEXONENAND(this)) { 3422 if (FLEXONENAND(this)) {
@@ -3847,7 +3850,7 @@ static int onenand_probe(struct mtd_info *mtd)
3847 /* The data buffer size is equal to page size */ 3850 /* The data buffer size is equal to page size */
3848 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE); 3851 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
3849 /* We use the full BufferRAM */ 3852 /* We use the full BufferRAM */
3850 if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this)) 3853 if (ONENAND_IS_4KB_PAGE(this))
3851 mtd->writesize <<= 1; 3854 mtd->writesize <<= 1;
3852 3855
3853 mtd->oobsize = mtd->writesize >> 5; 3856 mtd->oobsize = mtd->writesize >> 5;