blob: 6cfc8783c0e5e9a8fb03065186a8742ad865eff4 [file] [log] [blame]
Thomas Gleixner1a59d1b82019-05-27 08:55:05 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board
4 *
5 * Copyright (C) 2004 Sean Young <sean@mess.org>
6 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * Note:
8 * - In order for detection to work, jumper 3 must be set.
Thomas Gleixner69f34c92005-11-07 11:15:40 +00009 * - 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * it during boot, try disabling Drive A: and B: in the boot order.
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 */
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/init.h>
Sean Young28f46232005-06-29 09:46:19 +000015#include <linux/module.h>
16#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/mtd/map.h>
Sean Young28f46232005-06-29 09:46:19 +000018#include <linux/mtd/mtd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/mtd/partitions.h>
Sean Young28f46232005-06-29 09:46:19 +000020#include <linux/types.h>
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23#define WINDOW_ADDR 0x09400000
24#define WINDOW_SIZE 0x00200000
25
26static struct map_info ts5500_map = {
27 .name = "TS-5500 Flash",
28 .size = WINDOW_SIZE,
29 .bankwidth = 1,
30 .phys = WINDOW_ADDR
31};
32
Arvind Yadavd4906682017-08-28 13:54:57 +053033static const struct mtd_partition ts5500_partitions[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 {
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
Tobias Klauser87d10f32006-03-31 02:29:45 -080051#define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Linus Torvalds1da177e2005-04-16 15:20:36 -070053static struct mtd_info *mymtd;
54
55static 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
Sean Young28f46232005-06-29 09:46:19 +000061 if (!ts5500_map.virt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 printk(KERN_ERR "Failed to ioremap_nocache\n");
63 rc = -EIO;
Sean Young28f46232005-06-29 09:46:19 +000064 goto err2;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 }
66
67 simple_map_init(&ts5500_map);
68
69 mymtd = do_map_probe("jedec_probe", &ts5500_map);
Sean Young28f46232005-06-29 09:46:19 +000070 if (!mymtd)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 mymtd = do_map_probe("map_rom", &ts5500_map);
72
Sean Young28f46232005-06-29 09:46:19 +000073 if (!mymtd) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 rc = -ENXIO;
Sean Young28f46232005-06-29 09:46:19 +000075 goto err1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 }
77
78 mymtd->owner = THIS_MODULE;
Jamie Ilesee0e87b2011-05-23 10:23:40 +010079 mtd_device_register(mymtd, ts5500_partitions, NUM_PARTITIONS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81 return 0;
82
Sean Young28f46232005-06-29 09:46:19 +000083err1:
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 iounmap(ts5500_map.virt);
Sean Young28f46232005-06-29 09:46:19 +000085err2:
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 return rc;
87}
88
89static void __exit cleanup_ts5500_map(void)
90{
91 if (mymtd) {
Jamie Ilesee0e87b2011-05-23 10:23:40 +010092 mtd_device_unregister(mymtd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 map_destroy(mymtd);
94 }
95
96 if (ts5500_map.virt) {
97 iounmap(ts5500_map.virt);
98 ts5500_map.virt = NULL;
99 }
100}
101
102module_init(init_ts5500_map);
103module_exit(cleanup_ts5500_map);
104
105MODULE_LICENSE("GPL");
106MODULE_AUTHOR("Sean Young <sean@mess.org>");
Masanari Iida9cd5196e2015-03-30 19:06:22 +0900107MODULE_DESCRIPTION("MTD map driver for Technology Systems TS-5500 board");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108