Exemplo n.º 1
0
int __init uclinux_mtd_init(void)
{
	struct mtd_info *mtd;
	struct map_info *mapp;
	extern char _ebss;

	mapp = &uclinux_ram_map;
	mapp->phys = (unsigned long) &_ebss;
	mapp->size = PAGE_ALIGN(*((unsigned long *)((&_ebss) + 8)));
	mapp->bankwidth = 4;

	printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n",
	       	(int) mapp->map_priv_2, (int) mapp->size);

	mapp->virt = (void __iomem *)
		ioremap_nocache(mapp->phys, mapp->size);

	if (mapp->virt == 0) {
		printk("uclinux[mtd]: ioremap_nocache() failed\n");
		return(-EIO);
	}

	simple_map_init(mapp);

	mtd = do_map_probe("map_ram", mapp);
	if (!mtd) {
		printk("uclinux[mtd]: failed to find a mapping?\n");
		iounmap((void *) mapp->virt);
		return(-ENXIO);
	}
		
	mtd->owner = THIS_MODULE;
	mtd->point = uclinux_point;
	mtd->priv = mapp;

	uclinux_ram_mtdinfo = mtd;
	add_mtd_partitions(mtd, uclinux_romfs, NUM_PARTITIONS);

	printk("uclinux[mtd]: set %s to be root filesystem\n",
	     	uclinux_romfs[0].name);
	ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, 0);
	put_mtd_device(mtd);

	return(0);
}
Exemplo n.º 2
0
static int __init armflash_cfi_init(void *base, u_int size)
{
	int ret;

	armflash_flash_init();
	armflash_flash_wp(1);

	/*
	 * look for CFI based flash parts fitted to this board
	 */
	armflash_map.size       = size;
	armflash_map.bankwidth   = 4;
	armflash_map.virt = (void __iomem *) base;

	simple_map_init(&armflash_map);

	/*
	 * Also, the CFI layer automatically works out what size
	 * of chips we have, and does the necessary identification
	 * for us automatically.
	 */
	mtd = do_map_probe("cfi_probe", &armflash_map);
	if (!mtd)
		return -ENXIO;

	mtd->owner = THIS_MODULE;

	ret = parse_mtd_partitions(mtd, probes, &parts, (void *)0);
	if (ret > 0) {
		ret = add_mtd_partitions(mtd, parts, ret);
		if (ret)
			printk(KERN_ERR "mtd partition registration "
				"failed: %d\n", ret);
	}

	/*
	 * If we got an error, free all resources.
	 */
	if (ret < 0) {
		del_mtd_partitions(mtd);
		map_destroy(mtd);
	}

	return ret;
}
Exemplo n.º 3
0
int __init init_alteramap(void)
{
	static const char *rom_probe_types[] = {"cfi_probe", "jedec_probe", 0 };
	const char **type;

 	ndk_amd_map.virt = (unsigned long *)ioremap_nocache(WINDOW_ADDR, WINDOW_SIZE);
/*
	if (!ndk_amd_map.virt) {
		printk("Failed to ioremap\n");
		return -EIO;
	}
*/
	simple_map_init(&ndk_amd_map);

	mymtd = 0;
	type = rom_probe_types;
	for(; !mymtd && *type; type++) {
		mymtd = do_map_probe(*type, &ndk_amd_map);
	}
	if (mymtd) {
		mymtd->owner = THIS_MODULE;

		mtd_parts_nb = parse_mtd_partitions(mymtd, part_probes, 
						    &mtd_parts, 0);

		if (mtd_parts_nb > 0)
		{
			mtd_device_register(mymtd, mtd_parts, mtd_parts_nb);
			return 0;
		}

		if (NUM_PARTITIONS != 0) 
		{
			printk(KERN_NOTICE 
			       "Using Altera NDK partition definition\n");
			mtd_device_register(mymtd, alteramap_partitions, NUM_PARTITIONS);
			return 0;
		}

		return 0;
	}

	iounmap((void *)ndk_amd_map.virt);
	return -ENXIO;
}
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;

#ifdef CONFIG_MTD_PARTITIONS
			nr_parts = parse_mtd_partitions(mymtd,
							part_probe_types,
							&parts, 0);
			if (nr_parts > 0)
				add_mtd_partitions(mymtd, parts, nr_parts);
			else
				add_mtd_device(mymtd);
