diskonchip.c (93db446a424cee9387b532995e6b516667079555) diskonchip.c (63fa37f0c512481bd942e84b596ad58e1d4c84e2)
1/*
2 * (C) 2003 Red Hat, Inc.
3 * (C) 2004 Dan Brown <dan_brown@ieee.org>
4 * (C) 2004 Kalev Lember <kalev@smartlink.ee>
5 *
6 * Author: David Woodhouse <dwmw2@infradead.org>
7 * Additional Diskonchip 2000 and Millennium support by Dan Brown <dan_brown@ieee.org>
8 * Diskonchip Millennium Plus support by Kalev Lember <kalev@smartlink.ee>

--- 395 unchanged lines hidden (view full) ---

404 doc200x_hwcontrol(mtd, 0, NAND_CTRL_ALE | NAND_CTRL_CHANGE);
405 doc200x_hwcontrol(mtd, NAND_CMD_NONE,
406 NAND_NCE | NAND_CTRL_CHANGE);
407
408 udelay(50);
409
410 ident.dword = readl(docptr + DoC_2k_CDSN_IO);
411 if (((ident.byte[0] << 8) | ident.byte[1]) == ret) {
1/*
2 * (C) 2003 Red Hat, Inc.
3 * (C) 2004 Dan Brown <dan_brown@ieee.org>
4 * (C) 2004 Kalev Lember <kalev@smartlink.ee>
5 *
6 * Author: David Woodhouse <dwmw2@infradead.org>
7 * Additional Diskonchip 2000 and Millennium support by Dan Brown <dan_brown@ieee.org>
8 * Diskonchip Millennium Plus support by Kalev Lember <kalev@smartlink.ee>

--- 395 unchanged lines hidden (view full) ---

404 doc200x_hwcontrol(mtd, 0, NAND_CTRL_ALE | NAND_CTRL_CHANGE);
405 doc200x_hwcontrol(mtd, NAND_CMD_NONE,
406 NAND_NCE | NAND_CTRL_CHANGE);
407
408 udelay(50);
409
410 ident.dword = readl(docptr + DoC_2k_CDSN_IO);
411 if (((ident.byte[0] << 8) | ident.byte[1]) == ret) {
412 printk(KERN_INFO "DiskOnChip 2000 responds to DWORD access\n");
412 pr_info("DiskOnChip 2000 responds to DWORD access\n");
413 this->read_buf = &doc2000_readbuf_dword;
414 }
415 }
416
417 return ret;
418}
419
420static void __init doc2000_count_chips(struct mtd_info *mtd)

--- 10 unchanged lines hidden (view full) ---

431 mfrid = doc200x_ident_chip(mtd, 0);
432
433 /* Find how many chips in each floor. */
434 for (i = 1; i < 4; i++) {
435 if (doc200x_ident_chip(mtd, i) != mfrid)
436 break;
437 }
438 doc->chips_per_floor = i;
413 this->read_buf = &doc2000_readbuf_dword;
414 }
415 }
416
417 return ret;
418}
419
420static void __init doc2000_count_chips(struct mtd_info *mtd)

--- 10 unchanged lines hidden (view full) ---

