WIP FPC-III support
[linux/fpc-iii.git] / drivers / mtd / maps / ts5500_flash.c
blob70d6e865f55512087916f850d116284049905e99
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board
5 * Copyright (C) 2004 Sean Young <sean@mess.org>
7 * Note:
8 * - In order for detection to work, jumper 3 must be set.
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
11 * it during boot, try disabling Drive A: and B: in the boot order.
14 #include <linux/init.h>
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/partitions.h>
20 #include <linux/types.h>
23 #define WINDOW_ADDR 0x09400000
24 #define WINDOW_SIZE 0x00200000
26 static struct map_info ts5500_map = {
27 .name = "TS-5500 Flash",
28 .size = WINDOW_SIZE,
29 .bankwidth = 1,
30 .phys = WINDOW_ADDR
33 static const struct mtd_partition ts5500_partitions[] = {
35 .name = "Drive A",
36 .offset = 0,
37 .size = 0x0e0000
40 .name = "BIOS",
41 .offset = 0x0e0000,
42 .size = 0x020000,
45 .name = "Drive B",
46 .offset = 0x100000,
47 .size = 0x100000
51 #define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
53 static struct mtd_info *mymtd;
55 static int __init init_ts5500_map(void)
57 int rc = 0;
59 ts5500_map.virt = ioremap(ts5500_map.phys, ts5500_map.size);
61 if (!ts5500_map.virt) {
62 printk(KERN_ERR "Failed to ioremap\n");
63 rc = -EIO;
64 goto err2;
67 simple_map_init(&ts5500_map);
69 mymtd = do_map_probe("jedec_probe", &ts5500_map);
70 if (!mymtd)
71 mymtd = do_map_probe("map_rom", &ts5500_map);
73 if (!mymtd) {
74 rc = -ENXIO;
75 goto err1;
78 mymtd->owner = THIS_MODULE;
79 mtd_device_register(mymtd, ts5500_partitions, NUM_PARTITIONS);
81 return 0;
83 err1:
84 iounmap(ts5500_map.virt);
85 err2:
86 return rc;
89 static void __exit cleanup_ts5500_map(void)
91 if (mymtd) {
92 mtd_device_unregister(mymtd);
93 map_destroy(mymtd);
96 if (ts5500_map.virt) {
97 iounmap(ts5500_map.virt);
98 ts5500_map.virt = NULL;
102 module_init(init_ts5500_map);
103 module_exit(cleanup_ts5500_map);
105 MODULE_LICENSE("GPL");
106 MODULE_AUTHOR("Sean Young <sean@mess.org>");
107 MODULE_DESCRIPTION("MTD map driver for Technology Systems TS-5500 board");