#else
			add_mtd_device(mymtd);
#endif
		} else {
			pr_err("Failed to register MTD device for flash\n");
		}
	}
Exemplo n.º 5
0
static int __init init_cdb89712_bootrom (void)
{
	int err;

	if (request_resource (&ioport_resource, &cdb89712_bootrom_resource)) {
		printk(KERN_NOTICE "Failed to reserve Cdb89712 BOOTROM space\n");
		err = -EBUSY;
		goto out;
	}

	cdb89712_bootrom_map.virt = ioremap(BOOTROM_START, BOOTROM_SIZE);
	if (!cdb89712_bootrom_map.virt) {
		printk(KERN_NOTICE "Failed to ioremap Cdb89712 BootROM space\n");
		err = -EIO;
		goto out_resource;
	}
	simple_map_init(&cdb89712_bootrom_map);
	bootrom_mtd = do_map_probe("map_rom", &cdb89712_bootrom_map);
	if (!bootrom_mtd) {
		printk("BootROM probe failed\n");
		err = -ENXIO;
		goto out_ioremap;
	}

	bootrom_mtd->owner = THIS_MODULE;
	bootrom_mtd->erasesize = 0x10000;

	if (add_mtd_device(bootrom_mtd)) {
		printk("BootROM device addition failed\n");
		err = -ENOMEM;
		goto out_probe;
	}

	return 0;

out_probe:
	map_destroy(bootrom_mtd);
	bootrom_mtd = 0;
out_ioremap:
	iounmap((void *)cdb89712_bootrom_map.virt);
out_resource:
	release_resource (&cdb89712_bootrom_resource);
out:
	return err;
}
Exemplo n.º 6
0
int __init alchemy_mtd_init(void)
{
	struct mtd_partition *parts;
	int nb_parts = 0;
	unsigned long window_addr;
	unsigned long window_size;

	/* Default flash buswidth */
	alchemy_map.bankwidth = BOARD_FLASH_WIDTH;

	window_addr = 0x20000000 - BOARD_FLASH_SIZE;
	window_size = BOARD_FLASH_SIZE;
#ifdef CONFIG_MIPS_MIRAGE_WHY
	/* Boot ROM flash bank only; no user bank */
	window_addr = 0x1C000000;
	window_size = 0x04000000;
	/* USERFS from 0x1C00 0000 to 0x1FC00000 */
	alchemy_partitions[0].size = 0x03C00000;
#endif

	/*
	 * Static partition definition selection
	 */
	parts = alchemy_partitions;
	nb_parts = NB_OF(alchemy_partitions);
	alchemy_map.size = window_size;

	/*
	 * Now let's probe for the actual flash.  Do it here since
	 * specific machine settings might have been set above.
	 */
	printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",
			alchemy_map.bankwidth*8);
	alchemy_map.virt = ioremap(window_addr, window_size);
	mymtd = do_map_probe("cfi_probe", &alchemy_map);
	if (!mymtd) {
		iounmap(alchemy_map.virt);
		return -ENXIO;
	}
	mymtd->owner = THIS_MODULE;

	add_mtd_partitions(mymtd, parts, nb_parts);
	return 0;
}
Exemplo n.º 7
0
static int __init init_tsunami_flash(void)
{
	static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", 0 };
	char **type;

	tsunami_tig_writeb(FLASH_ENABLE_BYTE, FLASH_ENABLE_PORT);
	
	tsunami_flash_mtd = 0;
	type = rom_probe_types;
	for(; !tsunami_flash_mtd && *type; type++) {
		tsunami_flash_mtd = do_map_probe(*type, &tsunami_flash_map);
	}
	if (tsunami_flash_mtd) {
		tsunami_flash_mtd->module = THIS_MODULE;
		add_mtd_device(tsunami_flash_mtd);
		return 0;
	}
	return -ENXIO;
}
Exemplo n.º 8
0
static int __init uclinux_mtd_init(void)
{
	struct mtd_info *mtd;
	struct map_info *mapp;

	mapp = &uclinux_ram_map;
	if (!mapp->size)
		mapp->size = PAGE_ALIGN(ntohl(*((unsigned long *)(mapp->phys + 8))));
	mapp->bankwidth = 4;

	printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n",
	       	(int) mapp->phys, (int) mapp->size);

	/*
	 * The filesystem is guaranteed to be in direct mapped memory. It is
	 * directly following the kernels own bss region. Following the same
	 * mechanism used by architectures setting up traditional initrds we
	 * use phys_to_virt to get the virtual address of its start.
	 */
	mapp->virt = phys_to_virt(mapp->phys);

	if (mapp->virt == 0) {
		printk("uclinux[mtd]: no virtual mapping?\n");
		return(-EIO);
	}

	simple_map_init(mapp);

	mtd = do_map_probe("map_ram", mapp);
	if (!mtd) {
		printk("uclinux[mtd]: failed to find a mapping?\n");
		return(-ENXIO);
	}

	mtd->owner = THIS_MODULE;
	mtd->_point = uclinux_point;
	mtd->priv = mapp;

	uclinux_ram_mtdinfo = mtd;
	mtd_device_register(mtd, uclinux_romfs, NUM_PARTITIONS);

	return(0);
}
Exemplo n.º 9
0
int __init init_rpxlite(void)
{
	printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
	rpxlite_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);

	if (!rpxlite_map.map_priv_1) {
		printk("Failed to ioremap\n");
		return -EIO;
	}
	mymtd = do_map_probe("cfi_probe", &rpxlite_map);
	if (mymtd) {
		mymtd->module = THIS_MODULE;
		add_mtd_device(mymtd);
		return 0;
	}

	iounmap((void *)rpxlite_map.map_priv_1);
	return -ENXIO;
}
Exemplo n.º 10
0
int __init tcube_mtd_init(void)
{
	struct mtd_partition *parts;
	int nb_parts = 0;
	char *part_type;
#ifdef CONFIG_XIP_ROM
	const char *driver_name = "map_rom";
#else
	const char *driver_name = "cfi_probe";
#endif
	
	/* Default flash buswidth */
	tcube_map.buswidth = flash_buswidth;

	/*
	 * Static partition definition selection
	 */
	part_type = "static";
	parts = tcube_partitions;
	nb_parts = ARRAY_SIZE(tcube_partitions);
	tcube_map.size = flash_size;

	/*
	 * Now let's probe for the actual flash.  Do it here since
	 * specific machine settings might have been set above.
	 */
	printk(KERN_NOTICE "T-Cube flash: probing %d-bit flash bus\n", 
			tcube_map.buswidth*8);
	tcube_map.phys = WINDOW_ADDR;
	tcube_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);

	simple_map_init(&tcube_map);

	mymtd = do_map_probe(driver_name, &tcube_map);
	if (!mymtd) {
		iounmap((void*)tcube_map.virt);
		return -ENXIO;
	}
	mymtd->owner = THIS_MODULE;

	add_mtd_partitions(mymtd, parts, nb_parts);
	return 0;
}
Exemplo n.º 11
0
int __init init_am8xx(void)
{
    struct mtd_partition *parts;
    int nb_parts = 0;
    int parsed_nr_parts = 0;
    char *part_type;
    printk(KERN_NOTICE "A&M 8xx flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
    am8xx_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);

    if (!am8xx_map.map_priv_1) {
        printk("Failed to ioremap\n");
        return -EIO;
    }
    mymtd = do_map_probe("cfi_probe", &am8xx_map);
    if (mymtd) {
        mymtd->module = THIS_MODULE;
#ifdef CONFIG_MTD_REDBOOT_PARTS
	if (parsed_nr_parts == 0) {
            int ret = parse_redboot_partitions(mymtd, &parsed_parts, 0);
            if (ret > 0) {
                part_type = "RedBoot";
                parsed_nr_parts = ret;
            }
	}
#endif
	if (parsed_nr_parts > 0) {
            parts = parsed_parts;
            nb_parts = parsed_nr_parts;
	}
	if (nb_parts == 0) {
            printk(KERN_NOTICE "A&M 8xx flash: no partition info available, registering whole flash at once\n");
            add_mtd_device(mymtd);
	} else {
            printk(KERN_NOTICE "Using %s partition definition\n", part_type);
            add_mtd_partitions(mymtd, parts, nb_parts);
	}
        return 0;
    }

    iounmap((void *)am8xx_map.map_priv_1);
    return -ENXIO;
}
Exemplo n.º 12
0
int __init init_snsc_mpu210_map(unsigned long addr,
				unsigned long size,
				struct map_info *map,
				struct mtd_info **mtd
#ifdef CONFIG_MTD_REDBOOT_PARTS
				, struct mtd_partition **parts
#endif	/* CONFIG_MTD_REDBOOT_PARTS */
				)
{
#ifdef CONFIG_MTD_REDBOOT_PARTS
	int nr_parts;
#endif	/* CONFIG_MTD_REDBOOT_PARTS */

       	printk(KERN_NOTICE "Flash device: %lx at %lx\n", size, addr);
	map->map_priv_1 = (unsigned long)ioremap_nocache(addr, size);

	if (!map->map_priv_1) {
		printk("Failed to ioremap\n");
		return -EIO;
	}
	*mtd = do_map_probe("cfi_probe", map);
	if (*mtd) {
		(*mtd)->module = THIS_MODULE;

#ifdef CONFIG_MTD_REDBOOT_PARTS
		nr_parts = parse_redboot_partitions(*mtd, parts);
		if (nr_parts > 0) {
			printk(KERN_NOTICE "Found RedBoot partition table.\n");
			add_mtd_partitions(*mtd, *parts, nr_parts);
		} else {
			printk(KERN_NOTICE "Error looking for RedBoot partitions.\n");
			add_mtd_device(*mtd);
		}
#else	/* CONFIG_MTD_REDBOOT_PARTS */
		add_mtd_device(*mtd);
#endif	/* CONFIG_MTD_REDBOOT_PARTS */
		return 0;
	}

	iounmap((void *)map->map_priv_1);
	return -ENXIO;
}
Exemplo n.º 13
0
static int __init init_impa7(void)
{
	static const char *rom_probe_types[] = PROBETYPES;
	const char **type;
	int i;
	static struct { u_long addr; u_long size; } pt[NUM_FLASHBANKS] = {
	  { WINDOW_ADDR0, WINDOW_SIZE0 },
	  { WINDOW_ADDR1, WINDOW_SIZE1 },
        };
	int devicesfound = 0;

	for(i=0; i<NUM_FLASHBANKS; i++)
	{
		printk(KERN_NOTICE MSG_PREFIX "probing 0x%08lx at 0x%08lx\n",
		       pt[i].size, pt[i].addr);

		impa7_map[i].phys = pt[i].addr;
		impa7_map[i].virt = ioremap(pt[i].addr, pt[i].size);
		if (!impa7_map[i].virt) {
			printk(MSG_PREFIX "failed to ioremap\n");
			return -EIO;
		}
		simple_map_init(&impa7_map[i]);

		impa7_mtd[i] = 0;
		type = rom_probe_types;
		for(; !impa7_mtd[i] && *type; type++) {
			impa7_mtd[i] = do_map_probe(*type, &impa7_map[i]);
		}

		if (impa7_mtd[i]) {
			impa7_mtd[i]->owner = THIS_MODULE;
			devicesfound++;
			mtd_device_parse_register(impa7_mtd[i], NULL, NULL,
						  partitions,
						  ARRAY_SIZE(partitions));
		}
		else
			iounmap((void *)impa7_map[i].virt);
	}
	return devicesfound == 0 ? -ENXIO : 0;
}
Exemplo n.º 14
0
static int __init uclinux_mtd_init(void)
{
	struct mtd_info *mtd;
	struct map_info *mapp;

	mapp = &uclinux_ram_map;
	if (!mapp->size)
		mapp->size = PAGE_ALIGN(ntohl(*((unsigned long *)(mapp->phys + 8))));
	mapp->bankwidth = 4;

	printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n",
	       	(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);

	mtd = do_map_probe("map_ram", mapp);
	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_ram_mtdinfo = mtd;
#ifdef CONFIG_MTD_PARTITIONS
	add_mtd_partitions(mtd, uclinux_romfs, NUM_PARTITIONS);
#else
	add_mtd_device(mtd);
#endif

	return(0);
}
Exemplo n.º 15
0
static int __init init_rpxlite(void)
{
	printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
	rpxlite_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);

	if (!rpxlite_map.virt) {
		printk("Failed to ioremap\n");
		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;
}
Exemplo n.º 16
0
Arquivo: physmap.c Projeto: nhanh0/hah
int __init init_physmap(void)
{
       	printk(KERN_NOTICE "physmap flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR);
	physmap_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);

	if (!physmap_map.map_priv_1) {
		printk("Failed to ioremap\n");
		return -EIO;
	}
	mymtd = do_map_probe("cfi_probe", &physmap_map);
	if (mymtd) {
		mymtd->module = THIS_MODULE;

		add_mtd_device(mymtd);
		return 0;
	}

	iounmap((void *)physmap_map.map_priv_1);
	return -ENXIO;
}
Exemplo n.º 17
0
static int __init init_rrmap(void)
{
	void *ramroot_start;
	unsigned long ramroot_size;

	/* Check for supported rootfs types */
	if (get_ramroot(&ramroot_start, &ramroot_size)) {
		rr_map.phys = CPHYSADDR(ramroot_start);
		rr_map.size = ramroot_size;

		printk(KERN_NOTICE
			"PMC embedded root device: 0x%08lx @ 0x%08lx\n",
			rr_map.size, (unsigned long)rr_map.phys);
	} else {
		printk(KERN_ERR
			"init_rrmap: no supported embedded rootfs detected!\n");
		return -ENXIO;
	}

	/* Map rootfs to I/O space for block device driver */
	rr_map.virt = ioremap(rr_map.phys, rr_map.size);
	if (!rr_map.virt) {
		printk(KERN_ERR "Failed to ioremap\n");
		return -EIO;
	}

	simple_map_init(&rr_map);

	rr_mtd = do_map_probe("map_ram", &rr_map);
	if (rr_mtd) {
		rr_mtd->owner = THIS_MODULE;

		add_mtd_device(rr_mtd);
		ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, rr_mtd->index);

		return 0;
	}

	iounmap(rr_map.virt);
	return -ENXIO;
}
Exemplo n.º 18
0
static int __init init_sbc_gxx(void)
{
  	iomapadr = ioremap(WINDOW_START, WINDOW_LENGTH);
	if (!iomapadr) {
		printk( KERN_ERR"%s: failed to ioremap memory region\n",
			sbc_gxx_map.name );
		return -EIO;
	}

	if (!request_region( PAGE_IO, PAGE_IO_SIZE, "SBC-GXx flash")) {
		printk( KERN_ERR"%s: IO ports 0x%x-0x%x in use\n",
			sbc_gxx_map.name,
			PAGE_IO, PAGE_IO+PAGE_IO_SIZE-1 );
		iounmap(iomapadr);
		return -EAGAIN;
	}


#ifdef CONFIG_DEBUG_PRINTK
	printk( KERN_INFO"%s: IO:0x%x-0x%x MEM:0x%x-0x%x\n",
		sbc_gxx_map.name,
		PAGE_IO, PAGE_IO+PAGE_IO_SIZE-1,
		WINDOW_START, WINDOW_START+WINDOW_LENGTH-1 );
#else
	;
#endif

	/* Probe for chip. */
	all_mtd = do_map_probe( "cfi_probe", &sbc_gxx_map );
	if( !all_mtd ) {
		cleanup_sbc_gxx();
		return -ENXIO;
	}

	all_mtd->owner = THIS_MODULE;

	/* Create MTD devices for each partition. */
	mtd_device_register(all_mtd, partition_info, NUM_PARTITIONS);

	return 0;
}
Exemplo n.º 19
0
int __init init_brcm_physmap(void)
{
        PFILE_TAG pTag = NULL;
        u_int32_t rootfs_addr, kernel_addr;
        FLASH_ADDR_INFO info;

        kerSysFlashAddrInfoGet( &info );

        /* Read the flash memory map from flash memory. */
        if (!(pTag = kerSysImageTagGet())) {
                printk("Failed to read image tag from flash\n");
                return -EIO;
        }

        rootfs_addr = (u_int32_t) simple_strtoul(pTag->rootfsAddress, NULL, 10);
        kernel_addr = (u_int32_t) simple_strtoul(pTag->kernelAddress, NULL, 10);
	
	brcm_physmap_map.size = kernel_addr - rootfs_addr;
	brcm_physmap_map.map_priv_1 = (unsigned long)rootfs_addr;

	if (!brcm_physmap_map.map_priv_1) {
		printk("Wrong rootfs starting address\n");
		return -EIO;
	}
	
	if (brcm_physmap_map.size <= 0) {
		printk("Wrong rootfs size\n");
		return -EIO;
	}	
	
	mymtd = do_map_probe("map_rom", &brcm_physmap_map);
	if (mymtd) {
		mymtd->module = THIS_MODULE;
		add_mtd_device(mymtd);

		return 0;
	}

	return -ENXIO;
}
Exemplo n.º 20
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;
		/* 8-bit bus (0 + 1) or 16-bit bus (1 + 1) */
		flash_map.bankwidth = region_cfg.s.width + 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);
		flash_map.read = octeon_flash_map_read;
		flash_map.write = octeon_flash_map_write;
		flash_map.copy_from = octeon_flash_map_copy_from;
		flash_map.copy_to = octeon_flash_map_copy_to;
		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");
		}
	}
