OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [mtd/] [maps/] [sa1100-flash.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * Flash memory access on SA11x0 based devices
3
 *
4
 * (C) 2000 Nicolas Pitre <nico@cam.org>
5
 *
6
 * $Id: sa1100-flash.c,v 1.1.1.1 2004-04-15 01:51:48 phoenix Exp $
7
 */
8
 
9
#include <linux/config.h>
10
#include <linux/module.h>
11
#include <linux/types.h>
12
#include <linux/ioport.h>
13
#include <linux/kernel.h>
14
 
15
#include <linux/mtd/mtd.h>
16
#include <linux/mtd/map.h>
17
#include <linux/mtd/partitions.h>
18
 
19
#include <asm/hardware.h>
20
#include <asm/io.h>
21
 
22
 
23
#ifndef CONFIG_ARCH_SA1100
24
#error This is for SA1100 architecture only
25
#endif
26
 
27
 
28
#define WINDOW_ADDR 0xe8000000
29
 
30
static __u8 sa1100_read8(struct map_info *map, unsigned long ofs)
31
{
32
        return readb(map->map_priv_1 + ofs);
33
}
34
 
35
static __u16 sa1100_read16(struct map_info *map, unsigned long ofs)
36
{
37
        return readw(map->map_priv_1 + ofs);
38
}
39
 
40
static __u32 sa1100_read32(struct map_info *map, unsigned long ofs)
41
{
42
        return readl(map->map_priv_1 + ofs);
43
}
44
 
45
static void sa1100_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
46
{
47
        memcpy(to, (void *)(map->map_priv_1 + from), len);
48
}
49
 
50
static void sa1100_write8(struct map_info *map, __u8 d, unsigned long adr)
51
{
52
        writeb(d, map->map_priv_1 + adr);
53
}
54
 
55
static void sa1100_write16(struct map_info *map, __u16 d, unsigned long adr)
56
{
57
        writew(d, map->map_priv_1 + adr);
58
}
59
 
60
static void sa1100_write32(struct map_info *map, __u32 d, unsigned long adr)
61
{
62
        writel(d, map->map_priv_1 + adr);
63
}
64
 
65
static void sa1100_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
66
{
67
        memcpy((void *)(map->map_priv_1 + to), from, len);
68
}
69
 
70
static struct map_info sa1100_map = {
71
        name:           "SA1100 flash",
72
        read8:          sa1100_read8,
73
        read16:         sa1100_read16,
74
        read32:         sa1100_read32,
75
        copy_from:      sa1100_copy_from,
76
        write8:         sa1100_write8,
77
        write16:        sa1100_write16,
78
        write32:        sa1100_write32,
79
        copy_to:        sa1100_copy_to,
80
 
81
        map_priv_1:     WINDOW_ADDR,
82
        map_priv_2:     -1,
83
};
84
 
85
 
86
/*
87
 * Here are partition information for all known SA1100-based devices.
88
 * See include/linux/mtd/partitions.h for definition of the mtd_partition
89
 * structure.
90
 *
91
 * The *_max_flash_size is the maximum possible mapped flash size which
92
 * is not necessarily the actual flash size.  It must be no more than
93
 * the value specified in the "struct map_desc *_io_desc" mapping
94
 * definition for the corresponding machine.
95
 *
96
 * Please keep these in alphabetical order, and formatted as per existing
97
 * entries.  Thanks.
98
 */
99
 
100
#ifdef CONFIG_SA1100_ADSBITSY
101
#define ADSBITSY_FLASH_SIZE             0x02000000
102
static struct mtd_partition adsbitsy_partitions[] = {
103
        {
104
                name:           "bootROM",
105
                size:           0x80000,
106
                offset:         0,
107
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
108
        }, {
109
                name:           "zImage",
110
                size:           0x100000,
111
                offset:         MTDPART_OFS_APPEND,
112
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
113
        }, {
114
                name:           "ramdisk.gz",
115
                size:           0x300000,
116
                offset:         MTDPART_OFS_APPEND,
117
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
118
        }, {
119
                name:           "User FS",
120
                size:           MTDPART_SIZ_FULL,
121
                offset:         MTDPART_OFS_APPEND,
122
        }
123
};
124
#endif
125
 
126
#ifdef CONFIG_SA1100_ASSABET
127
/* Phase 4 Assabet has two 28F160B3 flash parts in bank 0: */
128
#define ASSABET4_FLASH_SIZE             0x00400000
129
static struct mtd_partition assabet4_partitions[] = {
130
        {
131
                name:           "bootloader",
132
                size:           0x00020000,
133
                offset:         0,
134
                mask_flags:     MTD_WRITEABLE,
135
        }, {
136
                name:           "bootloader params",
137
                size:           0x00020000,
138
                offset:         MTDPART_OFS_APPEND,
139
                mask_flags:     MTD_WRITEABLE,
140
        }, {
141
                name:           "jffs",
142
                size:           MTDPART_SIZ_FULL,
143
                offset:         MTDPART_OFS_APPEND,
144
        }
145
};
146
 
147
/* Phase 5 Assabet has two 28F128J3A flash parts in bank 0: */
148
#define ASSABET5_FLASH_SIZE             0x02000000
149
static struct mtd_partition assabet5_partitions[] = {
150
        {
151
                name:           "bootloader",
152
                size:           0x00040000,
153
                offset:         0,
154
                mask_flags:     MTD_WRITEABLE,
155
        }, {
156
                name:           "bootloader params",
157
                size:           0x00040000,
158
                offset:         MTDPART_OFS_APPEND,
159
                mask_flags:     MTD_WRITEABLE,
160
        }, {
161
                name:           "jffs",
162
                size:           MTDPART_SIZ_FULL,
163
                offset:         MTDPART_OFS_APPEND,
164
        }
165
};
166
 
167
#define ASSABET_FLASH_SIZE      ASSABET5_FLASH_SIZE
168
#define assabet_partitions      assabet5_partitions
169
#endif
170
 
171
#ifdef CONFIG_SA1100_BADGE4
172
 
173
/*
174
 * 1 x Intel 28F320C3BA100 Advanced+ Boot Block Flash (32 Mi bit)
175
 *   Eight 4 KiW Parameter Bottom Blocks (64 KiB)
176
 *   Sixty-three 32 KiW Main Blocks (4032 Ki b)
177
 */
178
#define BADGE4_FLASH_SIZE               0x00400000
179
static struct mtd_partition badge4_partitions[] = {
180
        {
181
                name:           "BLOB boot loader",
182
                offset:         0,
183
                size:           0x0000A000
184
        }, {
185
                name:           "params",
186
                offset:         MTDPART_OFS_APPEND,
187
                size:           0x00006000
188
        }, {
189
                name:           "kernel",
190
                offset:         MTDPART_OFS_APPEND,
191
                size:           0x00100000
192
        }, {
193
                name:           "root",
194
                offset:         MTDPART_OFS_APPEND,
195
                size:           MTDPART_SIZ_FULL
196
        }
197
};
198
 
199
#endif
200
 
201
 
202
#ifdef CONFIG_SA1100_CERF
203
#ifdef CONFIG_SA1100_CERF_FLASH_32MB
204
#define CERF_FLASH_SIZE                 0x02000000
205
static struct mtd_partition cerf_partitions[] = {
206
        {
207
                name:           "firmware",
208
                size:           0x00040000,
209
                offset:         0,
210
        }, {
211
                name:           "params",
212
                size:           0x00040000,
213
                offset:         0x00040000,
214
        }, {
215
                name:           "kernel",
216
                size:           0x00100000,
217
                offset:         0x00080000,
218
        }, {
219
                name:           "rootdisk",
220
                size:           0x01E80000,
221
                offset:         0x00180000,
222
        }
223
};
224
#elif defined CONFIG_SA1100_CERF_FLASH_16MB
225
#define CERF_FLASH_SIZE                 0x01000000
226
static struct mtd_partition cerf_partitions[] = {
227
        {
228
                name:           "firmware",
229
                size:           0x00020000,
230
                offset:         0,
231
        }, {
232
                name:           "params",
233
                size:           0x00020000,
234
                offset:         0x00020000,
235
        }, {
236
                name:           "kernel",
237
                size:           0x00100000,
238
                offset:         0x00040000,
239
        }, {
240
                name:           "rootdisk",
241
                size:           0x00EC0000,
242
                offset:         0x00140000,
243
        }
244
};
245
#elif defined CONFIG_SA1100_CERF_FLASH_8MB
246
#   error "Unwritten type definition"
247
#else
248
#   error "Undefined memory orientation for CERF in sa1100-flash.c"
249
#endif
250
#endif
251
 
252
#ifdef CONFIG_SA1100_CONSUS
253
#define CONSUS_FLASH_SIZE               0x02000000
254
static struct mtd_partition consus_partitions[] = {
255
        {
256
                name:           "Consus boot firmware",
257
                offset:         0,
258
                size:           0x00040000,
259
                mask_flags:     MTD_WRITABLE, /* force read-only */
260
        }, {
261
                name:           "Consus kernel",
262
                offset:         0x00040000,
263
                size:           0x00100000,
264
                mask_flags:     0,
265
        }, {
266
                name:           "Consus disk",
267
                offset:         0x00140000,
268
                /* The rest (up to 16M) for jffs.  We could put 0 and
269
                   make it find the size automatically, but right now
270
                   i have 32 megs.  jffs will use all 32 megs if given
271
                   the chance, and this leads to horrible problems
272
                   when you try to re-flash the image because blob
273
                   won't erase the whole partition. */
274
                size:           0x01000000 - 0x00140000,
275
                mask_flags:     0,
276
        }, {
277
                /* this disk is a secondary disk, which can be used as
278
                   needed, for simplicity, make it the size of the other
279
                   consus partition, although realistically it could be
280
                   the remainder of the disk (depending on the file
281
                   system used) */
282
                 name:          "Consus disk2",
283
                 offset:        0x01000000,
284
                 size:          0x01000000 - 0x00140000,
285
                 mask_flags:    0,
286
        }
287
};
288
#endif
289
 
290
#ifdef CONFIG_SA1100_FLEXANET
291
/* Flexanet has two 28F128J3A flash parts in bank 0: */
292
#define FLEXANET_FLASH_SIZE             0x02000000
293
static struct mtd_partition flexanet_partitions[] = {
294
        {
295
                name:           "bootloader",
296
                size:           0x00040000,
297
                offset:         0,
298
                mask_flags:     MTD_WRITEABLE,
299
        }, {
300
                name:           "bootloader params",
301
                size:           0x00040000,
302
                offset:         MTDPART_OFS_APPEND,
303
                mask_flags:     MTD_WRITEABLE,
304
        }, {
305
                name:           "kernel",
306
                size:           0x000C0000,
307
                offset:         MTDPART_OFS_APPEND,
308
                mask_flags:     MTD_WRITEABLE,
309
        }, {
310
                name:           "altkernel",
311
                size:           0x000C0000,
312
                offset:         MTDPART_OFS_APPEND,
313
                mask_flags:     MTD_WRITEABLE,
314
        }, {
315
                name:           "root",
316
                size:           0x00400000,
317
                offset:         MTDPART_OFS_APPEND,
318
                mask_flags:     MTD_WRITEABLE,
319
        }, {
320
                name:           "free1",
321
                size:           0x00300000,
322
                offset:         MTDPART_OFS_APPEND,
323
                mask_flags:     MTD_WRITEABLE,
324
        }, {
325
                name:           "free2",
326
                size:           0x00300000,
327
                offset:         MTDPART_OFS_APPEND,
328
                mask_flags:     MTD_WRITEABLE,
329
        }, {
330
                name:           "free3",
331
                size:           MTDPART_SIZ_FULL,
332
                offset:         MTDPART_OFS_APPEND,
333
                mask_flags:     MTD_WRITEABLE,
334
        }
335
};
336
#endif
337
 
338
#ifdef CONFIG_SA1100_FREEBIRD
339
#define FREEBIRD_FLASH_SIZE             0x02000000
340
static struct mtd_partition freebird_partitions[] = {
341
#if CONFIG_SA1100_FREEBIRD_NEW
342
        {
343
                name:           "firmware",
344
                size:           0x00040000,
345
                offset:         0,
346
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
347
        }, {
348
                name:           "kernel",
349
                size:           0x00080000,
350
                offset:         0x00040000,
351
        }, {
352
                name:           "params",
353
                size:           0x00040000,
354
                offset:         0x000C0000,
355
        }, {
356
                name:           "initrd",
357
                size:           0x00100000,
358
                offset:         0x00100000,
359
        }, {
360
                name:           "root cramfs",
361
                size:           0x00300000,
362
                offset:         0x00200000,
363
        }, {
364
                name:           "usr cramfs",
365
                size:           0x00C00000,
366
                offset:         0x00500000,
367
        }, {
368
                name:           "local",
369
                size:           MTDPART_SIZ_FULL,
370
                offset:         0x01100000,
371
        }
372
#else
373
        {
374
                size:           0x00040000,
375
                offset:         0,
376
        }, {
377
                size:           0x000c0000,
378
                offset:         MTDPART_OFS_APPEND,
379
        }, {
380
                size:           0x00400000,
381
                offset:         MTDPART_OFS_APPEND,
382
        }, {
383
                size:           MTDPART_SIZ_FULL,
384
                offset:         MTDPART_OFS_APPEND,
385
        }
386
#endif
387
};
388
#endif
389
 
390
#ifdef CONFIG_SA1100_FRODO
391
/* Frodo has 2 x 16M 28F128J3A flash chips in bank 0: */
392
#define FRODO_FLASH_SIZE                0x02000000
393
static struct mtd_partition frodo_partitions[] =
394
{
395
        {
396
                name:           "Boot Loader",
397
                size:           0x00040000,
398
                offset:         0x00000000
399
        }, {
400
                name:           "Parameter Block",
401
                size:           0x00040000,
402
                offset:         MTDPART_OFS_APPEND
403
        }, {
404
                name:           "Linux Kernel",
405
                size:           0x00100000,
406
                offset:         MTDPART_OFS_APPEND
407
        }, {
408
                name:           "Ramdisk",
409
                size:           0x00680000,
410
                offset:         MTDPART_OFS_APPEND
411
        }, {
412
                name:           "Flash File System",
413
                size:           MTDPART_SIZ_FULL,
414
                offset:         MTDPART_OFS_APPEND
415
        }
416
};
417
#endif
418
 
419
#ifdef CONFIG_SA1100_GRAPHICSCLIENT
420
#define GRAPHICSCLIENT_FLASH_SIZE       0x02000000
421
static struct mtd_partition graphicsclient_partitions[] = {
422
        {
423
                name:           "zImage",
424
                size:           0x100000,
425
                offset:         0,
426
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
427
        }, {
428
                name:           "ramdisk.gz",
429
                size:           0x300000,
430
                offset:         MTDPART_OFS_APPEND,
431
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
432
        }, {
433
                name:           "User FS",
434
                size:           MTDPART_SIZ_FULL,
435
                offset:         MTDPART_OFS_APPEND,
436
        }
437
};
438
#endif
439
 
440
#ifdef CONFIG_SA1100_GRAPHICSMASTER
441
#define GRAPHICSMASTER_FLASH_SIZE       0x01000000
442
static struct mtd_partition graphicsmaster_partitions[] = {
443
        {
444
                name:           "zImage",
445
                size:           0x100000,
446
                offset:         0,
447
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
448
        },
449
        {
450
                name:           "ramdisk.gz",
451
                size:           0x300000,
452
                offset:         MTDPART_OFS_APPEND,
453
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
454
        },
455
        {
456
                name:           "User FS",
457
                size:           MTDPART_SIZ_FULL,
458
                offset:         MTDPART_OFS_APPEND,
459
        }
460
};
461
#endif
462
 
463
#ifdef CONFIG_SA1100_H3600
464
#define H3600_FLASH_SIZE                0x02000000
465
static struct mtd_partition h3600_partitions[] = {
466
        {
467
                name:           "H3600 boot firmware",
468
                size:           0x00040000,
469
                offset:         0,
470
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
471
        }, {
472
                name:           "H3600 kernel",
473
                size:           0x00080000,
474
                offset:         0x00040000,
475
        }, {
476
                name:           "H3600 params",
477
                size:           0x00040000,
478
                offset:         0x000C0000,
479
        }, {
480
#ifdef CONFIG_JFFS2_FS
481
                name:           "H3600 root jffs2",
482
                size:           MTDPART_SIZ_FULL,
483
                offset:         0x00100000,
484
#else
485
                name:           "H3600 initrd",
486
                size:           0x00100000,
487
                offset:         0x00100000,
488
        }, {
489
                name:           "H3600 root cramfs",
490
                size:           0x00300000,
491
                offset:         0x00200000,
492
        }, {
493
                name:           "H3600 usr cramfs",
494
                size:           0x00800000,
495
                offset:         0x00500000,
496
        }, {
497
                name:           "H3600 usr local",
498
                size:           MTDPART_SIZ_FULL,
499
                offset:         0x00d00000,
500
#endif
501
        }
502
};
503
 
504
static void h3600_set_vpp(struct map_info *map, int vpp)
505
{
506
        assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, vpp);
507
}
508
#endif
509
 
