2 * $Id: physmap.c,v 1.29 2003/05/29 09:24:10 dwmw2 Exp $
4 * Normal mappings of chips in physical memory
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <linux/slab.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/map.h>
15 #include <linux/config.h>
16 #include <linux/mtd/partitions.h>
18 #define WINDOW_ADDR CONFIG_MTD_PHYSMAP_START
19 #define WINDOW_SIZE CONFIG_MTD_PHYSMAP_LEN
20 #define BUSWIDTH CONFIG_MTD_PHYSMAP_BUSWIDTH
22 static struct mtd_info *mymtd;
25 struct map_info physmap_map = {
26 .name = "Physically mapped flash",
32 #ifdef CONFIG_MTD_PARTITIONS
33 static struct mtd_partition *mtd_parts;
34 static int mtd_parts_nb;
36 static struct mtd_partition physmap_partitions[] = {
38 /* Put your own partition definitions here */
43 .mask_flags = MTD_WRITEABLE, /* force read-only */
47 .offset = MTDPART_OFS_APPEND,
48 .mask_flags = MTD_WRITEABLE, /* force read-only */
52 .offset = MTDPART_OFS_APPEND,
53 .mask_flags = MTD_WRITEABLE, /* force read-only */
56 .size = MTDPART_SIZ_FULL,
57 .offset = MTDPART_OFS_APPEND,
62 #define NUM_PARTITIONS (sizeof(physmap_partitions)/sizeof(struct mtd_partition))
63 const char *part_probes[] = {"cmdlinepart", "RedBoot", NULL};
65 #endif /* CONFIG_MTD_PARTITIONS */
67 int __init init_physmap(void)
69 static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", 0 };
72 printk(KERN_NOTICE "physmap flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
73 physmap_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
75 if (!physmap_map.virt) {
76 printk("Failed to ioremap\n");
80 simple_map_init(&physmap_map);
83 type = rom_probe_types;
84 for(; !mymtd && *type; type++) {
85 mymtd = do_map_probe(*type, &physmap_map);
88 mymtd->owner = THIS_MODULE;
90 #ifdef CONFIG_MTD_PARTITIONS
91 mtd_parts_nb = parse_mtd_partitions(mymtd, part_probes,
96 add_mtd_partitions (mymtd, mtd_parts, mtd_parts_nb);
100 if (NUM_PARTITIONS != 0)
103 "Using physmap partition definition\n");
104 add_mtd_partitions (mymtd, physmap_partitions, NUM_PARTITIONS);
109 add_mtd_device(mymtd);
114 iounmap((void *)physmap_map.virt);
118 static void __exit cleanup_physmap(void)
120 #ifdef CONFIG_MTD_PARTITIONS
122 del_mtd_partitions(mymtd);
124 } else if (NUM_PARTITIONS) {
125 del_mtd_partitions(mymtd);
127 del_mtd_device(mymtd);
130 del_mtd_device(mymtd);
134 iounmap((void *)physmap_map.virt);
135 physmap_map.virt = 0;
138 module_init(init_physmap);
139 module_exit(cleanup_physmap);
142 MODULE_LICENSE("GPL");
143 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
144 MODULE_DESCRIPTION("Generic configurable MTD map driver");