2 * Normal mappings of altera Nios II development kit flash in physical memory
3 * Derived from physmap.c, by Microtronix Datacom Ltd.
6 #include <linux/module.h>
7 #include <linux/types.h>
8 #include <linux/kernel.h>
9 #include <linux/init.h>
10 #include <linux/slab.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/map.h>
14 #include <linux/mtd/partitions.h>
18 #define WINDOW_ADDR na_flash_kernel
19 #define WINDOW_SIZE na_flash_kernel_size
22 static struct mtd_info
*mymtd
;
25 struct map_info ndk_amd_map
= {
26 .name
= "Altera NDK flash (AMD)",
28 .bankwidth
= BUSWIDTH
,
32 #ifdef CONFIG_MTD_PARTITIONS
33 static struct mtd_partition
*mtd_parts
;
34 static int mtd_parts_nb
;
36 static struct mtd_partition alteramap_partitions
[] = {
37 #ifdef CONFIG_ALTERA_STRATIX_II
39 .name
= "romfs/jffs2",
43 .name
= "loader/kernel",
47 .name
= "User configuration",
51 .name
= "safe configuration",
54 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
56 #elif defined(CONFIG_ALTERA_STRATIX_PRO)
58 .name
= "romfs/jffs2",
62 .name
= "loader/kernel",
66 .name
= "User configuration",
70 .name
= "safe configuration",
73 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
77 .name
= "romfs/jffs2",
81 .name
= "loader/kernel",
85 .name
= "User configuration",
89 .name
= "safe configuration",
92 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
97 #define NUM_PARTITIONS (sizeof(alteramap_partitions)/sizeof(struct mtd_partition))
98 const char *part_probes
[] = {"cmdlinepart", "RedBoot", NULL
};
100 #endif /* CONFIG_MTD_PARTITIONS */
102 int __init
init_alteramap(void)
104 static const char *rom_probe_types
[] = {"cfi_probe", "jedec_probe", 0 };
107 ndk_amd_map
.virt
= (unsigned long *)ioremap_nocache(WINDOW_ADDR
, WINDOW_SIZE
);
109 if (!ndk_amd_map.virt) {
110 printk("Failed to ioremap\n");
114 simple_map_init(&ndk_amd_map
);
117 type
= rom_probe_types
;
118 for(; !mymtd
&& *type
; type
++) {
119 mymtd
= do_map_probe(*type
, &ndk_amd_map
);
122 mymtd
->owner
= THIS_MODULE
;
124 #ifdef CONFIG_MTD_PARTITIONS
125 mtd_parts_nb
= parse_mtd_partitions(mymtd
, part_probes
,
128 if (mtd_parts_nb
> 0)
130 add_mtd_partitions (mymtd
, mtd_parts
, mtd_parts_nb
);
134 if (NUM_PARTITIONS
!= 0)
137 "Using Altera NDK partition definition\n");
138 add_mtd_partitions (mymtd
, alteramap_partitions
, NUM_PARTITIONS
);
143 add_mtd_device(mymtd
);
148 iounmap((void *)ndk_amd_map
.virt
);
152 static void __exit
cleanup_alteramap(void)
154 #ifdef CONFIG_MTD_PARTITIONS
156 del_mtd_partitions(mymtd
);
158 } else if (NUM_PARTITIONS
) {
159 del_mtd_partitions(mymtd
);
161 del_mtd_device(mymtd
);
164 del_mtd_device(mymtd
);
168 iounmap((void *)ndk_amd_map
.virt
);
169 ndk_amd_map
.virt
= 0;
172 module_init(init_alteramap
);
173 module_exit(cleanup_alteramap
);
176 MODULE_LICENSE("GPL");
177 MODULE_AUTHOR("Microtronix Datacom <www.microtronix.com>");
178 MODULE_DESCRIPTION("MTD map driver for Altera Nios Development Kit");