12 #include <linux/kernel.h>
13 #include <linux/module.h>
15 #include <linux/slab.h>
16 #include <linux/types.h>
18 #include <asm/addrspace.h>
19 #include <asm/bootinfo.h>
30 "ms02-nv.c: v.1.0.0 13 Aug 2001 Maciej W. Rozycki.\n";
44 0x07000000, 0x06800000, 0x06000000, 0x05800000, 0x05000000,
45 0x04800000, 0x04000000, 0x03800000, 0x03000000, 0x02800000,
46 0x02000000, 0x01800000, 0x01000000, 0x00800000
49 static const char ms02nv_name[] =
"DEC MS02-NV NVRAM";
50 static const char ms02nv_res_diag_ram[] =
"Diagnostic RAM";
51 static const char ms02nv_res_user_ram[] =
"General-purpose RAM";
52 static const char ms02nv_res_csr[] =
"Control and status register";
54 static struct mtd_info *root_ms02nv_mtd;
57 static int ms02nv_read(
struct mtd_info *mtd, loff_t
from,
67 static int ms02nv_write(
struct mtd_info *mtd, loff_t to,
68 size_t len,
size_t *retlen,
const u_char *
buf)
94 err =
get_dbe(ms02nv_magic, ms02nv_magicp);
100 ms02nv_diag = *ms02nv_diagp;
117 size_t size, fixsize;
119 static int version_printed;
124 mod_res = kzalloc(
sizeof(*mod_res),
GFP_KERNEL);
128 mod_res->
name = ms02nv_name;
133 goto err_out_mod_res;
135 size = ms02nv_probe_one(addr);
137 goto err_out_mod_res_rel;
139 if (!version_printed) {
147 goto err_out_mod_res_rel;
156 diag_res = kzalloc(
sizeof(*diag_res),
GFP_KERNEL);
160 diag_res->
name = ms02nv_res_diag_ram;
169 user_res = kzalloc(
sizeof(*user_res),
GFP_KERNEL);
171 goto err_out_diag_res;
173 user_res->
name = ms02nv_res_user_ram;
175 user_res->
end = addr + size - 1;
182 csr_res = kzalloc(
sizeof(*csr_res),
GFP_KERNEL);
184 goto err_out_user_res;
186 csr_res->
name = ms02nv_res_csr;
188 csr_res->
end = addr + MS02NV_CSR + 3;
208 mtd->
name = (
char *)ms02nv_name;
210 mtd->
_read = ms02nv_read;
211 mtd->
_write = ms02nv_write;
217 "ms02-nv: Unable to register MTD device, aborting!\n");
218 goto err_out_csr_res;
222 mtd->
index, ms02nv_name, addr, size >> 20);
224 mp->
next = root_ms02nv_mtd;
225 root_ms02nv_mtd = mtd;
250 static void __exit ms02nv_remove_one(
void)
252 struct mtd_info *mtd = root_ms02nv_mtd;
255 root_ms02nv_mtd = mp->
next;
272 static int __init ms02nv_init(
void)
279 switch (mips_machtype) {
296 for (i = 0; i <
ARRAY_SIZE(ms02nv_addrs); i++)
297 if (!ms02nv_init_one(ms02nv_addrs[i] << stride))
300 return (count > 0) ? 0 : -
ENODEV;
303 static void __exit ms02nv_cleanup(
void)
305 while (root_ms02nv_mtd)