24 #include <linux/types.h>
32 #ifdef CONFIG_MTD_CFI_I1
33 #define cfi_interleave(cfi) 1
34 #define cfi_interleave_is_1(cfi) (cfi_interleave(cfi) == 1)
36 #define cfi_interleave_is_1(cfi) (0)
39 #ifdef CONFIG_MTD_CFI_I2
40 # ifdef cfi_interleave
41 # undef cfi_interleave
42 # define cfi_interleave(cfi) ((cfi)->interleave)
44 # define cfi_interleave(cfi) 2
46 #define cfi_interleave_is_2(cfi) (cfi_interleave(cfi) == 2)
48 #define cfi_interleave_is_2(cfi) (0)
51 #ifdef CONFIG_MTD_CFI_I4
52 # ifdef cfi_interleave
53 # undef cfi_interleave
54 # define cfi_interleave(cfi) ((cfi)->interleave)
56 # define cfi_interleave(cfi) 4
58 #define cfi_interleave_is_4(cfi) (cfi_interleave(cfi) == 4)
60 #define cfi_interleave_is_4(cfi) (0)
63 #ifdef CONFIG_MTD_CFI_I8
64 # ifdef cfi_interleave
65 # undef cfi_interleave
66 # define cfi_interleave(cfi) ((cfi)->interleave)
68 # define cfi_interleave(cfi) 8
70 #define cfi_interleave_is_8(cfi) (cfi_interleave(cfi) == 8)
72 #define cfi_interleave_is_8(cfi) (0)
75 #ifndef cfi_interleave
76 #warning No CONFIG_MTD_CFI_Ix selected. No NOR chip support can work.
77 static inline int cfi_interleave(
void *cfi)
84 static inline int cfi_interleave_supported(
int i)
87 #ifdef CONFIG_MTD_CFI_I1
90 #ifdef CONFIG_MTD_CFI_I2
93 #ifdef CONFIG_MTD_CFI_I4
96 #ifdef CONFIG_MTD_CFI_I8
111 #define CFI_DEVICETYPE_X8 (8 / 8)
112 #define CFI_DEVICETYPE_X16 (16 / 8)
113 #define CFI_DEVICETYPE_X32 (32 / 8)
114 #define CFI_DEVICETYPE_X64 (64 / 8)
120 #define CFI_INTERFACE_X8_ASYNC 0x0000
121 #define CFI_INTERFACE_X16_ASYNC 0x0001
122 #define CFI_INTERFACE_X8_BY_X16_ASYNC 0x0002
123 #define CFI_INTERFACE_X32_ASYNC 0x0003
124 #define CFI_INTERFACE_X16_BY_X32_ASYNC 0x0005
125 #define CFI_INTERFACE_NOT_ALLOWED 0xffff
261 #define P_ID_NONE 0x0000
262 #define P_ID_INTEL_EXT 0x0001
263 #define P_ID_AMD_STD 0x0002
264 #define P_ID_INTEL_STD 0x0003
265 #define P_ID_AMD_EXT 0x0004
266 #define P_ID_WINBOND 0x0006
267 #define P_ID_ST_ADV 0x0020
268 #define P_ID_MITSUBISHI_STD 0x0100
269 #define P_ID_MITSUBISHI_EXT 0x0101
270 #define P_ID_SST_PAGE 0x0102
271 #define P_ID_SST_OLD 0x0701
272 #define P_ID_INTEL_PERFORMANCE 0x0200
273 #define P_ID_INTEL_DATA 0x0210
274 #define P_ID_RESERVED 0xffff
277 #define CFI_MODE_CFI 1
278 #define CFI_MODE_JEDEC 0
305 unsigned bankwidth = map_bankwidth(map);
310 addr = (cmd_ofs *
type) * interleave;
317 if (((type * interleave) > bankwidth) && ((cmd_ofs & 0xff) == 0xaa))
331 int wordwidth, words_per_bus, chip_mode, chips_per_word;
332 unsigned long onecmd;
340 wordwidth =
sizeof(
unsigned long);
341 words_per_bus = (map_bankwidth(map)) / wordwidth;
343 wordwidth = map_bankwidth(map);
347 chip_mode = map_bankwidth(map) / cfi_interleave(cfi);
348 chips_per_word = wordwidth * cfi_interleave(cfi) / map_bankwidth(map);
367 switch (chips_per_word) {
369 #if BITS_PER_LONG >= 64
371 onecmd |= (onecmd << (chip_mode * 32));
374 onecmd |= (onecmd << (chip_mode * 16));
376 onecmd |= (onecmd << (chip_mode * 8));
383 for (i=0; i < words_per_bus; i++) {
389 #define CMD(x) cfi_build_cmd((x), map, cfi)
392 static inline unsigned long cfi_merge_status(
map_word val,
struct map_info *map,
395 int wordwidth, words_per_bus, chip_mode, chips_per_word;
396 unsigned long onestat,
res = 0;
404 wordwidth =
sizeof(
unsigned long);
405 words_per_bus = (map_bankwidth(map)) / wordwidth;
407 wordwidth = map_bankwidth(map);
411 chip_mode = map_bankwidth(map) / cfi_interleave(cfi);
412 chips_per_word = wordwidth * cfi_interleave(cfi) / map_bankwidth(map);
416 for (i=1; i < words_per_bus; i++) {
421 switch(chips_per_word) {
423 #if BITS_PER_LONG >= 64
425 res |= (onestat >> (chip_mode * 32));
428 res |= (onestat >> (chip_mode * 16));
430 res |= (onestat >> (chip_mode * 8));
451 #define MERGESTATUS(x) cfi_merge_status((x), map, cfi)
466 uint32_t addr = base + cfi_build_cmd_addr(cmd_addr, map, cfi);
467 val = cfi_build_cmd(cmd, map, cfi);
498 return val.
x[0] & 0xff;
509 static inline void cfi_udelay(
int us)
534 #define CFI_MFR_ANY 0xFFFF
535 #define CFI_ID_ANY 0xFFFF
536 #define CFI_MFR_CONTINUATION 0x007F
538 #define CFI_MFR_AMD 0x0001
539 #define CFI_MFR_AMIC 0x0037
540 #define CFI_MFR_ATMEL 0x001F
541 #define CFI_MFR_EON 0x001C
542 #define CFI_MFR_FUJITSU 0x0004
543 #define CFI_MFR_HYUNDAI 0x00AD
544 #define CFI_MFR_INTEL 0x0089
545 #define CFI_MFR_MACRONIX 0x00C2
546 #define CFI_MFR_NEC 0x0010
547 #define CFI_MFR_PMC 0x009D
548 #define CFI_MFR_SAMSUNG 0x00EC
549 #define CFI_MFR_SHARP 0x00B0
550 #define CFI_MFR_SST 0x00BF
551 #define CFI_MFR_ST 0x0020
552 #define CFI_MFR_TOSHIBA 0x0098
553 #define CFI_MFR_WINBOND 0x00DA
558 unsigned long adr,
int len,
void *thunk);
561 loff_t ofs,
size_t len,
void *thunk);