diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/mtd/maps/omap-toto-flash.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/mtd/maps/omap-toto-flash.c')
-rw-r--r-- | drivers/mtd/maps/omap-toto-flash.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/drivers/mtd/maps/omap-toto-flash.c b/drivers/mtd/maps/omap-toto-flash.c new file mode 100644 index 000000000000..496109071cb1 --- /dev/null +++ b/drivers/mtd/maps/omap-toto-flash.c | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | * NOR Flash memory access on TI Toto board | ||
3 | * | ||
4 | * jzhang@ti.com (C) 2003 Texas Instruments. | ||
5 | * | ||
6 | * (C) 2002 MontVista Software, Inc. | ||
7 | * | ||
8 | * $Id: omap-toto-flash.c,v 1.3 2004/09/16 23:27:13 gleixner Exp $ | ||
9 | */ | ||
10 | |||
11 | #include <linux/config.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/types.h> | ||
14 | #include <linux/kernel.h> | ||
15 | |||
16 | #include <linux/errno.h> | ||
17 | #include <linux/init.h> | ||
18 | |||
19 | #include <linux/mtd/mtd.h> | ||
20 | #include <linux/mtd/map.h> | ||
21 | #include <linux/mtd/partitions.h> | ||
22 | |||
23 | #include <asm/hardware.h> | ||
24 | #include <asm/io.h> | ||
25 | |||
26 | |||
27 | #ifndef CONFIG_ARCH_OMAP | ||
28 | #error This is for OMAP architecture only | ||
29 | #endif | ||
30 | |||
31 | //these lines need be moved to a hardware header file | ||
32 | #define OMAP_TOTO_FLASH_BASE 0xd8000000 | ||
33 | #define OMAP_TOTO_FLASH_SIZE 0x80000 | ||
34 | |||
35 | static struct map_info omap_toto_map_flash = { | ||
36 | .name = "OMAP Toto flash", | ||
37 | .bankwidth = 2, | ||
38 | .virt = (void __iomem *)OMAP_TOTO_FLASH_BASE, | ||
39 | }; | ||
40 | |||
41 | |||
42 | static struct mtd_partition toto_flash_partitions[] = { | ||
43 | { | ||
44 | .name = "BootLoader", | ||
45 | .size = 0x00040000, /* hopefully u-boot will stay 128k + 128*/ | ||
46 | .offset = 0, | ||
47 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
48 | }, { | ||
49 | .name = "ReservedSpace", | ||
50 | .size = 0x00030000, | ||
51 | .offset = MTDPART_OFS_APPEND, | ||
52 | //mask_flags: MTD_WRITEABLE, /* force read-only */ | ||
53 | }, { | ||
54 | .name = "EnvArea", /* bottom 64KiB for env vars */ | ||
55 | .size = MTDPART_SIZ_FULL, | ||
56 | .offset = MTDPART_OFS_APPEND, | ||
57 | } | ||
58 | }; | ||
59 | |||
60 | static struct mtd_partition *parsed_parts; | ||
61 | |||
62 | static struct mtd_info *flash_mtd; | ||
63 | |||
64 | static int __init init_flash (void) | ||
65 | { | ||
66 | |||
67 | struct mtd_partition *parts; | ||
68 | int nb_parts = 0; | ||
69 | int parsed_nr_parts = 0; | ||
70 | const char *part_type; | ||
71 | |||
72 | /* | ||
73 | * Static partition definition selection | ||
74 | */ | ||
75 | part_type = "static"; | ||
76 | |||
77 | parts = toto_flash_partitions; | ||
78 | nb_parts = ARRAY_SIZE(toto_flash_partitions); | ||
79 | omap_toto_map_flash.size = OMAP_TOTO_FLASH_SIZE; | ||
80 | omap_toto_map_flash.phys = virt_to_phys(OMAP_TOTO_FLASH_BASE); | ||
81 | |||
82 | simple_map_init(&omap_toto_map_flash); | ||
83 | /* | ||
84 | * Now let's probe for the actual flash. Do it here since | ||
85 | * specific machine settings might have been set above. | ||
86 | */ | ||
87 | printk(KERN_NOTICE "OMAP toto flash: probing %d-bit flash bus\n", | ||
88 | omap_toto_map_flash.bankwidth*8); | ||
89 | flash_mtd = do_map_probe("jedec_probe", &omap_toto_map_flash); | ||
90 | if (!flash_mtd) | ||
91 | return -ENXIO; | ||
92 | |||
93 | if (parsed_nr_parts > 0) { | ||
94 | parts = parsed_parts; | ||
95 | nb_parts = parsed_nr_parts; | ||
96 | } | ||
97 | |||
98 | if (nb_parts == 0) { | ||
99 | printk(KERN_NOTICE "OMAP toto flash: no partition info available," | ||
100 | "registering whole flash at once\n"); | ||
101 | if (add_mtd_device(flash_mtd)){ | ||
102 | return -ENXIO; | ||
103 | } | ||
104 | } else { | ||
105 | printk(KERN_NOTICE "Using %s partition definition\n", | ||
106 | part_type); | ||
107 | return add_mtd_partitions(flash_mtd, parts, nb_parts); | ||
108 | } | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | int __init omap_toto_mtd_init(void) | ||
113 | { | ||
114 | int status; | ||
115 | |||
116 | if (status = init_flash()) { | ||
117 | printk(KERN_ERR "OMAP Toto Flash: unable to init map for toto flash\n"); | ||
118 | } | ||
119 | return status; | ||
120 | } | ||
121 | |||
122 | static void __exit omap_toto_mtd_cleanup(void) | ||
123 | { | ||
124 | if (flash_mtd) { | ||
125 | del_mtd_partitions(flash_mtd); | ||
126 | map_destroy(flash_mtd); | ||
127 | if (parsed_parts) | ||
128 | kfree(parsed_parts); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | module_init(omap_toto_mtd_init); | ||
133 | module_exit(omap_toto_mtd_cleanup); | ||
134 | |||
135 | MODULE_AUTHOR("Jian Zhang"); | ||
136 | MODULE_DESCRIPTION("OMAP Toto board map driver"); | ||
137 | MODULE_LICENSE("GPL"); | ||