1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <linux/init.h>
28#include <linux/module.h>
29#include <linux/kernel.h>
30#include <linux/mtd/map.h>
31#include <linux/mtd/mtd.h>
32#include <linux/mtd/partitions.h>
33#include <linux/types.h>
34
35
36#define WINDOW_ADDR 0x09400000
37#define WINDOW_SIZE 0x00200000
38
39static struct map_info ts5500_map = {
40 .name = "TS-5500 Flash",
41 .size = WINDOW_SIZE,
42 .bankwidth = 1,
43 .phys = WINDOW_ADDR
44};
45
46static struct mtd_partition ts5500_partitions[] = {
47 {
48 .name = "Drive A",
49 .offset = 0,
50 .size = 0x0e0000
51 },
52 {
53 .name = "BIOS",
54 .offset = 0x0e0000,
55 .size = 0x020000,
56 },
57 {
58 .name = "Drive B",
59 .offset = 0x100000,
60 .size = 0x100000
61 }
62};
63
64#define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
65
66static struct mtd_info *mymtd;
67
68static int __init init_ts5500_map(void)
69{
70 int rc = 0;
71
72 ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size);
73
74 if (!ts5500_map.virt) {
75 printk(KERN_ERR "Failed to ioremap_nocache\n");
76 rc = -EIO;
77 goto err2;
78 }
79
80 simple_map_init(&ts5500_map);
81
82 mymtd = do_map_probe("jedec_probe", &ts5500_map);
83 if (!mymtd)
84 mymtd = do_map_probe("map_rom", &ts5500_map);
85
86 if (!mymtd) {
87 rc = -ENXIO;
88 goto err1;
89 }
90
91 mymtd->owner = THIS_MODULE;
92 add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS);
93
94 return 0;
95
96err1:
97 iounmap(ts5500_map.virt);
98err2:
99 return rc;
100}
101
102static void __exit cleanup_ts5500_map(void)
103{
104 if (mymtd) {
105 del_mtd_partitions(mymtd);
106 map_destroy(mymtd);
107 }
108
109 if (ts5500_map.virt) {
110 iounmap(ts5500_map.virt);
111 ts5500_map.virt = NULL;
112 }
113}
114
115module_init(init_ts5500_map);
116module_exit(cleanup_ts5500_map);
117
118MODULE_LICENSE("GPL");
119MODULE_AUTHOR("Sean Young <sean@mess.org>");
120MODULE_DESCRIPTION("MTD map driver for Techology Systems TS-5500 board");
121
122