USB: usb-storage: unusual_devs update for Super TOP SATA bridge
[linux/fpc-iii.git] / drivers / mtd / maps / wr_sbc82xx_flash.c
blob71b0ba7979121f8cde4480751f547d42d8fa858b
1 /*
2 * Map for flash chips on Wind River PowerQUICC II SBC82xx board.
4 * Copyright (C) 2004 Red Hat, Inc.
6 * Author: David Woodhouse <dwmw2@infradead.org>
8 */
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/slab.h>
15 #include <asm/io.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/partitions.h>
20 #include <asm/immap_cpm2.h>
22 static struct mtd_info *sbcmtd[3];
24 struct map_info sbc82xx_flash_map[3] = {
25 {.name = "Boot flash"},
26 {.name = "Alternate boot flash"},
27 {.name = "User flash"}
30 static struct mtd_partition smallflash_parts[] = {
32 .name = "space",
33 .size = 0x100000,
34 .offset = 0,
35 }, {
36 .name = "bootloader",
37 .size = MTDPART_SIZ_FULL,
38 .offset = MTDPART_OFS_APPEND,
42 static struct mtd_partition bigflash_parts[] = {
44 .name = "bootloader",
45 .size = 0x00100000,
46 .offset = 0,
47 }, {
48 .name = "file system",
49 .size = 0x01f00000,
50 .offset = MTDPART_OFS_APPEND,
51 }, {
52 .name = "boot config",
53 .size = 0x00100000,
54 .offset = MTDPART_OFS_APPEND,
55 }, {
56 .name = "space",
57 .size = 0x01f00000,
58 .offset = MTDPART_OFS_APPEND,
62 static const char *part_probes[] __initdata = {"cmdlinepart", "RedBoot", NULL};
64 #define init_sbc82xx_one_flash(map, br, or) \
65 do { \
66 (map).phys = (br & 1) ? (br & 0xffff8000) : 0; \
67 (map).size = (br & 1) ? (~(or & 0xffff8000) + 1) : 0; \
68 switch (br & 0x00001800) { \
69 case 0x00000000: \
70 case 0x00000800: (map).bankwidth = 1; break; \
71 case 0x00001000: (map).bankwidth = 2; break; \
72 case 0x00001800: (map).bankwidth = 4; break; \
73 } \
74 } while (0);
76 static int __init init_sbc82xx_flash(void)
78 volatile memctl_cpm2_t *mc = &cpm2_immr->im_memctl;
79 int bigflash;
80 int i;
82 #ifdef CONFIG_SBC8560
83 mc = ioremap(0xff700000 + 0x5000, sizeof(memctl_cpm2_t));
84 #else
85 mc = &cpm2_immr->im_memctl;
86 #endif
88 bigflash = 1;
89 if ((mc->memc_br0 & 0x00001800) == 0x00001800)
90 bigflash = 0;
92 init_sbc82xx_one_flash(sbc82xx_flash_map[0], mc->memc_br0, mc->memc_or0);
93 init_sbc82xx_one_flash(sbc82xx_flash_map[1], mc->memc_br6, mc->memc_or6);
94 init_sbc82xx_one_flash(sbc82xx_flash_map[2], mc->memc_br1, mc->memc_or1);
96 #ifdef CONFIG_SBC8560
97 iounmap((void *) mc);
98 #endif
100 for (i=0; i<3; i++) {
101 int8_t flashcs[3] = { 0, 6, 1 };
102 int nr_parts;
103 struct mtd_partition *defparts;
105 printk(KERN_NOTICE "PowerQUICC II %s (%ld MiB on CS%d",
106 sbc82xx_flash_map[i].name,
107 (sbc82xx_flash_map[i].size >> 20),
108 flashcs[i]);
109 if (!sbc82xx_flash_map[i].phys) {
110 /* We know it can't be at zero. */
111 printk("): disabled by bootloader.\n");
112 continue;
114 printk(" at %08lx)\n", sbc82xx_flash_map[i].phys);
116 sbc82xx_flash_map[i].virt = ioremap(sbc82xx_flash_map[i].phys,
117 sbc82xx_flash_map[i].size);
119 if (!sbc82xx_flash_map[i].virt) {
120 printk("Failed to ioremap\n");
121 continue;
124 simple_map_init(&sbc82xx_flash_map[i]);
126 sbcmtd[i] = do_map_probe("cfi_probe", &sbc82xx_flash_map[i]);
128 if (!sbcmtd[i])
129 continue;
131 sbcmtd[i]->owner = THIS_MODULE;
133 /* No partitioning detected. Use default */
134 if (i == 2) {
135 defparts = NULL;
136 nr_parts = 0;
137 } else if (i == bigflash) {
138 defparts = bigflash_parts;
139 nr_parts = ARRAY_SIZE(bigflash_parts);
140 } else {
141 defparts = smallflash_parts;
142 nr_parts = ARRAY_SIZE(smallflash_parts);
145 mtd_device_parse_register(sbcmtd[i], part_probes, NULL,
146 defparts, nr_parts);
148 return 0;
151 static void __exit cleanup_sbc82xx_flash(void)
153 int i;
155 for (i=0; i<3; i++) {
156 if (!sbcmtd[i])
157 continue;
159 mtd_device_unregister(sbcmtd[i]);
161 map_destroy(sbcmtd[i]);
163 iounmap((void *)sbc82xx_flash_map[i].virt);
164 sbc82xx_flash_map[i].virt = 0;
168 module_init(init_sbc82xx_flash);
169 module_exit(cleanup_sbc82xx_flash);
172 MODULE_LICENSE("GPL");
173 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
174 MODULE_DESCRIPTION("Flash map driver for WindRiver PowerQUICC II");