diff options
author | Adrian Hunter <ext-adrian.hunter@nokia.com> | 2007-03-19 06:49:11 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2007-04-17 13:55:55 -0400 |
commit | a5ac8aeb29000fcab8d91848273a6616fcd039ee (patch) | |
tree | 491f9159b7b6222a217197fdc4a6e31604eb10f4 | |
parent | 57aa6b545f6f772dd317ccd29bdada999b16a13d (diff) |
[MTD] nandsim: enhance nandsim to allow arbitrary NAND size
A new module parameter has been added called 'overridesize',
which overrides the size that would be determined by the
ID bytes. 'overridesize' is specified in erase blocks and
as the exponent of a power of two e.g. 5 means a size of
32 erase blocks.
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rw-r--r-- | drivers/mtd/nand/nandsim.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index 1a44ef63c8d1..205df0f771fe 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -100,6 +100,7 @@ static char *weakpages = NULL; | |||
100 | static unsigned int bitflips = 0; | 100 | static unsigned int bitflips = 0; |
101 | static char *gravepages = NULL; | 101 | static char *gravepages = NULL; |
102 | static unsigned int rptwear = 0; | 102 | static unsigned int rptwear = 0; |
103 | static unsigned int overridesize = 0; | ||
103 | 104 | ||
104 | module_param(first_id_byte, uint, 0400); | 105 | module_param(first_id_byte, uint, 0400); |
105 | module_param(second_id_byte, uint, 0400); | 106 | module_param(second_id_byte, uint, 0400); |
@@ -121,8 +122,9 @@ module_param(weakpages, charp, 0400); | |||
121 | module_param(bitflips, uint, 0400); | 122 | module_param(bitflips, uint, 0400); |
122 | module_param(gravepages, charp, 0400); | 123 | module_param(gravepages, charp, 0400); |
123 | module_param(rptwear, uint, 0400); | 124 | module_param(rptwear, uint, 0400); |
125 | module_param(overridesize, uint, 0400); | ||
124 | 126 | ||
125 | MODULE_PARM_DESC(first_id_byte, "The fist byte returned by NAND Flash 'read ID' command (manufaturer ID)"); | 127 | MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); |
126 | MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); | 128 | MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); |
127 | MODULE_PARM_DESC(third_id_byte, "The third byte returned by NAND Flash 'read ID' command"); | 129 | MODULE_PARM_DESC(third_id_byte, "The third byte returned by NAND Flash 'read ID' command"); |
128 | MODULE_PARM_DESC(fourth_id_byte, "The fourth byte returned by NAND Flash 'read ID' command"); | 130 | MODULE_PARM_DESC(fourth_id_byte, "The fourth byte returned by NAND Flash 'read ID' command"); |
@@ -149,6 +151,9 @@ MODULE_PARM_DESC(gravepages, "Pages that lose data [: maximum reads (default | |||
149 | " separated by commas e.g. 1401:2 means page 1401" | 151 | " separated by commas e.g. 1401:2 means page 1401" |
150 | " can be read only twice before failing"); | 152 | " can be read only twice before failing"); |
151 | MODULE_PARM_DESC(rptwear, "Number of erases inbetween reporting wear, if not zero"); | 153 | MODULE_PARM_DESC(rptwear, "Number of erases inbetween reporting wear, if not zero"); |
154 | MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the ID bytes. " | ||
155 | "The size is specified in erase blocks and as the exponent of a power of two" | ||
156 | " e.g. 5 means a size of 32 erase blocks"); | ||
152 | 157 | ||
153 | /* The largest possible page size */ | 158 | /* The largest possible page size */ |
154 | #define NS_LARGEST_PAGE_SIZE 2048 | 159 | #define NS_LARGEST_PAGE_SIZE 2048 |
@@ -1959,6 +1964,8 @@ static int __init ns_init_module(void) | |||
1959 | chip->verify_buf = ns_nand_verify_buf; | 1964 | chip->verify_buf = ns_nand_verify_buf; |
1960 | chip->read_word = ns_nand_read_word; | 1965 | chip->read_word = ns_nand_read_word; |
1961 | chip->ecc.mode = NAND_ECC_SOFT; | 1966 | chip->ecc.mode = NAND_ECC_SOFT; |
1967 | /* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */ | ||
1968 | /* and 'badblocks' parameters to work */ | ||
1962 | chip->options |= NAND_SKIP_BBTSCAN; | 1969 | chip->options |= NAND_SKIP_BBTSCAN; |
1963 | 1970 | ||
1964 | /* | 1971 | /* |
@@ -1999,6 +2006,18 @@ static int __init ns_init_module(void) | |||
1999 | goto error; | 2006 | goto error; |
2000 | } | 2007 | } |
2001 | 2008 | ||
2009 | if (overridesize) { | ||
2010 | u_int32_t new_size = nsmtd->erasesize << overridesize; | ||
2011 | if (new_size >> overridesize != nsmtd->erasesize) { | ||
2012 | NS_ERR("overridesize is too big\n"); | ||
2013 | goto err_exit; | ||
2014 | } | ||
2015 | /* N.B. This relies on nand_scan not doing anything with the size before we change it */ | ||
2016 | nsmtd->size = new_size; | ||
2017 | chip->chipsize = new_size; | ||
2018 | chip->chip_shift = ffs(new_size) - 1; | ||
2019 | } | ||
2020 | |||
2002 | if ((retval = setup_wear_reporting(nsmtd)) != 0) | 2021 | if ((retval = setup_wear_reporting(nsmtd)) != 0) |
2003 | goto err_exit; | 2022 | goto err_exit; |
2004 | 2023 | ||