510
#ifdef CONFIG_SA1100_HUW_WEBPANEL
511
#define HUW_WEBPANEL_FLASH_SIZE         0x01000000
512
static struct mtd_partition huw_webpanel_partitions[] = {
513
        {
514
                name:           "Loader",
515
                size:           0x00040000,
516
                offset:         0,
517
        }, {
518
                name:           "Sector 1",
519
                size:           0x00040000,
520
                offset:         MTDPART_OFS_APPEND,
521
        }, {
522
                size:           MTDPART_SIZ_FULL,
523
                offset:         MTDPART_OFS_APPEND,
524
        }
525
};
526
#endif
527
 
528
#ifdef CONFIG_SA1100_JORNADA720
529
#define JORNADA720_FLASH_SIZE           0x02000000
530
static struct mtd_partition jornada720_partitions[] = {
531
        {
532
                name:           "JORNADA720 boot firmware",
533
                size:           0x00040000,
534
                offset:         0,
535
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
536
        }, {
537
                name:           "JORNADA720 kernel",
538
                size:           0x000c0000,
539
                offset:         0x00040000,
540
        }, {
541
                name:           "JORNADA720 params",
542
                size:           0x00040000,
543
                offset:         0x00100000,
544
        }, {
545
                name:           "JORNADA720 initrd",
546
                size:           0x00100000,
547
                offset:         0x00140000,
548
        }, {
549
                name:           "JORNADA720 root cramfs",
550
                size:           0x00300000,
551
                offset:         0x00240000,
552
        }, {
553
                name:           "JORNADA720 usr cramfs",
554
                size:           0x00800000,
555
                offset:         0x00540000,
556
        }, {
557
                name:           "JORNADA720 usr local",
558
                size:           0  /* will expand to the end of the flash */
559
                offset:         0x00d00000,
560
        }
561
};
562
 
