diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2005-03-15 14:03:16 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@mtd.linutronix.de> | 2005-05-23 06:53:05 -0400 |
commit | c927cd3a226bed5cf063cdf04de13cef51144cef (patch) | |
tree | ebb14c72811e3d2d76bf8be82799334302600947 /include/linux | |
parent | fb6bb52ddde0429b654ab6d4cb20fa016a1d5b0d (diff) |
[MTD] Add the reverse operation of cfi_build_cmd()
This is necessary to fix the broken status check in cfi_cmdset_0001
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/mtd/cfi.h | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h index 76255474a27c..66e0a32efbac 100644 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h | |||
@@ -1,7 +1,7 @@ | |||
1 | 1 | ||
2 | /* Common Flash Interface structures | 2 | /* Common Flash Interface structures |
3 | * See http://support.intel.com/design/flash/technote/index.htm | 3 | * See http://support.intel.com/design/flash/technote/index.htm |
4 | * $Id: cfi.h,v 1.52 2005/02/08 17:11:15 nico Exp $ | 4 | * $Id: cfi.h,v 1.53 2005/03/15 19:03:13 gleixner Exp $ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef __MTD_CFI_H__ | 7 | #ifndef __MTD_CFI_H__ |
@@ -315,6 +315,69 @@ static inline map_word cfi_build_cmd(u_long cmd, struct map_info *map, struct cf | |||
315 | } | 315 | } |
316 | #define CMD(x) cfi_build_cmd((x), map, cfi) | 316 | #define CMD(x) cfi_build_cmd((x), map, cfi) |
317 | 317 | ||
318 | |||
319 | static inline unsigned char cfi_merge_status(map_word val, struct map_info *map, | ||
320 | struct cfi_private *cfi) | ||
321 | { | ||
322 | int wordwidth, words_per_bus, chip_mode, chips_per_word; | ||
323 | unsigned long onestat, res = 0; | ||
324 | int i; | ||
325 | |||
326 | /* We do it this way to give the compiler a fighting chance | ||
327 | of optimising away all the crap for 'bankwidth' larger than | ||
328 | an unsigned long, in the common case where that support is | ||
329 | disabled */ | ||
330 | if (map_bankwidth_is_large(map)) { | ||
331 | wordwidth = sizeof(unsigned long); | ||
332 | words_per_bus = (map_bankwidth(map)) / wordwidth; // i.e. normally 1 | ||
333 | } else { | ||
334 | wordwidth = map_bankwidth(map); | ||
335 | words_per_bus = 1; | ||
336 | } | ||
337 | |||
338 | chip_mode = map_bankwidth(map) / cfi_interleave(cfi); | ||
339 | chips_per_word = wordwidth * cfi_interleave(cfi) / map_bankwidth(map); | ||
340 | |||
341 | onestat = val.x[0]; | ||
342 | /* Or all status words together */ | ||
343 | for (i=1; i < words_per_bus; i++) { | ||
344 | onestat |= val.x[i]; | ||
345 | } | ||
346 | |||
347 | res = onestat; | ||
348 | switch(chips_per_word) { | ||
349 | default: BUG(); | ||
350 | #if BITS_PER_LONG >= 64 | ||
351 | case 8: | ||
352 | res |= (onestat >> (chip_mode * 32)); | ||
353 | #endif | ||
354 | case 4: | ||
355 | res |= (onestat >> (chip_mode * 16)); | ||
356 | case 2: | ||
357 | res |= (onestat >> (chip_mode * 8)); | ||
358 | case 1: | ||
359 | ; | ||
360 | } | ||
361 | |||
362 | /* Last, determine what the bit-pattern should be for a single | ||
363 | device, according to chip mode and endianness... */ | ||
364 | switch (chip_mode) { | ||
365 | case 1: | ||
366 | break; | ||
367 | case 2: | ||
368 | res = cfi16_to_cpu(res); | ||
369 | break; | ||
370 | case 4: | ||
371 | res = cfi32_to_cpu(res); | ||
372 | break; | ||
373 | default: BUG(); | ||
374 | } | ||
375 | return res; | ||
376 | } | ||
377 | |||
378 | #define MERGESTATUS(x) cfi_merge_status((x), map, cfi) | ||
379 | |||
380 | |||
318 | /* | 381 | /* |
319 | * Sends a CFI command to a bank of flash for the given geometry. | 382 | * Sends a CFI command to a bank of flash for the given geometry. |
320 | * | 383 | * |