2 * Handle mapping of the NOR flash on implementa A7 boards
4 * Copyright 2002 SYSGO Real-Time Solutions GmbH
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/partitions.h>
20 #define WINDOW_ADDR0 0x00000000 /* physical properties of flash */
21 #define WINDOW_SIZE0 0x00800000
22 #define WINDOW_ADDR1 0x10000000 /* physical properties of flash */
23 #define WINDOW_SIZE1 0x00800000
24 #define NUM_FLASHBANKS 2
27 /* can be { "cfi_probe", "jedec_probe", "map_rom", NULL } */
28 #define PROBETYPES { "jedec_probe", NULL }
30 #define MSG_PREFIX "impA7:" /* prefix for our printk()'s */
31 #define MTDID "impa7-%d" /* for mtdparts= partitioning */
33 static struct mtd_info *impa7_mtd[NUM_FLASHBANKS];
36 static struct map_info impa7_map[NUM_FLASHBANKS] = {
38 .name = "impA7 NOR Flash Bank #0",
40 .bankwidth = BUSWIDTH,
43 .name = "impA7 NOR Flash Bank #1",
45 .bankwidth = BUSWIDTH,
50 * MTD partitioning stuff
52 static struct mtd_partition partitions[] =
61 static int __init init_impa7(void)
63 static const char *rom_probe_types[] = PROBETYPES;
66 static struct { u_long addr; u_long size; } pt[NUM_FLASHBANKS] = {
67 { WINDOW_ADDR0, WINDOW_SIZE0 },
68 { WINDOW_ADDR1, WINDOW_SIZE1 },
72 for(i=0; i<NUM_FLASHBANKS; i++)
74 printk(KERN_NOTICE MSG_PREFIX "probing 0x%08lx at 0x%08lx\n",
75 pt[i].size, pt[i].addr);
77 impa7_map[i].phys = pt[i].addr;
78 impa7_map[i].virt = ioremap(pt[i].addr, pt[i].size);
79 if (!impa7_map[i].virt) {
80 printk(MSG_PREFIX "failed to ioremap\n");
83 simple_map_init(&impa7_map[i]);
86 type = rom_probe_types;
87 for(; !impa7_mtd[i] && *type; type++) {
88 impa7_mtd[i] = do_map_probe(*type, &impa7_map[i]);
92 impa7_mtd[i]->owner = THIS_MODULE;
94 mtd_device_parse_register(impa7_mtd[i], NULL, NULL,
96 ARRAY_SIZE(partitions));
99 iounmap((void *)impa7_map[i].virt);
101 return devicesfound == 0 ? -ENXIO : 0;
104 static void __exit cleanup_impa7(void)
107 for (i=0; i<NUM_FLASHBANKS; i++) {
109 mtd_device_unregister(impa7_mtd[i]);
110 map_destroy(impa7_mtd[i]);
111 iounmap((void *)impa7_map[i].virt);
112 impa7_map[i].virt = 0;
117 module_init(init_impa7);
118 module_exit(cleanup_impa7);
120 MODULE_LICENSE("GPL");
121 MODULE_AUTHOR("Pavel Bartusek <pba@sysgo.de>");
122 MODULE_DESCRIPTION("MTD map driver for implementa impA7");