563
static void jornada720_set_vpp(int vpp)
564
{
565
        if (vpp)
566
                PPSR |= 0x80;
567
        else
568
                PPSR &= ~0x80;
569
        PPDR |= 0x80;
570
}
571
 
572
#endif
573
 
574
#ifdef CONFIG_SA1100_PANGOLIN
575
#define PANGOLIN_FLASH_SIZE             0x04000000
576
static struct mtd_partition pangolin_partitions[] = {
577
        {
578
                name:           "boot firmware",
579
                size:           0x00080000,
580
                offset:         0x00000000,
581
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
582
        }, {
583
                name:           "kernel",
584
                size:           0x00100000,
585
                offset:         0x00080000,
586
        }, {
587
                name:           "initrd",
588
                size:           0x00280000,
589
                offset:         0x00180000,
590
        }, {
591
                name:           "initrd-test",
592
                size:           0x03C00000,
593
                offset:         0x00400000,
594
        }
595
};
596
#endif
597
 
598
#ifdef CONFIG_SA1100_PT_SYSTEM3
599
/* erase size is 0x40000 == 256k partitions have to have this boundary */
600
#define SYSTEM3_FLASH_SIZE              0x01000000
601
static struct mtd_partition system3_partitions[] = {
602
        {
603
                name:           "BLOB",
604
                size:           0x00040000,
605
                offset:         0x00000000,
606
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
607
        }, {
608
                name:           "config",
609
                size:           0x00040000,
610
                offset:         MTDPART_OFS_APPEND,
611
        }, {
612
                name:           "kernel",
613
                size:           0x00100000,
614
                offset:         MTDPART_OFS_APPEND,
615
        }, {
616
                name:           "root",
617
                size:           MTDPART_SIZ_FULL,
618
                offset:         MTDPART_OFS_APPEND,
619
        }
620
};
621
#endif
622
 
