Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Flash and EPROM on Hitachi Solution Engine and similar boards.
0003  *
0004  * (C) 2001 Red Hat, Inc.
0005  *
0006  * GPL'd
0007  */
0008 
0009 #include <linux/module.h>
0010 #include <linux/types.h>
0011 #include <linux/kernel.h>
0012 #include <linux/init.h>
0013 #include <asm/io.h>
0014 #include <linux/mtd/mtd.h>
0015 #include <linux/mtd/map.h>
0016 #include <linux/mtd/partitions.h>
0017 #include <linux/errno.h>
0018 
0019 static struct mtd_info *flash_mtd;
0020 static struct mtd_info *eprom_mtd;
0021 
0022 struct map_info soleng_eprom_map = {
0023     .name = "Solution Engine EPROM",
0024     .size = 0x400000,
0025     .bankwidth = 4,
0026 };
0027 
0028 struct map_info soleng_flash_map = {
0029     .name = "Solution Engine FLASH",
0030     .size = 0x400000,
0031     .bankwidth = 4,
0032 };
0033 
0034 static const char * const probes[] = { "RedBoot", "cmdlinepart", NULL };
0035 
0036 static int __init init_soleng_maps(void)
0037 {
0038     /* First probe at offset 0 */
0039     soleng_flash_map.phys = 0;
0040     soleng_flash_map.virt = (void __iomem *)P2SEGADDR(0);
0041     soleng_eprom_map.phys = 0x01000000;
0042     soleng_eprom_map.virt = (void __iomem *)P1SEGADDR(0x01000000);
0043     simple_map_init(&soleng_eprom_map);
0044     simple_map_init(&soleng_flash_map);
0045 
0046     printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
0047     flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
0048     if (!flash_mtd) {
0049         /* Not there. Try swapping */
0050         printk(KERN_NOTICE "Probing for flash chips at 0x01000000:\n");
0051         soleng_flash_map.phys = 0x01000000;
0052         soleng_flash_map.virt = P2SEGADDR(0x01000000);
0053         soleng_eprom_map.phys = 0;
0054         soleng_eprom_map.virt = P1SEGADDR(0);
0055         flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
0056         if (!flash_mtd) {
0057             /* Eep. */
0058             printk(KERN_NOTICE "Flash chips not detected at either possible location.\n");
0059             return -ENXIO;
0060         }
0061     }
0062     printk(KERN_NOTICE "Solution Engine: Flash at 0x%pap, EPROM at 0x%pap\n",
0063            &soleng_flash_map.phys,
0064            &soleng_eprom_map.phys);
0065     flash_mtd->owner = THIS_MODULE;
0066 
0067     eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map);
0068     if (eprom_mtd) {
0069         eprom_mtd->owner = THIS_MODULE;
0070         mtd_device_register(eprom_mtd, NULL, 0);
0071     }
0072 
0073     mtd_device_parse_register(flash_mtd, probes, NULL, NULL, 0);
0074 
0075     return 0;
0076 }
0077 
0078 static void __exit cleanup_soleng_maps(void)
0079 {
0080     if (eprom_mtd) {
0081         mtd_device_unregister(eprom_mtd);
0082         map_destroy(eprom_mtd);
0083     }
0084 
0085     mtd_device_unregister(flash_mtd);
0086     map_destroy(flash_mtd);
0087 }
0088 
0089 module_init(init_soleng_maps);
0090 module_exit(cleanup_soleng_maps);
0091 
0092 MODULE_LICENSE("GPL");
0093 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
0094 MODULE_DESCRIPTION("MTD map driver for Hitachi SolutionEngine (and similar) boards");
0095