Lines Matching +full:cfi +full:- +full:flash

2    Common Flash Interface probe code.
18 #include <linux/mtd/cfi.h>
28 unsigned long *chip_map, struct cfi_private *cfi);
29 static int cfi_chip_setup(struct map_info *map, struct cfi_private *cfi);
45 #define xip_enable(base, map, cfi) \ argument
47 cfi_qry_mode_off(base, map, cfi); \
51 #define xip_disable_qry(base, map, cfi) \ argument
54 cfi_qry_mode_on(base, map, cfi); \
61 #define xip_enable(base, map, cfi) do { } while (0) argument
62 #define xip_disable_qry(base, map, cfi) do { } while (0) argument
67 * This fixup occurs immediately after reading the CFI structure and can affect
74 void (*fixup)(struct cfi_private *cfi);
77 static void cfi_early_fixup(struct cfi_private *cfi, in cfi_early_fixup() argument
82 for (f = fixups; f->fixup; f++) { in cfi_early_fixup()
83 if (((f->mfr == CFI_MFR_ANY) || (f->mfr == cfi->mfr)) && in cfi_early_fixup()
84 ((f->id == CFI_ID_ANY) || (f->id == cfi->id))) { in cfi_early_fixup()
85 f->fixup(cfi); in cfi_early_fixup()
96 unsigned long *chip_map, struct cfi_private *cfi) in cfi_probe_chip() argument
100 if ((base + 0) >= map->size) { in cfi_probe_chip()
103 (unsigned long)base, map->size -1); in cfi_probe_chip()
106 if ((base + 0xff) >= map->size) { in cfi_probe_chip()
109 (unsigned long)base + 0x55, map->size -1); in cfi_probe_chip()
114 if (!cfi_qry_mode_on(base, map, cfi)) { in cfi_probe_chip()
115 xip_enable(base, map, cfi); in cfi_probe_chip()
119 if (!cfi->numchips) { in cfi_probe_chip()
120 /* This is the first time we're called. Set up the CFI in cfi_probe_chip()
122 return cfi_chip_setup(map, cfi); in cfi_probe_chip()
126 for (i=0; i < (base >> cfi->chipshift); i++) { in cfi_probe_chip()
132 start = i << cfi->chipshift; in cfi_probe_chip()
135 if (cfi_qry_present(map, start, cfi)) { in cfi_probe_chip()
138 cfi_qry_mode_off(start, map, cfi); in cfi_probe_chip()
141 if (!cfi_qry_present(map, start, cfi)) { in cfi_probe_chip()
144 map->name, base, start); in cfi_probe_chip()
151 cfi_qry_mode_off(base, map, cfi); in cfi_probe_chip()
153 if (cfi_qry_present(map, base, cfi)) { in cfi_probe_chip()
156 map->name, base, start); in cfi_probe_chip()
164 set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */ in cfi_probe_chip()
165 cfi->numchips++; in cfi_probe_chip()
168 cfi_qry_mode_off(base, map, cfi); in cfi_probe_chip()
171 printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank\n", in cfi_probe_chip()
172 map->name, cfi->interleave, cfi->device_type*8, base, in cfi_probe_chip()
173 map->bankwidth*8); in cfi_probe_chip()
178 static void fixup_s70gl02gs_chips(struct cfi_private *cfi) in fixup_s70gl02gs_chips() argument
181 * S70GL02GS flash reports a single 256 MiB chip, but is really made up in fixup_s70gl02gs_chips()
184 cfi->cfiq->DevSize = 27; in fixup_s70gl02gs_chips()
185 cfi->cfiq->EraseRegionInfo[0] = 0x20003ff; in fixup_s70gl02gs_chips()
186 pr_warn("Bad S70GL02GS CFI data; adjust to detect 2 chips\n"); in fixup_s70gl02gs_chips()
195 struct cfi_private *cfi) in cfi_chip_setup() argument
197 int ofs_factor = cfi->interleave*cfi->device_type; in cfi_chip_setup()
203 xip_enable(base, map, cfi); in cfi_chip_setup()
210 cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + num_erase_regions * 4, GFP_KERNEL); in cfi_chip_setup()
211 if (!cfi->cfiq) in cfi_chip_setup()
214 memset(cfi->cfiq,0,sizeof(struct cfi_ident)); in cfi_chip_setup()
216 cfi->cfi_mode = CFI_MODE_CFI; in cfi_chip_setup()
218 cfi->sector_erase_cmd = CMD(0x30); in cfi_chip_setup()
220 /* Read the CFI info structure */ in cfi_chip_setup()
221 xip_disable_qry(base, map, cfi); in cfi_chip_setup()
223 ((unsigned char *)cfi->cfiq)[i] = cfi_read_query(map,base + (0x10 + i)*ofs_factor); in cfi_chip_setup()
226 cfi->cfiq->P_ID = le16_to_cpu(cfi->cfiq->P_ID); in cfi_chip_setup()
228 cfi->cfiq->P_ADR = le16_to_cpu(cfi->cfiq->P_ADR); in cfi_chip_setup()
229 cfi->cfiq->A_ID = le16_to_cpu(cfi->cfiq->A_ID); in cfi_chip_setup()
230 cfi->cfiq->A_ADR = le16_to_cpu(cfi->cfiq->A_ADR); in cfi_chip_setup()
231 cfi->cfiq->InterfaceDesc = le16_to_cpu(cfi->cfiq->InterfaceDesc); in cfi_chip_setup()
232 cfi->cfiq->MaxBufWriteSize = le16_to_cpu(cfi->cfiq->MaxBufWriteSize); in cfi_chip_setup()
236 print_cfi_ident(cfi->cfiq); in cfi_chip_setup()
239 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { in cfi_chip_setup()
240 cfi->cfiq->EraseRegionInfo[i] = le32_to_cpu(cfi->cfiq->EraseRegionInfo[i]); in cfi_chip_setup()
244 i, (cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff, in cfi_chip_setup()
245 (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1); in cfi_chip_setup()
249 if (cfi->cfiq->P_ID == P_ID_SST_OLD) { in cfi_chip_setup()
262 cfi_send_gen_cmd(0xf0, 0, base, map, cfi, cfi->device_type, NULL); in cfi_chip_setup()
263 cfi_send_gen_cmd(0xaa, addr_unlock1, base, map, cfi, cfi->device_type, NULL); in cfi_chip_setup()
264 cfi_send_gen_cmd(0x55, addr_unlock2, base, map, cfi, cfi->device_type, NULL); in cfi_chip_setup()
265 cfi_send_gen_cmd(0x90, addr_unlock1, base, map, cfi, cfi->device_type, NULL); in cfi_chip_setup()
266 cfi->mfr = cfi_read_query16(map, base); in cfi_chip_setup()
267 cfi->id = cfi_read_query16(map, base + ofs_factor); in cfi_chip_setup()
270 if (cfi->mfr == CFI_MFR_AMD && (cfi->id & 0xff) == 0x7e) in cfi_chip_setup()
271 cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 | in cfi_chip_setup()
275 cfi_qry_mode_off(base, map, cfi); in cfi_chip_setup()
278 cfi_early_fixup(cfi, cfi_early_fixup_table); in cfi_chip_setup()
280 …printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank. Manufacturer ID %#08x Chip ID %… in cfi_chip_setup()
281 map->name, cfi->interleave, cfi->device_type*8, base, in cfi_chip_setup()
282 map->bankwidth*8, cfi->mfr, cfi->id); in cfi_chip_setup()
342 if (cfip->qry[0] != 'Q' || cfip->qry[1] != 'R' || cfip->qry[2] != 'Y') { in print_cfi_ident()
343 printk("Invalid CFI ident structure.\n"); in print_cfi_ident()
347 printk("Primary Vendor Command Set: %4.4X (%s)\n", cfip->P_ID, vendorname(cfip->P_ID)); in print_cfi_ident()
348 if (cfip->P_ADR) in print_cfi_ident()
349 printk("Primary Algorithm Table at %4.4X\n", cfip->P_ADR); in print_cfi_ident()
353 printk("Alternative Vendor Command Set: %4.4X (%s)\n", cfip->A_ID, vendorname(cfip->A_ID)); in print_cfi_ident()
354 if (cfip->A_ADR) in print_cfi_ident()
355 printk("Alternate Algorithm Table at %4.4X\n", cfip->A_ADR); in print_cfi_ident()
360 printk("Vcc Minimum: %2d.%d V\n", cfip->VccMin >> 4, cfip->VccMin & 0xf); in print_cfi_ident()
361 printk("Vcc Maximum: %2d.%d V\n", cfip->VccMax >> 4, cfip->VccMax & 0xf); in print_cfi_ident()
362 if (cfip->VppMin) { in print_cfi_ident()
363 printk("Vpp Minimum: %2d.%d V\n", cfip->VppMin >> 4, cfip->VppMin & 0xf); in print_cfi_ident()
364 printk("Vpp Maximum: %2d.%d V\n", cfip->VppMax >> 4, cfip->VppMax & 0xf); in print_cfi_ident()
369 printk("Typical byte/word write timeout: %d µs\n", 1<<cfip->WordWriteTimeoutTyp); in print_cfi_ident()
370 …printk("Maximum byte/word write timeout: %d µs\n", (1<<cfip->WordWriteTimeoutMax) * (1<<cfip->Word… in print_cfi_ident()
372 if (cfip->BufWriteTimeoutTyp || cfip->BufWriteTimeoutMax) { in print_cfi_ident()
373 printk("Typical full buffer write timeout: %d µs\n", 1<<cfip->BufWriteTimeoutTyp); in print_cfi_ident()
374 …printk("Maximum full buffer write timeout: %d µs\n", (1<<cfip->BufWriteTimeoutMax) * (1<<cfip->Buf… in print_cfi_ident()
379 printk("Typical block erase timeout: %d ms\n", 1<<cfip->BlockEraseTimeoutTyp); in print_cfi_ident()
380 …printk("Maximum block erase timeout: %d ms\n", (1<<cfip->BlockEraseTimeoutMax) * (1<<cfip->BlockEr… in print_cfi_ident()
381 if (cfip->ChipEraseTimeoutTyp || cfip->ChipEraseTimeoutMax) { in print_cfi_ident()
382 printk("Typical chip erase timeout: %d ms\n", 1<<cfip->ChipEraseTimeoutTyp); in print_cfi_ident()
383 …printk("Maximum chip erase timeout: %d ms\n", (1<<cfip->ChipEraseTimeoutMax) * (1<<cfip->ChipErase… in print_cfi_ident()
388 printk("Device size: 0x%X bytes (%d MiB)\n", 1 << cfip->DevSize, 1<< (cfip->DevSize - 20)); in print_cfi_ident()
389 printk("Flash Device Interface description: 0x%4.4X\n", cfip->InterfaceDesc); in print_cfi_ident()
390 switch(cfip->InterfaceDesc) { in print_cfi_ident()
392 printk(" - x8-only asynchronous interface\n"); in print_cfi_ident()
396 printk(" - x16-only asynchronous interface\n"); in print_cfi_ident()
400 printk(" - supports x8 and x16 via BYTE# with asynchronous interface\n"); in print_cfi_ident()
404 printk(" - x32-only asynchronous interface\n"); in print_cfi_ident()
408 printk(" - supports x16 and x32 via Word# with asynchronous interface\n"); in print_cfi_ident()
412 printk(" - Not Allowed / Reserved\n"); in print_cfi_ident()
416 printk(" - Unknown\n"); in print_cfi_ident()
420 printk("Max. bytes in buffer write: 0x%x\n", 1<< cfip->MaxBufWriteSize); in print_cfi_ident()
421 printk("Number of Erase Block Regions: %d\n", cfip->NumEraseRegions); in print_cfi_ident()
427 .name = "CFI",
434 * Just use the generic probe stuff to call our CFI-specific in cfi_probe()
462 MODULE_DESCRIPTION("Probe code for CFI-compliant flash chips");