431 mfrid = doc200x_ident_chip(mtd, 0);
432
433 /* Find how many chips in each floor. */
434 for (i = 1; i < 4; i++) {
435 if (doc200x_ident_chip(mtd, i) != mfrid)
436 break;
437 }
438 doc->chips_per_floor = i;
439 printk(KERN_DEBUG "Detected %d chips per floor.\n", i);
439 pr_debug("Detected %d chips per floor.\n", i);
440}
441
442static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this)
443{
444 struct doc_priv *doc = nand_get_controller_data(this);
445
446 int status;
447

--- 479 unchanged lines hidden (view full) ---

927 if (DoC_is_MillenniumPlus(doc))
928 calc_ecc[i] = ReadDOC_(docptr, DoC_Mplus_ECCSyndrome0 + i);
929 else
930 calc_ecc[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
931 }
932
933 ret = doc_ecc_decode(rs_decoder, dat, calc_ecc);
934 if (ret > 0)
440}
441
442static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this)
443{
444 struct doc_priv *doc = nand_get_controller_data(this);
445
446 int status;
447

--- 479 unchanged lines hidden (view full) ---

927 if (DoC_is_MillenniumPlus(doc))
928 calc_ecc[i] = ReadDOC_(docptr, DoC_Mplus_ECCSyndrome0 + i);
929 else
930 calc_ecc[i] = ReadDOC_(docptr, DoC_ECCSyndrome0 + i);
931 }
932
933 ret = doc_ecc_decode(rs_decoder, dat, calc_ecc);
934 if (ret > 0)
935 printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret);
935 pr_err("doc200x_correct_data corrected %d errors\n",
936 ret);
936 }
937 if (DoC_is_MillenniumPlus(doc))
938 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf);
939 else
940 WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
941 if (no_ecc_failures && mtd_is_eccerr(ret)) {
937 }
938 if (DoC_is_MillenniumPlus(doc))
939 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf);
940 else
941 WriteDOC(DOC_ECC_DIS, docptr, ECCConf);
942 if (no_ecc_failures && mtd_is_eccerr(ret)) {
942 printk(KERN_ERR "suppressing ECC failure\n");
943 pr_err("suppressing ECC failure\n");
943 ret = 0;
944 }
945 return ret;
946}
947
948//u_char mydatabuf[528];
949
950static int doc200x_ooblayout_ecc(struct mtd_info *mtd, int section,

--- 56 unchanged lines hidden (view full) ---

1007 int ret;
1008 size_t retlen;
1009
1010 for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
1011 ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf);
1012 if (retlen != mtd->writesize)
1013 continue;
1014 if (ret) {
944 ret = 0;
945 }
946 return ret;
947}
948
949//u_char mydatabuf[528];
950
951static int doc200x_ooblayout_ecc(struct mtd_info *mtd, int section,

--- 56 unchanged lines hidden (view full) ---

1008 int ret;
1009 size_t retlen;
1010
1011 for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
1012 ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf);
1013 if (retlen != mtd->writesize)
1014 continue;
1015 if (ret) {
1015 printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", offs);
1016 pr_warn("ECC error scanning DOC at 0x%x\n", offs);
1016 }
1017 if (memcmp(buf, id, 6))
1018 continue;
1017 }
1018 if (memcmp(buf, id, 6))
1019 continue;
1019 printk(KERN_INFO "Found DiskOnChip %s Media Header at 0x%x\n", id, offs);
1020 pr_info("Found DiskOnChip %s Media Header at 0x%x\n", id, offs);
1020 if (doc->mh0_page == -1) {
1021 doc->mh0_page = offs >> this->page_shift;
1022 if (!findmirror)
1023 return 1;
1024 continue;
1025 }
1026 doc->mh1_page = offs >> this->page_shift;
1027 return 2;
1028 }
1029 if (doc->mh0_page == -1) {
1021 if (doc->mh0_page == -1) {
1022 doc->mh0_page = offs >> this->page_shift;
1023 if (!findmirror)
1024 return 1;
1025 continue;
1026 }
1027 doc->mh1_page = offs >> this->page_shift;
1028 return 2;
1029 }
1030 if (doc->mh0_page == -1) {
1030 printk(KERN_WARNING "DiskOnChip %s Media Header not found.\n", id);
1031 pr_warn("DiskOnChip %s Media Header not found.\n", id);
1031 return 0;
1032 }
1033 /* Only one mediaheader was found. We want buf to contain a
1034 mediaheader on return, so we'll have to re-read the one we found. */
1035 offs = doc->mh0_page << this->page_shift;
1036 ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf);
1037 if (retlen != mtd->writesize) {
1038 /* Insanity. Give up. */
1032 return 0;
1033 }
1034 /* Only one mediaheader was found. We want buf to contain a
1035 mediaheader on return, so we'll have to re-read the one we found. */
1036 offs = doc->mh0_page << this->page_shift;
1037 ret = mtd_read(mtd, offs, mtd->writesize, &retlen, buf);
1038 if (retlen != mtd->writesize) {
1039 /* Insanity. Give up. */
1039 printk(KERN_ERR "Read DiskOnChip Media Header once, but can't reread it???\n");
1040 pr_err("Read DiskOnChip Media Header once, but can't reread it???\n");
1040 return 0;
1041 }
1042 return 1;
1043}
1044
1045static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts)
1046{
1047 struct nand_chip *this = mtd_to_nand(mtd);

--- 13 unchanged lines hidden (view full) ---

1061 if (!(numheaders = find_media_headers(mtd, buf, "ANAND", 1)))
1062 goto out;
1063 mh = (struct NFTLMediaHeader *)buf;
1064
1065 le16_to_cpus(&mh->NumEraseUnits);
1066 le16_to_cpus(&mh->FirstPhysicalEUN);
1067 le32_to_cpus(&mh->FormattedSize);
1068
1041 return 0;
1042 }
1043 return 1;
1044}
1045
1046static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts)
1047{
1048 struct nand_chip *this = mtd_to_nand(mtd);

--- 13 unchanged lines hidden (view full) ---

1062 if (!(numheaders = find_media_headers(mtd, buf, "ANAND", 1)))
1063 goto out;
1064 mh = (struct NFTLMediaHeader *)buf;
1065
1066 le16_to_cpus(&mh->NumEraseUnits);
1067 le16_to_cpus(&mh->FirstPhysicalEUN);
1068 le32_to_cpus(&mh->FormattedSize);
1069
1069 printk(KERN_INFO " DataOrgID = %s\n"
1070 " NumEraseUnits = %d\n"
1071 " FirstPhysicalEUN = %d\n"
1072 " FormattedSize = %d\n"
1073 " UnitSizeFactor = %d\n",
1070 pr_info(" DataOrgID = %s\n"
1071 " NumEraseUnits = %d\n"
1072 " FirstPhysicalEUN = %d\n"
1073 " FormattedSize = %d\n"
1074 " UnitSizeFactor = %d\n",
1074 mh->DataOrgID, mh->NumEraseUnits,
1075 mh->FirstPhysicalEUN, mh->FormattedSize,
1076 mh->UnitSizeFactor);
1077
1078 blocks = mtd->size >> this->phys_erase_shift;
1079 maxblocks = min(32768U, mtd->erasesize - psize);
1080
1081 if (mh->UnitSizeFactor == 0x00) {
1082 /* Auto-determine UnitSizeFactor. The constraints are:
1083 - There can be at most 32768 virtual blocks.
1084 - There can be at most (virtual block size - page size)
1085 virtual blocks (because MediaHeader+BBT must fit in 1).
1086 */
1087 mh->UnitSizeFactor = 0xff;
1088 while (blocks > maxblocks) {
1089 blocks >>= 1;
1090 maxblocks = min(32768U, (maxblocks << 1) + psize);
1091 mh->UnitSizeFactor--;
1092 }
1075 mh->DataOrgID, mh->NumEraseUnits,
1076 mh->FirstPhysicalEUN, mh->FormattedSize,
1077 mh->UnitSizeFactor);
1078
1079 blocks = mtd->size >> this->phys_erase_shift;
1080 maxblocks = min(32768U, mtd->erasesize - psize);
1081
1082 if (mh->UnitSizeFactor == 0x00) {
1083 /* Auto-determine UnitSizeFactor. The constraints are:
1084 - There can be at most 32768 virtual blocks.
1085 - There can be at most (virtual block size - page size)
1086 virtual blocks (because MediaHeader+BBT must fit in 1).
1087 */
1088 mh->UnitSizeFactor = 0xff;
1089 while (blocks > maxblocks) {
1090 blocks >>= 1;
1091 maxblocks = min(32768U, (maxblocks << 1) + psize);
1092 mh->UnitSizeFactor--;
1093 }
1093 printk(KERN_WARNING "UnitSizeFactor=0x00 detected. Correct value is assumed to be 0x%02x.\n", mh->UnitSizeFactor);
1094 pr_warn("UnitSizeFactor=0x00 detected. Correct value is assumed to be 0x%02x.\n", mh->UnitSizeFactor);
1094 }
1095
1096 /* NOTE: The lines below modify internal variables of the NAND and MTD
1097 layers; variables with have already been configured by nand_scan.
1098 Unfortunately, we didn't know before this point what these values
1099 should be. Thus, this code is somewhat dependent on the exact
1100 implementation of the NAND layer. */
1101 if (mh->UnitSizeFactor != 0xff) {
1102 this->bbt_erase_shift += (0xff - mh->UnitSizeFactor);
1103 mtd->erasesize <<= (0xff - mh->UnitSizeFactor);
1095 }
1096
1097 /* NOTE: The lines below modify internal variables of the NAND and MTD
1098 layers; variables with have already been configured by nand_scan.
1099 Unfortunately, we didn't know before this point what these values
1100 should be. Thus, this code is somewhat dependent on the exact
1101 implementation of the NAND layer. */
1102 if (mh->UnitSizeFactor != 0xff) {
1103 this->bbt_erase_shift += (0xff - mh->UnitSizeFactor);
1104 mtd->erasesize <<= (0xff - mh->UnitSizeFactor);
1104 printk(KERN_INFO "Setting virtual erase size to %d\n", mtd->erasesize);
1105 pr_info("Setting virtual erase size to %d\n", mtd->erasesize);
1105 blocks = mtd->size >> this->bbt_erase_shift;
1106 maxblocks = min(32768U, mtd->erasesize - psize);
1107 }
1108
1109 if (blocks > maxblocks) {
1106 blocks = mtd->size >> this->bbt_erase_shift;
1107 maxblocks = min(32768U, mtd->erasesize - psize);
1108 }
1109
1110 if (blocks > maxblocks) {
1110 printk(KERN_ERR "UnitSizeFactor of 0x%02x is inconsistent with device size. Aborting.\n", mh->UnitSizeFactor);
1111 pr_err("UnitSizeFactor of 0x%02x is inconsistent with device size. Aborting.\n", mh->UnitSizeFactor);
1111 goto out;
1112 }
1113
1114 /* Skip past the media headers. */
1115 offs = max(doc->mh0_page, doc->mh1_page);
1116 offs <<= this->page_shift;
1117 offs += mtd->erasesize;
1118

--- 54 unchanged lines hidden (view full) ---

1173
1174 le32_to_cpus(&mh->NoOfBootImageBlocks);
1175 le32_to_cpus(&mh->NoOfBinaryPartitions);
1176 le32_to_cpus(&mh->NoOfBDTLPartitions);
1177 le32_to_cpus(&mh->BlockMultiplierBits);
1178 le32_to_cpus(&mh->FormatFlags);
1179 le32_to_cpus(&mh->PercentUsed);
1180
1112 goto out;
1113 }
1114
1115 /* Skip past the media headers. */
1116 offs = max(doc->mh0_page, doc->mh1_page);
1117 offs <<= this->page_shift;
1118 offs += mtd->erasesize;
1119

--- 54 unchanged lines hidden (view full) ---

1174
1175 le32_to_cpus(&mh->NoOfBootImageBlocks);
1176 le32_to_cpus(&mh->NoOfBinaryPartitions);
1177 le32_to_cpus(&mh->NoOfBDTLPartitions);
1178 le32_to_cpus(&mh->BlockMultiplierBits);
1179 le32_to_cpus(&mh->FormatFlags);
1180 le32_to_cpus(&mh->PercentUsed);
1181
1181 printk(KERN_INFO " bootRecordID = %s\n"
1182 " NoOfBootImageBlocks = %d\n"
1183 " NoOfBinaryPartitions = %d\n"
1184 " NoOfBDTLPartitions = %d\n"
1185 " BlockMultiplerBits = %d\n"
1186 " FormatFlgs = %d\n"
1187 " OsakVersion = %d.%d.%d.%d\n"
1188 " PercentUsed = %d\n",
1182 pr_info(" bootRecordID = %s\n"
1183 " NoOfBootImageBlocks = %d\n"
1184 " NoOfBinaryPartitions = %d\n"
1185 " NoOfBDTLPartitions = %d\n"
1186 " BlockMultiplerBits = %d\n"
1187 " FormatFlgs = %d\n"
1188 " OsakVersion = %d.%d.%d.%d\n"
1189 " PercentUsed = %d\n",
1189 mh->bootRecordID, mh->NoOfBootImageBlocks,
1190 mh->NoOfBinaryPartitions,
1191 mh->NoOfBDTLPartitions,
1192 mh->BlockMultiplierBits, mh->FormatFlags,
1193 ((unsigned char *) &mh->OsakVersion)[0] & 0xf,
1194 ((unsigned char *) &mh->OsakVersion)[1] & 0xf,
1195 ((unsigned char *) &mh->OsakVersion)[2] & 0xf,
1196 ((unsigned char *) &mh->OsakVersion)[3] & 0xf,
1197 mh->PercentUsed);
1198
1199 vshift = this->phys_erase_shift + mh->BlockMultiplierBits;
1200
1201 blocks = mtd->size >> vshift;
1202 if (blocks > 32768) {
1190 mh->bootRecordID, mh->NoOfBootImageBlocks,
1191 mh->NoOfBinaryPartitions,
1192 mh->NoOfBDTLPartitions,
1193 mh->BlockMultiplierBits, mh->FormatFlags,
1194 ((unsigned char *) &mh->OsakVersion)[0] & 0xf,
1195 ((unsigned char *) &mh->OsakVersion)[1] & 0xf,
1196 ((unsigned char *) &mh->OsakVersion)[2] & 0xf,
1197 ((unsigned char *) &mh->OsakVersion)[3] & 0xf,
1198 mh->PercentUsed);
1199
1200 vshift = this->phys_erase_shift + mh->BlockMultiplierBits;
1201
1202 blocks = mtd->size >> vshift;
1203 if (blocks > 32768) {
1203 printk(KERN_ERR "BlockMultiplierBits=%d is inconsistent with device size. Aborting.\n", mh->BlockMultiplierBits);
1204 pr_err("BlockMultiplierBits=%d is inconsistent with device size. Aborting.\n", mh->BlockMultiplierBits);
1204 goto out;
1205 }
1206
1207 blocks = doc->chips_per_floor << (this->chip_shift - this->phys_erase_shift);
1208 if (inftl_bbt_write && (blocks > mtd->erasesize)) {
1205 goto out;
1206 }
1207
1208 blocks = doc->chips_per_floor << (this->chip_shift - this->phys_erase_shift);
1209 if (inftl_bbt_write && (blocks > mtd->erasesize)) {
1209 printk(KERN_ERR "Writeable BBTs spanning more than one erase block are not yet supported. FIX ME!\n");
1210 pr_err("Writeable BBTs spanning more than one erase block are not yet supported. FIX ME!\n");
1210 goto out;
1211 }
1212
1213 /* Scan the partitions */
1214 for (i = 0; (i < 4); i++) {
1215 ip = &(mh->Partitions[i]);
1216 le32_to_cpus(&ip->virtualUnits);
1217 le32_to_cpus(&ip->firstUnit);
1218 le32_to_cpus(&ip->lastUnit);
1219 le32_to_cpus(&ip->flags);
1220 le32_to_cpus(&ip->spareUnits);
1221 le32_to_cpus(&ip->Reserved0);
1222
1211 goto out;
1212 }
1213
1214 /* Scan the partitions */
1215 for (i = 0; (i < 4); i++) {
1216 ip = &(mh->Partitions[i]);
1217 le32_to_cpus(&ip->virtualUnits);
1218 le32_to_cpus(&ip->firstUnit);
1219 le32_to_cpus(&ip->lastUnit);
1220 le32_to_cpus(&ip->flags);
1221 le32_to_cpus(&ip->spareUnits);
1222 le32_to_cpus(&ip->Reserved0);
1223
1223 printk(KERN_INFO " PARTITION[%d] ->\n"
1224 pr_info(" PARTITION[%d] ->\n"
1224 " virtualUnits = %d\n"
1225 " firstUnit = %d\n"
1226 " lastUnit = %d\n"
1227 " flags = 0x%x\n"
1228 " spareUnits = %d\n",
1229 i, ip->virtualUnits, ip->firstUnit,
1230 ip->lastUnit, ip->flags,
1231 ip->spareUnits);

--- 69 unchanged lines hidden (view full) ---

1301static int __init inftl_scan_bbt(struct mtd_info *mtd)
1302{
1303 int ret, numparts;
1304 struct nand_chip *this = mtd_to_nand(mtd);
1305 struct doc_priv *doc = nand_get_controller_data(this);
1306 struct mtd_partition parts[5];
1307
1308 if (this->numchips > doc->chips_per_floor) {
1225 " virtualUnits = %d\n"
1226 " firstUnit = %d\n"
1227 " lastUnit = %d\n"
1228 " flags = 0x%x\n"
1229 " spareUnits = %d\n",
1230 i, ip->virtualUnits, ip->firstUnit,
1231 ip->lastUnit, ip->flags,
1232 ip->spareUnits);

--- 69 unchanged lines hidden (view full) ---

1302static int __init inftl_scan_bbt(struct mtd_info *mtd)
1303{
1304 int ret, numparts;
1305 struct nand_chip *this = mtd_to_nand(mtd);
1306 struct doc_priv *doc = nand_get_controller_data(this);
1307 struct mtd_partition parts[5];
1308
1309 if (this->numchips > doc->chips_per_floor) {
1309 printk(KERN_ERR "Multi-floor INFTL devices not yet supported.\n");
1310 pr_err("Multi-floor INFTL devices not yet supported.\n");
1310 return -EIO;
1311 }
1312
1313 if (DoC_is_MillenniumPlus(doc)) {
1314 this->bbt_td->options = NAND_BBT_2BIT | NAND_BBT_ABSPAGE;
1315 if (inftl_bbt_write)
1316 this->bbt_td->options |= NAND_BBT_WRITE;
1317 this->bbt_td->pages[0] = 2;

--- 111 unchanged lines hidden (view full) ---

1429 unsigned char tmp, tmpb, tmpc;
1430 int reg, len, numchips;
1431 int ret = 0;
1432
1433 if (!request_mem_region(physadr, DOC_IOREMAP_LEN, "DiskOnChip"))
1434 return -EBUSY;
1435 virtadr = ioremap(physadr, DOC_IOREMAP_LEN);
1436 if (!virtadr) {
1311 return -EIO;
1312 }
1313
1314 if (DoC_is_MillenniumPlus(doc)) {
1315 this->bbt_td->options = NAND_BBT_2BIT | NAND_BBT_ABSPAGE;
1316 if (inftl_bbt_write)
1317 this->bbt_td->options |= NAND_BBT_WRITE;
1318 this->bbt_td->pages[0] = 2;

--- 111 unchanged lines hidden (view full) ---

1430 unsigned char tmp, tmpb, tmpc;
1431 int reg, len, numchips;
1432 int ret = 0;
1433
1434 if (!request_mem_region(physadr, DOC_IOREMAP_LEN, "DiskOnChip"))
1435 return -EBUSY;
1436 virtadr = ioremap(physadr, DOC_IOREMAP_LEN);
1437 if (!virtadr) {
1437 printk(KERN_ERR "Diskonchip ioremap failed: 0x%x bytes at 0x%lx\n", DOC_IOREMAP_LEN, physadr);
1438 pr_err("Diskonchip ioremap failed: 0x%x bytes at 0x%lx\n",
1439 DOC_IOREMAP_LEN, physadr);
1438 ret = -EIO;
1439 goto error_ioremap;
1440 }
1441
1442 /* It's not possible to cleanly detect the DiskOnChip - the
1443 * bootup procedure will put the device into reset mode, and
1444 * it's not possible to talk to it without actually writing
1445 * to the DOCControl register. So we store the current contents

--- 42 unchanged lines hidden (view full) ---

1488
1489 ChipID = ReadDOC(virtadr, ChipID);
1490
1491 switch (ChipID) {
1492 case DOC_ChipID_DocMilPlus16:
1493 reg = DoC_Mplus_Toggle;
1494 break;
1495 case DOC_ChipID_DocMilPlus32:
1440 ret = -EIO;
1441 goto error_ioremap;
1442 }
1443
1444 /* It's not possible to cleanly detect the DiskOnChip - the
1445 * bootup procedure will put the device into reset mode, and
1446 * it's not possible to talk to it without actually writing
1447 * to the DOCControl register. So we store the current contents

--- 42 unchanged lines hidden (view full) ---

1490
1491 ChipID = ReadDOC(virtadr, ChipID);
1492
1493 switch (ChipID) {
1494 case DOC_ChipID_DocMilPlus16:
1495 reg = DoC_Mplus_Toggle;
1496 break;
1497 case DOC_ChipID_DocMilPlus32:
1496 printk(KERN_ERR "DiskOnChip Millennium Plus 32MB is not supported, ignoring.\n");
1498 pr_err("DiskOnChip Millennium Plus 32MB is not supported, ignoring.\n");
1497 default:
1498 ret = -ENODEV;
1499 goto notfound;
1500 }
1501 break;
1502
1503 default:
1504 ret = -ENODEV;
1505 goto notfound;
1506 }
1507 /* Check the TOGGLE bit in the ECC register */
1508 tmp = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT;
1509 tmpb = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT;
1510 tmpc = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT;
1511 if ((tmp == tmpb) || (tmp != tmpc)) {
1499 default:
1500 ret = -ENODEV;
1501 goto notfound;
1502 }
1503 break;
1504
1505 default:
1506 ret = -ENODEV;
1507 goto notfound;
1508 }
1509 /* Check the TOGGLE bit in the ECC register */
1510 tmp = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT;
1511 tmpb = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT;
1512 tmpc = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT;
1513 if ((tmp == tmpb) || (tmp != tmpc)) {
1512 printk(KERN_WARNING "Possible DiskOnChip at 0x%lx failed TOGGLE test, dropping.\n", physadr);
1514 pr_warn("Possible DiskOnChip at 0x%lx failed TOGGLE test, dropping.\n", physadr);
1513 ret = -ENODEV;
1514 goto notfound;
1515 }
1516
1517 for (mtd = doclist; mtd; mtd = doc->nextdoc) {
1518 unsigned char oldval;
1519 unsigned char newval;
1520 nand = mtd_to_nand(mtd);

--- 17 unchanged lines hidden (view full) ---

1538 WriteDOC(newval, virtadr, Mplus_AliasResolution); // restore it
1539 } else {
1540 WriteDOC(~newval, virtadr, AliasResolution);
1541 oldval = ReadDOC(doc->virtadr, AliasResolution);
1542 WriteDOC(newval, virtadr, AliasResolution); // restore it
1543 }
1544 newval = ~newval;
1545 if (oldval == newval) {
1515 ret = -ENODEV;
1516 goto notfound;
1517 }
1518
1519 for (mtd = doclist; mtd; mtd = doc->nextdoc) {
1520 unsigned char oldval;
1521 unsigned char newval;
1522 nand = mtd_to_nand(mtd);

--- 17 unchanged lines hidden (view full) ---

1540 WriteDOC(newval, virtadr, Mplus_AliasResolution); // restore it
1541 } else {
1542 WriteDOC(~newval, virtadr, AliasResolution);
1543 oldval = ReadDOC(doc->virtadr, AliasResolution);
1544 WriteDOC(newval, virtadr, AliasResolution); // restore it
1545 }
1546 newval = ~newval;
1547 if (oldval == newval) {
1546 printk(KERN_DEBUG "Found alias of DOC at 0x%lx to 0x%lx\n", doc->physadr, physadr);
1548 pr_debug("Found alias of DOC at 0x%lx to 0x%lx\n",
1549 doc->physadr, physadr);
1547 goto notfound;
1548 }
1549 }
1550
1550 goto notfound;
1551 }
1552 }
1553
1551 printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr);
1554 pr_notice("DiskOnChip found at 0x%lx\n", physadr);
1552
1553 len = sizeof(struct nand_chip) + sizeof(struct doc_priv) +
1554 (2 * sizeof(struct nand_bbt_descr));
1555 nand = kzalloc(len, GFP_KERNEL);
1556 if (!nand) {
1557 ret = -ENOMEM;
1558 goto fail;
1559 }

--- 98 unchanged lines hidden (view full) ---

1658 * Symbolsize is 10 (bits)
1659 * Primitve polynomial is x^10+x^3+1
1660 * first consecutive root is 510
1661 * primitve element to generate roots = 1
1662 * generator polinomial degree = 4
1663 */
1664 rs_decoder = init_rs(10, 0x409, FCR, 1, NROOTS);
1665 if (!rs_decoder) {
1555
1556 len = sizeof(struct nand_chip) + sizeof(struct doc_priv) +
1557 (2 * sizeof(struct nand_bbt_descr));
1558 nand = kzalloc(len, GFP_KERNEL);
1559 if (!nand) {
1560 ret = -ENOMEM;
1561 goto fail;
1562 }

--- 98 unchanged lines hidden (view full) ---

1661 * Symbolsize is 10 (bits)
1662 * Primitve polynomial is x^10+x^3+1
1663 * first consecutive root is 510
1664 * primitve element to generate roots = 1
1665 * generator polinomial degree = 4
1666 */
1667 rs_decoder = init_rs(10, 0x409, FCR, 1, NROOTS);
1668 if (!rs_decoder) {
1666 printk(KERN_ERR "DiskOnChip: Could not create a RS decoder\n");
1669 pr_err("DiskOnChip: Could not create a RS decoder\n");
1667 return -ENOMEM;
1668 }
1669
1670 if (doc_config_location) {
1670 return -ENOMEM;
1671 }
1672
1673 if (doc_config_location) {
1671 printk(KERN_INFO "Using configured DiskOnChip probe address 0x%lx\n", doc_config_location);
1674 pr_info("Using configured DiskOnChip probe address 0x%lx\n",
1675 doc_config_location);
1672 ret = doc_probe(doc_config_location);
1673 if (ret < 0)
1674 goto outerr;
1675 } else {
1676 for (i = 0; (doc_locations[i] != 0xffffffff); i++) {
1677 doc_probe(doc_locations[i]);
1678 }
1679 }
1680 /* No banner message any more. Print a message if no DiskOnChip
1681 found, so the user knows we at least tried. */
1682 if (!doclist) {
1676 ret = doc_probe(doc_config_location);
1677 if (ret < 0)
1678 goto outerr;
1679 } else {
1680 for (i = 0; (doc_locations[i] != 0xffffffff); i++) {
1681 doc_probe(doc_locations[i]);
1682 }
1683 }
1684 /* No banner message any more. Print a message if no DiskOnChip
1685 found, so the user knows we at least tried. */
1686 if (!doclist) {
1683 printk(KERN_INFO "No valid DiskOnChip devices found\n");
1687 pr_info("No valid DiskOnChip devices found\n");
1684 ret = -ENODEV;
1685 goto outerr;
1686 }
1687 return 0;
1688 outerr:
1689 free_rs(rs_decoder);
1690 return ret;
1691}

--- 18 unchanged lines hidden ---
1688 ret = -ENODEV;
1689 goto outerr;
1690 }
1691 return 0;
1692 outerr:
1693 free_rs(rs_decoder);
1694 return ret;
1695}

--- 18 unchanged lines hidden ---