]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
1da177e4 LT |
2 | /* |
3 | * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board | |
4 | * | |
5 | * Copyright (C) 2004 Sean Young <sean@mess.org> | |
6 | * | |
1da177e4 LT |
7 | * Note: |
8 | * - In order for detection to work, jumper 3 must be set. | |
69f34c98 TG |
9 | * - Drive A and B use the resident flash disk (RFD) flash translation layer. |
10 | * - If you have created your own jffs file system and the bios overwrites | |
1da177e4 | 11 | * it during boot, try disabling Drive A: and B: in the boot order. |
1da177e4 LT |
12 | */ |
13 | ||
28f46230 | 14 | #include <linux/init.h> |
1da177e4 | 15 | #include <linux/module.h> |
1da177e4 | 16 | #include <linux/kernel.h> |
1da177e4 | 17 | #include <linux/mtd/map.h> |
28f46230 | 18 | #include <linux/mtd/mtd.h> |
1da177e4 | 19 | #include <linux/mtd/partitions.h> |
28f46230 SY |
20 | #include <linux/types.h> |
21 | ||
1da177e4 LT |
22 | |
23 | #define WINDOW_ADDR 0x09400000 | |
24 | #define WINDOW_SIZE 0x00200000 | |
25 | ||
26 | static struct map_info ts5500_map = { | |
27 | .name = "TS-5500 Flash", | |
28 | .size = WINDOW_SIZE, | |
29 | .bankwidth = 1, | |
30 | .phys = WINDOW_ADDR | |
31 | }; | |
32 | ||
d4906688 | 33 | static const struct mtd_partition ts5500_partitions[] = { |
1da177e4 LT |
34 | { |
35 | .name = "Drive A", | |
36 | .offset = 0, | |
37 | .size = 0x0e0000 | |
38 | }, | |
39 | { | |
40 | .name = "BIOS", | |
41 | .offset = 0x0e0000, | |
42 | .size = 0x020000, | |
43 | }, | |
44 | { | |
45 | .name = "Drive B", | |
46 | .offset = 0x100000, | |
47 | .size = 0x100000 | |
48 | } | |
49 | }; | |
50 | ||
87d10f3c | 51 | #define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions) |
1da177e4 | 52 | |
1da177e4 LT |
53 | static struct mtd_info *mymtd; |
54 | ||
55 | static int __init init_ts5500_map(void) | |
56 | { | |
57 | int rc = 0; | |
58 | ||
59 | ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size); | |
60 | ||
28f46230 | 61 | if (!ts5500_map.virt) { |
1da177e4 LT |
62 | printk(KERN_ERR "Failed to ioremap_nocache\n"); |
63 | rc = -EIO; | |
28f46230 | 64 | goto err2; |
1da177e4 LT |
65 | } |
66 | ||
67 | simple_map_init(&ts5500_map); | |
68 | ||
69 | mymtd = do_map_probe("jedec_probe", &ts5500_map); | |
28f46230 | 70 | if (!mymtd) |
1da177e4 LT |
71 | mymtd = do_map_probe("map_rom", &ts5500_map); |
72 | ||
28f46230 | 73 | if (!mymtd) { |
1da177e4 | 74 | rc = -ENXIO; |
28f46230 | 75 | goto err1; |
1da177e4 LT |
76 | } |
77 | ||
78 | mymtd->owner = THIS_MODULE; | |
ee0e87b1 | 79 | mtd_device_register(mymtd, ts5500_partitions, NUM_PARTITIONS); |
1da177e4 LT |
80 | |
81 | return 0; | |
82 | ||
28f46230 | 83 | err1: |
1da177e4 | 84 | iounmap(ts5500_map.virt); |
28f46230 | 85 | err2: |
1da177e4 LT |
86 | return rc; |
87 | } | |
88 | ||
89 | static void __exit cleanup_ts5500_map(void) | |
90 | { | |
91 | if (mymtd) { | |
ee0e87b1 | 92 | mtd_device_unregister(mymtd); |
1da177e4 LT |
93 | map_destroy(mymtd); |
94 | } | |
95 | ||
96 | if (ts5500_map.virt) { | |
97 | iounmap(ts5500_map.virt); | |
98 | ts5500_map.virt = NULL; | |
99 | } | |
100 | } | |
101 | ||
102 | module_init(init_ts5500_map); | |
103 | module_exit(cleanup_ts5500_map); | |
104 | ||
105 | MODULE_LICENSE("GPL"); | |
106 | MODULE_AUTHOR("Sean Young <sean@mess.org>"); | |
9cd5196e | 107 | MODULE_DESCRIPTION("MTD map driver for Technology Systems TS-5500 board"); |
1da177e4 | 108 |