static int __init init_soleng_maps(void) { int nr_parts = 0; /* First probe at offset 0 */ soleng_flash_map.phys = 0; soleng_flash_map.virt = (void __iomem *)P2SEGADDR(0); soleng_eprom_map.phys = 0x01000000; soleng_eprom_map.virt = (void __iomem *)P1SEGADDR(0x01000000); simple_map_init(&soleng_eprom_map); simple_map_init(&soleng_flash_map); printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n"); flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map); if (!flash_mtd) { /* Not there. Try swapping */ printk(KERN_NOTICE "Probing for flash chips at 0x01000000:\n"); soleng_flash_map.phys = 0x01000000; soleng_flash_map.virt = P2SEGADDR(0x01000000); soleng_eprom_map.phys = 0; soleng_eprom_map.virt = P1SEGADDR(0); flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map); if (!flash_mtd) { /* Eep. */ printk(KERN_NOTICE "Flash chips not detected at either possible location.\n"); return -ENXIO; } } printk(KERN_NOTICE "Solution Engine: Flash at 0x%08lx, EPROM at 0x%08lx\n", soleng_flash_map.phys & 0x1fffffff, soleng_eprom_map.phys & 0x1fffffff); flash_mtd->owner = THIS_MODULE; eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map); if (eprom_mtd) { eprom_mtd->owner = THIS_MODULE; add_mtd_device(eprom_mtd); } nr_parts = parse_mtd_partitions(flash_mtd, probes, &parsed_parts, 0); #ifdef CONFIG_MTD_SUPERH_RESERVE if (nr_parts <= 0) { printk(KERN_NOTICE "Using configured partition at 0x%08x.\n", CONFIG_MTD_SUPERH_RESERVE); parsed_parts = superh_se_partitions; nr_parts = sizeof(superh_se_partitions)/sizeof(*parsed_parts); } #endif /* CONFIG_MTD_SUPERH_RESERVE */ if (nr_parts > 0) add_mtd_partitions(flash_mtd, parsed_parts, nr_parts); else add_mtd_device(flash_mtd); return 0; }
/* * Initialize FLASH support */ static int __init h720x_mtd_init(void) { char *part_type = NULL; h720x_map.virt = ioremap(h720x_map.phys, h720x_map.size); if (!h720x_map.virt) { printk(KERN_ERR "H720x-MTD: ioremap failed\n"); return -EIO; } simple_map_init(&h720x_map); // Probe for flash bankwidth 4 printk (KERN_INFO "H720x-MTD probing 32bit FLASH\n"); mymtd = do_map_probe("cfi_probe", &h720x_map); if (!mymtd) { printk (KERN_INFO "H720x-MTD probing 16bit FLASH\n"); // Probe for bankwidth 2 h720x_map.bankwidth = 2; mymtd = do_map_probe("cfi_probe", &h720x_map); } if (mymtd) { mymtd->owner = THIS_MODULE; <<<<<<< HEAD nr_mtd_parts = parse_mtd_partitions(mymtd, probes, &mtd_parts, 0); if (nr_mtd_parts > 0) part_type = "command line"; =======
static int __init init_beech_mtd(void) { int err; printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); beech_mtd_map.virt = ioremap(PADDR, SIZE); if (!beech_mtd_map.virt) { printk("%s: failed to ioremap 0x%x\n", NAME, PADDR); return -EIO; } simple_map_init(&beech_mtd_map); printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); beech_mtd = do_map_probe("cfi_probe", &beech_mtd_map); if (!beech_mtd) { iounmap(beech_mtd_map.virt); return -ENXIO; } beech_mtd->owner = THIS_MODULE; err = add_mtd_partitions(beech_mtd, beech_partitions, 2); if (err) { printk("%s: add_mtd_partitions failed\n", NAME); iounmap(beech_mtd_map.virt); } return err; }
static int __init init_dbox2_flash(void) { ; dbox2_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); if (!dbox2_flash_map.virt) { ; return -EIO; } simple_map_init(&dbox2_flash_map); // Probe for dual Intel 28F320 or dual AMD mymtd = do_map_probe("cfi_probe", &dbox2_flash_map); if (!mymtd) { // Probe for single Intel 28F640 dbox2_flash_map.bankwidth = 2; mymtd = do_map_probe("cfi_probe", &dbox2_flash_map); } if (mymtd) { mymtd->owner = THIS_MODULE; /* Create MTD devices for each partition. */ mtd_device_register(mymtd, partition_info, NUM_PARTITIONS); return 0; } iounmap((void *)dbox2_flash_map.virt); return -ENXIO; }
int __init init_flagadm(void) { printk(KERN_NOTICE "COBRA5272 flash device: %x at %x\n", FLASH_SIZE, FLASH_PHYS_ADDR); flagadm_map.phys = FLASH_PHYS_ADDR; flagadm_map.virt = ioremap(FLASH_PHYS_ADDR, FLASH_SIZE); if (!flagadm_map.virt) { printk("Failed to ioremap\n"); return -EIO; } simple_map_init(&flagadm_map); mymtd = do_map_probe("cfi_probe", &flagadm_map); if (mymtd) { mymtd->owner = THIS_MODULE; add_mtd_partitions(mymtd, flagadm_parts, PARTITION_COUNT); printk(KERN_NOTICE "COBRA5272 flash device initialized\n"); return 0; } iounmap((void *)flagadm_map.virt); return -ENXIO; }
static int __init init_opb_mtd(void) { map_bank.virt = ioremap(map_bank.phys, map_bank.size); if (!map_bank.virt) { printk("OPB Flash: failed to ioremap\n"); return -EIO; } simple_map_init(&map_bank); mtd_bank = do_map_probe("cfi_probe", &map_bank); if (!mtd_bank) { printk("OPB Flash: failed to find a mapping\n"); iounmap(map_bank.virt); map_bank.virt = 0; return -ENXIO; } mtd_bank->owner = THIS_MODULE; printk("Registering a %ldMB OPB Flash at 0x%lX\n", map_bank.size >> 20, map_bank.phys); add_mtd_device(mtd_bank); return 0; }
static int __init init_ts5500_map(void) { int rc = 0; ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size); if (!ts5500_map.virt) { printk(KERN_ERR "Failed to ioremap_nocache\n"); rc = -EIO; goto err2; } simple_map_init(&ts5500_map); mymtd = do_map_probe("jedec_probe", &ts5500_map); if (!mymtd) mymtd = do_map_probe("map_rom", &ts5500_map); if (!mymtd) { rc = -ENXIO; goto err1; } mymtd->owner = THIS_MODULE; add_mtd_partitions(mymtd, ts5500_partitions, NUM_PARTITIONS); return 0; err1: map_destroy(mymtd); iounmap(ts5500_map.virt); err2: return rc; }
static int __init init_netsc520(void) { printk(KERN_NOTICE "NetSc520 flash device: 0x%lx at 0x%lx\n", netsc520_map.size, netsc520_map.phys); netsc520_map.virt = (unsigned long)ioremap_nocache(netsc520_map.phys, netsc520_map.size); if (!netsc520_map.virt) { printk("Failed to ioremap_nocache\n"); return -EIO; } simple_map_init(&netsc520_map); mymtd = do_map_probe("cfi_probe", &netsc520_map); if(!mymtd) mymtd = do_map_probe("map_ram", &netsc520_map); if(!mymtd) mymtd = do_map_probe("map_rom", &netsc520_map); if (!mymtd) { iounmap((void *)netsc520_map.virt); return -ENXIO; } mymtd->owner = THIS_MODULE; add_mtd_partitions( mymtd, partition_info, NUM_PARTITIONS ); return 0; }
/** * Module/ driver initialization. * * Returns Zero on success */ static int __init flash_init(void) { /* * Read the bootbus region 0 setup to determine the base * address of the flash. */ union cvmx_mio_boot_reg_cfgx region_cfg; region_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(0)); if (region_cfg.s.en) { /* * The bootloader always takes the flash and sets its * address so the entire flash fits below * 0x1fc00000. This way the flash aliases to * 0x1fc00000 for booting. Software can access the * full flash at the true address, while core boot can * access 4MB. */ /* Use this name so old part lines work */ flash_map.name = "phys_mapped_flash"; flash_map.phys = region_cfg.s.base << 16; flash_map.size = 0x1fc00000 - flash_map.phys; flash_map.bankwidth = 1; flash_map.virt = ioremap(flash_map.phys, flash_map.size); pr_notice("Bootbus flash: Setting flash for %luMB flash at " "0x%08llx\n", flash_map.size >> 20, flash_map.phys); simple_map_init(&flash_map); mymtd = do_map_probe("cfi_probe", &flash_map); if (mymtd) { mymtd->owner = THIS_MODULE; mtd_device_parse_register(mymtd, part_probe_types, NULL, NULL, 0); } else { pr_err("Failed to register MTD device for flash\n"); } }
static int __init init_rpxlite(void) { #ifdef CONFIG_DEBUG_PRINTK printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR); #else ; #endif rpxlite_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4); if (!rpxlite_map.virt) { #ifdef CONFIG_DEBUG_PRINTK printk("Failed to ioremap\n"); #else ; #endif return -EIO; } simple_map_init(&rpxlite_map); mymtd = do_map_probe("cfi_probe", &rpxlite_map); if (mymtd) { mymtd->owner = THIS_MODULE; mtd_device_register(mymtd, NULL, 0); return 0; } iounmap((void *)rpxlite_map.virt); return -ENXIO; }
static int __init init_ts5500_map(void) { int rc = 0; ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size); if (!ts5500_map.virt) { ; rc = -EIO; goto err2; } simple_map_init(&ts5500_map); mymtd = do_map_probe("jedec_probe", &ts5500_map); if (!mymtd) mymtd = do_map_probe("map_rom", &ts5500_map); if (!mymtd) { rc = -ENXIO; goto err1; } mymtd->owner = THIS_MODULE; mtd_device_register(mymtd, ts5500_partitions, NUM_PARTITIONS); return 0; err1: iounmap(ts5500_map.virt); err2: return rc; }
int __init init_dbox2_flash(void) { printk(KERN_NOTICE "D-Box 2 flash driver (size->0x%X mem->0x%X)\n", WINDOW_SIZE, WINDOW_ADDR); dbox2_flash_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); if (!dbox2_flash_map.virt) { printk("Failed to ioremap\n"); return -EIO; } simple_map_init(&dbox2_flash_map); // Probe for dual Intel 28F320 or dual AMD mymtd = do_map_probe("cfi_probe", &dbox2_flash_map); if (!mymtd) { // Probe for single Intel 28F640 dbox2_flash_map.buswidth = 2; mymtd = do_map_probe("cfi_probe", &dbox2_flash_map); } if (mymtd) { mymtd->owner = THIS_MODULE; /* Create MTD devices for each partition. */ add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS); return 0; } iounmap((void *)dbox2_flash_map.virt); return -ENXIO; }
int __init pb1xxx_mtd_init(void) { struct mtd_partition *parts; int nb_parts = 0; char *part_type; /* * Static partition definition selection */ part_type = "static"; parts = pb1xxx_partitions; nb_parts = ARRAY_SIZE(pb1xxx_partitions); /* * Now let's probe for the actual flash. Do it here since * specific machine settings might have been set above. */ printk(KERN_NOTICE "Pb1xxx flash: probing %d-bit flash bus\n", BUSWIDTH*8); pb1xxx_mtd_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); simple_map_init(&pb1xxx_mtd_map); pb1xxx_mtd = do_map_probe("cfi_probe", &pb1xxx_mtd_map); if (!pb1xxx_mtd) return -ENXIO; pb1xxx_mtd->owner = THIS_MODULE; add_mtd_partitions(pb1xxx_mtd, parts, nb_parts); return 0; }
static int __init h720x_mtd_init(void) { h720x_map.virt = ioremap(h720x_map.phys, h720x_map.size); if (!h720x_map.virt) { printk(KERN_ERR "H720x-MTD: ioremap failed\n"); return -EIO; } simple_map_init(&h720x_map); // printk (KERN_INFO "H720x-MTD probing 32bit FLASH\n"); mymtd = do_map_probe("cfi_probe", &h720x_map); if (!mymtd) { printk (KERN_INFO "H720x-MTD probing 16bit FLASH\n"); // h720x_map.bankwidth = 2; mymtd = do_map_probe("cfi_probe", &h720x_map); } if (mymtd) { mymtd->owner = THIS_MODULE; mtd_device_parse_register(mymtd, NULL, NULL, h720x_partitions, NUM_PARTITIONS); return 0; } iounmap((void *)h720x_map.virt); return -ENXIO; }
int __init mtx1_mtd_init(void) { int ret = -ENXIO; simple_map_init(&mtx1_map); mtx1_map.virt = ioremap(mtx1_map.phys, mtx1_map.size); if (!mtx1_map.virt) return -EIO; mtx1_mtd = do_map_probe("cfi_probe", &mtx1_map); if (!mtx1_mtd) goto err; mtx1_mtd->owner = THIS_MODULE; ret = add_mtd_partitions(mtx1_mtd, mtx1_partitions, ARRAY_SIZE(mtx1_partitions)); if (ret) goto err; return 0; err: iounmap(mtx1_map.virt); return ret; }
static int __init init_str8100_mtd(void) { struct mtd_partition *parts; int nb_parts = 0; str8100_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); if (!str8100_map.virt) { printk("Failed to ioremap\n"); return -EIO; } simple_map_init(&str8100_map); mymtd = do_map_probe("cfi_probe", &str8100_map); if (!mymtd) { iounmap((void *)str8100_map.virt); return -ENXIO; } mymtd->owner = THIS_MODULE; add_mtd_device(mymtd); #ifdef CONFIG_MTD_PARTITIONS parts = str8100_partitions; nb_parts = ARRAY_SIZE(str8100_partitions); add_mtd_partitions(mymtd, parts, nb_parts); #endif return 0; }
static int __init init_redwood_flash(void) { int err; printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR); redwood_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); if (!redwood_flash_map.virt) { printk("init_redwood_flash: failed to ioremap\n"); return -EIO; } simple_map_init(&redwood_flash_map); redwood_mtd = do_map_probe("cfi_probe",&redwood_flash_map); if (redwood_mtd) { redwood_mtd->owner = THIS_MODULE; err = add_mtd_partitions(redwood_mtd, redwood_flash_partitions, NUM_REDWOOD_FLASH_PARTITIONS); if (err) { printk("init_redwood_flash: add_mtd_partitions failed\n"); iounmap(redwood_flash_map.virt); } return err; } iounmap(redwood_flash_map.virt); return -ENXIO; }
static int __init omapflash_probe(struct platform_device *pdev) { int err; struct omapflash_info *info; struct flash_platform_data *pdata = pdev->dev.platform_data; struct resource *res = pdev->resource; unsigned long size = res->end - res->start + 1; info = kzalloc(sizeof(struct omapflash_info), GFP_KERNEL); if (!info) return -ENOMEM; if (!request_mem_region(res->start, size, "flash")) { err = -EBUSY; goto out_free_info; } info->map.virt = ioremap(res->start, size); if (!info->map.virt) { err = -ENOMEM; goto out_release_mem_region; } info->map.name = pdev->dev.bus_id; info->map.phys = res->start; info->map.size = size; info->map.bankwidth = pdata->width; info->map.set_vpp = omap_set_vpp; simple_map_init(&info->map); info->mtd = do_map_probe(pdata->map_name, &info->map); if (!info->mtd) { err = -EIO; goto out_iounmap; } info->mtd->owner = THIS_MODULE; #ifdef CONFIG_MTD_PARTITIONS err = parse_mtd_partitions(info->mtd, part_probes, &info->parts, 0); if (err > 0) add_mtd_partitions(info->mtd, info->parts, err); else if (err <= 0 && pdata->parts) add_mtd_partitions(info->mtd, pdata->parts, pdata->nr_parts); else #endif add_mtd_device(info->mtd); platform_set_drvdata(pdev, info); return 0; out_iounmap: iounmap(info->map.virt); out_release_mem_region: release_mem_region(res->start, size); out_free_info: kfree(info); return err; }
static int __init dm270_init_flash (void) { struct mtd_partition *parts; int nb_parts = 0; int parsed_nr_parts = 0; const char *part_type; /* * Static partition definition selection */ part_type = "static"; parts = dm270_partitions; nb_parts = ARRAY_SIZE(dm270_partitions); dm270_map_flash.virt = phys_to_virt(dm270_map_flash.phys); simple_map_init(&dm270_map_flash); /* * Now let's probe for the actual flash. Do it here since * specific machine settings might have been set above. */ printk(KERN_NOTICE "DM270 flash: probing %d-bit flash bus\n", dm270_map_flash.bankwidth*8); dm270_flash_mtd = do_map_probe("cfi_probe", &dm270_map_flash); if (!dm270_flash_mtd) { return -ENXIO; } dm270_flash_mtd->owner = THIS_MODULE; /* * Dynamic partition selection stuff (might override the static ones) */ if (dm270_partition_types[0]) { parsed_nr_parts = parse_mtd_partitions(dm270_flash_mtd, dm270_partition_types, &parsed_parts, CONFIG_FLASH_MEM_BASE); } if (parsed_nr_parts > 0) { part_type = "dynamic"; parts = parsed_parts; nb_parts = parsed_nr_parts; } if (nb_parts == 0) { printk(KERN_NOTICE "DM270 flash: no partition info available," "registering whole flash at once\n"); if (add_mtd_device(dm270_flash_mtd)) { return -ENXIO; } } else { printk(KERN_NOTICE "Using %s partition definition\n", part_type); return add_mtd_partitions(dm270_flash_mtd, parts, nb_parts); } return 0; }
int __init init_taihu_flash(void) { printk(KERN_NOTICE "taihu: bootflash mapping: %x at %x\n", BOOTWINDOW_SIZE, BOOTWINDOW_ADDR); taihu_bootflash_map.virt = ioremap(BOOTWINDOW_ADDR, BOOTWINDOW_SIZE); if (!taihu_bootflash_map.virt) { printk("init_taihu_flash: failed to ioremap for bootflash\n"); return -EIO; } simple_map_init(&taihu_bootflash_map); taihu_mtd = do_map_probe("cfi_probe", &taihu_bootflash_map); if (taihu_mtd) { taihu_mtd->owner = THIS_MODULE; add_mtd_partitions(taihu_mtd, taihu_bootflash_partitions, ARRAY_SIZE(taihu_bootflash_partitions)); } else { printk("map probe failed (bootflash)\n"); return -ENXIO; } printk(KERN_NOTICE "taihu: appflash mapping: %x at %x\n", APPWINDOW_SIZE, APPWINDOW_ADDR); taihu_appflash_map.virt = ioremap(APPWINDOW_ADDR, APPWINDOW_SIZE); if (!taihu_appflash_map.virt) { printk("init_taihu_flash: failed to ioremap for appflash\n"); return -EIO; } simple_map_init(&taihu_appflash_map); taihu_mtd = do_map_probe("cfi_probe", &taihu_appflash_map); if (taihu_mtd) { taihu_mtd->owner = THIS_MODULE; add_mtd_partitions(taihu_mtd, taihu_appflash_partitions, ARRAY_SIZE(taihu_appflash_partitions)); } else { printk("map probe failed (appflash)\n"); return -ENXIO; } return 0; }
static int __init init_autcpu12_sram (void) { int err, save0, save1; autcpu12_sram_map.virt = ioremap(0x12000000, SZ_128K); if (!autcpu12_sram_map.virt) { printk("Failed to ioremap autcpu12 NV-RAM space\n"); err = -EIO; goto out; } simple_map_init(&autcpu_sram_map); save0 = map_read32(&autcpu12_sram_map,0); save1 = map_read32(&autcpu12_sram_map,0x10000); map_write32(&autcpu12_sram_map,~save0,0x10000); if ( map_read32(&autcpu12_sram_map,0) != save0) { map_write32(&autcpu12_sram_map,save0,0x0); goto map; } map_write32(&autcpu12_sram_map,save1,0x10000); autcpu12_sram_map.size = SZ_128K; map: sram_mtd = do_map_probe("map_ram", &autcpu12_sram_map); if (!sram_mtd) { printk("NV-RAM probe failed\n"); err = -ENXIO; goto out_ioremap; } sram_mtd->owner = THIS_MODULE; sram_mtd->erasesize = 16; if (add_mtd_device(sram_mtd)) { printk("NV-RAM device addition failed\n"); err = -ENOMEM; goto out_probe; } printk("NV-RAM device size %ldKiB registered on AUTCPU12\n",autcpu12_sram_map.size/SZ_1K); return 0; out_probe: map_destroy(sram_mtd); sram_mtd = 0; out_ioremap: iounmap((void *)autcpu12_sram_map.virt); out: return err; }
static int __init init_sc520cdp(void) { int i, devices_found = 0; #ifdef REPROGRAM_PAR /* reprogram PAR registers so flash appears at the desired addresses */ sc520cdp_setup_par(); #endif for (i = 0; i < NUM_FLASH_BANKS; i++) { #ifdef CONFIG_DEBUG_PRINTK printk(KERN_NOTICE "SC520 CDP flash device: 0x%Lx at 0x%Lx\n", (unsigned long long)sc520cdp_map[i].size, (unsigned long long)sc520cdp_map[i].phys); #else ; #endif sc520cdp_map[i].virt = ioremap_nocache(sc520cdp_map[i].phys, sc520cdp_map[i].size); if (!sc520cdp_map[i].virt) { #ifdef CONFIG_DEBUG_PRINTK printk("Failed to ioremap_nocache\n"); #else ; #endif return -EIO; } simple_map_init(&sc520cdp_map[i]); mymtd[i] = do_map_probe("cfi_probe", &sc520cdp_map[i]); if(!mymtd[i]) mymtd[i] = do_map_probe("jedec_probe", &sc520cdp_map[i]); if(!mymtd[i]) mymtd[i] = do_map_probe("map_rom", &sc520cdp_map[i]); if (mymtd[i]) { mymtd[i]->owner = THIS_MODULE; ++devices_found; } else { iounmap(sc520cdp_map[i].virt); } } if(devices_found >= 2) { /* Combine the two flash banks into a single MTD device & register it: */ merged_mtd = mtd_concat_create(mymtd, 2, "SC520CDP Flash Banks #0 and #1"); if(merged_mtd) mtd_device_register(merged_mtd, NULL, 0); } if(devices_found == 3) /* register the third (DIL-Flash) device */ mtd_device_register(mymtd[2], NULL, 0); return(devices_found ? 0 : -ENXIO); }
static int __init init_soleng_maps(void) { /* First probe at offset 0 */ soleng_flash_map.phys = 0; soleng_flash_map.virt = (void __iomem *)P2SEGADDR(0); soleng_eprom_map.phys = 0x01000000; soleng_eprom_map.virt = (void __iomem *)P1SEGADDR(0x01000000); simple_map_init(&soleng_eprom_map); simple_map_init(&soleng_flash_map); printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n"); flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map); if (!flash_mtd) { /* Not there. Try swapping */ printk(KERN_NOTICE "Probing for flash chips at 0x01000000:\n"); soleng_flash_map.phys = 0x01000000; soleng_flash_map.virt = P2SEGADDR(0x01000000); soleng_eprom_map.phys = 0; soleng_eprom_map.virt = P1SEGADDR(0); flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map); if (!flash_mtd) { /* Eep. */ printk(KERN_NOTICE "Flash chips not detected at either possible location.\n"); return -ENXIO; } } printk(KERN_NOTICE "Solution Engine: Flash at 0x%08lx, EPROM at 0x%08lx\n", soleng_flash_map.phys & 0x1fffffff, soleng_eprom_map.phys & 0x1fffffff); flash_mtd->owner = THIS_MODULE; eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map); if (eprom_mtd) { eprom_mtd->owner = THIS_MODULE; mtd_device_register(eprom_mtd, NULL, 0); } mtd_device_parse_register(flash_mtd, probes, NULL, superh_se_partitions, NUM_PARTITIONS); return 0; }
/* * Initialize the map_info structure and map the flash. * Returns 0 on success, nonzero otherwise. */ static int vr_nor_init_maps(struct vr_nor_mtd *p) { unsigned long csr_phys, csr_len; unsigned long win_phys, win_len; unsigned int exp_timing_cs0; int err; csr_phys = pci_resource_start(p->dev, EXP_CSR_MBAR); csr_len = pci_resource_len(p->dev, EXP_CSR_MBAR); win_phys = pci_resource_start(p->dev, EXP_WIN_MBAR); win_len = pci_resource_len(p->dev, EXP_WIN_MBAR); if (!csr_phys || !csr_len || !win_phys || !win_len) return -ENODEV; if (win_len < (CS0_START + CS0_SIZE)) return -ENXIO; p->csr_base = ioremap_nocache(csr_phys, csr_len); if (!p->csr_base) return -ENOMEM; exp_timing_cs0 = readl(p->csr_base + EXP_TIMING_CS0); if (!(exp_timing_cs0 & TIMING_CS_EN)) { dev_warn(&p->dev->dev, "Expansion Bus Chip Select 0 " "is disabled.\n"); err = -ENODEV; goto release; } if ((exp_timing_cs0 & TIMING_MASK) == TIMING_MASK) { dev_warn(&p->dev->dev, "Expansion Bus Chip Select 0 " "is configured for maximally slow access times.\n"); } p->map.name = DRV_NAME; p->map.bankwidth = (exp_timing_cs0 & TIMING_BYTE_EN) ? 1 : 2; p->map.phys = win_phys + CS0_START; p->map.size = CS0_SIZE; p->map.virt = ioremap_nocache(p->map.phys, p->map.size); if (!p->map.virt) { err = -ENOMEM; goto release; } simple_map_init(&p->map); /* Enable writes to flash bank */ exp_timing_cs0 |= TIMING_BOOT_ACCEL_DIS | TIMING_WR_EN; writel(exp_timing_cs0, p->csr_base + EXP_TIMING_CS0); return 0; release: iounmap(p->csr_base); return err; }
int __init init_s3c2410nor(void) { static const char *rom_probe_types[] = PROBETYPES; const char **type; const char *part_type = 0; printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n", WINDOW_SIZE, WINDOW_ADDR); s3c2410nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);//物理->虚拟地址 if (!s3c2410nor_map.virt) { printk(MSG_PREFIX "failed to ioremap\n"); return - EIO; } simple_map_init(&s3c2410nor_map); mymtd = 0; type = rom_probe_types; for (; !mymtd && *type; type++) { mymtd = do_map_probe(*type, &s3c2410nor_map);//探测NOR FLASH } if (mymtd) { mymtd->owner = THIS_MODULE; #ifdef CONFIG_MTD_PARTITIONS mtd_parts_nb = parse_mtd_partitions(mymtd, NULL, &mtd_parts, MTDID);//探测分区信息 if (mtd_parts_nb > 0) part_type = "detected"; if (mtd_parts_nb == 0) //未探测到,使用数组定义的分区信息 { mtd_parts = static_partitions; mtd_parts_nb = ARRAY_SIZE(static_partitions); part_type = "static"; } #endif add_mtd_device(mymtd); if (mtd_parts_nb == 0) printk(KERN_NOTICE MSG_PREFIX "no partition info available\n"); else { printk(KERN_NOTICE MSG_PREFIX "using %s partition definition\n", part_type); add_mtd_partitions(mymtd, mtd_parts, mtd_parts_nb);//添加分区信息 } return 0; } iounmap((void*)s3c2410nor_map.virt); return - ENXIO; }
int __init init_walnut(void) { u8 fpga_brds1; void *fpga_brds1_adr; void *fpga_status_adr; unsigned long flash_base; /* this should already be mapped (platform/4xx/walnut.c) */ fpga_status_adr = ioremap(WALNUT_FPGA_BASE, 8); if (!fpga_status_adr) return -ENOMEM; fpga_brds1_adr = fpga_status_adr+5; fpga_brds1 = readb(fpga_brds1_adr); /* iounmap(fpga_status_adr); */ if (WALNUT_FLASH_ONBD_N(fpga_brds1)) { printk("The on-board flash is disabled (U79 sw 5)!"); iounmap(fpga_status_adr); return -EIO; } if (WALNUT_FLASH_SRAM_SEL(fpga_brds1)) flash_base = WALNUT_FLASH_LOW; else flash_base = WALNUT_FLASH_HIGH; walnut_map.phys = flash_base; walnut_map.virt = (void __iomem *)ioremap(flash_base, walnut_map.size); if (!walnut_map.virt) { printk("Failed to ioremap flash.\n"); iounmap(fpga_status_adr); return -EIO; } simple_map_init(&walnut_map); flash = do_map_probe("jedec_probe", &walnut_map); if (flash) { flash->owner = THIS_MODULE; add_mtd_partitions(flash, walnut_partitions, ARRAY_SIZE(walnut_partitions)); } else { printk("map probe failed for flash\n"); iounmap(fpga_status_adr); return -ENXIO; } iounmap(fpga_status_adr); return 0; }
static int __init uclinux_mtd_init(void) { struct mtd_info *mtd; struct map_info *mapp; mapp = &uclinux_romfs_map; if (!mapp->size) mapp->size = PAGE_ALIGN(ntohl(*((unsigned long *)(mapp->phys + 8)))); mapp->bankwidth = 4; #ifdef CONFIG_MTD_UCLINUX_RELOCATE printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n", #else printk("uclinux[mtd]: ROM probe address=0x%x size=0x%x\n", #endif (int) mapp->phys, (int) mapp->size); mapp->virt = ioremap_nocache(mapp->phys, mapp->size); if (mapp->virt == 0) { printk("uclinux[mtd]: ioremap_nocache() failed\n"); return(-EIO); } simple_map_init(mapp); #ifdef CONFIG_MTD_UCLINUX_RELOCATE mtd = do_map_probe("map_ram", mapp); #else mtd = do_map_probe("map_rom", mapp); #endif if (!mtd) { printk("uclinux[mtd]: failed to find a mapping?\n"); iounmap(mapp->virt); return(-ENXIO); } mtd->owner = THIS_MODULE; mtd->point = uclinux_point; mtd->priv = mapp; uclinux_romfs_mtdinfo = mtd; #ifdef CONFIG_MTD_PARTITIONS add_mtd_partitions(mtd, uclinux_romfs, NUM_PARTITIONS); #else add_mtd_device(mtd); #endif return(0); }
static int __init epxa_mtd_init(void) { int i; printk(KERN_NOTICE "%s flash device: 0x%x at 0x%x\n", BOARD_NAME, FLASH_SIZE, FLASH_START); epxa_map.virt = (void __iomem *)ioremap(FLASH_START, FLASH_SIZE); if (!epxa_map.virt) { printk("Failed to ioremap %s flash\n",BOARD_NAME); return -EIO; } simple_map_init(&epxa_map); mymtd = do_map_probe("cfi_probe", &epxa_map); if (!mymtd) { iounmap((void *)epxa_map.virt); return -ENXIO; } mymtd->owner = THIS_MODULE; /* Unlock the flash device. */ if(mymtd->unlock){ for (i=0; i<mymtd->numeraseregions;i++){ int j; for(j=0;j<mymtd->eraseregions[i].numblocks;j++){ mymtd->unlock(mymtd,mymtd->eraseregions[i].offset + j * mymtd->eraseregions[i].erasesize,mymtd->eraseregions[i].erasesize); } } } #ifdef CONFIG_MTD_PARTITIONS nr_parts = parse_mtd_partitions(mymtd, probes, &parts, 0); if (nr_parts > 0) { add_mtd_partitions(mymtd, parts, nr_parts); return 0; } #endif /* No recognised partitioning schemes found - use defaults */ nr_parts = epxa_default_partitions(mymtd, &parts); if (nr_parts > 0) { add_mtd_partitions(mymtd, parts, nr_parts); return 0; } /* If all else fails... */ add_mtd_device(mymtd); return 0; }
int __init init_physmap(void) { static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", 0 }; const char **type; printk(KERN_NOTICE "physmap flash device: %lx at %lx\n", physmap_map.size, physmap_map.phys); physmap_map.virt = (unsigned long)ioremap(physmap_map.phys, physmap_map.size); if (!physmap_map.virt) { printk("Failed to ioremap\n"); return -EIO; } simple_map_init(&physmap_map); mymtd = 0; type = rom_probe_types; for(; !mymtd && *type; type++) { mymtd = do_map_probe(*type, &physmap_map); } if (mymtd) { mymtd->owner = THIS_MODULE; #ifdef CONFIG_MTD_PARTITIONS mtd_parts_nb = parse_mtd_partitions(mymtd, part_probes, &mtd_parts, 0); if (mtd_parts_nb > 0) { add_mtd_partitions (mymtd, mtd_parts, mtd_parts_nb); return 0; } if (num_physmap_partitions != 0) { printk(KERN_NOTICE "Using physmap partition definition\n"); add_mtd_partitions (mymtd, physmap_partitions, num_physmap_partitions); return 0; } #endif add_mtd_device(mymtd); return 0; } iounmap((void *)physmap_map.virt); return -ENXIO; }
static int __init init_pnc2000(void) { printk(KERN_NOTICE "Photron PNC-2000 flash mapping: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR); simple_map_init(&pnc_map); mymtd = do_map_probe("cfi_probe", &pnc_map); if (mymtd) { mymtd->owner = THIS_MODULE; return add_mtd_partitions(mymtd, pnc_partitions, 3); } return -ENXIO; }