623
#ifdef CONFIG_SA1100_SHANNON
624
#define SHANNON_FLASH_SIZE              0x00400000
625
static struct mtd_partition shannon_partitions[] = {
626
        {
627
                name: "BLOB boot loader",
628
                offset: 0,
629
                size: 0x20000
630
        },
631
        {
632
                name: "kernel",
633
                offset: MTDPART_OFS_APPEND,
634
                size: 0xe0000
635
        },
636
        {
637
                name: "initrd",
638
                offset: MTDPART_OFS_APPEND,
639
                size: MTDPART_SIZ_FULL
640
        }
641
};
642
 
643
#endif
644
 
645
#ifdef CONFIG_SA1100_SHERMAN
646
#define SHERMAN_FLASH_SIZE              0x02000000
647
static struct mtd_partition sherman_partitions[] = {
648
        {
649
                size:           0x50000,
650
                offset:         0,
651
        }, {
652
                size:           0x70000,
653
                offset:         MTDPART_OFS_APPEND,
654
        }, {
655
                size:           0x600000,
656
                offset:         MTDPART_OFS_APPEND,
657
        }, {
658
                size:           0xA0000,
659
                offset:         MTDPART_OFS_APPEND,
660
        }
661
};
662
#endif
663
 
664
#ifdef CONFIG_SA1100_SIMPAD
665
#define SIMPAD_FLASH_SIZE               0x02000000
666
static struct mtd_partition simpad_partitions[] = {
667
        {
668
                name:           "SIMpad boot firmware",
669
                size:           0x00080000,
670
                offset:         0,
671
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
672
        }, {
673
                name:           "SIMpad kernel",
674
                size:           0x00100000,
675
                offset:         0x00080000,
676
        }, {
677
#ifdef CONFIG_JFFS2_FS
678
                name:           "SIMpad root jffs2",
679
                size:           MTDPART_SIZ_FULL,
680
                offset:         0x00180000,
681
#else
682
                name:           "SIMpad initrd",
683
                size:           0x00300000,
684
                offset:         0x00180000,
685
        }, {
686
                name:           "SIMpad root cramfs",
687
                size:           0x00300000,
688
                offset:         0x00480000,
689
        }, {
690
                name:           "SIMpad usr cramfs",
691
                size:           0x005c0000,
692
                offset:         0x00780000,
693
        }, {
694
                name:           "SIMpad usr local",
695
                size:           MTDPART_SIZ_FULL,
696
                offset:         0x00d40000,
697
#endif
698
        }
699
};
700
#endif /* CONFIG_SA1100_SIMPAD */
701
 
