Skip to content

Commit 5c9c11e

Browse files
Mike Rapoportdwmw2
authored andcommitted
[MTD] [NOR] Add support for flash chips with ID in bank other than 0
According to JEDEC "Standard Manufacturer's Identification Code" (http://www.jedec.org/download/search/jep106W.pdf) several first banks of NOR flash can contain 0x7f instead of actual ID. This patch adds support for reading manufacturer ID from banks other than 0. Signed-off-by: Mike Rapoport <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
1 parent 8fd310a commit 5c9c11e

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

drivers/mtd/chips/jedec_probe.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define MANUFACTURER_ST 0x0020
3838
#define MANUFACTURER_TOSHIBA 0x0098
3939
#define MANUFACTURER_WINBOND 0x00da
40+
#define CONTINUATION_CODE 0x007f
4041

4142

4243
/* AMD */
@@ -1760,9 +1761,21 @@ static inline u32 jedec_read_mfr(struct map_info *map, uint32_t base,
17601761
{
17611762
map_word result;
17621763
unsigned long mask;
1763-
u32 ofs = cfi_build_cmd_addr(0, cfi_interleave(cfi), cfi->device_type);
1764-
mask = (1 << (cfi->device_type * 8)) -1;
1765-
result = map_read(map, base + ofs);
1764+
int bank = 0;
1765+
1766+
/* According to JEDEC "Standard Manufacturer's Identification Code"
1767+
* (http://www.jedec.org/download/search/jep106W.pdf)
1768+
* several first banks can contain 0x7f instead of actual ID
1769+
*/
1770+
do {
1771+
uint32_t ofs = cfi_build_cmd_addr(0 + (bank << 8),
1772+
cfi_interleave(cfi),
1773+
cfi->device_type);
1774+
mask = (1 << (cfi->device_type * 8)) - 1;
1775+
result = map_read(map, base + ofs);
1776+
bank++;
1777+
} while ((result.x[0] & mask) == CONTINUATION_CODE);
1778+
17661779
return result.x[0] & mask;
17671780
}
17681781

0 commit comments

Comments
 (0)