Blame view

drivers/mtd/chips/cfi_probe.c 11.6 KB
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
1
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
     Common Flash Interface probe code.
     (C) 2000 Red Hat. GPL'd.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
  */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #include <linux/module.h>
  #include <linux/types.h>
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <asm/io.h>
  #include <asm/byteorder.h>
  #include <linux/errno.h>
  #include <linux/slab.h>
  #include <linux/interrupt.h>
  
  #include <linux/mtd/xip.h>
  #include <linux/mtd/map.h>
  #include <linux/mtd/cfi.h>
  #include <linux/mtd/gen_probe.h>
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
19
  //#define DEBUG_CFI
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  
  #ifdef DEBUG_CFI
  static void print_cfi_ident(struct cfi_ident *);
  #endif
  
  static int cfi_probe_chip(struct map_info *map, __u32 base,
  			  unsigned long *chip_map, struct cfi_private *cfi);
  static int cfi_chip_setup(struct map_info *map, struct cfi_private *cfi);
  
  struct mtd_info *cfi_probe(struct map_info *map);
  
  #ifdef CONFIG_MTD_XIP
  
  /* only needed for short periods, so this is rather simple */
  #define xip_disable()	local_irq_disable()
  
  #define xip_allowed(base, map) \
  do { \
  	(void) map_read(map, base); \
ca5c23c3b   Paulius Zaleckas   [MTD] XIP: Use ge...
39
  	xip_iprefetch(); \
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
42
43
44
  	local_irq_enable(); \
  } while (0)
  
  #define xip_enable(base, map, cfi) \
  do { \
c314dfdc3   David Woodhouse   [MTD] [NOR] Renam...
45
  	cfi_qry_mode_off(base, map, cfi);		\
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
48
49
50
51
  	xip_allowed(base, map); \
  } while (0)
  
  #define xip_disable_qry(base, map, cfi) \
  do { \
  	xip_disable(); \
c314dfdc3   David Woodhouse   [MTD] [NOR] Renam...
52
  	cfi_qry_mode_on(base, map, cfi); \
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  } while (0)
  
  #else
  
  #define xip_disable()			do { } while (0)
  #define xip_allowed(base, map)		do { } while (0)
  #define xip_enable(base, map, cfi)	do { } while (0)
  #define xip_disable_qry(base, map, cfi) do { } while (0)
  
  #endif
  
  /* check for QRY.
     in: interleave,type,mode
     ret: table index, <0 for error
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
69
70
71
72
  
  static int __xipram cfi_probe_chip(struct map_info *map, __u32 base,
  				   unsigned long *chip_map, struct cfi_private *cfi)
  {
  	int i;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
73

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
  	if ((base + 0) >= map->size) {
  		printk(KERN_NOTICE
  			"Probe at base[0x00](0x%08lx) past the end of the map(0x%08lx)
  ",
  			(unsigned long)base, map->size -1);
  		return 0;
  	}
  	if ((base + 0xff) >= map->size) {
  		printk(KERN_NOTICE
  			"Probe at base[0x55](0x%08lx) past the end of the map(0x%08lx)
  ",
  			(unsigned long)base + 0x55, map->size -1);
  		return 0;
  	}
  
  	xip_disable();
c314dfdc3   David Woodhouse   [MTD] [NOR] Renam...
90
  	if (!cfi_qry_mode_on(base, map, cfi)) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
92
93
94
95
  		xip_enable(base, map, cfi);
  		return 0;
  	}
  
  	if (!cfi->numchips) {
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
96
  		/* This is the first time we're called. Set up the CFI
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
97
98
99
100
101
102
103
104
105
  		   stuff accordingly and return */
  		return cfi_chip_setup(map, cfi);
  	}
  
  	/* Check each previous chip to see if it's an alias */
   	for (i=0; i < (base >> cfi->chipshift); i++) {
   		unsigned long start;
   		if(!test_bit(i, chip_map)) {
  			/* Skip location; no valid chip at this address */
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
106
   			continue;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
108
109
110
   		}
   		start = i << cfi->chipshift;
  		/* This chip should be in read mode if it's one
  		   we've already touched. */
c314dfdc3   David Woodhouse   [MTD] [NOR] Renam...
111
  		if (cfi_qry_present(map, start, cfi)) {
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
112
  			/* Eep. This chip also had the QRY marker.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
  			 * Is it an alias for the new one? */
c314dfdc3   David Woodhouse   [MTD] [NOR] Renam...
114
  			cfi_qry_mode_off(start, map, cfi);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
115
116
  
  			/* If the QRY marker goes away, it's an alias */
c314dfdc3   David Woodhouse   [MTD] [NOR] Renam...
117
  			if (!cfi_qry_present(map, start, cfi)) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
119
120
121
122
123
  				xip_allowed(base, map);
  				printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx
  ",
  				       map->name, base, start);
  				return 0;
  			}
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
124
  			/* Yes, it's actually got QRY for data. Most
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
125
126
127
  			 * unfortunate. Stick the new chip in read mode
  			 * too and if it's the same, assume it's an alias. */
  			/* FIXME: Use other modes to do a proper check */
