aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/onenand/onenand_base.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/onenand/onenand_base.c')
-rw-r--r--drivers/mtd/onenand/onenand_base.c75
1 files changed, 17 insertions, 58 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 3a3fe1d8fcdd..7a2419186ff4 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -597,31 +597,28 @@ static void onenand_release_device(struct mtd_info *mtd)
597} 597}
598 598
599/** 599/**
600 * onenand_read_ecc - [MTD Interface] Read data with ECC 600 * onenand_read - [MTD Interface] Read data from flash
601 * @param mtd MTD device structure 601 * @param mtd MTD device structure
602 * @param from offset to read from 602 * @param from offset to read from
603 * @param len number of bytes to read 603 * @param len number of bytes to read
604 * @param retlen pointer to variable to store the number of read bytes 604 * @param retlen pointer to variable to store the number of read bytes
605 * @param buf the databuffer to put data 605 * @param buf the databuffer to put data
606 * @param oob_buf filesystem supplied oob data buffer
607 * @param oobsel oob selection structure
608 * 606 *
609 * OneNAND read with ECC 607 * Read with ecc
610 */ 608*/
611static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, 609static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
612 size_t *retlen, u_char *buf, 610 size_t *retlen, u_char *buf)
613 u_char *oob_buf, struct nand_oobinfo *oobsel)
614{ 611{
615 struct onenand_chip *this = mtd->priv; 612 struct onenand_chip *this = mtd->priv;
616 int read = 0, column; 613 int read = 0, column;
617 int thislen; 614 int thislen;
618 int ret = 0; 615 int ret = 0;
619 616
620 DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len); 617 DEBUG(MTD_DEBUG_LEVEL3, "onenand_read: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
621 618
622 /* Do not allow reads past end of device */ 619 /* Do not allow reads past end of device */
623 if ((from + len) > mtd->size) { 620 if ((from + len) > mtd->size) {
624 DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_ecc: Attempt read beyond end of device\n"); 621 DEBUG(MTD_DEBUG_LEVEL0, "onenand_read: Attempt read beyond end of device\n");
625 *retlen = 0; 622 *retlen = 0;
626 return -EINVAL; 623 return -EINVAL;
627 } 624 }
@@ -654,7 +651,7 @@ static int onenand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
654 break; 651 break;
655 652
656 if (ret) { 653 if (ret) {
657 DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_ecc: read failed = %d\n", ret); 654 DEBUG(MTD_DEBUG_LEVEL0, "onenand_read: read failed = %d\n", ret);
658 goto out; 655 goto out;
659 } 656 }
660 657
@@ -676,22 +673,6 @@ out:
676} 673}
677 674
678/** 675/**
679 * onenand_read - [MTD Interface] MTD compability function for onenand_read_ecc
680 * @param mtd MTD device structure
681 * @param from offset to read from
682 * @param len number of bytes to read
683 * @param retlen pointer to variable to store the number of read bytes
684 * @param buf the databuffer to put data
685 *
686 * This function simply calls onenand_read_ecc with oob buffer and oobsel = NULL
687*/
688static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len,
689 size_t *retlen, u_char *buf)
690{
691 return onenand_read_ecc(mtd, from, len, retlen, buf, NULL, NULL);
692}
693
694/**
695 * onenand_read_oob - [MTD Interface] OneNAND read out-of-band 676 * onenand_read_oob - [MTD Interface] OneNAND read out-of-band
696 * @param mtd MTD device structure 677 * @param mtd MTD device structure
697 * @param from offset to read from 678 * @param from offset to read from
@@ -834,39 +815,36 @@ static int onenand_verify_page(struct mtd_info *mtd, u_char *buf, loff_t addr)
834#define NOTALIGNED(x) ((x & (mtd->writesize - 1)) != 0) 815#define NOTALIGNED(x) ((x & (mtd->writesize - 1)) != 0)
835 816
836/** 817/**
837 * onenand_write_ecc - [MTD Interface] OneNAND write with ECC 818 * onenand_write - [MTD Interface] write buffer to FLASH
838 * @param mtd MTD device structure 819 * @param mtd MTD device structure
839 * @param to offset to write to 820 * @param to offset to write to
840 * @param len number of bytes to write 821 * @param len number of bytes to write
841 * @param retlen pointer to variable to store the number of written bytes 822 * @param retlen pointer to variable to store the number of written bytes
842 * @param buf the data to write 823 * @param buf the data to write
843 * @param eccbuf filesystem supplied oob data buffer
844 * @param oobsel oob selection structure
845 * 824 *
846 * OneNAND write with ECC 825 * Write with ECC
847 */ 826 */
848static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, 827static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len,
849 size_t *retlen, const u_char *buf, 828 size_t *retlen, const u_char *buf)
850 u_char *eccbuf, struct nand_oobinfo *oobsel)
851{ 829{
852 struct onenand_chip *this = mtd->priv; 830 struct onenand_chip *this = mtd->priv;
853 int written = 0; 831 int written = 0;
854 int ret = 0; 832 int ret = 0;
855 833
856 DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len); 834 DEBUG(MTD_DEBUG_LEVEL3, "onenand_write: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
857 835
858 /* Initialize retlen, in case of early exit */ 836 /* Initialize retlen, in case of early exit */
859 *retlen = 0; 837 *retlen = 0;
860 838
861 /* Do not allow writes past end of device */ 839 /* Do not allow writes past end of device */
862 if (unlikely((to + len) > mtd->size)) { 840 if (unlikely((to + len) > mtd->size)) {
863 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: Attempt write to past end of device\n"); 841 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: Attempt write to past end of device\n");
864 return -EINVAL; 842 return -EINVAL;
865 } 843 }
866 844
867 /* Reject writes, which are not page aligned */ 845 /* Reject writes, which are not page aligned */
868 if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(len))) { 846 if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(len))) {
869 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: Attempt to write not page aligned data\n"); 847 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: Attempt to write not page aligned data\n");
870 return -EINVAL; 848 return -EINVAL;
871 } 849 }
872 850
@@ -888,7 +866,7 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
888 866
889 ret = this->wait(mtd, FL_WRITING); 867 ret = this->wait(mtd, FL_WRITING);
890 if (ret) { 868 if (ret) {
891 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: write filaed %d\n", ret); 869 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: write filaed %d\n", ret);
892 goto out; 870 goto out;
893 } 871 }
894 872
@@ -897,7 +875,7 @@ static int onenand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
897 /* Only check verify write turn on */ 875 /* Only check verify write turn on */
898 ret = onenand_verify_page(mtd, (u_char *) buf, to); 876 ret = onenand_verify_page(mtd, (u_char *) buf, to);
899 if (ret) { 877 if (ret) {
900 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write_ecc: verify failed %d\n", ret); 878 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: verify failed %d\n", ret);
901 goto out; 879 goto out;
902 } 880 }
903 881
@@ -918,23 +896,6 @@ out:
918} 896}
919 897
920/** 898/**
921 * onenand_write - [MTD Interface] compability function for onenand_write_ecc
922 * @param mtd MTD device structure
923 * @param to offset to write to
924 * @param len number of bytes to write
925 * @param retlen pointer to variable to store the number of written bytes
926 * @param buf the data to write
927 *
928 * This function simply calls onenand_write_ecc
929 * with oob buffer and oobsel = NULL
930 */
931static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len,
932 size_t *retlen, const u_char *buf)
933{
934 return onenand_write_ecc(mtd, to, len, retlen, buf, NULL, NULL);
935}
936
937/**
938 * onenand_write_oob - [MTD Interface] OneNAND write out-of-band 899 * onenand_write_oob - [MTD Interface] OneNAND write out-of-band
939 * @param mtd MTD device structure 900 * @param mtd MTD device structure
940 * @param to offset to write to 901 * @param to offset to write to
@@ -1812,8 +1773,6 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1812 mtd->unpoint = NULL; 1773 mtd->unpoint = NULL;
1813 mtd->read = onenand_read; 1774 mtd->read = onenand_read;
1814 mtd->write = onenand_write; 1775 mtd->write = onenand_write;
1815 mtd->read_ecc = onenand_read_ecc;
1816 mtd->write_ecc = onenand_write_ecc;
1817 mtd->read_oob = onenand_read_oob; 1776 mtd->read_oob = onenand_read_oob;
1818 mtd->write_oob = onenand_write_oob; 1777 mtd->write_oob = onenand_write_oob;
1819#ifdef CONFIG_MTD_ONENAND_OTP 1778#ifdef CONFIG_MTD_ONENAND_OTP