diff options
Diffstat (limited to 'drivers/mtd/onenand/onenand_base.c')
-rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index fe5b48997275..198bb8562d93 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 | ||
1129 | out: | 1129 | out: |
@@ -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"); |