c314dfdc3   David Woodhouse   [MTD] [NOR] Renam...
128
  			cfi_qry_mode_off(base, map, cfi);
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
129

c314dfdc3   David Woodhouse   [MTD] [NOR] Renam...
130
  			if (cfi_qry_present(map, base, cfi)) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
131
132
133
134
135
136
137
138
  				xip_allowed(base, map);
  				printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx
  ",
  				       map->name, base, start);
  				return 0;
  			}
  		}
  	}
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
139

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
141
142
143
  	/* OK, if we got to here, then none of the previous chips appear to
  	   be aliases for the current one. */
  	set_bit((base >> cfi->chipshift), chip_map); /* Update chip map */
  	cfi->numchips++;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
144

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
145
  	/* Put it back into Read Mode */
c314dfdc3   David Woodhouse   [MTD] [NOR] Renam...
146
  	cfi_qry_mode_off(base, map, cfi);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
147
148
149
150
151
152
  	xip_allowed(base, map);
  
  	printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank
  ",
  	       map->name, cfi->interleave, cfi->device_type*8, base,
  	       map->bankwidth*8);
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
153

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
154
155
  	return 1;
  }
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
156
  static int __xipram cfi_chip_setup(struct map_info *map,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
157
158
159
160
161
162
  				   struct cfi_private *cfi)
  {
  	int ofs_factor = cfi->interleave*cfi->device_type;
  	__u32 base = 0;
  	int num_erase_regions = cfi_read_query(map, base + (0x10 + 28)*ofs_factor);
  	int i;
ad7026fef   Guillaume LECERF   mtd: cfi_probe: m...
163
  	int addr_unlock1 = 0x555, addr_unlock2 = 0x2AA;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
164
165
166
167
168
169
170
171
172
173
  
  	xip_enable(base, map, cfi);
  #ifdef DEBUG_CFI
  	printk("Number of erase regions: %d
  ", num_erase_regions);
  #endif
  	if (!num_erase_regions)
  		return 0;
  
  	cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + num_erase_regions * 4, GFP_KERNEL);
5c8b1fbb2   Jingoo Han   mtd: cfi: Remove ...
174
  	if (!cfi->cfiq)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
175
  		return 0;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
176
177
  
  	memset(cfi->cfiq,0,sizeof(struct cfi_ident));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
178
  	cfi->cfi_mode = CFI_MODE_CFI;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
179

08968041b   Guillaume LECERF   mtd: cfi_cmdset_0...
180
  	cfi->sector_erase_cmd = CMD(0x30);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
181
182
183
184
  	/* Read the CFI info structure */
  	xip_disable_qry(base, map, cfi);
  	for (i=0; i<(sizeof(struct cfi_ident) + num_erase_regions * 4); i++)
  		((unsigned char *)cfi->cfiq)[i] = cfi_read_query(map,base + (0x10 + i)*ofs_factor);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
  	/* Do any necessary byteswapping */
  	cfi->cfiq->P_ID = le16_to_cpu(cfi->cfiq->P_ID);
  
  	cfi->cfiq->P_ADR = le16_to_cpu(cfi->cfiq->P_ADR);
  	cfi->cfiq->A_ID = le16_to_cpu(cfi->cfiq->A_ID);
  	cfi->cfiq->A_ADR = le16_to_cpu(cfi->cfiq->A_ADR);
  	cfi->cfiq->InterfaceDesc = le16_to_cpu(cfi->cfiq->InterfaceDesc);
  	cfi->cfiq->MaxBufWriteSize = le16_to_cpu(cfi->cfiq->MaxBufWriteSize);
  
  #ifdef DEBUG_CFI
  	/* Dump the information therein */
  	print_cfi_ident(cfi->cfiq);
  #endif
  
  	for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
  		cfi->cfiq->EraseRegionInfo[i] = le32_to_cpu(cfi->cfiq->EraseRegionInfo[i]);
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
201
202
  
  #ifdef DEBUG_CFI
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
203
204
  		printk("  Erase Region #%d: BlockSize 0x%4.4X bytes, %d blocks
  ",
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
205
  		       i, (cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
206
207
208
  		       (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1);
  #endif
  	}
54b93a49d   Guillaume LECERF   mtd: cfi_probe: a...
209
210
211
212
  	if (cfi->cfiq->P_ID == P_ID_SST_OLD) {
  		addr_unlock1 = 0x5555;
  		addr_unlock2 = 0x2AAA;
  	}
8473044d6   Guillaume LECERF   mtd: cfi_probe: e...
213
214
215
216
217
218
219
220
221
  	/*
  	 * Note we put the device back into Read Mode BEFORE going into Auto
  	 * Select Mode, as some devices support nesting of modes, others
  	 * don't. This way should always work.
  	 * On cmdset 0001 the writes of 0xaa and 0x55 are not needed, and
  	 * so should be treated as nops or illegal (and so put the device
  	 * back into Read Mode, which is a nop in this case).
  	 */
  	cfi_send_gen_cmd(0xf0,     0, base, map, cfi, cfi->device_type, NULL);
ad7026fef   Guillaume LECERF   mtd: cfi_probe: m...
222
223
224
  	cfi_send_gen_cmd(0xaa, addr_unlock1, base, map, cfi, cfi->device_type, NULL);
  	cfi_send_gen_cmd(0x55, addr_unlock2, base, map, cfi, cfi->device_type, NULL);
  	cfi_send_gen_cmd(0x90, addr_unlock1, base, map, cfi, cfi->device_type, NULL);
8473044d6   Guillaume LECERF   mtd: cfi_probe: e...
225
226
227
228
229
230
231
232
233
234
235
  	cfi->mfr = cfi_read_query16(map, base);
  	cfi->id = cfi_read_query16(map, base + ofs_factor);
  
  	/* Get AMD/Spansion extended JEDEC ID */
  	if (cfi->mfr == CFI_MFR_AMD && (cfi->id & 0xff) == 0x7e)
  		cfi->id = cfi_read_query(map, base + 0xe * ofs_factor) << 8 |
  			  cfi_read_query(map, base + 0xf * ofs_factor);
  
  	/* Put it back into Read Mode */
  	cfi_qry_mode_off(base, map, cfi);
  	xip_allowed(base, map);
771a115a6   Guillaume LECERF   mtd: cfi_probe: p...
236
237
  	printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit bank. Manufacturer ID %#08x Chip ID %#08x
  ",
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
238
  	       map->name, cfi->interleave, cfi->device_type*8, base,
771a115a6   Guillaume LECERF   mtd: cfi_probe: p...
239
  	       map->bankwidth*8, cfi->mfr, cfi->id);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
240
241
242
243
244
  
  	return 1;
  }
  
  #ifdef DEBUG_CFI
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
245
  static char *vendorname(__u16 vendor)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
