aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/cris/arch-v10/drivers/axisflashmap.c181
1 files changed, 37 insertions, 144 deletions
diff --git a/arch/cris/arch-v10/drivers/axisflashmap.c b/arch/cris/arch-v10/drivers/axisflashmap.c
index ea3cf2e39a14..b3bdda93ffef 100644
--- a/arch/cris/arch-v10/drivers/axisflashmap.c
+++ b/arch/cris/arch-v10/drivers/axisflashmap.c
@@ -10,129 +10,6 @@
10 * tells us what other partitions to define. If there isn't, we use a default 10 * tells us what other partitions to define. If there isn't, we use a default
11 * partition split defined below. 11 * partition split defined below.
12 * 12 *
13 * $Log: axisflashmap.c,v $
14 * Revision 1.11 2004/11/15 10:27:14 starvik
15 * Corrected typo (Thanks to Milton Miller <miltonm@bga.com>).
16 *
17 * Revision 1.10 2004/08/16 12:37:22 starvik
18 * Merge of Linux 2.6.8
19 *
20 * Revision 1.8 2004/05/14 07:58:03 starvik
21 * Merge of changes from 2.4
22 *
23 * Revision 1.6 2003/07/04 08:27:37 starvik
24 * Merge of Linux 2.5.74
25 *
26 * Revision 1.5 2002/12/11 13:13:57 starvik
27 * Added arch/ to v10 specific includes
28 * Added fix from Linux 2.4 in serial.c (flush_to_flip_buffer)
29 *
30 * Revision 1.4 2002/11/20 11:56:10 starvik
31 * Merge of Linux 2.5.48
32 *
33 * Revision 1.3 2002/11/13 14:54:13 starvik
34 * Copied from linux 2.4
35 *
36 * Revision 1.28 2002/10/01 08:08:43 jonashg
37 * The first partition ends at the start of the partition table.
38 *
39 * Revision 1.27 2002/08/21 09:23:13 jonashg
40 * Speling.
41 *
42 * Revision 1.26 2002/08/21 08:35:20 jonashg
43 * Cosmetic change to printouts.
44 *
45 * Revision 1.25 2002/08/21 08:15:42 jonashg
46 * Made it compile even without CONFIG_MTD_CONCAT defined.
47 *
48 * Revision 1.24 2002/08/20 13:12:35 jonashg
49 * * New approach to probing. Probe cse0 and cse1 separately and (mtd)concat
50 * the results.
51 * * Removed compile time tests concerning how the mtdram driver has been
52 * configured. The user will know about the misconfiguration at runtime
53 * instead. (The old approach made it impossible to use mtdram for anything
54 * else than RAM boot).
55 *
56 * Revision 1.23 2002/05/13 12:12:28 johana
57 * Allow compile without CONFIG_MTD_MTDRAM but warn at compiletime and
58 * be informative at runtime.
59 *
60 * Revision 1.22 2002/05/13 10:24:44 johana
61 * Added #if checks on MTDRAM CONFIG
62 *
63 * Revision 1.21 2002/05/06 16:05:20 johana
64 * Removed debug printout.
65 *
66 * Revision 1.20 2002/05/06 16:03:00 johana
67 * No more cramfs as root hack in generic code.
68 * It's handled by axisflashmap using mtdram.
69 *
70 * Revision 1.19 2002/03/15 17:10:28 bjornw
71 * Changed comment about cached access since we changed this before
72 *
73 * Revision 1.18 2002/03/05 17:06:15 jonashg
74 * Try amd_flash probe before cfi_probe since amd_flash driver can handle two
75 * (or more) flash chips of different model and the cfi driver cannot.
76 *
77 * Revision 1.17 2001/11/12 19:42:38 pkj
78 * Fixed compiler warnings.
79 *
80 * Revision 1.16 2001/11/08 11:18:58 jonashg
81 * Always read from uncached address to avoid problems with flushing
82 * cachelines after write and MTD-erase. No performance loss have been
83 * seen yet.
84 *
85 * Revision 1.15 2001/10/19 12:41:04 jonashg
86 * Name of probe has changed in MTD.
87 *
88 * Revision 1.14 2001/09/21 07:14:10 jonashg
89 * Made root filesystem (cramfs) use mtdblock driver when booting from flash.
90 *
91 * Revision 1.13 2001/08/15 13:57:35 jonashg
92 * Entire MTD updated to the linux 2.4.7 version.
93 *
94 * Revision 1.12 2001/06/11 09:50:30 jonashg
95 * Oops, 2MB is 0x200000 bytes.
96 *
97 * Revision 1.11 2001/06/08 11:39:44 jonashg
98 * Changed sizes and offsets in axis_default_partitions to use
99 * CONFIG_ETRAX_PTABLE_SECTOR.
100 *
101 * Revision 1.10 2001/05/29 09:42:03 jonashg
102 * Use macro for end marker length instead of sizeof.
103 *
104 * Revision 1.9 2001/05/29 08:52:52 jonashg
105 * Gave names to the magic fours (size of the ptable end marker).
106 *
107 * Revision 1.8 2001/05/28 15:36:20 jonashg
108 * * Removed old comment about ptable location in flash (it's a CONFIG_ option).
109 * * Variable ptable was initialized twice to the same value.
110 *
111 * Revision 1.7 2001/04/05 13:41:46 markusl
112 * Updated according to review remarks
113 *
114 * Revision 1.6 2001/03/07 09:21:21 bjornw
115 * No need to waste .data
116 *
117 * Revision 1.5 2001/03/06 16:27:01 jonashg
118 * Probe the entire flash area for flash devices.
119 *
120 * Revision 1.4 2001/02/23 12:47:15 bjornw
121 * Uncached flash in LOW_MAP moved from 0xe to 0x8
122 *
123 * Revision 1.3 2001/02/16 12:11:45 jonashg
124 * MTD driver amd_flash is now included in MTD CVS repository.
125 * (It's now in drivers/mtd).
126 *
127 * Revision 1.2 2001/02/09 11:12:22 jonashg
128 * Support for AMD compatible non-CFI flash chips.
129 * Only tested with Toshiba TC58FVT160 so far.
130 *
131 * Revision 1.1 2001/01/12 17:01:18 bjornw
132 * * Added axisflashmap.c, a physical mapping for MTD that reads and understands
133 * Axis partition-table format.
134 *
135 *
136 */ 13 */
137 14
138#include <linux/module.h> 15#include <linux/module.h>
@@ -235,7 +112,7 @@ static struct map_info map_cse1 = {
235}; 112};
236 113
237/* If no partition-table was found, we use this default-set. */ 114/* If no partition-table was found, we use this default-set. */
238#define MAX_PARTITIONS 7 115#define MAX_PARTITIONS 7
239#define NUM_DEFAULT_PARTITIONS 3 116#define NUM_DEFAULT_PARTITIONS 3
240 117
241/* 118/*
@@ -300,6 +177,15 @@ static struct mtd_partition axis_partitions[MAX_PARTITIONS] = {
300 }, 177 },
301}; 178};
302 179
180#ifdef CONFIG_ETRAX_AXISFLASHMAP_MTD0WHOLE
181/* Main flash device */
182static struct mtd_partition main_partition = {
183 .name = "main",
184 .size = 0,
185 .offset = 0
186};
187#endif
188
303/* 189/*
304 * Probe a chip select for AMD-compatible (JEDEC) or CFI-compatible flash 190 * Probe a chip select for AMD-compatible (JEDEC) or CFI-compatible flash
305 * chips in that order (because the amd_flash-driver is faster). 191 * chips in that order (because the amd_flash-driver is faster).
@@ -316,15 +202,14 @@ static struct mtd_info *probe_cs(struct map_info *map_cs)
316 mtd_cs = do_map_probe("cfi_probe", map_cs); 202 mtd_cs = do_map_probe("cfi_probe", map_cs);
317#endif 203#endif
318#ifdef CONFIG_MTD_JEDECPROBE 204#ifdef CONFIG_MTD_JEDECPROBE
319 if (!mtd_cs) { 205 if (!mtd_cs)
320 mtd_cs = do_map_probe("jedec_probe", map_cs); 206 mtd_cs = do_map_probe("jedec_probe", map_cs);
321 }
322#endif 207#endif
323 208
324 return mtd_cs; 209 return mtd_cs;
325} 210}
326 211
327/* 212/*
328 * Probe each chip select individually for flash chips. If there are chips on 213 * Probe each chip select individually for flash chips. If there are chips on
329 * both cse0 and cse1, the mtd_info structs will be concatenated to one struct 214 * both cse0 and cse1, the mtd_info structs will be concatenated to one struct
330 * so that MTD partitions can cross chip boundries. 215 * so that MTD partitions can cross chip boundries.
@@ -351,7 +236,7 @@ static struct mtd_info *flash_probe(void)
351 if (mtd_cse0 && mtd_cse1) { 236 if (mtd_cse0 && mtd_cse1) {
352#ifdef CONFIG_MTD_CONCAT 237#ifdef CONFIG_MTD_CONCAT
353 struct mtd_info *mtds[] = { mtd_cse0, mtd_cse1 }; 238 struct mtd_info *mtds[] = { mtd_cse0, mtd_cse1 };
354 239
355 /* Since the concatenation layer adds a small overhead we 240 /* Since the concatenation layer adds a small overhead we
356 * could try to figure out if the chips in cse0 and cse1 are 241 * could try to figure out if the chips in cse0 and cse1 are
357 * identical and reprobe the whole cse0+cse1 window. But since 242 * identical and reprobe the whole cse0+cse1 window. But since
@@ -372,7 +257,7 @@ static struct mtd_info *flash_probe(void)
372 257
373 /* The best we can do now is to only use what we found 258 /* The best we can do now is to only use what we found
374 * at cse0. 259 * at cse0.
375 */ 260 */
376 mtd_cse = mtd_cse0; 261 mtd_cse = mtd_cse0;
377 map_destroy(mtd_cse1); 262 map_destroy(mtd_cse1);
378 } 263 }
@@ -395,7 +280,7 @@ static int __init init_axis_flash(void)
395 struct partitiontable_head *ptable_head = NULL; 280 struct partitiontable_head *ptable_head = NULL;
396 struct partitiontable_entry *ptable; 281 struct partitiontable_entry *ptable;
397 int use_default_ptable = 1; /* Until proven otherwise. */ 282 int use_default_ptable = 1; /* Until proven otherwise. */
398 const char *pmsg = " /dev/flash%d at 0x%08x, size 0x%08x\n"; 283 const char pmsg[] = " /dev/flash%d at 0x%08x, size 0x%08x\n";
399 284
400 if (!(mymtd = flash_probe())) { 285 if (!(mymtd = flash_probe())) {
401 /* There's no reason to use this module if no flash chip can 286 /* There's no reason to use this module if no flash chip can
@@ -435,7 +320,7 @@ static int __init init_axis_flash(void)
435 unsigned long offset = CONFIG_ETRAX_PTABLE_SECTOR; 320 unsigned long offset = CONFIG_ETRAX_PTABLE_SECTOR;
436 unsigned char *p; 321 unsigned char *p;
437 unsigned long csum = 0; 322 unsigned long csum = 0;
438 323
439 ptable = (struct partitiontable_entry *) 324 ptable = (struct partitiontable_entry *)
440 ((unsigned long)ptable_head + sizeof(*ptable_head)); 325 ((unsigned long)ptable_head + sizeof(*ptable_head));
441 326
@@ -490,6 +375,16 @@ static int __init init_axis_flash(void)
490 pidx++; 375 pidx++;
491 } 376 }
492 377
378#ifdef CONFIG_ETRAX_AXISFLASHMAP_MTD0WHOLE
379 if (mymtd) {
380 main_partition.size = mymtd->size;
381 err = add_mtd_partitions(mymtd, &main_partition, 1);
382 if (err)
383 panic("axisflashmap: Could not initialize "
384 "partition for whole main mtd device!\n");
385 }
386#endif
387
493 if (mymtd) { 388 if (mymtd) {
494 if (use_default_ptable) { 389 if (use_default_ptable) {
495 printk(KERN_INFO " Using default partition table.\n"); 390 printk(KERN_INFO " Using default partition table.\n");
@@ -499,9 +394,8 @@ static int __init init_axis_flash(void)
499 err = add_mtd_partitions(mymtd, axis_partitions, pidx); 394 err = add_mtd_partitions(mymtd, axis_partitions, pidx);
500 } 395 }
501 396
502 if (err) { 397 if (err)
503 panic("axisflashmap could not add MTD partitions!\n"); 398 panic("axisflashmap could not add MTD partitions!\n");
504 }
505 } 399 }
506 400
507 if (!romfs_in_flash) { 401 if (!romfs_in_flash) {
@@ -515,25 +409,24 @@ static int __init init_axis_flash(void)
515#else 409#else
516 struct mtd_info *mtd_ram; 410 struct mtd_info *mtd_ram;
517 411
518 mtd_ram = kmalloc(sizeof(struct mtd_info), 412 mtd_ram = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
519 GFP_KERNEL); 413 if (!mtd_ram)
520 if (!mtd_ram) {
521 panic("axisflashmap couldn't allocate memory for " 414 panic("axisflashmap couldn't allocate memory for "
522 "mtd_info!\n"); 415 "mtd_info!\n");
523 }
524 416
525 printk(KERN_INFO " Adding RAM partition for romfs image:\n"); 417 printk(KERN_INFO " Adding RAM partition for romfs image:\n");
526 printk(pmsg, pidx, romfs_start, romfs_length); 418 printk(pmsg, pidx, (unsigned)romfs_start,
527 419 (unsigned)romfs_length);
528 err = mtdram_init_device(mtd_ram, (void*)romfs_start, 420
529 romfs_length, "romfs"); 421 err = mtdram_init_device(mtd_ram,
530 if (err) { 422 (void *)romfs_start,
423 romfs_length,
424 "romfs");
425 if (err)
531 panic("axisflashmap could not initialize MTD RAM " 426 panic("axisflashmap could not initialize MTD RAM "
532 "device!\n"); 427 "device!\n");
533 }
534#endif 428#endif
535 } 429 }
536
537 return err; 430 return err;
538} 431}
539 432