Esempio n. 1
0
static int __init epxa_mtd_init(void)
{
	int i;
	
	printk(KERN_NOTICE "%s flash device: %x at %x\n", BOARD_NAME, FLASH_SIZE, FLASH_START);
	epxa_map.map_priv_1 = (unsigned long)ioremap(FLASH_START, FLASH_SIZE);
	if (!epxa_map.map_priv_1) {
		printk("Failed to ioremap %s flash\n",BOARD_NAME);
		return -EIO;
	}

	mymtd = do_map_probe("cfi_probe", &epxa_map);
	if (!mymtd) {
		iounmap((void *)epxa_map.map_priv_1);
		return -ENXIO;
	}

	mymtd->module = 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_REDBOOT_PARTS
	nr_parts = parse_redboot_partitions(mymtd, &parts);

	if (nr_parts > 0) {
		add_mtd_partitions(mymtd, parts, nr_parts);
		return 0;
	}
#endif
#ifdef CONFIG_MTD_AFS_PARTS
	nr_parts = parse_afs_partitions(mymtd, &parts);

	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;
}
static int __init se4000_init(void)
{
    int res, npart;

    /* Enable flash write */
    *IXP425_EXP_CS0 |= IXP425_FLASH_WRITABLE;

    se4000_map.map_priv_1 = 0;
    mtd_resource = request_mem_region(WINDOW_ADDR, WINDOW_SIZE, "SnapGear SE4000");
    if (!mtd_resource) {
	printk(KERN_ERR "SE4000: request_mem_region() failed\n" );
	res = -ENOMEM;
	goto Error;
    }

    se4000_map.map_priv_1 = (unsigned long) ioremap(WINDOW_ADDR, WINDOW_SIZE);
    if (!se4000_map.map_priv_1) {
	printk(KERN_ERR "SE4000: ioremap() failed\n");
	res = -EIO;
	goto Error;
    }
    se4000_map.size = WINDOW_SIZE;

    /* 
     * Probe for the CFI complaint chip
     * suposed to be 28F128J3A
     */
    se4000_mtd = do_map_probe("cfi_probe", &se4000_map);
    if (!se4000_mtd) {
	res = -ENXIO;
	goto Error;
    }
    se4000_mtd->module = THIS_MODULE;
   
    /* Try to parse RedBoot partitions */
    npart = parse_redboot_partitions(se4000_mtd, &parsed_parts, 0);
    if (npart > 0) {
	/* found "npart" RedBoot partitions */
	res = add_mtd_partitions(se4000_mtd, parsed_parts, npart);
    } else {
	res = -EIO;
    }

    if (res)
	goto Error;

#ifdef CONFIG_MTD_CFI_INTELEXT
	register_reboot_notifier(&se4000_notifier_block);
#endif

    return res;
Error:
    se4000_exit();
    return res;
}
Esempio n. 3
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;
}
Esempio n. 4
0
static int __init init_soleng_maps(void)
{
	int nr_parts;

	/* First probe at offset 0 */
	soleng_flash_map.map_priv_1 = P2SEGADDR(0);
	soleng_eprom_map.map_priv_1 = P1SEGADDR(0x400000);

	printk(KERN_NOTICE "Probing for flash chips at 0x000000:\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 0x400000:\n");
		soleng_flash_map.map_priv_1 = P2SEGADDR(0x400000);
		soleng_eprom_map.map_priv_1 = 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.map_priv_1 & 0x1fffffff,
	       soleng_eprom_map.map_priv_1 & 0x1fffffff);
	flash_mtd->module = THIS_MODULE;

	eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map);
	if (eprom_mtd) {
		eprom_mtd->module = THIS_MODULE;
		add_mtd_device(eprom_mtd);
	}

	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;
}
Esempio n. 5
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;
}
Esempio n. 6
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;
}
Esempio n. 7
0
/* 
   initialise for two set of flash. 
*/
int __init init_snsc_mpu110_map(void)
{
#ifdef CONFIG_MTD_SDM_PARTITION
    int ret;
#else
    int i, j, ret;
    int nr_parts = 0, nr_nextparts = 0;
    int namelen = 0, nextnamelen = 0;
    int nr_tmpparts = 0;
    char *names;
#endif

    /* first flash */
    printk(KERN_NOTICE "Flash device: 0x%x[bytes] at 0x%x\n", WINDOW_SIZE_0, WINDOW_ADDR_0);
    map_0.map_priv_1 = (unsigned long)ioremap_nocache(WINDOW_ADDR_0, WINDOW_SIZE_0);
    if (!map_0.map_priv_1) {
        printk("Failed to ioremap\n");
        return -EIO;
    } 
    mtd_0 = do_map_probe("cfi_probe", &map_0);

    if (mtd_0) {
        mtd_0->module = THIS_MODULE;

#ifdef CONFIG_MTD_SDM_PARTITION
	add_mtd_device(mtd_0);
#else
        /* parse the first flash.  it should have both two flash infomation */
        nr_tmpparts = parse_redboot_partitions(mtd_0, &tmp_parts);

        if (nr_tmpparts > 0) {
            printk(KERN_NOTICE "Found RedBoot partition table.\n");

            /* split the retrieved information */
            for (i=0; i<nr_tmpparts; i++) {
                printk("[%02d];0x%08x-0x%08x : %s\n", i, tmp_parts[i].offset, tmp_parts[i].offset+tmp_parts[i].size, tmp_parts[i].name);
                if (tmp_parts[i].offset >= WINDOW_SIZE_0) {
                    nr_nextparts++;
                    nextnamelen += strlen(tmp_parts[i].name)+1;
                } else {
                    nr_parts++;
                    namelen += strlen(tmp_parts[i].name)+1;
                }
            }

            /* allocate partition information */
            parsed_parts_0 = kmalloc(sizeof(struct mtd_partition)*nr_parts + namelen, GFP_KERNEL);
            if (!parsed_parts_0) {
                printk("%s():%d: kmalloc() failed\n", __FUNCTION__, __LINE__ );
                ret = -ENOMEM;
                goto out;
            }
	    names = (char *) &parsed_parts_0[nr_parts];

            for (i=0, j=0; i<nr_tmpparts; i++) {
                if (tmp_parts[i].offset < WINDOW_SIZE_0) {
		    memcpy(&parsed_parts_0[j], &tmp_parts[i], sizeof(struct mtd_partition));
		    parsed_parts_0[j].name = names;
                    strcpy(names, tmp_parts[i].name);
                    names += strlen(names) + 1;
		    j++;
                }
            }
            add_mtd_partitions(mtd_0, parsed_parts_0, nr_parts);
        } else {
            printk(KERN_NOTICE "Error looking for RedBoot partitions.\n");
            add_mtd_device(mtd_0);
        }
#endif /* CONFIG_MTD_SDM_PARTITION */
    }

    /* second flash */
    printk(KERN_NOTICE "Flash device: 0x%x[bytes] at 0x%x\n", WINDOW_SIZE_1, WINDOW_ADDR_1);
    map_1.map_priv_1 = (unsigned long)ioremap_nocache(WINDOW_ADDR_1, WINDOW_SIZE_1);
    if (!map_1.map_priv_1) {
        printk("Failed to ioremap\n");
        ret = -EIO;
        goto out2;
    } 
    mtd_1 = do_map_probe("cfi_probe", &map_1);

    if (mtd_1) {
        mtd_1->module = THIS_MODULE;
#ifdef CONFIG_MTD_SDM_PARTITION
	add_mtd_device(mtd_1);
#else
        /* we trust the information from the fist flash */
        if (nr_nextparts > 0) {
            printk(KERN_NOTICE "Found RedBoot partition table.\n");

            /* allocate partition information */
            parsed_parts_1 = kmalloc(sizeof(struct mtd_partition)*nr_nextparts + nextnamelen, GFP_KERNEL);
            if (!parsed_parts_1) {
                printk("%s():%d: kmalloc() failed\n", __FUNCTION__, __LINE__ );
                ret = -ENOMEM;
                goto out2;
            }
	    names = (char *) &parsed_parts_1[nr_nextparts];

            for (i=0, j=0; i<nr_tmpparts; i++) {
                if (tmp_parts[i].offset >= WINDOW_SIZE_0) {
		    memcpy(&parsed_parts_1[j], &tmp_parts[i], sizeof(struct mtd_partition));
                    parsed_parts_1[j].offset &= (WINDOW_SIZE_1-1);
		    parsed_parts_1[j].name = names;
                    strcpy(names, tmp_parts[i].name);
		    names += strlen(names) + 1;
                    j++;
                }
            }
            add_mtd_partitions(mtd_1, parsed_parts_1, nr_nextparts);
        } else {
            printk(KERN_NOTICE "Error looking for RedBoot partitions.\n");
            add_mtd_device(mtd_1);
        }
#endif /* CONFIG_MTD_SDM_PARTITION */
    }

    /* free tmp_parts */
    return 0;

#ifdef CONFIG_MTD_SDM_PARTITION
 out2:
    return ret;
#else
 out2:
    kfree(parsed_parts_0);
 out:
    kfree(tmp_parts);
    return ret;
#endif
}
int __init init_dc21285(void)
{
	/* Determine buswidth */
	switch (*CSR_SA110_CNTL & (3<<14)) {
		case SA110_CNTL_ROMWIDTH_8: 
			dc21285_map.buswidth = 1;
			break;
		case SA110_CNTL_ROMWIDTH_16: 
			dc21285_map.buswidth = 2; 
			break;
		case SA110_CNTL_ROMWIDTH_32: 
			dc21285_map.buswidth = 4; 
			break;
		default:
			printk (KERN_ERR "DC21285 flash: undefined buswidth\n");
			return -ENXIO;
	}
	printk (KERN_NOTICE "DC21285 flash support (%d-bit buswidth)\n",
		dc21285_map.buswidth*8);

	/* Let's map the flash area */
	dc21285_map.map_priv_1 = (unsigned long)ioremap(DC21285_FLASH, 16*1024*1024);
	if (!dc21285_map.map_priv_1) {
		printk("Failed to ioremap\n");
		return -EIO;
	}

	mymtd = do_map_probe("cfi_probe", &dc21285_map);
	if (mymtd) {
		int nrparts = 0;

		mymtd->module = THIS_MODULE;
			
		/* partition fixup */

#ifdef CONFIG_MTD_REDBOOT_PARTS
		nrparts = parse_redboot_partitions(mymtd, &dc21285_parts);
#endif
		if (nrparts > 0) {
			add_mtd_partitions(mymtd, dc21285_parts, nrparts);
		} else if (nrparts == 0) {
			printk(KERN_NOTICE "RedBoot partition table failed\n");
			add_mtd_device(mymtd);
		}

		/* 
		 * Flash timing is determined with bits 19-16 of the
		 * CSR_SA110_CNTL.  The value is the number of wait cycles, or
		 * 0 for 16 cycles (the default).  Cycles are 20 ns.
		 * Here we use 7 for 140 ns flash chips.
		 */
		/* access time */
		*CSR_SA110_CNTL = ((*CSR_SA110_CNTL & ~0x000f0000) | (7 << 16));
		/* burst time */
		*CSR_SA110_CNTL = ((*CSR_SA110_CNTL & ~0x00f00000) | (7 << 20));
		/* tristate time */
		*CSR_SA110_CNTL = ((*CSR_SA110_CNTL & ~0x0f000000) | (7 << 24));

		return 0;
	}

	iounmap((void *)dc21285_map.map_priv_1);
	return -ENXIO;
}