702
#ifdef CONFIG_SA1100_STORK
703
#define STORK_FLASH_SIZE                0x02000000
704
static struct mtd_partition stork_partitions[] = {
705
        {
706
                name:           "STORK boot firmware",
707
                size:           0x00040000,
708
                offset:         0,
709
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
710
        }, {
711
                name:           "STORK params",
712
                size:           0x00040000,
713
                offset:         0x00040000,
714
        }, {
715
                name:           "STORK kernel",
716
                size:           0x00100000,
717
                offset:         0x00080000,
718
        }, {
719
#ifdef CONFIG_JFFS2_FS
720
                name:           "STORK root jffs2",
721
                offset:         0x00180000,
722
                size:           MTDPART_SIZ_FULL,
723
#else
724
                name:           "STORK initrd",
725
                size:           0x00100000,
726
                offset:         0x00180000,
727
        }, {
728
                name:           "STORK root cramfs",
729
                size:           0x00300000,
730
                offset:         0x00280000,
731
        }, {
732
                name:           "STORK usr cramfs",
733
                size:           0x00800000,
734
                offset:         0x00580000,
735
        }, {
736
                name:           "STORK usr local",
737
                offset:         0x00d80000,
738
                size:           MTDPART_SIZ_FULL,
739
#endif
740
        }
741
};
742
#endif
743
 
