2 * $Id: physmap.c,v 1.39 2005/11/29 14:49:36 gleixner Exp $
4 * Normal mappings of chips in physical memory
6 * Copyright (C) 2003 MontaVista Software Inc.
7 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
9 * 031022 - [jsun] add run-time configure and partition setup
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/slab.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
20 #include <linux/config.h>
21 #include <linux/mtd/partitions.h>
22 #include <linux/mtd/physmap.h>
24 static struct mtd_info *mymtd;
26 struct map_info physmap_map = {
27 .name = "phys_mapped_flash",
28 .phys = CONFIG_MTD_PHYSMAP_START,
29 .size = CONFIG_MTD_PHYSMAP_LEN,
30 .bankwidth = CONFIG_MTD_PHYSMAP_BANKWIDTH,
33 #ifdef CONFIG_MTD_PARTITIONS
34 static struct mtd_partition *mtd_parts;
35 static int mtd_parts_nb;
37 static int num_physmap_partitions;
38 static struct mtd_partition *physmap_partitions;
40 static const char *part_probes[] __initdata = {"cmdlinepart", "RedBoot", NULL};
42 void physmap_set_partitions(struct mtd_partition *parts, int num_parts)
44 physmap_partitions=parts;
45 num_physmap_partitions=num_parts;
47 #endif /* CONFIG_MTD_PARTITIONS */
49 static int __init init_physmap(void)
51 static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", NULL };
54 printk(KERN_NOTICE "physmap flash device: %lx at %lx\n", physmap_map.size, physmap_map.phys);
55 physmap_map.virt = ioremap(physmap_map.phys, physmap_map.size);
57 if (!physmap_map.virt) {
58 printk("Failed to ioremap\n");
62 simple_map_init(&physmap_map);
65 type = rom_probe_types;
66 for(; !mymtd && *type; type++) {
67 mymtd = do_map_probe(*type, &physmap_map);
70 mymtd->owner = THIS_MODULE;
72 #ifdef CONFIG_MTD_PARTITIONS
73 mtd_parts_nb = parse_mtd_partitions(mymtd, part_probes,
78 add_mtd_partitions (mymtd, mtd_parts, mtd_parts_nb);
82 if (num_physmap_partitions != 0)
85 "Using physmap partition definition\n");
86 add_mtd_partitions (mymtd, physmap_partitions, num_physmap_partitions);
91 add_mtd_device(mymtd);
96 iounmap(physmap_map.virt);
100 static void __exit cleanup_physmap(void)
102 #ifdef CONFIG_MTD_PARTITIONS
104 del_mtd_partitions(mymtd);
106 } else if (num_physmap_partitions) {
107 del_mtd_partitions(mymtd);
109 del_mtd_device(mymtd);
112 del_mtd_device(mymtd);
116 iounmap(physmap_map.virt);
117 physmap_map.virt = NULL;
120 module_init(init_physmap);
121 module_exit(cleanup_physmap);
124 MODULE_LICENSE("GPL");
125 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
126 MODULE_DESCRIPTION("Generic configurable MTD map driver");