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>
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>
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
[] = {
37 .size
= MTDPART_SIZ_FULL
,
38 .offset
= MTDPART_OFS_APPEND
,
42 static struct mtd_partition bigflash_parts
[] = {
48 .name
= "file system",
50 .offset
= MTDPART_OFS_APPEND
,
52 .name
= "boot config",
54 .offset
= MTDPART_OFS_APPEND
,
58 .offset
= MTDPART_OFS_APPEND
,
62 static const char *part_probes
[] __initdata
= {"cmdlinepart", "RedBoot", NULL
};
64 #define init_sbc82xx_one_flash(map, br, or) \
66 (map).phys = (br & 1) ? (br & 0xffff8000) : 0; \
67 (map).size = (br & 1) ? (~(or & 0xffff8000) + 1) : 0; \
68 switch (br & 0x00001800) { \
70 case 0x00000800: (map).bankwidth = 1; break; \
71 case 0x00001000: (map).bankwidth = 2; break; \
72 case 0x00001800: (map).bankwidth = 4; break; \
76 static int __init
init_sbc82xx_flash(void)
78 volatile memctl_cpm2_t
*mc
= &cpm2_immr
->im_memctl
;
83 mc
= ioremap(0xff700000 + 0x5000, sizeof(memctl_cpm2_t
));
85 mc
= &cpm2_immr
->im_memctl
;
89 if ((mc
->memc_br0
& 0x00001800) == 0x00001800)
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
);
100 for (i
=0; i
<3; i
++) {
101 int8_t flashcs
[3] = { 0, 6, 1 };
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),
109 if (!sbc82xx_flash_map
[i
].phys
) {
110 /* We know it can't be at zero. */
111 printk("): disabled by bootloader.\n");
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");
124 simple_map_init(&sbc82xx_flash_map
[i
]);
126 sbcmtd
[i
] = do_map_probe("cfi_probe", &sbc82xx_flash_map
[i
]);
131 sbcmtd
[i
]->owner
= THIS_MODULE
;
133 /* No partitioning detected. Use default */
137 } else if (i
== bigflash
) {
138 defparts
= bigflash_parts
;
139 nr_parts
= ARRAY_SIZE(bigflash_parts
);
141 defparts
= smallflash_parts
;
142 nr_parts
= ARRAY_SIZE(smallflash_parts
);
145 mtd_device_parse_register(sbcmtd
[i
], part_probes
, 0,
151 static void __exit
cleanup_sbc82xx_flash(void)
155 for (i
=0; i
<3; i
++) {
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");