744
#ifdef CONFIG_SA1100_YOPY
745
#define YOPY_FLASH_SIZE                 0x08000000
746
static struct mtd_partition yopy_partitions[] = {
747
        {
748
                name:           "boot firmware",
749
                size:           0x00040000,
750
                offset:         0x00000000,
751
                mask_flags:     MTD_WRITEABLE,  /* force read-only */
752
        }, {
753
                name:           "kernel",
754
                size:           0x00080000,
755
                offset:         0x00080000,
756
        }, {
757
                name:           "initrd",
758
                size:           0x00300000,
759
                offset:         0x00100000,
760
        }, {
761
                name:           "root",
762
                size:           0x01000000,
763
                offset:         0x00400000,
764
        }
765
};
766
#endif
767
 
768
extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);
769
extern int parse_bootldr_partitions(struct mtd_info *master, struct mtd_partition **pparts);
770
 
771
static struct mtd_partition *parsed_parts;
772
static struct mtd_info *mymtd;
773
 
774
int __init sa1100_mtd_init(void)
775
{
776
        struct mtd_partition *parts;
777
        int nb_parts = 0, ret;
778
        int parsed_nr_parts = 0;
779
        const char *part_type;
780
        unsigned long base = -1UL;
781
 
782
        /* Default flash buswidth */
783
        sa1100_map.buswidth = (MSC0 & MSC_RBW) ? 2 : 4;
784
 
785
        /*
786
         * Static partition definition selection
787
         */
788
        part_type = "static";
789
 
790
#ifdef CONFIG_SA1100_ADSBITSY
791
        if (machine_is_adsbitsy()) {
792
                parts = adsbitsy_partitions;
793
                nb_parts = ARRAY_SIZE(adsbitsy_partitions);
794
                sa1100_map.size = ADSBITSY_FLASH_SIZE;
795
                sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2 : 4;
796
        }
797
#endif
798
#ifdef CONFIG_SA1100_ASSABET
799
        if (machine_is_assabet()) {
800
                parts = assabet_partitions;
801
                nb_parts = ARRAY_SIZE(assabet_partitions);
802
                sa1100_map.size = ASSABET_FLASH_SIZE;
803
        }
804
#endif
805
#ifdef CONFIG_SA1100_BADGE4
806
        if (machine_is_badge4()) {
807
                parts = badge4_partitions;
808
                nb_parts = ARRAY_SIZE(badge4_partitions);
809
                sa1100_map.size = BADGE4_FLASH_SIZE;
810
        }
811
#endif
812
#ifdef CONFIG_SA1100_CERF
813
        if (machine_is_cerf()) {
814
                parts = cerf_partitions;
815
                nb_parts = ARRAY_SIZE(cerf_partitions);
816
                sa1100_map.size = CERF_FLASH_SIZE;
817
        }
818
#endif
819
#ifdef CONFIG_SA1100_CONSUS
820
        if (machine_is_consus()) {
821
                parts = consus_partitions;
822
                nb_parts = ARRAY_SIZE(consus_partitions);
823
                sa1100_map.size = CONSUS_FLASH_SIZE;
824
        }
825
#endif
826
#ifdef CONFIG_SA1100_FLEXANET
827
        if (machine_is_flexanet()) {
828
                parts = flexanet_partitions;
829
                nb_parts = ARRAY_SIZE(flexanet_partitions);
830
                sa1100_map.size = FLEXANET_FLASH_SIZE;
831
        }
832
#endif
833
#ifdef CONFIG_SA1100_FREEBIRD
834
        if (machine_is_freebird()) {
835
                parts = freebird_partitions;
836
                nb_parts = ARRAY_SIZE(freebird_partitions);
837
                sa1100_map.size = FREEBIRD_FLASH_SIZE;
838
        }
839
#endif
840
#ifdef CONFIG_SA1100_FRODO
841
        if (machine_is_frodo()) {
842
                parts = frodo_partitions;
843
                nb_parts = ARRAY_SIZE(frodo_partitions);
844
                sa1100_map.size = FRODO_FLASH_SIZE;
845
                base = 0x00000000;
846
        }
847
#endif
848
#ifdef CONFIG_SA1100_GRAPHICSCLIENT
849
        if (machine_is_graphicsclient()) {
850
                parts = graphicsclient_partitions;
851
                nb_parts = ARRAY_SIZE(graphicsclient_partitions);
852
                sa1100_map.size = GRAPHICSCLIENT_FLASH_SIZE;
853
                sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2:4;
854
        }
855
#endif
856
#ifdef CONFIG_SA1100_GRAPHICSMASTER
857
        if (machine_is_graphicsmaster()) {
858
                parts = graphicsmaster_partitions;
859
                nb_parts = ARRAY_SIZE(graphicsmaster_partitions);
860
                sa1100_map.size = GRAPHICSMASTER_FLASH_SIZE;
861
                sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2:4;
862
        }
863
#endif
864
#ifdef CONFIG_SA1100_H3600
865
        if (machine_is_h3600()) {
866
                parts = h3600_partitions;
867
                nb_parts = ARRAY_SIZE(h3600_partitions);
868
                sa1100_map.size = H3600_FLASH_SIZE;
869
                sa1100_map.set_vpp = h3600_set_vpp;
870
        }
871
#endif
872
#ifdef CONFIG_SA1100_HUW_WEBPANEL
873
        if (machine_is_huw_webpanel()) {
874
                parts = huw_webpanel_partitions;
875
                nb_parts = ARRAY_SIZE(huw_webpanel_partitions);
876
                sa1100_map.size = HUW_WEBPANEL_FLASH_SIZE;
877
        }
878
#endif
879
#ifdef CONFIG_SA1100_JORNADA720
880
        if (machine_is_jornada720()) {
881
                parts = jornada720_partitions;
882
                nb_parts = ARRAY_SIZE(jornada720_partitions);
883
                sa1100_map.size = JORNADA720_FLASH_SIZE;
884
                sa1100_map.set_vpp = jornada720_set_vpp;
885
        }
886
#endif
887
#ifdef CONFIG_SA1100_PANGOLIN
888
        if (machine_is_pangolin()) {
889
                parts = pangolin_partitions;
890
                nb_parts = ARRAY_SIZE(pangolin_partitions);
891
                sa1100_map.size = PANGOLIN_FLASH_SIZE;
892
        }
893
#endif
894
#ifdef CONFIG_SA1100_PT_SYSTEM3
895
        if (machine_is_pt_system3()) {
896
                parts = system3_partitions;
897
                nb_parts = ARRAY_SIZE(system3_partitions);
898
                sa1100_map.size = SYSTEM3_FLASH_SIZE;
899
        }
900
#endif
901
#ifdef CONFIG_SA1100_SHANNON
902
        if (machine_is_shannon()) {
903
                parts = shannon_partitions;
904
                nb_parts = ARRAY_SIZE(shannon_partitions);
905
                sa1100_map.size = SHANNON_FLASH_SIZE;
906
        }
907
#endif
908
#ifdef CONFIG_SA1100_SHERMAN
909
        if (machine_is_sherman()) {
910
                parts = sherman_partitions;
911
                nb_parts = ARRAY_SIZE(sherman_partitions);
912
                sa1100_map.size = SHERMAN_FLASH_SIZE;
913
        }
914
#endif
915
#ifdef CONFIG_SA1100_SIMPAD
916
        if (machine_is_simpad()) {
917
                parts = simpad_partitions;
918
                nb_parts = ARRAY_SIZE(simpad_partitions);
919
                sa1100_map.size = SIMPAD_FLASH_SIZE;
920
        }
921
#endif
922
#ifdef CONFIG_SA1100_STORK
923
        if (machine_is_stork()) {
924
                parts = stork_partitions;
925
                nb_parts = ARRAY_SIZE(stork_partitions);
926
                sa1100_map.size = STORK_FLASH_SIZE;
927
        }
928
#endif
929
#ifdef CONFIG_SA1100_YOPY
930
        if (machine_is_yopy()) {
931
                parts = yopy_partitions;
932
                nb_parts = ARRAY_SIZE(yopy_partitions);
933
                sa1100_map.size = YOPY_FLASH_SIZE;
934
        }
935
#endif
936
 
937
        /*
938
         * For simple flash devices, use ioremap to map the flash.
939
         */
940
        if (base != (unsigned long)-1) {
941
                if (!request_mem_region(base, sa1100_map.size, "flash"))
942
                        return -EBUSY;
943
                sa1100_map.map_priv_2 = base;
944
                sa1100_map.map_priv_1 = (unsigned long)
945
                                ioremap(base, sa1100_map.size);
946
                ret = -ENOMEM;
947
                if (!sa1100_map.map_priv_1)
948
                        goto out_err;
949
        }
950
 
951
        /*
952
         * Now let's probe for the actual flash.  Do it here since
953
         * specific machine settings might have been set above.
954
         */
955
        printk(KERN_NOTICE "SA1100 flash: probing %d-bit flash bus\n", sa1100_map.buswidth*8);
956
        mymtd = do_map_probe("cfi_probe", &sa1100_map);
957
        ret = -ENXIO;
958
        if (!mymtd)
959
                goto out_err;
960
        mymtd->module = THIS_MODULE;
961
 
962
        /*
963
         * Dynamic partition selection stuff (might override the static ones)
964
         */
965
#ifdef CONFIG_MTD_REDBOOT_PARTS
966
        if (parsed_nr_parts == 0) {
967
                int ret = parse_redboot_partitions(mymtd, &parsed_parts);
968
 
969
                if (ret > 0) {
970
                        part_type = "RedBoot";
971
                        parsed_nr_parts = ret;
972
                }
973
        }
974
#endif
975
#ifdef CONFIG_MTD_CMDLINE_PARTS
976
        if (parsed_nr_parts == 0) {
977
                int ret = parse_cmdline_partitions(mymtd, &parsed_parts, "sa1100");
978
                if (ret > 0) {
979
                        part_type = "Command Line";
980
                        parsed_nr_parts = ret;
981
                }
982
        }
983
#endif
984
 
985
        if (parsed_nr_parts > 0) {
986
                parts = parsed_parts;
987
                nb_parts = parsed_nr_parts;
988
        }
989
 
990
        if (nb_parts == 0) {
991
                printk(KERN_NOTICE "SA1100 flash: no partition info available, registering whole flash at once\n");
992
                add_mtd_device(mymtd);
993
        } else {
994
                printk(KERN_NOTICE "Using %s partition definition\n", part_type);
995
                add_mtd_partitions(mymtd, parts, nb_parts);
996
        }
997
        return 0;
998
 
999
 out_err:
1000
        if (sa1100_map.map_priv_2 != -1) {
1001
                iounmap((void *)sa1100_map.map_priv_1);
1002
                release_mem_region(sa1100_map.map_priv_2, sa1100_map.size);
1003
        }
1004
        return ret;
1005
}
1006
 
1007
static void __exit sa1100_mtd_cleanup(void)
1008
{
1009
        if (mymtd) {
1010
                del_mtd_partitions(mymtd);
1011
                map_destroy(mymtd);
1012
                if (parsed_parts)
1013
                        kfree(parsed_parts);
1014
        }
1015
        if (sa1100_map.map_priv_2 != -1) {
1016
                iounmap((void *)sa1100_map.map_priv_1);
1017
                release_mem_region(sa1100_map.map_priv_2, sa1100_map.size);
1018
        }
1019
}
1020
 
1021
module_init(sa1100_mtd_init);
1022
module_exit(sa1100_mtd_cleanup);
1023
 
1024
MODULE_AUTHOR("Nicolas Pitre");
1025
MODULE_DESCRIPTION("SA1100 CFI map driver");
1026
MODULE_LICENSE("GPL");

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.