aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorDan Brown <dan_brown@ieee.org>2005-03-29 15:57:48 -0500
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-05-23 07:04:36 -0400
commit1a78ff6b4114cfb0f734b7df217759315d692683 (patch)
tree279791ef920eeef1ba87f0305b722cd5fa4c5a14 /drivers/mtd/nand
parent15fc108606a499df44549274a95d1e3455823347 (diff)
[MTD] DiskOnChip: Scan the entire device for Media Headers.
Add a new module param, show_firmware_partition. Signed-off-by: Dan Brown <dan_brown@ieee.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/diskonchip.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index a9b1da40ad32..a96c43b4ea15 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -16,7 +16,7 @@
16 * 16 *
17 * Interface to generic NAND code for M-Systems DiskOnChip devices 17 * Interface to generic NAND code for M-Systems DiskOnChip devices
18 * 18 *
19 * $Id: diskonchip.c,v 1.49 2005/02/22 21:48:21 gleixner Exp $ 19 * $Id: diskonchip.c,v 1.50 2005/03/29 20:57:45 dbrown Exp $
20 */ 20 */
21 21
22#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -81,11 +81,6 @@ struct doc_priv {
81 struct mtd_info *nextdoc; 81 struct mtd_info *nextdoc;
82}; 82};
83 83
84/* Max number of eraseblocks to scan (from start of device) for the (I)NFTL
85 MediaHeader. The spec says to just keep going, I think, but that's just
86 silly. */
87#define MAX_MEDIAHEADER_SCAN 8
88
89/* This is the syndrome computed by the HW ecc generator upon reading an empty 84/* This is the syndrome computed by the HW ecc generator upon reading an empty
90 page, one with all 0xff for data and stored ecc code. */ 85 page, one with all 0xff for data and stored ecc code. */
91static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a }; 86static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a };
@@ -114,6 +109,9 @@ module_param(no_ecc_failures, int, 0);
114#ifdef CONFIG_MTD_PARTITIONS 109#ifdef CONFIG_MTD_PARTITIONS
115static int no_autopart=0; 110static int no_autopart=0;
116module_param(no_autopart, int, 0); 111module_param(no_autopart, int, 0);
112
113static int show_firmware_partition=0;
114module_param(show_firmware_partition, int, 0);
117#endif 115#endif
118 116
119#ifdef MTD_NAND_DISKONCHIP_BBTWRITE 117#ifdef MTD_NAND_DISKONCHIP_BBTWRITE
@@ -1071,12 +1069,11 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf,
1071{ 1069{
1072 struct nand_chip *this = mtd->priv; 1070 struct nand_chip *this = mtd->priv;
1073 struct doc_priv *doc = this->priv; 1071 struct doc_priv *doc = this->priv;
1074 unsigned offs, end = (MAX_MEDIAHEADER_SCAN << this->phys_erase_shift); 1072 unsigned offs;
1075 int ret; 1073 int ret;
1076 size_t retlen; 1074 size_t retlen;
1077 1075
1078 end = min(end, mtd->size); // paranoia 1076 for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
1079 for (offs = 0; offs < end; offs += mtd->erasesize) {
1080 ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); 1077 ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf);
1081 if (retlen != mtd->oobblock) continue; 1078 if (retlen != mtd->oobblock) continue;
1082 if (ret) { 1079 if (ret) {
@@ -1118,6 +1115,7 @@ static inline int __init nftl_partscan(struct mtd_info *mtd,
1118 u_char *buf; 1115 u_char *buf;
1119 struct NFTLMediaHeader *mh; 1116 struct NFTLMediaHeader *mh;
1120 const unsigned psize = 1 << this->page_shift; 1117 const unsigned psize = 1 << this->page_shift;
1118 int numparts = 0;
1121 unsigned blocks, maxblocks; 1119 unsigned blocks, maxblocks;
1122 int offs, numheaders; 1120 int offs, numheaders;
1123 1121
@@ -1183,19 +1181,28 @@ static inline int __init nftl_partscan(struct mtd_info *mtd,
1183 offs <<= this->page_shift; 1181 offs <<= this->page_shift;
1184 offs += mtd->erasesize; 1182 offs += mtd->erasesize;
1185 1183
1186 parts[0].name = " DiskOnChip BDTL partition"; 1184 if (show_firmware_partition == 1) {
1187 parts[0].offset = offs; 1185 parts[0].name = " DiskOnChip Firmware / Media Header partition";
1188 parts[0].size = (mh->NumEraseUnits - numheaders) << this->bbt_erase_shift; 1186 parts[0].offset = 0;
1187 parts[0].size = offs;
1188 numparts = 1;
1189 }
1190
1191 parts[numparts].name = " DiskOnChip BDTL partition";
1192 parts[numparts].offset = offs;
1193 parts[numparts].size = (mh->NumEraseUnits - numheaders) << this->bbt_erase_shift;
1194
1195 offs += parts[numparts].size;
1196 numparts++;
1189 1197
1190 offs += parts[0].size;
1191 if (offs < mtd->size) { 1198 if (offs < mtd->size) {
1192 parts[1].name = " DiskOnChip Remainder partition"; 1199 parts[numparts].name = " DiskOnChip Remainder partition";
1193 parts[1].offset = offs; 1200 parts[numparts].offset = offs;
1194 parts[1].size = mtd->size - offs; 1201 parts[numparts].size = mtd->size - offs;
1195 ret = 2; 1202 numparts++;
1196 goto out;
1197 } 1203 }
1198 ret = 1; 1204
1205 ret = numparts;
1199out: 1206out:
1200 kfree(buf); 1207 kfree(buf);
1201 return ret; 1208 return ret;
@@ -1289,14 +1296,13 @@ static inline int __init inftl_partscan(struct mtd_info *mtd,
1289 ip->lastUnit, ip->flags, 1296 ip->lastUnit, ip->flags,
1290 ip->spareUnits); 1297 ip->spareUnits);
1291 1298
1292#if 0 1299 if ((show_firmware_partition == 1) &&
1293 if ((i == 0) && (ip->firstUnit > 0)) { 1300 (i == 0) && (ip->firstUnit > 0)) {
1294 parts[0].name = " DiskOnChip IPL / Media Header partition"; 1301 parts[0].name = " DiskOnChip IPL / Media Header partition";
1295 parts[0].offset = 0; 1302 parts[0].offset = 0;
1296 parts[0].size = mtd->erasesize * ip->firstUnit; 1303 parts[0].size = mtd->erasesize * ip->firstUnit;
1297 numparts = 1; 1304 numparts = 1;
1298 } 1305 }
1299#endif
1300 1306
1301 if (ip->flags & INFTL_BINARY) 1307 if (ip->flags & INFTL_BINARY)
1302 parts[numparts].name = " DiskOnChip BDK partition"; 1308 parts[numparts].name = " DiskOnChip BDK partition";