Exemplo n.º 21
0
int __init init_mbx(void)
{
	printk(KERN_NOTICE "Motorola MBX flash device: 0x%x at 0x%x\n", WINDOW_SIZE*4, WINDOW_ADDR);
	mbx_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);

	if (!mbx_map.virt) {
		printk("Failed to ioremap\n");
		return -EIO;
	}
	simple_map_init(&mbx_map);

	mymtd = do_map_probe("jedec_probe", &mbx_map);
	if (mymtd) {
		mymtd->owner = THIS_MODULE;
		add_mtd_device(mymtd);
                add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
		return 0;
	}

	iounmap((void *)mbx_map.virt);
	return -ENXIO;
}
Exemplo n.º 22
0
static int __init
init_arctic_mtd(void)
{
	printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR);

	arctic_mtd_map.virt = (unsigned long) ioremap(PADDR, SIZE);

	if (!arctic_mtd_map.virt) {
		printk("%s: failed to ioremap 0x%x\n", NAME, PADDR);
		return -EIO;
	}
	simple_map_init(&arctic_mtd_map);

	printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8);
	arctic_mtd = do_map_probe("cfi_probe", &arctic_mtd_map);

	if (!arctic_mtd)
		return -ENXIO;

	arctic_mtd->module = THIS_MODULE;

	return add_mtd_partitions(arctic_mtd, arctic_partitions, PARTITIONS);
}
Exemplo n.º 23
0
int __init init_ag_hmc80_mtdmap(void)
{
	printk(KERN_NOTICE"Panasonic AG-HMC80 flash device: %x at %x Partition number %d\n",
			WINDOW_SIZE, WINDOW_ADDR, PARTITION_NUM);
	ag_hmc80_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);

	if (!ag_hmc80_map.virt) {
		printk("Failed to ioremap\n");
		return -EIO;
	}
	simple_map_init(&ag_hmc80_map);
	
	mymtd = do_map_probe("cfi_probe", &ag_hmc80_map);
	if (mymtd) {
		mymtd->owner = THIS_MODULE;
                add_mtd_partitions(mymtd, partition_info, PARTITION_NUM);
		printk(KERN_NOTICE "AG-HMC80 flash device (%s) initialized\n",mymtd->name);
		return 0;
	}

	iounmap((void *)ag_hmc80_map.virt);
	return -ENXIO;
}
Exemplo n.º 24
0
int __init alchemy_mtd_init(void)
{
	struct mtd_partition *parts;
	int nb_parts = 0;
	unsigned long window_addr;
	unsigned long window_size;

	/* Default flash buswidth */
	alchemy_map.bankwidth = BOARD_FLASH_WIDTH;

	window_addr = 0x20000000 - BOARD_FLASH_SIZE;
	window_size = BOARD_FLASH_SIZE;

	/*
	 * Static partition definition selection
	 */
	parts = alchemy_partitions;
	nb_parts = ARRAY_SIZE(alchemy_partitions);
	alchemy_map.size = window_size;

	/*
	 * Now let's probe for the actual flash.  Do it here since
	 * specific machine settings might have been set above.
	 */
	printk(KERN_NOTICE BOARD_MAP_NAME ": probing %d-bit flash bus\n",
			alchemy_map.bankwidth*8);
	alchemy_map.virt = ioremap(window_addr, window_size);
	mymtd = do_map_probe("cfi_probe", &alchemy_map);
	if (!mymtd) {
		iounmap(alchemy_map.virt);
		return -ENXIO;
	}
	mymtd->owner = THIS_MODULE;

	add_mtd_partitions(mymtd, parts, nb_parts);
	return 0;
}
Exemplo n.º 25
0
static int __init
init_beech_mtd(void)
{
	printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR);

	beech_mtd_map.virt = (unsigned long) 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)
		return -ENXIO;

	beech_mtd->owner = THIS_MODULE;

	return add_mtd_partitions(beech_mtd, beech_partitions, 2);
}
Exemplo n.º 26
0
static int __init init_iq80310(void)
{
	struct mtd_partition *parts;
	int nb_parts = 0;
	int parsed_nr_parts = 0;
	int ret;

	iq80310_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
	if (!iq80310_map.virt) {
		printk("Failed to ioremap\n");
		return -EIO;
	}
	simple_map_init(&iq80310_map);

	mymtd = do_map_probe("cfi_probe", &iq80310_map);
	if (!mymtd) {
		iounmap((void *)iq80310_map.virt);
		return -ENXIO;
	}
	mymtd->owner = THIS_MODULE;

	ret = parse_mtd_partitions(mymtd, probes, &parsed_parts, 0);

	if (ret > 0)
		parsed_nr_parts = ret;

	if (parsed_nr_parts > 0) {
		parts = parsed_parts;
		nb_parts = parsed_nr_parts;
	} else {
		parts = iq80310_partitions;
		nb_parts = ARRAY_SIZE(iq80310_partitions);
	}
	add_mtd_partitions(mymtd, parts, nb_parts);
	return 0;
}
Exemplo n.º 27
0
int __init init_redwood_flash(void)
{
	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;
		return add_mtd_partitions(redwood_mtd,
				redwood_flash_partitions,
				NUM_REDWOOD_FLASH_PARTITIONS);
	}

	return -ENXIO;
}
Exemplo n.º 28
0
static int __init init_mpc1211_maps(void)
{
	int nr_parts;

	mpc1211_flash_map.phys = 0;
	mpc1211_flash_map.virt = (void __iomem *)P2SEGADDR(0);

	simple_map_init(&mpc1211_flash_map);

	printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
	flash_mtd = do_map_probe("jedec_probe", &mpc1211_flash_map);
	if (!flash_mtd) {
		printk(KERN_NOTICE "Flash chips not detected at either possible location.\n");
		return -ENXIO;
	}
	printk(KERN_NOTICE "MPC-1211: Flash at 0x%08lx\n", mpc1211_flash_map.virt & 0x1fffffff);
	flash_mtd->module = THIS_MODULE;

	parsed_parts = mpc1211_partitions;
	nr_parts = ARRAY_SIZE(mpc1211_partitions);

	add_mtd_partitions(flash_mtd, parsed_parts, nr_parts);
	return 0;
}
Exemplo n.º 29
0
static int __init init_ocelot_maps(void)
{
	void *pld;
	int nr_parts;
	unsigned char brd_status;

       	printk(KERN_INFO "Momenco Ocelot MTD mappings: Flash 0x%x at 0x%x, NVRAM 0x%x at 0x%x\n", 
	       FLASH_WINDOW_SIZE, FLASH_WINDOW_ADDR, NVRAM_WINDOW_SIZE, NVRAM_WINDOW_ADDR);

	/* First check whether the flash jumper is present */
	pld = ioremap(OCELOT_PLD, 0x10);
	if (!pld) {
		printk(KERN_NOTICE "Failed to ioremap Ocelot PLD\n");
		return -EIO;
	}
	brd_status = readb(pld+4);
	iounmap(pld);

	/* Now ioremap the NVRAM space */
	ocelot_nvram_map.map_priv_1 = (unsigned long)ioremap_nocache(NVRAM_WINDOW_ADDR, NVRAM_WINDOW_SIZE);
	if (!ocelot_nvram_map.map_priv_1) {
		printk(KERN_NOTICE "Failed to ioremap Ocelot NVRAM space\n");
		return -EIO;
	}
	//	ocelot_nvram_map.map_priv_2 = ocelot_nvram_map.map_priv_1;

	/* And do the RAM probe on it to get an MTD device */
	nvram_mtd = do_map_probe("map_ram", &ocelot_nvram_map);
	if (!nvram_mtd) {
		printk("NVRAM probe failed\n");
		goto fail_1;
	}
	nvram_mtd->module = THIS_MODULE;
	nvram_mtd->erasesize = 16;

	/* Now map the flash space */
	ocelot_flash_map.map_priv_1 = (unsigned long)ioremap_nocache(FLASH_WINDOW_ADDR, FLASH_WINDOW_SIZE);
	if (!ocelot_flash_map.map_priv_1) {
		printk(KERN_NOTICE "Failed to ioremap Ocelot flash space\n");
		goto fail_2;
	}
	/* Now the cached version */
	ocelot_flash_map.map_priv_2 = (unsigned long)__ioremap(FLASH_WINDOW_ADDR, FLASH_WINDOW_SIZE, 0);

	if (!ocelot_flash_map.map_priv_2) {
		/* Doesn't matter if it failed. Just use the uncached version */
		ocelot_flash_map.map_priv_2 = ocelot_flash_map.map_priv_1;
	}

	/* Only probe for flash if the write jumper is present */
	if (brd_status & 0x40) {
		flash_mtd = do_map_probe("jedec", &ocelot_flash_map);
	} else {
		printk(KERN_NOTICE "Ocelot flash write jumper not present. Treating as ROM\n");
	}
	/* If that failed or the jumper's absent, pretend it's ROM */
	if (!flash_mtd) {
		flash_mtd = do_map_probe("map_rom", &ocelot_flash_map);
		/* If we're treating it as ROM, set the erase size */
		if (flash_mtd)
			flash_mtd->erasesize = 0x10000;
	}
	if (!flash_mtd)
		goto fail3;

	add_mtd_device(nvram_mtd);

	flash_mtd->module = THIS_MODULE;
	nr_parts = parse_redboot_partitions(flash_mtd, &parsed_parts);

	if (nr_parts)
		add_mtd_partitions(flash_mtd, parsed_parts, nr_parts);
	else
		add_mtd_device(flash_mtd);

	return 0;
	
 fail3:	
	iounmap((void *)ocelot_flash_map.map_priv_1);
	if (ocelot_flash_map.map_priv_2 &&
	    ocelot_flash_map.map_priv_2 != ocelot_flash_map.map_priv_1)
			iounmap((void *)ocelot_flash_map.map_priv_2);
 fail_2:
	map_destroy(nvram_mtd);
 fail_1:
	iounmap((void *)ocelot_nvram_map.map_priv_1);

	return -ENXIO;
}
Exemplo n.º 30
0
static int __init pxa2xx_flash_probe(struct platform_device *pdev)
{
	struct flash_platform_data *flash = pdev->dev.platform_data;
	struct pxa2xx_flash_info *info;
	struct mtd_partition *parts;
	struct resource *res;
	int ret = 0;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res)
		return -ENODEV;

	info = kmalloc(sizeof(struct pxa2xx_flash_info), GFP_KERNEL);
	if (!info)
		return -ENOMEM;

	memset(info, 0, sizeof(struct pxa2xx_flash_info));
	info->map.name = (char *) flash->name;
	info->map.bankwidth = flash->width;
	info->map.phys = res->start;
	info->map.size = res->end - res->start + 1;
	info->parts = flash->parts;
	info->nr_parts = flash->nr_parts;

	info->map.virt = ioremap(info->map.phys, info->map.size);
	if (!info->map.virt) {
		printk(KERN_WARNING "Failed to ioremap %s\n",
		       info->map.name);
		return -ENOMEM;
	}
	info->map.cached =
		ioremap_cached(info->map.phys, info->map.size);
	if (!info->map.cached)
		printk(KERN_WARNING "Failed to ioremap cached %s\n",
		       info->map.name);
	info->map.inval_cache = pxa2xx_map_inval_cache;
	simple_map_init(&info->map);

	printk(KERN_NOTICE
	       "Probing %s at physical address 0x%08lx"
	       " (%d-bit bankwidth)\n",
	       info->map.name, (unsigned long)info->map.phys,
	       info->map.bankwidth * 8);

	info->mtd = do_map_probe(flash->map_name, &info->map);

	if (!info->mtd) {
		iounmap((void *)info->map.virt);
		if (info->map.cached)
			iounmap(info->map.cached);
		return -EIO;
	}
	info->mtd->owner = THIS_MODULE;

#ifdef CONFIG_MTD_PARTITIONS
	ret = parse_mtd_partitions(info->mtd, probes, &parts, 0);

	if (ret > 0) {
		info->nr_parts = ret;
		info->parts = parts;
	}
#endif

	if (info->nr_parts) {
		add_mtd_partitions(info->mtd, info->parts,
				   info->nr_parts);
	} else {
		printk("Registering %s as whole device\n",
		       info->map.name);
		add_mtd_device(info->mtd);
	}

	platform_set_drvdata(pdev, info);
	return 0;
}