16 #include <linux/module.h>
17 #include <linux/types.h>
19 #include <linux/device.h>
27 #include <linux/slab.h>
51 if (info->
cmtd != info->
list[0].mtd) {
60 if (info->
list[i].mtd)
63 if (info->
list[i].map.virt)
66 if (info->
list[i].res) {
86 static const char *rom_probe_types[]
87 = {
"cfi_probe",
"jedec_probe",
"map_rom"};
90 dev_warn(&dev->
dev,
"Device tree uses obsolete \"direct-mapped\" "
95 for (i = 0; i <
ARRAY_SIZE(rom_probe_types); i++) {
101 }
else if (
strcmp(of_probe,
"CFI") == 0) {
103 }
else if (
strcmp(of_probe,
"JEDEC") == 0) {
106 if (
strcmp(of_probe,
"ROM") != 0)
107 dev_warn(&dev->
dev,
"obsolete_probe: don't know probe "
108 "type '%s', mapping as rom\n", of_probe);
117 static const char *part_probe_types_def[] = {
"cmdlinepart",
"RedBoot",
118 "ofpart",
"ofoldpart",
NULL };
129 return part_probe_types_def;
132 for (l = 0; l != cplen; l++)
136 res = kzalloc((count + 1)*
sizeof(*res),
GFP_KERNEL);
148 static void __devinit of_free_probes(
const char **probes)
150 if (probes != part_probe_types_def)
157 const char **part_probe_types;
162 const char *probe_type;
177 probe_type = match->
data;
188 if (count % reg_tuple_size != 0) {
189 dev_err(&dev->
dev,
"Malformed reg property on %s\n",
190 dev->
dev.of_node->full_name);
192 goto err_flash_remove;
194 count /= reg_tuple_size;
196 map_indirect = of_property_read_bool(dp,
"no-unaligned-direct-access");
199 info = kzalloc(
sizeof(
struct of_flash) +
202 goto err_flash_remove;
206 mtd_list = kzalloc(
sizeof(*mtd_list) * count,
GFP_KERNEL);
208 goto err_flash_remove;
210 for (i = 0; i <
count; i++) {
220 dev_dbg(&dev->
dev,
"of_flash device: %pR\n", &res);
223 res_size = resource_size(&res);
225 dev_name(&dev->
dev));
226 if (!info->
list[i].res)
232 dev_err(&dev->
dev,
"Can't get bank width from device"
237 info->
list[
i].map.name = dev_name(&dev->
dev);
238 info->
list[
i].map.phys = res.start;
244 info->
list[i].map.size);
245 if (!info->
list[i].map.virt) {
246 dev_err(&dev->
dev,
"Failed to ioremap() flash"
268 info->
list[
i].mtd = obsolete_probe(dev,
271 mtd_list[
i] = info->
list[
i].mtd;
274 if (!info->
list[i].mtd) {
275 dev_err(&dev->
dev,
"do_map_probe() failed\n");
281 info->
list[
i].mtd->dev.parent = &dev->
dev;
292 dev_name(&dev->
dev));
300 part_probe_types = of_get_probes(dp);
303 of_free_probes(part_probe_types);
312 of_flash_remove(dev);
319 .compatible =
"cfi-flash",
320 .data = (
void *)
"cfi_probe",
330 .compatible =
"jedec-flash",
331 .data = (
void *)
"jedec_probe",
334 .compatible =
"mtd-ram",
335 .data = (
void *)
"map_ram",
339 .compatible =
"direct-mapped"
349 .of_match_table = of_flash_match,
351 .probe = of_flash_probe,
352 .remove = of_flash_remove,