Blame view
drivers/mtd/maps/impa7.c
2.85 KB
1da177e4c
|
1 |
/* |
1da177e4c
|
2 3 4 |
* Handle mapping of the NOR flash on implementa A7 boards * * Copyright 2002 SYSGO Real-Time Solutions GmbH |
69f34c98c
|
5 |
* |
1da177e4c
|
6 7 8 9 10 11 12 13 14 15 16 17 |
* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/init.h> #include <asm/io.h> #include <linux/mtd/mtd.h> #include <linux/mtd/map.h> |
1da177e4c
|
18 |
#include <linux/mtd/partitions.h> |
1da177e4c
|
19 20 21 22 23 24 25 |
#define WINDOW_ADDR0 0x00000000 /* physical properties of flash */ #define WINDOW_SIZE0 0x00800000 #define WINDOW_ADDR1 0x10000000 /* physical properties of flash */ #define WINDOW_SIZE1 0x00800000 #define NUM_FLASHBANKS 2 #define BUSWIDTH 4 |
1da177e4c
|
26 27 28 29 |
#define MSG_PREFIX "impA7:" /* prefix for our printk()'s */ #define MTDID "impa7-%d" /* for mtdparts= partitioning */ static struct mtd_info *impa7_mtd[NUM_FLASHBANKS]; |
0984c8910
|
30 |
static const char * const rom_probe_types[] = { "jedec_probe", NULL }; |
1da177e4c
|
31 32 33 34 35 36 37 38 39 40 41 42 43 |
static struct map_info impa7_map[NUM_FLASHBANKS] = { { .name = "impA7 NOR Flash Bank #0", .size = WINDOW_SIZE0, .bankwidth = BUSWIDTH, }, { .name = "impA7 NOR Flash Bank #1", .size = WINDOW_SIZE1, .bankwidth = BUSWIDTH, }, }; |
1da177e4c
|
44 |
/* |
69f34c98c
|
45 |
* MTD partitioning stuff |
1da177e4c
|
46 |
*/ |
5003403b8
|
47 |
static struct mtd_partition partitions[] = |
1da177e4c
|
48 49 50 51 52 53 54 |
{ { .name = "FileSystem", .size = 0x800000, .offset = 0x00000000 }, }; |
4f8f3af20
|
55 |
static int __init init_impa7(void) |
1da177e4c
|
56 |
{ |
0984c8910
|
57 |
const char * const *type; |
1da177e4c
|
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
int i; static struct { u_long addr; u_long size; } pt[NUM_FLASHBANKS] = { { WINDOW_ADDR0, WINDOW_SIZE0 }, { WINDOW_ADDR1, WINDOW_SIZE1 }, }; int devicesfound = 0; for(i=0; i<NUM_FLASHBANKS; i++) { printk(KERN_NOTICE MSG_PREFIX "probing 0x%08lx at 0x%08lx ", pt[i].size, pt[i].addr); impa7_map[i].phys = pt[i].addr; impa7_map[i].virt = ioremap(pt[i].addr, pt[i].size); if (!impa7_map[i].virt) { printk(MSG_PREFIX "failed to ioremap "); return -EIO; } simple_map_init(&impa7_map[i]); |
d1d90c992
|
79 |
impa7_mtd[i] = NULL; |
1da177e4c
|
80 81 82 83 84 85 86 87 |
type = rom_probe_types; for(; !impa7_mtd[i] && *type; type++) { impa7_mtd[i] = do_map_probe(*type, &impa7_map[i]); } if (impa7_mtd[i]) { impa7_mtd[i]->owner = THIS_MODULE; devicesfound++; |
42d7fbe22
|
88 |
mtd_device_parse_register(impa7_mtd[i], NULL, NULL, |
5003403b8
|
89 90 |
partitions, ARRAY_SIZE(partitions)); |
d1d90c992
|
91 92 |
} else { iounmap((void __iomem *)impa7_map[i].virt); |
1da177e4c
|
93 |
} |
1da177e4c
|
94 95 96 97 98 99 100 101 102 |
} return devicesfound == 0 ? -ENXIO : 0; } static void __exit cleanup_impa7(void) { int i; for (i=0; i<NUM_FLASHBANKS; i++) { if (impa7_mtd[i]) { |
96b639fd5
|
103 |
mtd_device_unregister(impa7_mtd[i]); |
1da177e4c
|
104 |
map_destroy(impa7_mtd[i]); |
d1d90c992
|
105 106 |
iounmap((void __iomem *)impa7_map[i].virt); impa7_map[i].virt = NULL; |
1da177e4c
|
107 108 109 110 111 112 113 114 115 116 |
} } } module_init(init_impa7); module_exit(cleanup_impa7); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Pavel Bartusek <pba@sysgo.de>"); MODULE_DESCRIPTION("MTD map driver for implementa impA7"); |