aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2010-09-29 13:43:54 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-10-24 19:55:03 -0400
commitce85b79fe809eaf34b84a9ebf4ac37ee37b3455b (patch)
treea58614c5cff44094477444f203537be0065a43f7 /drivers/mtd/nand
parent453281a973c10bce941b240d1c654d536623b16b (diff)
mtd: nandsim: add module param for BBT handling
I used this to check the BBT on flash together with a hack in mtdchar in order to read bad blocks. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/nandsim.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index c25648bb5793..a6a73aab1253 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -107,6 +107,7 @@ static char *gravepages = NULL;
107static unsigned int rptwear = 0; 107static unsigned int rptwear = 0;
108static unsigned int overridesize = 0; 108static unsigned int overridesize = 0;
109static char *cache_file = NULL; 109static char *cache_file = NULL;
110static unsigned int bbt;
110 111
111module_param(first_id_byte, uint, 0400); 112module_param(first_id_byte, uint, 0400);
112module_param(second_id_byte, uint, 0400); 113module_param(second_id_byte, uint, 0400);
@@ -130,6 +131,7 @@ module_param(gravepages, charp, 0400);
130module_param(rptwear, uint, 0400); 131module_param(rptwear, uint, 0400);
131module_param(overridesize, uint, 0400); 132module_param(overridesize, uint, 0400);
132module_param(cache_file, charp, 0400); 133module_param(cache_file, charp, 0400);
134module_param(bbt, uint, 0400);
133 135
134MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); 136MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)");
135MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); 137MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)");
@@ -162,6 +164,7 @@ MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the I
162 "The size is specified in erase blocks and as the exponent of a power of two" 164 "The size is specified in erase blocks and as the exponent of a power of two"
163 " e.g. 5 means a size of 32 erase blocks"); 165 " e.g. 5 means a size of 32 erase blocks");
164MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memory"); 166MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memory");
167MODULE_PARM_DESC(bbt, "0 OOB, 1 BBT with marker in OOB, 2 BBT with marker in data area");
165 168
166/* The largest possible page size */ 169/* The largest possible page size */
167#define NS_LARGEST_PAGE_SIZE 4096 170#define NS_LARGEST_PAGE_SIZE 4096
@@ -2264,6 +2267,18 @@ static int __init ns_init_module(void)
2264 /* and 'badblocks' parameters to work */ 2267 /* and 'badblocks' parameters to work */
2265 chip->options |= NAND_SKIP_BBTSCAN; 2268 chip->options |= NAND_SKIP_BBTSCAN;
2266 2269
2270 switch (bbt) {
2271 case 2:
2272 chip->options |= NAND_USE_FLASH_BBT_NO_OOB;
2273 case 1:
2274 chip->options |= NAND_USE_FLASH_BBT;
2275 case 0:
2276 break;
2277 default:
2278 NS_ERR("bbt has to be 0..2\n");
2279 retval = -EINVAL;
2280 goto error;
2281 }
2267 /* 2282 /*
2268 * Perform minimum nandsim structure initialization to handle 2283 * Perform minimum nandsim structure initialization to handle
2269 * the initial ID read command correctly 2284 * the initial ID read command correctly
@@ -2321,10 +2336,10 @@ static int __init ns_init_module(void)
2321 if ((retval = init_nandsim(nsmtd)) != 0) 2336 if ((retval = init_nandsim(nsmtd)) != 0)
2322 goto err_exit; 2337 goto err_exit;
2323 2338
2324 if ((retval = parse_badblocks(nand, nsmtd)) != 0) 2339 if ((retval = nand_default_bbt(nsmtd)) != 0)
2325 goto err_exit; 2340 goto err_exit;
2326 2341
2327 if ((retval = nand_default_bbt(nsmtd)) != 0) 2342 if ((retval = parse_badblocks(nand, nsmtd)) != 0)
2328 goto err_exit; 2343 goto err_exit;
2329 2344
2330 /* Register NAND partitions */ 2345 /* Register NAND partitions */