blob: 4b372bcb17f1c0b6dbd5ec3312aa59edbb97f7dd [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.
25 *
Thomas Gleixner69f34c92005-11-07 11:15:40 +000026 * $Id: ts5500_flash.c,v 1.5 2005/11/07 11:14:28 gleixner Exp $
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 */
28
29#include <linux/config.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/init.h>
Sean Young28f46232005-06-29 09:46:19 +000031#include <linux/module.h>
32#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <linux/mtd/map.h>
Sean Young28f46232005-06-29 09:46:19 +000034#include <linux/mtd/mtd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/mtd/partitions.h>
Sean Young28f46232005-06-29 09:46:19 +000036#include <linux/types.h>
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39#define WINDOW_ADDR 0x09400000
40#define WINDOW_SIZE 0x00200000
41
42static struct map_info ts5500_map = {
43 .name = "TS-5500 Flash",
44 .size = WINDOW_SIZE,
45 .bankwidth = 1,
46 .phys = WINDOW_ADDR
47};
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049static struct mtd_partition ts5500_partitions[] = {
50 {
51 .name = "Drive A",
52 .offset = 0,
53 .size = 0x0e0000
54 },
55 {
56 .name = "BIOS",
57 .offset = 0x0e0000,
58 .size = 0x020000,
59 },
60 {
61 .name = "Drive B",
62 .offset = 0x100000,
63 .size = 0x100000
64 }
65};
66
67#define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition))
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069static struct mtd_info *mymtd;
70
71static int __init init_ts5500_map(void)
72{
73 int rc = 0;
74
75 ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size);
76
Sean Young28f46232005-06-29 09:46:19 +000077 if (!ts5500_map.virt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 printk(KERN_ERR "Failed to ioremap_nocache\n");
79 rc = -EIO;
Sean Young28f46232005-06-29 09:46:19 +000080 goto err2;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 }
82
83 simple_map_init(&ts5500_map);
84
85 mymtd = do_map_probe("jedec_probe", &ts5500_map);
Sean Young28f46232005-06-29 09:46:19 +000086 if (!mymtd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 mymtd = do_map_probe("map_rom", &ts5500_map);
88
Sean Young28f46232005-06-29 09:46:19 +000089 if (!mymtd) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 rc = -ENXIO;
Sean Young28f46232005-06-29 09:46:19 +000091 goto err1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 }
93
94 mymtd->owner = THIS_MODULE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97 return 0;
98
Sean Young28f46232005-06-29 09:46:19 +000099err1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 map_destroy(mymtd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 iounmap(ts5500_map.virt);
Sean Young28f46232005-06-29 09:46:19 +0000102err2:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 return rc;
104}
105
106static void __exit cleanup_ts5500_map(void)
107{
108 if (mymtd) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 del_mtd_partitions(mymtd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 map_destroy(mymtd);
111 }
112
113 if (ts5500_map.virt) {
114 iounmap(ts5500_map.virt);
115 ts5500_map.virt = NULL;
116 }
117}
118
119module_init(init_ts5500_map);
120module_exit(cleanup_ts5500_map);
121
122MODULE_LICENSE("GPL");
123MODULE_AUTHOR("Sean Young <sean@mess.org>");
124MODULE_DESCRIPTION("MTD map driver for Techology Systems TS-5500 board");
125