blob: d884f2be28f6574fb45f19a7cd423bee4a81a1de [file] [log] [blame]
Joern Engelb523b3b2005-09-18 11:46:45 +01001/*
2 * Flash memory access on 4G Systems MTX-1 boards
3 *
Thomas Gleixner69f34c92005-11-07 11:15:40 +00004 * $Id: mtx-1_flash.c,v 1.2 2005/11/07 11:14:27 gleixner Exp $
Joern Engelb523b3b2005-09-18 11:46:45 +01005 *
6 * (C) 2005 Bruno Randolf <bruno.randolf@4g-systems.biz>
David Woodhouse151e7652006-05-14 01:51:54 +01007 * (C) 2005 Jörn Engel <joern@wohnheim.fh-wedel.de>
Joern Engelb523b3b2005-09-18 11:46:45 +01008 *
9 */
10
Joern Engelb523b3b2005-09-18 11:46:45 +010011#include <linux/module.h>
12#include <linux/types.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/map.h>
18#include <linux/mtd/partitions.h>
19
20#include <asm/io.h>
21
22static struct map_info mtx1_map = {
23 .name = "MTX-1 flash",
24 .bankwidth = 4,
25 .size = 0x2000000,
26 .phys = 0x1E000000,
27};
28
29static struct mtd_partition mtx1_partitions[] = {
30 {
31 .name = "filesystem",
32 .size = 0x01C00000,
33 .offset = 0,
34 },{
35 .name = "yamon",
36 .size = 0x00100000,
37 .offset = MTDPART_OFS_APPEND,
38 .mask_flags = MTD_WRITEABLE,
39 },{
40 .name = "kernel",
41 .size = 0x002c0000,
42 .offset = MTDPART_OFS_APPEND,
43 },{
44 .name = "yamon env",
45 .size = 0x00040000,
46 .offset = MTDPART_OFS_APPEND,
47 }
48};
49
50static struct mtd_info *mtx1_mtd;
51
52int __init mtx1_mtd_init(void)
53{
54 int ret = -ENXIO;
55
56 simple_map_init(&mtx1_map);
57
58 mtx1_map.virt = ioremap(mtx1_map.phys, mtx1_map.size);
59 if (!mtx1_map.virt)
60 return -EIO;
61
62 mtx1_mtd = do_map_probe("cfi_probe", &mtx1_map);
63 if (!mtx1_mtd)
64 goto err;
65
66 mtx1_mtd->owner = THIS_MODULE;
67
Thomas Gleixner69f34c92005-11-07 11:15:40 +000068 ret = add_mtd_partitions(mtx1_mtd, mtx1_partitions,
Joern Engelb523b3b2005-09-18 11:46:45 +010069 ARRAY_SIZE(mtx1_partitions));
70 if (ret)
71 goto err;
72
73 return 0;
74
75err:
76 iounmap(mtx1_map.virt);
77 return ret;
78}
79
80static void __exit mtx1_mtd_cleanup(void)
81{
82 if (mtx1_mtd) {
83 del_mtd_partitions(mtx1_mtd);
84 map_destroy(mtx1_mtd);
85 }
86 if (mtx1_map.virt)
87 iounmap(mtx1_map.virt);
88}
89
90module_init(mtx1_mtd_init);
91module_exit(mtx1_mtd_cleanup);
92
93MODULE_AUTHOR("Bruno Randolf <bruno.randolf@4g-systems.biz>");
94MODULE_DESCRIPTION("MTX-1 flash map");
95MODULE_LICENSE("GPL");