+
+#ifdef CONFIG_CFI_FLASH /* for driver model */
+static int cfi_flash_probe(struct udevice *dev)
+{
+ const fdt32_t *cell;
+ int addrc, sizec;
+ int len, idx;
+
+ addrc = dev_read_addr_cells(dev);
+ sizec = dev_read_size_cells(dev);
+
+ /* decode regs; there may be multiple reg tuples. */
+ cell = dev_read_prop(dev, "reg", &len);
+ if (!cell)
+ return -ENOENT;
+ idx = 0;
+ len /= sizeof(fdt32_t);
+ while (idx < len) {
+ phys_addr_t addr;
+
+ addr = dev_translate_address(dev, cell + idx);
+
+ flash_info[cfi_flash_num_flash_banks].dev = dev;
+ flash_info[cfi_flash_num_flash_banks].base = addr;
+ cfi_flash_num_flash_banks++;
+
+ idx += addrc + sizec;
+ }
+ gd->bd->bi_flashstart = flash_info[0].base;
+
+ return 0;
+}
+
+static const struct udevice_id cfi_flash_ids[] = {
+ { .compatible = "cfi-flash" },
+ { .compatible = "jedec-flash" },
+ {}
+};
+
+U_BOOT_DRIVER(cfi_flash) = {
+ .name = "cfi_flash",
+ .id = UCLASS_MTD,
+ .of_match = cfi_flash_ids,
+ .probe = cfi_flash_probe,
+};
+#endif /* CONFIG_CFI_FLASH */