diff options
Diffstat (limited to 'drivers/mtd/onenand/onenand_base.c')
-rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 4c2c61d54b3a..8e875fa140a8 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
@@ -1014,144 +1014,6 @@ out: | |||
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | /** | 1016 | /** |
1017 | * onenand_writev_ecc - [MTD Interface] write with iovec with ecc | ||
1018 | * @param mtd MTD device structure | ||
1019 | * @param vecs the iovectors to write | ||
1020 | * @param count number of vectors | ||
1021 | * @param to offset to write to | ||
1022 | * @param retlen pointer to variable to store the number of written bytes | ||
1023 | * @param eccbuf filesystem supplied oob data buffer | ||
1024 | * @param oobsel oob selection structure | ||
1025 | * | ||
1026 | * OneNAND write with iovec with ecc | ||
1027 | */ | ||
1028 | static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, | ||
1029 | unsigned long count, loff_t to, size_t *retlen, | ||
1030 | u_char *eccbuf, struct nand_oobinfo *oobsel) | ||
1031 | { | ||
1032 | struct onenand_chip *this = mtd->priv; | ||
1033 | unsigned char *pbuf; | ||
1034 | size_t total_len, len; | ||
1035 | int i, written = 0; | ||
1036 | int ret = 0; | ||
1037 | |||
1038 | /* Preset written len for early exit */ | ||
1039 | *retlen = 0; | ||
1040 | |||
1041 | /* Calculate total length of data */ | ||
1042 | total_len = 0; | ||
1043 | for (i = 0; i < count; i++) | ||
1044 | total_len += vecs[i].iov_len; | ||
1045 | |||
1046 | DEBUG(MTD_DEBUG_LEVEL3, "onenand_writev_ecc: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count); | ||
1047 | |||
1048 | /* Do not allow write past end of the device */ | ||
1049 | if (unlikely((to + total_len) > mtd->size)) { | ||
1050 | DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: Attempted write past end of device\n"); | ||
1051 | return -EINVAL; | ||
1052 | } | ||
1053 | |||
1054 | /* Reject writes, which are not page aligned */ | ||
1055 | if (unlikely(NOTALIGNED(to)) || unlikely(NOTALIGNED(total_len))) { | ||
1056 | DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: Attempt to write not page aligned data\n"); | ||
1057 | return -EINVAL; | ||
1058 | } | ||
1059 | |||
1060 | /* Grab the lock and see if the device is available */ | ||
1061 | onenand_get_device(mtd, FL_WRITING); | ||
1062 | |||
1063 | /* TODO handling oob */ | ||
1064 | |||
1065 | /* Loop until all keve's data has been written */ | ||
1066 | len = 0; | ||
1067 | while (count) { | ||
1068 | pbuf = this->page_buf; | ||
1069 | /* | ||
1070 | * If the given tuple is >= pagesize then | ||
1071 | * write it out from the iov | ||
1072 | */ | ||
1073 | if ((vecs->iov_len - len) >= mtd->writesize) { | ||
1074 | pbuf = vecs->iov_base + len; | ||
1075 | |||
1076 | len += mtd->writesize; | ||
1077 | |||
1078 | /* Check, if we have to switch to the next tuple */ | ||
1079 | if (len >= (int) vecs->iov_len) { | ||
1080 | vecs++; | ||
1081 | len = 0; | ||
1082 | count--; | ||
1083 | } | ||
1084 | } else { | ||
1085 | int cnt = 0, thislen; | ||
1086 | while (cnt < mtd->writesize) { | ||
1087 | thislen = min_t(int, mtd->writesize - cnt, vecs->iov_len - len); | ||
1088 | memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen); | ||
1089 | cnt += thislen; | ||
1090 | len += thislen; | ||
1091 | |||
1092 | /* Check, if we have to switch to the next tuple */ | ||
1093 | if (len >= (int) vecs->iov_len) { | ||
1094 | vecs++; | ||
1095 | len = 0; | ||
1096 | count--; | ||
1097 | } | ||
1098 | } | ||
1099 | } | ||
1100 | |||
1101 | this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->writesize); | ||
1102 | |||
1103 | this->write_bufferram(mtd, ONENAND_DATARAM, pbuf, 0, mtd->writesize); | ||
1104 | this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); | ||
1105 | |||
1106 | this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize); | ||
1107 | |||
1108 | onenand_update_bufferram(mtd, to, 1); | ||
1109 | |||
1110 | ret = this->wait(mtd, FL_WRITING); | ||
1111 | if (ret) { | ||
1112 | DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: write failed %d\n", ret); | ||
1113 | goto out; | ||
1114 | } | ||
1115 | |||
1116 | |||
1117 | /* Only check verify write turn on */ | ||
1118 | ret = onenand_verify_page(mtd, (u_char *) pbuf, to); | ||
1119 | if (ret) { | ||
1120 | DEBUG(MTD_DEBUG_LEVEL0, "onenand_writev_ecc: verify failed %d\n", ret); | ||
1121 | goto out; | ||
1122 | } | ||
1123 | |||
1124 | written += mtd->writesize; | ||
1125 | |||
1126 | to += mtd->writesize; | ||
1127 | } | ||
1128 | |||
1129 | out: | ||
1130 | /* Deselect and wakt up anyone waiting on the device */ | ||
1131 | onenand_release_device(mtd); | ||
1132 | |||
1133 | *retlen = written; | ||
1134 | |||
1135 | return 0; | ||
1136 | } | ||
1137 | |||
1138 | /** | ||
1139 | * onenand_writev - [MTD Interface] compabilty function for onenand_writev_ecc | ||
1140 | * @param mtd MTD device structure | ||
1141 | * @param vecs the iovectors to write | ||
1142 | * @param count number of vectors | ||
1143 | * @param to offset to write to | ||
1144 | * @param retlen pointer to variable to store the number of written bytes | ||
1145 | * | ||
1146 | * OneNAND write with kvec. This just calls the ecc function | ||
1147 | */ | ||
1148 | static int onenand_writev(struct mtd_info *mtd, const struct kvec *vecs, | ||
1149 | unsigned long count, loff_t to, size_t *retlen) | ||
1150 | { | ||
1151 | return onenand_writev_ecc(mtd, vecs, count, to, retlen, NULL, NULL); | ||
1152 | } | ||
1153 | |||
1154 | /** | ||
1155 | * onenand_block_checkbad - [GENERIC] Check if a block is marked bad | 1017 | * onenand_block_checkbad - [GENERIC] Check if a block is marked bad |
1156 | * @param mtd MTD device structure | 1018 | * @param mtd MTD device structure |
1157 | * @param ofs offset from device start | 1019 | * @param ofs offset from device start |
@@ -1964,8 +1826,6 @@ int onenand_scan(struct mtd_info *mtd, int maxchips) | |||
1964 | #endif | 1826 | #endif |
1965 | mtd->readv = NULL; | 1827 | mtd->readv = NULL; |
1966 | mtd->readv_ecc = NULL; | 1828 | mtd->readv_ecc = NULL; |
1967 | mtd->writev = onenand_writev; | ||
1968 | mtd->writev_ecc = onenand_writev_ecc; | ||
1969 | mtd->sync = onenand_sync; | 1829 | mtd->sync = onenand_sync; |
1970 | mtd->lock = NULL; | 1830 | mtd->lock = NULL; |
1971 | mtd->unlock = onenand_unlock; | 1831 | mtd->unlock = onenand_unlock; |