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