diff options
Diffstat (limited to 'drivers/mtd/chips/cfi_probe.c')
-rw-r--r-- | drivers/mtd/chips/cfi_probe.c | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c index cf750038ce6a..90eb30e06b7c 100644 --- a/drivers/mtd/chips/cfi_probe.c +++ b/drivers/mtd/chips/cfi_probe.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | Common Flash Interface probe code. | 2 | Common Flash Interface probe code. |
3 | (C) 2000 Red Hat. GPL'd. | 3 | (C) 2000 Red Hat. GPL'd. |
4 | $Id: cfi_probe.c,v 1.83 2004/11/16 18:19:02 nico Exp $ | 4 | $Id: cfi_probe.c,v 1.84 2005/11/07 11:14:23 gleixner Exp $ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <linux/config.h> | 7 | #include <linux/config.h> |
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/mtd/cfi.h> | 20 | #include <linux/mtd/cfi.h> |
21 | #include <linux/mtd/gen_probe.h> | 21 | #include <linux/mtd/gen_probe.h> |
22 | 22 | ||
23 | //#define DEBUG_CFI | 23 | //#define DEBUG_CFI |
24 | 24 | ||
25 | #ifdef DEBUG_CFI | 25 | #ifdef DEBUG_CFI |
26 | static void print_cfi_ident(struct cfi_ident *); | 26 | static void print_cfi_ident(struct cfi_ident *); |
@@ -103,7 +103,7 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base, | |||
103 | unsigned long *chip_map, struct cfi_private *cfi) | 103 | unsigned long *chip_map, struct cfi_private *cfi) |
104 | { | 104 | { |
105 | int i; | 105 | int i; |
106 | 106 | ||
107 | if ((base + 0) >= map->size) { | 107 | if ((base + 0) >= map->size) { |
108 | printk(KERN_NOTICE | 108 | printk(KERN_NOTICE |
109 | "Probe at base[0x00](0x%08lx) past the end of the map(0x%08lx)\n", | 109 | "Probe at base[0x00](0x%08lx) past the end of the map(0x%08lx)\n", |
@@ -128,7 +128,7 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base, | |||
128 | } | 128 | } |
129 | 129 | ||
130 | if (!cfi->numchips) { | 130 | if (!cfi->numchips) { |
131 | /* This is the first time we're called. Set up the CFI | 131 | /* This is the first time we're called. Set up the CFI |
132 | stuff accordingly and return */ | 132 | stuff accordingly and return */ |
133 | return cfi_chip_setup(map, cfi); | 133 | return cfi_chip_setup(map, cfi); |
134 | } | 134 | } |
@@ -138,13 +138,13 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base, | |||
138 | unsigned long start; | 138 | unsigned long start; |
139 | if(!test_bit(i, chip_map)) { | 139 | if(!test_bit(i, chip_map)) { |
140 | /* Skip location; no valid chip at this address */ | 140 | /* Skip location; no valid chip at this address */ |
141 | continue; | 141 | continue; |
142 | } | 142 | } |
143 | start = i << cfi->chipshift; | 143 | start = i << cfi->chipshift; |
144 | /* This chip should be in read mode if it's one | 144 | /* This chip should be in read mode if it's one |
145 | we've already touched. */ | 145 | we've already touched. */ |
146 | if (qry_present(map, start, cfi)) { | 146 | if (qry_present(map, start, cfi)) { |
147 | /* Eep. This chip also had the QRY marker. | 147 | /* Eep. This chip also had the QRY marker. |
148 | * Is it an alias for the new one? */ | 148 | * Is it an alias for the new one? */ |
149 | cfi_send_gen_cmd(0xF0, 0, start, map, cfi, cfi->device_type, NULL); | 149 | cfi_send_gen_cmd(0xF0, 0, start, map, cfi, cfi->device_type, NULL); |
150 | cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL); | 150 | cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL); |
@@ -156,13 +156,13 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base, | |||
156 | map->name, base, start); | 156 | map->name, base, start); |
157 | return 0; | 157 | return 0; |
158 | } | 158 | } |
159 | /* Yes, it's actually got QRY for data. Most | 159 | /* Yes, it's actually got QRY for data. Most |
160 | * unfortunate. Stick the new chip in read mode | 160 | * unfortunate. Stick the new chip in read mode |
161 | * too and if it's the same, assume it's an alias. */ | 161 | * too and if it's the same, assume it's an alias. */ |
162 | /* FIXME: Use other modes to do a proper check */ | 162 | /* FIXME: Use other modes to do a proper check */ |
163 | cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); | 163 | cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); |
164 | cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL); | 164 | cfi_send_gen_cmd(0xFF, 0, start, map, cfi, cfi->device_type, NULL); |
165 | 165 | ||
166 | if (qry_present(map, base, cfi)) { | 166 | if (qry_present(map, base, cfi)) { |
167 | xip_allowed(base, map); | 167 | xip_allowed(base, map); |
168 | printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx\n", | 168 | printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx\n", |
@@ -171,12 +171,12 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base, | |||
171 | } | 171 | } |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | /* OK, if we got to here, then none of the previous chips appear to | 175 | /* OK, if we got to here, then none of the previous chips appear to |
176 | be aliases for the current one. */ | 176 | be aliases for the current one. */ |
177 | set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */ | 177 | set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */ |
178 | cfi->numchips++; | 178 | cfi->numchips++; |
179 | 179 | ||
180 | /* Put it back into Read Mode */ | 180 | /* Put it back into Read Mode */ |
181 | cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); | 181 | cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); |
182 | cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); | 182 | cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL); |
@@ -185,11 +185,11 @@ static int __xipram cfi_probe_chip(struct map_info *map, __u32 base, | |||
185 | printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", | 185 | printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", |
186 | map->name, cfi->interleave, cfi->device_type*8, base, | 186 | map->name, cfi->interleave, cfi->device_type*8, base, |
187 | map->bankwidth*8); | 187 | map->bankwidth*8); |
188 | 188 | ||
189 | return 1; | 189 | return 1; |
190 | } | 190 | } |
191 | 191 | ||
192 | static int __xipram cfi_chip_setup(struct map_info *map, | 192 | static int __xipram cfi_chip_setup(struct map_info *map, |
193 | struct cfi_private *cfi) | 193 | struct cfi_private *cfi) |
194 | { | 194 | { |
195 | int ofs_factor = cfi->interleave*cfi->device_type; | 195 | int ofs_factor = cfi->interleave*cfi->device_type; |
@@ -209,11 +209,11 @@ static int __xipram cfi_chip_setup(struct map_info *map, | |||
209 | printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name); | 209 | printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name); |
210 | return 0; | 210 | return 0; |
211 | } | 211 | } |
212 | 212 | ||
213 | memset(cfi->cfiq,0,sizeof(struct cfi_ident)); | 213 | memset(cfi->cfiq,0,sizeof(struct cfi_ident)); |
214 | 214 | ||
215 | cfi->cfi_mode = CFI_MODE_CFI; | 215 | cfi->cfi_mode = CFI_MODE_CFI; |
216 | 216 | ||
217 | /* Read the CFI info structure */ | 217 | /* Read the CFI info structure */ |
218 | xip_disable_qry(base, map, cfi); | 218 | xip_disable_qry(base, map, cfi); |
219 | for (i=0; i<(sizeof(struct cfi_ident) + num_erase_regions * 4); i++) | 219 | for (i=0; i<(sizeof(struct cfi_ident) + num_erase_regions * 4); i++) |
@@ -231,7 +231,7 @@ static int __xipram cfi_chip_setup(struct map_info *map, | |||
231 | cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL); | 231 | cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL); |
232 | cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL); | 232 | cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL); |
233 | cfi->mfr = cfi_read_query(map, base); | 233 | cfi->mfr = cfi_read_query(map, base); |
234 | cfi->id = cfi_read_query(map, base + ofs_factor); | 234 | cfi->id = cfi_read_query(map, base + ofs_factor); |
235 | 235 | ||
236 | /* Put it back into Read Mode */ | 236 | /* Put it back into Read Mode */ |
237 | cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); | 237 | cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); |
@@ -255,10 +255,10 @@ static int __xipram cfi_chip_setup(struct map_info *map, | |||
255 | 255 | ||
256 | for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { | 256 | for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { |
257 | cfi->cfiq->EraseRegionInfo[i] = le32_to_cpu(cfi->cfiq->EraseRegionInfo[i]); | 257 | cfi->cfiq->EraseRegionInfo[i] = le32_to_cpu(cfi->cfiq->EraseRegionInfo[i]); |
258 | 258 | ||
259 | #ifdef DEBUG_CFI | 259 | #ifdef DEBUG_CFI |
260 | printk(" Erase Region #%d: BlockSize 0x%4.4X bytes, %d blocks\n", | 260 | printk(" Erase Region #%d: BlockSize 0x%4.4X bytes, %d blocks\n", |
261 | i, (cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff, | 261 | i, (cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff, |
262 | (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1); | 262 | (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1); |
263 | #endif | 263 | #endif |
264 | } | 264 | } |
@@ -271,33 +271,33 @@ static int __xipram cfi_chip_setup(struct map_info *map, | |||
271 | } | 271 | } |
272 | 272 | ||
273 | #ifdef DEBUG_CFI | 273 | #ifdef DEBUG_CFI |
274 | static char *vendorname(__u16 vendor) | 274 | static char *vendorname(__u16 vendor) |
275 | { | 275 | { |
276 | switch (vendor) { | 276 | switch (vendor) { |
277 | case P_ID_NONE: | 277 | case P_ID_NONE: |
278 | return "None"; | 278 | return "None"; |
279 | 279 | ||
280 | case P_ID_INTEL_EXT: | 280 | case P_ID_INTEL_EXT: |
281 | return "Intel/Sharp Extended"; | 281 | return "Intel/Sharp Extended"; |
282 | 282 | ||
283 | case P_ID_AMD_STD: | 283 | case P_ID_AMD_STD: |
284 | return "AMD/Fujitsu Standard"; | 284 | return "AMD/Fujitsu Standard"; |
285 | 285 | ||
286 | case P_ID_INTEL_STD: | 286 | case P_ID_INTEL_STD: |
287 | return "Intel/Sharp Standard"; | 287 | return "Intel/Sharp Standard"; |
288 | 288 | ||
289 | case P_ID_AMD_EXT: | 289 | case P_ID_AMD_EXT: |
290 | return "AMD/Fujitsu Extended"; | 290 | return "AMD/Fujitsu Extended"; |
291 | 291 | ||
292 | case P_ID_WINBOND: | 292 | case P_ID_WINBOND: |
293 | return "Winbond Standard"; | 293 | return "Winbond Standard"; |
294 | 294 | ||
295 | case P_ID_ST_ADV: | 295 | case P_ID_ST_ADV: |
296 | return "ST Advanced"; | 296 | return "ST Advanced"; |
297 | 297 | ||
298 | case P_ID_MITSUBISHI_STD: | 298 | case P_ID_MITSUBISHI_STD: |
299 | return "Mitsubishi Standard"; | 299 | return "Mitsubishi Standard"; |
300 | 300 | ||
301 | case P_ID_MITSUBISHI_EXT: | 301 | case P_ID_MITSUBISHI_EXT: |
302 | return "Mitsubishi Extended"; | 302 | return "Mitsubishi Extended"; |
303 | 303 | ||
@@ -306,13 +306,13 @@ static char *vendorname(__u16 vendor) | |||
306 | 306 | ||
307 | case P_ID_INTEL_PERFORMANCE: | 307 | case P_ID_INTEL_PERFORMANCE: |
308 | return "Intel Performance Code"; | 308 | return "Intel Performance Code"; |
309 | 309 | ||
310 | case P_ID_INTEL_DATA: | 310 | case P_ID_INTEL_DATA: |
311 | return "Intel Data"; | 311 | return "Intel Data"; |
312 | 312 | ||
313 | case P_ID_RESERVED: | 313 | case P_ID_RESERVED: |
314 | return "Not Allowed / Reserved for Future Use"; | 314 | return "Not Allowed / Reserved for Future Use"; |
315 | 315 | ||
316 | default: | 316 | default: |
317 | return "Unknown"; | 317 | return "Unknown"; |
318 | } | 318 | } |
@@ -325,21 +325,21 @@ static void print_cfi_ident(struct cfi_ident *cfip) | |||
325 | if (cfip->qry[0] != 'Q' || cfip->qry[1] != 'R' || cfip->qry[2] != 'Y') { | 325 | if (cfip->qry[0] != 'Q' || cfip->qry[1] != 'R' || cfip->qry[2] != 'Y') { |
326 | printk("Invalid CFI ident structure.\n"); | 326 | printk("Invalid CFI ident structure.\n"); |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | #endif | 329 | #endif |
330 | printk("Primary Vendor Command Set: %4.4X (%s)\n", cfip->P_ID, vendorname(cfip->P_ID)); | 330 | printk("Primary Vendor Command Set: %4.4X (%s)\n", cfip->P_ID, vendorname(cfip->P_ID)); |
331 | if (cfip->P_ADR) | 331 | if (cfip->P_ADR) |
332 | printk("Primary Algorithm Table at %4.4X\n", cfip->P_ADR); | 332 | printk("Primary Algorithm Table at %4.4X\n", cfip->P_ADR); |
333 | else | 333 | else |
334 | printk("No Primary Algorithm Table\n"); | 334 | printk("No Primary Algorithm Table\n"); |
335 | 335 | ||
336 | printk("Alternative Vendor Command Set: %4.4X (%s)\n", cfip->A_ID, vendorname(cfip->A_ID)); | 336 | printk("Alternative Vendor Command Set: %4.4X (%s)\n", cfip->A_ID, vendorname(cfip->A_ID)); |
337 | if (cfip->A_ADR) | 337 | if (cfip->A_ADR) |
338 | printk("Alternate Algorithm Table at %4.4X\n", cfip->A_ADR); | 338 | printk("Alternate Algorithm Table at %4.4X\n", cfip->A_ADR); |
339 | else | 339 | else |
340 | printk("No Alternate Algorithm Table\n"); | 340 | printk("No Alternate Algorithm Table\n"); |
341 | 341 | ||
342 | 342 | ||
343 | printk("Vcc Minimum: %2d.%d V\n", cfip->VccMin >> 4, cfip->VccMin & 0xf); | 343 | printk("Vcc Minimum: %2d.%d V\n", cfip->VccMin >> 4, cfip->VccMin & 0xf); |
344 | printk("Vcc Maximum: %2d.%d V\n", cfip->VccMax >> 4, cfip->VccMax & 0xf); | 344 | printk("Vcc Maximum: %2d.%d V\n", cfip->VccMax >> 4, cfip->VccMax & 0xf); |
345 | if (cfip->VppMin) { | 345 | if (cfip->VppMin) { |
@@ -348,61 +348,61 @@ static void print_cfi_ident(struct cfi_ident *cfip) | |||
348 | } | 348 | } |
349 | else | 349 | else |
350 | printk("No Vpp line\n"); | 350 | printk("No Vpp line\n"); |
351 | 351 | ||
352 | printk("Typical byte/word write timeout: %d µs\n", 1<<cfip->WordWriteTimeoutTyp); | 352 | printk("Typical byte/word write timeout: %d µs\n", 1<<cfip->WordWriteTimeoutTyp); |
353 | printk("Maximum byte/word write timeout: %d µs\n", (1<<cfip->WordWriteTimeoutMax) * (1<<cfip->WordWriteTimeoutTyp)); | 353 | printk("Maximum byte/word write timeout: %d µs\n", (1<<cfip->WordWriteTimeoutMax) * (1<<cfip->WordWriteTimeoutTyp)); |
354 | 354 | ||
355 | if (cfip->BufWriteTimeoutTyp || cfip->BufWriteTimeoutMax) { | 355 | if (cfip->BufWriteTimeoutTyp || cfip->BufWriteTimeoutMax) { |
356 | printk("Typical full buffer write timeout: %d µs\n", 1<<cfip->BufWriteTimeoutTyp); | 356 | printk("Typical full buffer write timeout: %d µs\n", 1<<cfip->BufWriteTimeoutTyp); |
357 | printk("Maximum full buffer write timeout: %d µs\n", (1<<cfip->BufWriteTimeoutMax) * (1<<cfip->BufWriteTimeoutTyp)); | 357 | printk("Maximum full buffer write timeout: %d µs\n", (1<<cfip->BufWriteTimeoutMax) * (1<<cfip->BufWriteTimeoutTyp)); |
358 | } | 358 | } |
359 | else | 359 | else |
360 | printk("Full buffer write not supported\n"); | 360 | printk("Full buffer write not supported\n"); |
361 | 361 | ||
362 | printk("Typical block erase timeout: %d ms\n", 1<<cfip->BlockEraseTimeoutTyp); | 362 | printk("Typical block erase timeout: %d ms\n", 1<<cfip->BlockEraseTimeoutTyp); |
363 | printk("Maximum block erase timeout: %d ms\n", (1<<cfip->BlockEraseTimeoutMax) * (1<<cfip->BlockEraseTimeoutTyp)); | 363 | printk("Maximum block erase timeout: %d ms\n", (1<<cfip->BlockEraseTimeoutMax) * (1<<cfip->BlockEraseTimeoutTyp)); |
364 | if (cfip->ChipEraseTimeoutTyp || cfip->ChipEraseTimeoutMax) { | 364 | if (cfip->ChipEraseTimeoutTyp || cfip->ChipEraseTimeoutMax) { |
365 | printk("Typical chip erase timeout: %d ms\n", 1<<cfip->ChipEraseTimeoutTyp); | 365 | printk("Typical chip erase timeout: %d ms\n", 1<<cfip->ChipEraseTimeoutTyp); |
366 | printk("Maximum chip erase timeout: %d ms\n", (1<<cfip->ChipEraseTimeoutMax) * (1<<cfip->ChipEraseTimeoutTyp)); | 366 | printk("Maximum chip erase timeout: %d ms\n", (1<<cfip->ChipEraseTimeoutMax) * (1<<cfip->ChipEraseTimeoutTyp)); |
367 | } | 367 | } |
368 | else | 368 | else |
369 | printk("Chip erase not supported\n"); | 369 | printk("Chip erase not supported\n"); |
370 | 370 | ||
371 | printk("Device size: 0x%X bytes (%d MiB)\n", 1 << cfip->DevSize, 1<< (cfip->DevSize - 20)); | 371 | printk("Device size: 0x%X bytes (%d MiB)\n", 1 << cfip->DevSize, 1<< (cfip->DevSize - 20)); |
372 | printk("Flash Device Interface description: 0x%4.4X\n", cfip->InterfaceDesc); | 372 | printk("Flash Device Interface description: 0x%4.4X\n", cfip->InterfaceDesc); |
373 | switch(cfip->InterfaceDesc) { | 373 | switch(cfip->InterfaceDesc) { |
374 | case 0: | 374 | case 0: |
375 | printk(" - x8-only asynchronous interface\n"); | 375 | printk(" - x8-only asynchronous interface\n"); |
376 | break; | 376 | break; |
377 | 377 | ||
378 | case 1: | 378 | case 1: |
379 | printk(" - x16-only asynchronous interface\n"); | 379 | printk(" - x16-only asynchronous interface\n"); |
380 | break; | 380 | break; |
381 | 381 | ||
382 | case 2: | 382 | case 2: |
383 | printk(" - supports x8 and x16 via BYTE# with asynchronous interface\n"); | 383 | printk(" - supports x8 and x16 via BYTE# with asynchronous interface\n"); |
384 | break; | 384 | break; |
385 | 385 | ||
386 | case 3: | 386 | case 3: |
387 | printk(" - x32-only asynchronous interface\n"); | 387 | printk(" - x32-only asynchronous interface\n"); |
388 | break; | 388 | break; |
389 | 389 | ||
390 | case 4: | 390 | case 4: |
391 | printk(" - supports x16 and x32 via Word# with asynchronous interface\n"); | 391 | printk(" - supports x16 and x32 via Word# with asynchronous interface\n"); |
392 | break; | 392 | break; |
393 | 393 | ||
394 | case 65535: | 394 | case 65535: |
395 | printk(" - Not Allowed / Reserved\n"); | 395 | printk(" - Not Allowed / Reserved\n"); |
396 | break; | 396 | break; |
397 | 397 | ||
398 | default: | 398 | default: |
399 | printk(" - Unknown\n"); | 399 | printk(" - Unknown\n"); |
400 | break; | 400 | break; |
401 | } | 401 | } |
402 | 402 | ||
403 | printk("Max. bytes in buffer write: 0x%x\n", 1<< cfip->MaxBufWriteSize); | 403 | printk("Max. bytes in buffer write: 0x%x\n", 1<< cfip->MaxBufWriteSize); |
404 | printk("Number of Erase Block Regions: %d\n", cfip->NumEraseRegions); | 404 | printk("Number of Erase Block Regions: %d\n", cfip->NumEraseRegions); |
405 | 405 | ||
406 | } | 406 | } |
407 | #endif /* DEBUG_CFI */ | 407 | #endif /* DEBUG_CFI */ |
408 | 408 | ||