Skip to content

Commit

Permalink
[MTD] CFI: Use 16-bit access to autoselect/read device id data
Browse files Browse the repository at this point in the history
Recent models of Intel/Sharp and Spansion CFI flash now have significant
bits in the upper byte of device ID codes, read via what Spansion calls
"autoselect" and Intel calls "read device identifier".  Currently these
values are truncated to the low 8 bits in the mtd data structures, as
all CFI read query info has previously been read one byte at a time.
Add a new method for reading 16-bit info, currently just manufacturer
and device codes; datasheets hint at future uses for upper bytes in
other fields.

Signed-off-by: Todd Poynor <tpoynor@mvista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Todd Poynor authored and Thomas Gleixner committed Nov 29, 2005
1 parent 3eb8cea commit 987d240
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions drivers/mtd/chips/cfi_probe.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Common Flash Interface probe code.
(C) 2000 Red Hat. GPL'd.
$Id: cfi_probe.c,v 1.84 2005/11/07 11:14:23 gleixner Exp $
$Id: cfi_probe.c,v 1.85 2005/11/15 23:28:17 tpoynor Exp $
*/

#include <linux/config.h>
Expand Down Expand Up @@ -230,8 +230,8 @@ static int __xipram cfi_chip_setup(struct map_info *map,
cfi_send_gen_cmd(0xaa, 0x555, base, map, cfi, cfi->device_type, NULL);
cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL);
cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL);
cfi->mfr = cfi_read_query(map, base);
cfi->id = cfi_read_query(map, base + ofs_factor);
cfi->mfr = cfi_read_query16(map, base);
cfi->id = cfi_read_query16(map, base + ofs_factor);

/* Put it back into Read Mode */
cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
Expand Down
18 changes: 17 additions & 1 deletion 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.56 2005/11/07 11:14:54 gleixner Exp $
* $Id: cfi.h,v 1.57 2005/11/15 23:28:17 tpoynor Exp $
*/

#ifndef __MTD_CFI_H__
Expand Down Expand Up @@ -426,6 +426,22 @@ static inline uint8_t cfi_read_query(struct map_info *map, uint32_t addr)
}
}

static inline uint16_t cfi_read_query16(struct map_info *map, uint32_t addr)
{
map_word val = map_read(map, addr);

if (map_bankwidth_is_1(map)) {
return val.x[0] & 0xff;
} else if (map_bankwidth_is_2(map)) {
return cfi16_to_cpu(val.x[0]);
} else {
/* No point in a 64-bit byteswap since that would just be
swapping the responses from different chips, and we are
only interested in one chip (a representative sample) */
return cfi32_to_cpu(val.x[0]);
}
}

static inline void cfi_udelay(int us)
{
if (us >= 1000) {
Expand Down

0 comments on commit 987d240

Please sign in to comment.