diff options
Diffstat (limited to 'drivers/mtd/maps/mbx860.c')
-rw-r--r-- | drivers/mtd/maps/mbx860.c | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/drivers/mtd/maps/mbx860.c b/drivers/mtd/maps/mbx860.c new file mode 100644 index 000000000000..c5c6901a4763 --- /dev/null +++ b/drivers/mtd/maps/mbx860.c | |||
@@ -0,0 +1,100 @@ | |||
1 | /* | ||
2 | * $Id: mbx860.c,v 1.8 2004/11/04 13:24:15 gleixner Exp $ | ||
3 | * | ||
4 | * Handle mapping of the flash on MBX860 boards | ||
5 | * | ||
6 | * Author: Anton Todorov | ||
7 | * Copyright: (C) 2001 Emness Technology | ||
8 | * | ||
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. | ||
12 | * | ||
13 | */ | ||
14 | |||
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> | ||
23 | |||
24 | |||
25 | #define WINDOW_ADDR 0xfe000000 | ||
26 | #define WINDOW_SIZE 0x00200000 | ||
27 | |||
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 | ||
33 | |||
34 | #define NUM_PARTITIONS 3 | ||
35 | |||
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 } | ||
48 | }; | ||
49 | |||
50 | |||
51 | static struct mtd_info *mymtd; | ||
52 | |||
53 | struct map_info mbx_map = { | ||
54 | .name = "MBX flash", | ||
55 | .size = WINDOW_SIZE, | ||
56 | .phys = WINDOW_ADDR, | ||
57 | .bankwidth = 4, | ||
58 | }; | ||
59 | |||
60 | int __init init_mbx(void) | ||
61 | { | ||
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); | ||
64 | |||
65 | if (!mbx_map.virt) { | ||
66 | printk("Failed to ioremap\n"); | ||
67 | return -EIO; | ||
68 | } | ||
69 | simple_map_init(&mbx_map); | ||
70 | |||
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; | ||
77 | } | ||
78 | |||
79 | iounmap((void *)mbx_map.virt); | ||
80 | return -ENXIO; | ||
81 | } | ||
82 | |||
83 | static void __exit cleanup_mbx(void) | ||
84 | { | ||
85 | if (mymtd) { | ||
86 | del_mtd_device(mymtd); | ||
87 | map_destroy(mymtd); | ||
88 | } | ||
89 | if (mbx_map.virt) { | ||
90 | iounmap((void *)mbx_map.virt); | ||
91 | mbx_map.virt = 0; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | module_init(init_mbx); | ||
96 | module_exit(cleanup_mbx); | ||
97 | |||
98 | MODULE_AUTHOR("Anton Todorov <a.todorov@emness.com>"); | ||
99 | MODULE_DESCRIPTION("MTD map driver for Motorola MBX860 board"); | ||
100 | MODULE_LICENSE("GPL"); | ||