aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/onenand
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/onenand')
-rw-r--r--drivers/mtd/onenand/onenand_base.c74
-rw-r--r--drivers/mtd/onenand/onenand_bbt.c4
2 files changed, 39 insertions, 39 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index fe5b48997275..4c2c61d54b3a 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -354,7 +354,7 @@ static inline int onenand_bufferram_offset(struct mtd_info *mtd, int area)
354 354
355 if (ONENAND_CURRENT_BUFFERRAM(this)) { 355 if (ONENAND_CURRENT_BUFFERRAM(this)) {
356 if (area == ONENAND_DATARAM) 356 if (area == ONENAND_DATARAM)
357 return mtd->oobblock; 357 return mtd->writesize;
358 if (area == ONENAND_SPARERAM) 358 if (area == ONENAND_SPARERAM)
359 return mtd->oobsize; 359 return mtd->oobsize;
360 } 360 }
@@ -632,14 +632,14 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
632 /* TODO handling oob */ 632 /* TODO handling oob */
633 633
634 while (read < len) { 634 while (read < len) {
635 thislen = min_t(int, mtd->oobblock, len - read); 635 thislen = min_t(int, mtd->writesize, len - read);
636 636
637 column = from & (mtd->oobblock - 1); 637 column = from & (mtd->writesize - 1);
638 if (column + thislen > mtd->oobblock) 638 if (column + thislen > mtd->writesize)
639 thislen = mtd->oobblock - column; 639 thislen = mtd->writesize - column;
640 640
641 if (!onenand_check_bufferram(mtd, from)) { 641 if (!onenand_check_bufferram(mtd, from)) {
642 this->command(mtd, ONENAND_CMD_READ, from, mtd->oobblock); 642 this->command(mtd, ONENAND_CMD_READ, from, mtd->writesize);
643 643
644 ret = this->wait(mtd, FL_READING); 644 ret = this->wait(mtd, FL_READING);
645 /* First copy data and check return value for ECC handling */ 645 /* First copy data and check return value for ECC handling */
@@ -752,7 +752,7 @@ static int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
752 /* Read more? */ 752 /* Read more? */
753 if (read < len) { 753 if (read < len) {
754 /* Page size */ 754 /* Page size */
755 from += mtd->oobblock; 755 from += mtd->writesize;
756 column = 0; 756 column = 0;
757 } 757 }
758 } 758 }
@@ -809,7 +809,7 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
809 void __iomem *dataram0, *dataram1; 809 void __iomem *dataram0, *dataram1;
810 int ret = 0; 810 int ret = 0;
811 811
812 this->command(mtd, ONENAND_CMD_READ, addr, mtd->oobblock); 812 this->command(mtd, ONENAND_CMD_READ, addr, mtd->writesize);
813 813
814 ret = this->wait(mtd, FL_READING); 814 ret = this->wait(mtd, FL_READING);
815 if (ret) 815 if (ret)
@@ -819,9 +819,9 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
819 819
820 /* Check, if the two dataram areas are same */ 820 /* Check, if the two dataram areas are same */
821 dataram0 = this->base + ONENAND_DATARAM; 821 dataram0 = this->base + ONENAND_DATARAM;
822 dataram1 = dataram0 + mtd->oobblock; 822 dataram1 = dataram0 + mtd->writesize;
823 823
824 if (memcmp(dataram0, dataram1, mtd->oobblock)) 824 if (memcmp(dataram0, dataram1, mtd->writesize))
825 return -EBADMSG; 825 return -EBADMSG;
826 826
827 return 0; 827 return 0;
@@ -831,7 +831,7 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
831#define onenand_verify_oob(...) (0) 831#define onenand_verify_oob(...) (0)
832#endif 832#endif
833 833
834#define NOTALIGNED(x) ((x & (mtd->oobblock - 1)) != 0) 834#define NOTALIGNED(x) ((x & (mtd->writesize - 1)) != 0)
835 835
836/** 836/**
837 * onenand_write_ecc - [MTD Interface] OneNAND write with ECC 837 * onenand_write_ecc - [MTD Interface] OneNAND write with ECC
@@ -875,14 +875,14 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
875 875
876 /* Loop until all data write */ 876 /* Loop until all data write */
877 while (written < len) { 877 while (written < len) {
878 int thislen = min_t(int, mtd->oobblock, len - written); 878 int thislen = min_t(int, mtd->writesize, len - written);
879 879
880 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock); 880 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->writesize);
881 881
882 this->write_bufferram(mtd, ONENAND_DATARAM, buf, 0, thislen); 882 this->write_bufferram(mtd, ONENAND_DATARAM, buf, 0, thislen);
883 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); 883 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
884 884
885 this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock); 885 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
886 886
887 onenand_update_bufferram(mtd, to, 1); 887 onenand_update_bufferram(mtd, to, 1);
888 888
@@ -1070,10 +1070,10 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
1070 * If the given tuple is >= pagesize then 1070 * If the given tuple is >= pagesize then
1071 * write it out from the iov 1071 * write it out from the iov
1072 */ 1072 */
1073 if ((vecs->iov_len - len) >= mtd->oobblock) { 1073 if ((vecs->iov_len - len) >= mtd->writesize) {
1074 pbuf = vecs->iov_base + len; 1074 pbuf = vecs->iov_base + len;
1075 1075
1076 len += mtd->oobblock; 1076 len += mtd->writesize;
1077 1077
1078 /* Check, if we have to switch to the next tuple */ 1078 /* Check, if we have to switch to the next tuple */
1079 if (len >= (int) vecs->iov_len) { 1079 if (len >= (int) vecs->iov_len) {
@@ -1083,8 +1083,8 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
1083 } 1083 }
1084 } else { 1084 } else {
1085 int cnt = 0, thislen; 1085 int cnt = 0, thislen;
1086 while (cnt < mtd->oobblock) { 1086 while (cnt < mtd->writesize) {
1087 thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len); 1087 thislen = min_t(int, mtd->writesize - cnt, vecs->iov_len - len);
1088 memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen); 1088 memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen);
1089 cnt += thislen; 1089 cnt += thislen;
1090 len += thislen; 1090 len += thislen;
@@ -1098,12 +1098,12 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
1098 } 1098 }
1099 } 1099 }
1100 1100
1101 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobblock); 1101 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->writesize);
1102 1102
1103 this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->oobblock); 1103 this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->writesize);
1104 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); 1104 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
1105 1105
1106 this->command(mtd, ONENAND_CMD_PROG, to, mtd->oobblock); 1106 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
1107 1107
1108 onenand_update_bufferram(mtd, to, 1); 1108 onenand_update_bufferram(mtd, to, 1);
1109 1109
@@ -1121,9 +1121,9 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
1121 goto out; 1121 goto out;
1122 } 1122 }
1123 1123
1124 written += mtd->oobblock; 1124 written += mtd->writesize;
1125 1125
1126 to += mtd->oobblock; 1126 to += mtd->writesize;
1127 } 1127 }
1128 1128
1129out: 1129out:
@@ -1467,11 +1467,11 @@ static int do_otp_write(struct mtd_info *mtd, loff_t from, size_t len,
1467 int ret; 1467 int ret;
1468 1468
1469 /* Force buffer page aligned */ 1469 /* Force buffer page aligned */
1470 if (len < mtd->oobblock) { 1470 if (len < mtd->writesize) {
1471 memcpy(this->page_buf, buf, len); 1471 memcpy(this->page_buf, buf, len);
1472 memset(this->page_buf + len, 0xff, mtd->oobblock - len); 1472 memset(this->page_buf + len, 0xff, mtd->writesize - len);
1473 pbuf = this->page_buf; 1473 pbuf = this->page_buf;
1474 len = mtd->oobblock; 1474 len = mtd->writesize;
1475 } 1475 }
1476 1476
1477 /* Enter OTP access mode */ 1477 /* Enter OTP access mode */
@@ -1546,12 +1546,12 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
1546 otp_pages = 10; 1546 otp_pages = 10;
1547 1547
1548 if (mode == MTD_OTP_FACTORY) { 1548 if (mode == MTD_OTP_FACTORY) {
1549 from += mtd->oobblock * otp_pages; 1549 from += mtd->writesize * otp_pages;
1550 otp_pages = 64 - otp_pages; 1550 otp_pages = 64 - otp_pages;
1551 } 1551 }
1552 1552
1553 /* Check User/Factory boundary */ 1553 /* Check User/Factory boundary */
1554 if (((mtd->oobblock * otp_pages) - (from + len)) < 0) 1554 if (((mtd->writesize * otp_pages) - (from + len)) < 0)
1555 return 0; 1555 return 0;
1556 1556
1557 while (len > 0 && otp_pages > 0) { 1557 while (len > 0 && otp_pages > 0) {
@@ -1564,10 +1564,10 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
1564 1564
1565 otpinfo = (struct otp_info *) buf; 1565 otpinfo = (struct otp_info *) buf;
1566 otpinfo->start = from; 1566 otpinfo->start = from;
1567 otpinfo->length = mtd->oobblock; 1567 otpinfo->length = mtd->writesize;
1568 otpinfo->locked = 0; 1568 otpinfo->locked = 0;
1569 1569
1570 from += mtd->oobblock; 1570 from += mtd->writesize;
1571 buf += sizeof(struct otp_info); 1571 buf += sizeof(struct otp_info);
1572 *retlen += sizeof(struct otp_info); 1572 *retlen += sizeof(struct otp_info);
1573 } else { 1573 } else {
@@ -1811,15 +1811,15 @@ static int onenand_probe(struct mtd_info *mtd)
1811 1811
1812 /* OneNAND page size & block size */ 1812 /* OneNAND page size & block size */
1813 /* The data buffer size is equal to page size */ 1813 /* The data buffer size is equal to page size */
1814 mtd->oobblock = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE); 1814 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE);
1815 mtd->oobsize = mtd->oobblock >> 5; 1815 mtd->oobsize = mtd->writesize >> 5;
1816 /* Pagers per block is always 64 in OneNAND */ 1816 /* Pagers per block is always 64 in OneNAND */
1817 mtd->erasesize = mtd->oobblock << 6; 1817 mtd->erasesize = mtd->writesize << 6;
1818 1818
1819 this->erase_shift = ffs(mtd->erasesize) - 1; 1819 this->erase_shift = ffs(mtd->erasesize) - 1;
1820 this->page_shift = ffs(mtd->oobblock) - 1; 1820 this->page_shift = ffs(mtd->writesize) - 1;
1821 this->ppb_shift = (this->erase_shift - this->page_shift); 1821 this->ppb_shift = (this->erase_shift - this->page_shift);
1822 this->page_mask = (mtd->erasesize / mtd->oobblock) - 1; 1822 this->page_mask = (mtd->erasesize / mtd->writesize) - 1;
1823 1823
1824 /* REVIST: Multichip handling */ 1824 /* REVIST: Multichip handling */
1825 1825
@@ -1909,7 +1909,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1909 /* Allocate buffers, if necessary */ 1909 /* Allocate buffers, if necessary */
1910 if (!this->page_buf) { 1910 if (!this->page_buf) {
1911 size_t len; 1911 size_t len;
1912 len = mtd->oobblock + mtd->oobsize; 1912 len = mtd->writesize + mtd->oobsize;
1913 this->page_buf = kmalloc(len, GFP_KERNEL); 1913 this->page_buf = kmalloc(len, GFP_KERNEL);
1914 if (!this->page_buf) { 1914 if (!this->page_buf) {
1915 printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n"); 1915 printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n");
@@ -1943,7 +1943,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1943 1943
1944 /* Fill in remaining MTD driver data */ 1944 /* Fill in remaining MTD driver data */
1945 mtd->type = MTD_NANDFLASH; 1945 mtd->type = MTD_NANDFLASH;
1946 mtd->flags = MTD_CAP_NANDFLASH | MTD_ECC; 1946 mtd->flags = MTD_CAP_NANDFLASH;
1947 mtd->ecctype = MTD_ECC_SW; 1947 mtd->ecctype = MTD_ECC_SW;
1948 mtd->erase = onenand_erase; 1948 mtd->erase = onenand_erase;
1949 mtd->point = NULL; 1949 mtd->point = NULL;
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c
index 4510d3361eaa..aafd7c2f7802 100644
--- a/drivers/mtd/onenand/onenand_bbt.c
+++ b/drivers/mtd/onenand/onenand_bbt.c
@@ -87,13 +87,13 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
87 87
88 /* No need to read pages fully, 88 /* No need to read pages fully,
89 * just read required OOB bytes */ 89 * just read required OOB bytes */
90 ret = mtd->read_oob(mtd, from + j * mtd->oobblock + bd->offs, 90 ret = mtd->read_oob(mtd, from + j * mtd->writesize + bd->offs,
91 readlen, &retlen, &buf[0]); 91 readlen, &retlen, &buf[0]);
92 92
93 if (ret) 93 if (ret)
94 return ret; 94 return ret;
95 95
96 if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { 96 if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {
97 bbm->bbt[i >> 3] |= 0x03 << (i & 0x6); 97 bbm->bbt[i >> 3] |= 0x03 << (i & 0x6);
98 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 98 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
99 i >> 1, (unsigned int) from); 99 i >> 1, (unsigned int) from);