int __init db1x00_mtd_init(void)
{
	struct mtd_partition *parts;
	int nb_parts = 0;
	
	if (setup_flash_params()) 
		return -ENXIO;

	/*
	 * Static partition definition selection
	 */
	parts = db1x00_partitions;
	nb_parts = NB_OF(db1x00_partitions);

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

	add_mtd_partitions(db1xxx_mtd, parts, nb_parts);
	return 0;
}
Esempio n. 2
0
int __init init_sharpsl(void)
{
	struct mtd_partition *parts;
	int nb_parts = 0;
	char *part_type = "static";

	printk(KERN_NOTICE "Sharp SL series flash device: %x at %x\n",
		WINDOW_SIZE, WINDOW_ADDR);
	sharpsl_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
	if (!sharpsl_map.virt) {
		printk("Failed to ioremap\n");
		return -EIO;
	}

	simple_map_init(&sharpsl_map);

	mymtd = do_map_probe("map_rom", &sharpsl_map);
	if (!mymtd) {
		iounmap(sharpsl_map.virt);
		return -ENXIO;
	}

	mymtd->owner = THIS_MODULE;

	if (machine_is_corgi() || machine_is_shepherd() || machine_is_husky()
		|| machine_is_poodle()) {
		sharpsl_partitions[0].size=0x006d0000;
		sharpsl_partitions[0].offset=0x00120000;
	} else if (machine_is_tosa()) {
		sharpsl_partitions[0].size=0x006a0000;
		sharpsl_partitions[0].offset=0x00160000;
	} else if (machine_is_spitz() || machine_is_akita() || machine_is_borzoi()) {
		sharpsl_partitions[0].size=0x006b0000;
		sharpsl_partitions[0].offset=0x00140000;
	} else {
		map_destroy(mymtd);
		iounmap(sharpsl_map.virt);
		return -ENODEV;
	}

	parts = sharpsl_partitions;
	nb_parts = NB_OF(sharpsl_partitions);

	printk(KERN_NOTICE "Using %s partision definition\n", part_type);
	add_mtd_partitions(mymtd, parts, nb_parts);

	return 0;
}
Esempio n. 3
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;
}
Esempio n. 4
0
int old_pcmcia_sleeve_attach_flash(void (*set_vpp)(struct map_info *, int), unsigned long map_size)
{
        void *(*cfi_probe)(void *) = inter_module_get("cfi_probe");

	printk(" ### " __FUNCTION__ "\n");

        if (cfi_probe != NULL) {
                /* 
                 * assuming 150ns Flash, 30ns extra to cross the expansion ASIC and control logic 
                 * and 206 MHz CPU clock (4ns ns cycle time, up to 250MHz)
                 */
                unsigned long msc1_sm1_config = (MSC_NonBrst | MSC_16BitStMem 
                                                 | MSC_RdAcc((150 + 100)/4)
                                                 | MSC_NxtRdAcc((150 + 100)/4)
                                                 | MSC_Rec(100/4));
                msc1_sm1_config = 0xFFFC;
                MSC1 = ((MSC1 & 0xFFFF) /* sm0 */
                        | (msc1_sm1_config << 16));

                printk(__FUNCTION__ ": setting MSC1=0x%x\n", MSC1);

                pcmcia_sleeve_flash_map.set_vpp = set_vpp;
                pcmcia_sleeve_flash_map.size = map_size;

                pcmcia_sleeve_mtd = cfi_probe(&pcmcia_sleeve_flash_map);
                if (pcmcia_sleeve_mtd) {
                        pcmcia_sleeve_mtd->module = THIS_MODULE;
                        if ( add_mtd_partitions(pcmcia_sleeve_mtd, pcmcia_sleeve_flash_partitions, 
						NB_OF(pcmcia_sleeve_flash_partitions)))
				printk(" *** " __FUNCTION__ ": unable to add flash partitions\n");
                        printk(KERN_NOTICE "PCMCIA flash access initialized\n");
                        return 0;
                }
                return -ENXIO;
        } else {
                return -EINVAL;
        }

}
Esempio n. 5
0
static int __init
nettel_probe(int ram, unsigned long addr, int size, int buswidth)
{
	struct mtd_info *mymtd;
	struct map_info *map_ptr;

	if (ram)
		map_ptr = &nettel_ram_map;
	else
		map_ptr = &nettel_flash_map;

	map_ptr->bankwidth = buswidth;
	map_ptr->map_priv_2 = addr;
	map_ptr->phys = addr;
	map_ptr->size = size;

	printk(KERN_NOTICE "SnapGear %s probe(0x%lx,%d,%d): %lx at %lx\n",
			ram ? "ram" : "flash",
			addr, size, buswidth, map_ptr->size, map_ptr->map_priv_2);

	map_ptr->virt = ioremap_nocache(map_ptr->map_priv_2, map_ptr->size);

	if (!map_ptr->virt) {
		printk("Failed to ioremap_nocache\n");
		return -EIO;
	}

	simple_map_init(map_ptr);
	if (!ram) {
		mymtd = do_map_probe("cfi_probe", map_ptr);
		if (!mymtd)
			mymtd = do_map_probe("jedec_probe", map_ptr);
	} else
		mymtd = do_map_probe("map_ram", map_ptr);

	if (!mymtd) {
		iounmap((void *)map_ptr->map_priv_1);
		return -ENXIO;
	}
		
	mymtd->owner = THIS_MODULE;
	mymtd->point = nettel_point;
	mymtd->priv = map_ptr;

	if (ram) {
		ram_mtdinfo = mymtd;
		add_mtd_partitions(mymtd, nettel_romfs, NB_OF(nettel_romfs));
		return(0);
	}

	flash_mtdinfo = mymtd;
	switch (size) {
	case SIZE_128K:
		add_mtd_partitions(mymtd, nettel_128k, NB_OF(nettel_128k));
		break;
	case SIZE_1MB:
		add_mtd_partitions(mymtd, nettel_1mb, NB_OF(nettel_1mb));
		break;
	case SIZE_2MB:
		add_mtd_partitions(mymtd, nettel_2mb, NB_OF(nettel_2mb));
		break;
	case SIZE_4MB:
		add_mtd_partitions(mymtd, nettel_4mb, NB_OF(nettel_4mb));
		break;
	case SIZE_8MB:
		add_mtd_partitions(mymtd, nettel_8mb, NB_OF(nettel_8mb));
		break;
    case SIZE_16MB:
        add_mtd_partitions(mymtd, nettel_16mb, NB_OF(nettel_16mb));
        break;
	}

	return 0;
}
Esempio n. 6
0
int __init lart_flash_init (void)
{
   int result;
   memset (&mtd,0,sizeof (mtd));
   printk ("MTD driver for LART. Written by Abraham vd Merwe <*****@*****.**>\n");
   printk ("%s: Probing for 28F160x3 flash on LART...\n",module_name);
   if (!flash_probe ())
	 {
		printk (KERN_WARNING "%s: Found no LART compatible flash device\n",module_name);
		return (-ENXIO);
	 }
   printk ("%s: This looks like a LART board to me.\n",module_name);
   mtd.name = module_name;
   mtd.type = MTD_NORFLASH;
   mtd.flags = MTD_CAP_NORFLASH;
   mtd.size = FLASH_BLOCKSIZE_PARAM * FLASH_NUMBLOCKS_16m_PARAM + FLASH_BLOCKSIZE_MAIN * FLASH_NUMBLOCKS_16m_MAIN;
   mtd.erasesize = FLASH_BLOCKSIZE_MAIN;
   mtd.numeraseregions = NB_OF (erase_regions);
   mtd.eraseregions = erase_regions;
   mtd.erase = flash_erase;
   mtd.read = flash_read;
   mtd.write = flash_write;
   mtd.owner = THIS_MODULE;

#ifdef LART_DEBUG
   printk (KERN_DEBUG
		   "mtd.name = %s\n"
		   "mtd.size = 0x%.8x (%uM)\n"
		   "mtd.erasesize = 0x%.8x (%uK)\n"
		   "mtd.numeraseregions = %d\n",
		   mtd.name,
		   mtd.size,mtd.size / (1024*1024),
		   mtd.erasesize,mtd.erasesize / 1024,
		   mtd.numeraseregions);

   if (mtd.numeraseregions)
	 for (result = 0; result < mtd.numeraseregions; result++)
	   printk (KERN_DEBUG
			   "\n\n"
			   "mtd.eraseregions[%d].offset = 0x%.8x\n"
			   "mtd.eraseregions[%d].erasesize = 0x%.8x (%uK)\n"
			   "mtd.eraseregions[%d].numblocks = %d\n",
			   result,mtd.eraseregions[result].offset,
			   result,mtd.eraseregions[result].erasesize,mtd.eraseregions[result].erasesize / 1024,
			   result,mtd.eraseregions[result].numblocks);

#ifdef HAVE_PARTITIONS
   printk ("\npartitions = %d\n",NB_OF (lart_partitions));

   for (result = 0; result < NB_OF (lart_partitions); result++)
	 printk (KERN_DEBUG
			 "\n\n"
			 "lart_partitions[%d].name = %s\n"
			 "lart_partitions[%d].offset = 0x%.8x\n"
			 "lart_partitions[%d].size = 0x%.8x (%uK)\n",
			 result,lart_partitions[result].name,
			 result,lart_partitions[result].offset,
			 result,lart_partitions[result].size,lart_partitions[result].size / 1024);
#endif
#endif

#ifndef HAVE_PARTITIONS
   result = add_mtd_device (&mtd);
#else
   result = add_mtd_partitions (&mtd,lart_partitions,NB_OF (lart_partitions));
#endif

   return (result);
}
Esempio n. 7
0
int __init init_ocotea(void)
{
	u8 fpga0_reg;
	u8 *fpga0_adr;
	unsigned long long small_flash_base, large_flash_base;

	fpga0_adr = ioremap64(OCOTEA_FPGA_ADDR, 16);
	if (!fpga0_adr)
		return -ENOMEM;

	fpga0_reg = readb((unsigned long)fpga0_adr);
	iounmap(fpga0_adr);

	if (OCOTEA_BOOT_LARGE_FLASH(fpga0_reg)) {
		small_flash_base = OCOTEA_SMALL_FLASH_HIGH;
		large_flash_base = OCOTEA_LARGE_FLASH_LOW;
	}
	else {
		small_flash_base = OCOTEA_SMALL_FLASH_LOW;
		large_flash_base = OCOTEA_LARGE_FLASH_HIGH;
	}

	ocotea_small_map.phys = small_flash_base;
	ocotea_small_map.virt = ioremap64(small_flash_base,
					 ocotea_small_map.size);

	if (!ocotea_small_map.virt) {
		printk("Failed to ioremap flash\n");
		return -EIO;
	}

	simple_map_init(&ocotea_small_map);

	flash = do_map_probe("map_rom", &ocotea_small_map);
	if (flash) {
		flash->owner = THIS_MODULE;
		add_mtd_partitions(flash, ocotea_small_partitions,
					NB_OF(ocotea_small_partitions));
	} else {
		printk("map probe failed for flash\n");
		return -ENXIO;
	}

	ocotea_large_map.phys = large_flash_base;
	ocotea_large_map.virt = ioremap64(large_flash_base,
					 ocotea_large_map.size);

	if (!ocotea_large_map.virt) {
		printk("Failed to ioremap flash\n");
		return -EIO;
	}

	simple_map_init(&ocotea_large_map);

	flash = do_map_probe("cfi_probe", &ocotea_large_map);
	if (flash) {
		flash->owner = THIS_MODULE;
		add_mtd_partitions(flash, ocotea_large_partitions,
					NB_OF(ocotea_large_partitions));
	} else {
		printk("map probe failed for flash\n");
		return -ENXIO;
	}

	return 0;
}
Esempio n. 8
0
static int __init init_csbxxx(void)
{
  int ret = 0;
  const char *part_type = 0;

  csbxxx_map.virt = ioremap(csbxxx_map.phys, WINDOW_SIZE);
  if (!csbxxx_map.virt) {
    printk(KERN_WARNING "Failed to ioremap %s, MTD disabled\n", csbxxx_map.name);
    ret = -ENOMEM;
    goto err;
  }
  csbxxx_map.cached = ioremap_cached(csbxxx_map.phys, WINDOW_SIZE);
  if (!csbxxx_map.cached)
    printk(KERN_WARNING "Failed to ioremap cached %s\n", csbxxx_map.name);

  simple_map_init(&csbxxx_map);
  
  printk(KERN_NOTICE "Probing %s at physical address 0x%08lx (%d-bit bankwidth)\n",
	 csbxxx_map.name, csbxxx_map.phys, csbxxx_map.bankwidth * 8);
  
  mymtd = do_map_probe("cfi_probe", &csbxxx_map);
  
  if (!mymtd)
    goto err;

  mymtd->owner = THIS_MODULE;
  
  mtd_parts_nb = parse_mtd_partitions(mymtd, probes, &mtd_parts, 0);

  if (mtd_parts_nb > 0)
    part_type = "command line";
  else if (mtd_parts_nb == 0)
    {
      mtd_parts = csbxxx_partitions;
      mtd_parts_nb = NB_OF(csbxxx_partitions);
      part_type = "static";
    }
  else goto err;

#if 1
#warning "TODO: is add_mtd_device needed?"
#else
  add_mtd_device(mymtd);
#endif
  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;

err:
  if (csbxxx_map.virt)
    iounmap(csbxxx_map.virt);
  if (csbxxx_map.cached)
    iounmap(csbxxx_map.cached);
  if (!ret)
    ret = -EIO;

  return ret;
}