Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4509
b: refs/heads/master
c: c927cd3
h: refs/heads/master
i:
  4507: 06de731
v: v3
  • Loading branch information
Thomas Gleixner authored and Thomas Gleixner committed May 23, 2005
1 parent dd8c4ec commit bab8eb2
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fb6bb52ddde0429b654ab6d4cb20fa016a1d5b0d
refs/heads/master: c927cd3a226bed5cf063cdf04de13cef51144cef
65 changes: 64 additions & 1 deletion trunk/include/linux/mtd/cfi.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/* Common Flash Interface structures
* See http://support.intel.com/design/flash/technote/index.htm
* $Id: cfi.h,v 1.52 2005/02/08 17:11:15 nico Exp $
* $Id: cfi.h,v 1.53 2005/03/15 19:03:13 gleixner Exp $
*/

#ifndef __MTD_CFI_H__
Expand Down Expand Up @@ -315,6 +315,69 @@ static inline map_word cfi_build_cmd(u_long cmd, struct map_info *map, struct cf
}
#define CMD(x) cfi_build_cmd((x), map, cfi)


static inline unsigned char cfi_merge_status(map_word val, struct map_info *map,
struct cfi_private *cfi)
{
int wordwidth, words_per_bus, chip_mode, chips_per_word;
unsigned long onestat, res = 0;
int i;

/* We do it this way to give the compiler a fighting chance
of optimising away all the crap for 'bankwidth' larger than
an unsigned long, in the common case where that support is
disabled */
if (map_bankwidth_is_large(map)) {
wordwidth = sizeof(unsigned long);
words_per_bus = (map_bankwidth(map)) / wordwidth; // i.e. normally 1
} else {
wordwidth = map_bankwidth(map);
words_per_bus = 1;
}

chip_mode = map_bankwidth(map) / cfi_interleave(cfi);
chips_per_word = wordwidth * cfi_interleave(cfi) / map_bankwidth(map);

onestat = val.x[0];
/* Or all status words together */
for (i=1; i < words_per_bus; i++) {
onestat |= val.x[i];
}

res = onestat;
switch(chips_per_word) {
default: BUG();
#if BITS_PER_LONG >= 64
case 8:
res |= (onestat >> (chip_mode * 32));
#endif
case 4:
res |= (onestat >> (chip_mode * 16));
case 2:
res |= (onestat >> (chip_mode * 8));
case 1:
;
}

/* Last, determine what the bit-pattern should be for a single
device, according to chip mode and endianness... */
switch (chip_mode) {
case 1:
break;
case 2:
res = cfi16_to_cpu(res);
break;
case 4:
res = cfi32_to_cpu(res);
break;
default: BUG();
}
return res;
}

#define MERGESTATUS(x) cfi_merge_status((x), map, cfi)


/*
* Sends a CFI command to a bank of flash for the given geometry.
*
Expand Down

0 comments on commit bab8eb2

Please sign in to comment.