diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2014-10-22 19:41:44 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-10-23 03:36:18 -0400 |
commit | b00358a5632bdfc5048fdee04b548ebf8ca1c79c (patch) | |
tree | 823bf2c752375c5849c486ac441e85e4c4286d03 /drivers/mtd | |
parent | d4efafcc040dcc91b09fd393756e4ee4ad7bf9f2 (diff) |
nandsim: add id_bytes module parameter
nandsim can simulate NAND Flash which returns the ID bytes specified
by first_id_byte, ..., fourth_id_byte module parameters.
In order to simulate NAND flash which returns more than four ID bytes,
this adds id_bytes module parameter which is specified by the array of
byte like this:
# modprobe nandsim id_bytes=0x98,0xdc,0x90,0x26,0x76,0x15,0x01,0x08 bch=1
This doesn't add fifth_id_byte, ..., seventh_id_byte module parameters,
because they are redundant. But the existing first_id_byte, ...,
fourth_id_byte module parameters are preserved and add "(obsolete)" to
the description.
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/nandsim.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index 7dc1dd28d896..ab5bbf567439 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -87,10 +87,6 @@ | |||
87 | #define CONFIG_NANDSIM_MAX_PARTS 32 | 87 | #define CONFIG_NANDSIM_MAX_PARTS 32 |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | static uint first_id_byte = CONFIG_NANDSIM_FIRST_ID_BYTE; | ||
91 | static uint second_id_byte = CONFIG_NANDSIM_SECOND_ID_BYTE; | ||
92 | static uint third_id_byte = CONFIG_NANDSIM_THIRD_ID_BYTE; | ||
93 | static uint fourth_id_byte = CONFIG_NANDSIM_FOURTH_ID_BYTE; | ||
94 | static uint access_delay = CONFIG_NANDSIM_ACCESS_DELAY; | 90 | static uint access_delay = CONFIG_NANDSIM_ACCESS_DELAY; |
95 | static uint programm_delay = CONFIG_NANDSIM_PROGRAMM_DELAY; | 91 | static uint programm_delay = CONFIG_NANDSIM_PROGRAMM_DELAY; |
96 | static uint erase_delay = CONFIG_NANDSIM_ERASE_DELAY; | 92 | static uint erase_delay = CONFIG_NANDSIM_ERASE_DELAY; |
@@ -111,11 +107,19 @@ static unsigned int overridesize = 0; | |||
111 | static char *cache_file = NULL; | 107 | static char *cache_file = NULL; |
112 | static unsigned int bbt; | 108 | static unsigned int bbt; |
113 | static unsigned int bch; | 109 | static unsigned int bch; |
110 | static u_char id_bytes[8] = { | ||
111 | [0] = CONFIG_NANDSIM_FIRST_ID_BYTE, | ||
112 | [1] = CONFIG_NANDSIM_SECOND_ID_BYTE, | ||
113 | [2] = CONFIG_NANDSIM_THIRD_ID_BYTE, | ||
114 | [3] = CONFIG_NANDSIM_FOURTH_ID_BYTE, | ||
115 | [4 ... 7] = 0xFF, | ||
116 | }; | ||
114 | 117 | ||
115 | module_param(first_id_byte, uint, 0400); | 118 | module_param_array(id_bytes, byte, NULL, 0400); |
116 | module_param(second_id_byte, uint, 0400); | 119 | module_param_named(first_id_byte, id_bytes[0], byte, 0400); |
117 | module_param(third_id_byte, uint, 0400); | 120 | module_param_named(second_id_byte, id_bytes[1], byte, 0400); |
118 | module_param(fourth_id_byte, uint, 0400); | 121 | module_param_named(third_id_byte, id_bytes[2], byte, 0400); |
122 | module_param_named(fourth_id_byte, id_bytes[3], byte, 0400); | ||
119 | module_param(access_delay, uint, 0400); | 123 | module_param(access_delay, uint, 0400); |
120 | module_param(programm_delay, uint, 0400); | 124 | module_param(programm_delay, uint, 0400); |
121 | module_param(erase_delay, uint, 0400); | 125 | module_param(erase_delay, uint, 0400); |
@@ -136,10 +140,11 @@ module_param(cache_file, charp, 0400); | |||
136 | module_param(bbt, uint, 0400); | 140 | module_param(bbt, uint, 0400); |
137 | module_param(bch, uint, 0400); | 141 | module_param(bch, uint, 0400); |
138 | 142 | ||
139 | MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); | 143 | MODULE_PARM_DESC(id_bytes, "The ID bytes returned by NAND Flash 'read ID' command"); |
140 | MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); | 144 | MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID) (obsolete)"); |
141 | MODULE_PARM_DESC(third_id_byte, "The third byte returned by NAND Flash 'read ID' command"); | 145 | MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID) (obsolete)"); |
142 | MODULE_PARM_DESC(fourth_id_byte, "The fourth byte returned by NAND Flash 'read ID' command"); | 146 | MODULE_PARM_DESC(third_id_byte, "The third byte returned by NAND Flash 'read ID' command (obsolete)"); |
147 | MODULE_PARM_DESC(fourth_id_byte, "The fourth byte returned by NAND Flash 'read ID' command (obsolete)"); | ||
143 | MODULE_PARM_DESC(access_delay, "Initial page access delay (microseconds)"); | 148 | MODULE_PARM_DESC(access_delay, "Initial page access delay (microseconds)"); |
144 | MODULE_PARM_DESC(programm_delay, "Page programm delay (microseconds"); | 149 | MODULE_PARM_DESC(programm_delay, "Page programm delay (microseconds"); |
145 | MODULE_PARM_DESC(erase_delay, "Sector erase delay (milliseconds)"); | 150 | MODULE_PARM_DESC(erase_delay, "Sector erase delay (milliseconds)"); |
@@ -304,7 +309,7 @@ struct nandsim { | |||
304 | unsigned int nbparts; | 309 | unsigned int nbparts; |
305 | 310 | ||
306 | uint busw; /* flash chip bus width (8 or 16) */ | 311 | uint busw; /* flash chip bus width (8 or 16) */ |
307 | u_char ids[4]; /* chip's ID bytes */ | 312 | u_char ids[8]; /* chip's ID bytes */ |
308 | uint32_t options; /* chip's characteristic bits */ | 313 | uint32_t options; /* chip's characteristic bits */ |
309 | uint32_t state; /* current chip state */ | 314 | uint32_t state; /* current chip state */ |
310 | uint32_t nxstate; /* next expected state */ | 315 | uint32_t nxstate; /* next expected state */ |
@@ -2279,17 +2284,18 @@ static int __init ns_init_module(void) | |||
2279 | * Perform minimum nandsim structure initialization to handle | 2284 | * Perform minimum nandsim structure initialization to handle |
2280 | * the initial ID read command correctly | 2285 | * the initial ID read command correctly |
2281 | */ | 2286 | */ |
2282 | if (third_id_byte != 0xFF || fourth_id_byte != 0xFF) | 2287 | if (id_bytes[6] != 0xFF || id_bytes[7] != 0xFF) |
2288 | nand->geom.idbytes = 8; | ||
2289 | else if (id_bytes[4] != 0xFF || id_bytes[5] != 0xFF) | ||
2290 | nand->geom.idbytes = 6; | ||
2291 | else if (id_bytes[2] != 0xFF || id_bytes[3] != 0xFF) | ||
2283 | nand->geom.idbytes = 4; | 2292 | nand->geom.idbytes = 4; |
2284 | else | 2293 | else |
2285 | nand->geom.idbytes = 2; | 2294 | nand->geom.idbytes = 2; |
2286 | nand->regs.status = NS_STATUS_OK(nand); | 2295 | nand->regs.status = NS_STATUS_OK(nand); |
2287 | nand->nxstate = STATE_UNKNOWN; | 2296 | nand->nxstate = STATE_UNKNOWN; |
2288 | nand->options |= OPT_PAGE512; /* temporary value */ | 2297 | nand->options |= OPT_PAGE512; /* temporary value */ |
2289 | nand->ids[0] = first_id_byte; | 2298 | memcpy(nand->ids, id_bytes, sizeof(nand->ids)); |
2290 | nand->ids[1] = second_id_byte; | ||
2291 | nand->ids[2] = third_id_byte; | ||
2292 | nand->ids[3] = fourth_id_byte; | ||
2293 | if (bus_width == 16) { | 2299 | if (bus_width == 16) { |
2294 | nand->busw = 16; | 2300 | nand->busw = 16; |
2295 | chip->options |= NAND_BUSWIDTH_16; | 2301 | chip->options |= NAND_BUSWIDTH_16; |