6 #include <linux/module.h>
7 #include <linux/types.h>
8 #include <linux/kernel.h>
11 #include <asm/byteorder.h>
12 #include <linux/errno.h>
13 #include <linux/slab.h>
24 static void print_cfi_ident(
struct cfi_ident *);
36 #define xip_disable() local_irq_disable()
38 #define xip_allowed(base, map) \
40 (void) map_read(map, base); \
45 #define xip_enable(base, map, cfi) \
47 cfi_qry_mode_off(base, map, cfi); \
48 xip_allowed(base, map); \
51 #define xip_disable_qry(base, map, cfi) \
54 cfi_qry_mode_on(base, map, cfi); \
59 #define xip_disable() do { } while (0)
60 #define xip_allowed(base, map) do { } while (0)
61 #define xip_enable(base, map, cfi) do { } while (0)
62 #define xip_disable_qry(base, map, cfi) do { } while (0)
76 if ((base + 0) >= map->
size) {
78 "Probe at base[0x00](0x%08lx) past the end of the map(0x%08lx)\n",
79 (
unsigned long)base, map->
size -1);
82 if ((base + 0xff) >= map->
size) {
84 "Probe at base[0x55](0x%08lx) past the end of the map(0x%08lx)\n",
85 (
unsigned long)base + 0x55, map->
size -1);
98 return cfi_chip_setup(map, cfi);
102 for (i=0; i < (base >> cfi->
chipshift); i++) {
120 map->
name, base, start);
132 map->
name, base, start);
159 int num_erase_regions = cfi_read_query(map, base + (0x10 + 28)*ofs_factor);
161 int addr_unlock1 = 0x555, addr_unlock2 = 0x2AA;
165 printk(
"Number of erase regions: %d\n", num_erase_regions);
167 if (!num_erase_regions)
184 for (i=0; i<(
sizeof(
struct cfi_ident) + num_erase_regions * 4); i++)
185 ((
unsigned char *)cfi->
cfiq)[i] = cfi_read_query(map,base + (0x10 + i)*ofs_factor);
198 print_cfi_ident(cfi->
cfiq);
201 for (i=0; i<cfi->
cfiq->NumEraseRegions; i++) {
205 printk(
" Erase Region #%d: BlockSize 0x%4.4X bytes, %d blocks\n",
206 i, (cfi->
cfiq->EraseRegionInfo[i] >> 8) & ~0xff,
207 (cfi->
cfiq->EraseRegionInfo[i] & 0xffff) + 1);
212 addr_unlock1 = 0x5555;
213 addr_unlock2 = 0x2AAA;
225 cfi_send_gen_cmd(0xaa, addr_unlock1, base, map, cfi, cfi->
device_type,
NULL);
226 cfi_send_gen_cmd(0x55, addr_unlock2, base, map, cfi, cfi->
device_type,
NULL);
227 cfi_send_gen_cmd(0x90, addr_unlock1, base, map, cfi, cfi->
device_type,
NULL);
228 cfi->
mfr = cfi_read_query16(map, base);
229 cfi->
id = cfi_read_query16(map, base + ofs_factor);
233 cfi->
id = cfi_read_query(map, base + 0
xe * ofs_factor) << 8 |
234 cfi_read_query(map, base + 0xf * ofs_factor);
240 printk(
KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank. Manufacturer ID %#08x Chip ID %#08x\n",
255 return "Intel/Sharp Extended";
258 return "AMD/Fujitsu Standard";
261 return "Intel/Sharp Standard";
264 return "AMD/Fujitsu Extended";
267 return "Winbond Standard";
270 return "ST Advanced";
273 return "Mitsubishi Standard";
276 return "Mitsubishi Extended";
279 return "SST Page Write";
282 return "SST 39VF160x/39VF320x";
285 return "Intel Performance Code";
291 return "Not Allowed / Reserved for Future Use";
299 static void print_cfi_ident(
struct cfi_ident *cfip)
302 if (cfip->
qry[0] !=
'Q' || cfip->
qry[1] !=
'R' || cfip->
qry[2] !=
'Y') {
303 printk(
"Invalid CFI ident structure.\n");
309 printk(
"Primary Algorithm Table at %4.4X\n", cfip->
P_ADR);
311 printk(
"No Primary Algorithm Table\n");
315 printk(
"Alternate Algorithm Table at %4.4X\n", cfip->
A_ADR);
317 printk(
"No Alternate Algorithm Table\n");
337 printk(
"Full buffer write not supported\n");
346 printk(
"Chip erase not supported\n");
352 printk(
" - x8-only asynchronous interface\n");
356 printk(
" - x16-only asynchronous interface\n");
360 printk(
" - supports x8 and x16 via BYTE# with asynchronous interface\n");
364 printk(
" - x32-only asynchronous interface\n");
368 printk(
" - supports x16 and x32 via Word# with asynchronous interface\n");
372 printk(
" - Not Allowed / Reserved\n");
388 .probe_chip = cfi_probe_chip
406 static int __init cfi_probe_init(
void)
412 static void __exit cfi_probe_exit(
void)