Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board
0004  *
0005  * Copyright (C) 2004 Sean Young <sean@mess.org>
0006  *
0007  * Note:
0008  * - In order for detection to work, jumper 3 must be set.
0009  * - Drive A and B use the resident flash disk (RFD) flash translation layer.
0010  * - If you have created your own jffs file system and the bios overwrites
0011  *   it during boot, try disabling Drive A: and B: in the boot order.
0012  */
0013 
0014 #include <linux/init.h>
0015 #include <linux/module.h>
0016 #include <linux/kernel.h>
0017 #include <linux/mtd/map.h>
0018 #include <linux/mtd/mtd.h>
0019 #include <linux/mtd/partitions.h>
0020 #include <linux/types.h>
0021 
0022 
0023 #define WINDOW_ADDR 0x09400000
0024 #define WINDOW_SIZE 0x00200000
0025 
0026 static struct map_info ts5500_map = {
0027     .name = "TS-5500 Flash",
0028     .size = WINDOW_SIZE,
0029     .bankwidth = 1,
0030     .phys = WINDOW_ADDR
0031 };
0032 
0033 static const struct mtd_partition ts5500_partitions[] = {
0034     {
0035         .name = "Drive A",
0036         .offset = 0,
0037         .size = 0x0e0000
0038     },
0039     {
0040         .name = "BIOS",
0041         .offset = 0x0e0000,
0042         .size = 0x020000,
0043     },
0044     {
0045         .name = "Drive B",
0046         .offset = 0x100000,
0047         .size = 0x100000
0048     }
0049 };
0050 
0051 #define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
0052 
0053 static struct mtd_info *mymtd;
0054 
0055 static int __init init_ts5500_map(void)
0056 {
0057     int rc = 0;
0058 
0059     ts5500_map.virt = ioremap(ts5500_map.phys, ts5500_map.size);
0060 
0061     if (!ts5500_map.virt) {
0062         printk(KERN_ERR "Failed to ioremap\n");
0063         rc = -EIO;
0064         goto err2;
0065     }
0066 
0067     simple_map_init(&ts5500_map);
0068 
0069     mymtd = do_map_probe("jedec_probe", &ts5500_map);
0070     if (!mymtd)
0071         mymtd = do_map_probe("map_rom", &ts5500_map);
0072 
0073     if (!mymtd) {
0074         rc = -ENXIO;
0075         goto err1;
0076     }
0077 
0078     mymtd->owner = THIS_MODULE;
0079     mtd_device_register(mymtd, ts5500_partitions, NUM_PARTITIONS);
0080 
0081     return 0;
0082 
0083 err1:
0084     iounmap(ts5500_map.virt);
0085 err2:
0086     return rc;
0087 }
0088 
0089 static void __exit cleanup_ts5500_map(void)
0090 {
0091     if (mymtd) {
0092         mtd_device_unregister(mymtd);
0093         map_destroy(mymtd);
0094     }
0095 
0096     if (ts5500_map.virt) {
0097         iounmap(ts5500_map.virt);
0098         ts5500_map.virt = NULL;
0099     }
0100 }
0101 
0102 module_init(init_ts5500_map);
0103 module_exit(cleanup_ts5500_map);
0104 
0105 MODULE_LICENSE("GPL");
0106 MODULE_AUTHOR("Sean Young <sean@mess.org>");
0107 MODULE_DESCRIPTION("MTD map driver for Technology Systems TS-5500 board");
0108