diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2008-11-01 07:19:11 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-11-05 08:40:25 -0500 |
commit | 467622ef2acb01986eab37ef96c3632b3ea35999 (patch) | |
tree | b483202500c418696a14ee00857f7c7f6c20bbe4 /include/linux/mtd | |
parent | b27cf88e9592953ae292d05324887f2f44979433 (diff) |
[MTD] [NOR] Fix cfi_send_gen_cmd handling of x16 devices in x8 mode (v4)
For "unlock" cycles to 16bit devices in 8bit compatibility mode we need
to use the byte addresses 0xaaa and 0x555. These effectively match
the word address 0x555 and 0x2aa, except the latter has its low bit set.
Most chips don't care about the value of the 'A-1' pin in x8 mode,
but some -- like the ST M29W320D -- do. So we need to be careful to
set it where appropriate.
cfi_send_gen_cmd is only ever passed addresses where the low byte
is 0x00, 0x55 or 0xaa. Of those, only addresses ending 0xaa are
affected by this patch, by masking in the extra low bit when the device
is known to be in compatibility mode.
[dwmw2: Do it only when (cmd_ofs & 0xff) == 0xaa]
v4: Fix stupid typo in cfi_build_cmd_addr that failed to compile
I'm writing this patch way to late at night.
v3: Bring all of the work back into cfi_build_cmd_addr
including calling of map_bankwidth(map) and cfi_interleave(cfi)
So every caller doesn't need to.
v2: Only modified the address if we our device_type is larger than our
bus width.
Cc: stable@kernel.org
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'include/linux/mtd')
-rw-r--r-- | include/linux/mtd/cfi.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h index ee5124ec319e..00e2b575021f 100644 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h | |||
@@ -282,9 +282,25 @@ struct cfi_private { | |||
282 | /* | 282 | /* |
283 | * Returns the command address according to the given geometry. | 283 | * Returns the command address according to the given geometry. |
284 | */ | 284 | */ |
285 | static inline uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs, int interleave, int type) | 285 | static inline uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs, |
286 | struct map_info *map, struct cfi_private *cfi) | ||
286 | { | 287 | { |
287 | return (cmd_ofs * type) * interleave; | 288 | unsigned bankwidth = map_bankwidth(map); |
289 | unsigned interleave = cfi_interleave(cfi); | ||
290 | unsigned type = cfi->device_type; | ||
291 | uint32_t addr; | ||
292 | |||
293 | addr = (cmd_ofs * type) * interleave; | ||
294 | |||
295 | /* Modify the unlock address if we are in compatiblity mode. | ||
296 | * For 16bit devices on 8 bit busses | ||
297 | * and 32bit devices on 16 bit busses | ||
298 | * set the low bit of the alternating bit sequence of the address. | ||
299 | */ | ||
300 | if (((type * interleave) > bankwidth) && ((uint8_t)cmd_ofs == 0xaa)) | ||
301 | addr |= (type >> 1)*interleave; | ||
302 | |||
303 | return addr; | ||
288 | } | 304 | } |
289 | 305 | ||
290 | /* | 306 | /* |
@@ -430,7 +446,7 @@ static inline uint32_t cfi_send_gen_cmd(u_char cmd, uint32_t cmd_addr, uint32_t | |||
430 | int type, map_word *prev_val) | 446 | int type, map_word *prev_val) |
431 | { | 447 | { |
432 | map_word val; | 448 | map_word val; |
433 | uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, cfi_interleave(cfi), type); | 449 | uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, map, cfi); |
434 | val = cfi_build_cmd(cmd, map, cfi); | 450 | val = cfi_build_cmd(cmd, map, cfi); |
435 | 451 | ||
436 | if (prev_val) | 452 | if (prev_val) |