Linux 2.6.19-rc1
[linux-2.6/next.git] / drivers / mtd / maps / mbx860.c
blob06b1187278468bb4e0392b8a70edc1b32842c3f3
1 /*
2 * $Id: mbx860.c,v 1.9 2005/11/07 11:14:27 gleixner Exp $
4 * Handle mapping of the flash on MBX860 boards
6 * Author: Anton Todorov
7 * Copyright: (C) 2001 Emness Technology
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <asm/io.h>
20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/map.h>
22 #include <linux/mtd/partitions.h>
25 #define WINDOW_ADDR 0xfe000000
26 #define WINDOW_SIZE 0x00200000
28 /* Flash / Partition sizing */
29 #define MAX_SIZE_KiB 8192
30 #define BOOT_PARTITION_SIZE_KiB 512
31 #define KERNEL_PARTITION_SIZE_KiB 5632
32 #define APP_PARTITION_SIZE_KiB 2048
34 #define NUM_PARTITIONS 3
36 /* partition_info gives details on the logical partitions that the split the
37 * single flash device into. If the size if zero we use up to the end of the
38 * device. */
39 static struct mtd_partition partition_info[]={
40 { .name = "MBX flash BOOT partition",
41 .offset = 0,
42 .size = BOOT_PARTITION_SIZE_KiB*1024 },
43 { .name = "MBX flash DATA partition",
44 .offset = BOOT_PARTITION_SIZE_KiB*1024,
45 .size = (KERNEL_PARTITION_SIZE_KiB)*1024 },
46 { .name = "MBX flash APPLICATION partition",
47 .offset = (BOOT_PARTITION_SIZE_KiB+KERNEL_PARTITION_SIZE_KiB)*1024 }
51 static struct mtd_info *mymtd;
53 struct map_info mbx_map = {
54 .name = "MBX flash",
55 .size = WINDOW_SIZE,
56 .phys = WINDOW_ADDR,
57 .bankwidth = 4,
60 int __init init_mbx(void)
62 printk(KERN_NOTICE "Motorola MBX flash device: 0x%x at 0x%x\n", WINDOW_SIZE*4, WINDOW_ADDR);
63 mbx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
65 if (!mbx_map.virt) {
66 printk("Failed to ioremap\n");
67 return -EIO;
69 simple_map_init(&mbx_map);
71 mymtd = do_map_probe("jedec_probe", &mbx_map);
72 if (mymtd) {
73 mymtd->owner = THIS_MODULE;
74 add_mtd_device(mymtd);
75 add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
76 return 0;
79 iounmap((void *)mbx_map.virt);
80 return -ENXIO;
83 static void __exit cleanup_mbx(void)
85 if (mymtd) {
86 del_mtd_device(mymtd);
87 map_destroy(mymtd);
89 if (mbx_map.virt) {
90 iounmap((void *)mbx_map.virt);
91 mbx_map.virt = 0;
95 module_init(init_mbx);
96 module_exit(cleanup_mbx);
98 MODULE_AUTHOR("Anton Todorov <a.todorov@emness.com>");
99 MODULE_DESCRIPTION("MTD map driver for Motorola MBX860 board");
100 MODULE_LICENSE("GPL");