Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 22 | * - 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | * it during boot, try disabling Drive A: and B: in the boot order. |
| 25 | * |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 26 | * $Id: ts5500_flash.c,v 1.5 2005/11/07 11:14:28 gleixner Exp $ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | */ |
| 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <linux/init.h> |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 30 | #include <linux/module.h> |
| 31 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/mtd/map.h> |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 33 | #include <linux/mtd/mtd.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <linux/mtd/partitions.h> |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 35 | #include <linux/types.h> |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | #define WINDOW_ADDR 0x09400000 |
| 39 | #define WINDOW_SIZE 0x00200000 |
| 40 | |
| 41 | static struct map_info ts5500_map = { |
| 42 | .name = "TS-5500 Flash", |
| 43 | .size = WINDOW_SIZE, |
| 44 | .bankwidth = 1, |
| 45 | .phys = WINDOW_ADDR |
| 46 | }; |
| 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | static struct mtd_partition ts5500_partitions[] = { |
| 49 | { |
| 50 | .name = "Drive A", |
| 51 | .offset = 0, |
| 52 | .size = 0x0e0000 |
| 53 | }, |
| 54 | { |
| 55 | .name = "BIOS", |
| 56 | .offset = 0x0e0000, |
| 57 | .size = 0x020000, |
| 58 | }, |
| 59 | { |
| 60 | .name = "Drive B", |
| 61 | .offset = 0x100000, |
| 62 | .size = 0x100000 |
| 63 | } |
| 64 | }; |
| 65 | |
Tobias Klauser | 87d10f3 | 2006-03-31 02:29:45 -0800 | [diff] [blame] | 66 | #define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | static struct mtd_info *mymtd; |
| 69 | |
| 70 | static int __init init_ts5500_map(void) |
| 71 | { |
| 72 | int rc = 0; |
| 73 | |
| 74 | ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size); |
| 75 | |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 76 | if (!ts5500_map.virt) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | printk(KERN_ERR "Failed to ioremap_nocache\n"); |
| 78 | rc = -EIO; |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 79 | goto err2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | simple_map_init(&ts5500_map); |
| 83 | |
| 84 | mymtd = do_map_probe("jedec_probe", &ts5500_map); |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 85 | if (!mymtd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | mymtd = do_map_probe("map_rom", &ts5500_map); |
| 87 | |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 88 | if (!mymtd) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | rc = -ENXIO; |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 90 | goto err1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | mymtd->owner = THIS_MODULE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | return 0; |
| 97 | |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 98 | err1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | map_destroy(mymtd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | iounmap(ts5500_map.virt); |
Sean Young | 28f4623 | 2005-06-29 09:46:19 +0000 | [diff] [blame] | 101 | err2: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | return rc; |
| 103 | } |
| 104 | |
| 105 | static void __exit cleanup_ts5500_map(void) |
| 106 | { |
| 107 | if (mymtd) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | del_mtd_partitions(mymtd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | map_destroy(mymtd); |
| 110 | } |
| 111 | |
| 112 | if (ts5500_map.virt) { |
| 113 | iounmap(ts5500_map.virt); |
| 114 | ts5500_map.virt = NULL; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | module_init(init_ts5500_map); |
| 119 | module_exit(cleanup_ts5500_map); |
| 120 | |
| 121 | MODULE_LICENSE("GPL"); |
| 122 | MODULE_AUTHOR("Sean Young <sean@mess.org>"); |
| 123 | MODULE_DESCRIPTION("MTD map driver for Techology Systems TS-5500 board"); |
| 124 | |