1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <linux/module.h>
26#include <linux/types.h>
27#include <linux/kernel.h>
28#include <linux/init.h>
29#include <asm/io.h>
30#include <linux/mtd/mtd.h>
31#include <linux/mtd/map.h>
32#include <linux/mtd/partitions.h>
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55static const struct mtd_partition partition_info[] = {
56 {
57 .name = "NetSc520 boot kernel",
58 .offset = 0,
59 .size = 0xc0000
60 },
61 {
62 .name = "NetSc520 Low BIOS",
63 .offset = 0xc0000,
64 .size = 0x40000
65 },
66 {
67 .name = "NetSc520 file system",
68 .offset = 0x100000,
69 .size = 0xe80000
70 },
71 {
72 .name = "NetSc520 High BIOS",
73 .offset = 0xf80000,
74 .size = 0x80000
75 },
76};
77#define NUM_PARTITIONS ARRAY_SIZE(partition_info)
78
79#define WINDOW_SIZE 0x00100000
80#define WINDOW_ADDR 0x00200000
81
82static struct map_info netsc520_map = {
83 .name = "netsc520 Flash Bank",
84 .size = WINDOW_SIZE,
85 .bankwidth = 4,
86 .phys = WINDOW_ADDR,
87};
88
89#define NUM_FLASH_BANKS ARRAY_SIZE(netsc520_map)
90
91static struct mtd_info *mymtd;
92
93static int __init init_netsc520(void)
94{
95 printk(KERN_NOTICE "NetSc520 flash device: 0x%Lx at 0x%Lx\n",
96 (unsigned long long)netsc520_map.size,
97 (unsigned long long)netsc520_map.phys);
98 netsc520_map.virt = ioremap_nocache(netsc520_map.phys, netsc520_map.size);
99
100 if (!netsc520_map.virt) {
101 printk("Failed to ioremap_nocache\n");
102 return -EIO;
103 }
104
105 simple_map_init(&netsc520_map);
106
107 mymtd = do_map_probe("cfi_probe", &netsc520_map);
108 if(!mymtd)
109 mymtd = do_map_probe("map_ram", &netsc520_map);
110 if(!mymtd)
111 mymtd = do_map_probe("map_rom", &netsc520_map);
112
113 if (!mymtd) {
114 iounmap(netsc520_map.virt);
115 return -ENXIO;
116 }
117
118 mymtd->owner = THIS_MODULE;
119 mtd_device_register(mymtd, partition_info, NUM_PARTITIONS);
120 return 0;
121}
122
123static void __exit cleanup_netsc520(void)
124{
125 if (mymtd) {
126 mtd_device_unregister(mymtd);
127 map_destroy(mymtd);
128 }
129 if (netsc520_map.virt) {
130 iounmap(netsc520_map.virt);
131 netsc520_map.virt = NULL;
132 }
133}
134
135module_init(init_netsc520);
136module_exit(cleanup_netsc520);
137
138MODULE_LICENSE("GPL");
139MODULE_AUTHOR("Mark Langsdorf <mark.langsdorf@amd.com>");
140MODULE_DESCRIPTION("MTD map driver for AMD NetSc520 Demonstration Board");
141