2 * $Id: solutionengine.c,v 1.15 2005/11/07 11:14:28 gleixner Exp $
4 * Flash and EPROM on Hitachi Solution Engine and similar boards.
6 * (C) 2001 Red Hat, Inc.
11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/config.h>
20 #include <linux/errno.h>
22 static struct mtd_info
*flash_mtd
;
23 static struct mtd_info
*eprom_mtd
;
25 static struct mtd_partition
*parsed_parts
;
27 struct map_info soleng_eprom_map
= {
28 .name
= "Solution Engine EPROM",
33 struct map_info soleng_flash_map
= {
34 .name
= "Solution Engine FLASH",
39 static const char *probes
[] = { "RedBoot", "cmdlinepart", NULL
};
41 #ifdef CONFIG_MTD_SUPERH_RESERVE
42 static struct mtd_partition superh_se_partitions
[] = {
43 /* Reserved for boot code, read-only */
47 .size
= CONFIG_MTD_SUPERH_RESERVE
,
48 .mask_flags
= MTD_WRITEABLE
,
50 /* All else is writable (e.g. JFFS) */
53 .offset
= MTDPART_OFS_NXTBLK
,
54 .size
= MTDPART_SIZ_FULL
,
57 #endif /* CONFIG_MTD_SUPERH_RESERVE */
59 static int __init
init_soleng_maps(void)
63 /* First probe at offset 0 */
64 soleng_flash_map
.phys
= 0;
65 soleng_flash_map
.virt
= (void __iomem
*)P2SEGADDR(0);
66 soleng_eprom_map
.phys
= 0x01000000;
67 soleng_eprom_map
.virt
= (void __iomem
*)P1SEGADDR(0x01000000);
68 simple_map_init(&soleng_eprom_map
);
69 simple_map_init(&soleng_flash_map
);
71 printk(KERN_NOTICE
"Probing for flash chips at 0x00000000:\n");
72 flash_mtd
= do_map_probe("cfi_probe", &soleng_flash_map
);
74 /* Not there. Try swapping */
75 printk(KERN_NOTICE
"Probing for flash chips at 0x01000000:\n");
76 soleng_flash_map
.phys
= 0x01000000;
77 soleng_flash_map
.virt
= P2SEGADDR(0x01000000);
78 soleng_eprom_map
.phys
= 0;
79 soleng_eprom_map
.virt
= P1SEGADDR(0);
80 flash_mtd
= do_map_probe("cfi_probe", &soleng_flash_map
);
83 printk(KERN_NOTICE
"Flash chips not detected at either possible location.\n");
87 printk(KERN_NOTICE
"Solution Engine: Flash at 0x%08lx, EPROM at 0x%08lx\n",
88 soleng_flash_map
.phys
& 0x1fffffff,
89 soleng_eprom_map
.phys
& 0x1fffffff);
90 flash_mtd
->owner
= THIS_MODULE
;
92 eprom_mtd
= do_map_probe("map_rom", &soleng_eprom_map
);
94 eprom_mtd
->owner
= THIS_MODULE
;
95 add_mtd_device(eprom_mtd
);
98 nr_parts
= parse_mtd_partitions(flash_mtd
, probes
, &parsed_parts
, 0);
100 #ifdef CONFIG_MTD_SUPERH_RESERVE
102 printk(KERN_NOTICE
"Using configured partition at 0x%08x.\n",
103 CONFIG_MTD_SUPERH_RESERVE
);
104 parsed_parts
= superh_se_partitions
;
105 nr_parts
= sizeof(superh_se_partitions
)/sizeof(*parsed_parts
);
107 #endif /* CONFIG_MTD_SUPERH_RESERVE */
110 add_mtd_partitions(flash_mtd
, parsed_parts
, nr_parts
);
112 add_mtd_device(flash_mtd
);
117 static void __exit
cleanup_soleng_maps(void)
120 del_mtd_device(eprom_mtd
);
121 map_destroy(eprom_mtd
);
125 del_mtd_partitions(flash_mtd
);
127 del_mtd_device(flash_mtd
);
128 map_destroy(flash_mtd
);
131 module_init(init_soleng_maps
);
132 module_exit(cleanup_soleng_maps
);
134 MODULE_LICENSE("GPL");
135 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
136 MODULE_DESCRIPTION("MTD map driver for Hitachi SolutionEngine (and similar) boards");