246
247
248
249
  {
  	switch (vendor) {
  	case P_ID_NONE:
  		return "None";
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
250

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
251
252
  	case P_ID_INTEL_EXT:
  		return "Intel/Sharp Extended";
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
253

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
254
255
  	case P_ID_AMD_STD:
  		return "AMD/Fujitsu Standard";
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
256

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
257
258
  	case P_ID_INTEL_STD:
  		return "Intel/Sharp Standard";
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
259

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
260
261
262
263
264
  	case P_ID_AMD_EXT:
  		return "AMD/Fujitsu Extended";
  
  	case P_ID_WINBOND:
  		return "Winbond Standard";
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
265

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
266
267
268
269
270
  	case P_ID_ST_ADV:
  		return "ST Advanced";
  
  	case P_ID_MITSUBISHI_STD:
  		return "Mitsubishi Standard";
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
271

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
272
273
274
275
276
  	case P_ID_MITSUBISHI_EXT:
  		return "Mitsubishi Extended";
  
  	case P_ID_SST_PAGE:
  		return "SST Page Write";
54b93a49d   Guillaume LECERF   mtd: cfi_probe: a...
277
278
  	case P_ID_SST_OLD:
  		return "SST 39VF160x/39VF320x";
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
279
280
  	case P_ID_INTEL_PERFORMANCE:
  		return "Intel Performance Code";
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
281

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
282
283
  	case P_ID_INTEL_DATA:
  		return "Intel Data";
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
284

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
285
286
  	case P_ID_RESERVED:
  		return "Not Allowed / Reserved for Future Use";
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
287

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
288
289
290
291
292
293
294
295
296
297
298
299
300
  	default:
  		return "Unknown";
  	}
  }
  
  
  static void print_cfi_ident(struct cfi_ident *cfip)
  {
  #if 0
  	if (cfip->qry[0] != 'Q' || cfip->qry[1] != 'R' || cfip->qry[2] != 'Y') {
  		printk("Invalid CFI ident structure.
  ");
  		return;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
301
302
  	}
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
303
304
305
306
307
308
309
310
  	printk("Primary Vendor Command Set: %4.4X (%s)
  ", cfip->P_ID, vendorname(cfip->P_ID));
  	if (cfip->P_ADR)
  		printk("Primary Algorithm Table at %4.4X
  ", cfip->P_ADR);
  	else
  		printk("No Primary Algorithm Table
  ");
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
311

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
312
313
314
315
316
317
318
319
  	printk("Alternative Vendor Command Set: %4.4X (%s)
  ", cfip->A_ID, vendorname(cfip->A_ID));
  	if (cfip->A_ADR)
  		printk("Alternate Algorithm Table at %4.4X
  ", cfip->A_ADR);
  	else
  		printk("No Alternate Algorithm Table
  ");
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
320

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
321
322
323
324
325
326
327
328
329
330
331
332
333
  	printk("Vcc Minimum: %2d.%d V
  ", cfip->VccMin >> 4, cfip->VccMin & 0xf);
  	printk("Vcc Maximum: %2d.%d V
  ", cfip->VccMax >> 4, cfip->VccMax & 0xf);
  	if (cfip->VppMin) {
  		printk("Vpp Minimum: %2d.%d V
  ", cfip->VppMin >> 4, cfip->VppMin & 0xf);
  		printk("Vpp Maximum: %2d.%d V
  ", cfip->VppMax >> 4, cfip->VppMax & 0xf);
  	}
  	else
  		printk("No Vpp line
  ");
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
334

151e76590   David Woodhouse   [MTD] Fix legacy ...
335
336
337
338
  	printk("Typical byte/word write timeout: %d µs
  ", 1<<cfip->WordWriteTimeoutTyp);
  	printk("Maximum byte/word write timeout: %d µs
  ", (1<<cfip->WordWriteTimeoutMax) * (1<<cfip->WordWriteTimeoutTyp));
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
339

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
340
  	if (cfip->BufWriteTimeoutTyp || cfip->BufWriteTimeoutMax) {
151e76590   David Woodhouse   [MTD] Fix legacy ...
341
342
343
344
  		printk("Typical full buffer write timeout: %d µs
  ", 1<<cfip->BufWriteTimeoutTyp);
  		printk("Maximum full buffer write timeout: %d µs
  ", (1<<cfip->BufWriteTimeoutMax) * (1<<cfip->BufWriteTimeoutTyp));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
345
346
347
348
  	}
  	else
  		printk("Full buffer write not supported
  ");
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
349

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
350
351
352
353
354
  	printk("Typical block erase timeout: %d ms
  ", 1<<cfip->BlockEraseTimeoutTyp);
  	printk("Maximum block erase timeout: %d ms
  ", (1<<cfip->BlockEraseTimeoutMax) * (1<<cfip->BlockEraseTimeoutTyp));
  	if (cfip->ChipEraseTimeoutTyp || cfip->ChipEraseTimeoutMax) {
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
355
356
  		printk("Typical chip erase timeout: %d ms
  ", 1<<cfip->ChipEraseTimeoutTyp);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
357
358
359
360
361
362
  		printk("Maximum chip erase timeout: %d ms
  ", (1<<cfip->ChipEraseTimeoutMax) * (1<<cfip->ChipEraseTimeoutTyp));
  	}
  	else
  		printk("Chip erase not supported
  ");
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
363

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
364
365
366
367
368
  	printk("Device size: 0x%X bytes (%d MiB)
  ", 1 << cfip->DevSize, 1<< (cfip->DevSize - 20));
  	printk("Flash Device Interface description: 0x%4.4X
  ", cfip->InterfaceDesc);
  	switch(cfip->InterfaceDesc) {
de7921f01   Bartlomiej Sieka   [MTD] [NOR] Fix i...
369
  	case CFI_INTERFACE_X8_ASYNC:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
370
371
372
  		printk("  - x8-only asynchronous interface
  ");
  		break;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
373

de7921f01   Bartlomiej Sieka   [MTD] [NOR] Fix i...
374
  	case CFI_INTERFACE_X16_ASYNC:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
375
376
377
  		printk("  - x16-only asynchronous interface
  ");
  		break;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
378

de7921f01   Bartlomiej Sieka   [MTD] [NOR] Fix i...
379
  	case CFI_INTERFACE_X8_BY_X16_ASYNC:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
380
381
382
  		printk("  - supports x8 and x16 via BYTE# with asynchronous interface
  ");
  		break;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
383

de7921f01   Bartlomiej Sieka   [MTD] [NOR] Fix i...
384
  	case CFI_INTERFACE_X32_ASYNC:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
385
386
387
  		printk("  - x32-only asynchronous interface
  ");
  		break;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
388

de7921f01   Bartlomiej Sieka   [MTD] [NOR] Fix i...
389
  	case CFI_INTERFACE_X16_BY_X32_ASYNC:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
390
391
392
  		printk("  - supports x16 and x32 via Word# with asynchronous interface
  ");
  		break;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
393

de7921f01   Bartlomiej Sieka   [MTD] [NOR] Fix i...
394
  	case CFI_INTERFACE_NOT_ALLOWED:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
395
396
397
  		printk("  - Not Allowed / Reserved
  ");
  		break;
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
398

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
399
400
401
402
403
  	default:
  		printk("  - Unknown
  ");
  		break;
  	}
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
404

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
405
406
407
408
  	printk("Max. bytes in buffer write: 0x%x
  ", 1<< cfip->MaxBufWriteSize);
  	printk("Number of Erase Block Regions: %d
  ", cfip->NumEraseRegions);
1f948b43f   Thomas Gleixner   [MTD] chips: Clea...
409

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
  }
  #endif /* DEBUG_CFI */
  
  static struct chip_probe cfi_chip_probe = {
  	.name		= "CFI",
  	.probe_chip	= cfi_probe_chip
  };
  
  struct mtd_info *cfi_probe(struct map_info *map)
  {
  	/*
  	 * Just use the generic probe stuff to call our CFI-specific
  	 * chip_probe routine in all the possible permutations, etc.
  	 */
  	return mtd_do_chip_probe(map, &cfi_chip_probe);
  }
  
  static struct mtd_chip_driver cfi_chipdrv = {
  	.probe		= cfi_probe,
  	.name		= "cfi_probe",
  	.module		= THIS_MODULE
  };
2b9175c17   Adrian Bunk   [MTD] Make functi...
432
  static int __init cfi_probe_init(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
  {
  	register_mtd_chip_driver(&cfi_chipdrv);
  	return 0;
  }
  
  static void __exit cfi_probe_exit(void)
  {
  	unregister_mtd_chip_driver(&cfi_chipdrv);
  }
  
  module_init(cfi_probe_init);
  module_exit(cfi_probe_exit);
  
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org> et al.");
  MODULE_DESCRIPTION("Probe code for CFI-compliant flash chips");