blob: 286dd82e8b831694eefe32ed7729e67ec0004edf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board
3 *
4 * Copyright (C) 2004 Sean Young <sean@mess.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 *
20 * Note:
21 * - In order for detection to work, jumper 3 must be set.
Sean Younge27a9962005-06-16 09:49:33 +010022 * - Drive A and B use the resident flash disk (RFD) flash translation layer.
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 * - If you have created your own jffs file system and the bios overwrites
24 * it during boot, try disabling Drive A: and B: in the boot order.
25 *
Sean Younge27a9962005-06-16 09:49:33 +010026 * $Id: ts5500_flash.c,v 1.3 2005/06/16 08:49:30 sean Exp $
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 */
28
29#include <linux/config.h>
30#include <linux/module.h>
31#include <linux/types.h>
32#include <linux/kernel.h>
33#include <linux/init.h>
34#include <linux/mtd/mtd.h>
35#include <linux/mtd/map.h>
36
37#ifdef CONFIG_MTD_PARTITIONS
38#include <linux/mtd/partitions.h>
39#endif
40
41#define WINDOW_ADDR 0x09400000
42#define WINDOW_SIZE 0x00200000
43
44static struct map_info ts5500_map = {
45 .name = "TS-5500 Flash",
46 .size = WINDOW_SIZE,
47 .bankwidth = 1,
48 .phys = WINDOW_ADDR
49};
50
51#ifdef CONFIG_MTD_PARTITIONS
52static struct mtd_partition ts5500_partitions[] = {
53 {
54 .name = "Drive A",
55 .offset = 0,
56 .size = 0x0e0000
57 },
58 {
59 .name = "BIOS",
60 .offset = 0x0e0000,
61 .size = 0x020000,
62 },
63 {
64 .name = "Drive B",
65 .offset = 0x100000,
66 .size = 0x100000
67 }
68};
69
70#define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition))
71
72#endif
73
74static struct mtd_info *mymtd;
75
76static int __init init_ts5500_map(void)
77{
78 int rc = 0;
79
80 ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size);
81
82 if(!ts5500_map.virt) {
83 printk(KERN_ERR "Failed to ioremap_nocache\n");
84 rc = -EIO;
85 goto err_out_ioremap;
86 }
87
88 simple_map_init(&ts5500_map);
89
90 mymtd = do_map_probe("jedec_probe", &ts5500_map);
91 if(!mymtd)
92 mymtd = do_map_probe("map_rom", &ts5500_map);
93
94 if(!mymtd) {
95 rc = -ENXIO;
96 goto err_out_map;
97 }
98
99 mymtd->owner = THIS_MODULE;
100#ifdef CONFIG_MTD_PARTITIONS
101 add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS);
102#else
103 add_mtd_device(mymtd);
104#endif
105
106 return 0;
107
108err_out_map:
109 map_destroy(mymtd);
110err_out_ioremap:
111 iounmap(ts5500_map.virt);
112
113 return rc;
114}
115
116static void __exit cleanup_ts5500_map(void)
117{
118 if (mymtd) {
119#ifdef CONFIG_MTD_PARTITIONS
120 del_mtd_partitions(mymtd);
121#else
122 del_mtd_device(mymtd);
123#endif
124 map_destroy(mymtd);
125 }
126
127 if (ts5500_map.virt) {
128 iounmap(ts5500_map.virt);
129 ts5500_map.virt = NULL;
130 }
131}
132
133module_init(init_ts5500_map);
134module_exit(cleanup_ts5500_map);
135
136MODULE_LICENSE("GPL");
137MODULE_AUTHOR("Sean Young <sean@mess.org>");
138MODULE_DESCRIPTION("MTD map driver for Techology Systems TS-5500 board");
139