0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/module.h>
0013 #include <linux/types.h>
0014 #include <linux/kernel.h>
0015 #include <linux/init.h>
0016 #include <asm/io.h>
0017 #include <linux/mtd/mtd.h>
0018 #include <linux/mtd/map.h>
0019 #include <linux/mtd/partitions.h>
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 static const struct mtd_partition partition_info[] = {
0043 {
0044 .name = "NetSc520 boot kernel",
0045 .offset = 0,
0046 .size = 0xc0000
0047 },
0048 {
0049 .name = "NetSc520 Low BIOS",
0050 .offset = 0xc0000,
0051 .size = 0x40000
0052 },
0053 {
0054 .name = "NetSc520 file system",
0055 .offset = 0x100000,
0056 .size = 0xe80000
0057 },
0058 {
0059 .name = "NetSc520 High BIOS",
0060 .offset = 0xf80000,
0061 .size = 0x80000
0062 },
0063 };
0064 #define NUM_PARTITIONS ARRAY_SIZE(partition_info)
0065
0066 #define WINDOW_SIZE 0x00100000
0067 #define WINDOW_ADDR 0x00200000
0068
0069 static struct map_info netsc520_map = {
0070 .name = "netsc520 Flash Bank",
0071 .size = WINDOW_SIZE,
0072 .bankwidth = 4,
0073 .phys = WINDOW_ADDR,
0074 };
0075
0076 #define NUM_FLASH_BANKS ARRAY_SIZE(netsc520_map)
0077
0078 static struct mtd_info *mymtd;
0079
0080 static int __init init_netsc520(void)
0081 {
0082 printk(KERN_NOTICE "NetSc520 flash device: 0x%Lx at 0x%Lx\n",
0083 (unsigned long long)netsc520_map.size,
0084 (unsigned long long)netsc520_map.phys);
0085 netsc520_map.virt = ioremap(netsc520_map.phys, netsc520_map.size);
0086
0087 if (!netsc520_map.virt) {
0088 printk("Failed to ioremap\n");
0089 return -EIO;
0090 }
0091
0092 simple_map_init(&netsc520_map);
0093
0094 mymtd = do_map_probe("cfi_probe", &netsc520_map);
0095 if(!mymtd)
0096 mymtd = do_map_probe("map_ram", &netsc520_map);
0097 if(!mymtd)
0098 mymtd = do_map_probe("map_rom", &netsc520_map);
0099
0100 if (!mymtd) {
0101 iounmap(netsc520_map.virt);
0102 return -ENXIO;
0103 }
0104
0105 mymtd->owner = THIS_MODULE;
0106 mtd_device_register(mymtd, partition_info, NUM_PARTITIONS);
0107 return 0;
0108 }
0109
0110 static void __exit cleanup_netsc520(void)
0111 {
0112 if (mymtd) {
0113 mtd_device_unregister(mymtd);
0114 map_destroy(mymtd);
0115 }
0116 if (netsc520_map.virt) {
0117 iounmap(netsc520_map.virt);
0118 netsc520_map.virt = NULL;
0119 }
0120 }
0121
0122 module_init(init_netsc520);
0123 module_exit(cleanup_netsc520);
0124
0125 MODULE_LICENSE("GPL");
0126 MODULE_AUTHOR("Mark Langsdorf <mark.langsdorf@amd.com>");
0127 MODULE_DESCRIPTION("MTD map driver for AMD NetSc520 Demonstration Board");