fs: use kmem_cache_zalloc instead
[pv_ops_mirror.git] / drivers / mtd / maps / edb7312.c
blob1c5b97c8968540703130e7e6817f5c4a32e71d1f
1 /*
2 * $Id: edb7312.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
4 * Handle mapping of the NOR flash on Cogent EDB7312 boards
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <asm/io.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
21 #ifdef CONFIG_MTD_PARTITIONS
22 #include <linux/mtd/partitions.h>
23 #endif
25 #define WINDOW_ADDR 0x00000000 /* physical properties of flash */
26 #define WINDOW_SIZE 0x01000000
27 #define BUSWIDTH 2
28 #define FLASH_BLOCKSIZE_MAIN 0x20000
29 #define FLASH_NUMBLOCKS_MAIN 128
30 /* can be "cfi_probe", "jedec_probe", "map_rom", NULL }; */
31 #define PROBETYPES { "cfi_probe", NULL }
33 #define MSG_PREFIX "EDB7312-NOR:" /* prefix for our printk()'s */
34 #define MTDID "edb7312-nor" /* for mtdparts= partitioning */
36 static struct mtd_info *mymtd;
38 struct map_info edb7312nor_map = {
39 .name = "NOR flash on EDB7312",
40 .size = WINDOW_SIZE,
41 .bankwidth = BUSWIDTH,
42 .phys = WINDOW_ADDR,
45 #ifdef CONFIG_MTD_PARTITIONS
48 * MTD partitioning stuff
50 static struct mtd_partition static_partitions[3] =
53 .name = "ARMboot",
54 .size = 0x40000,
55 .offset = 0
58 .name = "Kernel",
59 .size = 0x200000,
60 .offset = 0x40000
63 .name = "RootFS",
64 .size = 0xDC0000,
65 .offset = 0x240000
69 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
71 #endif
73 static int mtd_parts_nb = 0;
74 static struct mtd_partition *mtd_parts = 0;
76 int __init init_edb7312nor(void)
78 static const char *rom_probe_types[] = PROBETYPES;
79 const char **type;
80 const char *part_type = 0;
82 printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n",
83 WINDOW_SIZE, WINDOW_ADDR);
84 edb7312nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
86 if (!edb7312nor_map.virt) {
87 printk(MSG_PREFIX "failed to ioremap\n");
88 return -EIO;
91 simple_map_init(&edb7312nor_map);
93 mymtd = 0;
94 type = rom_probe_types;
95 for(; !mymtd && *type; type++) {
96 mymtd = do_map_probe(*type, &edb7312nor_map);
98 if (mymtd) {
99 mymtd->owner = THIS_MODULE;
101 #ifdef CONFIG_MTD_PARTITIONS
102 mtd_parts_nb = parse_mtd_partitions(mymtd, probes, &mtd_parts, MTDID);
103 if (mtd_parts_nb > 0)
104 part_type = "detected";
106 if (mtd_parts_nb == 0)
108 mtd_parts = static_partitions;
109 mtd_parts_nb = ARRAY_SIZE(static_partitions);
110 part_type = "static";
112 #endif
113 add_mtd_device(mymtd);
114 if (mtd_parts_nb == 0)
115 printk(KERN_NOTICE MSG_PREFIX "no partition info available\n");
116 else
118 printk(KERN_NOTICE MSG_PREFIX
119 "using %s partition definition\n", part_type);
120 add_mtd_partitions(mymtd, mtd_parts, mtd_parts_nb);
122 return 0;
125 iounmap((void *)edb7312nor_map.virt);
126 return -ENXIO;
129 static void __exit cleanup_edb7312nor(void)
131 if (mymtd) {
132 del_mtd_device(mymtd);
133 map_destroy(mymtd);
135 if (edb7312nor_map.virt) {
136 iounmap((void *)edb7312nor_map.virt);
137 edb7312nor_map.virt = 0;
141 module_init(init_edb7312nor);
142 module_exit(cleanup_edb7312nor);
144 MODULE_LICENSE("GPL");
145 MODULE_AUTHOR("Marius Groeger <mag@sysgo.de>");
146 MODULE_DESCRIPTION("Generic configurable MTD map driver");