blob: d1d671daf2356862374691b5a5977754d6828384 [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.
Thomas Gleixner69f34c92005-11-07 11:15:40 +000022 * - Drive A and B use the resident flash disk (RFD) flash translation layer.
23 * - If you have created your own jffs file system and the bios overwrites
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 * it during boot, try disabling Drive A: and B: in the boot order.
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 */
26
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/init.h>
Sean Young28f46232005-06-29 09:46:19 +000028#include <linux/module.h>
29#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/mtd/map.h>
Sean Young28f46232005-06-29 09:46:19 +000031#include <linux/mtd/mtd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/mtd/partitions.h>
Sean Young28f46232005-06-29 09:46:19 +000033#include <linux/types.h>
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070046static 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
Tobias Klauser87d10f32006-03-31 02:29:45 -080064#define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Linus Torvalds1da177e2005-04-16 15:20:36 -070066static 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
Sean Young28f46232005-06-29 09:46:19 +000074 if (!ts5500_map.virt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 printk(KERN_ERR "Failed to ioremap_nocache\n");
76 rc = -EIO;
Sean Young28f46232005-06-29 09:46:19 +000077 goto err2;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 }
79
80 simple_map_init(&ts5500_map);
81
82 mymtd = do_map_probe("jedec_probe", &ts5500_map);
Sean Young28f46232005-06-29 09:46:19 +000083 if (!mymtd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 mymtd = do_map_probe("map_rom", &ts5500_map);
85
Sean Young28f46232005-06-29 09:46:19 +000086 if (!mymtd) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 rc = -ENXIO;
Sean Young28f46232005-06-29 09:46:19 +000088 goto err1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 }
90
91 mymtd->owner = THIS_MODULE;
Jamie Ilesee0e87b2011-05-23 10:23:40 +010092 mtd_device_register(mymtd, ts5500_partitions, NUM_PARTITIONS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
94 return 0;
95
Sean Young28f46232005-06-29 09:46:19 +000096err1:
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 iounmap(ts5500_map.virt);
Sean Young28f46232005-06-29 09:46:19 +000098err2:
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 return rc;
100}
101
102static void __exit cleanup_ts5500_map(void)
103{
104 if (mymtd) {
Jamie Ilesee0e87b2011-05-23 10:23:40 +0100105 mtd_device_unregister(mymtd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 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