15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
19 #include <linux/slab.h>
31 #ifdef CONFIG_CRIS_LOW_MAP
32 #define FLASH_UNCACHED_ADDR KSEG_8
33 #define FLASH_CACHED_ADDR KSEG_5
35 #define FLASH_UNCACHED_ADDR KSEG_E
36 #define FLASH_CACHED_ADDR KSEG_F
39 #if CONFIG_ETRAX_FLASH_BUSWIDTH==1
40 #define flash_data __u8
41 #elif CONFIG_ETRAX_FLASH_BUSWIDTH==2
42 #define flash_data __u16
43 #elif CONFIG_ETRAX_FLASH_BUSWIDTH==4
44 #define flash_data __u32
62 static void flash_copy_from(
struct map_info *
map,
void *to,
70 *(flash_data *)(map->
map_priv_1 + adr) = (flash_data)d.
x[0];
91 .bankwidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
93 .copy_from = flash_copy_from,
107 .bankwidth = CONFIG_ETRAX_FLASH_BUSWIDTH,
109 .copy_from = flash_copy_from,
115 #define MAX_PARTITIONS 7
116 #define NUM_DEFAULT_PARTITIONS 3
125 .name =
"boot firmware",
126 .size = CONFIG_ETRAX_PTABLE_SECTOR,
131 .size = 0x200000 - (6 * CONFIG_ETRAX_PTABLE_SECTOR),
132 .
offset = CONFIG_ETRAX_PTABLE_SECTOR
135 .name =
"filesystem",
136 .size = 5 * CONFIG_ETRAX_PTABLE_SECTOR,
137 .
offset = 0x200000 - (5 * CONFIG_ETRAX_PTABLE_SECTOR)
142 static struct mtd_partition axis_partitions[MAX_PARTITIONS] = {
145 .size = CONFIG_ETRAX_PTABLE_SECTOR,
180 #ifdef CONFIG_ETRAX_AXISFLASHMAP_MTD0WHOLE
198 "%s: Probing a 0x%08lx bytes large window at 0x%08lx.\n",
201 #ifdef CONFIG_MTD_CFI
204 #ifdef CONFIG_MTD_JEDECPROBE
222 static struct mtd_info *flash_probe(
void)
228 mtd_cse0 = probe_cs(&map_cse0);
229 mtd_cse1 = probe_cs(&map_cse1);
231 if (!mtd_cse0 && !mtd_cse1) {
236 if (mtd_cse0 && mtd_cse1) {
237 struct mtd_info *mtds[] = { mtd_cse0, mtd_cse1 };
259 mtd_cse = mtd_cse0? mtd_cse0 : mtd_cse1;
269 static int __init init_axis_flash(
void)
276 int use_default_ptable = 1;
277 const char pmsg[] =
" /dev/flash%d at 0x%08x, size 0x%08x\n";
279 if (!(mymtd = flash_probe())) {
287 axisflash_mtd = mymtd;
293 CONFIG_ETRAX_PTABLE_SECTOR +
299 && (ptable_head->
size <
301 PARTITIONTABLE_END_MARKER_SIZE))
302 && (*(
unsigned long*)((
void*)ptable_head +
sizeof(*ptable_head) +
312 ((
unsigned long)ptable_head +
sizeof(*ptable_head) +
314 unsigned long offset = CONFIG_ETRAX_PTABLE_SECTOR;
316 unsigned long csum = 0;
319 ((
unsigned long)ptable_head +
sizeof(*ptable_head));
322 p = (
unsigned char*) ptable;
324 while (p <= (
unsigned char*)max_addr) {
330 ptable_ok = (csum == ptable_head->
checksum);
334 (ptable_ok ?
" valid" :
"n invalid"), ptable_head,
342 && ptable->
offset != 0xffffffff
344 && pidx < MAX_PARTITIONS) {
347 axis_partitions[pidx].
size = ptable->
size;
349 printk(pmsg, pidx, axis_partitions[pidx].offset,
350 axis_partitions[pidx].
size);
354 use_default_ptable = !ptable_ok;
360 axis_partitions[pidx].
name =
"romfs";
366 " Adding readonly flash partition for romfs image:\n");
368 axis_partitions[pidx].
size);
372 #ifdef CONFIG_ETRAX_AXISFLASHMAP_MTD0WHOLE
377 panic(
"axisflashmap: Could not initialize "
378 "partition for whole main mtd device!\n");
383 if (use_default_ptable) {
386 axis_default_partitions,
394 panic(
"axisflashmap could not add MTD partitions!\n");
400 #if !defined(CONFIG_MTD_MTDRAM) || (CONFIG_MTDRAM_TOTAL_SIZE != 0) || (CONFIG_MTDRAM_ABS_POS != 0)
403 "device due to kernel (mis)configuration!\n");
404 panic(
"This kernel cannot boot from RAM!\n");
410 panic(
"axisflashmap couldn't allocate memory for "
422 panic(
"axisflashmap could not initialize MTD RAM "