diff -urP linux-2.6.6/drivers/mtd/chips/jedec_probe.c linux-2.6.6-mw1/drivers/mtd/chips/jedec_probe.c --- linux-2.6.6/drivers/mtd/chips/jedec_probe.c Mon May 10 04:33:21 2004 +++ linux-2.6.6-mw1/drivers/mtd/chips/jedec_probe.c Wed May 26 09:53:32 2004 @@ -49,6 +49,8 @@ #define AM29F040 0x00A4 #define AM29LV040B 0x004F #define AM29F032B 0x0041 +#define AM29LV081 0x0038 +#define AM29LV017 0x00C8 /* Atmel */ #define AT49BV512 0x0003 @@ -415,6 +417,32 @@ .NumEraseRegions= 1, .regions = { ERASEINFO(0x10000,8), + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29LV081, + .name = "AMD AM29LV081", + .uaddr = { + [0] = MTD_UADDR_0x0555_0x02AA /* x8 */ + }, + .DevSize = SIZE_1MiB, + .CmdSet = P_ID_AMD_STD, + .NumEraseRegions= 1, + .regions = { + ERASEINFO(0x10000,16), + } + }, { + .mfr_id = MANUFACTURER_AMD, + .dev_id = AM29LV017, + .name = "AMD AM29LV017", + .uaddr = { + [0] = MTD_UADDR_0x0555_0x02AA /* x8 */ + }, + .DevSize = SIZE_2MiB, + .CmdSet = P_ID_AMD_STD, + .NumEraseRegions= 1, + .regions = { + ERASEINFO(0x10000,32), } }, { .mfr_id = MANUFACTURER_ATMEL, diff -urP linux-2.6.6/drivers/mtd/maps/Kconfig linux-2.6.6-mw1/drivers/mtd/maps/Kconfig --- linux-2.6.6/drivers/mtd/maps/Kconfig Mon May 10 04:33:20 2004 +++ linux-2.6.6-mw1/drivers/mtd/maps/Kconfig Wed May 26 09:54:17 2004 @@ -53,6 +53,13 @@ bits, you would set the bus width octect value to 4. This is used internally by the CFI drivers. +config MTD_SUN_JSFLASH + tristate "Sun Javastation userflash support" + depends on SPARC32 && MTD_CFI && MTD_COMPLEX_MAPPINGS + help + This provides a 'mapping' driver which supports the OS-flash + simm available in Sun Javastations. + config MTD_SUN_UFLASH tristate "Sun Microsystems userflash support" depends on (SPARC32 || SPARC64) && MTD_CFI diff -urP linux-2.6.6/drivers/mtd/maps/Makefile linux-2.6.6-mw1/drivers/mtd/maps/Makefile --- linux-2.6.6/drivers/mtd/maps/Makefile Mon May 10 04:31:55 2004 +++ linux-2.6.6-mw1/drivers/mtd/maps/Makefile Wed May 26 09:54:29 2004 @@ -35,6 +35,7 @@ obj-$(CONFIG_MTD_SC520CDP) += sc520cdp.o obj-$(CONFIG_MTD_NETSC520) += netsc520.o obj-$(CONFIG_MTD_SUN_UFLASH) += sun_uflash.o +obj-$(CONFIG_MTD_SUN_JSFLASH) += sun_jsflash.o obj-$(CONFIG_MTD_VMAX) += vmax301.o obj-$(CONFIG_MTD_SCx200_DOCFLASH)+= scx200_docflash.o obj-$(CONFIG_MTD_DBOX2) += dbox2-flash.o diff -urP linux-2.6.6/drivers/mtd/maps/sun_jsflash.c linux-2.6.6-mw1/drivers/mtd/maps/sun_jsflash.c --- linux-2.6.6/drivers/mtd/maps/sun_jsflash.c Thu Jan 1 01:00:00 1970 +++ linux-2.6.6-mw1/drivers/mtd/maps/sun_jsflash.c Thu May 27 21:22:05 2004 @@ -0,0 +1,239 @@ +/* + * sun_jsflash - Driver implementation for user-programmable flash + * module present on Sun Javastations. + * + * This driver does NOT provide access to the OBP-flash for + * safety reasons-- use /drivers/sbus/char/flash.c instead. + * + * Copyright (C) 1999-2000 Pete Zaitcev (Old jsflash.c) + * Copyright (C) 2003 Jarno Manninen + * Copyright (C) 2004 Jasper van der Neut - Stulen + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define CONFIG_MTD_PARTITIONS + +#ifdef CONFIG_MTD_PARTITIONS +#include +#else +#error config-mtd-partitions not defined +#endif + +#define MSG_PREFIX "sun_jsflash:" + +static u32 jsflash_read32(struct map_info *map, unsigned long ofs) +{ + unsigned long retval, addr; + + /* Non 4-byte aligned accesses kill the system, + but MTD takes care of this after probing. */ + if (ofs & 0x3) { + printk(KERN_DEBUG "%s: unaligned access", __FUNCTION__); + return 0; + } + + addr = map->virt + ofs; + + __asm__ __volatile__("lda [%1] %2, %0\n\t" : + "=r"(retval) : + "r"(addr), "i"(ASI_M_BYPASS)); + + return retval; +} + +static void jsflash_copy_from(struct map_info *map, void *to, + unsigned long from, ssize_t len) +{ + union byte4 { + char s[4]; + unsigned int n; + } b; + + ssize_t size = 4; + + while (len > 0) { + b.n = jsflash_read32(map, from); + if (len < 4) { + size = len; + } + memcpy(to, b.s, size); + len -= size; + from += size; + to += size; + } + + if (len > 0) { + printk(KERN_NOTICE "%s: length not zero, unaligned?", __FUNCTION__); + } +} + +static void jsflash_write32(struct map_info *map, u32 data, + unsigned long ofs) +{ + + unsigned long addr; + + if (ofs & 0x3) { + printk(KERN_DEBUG "%s: unaligned write at %lx (%lx)\n", __FUNCTION__, + ofs, (unsigned long) data); + return; + } + + addr = map->virt + ofs; + + __asm__ __volatile__("sta %0, [%1] %2\n\t" : + /* no output */ : + "r"(data), "r"(addr), "i"(ASI_M_BYPASS):"memory"); +} + +static struct mtd_info *jsflash_mtd; + +static struct map_info jsflash_map = { + + .name = "OS-flash", + .virt = 0x20400000, /* We know this */ + .size = 0x01000000, /* 16 MiB window */ + .buswidth = 4, /* 32 bit native */ + .read32 = jsflash_read32, + .copy_from = jsflash_copy_from, + .write32 = jsflash_write32, +}; + +/* + TODO! Create simple partitioning, with correct values + this is just for testing. +*/ + +#ifdef CONFIG_MTD_PARTITIONS + +static struct mtd_partition *mtd_parts; +static int mtd_parts_nb; + +const char *part_probes[] = { "cmdlinepart", NULL }; + +static struct mtd_partition jsflash_partitions[] = { + { + .name = "Bootstrap", /* SILO, proll, kernel */ + .size = 0x100000, + .offset = 0, + }, { + .name = "Filesystem", /* rootfs */ + .size = MTDPART_SIZ_FULL, + .offset = MTDPART_OFS_APPEND, + } +}; + +#define NUM_PARTITIONS (sizeof(jsflash_partitions)/ \ + sizeof(struct mtd_partition)) + +#endif + +static int __init jsflash_init(void) +{ + int node; + + node = prom_getchild(prom_root_node); + node = prom_searchsiblings(node, "flash-memory"); + + if (node == 0 || node == -1 || sparc_cpu_model != sun4m) { + printk(KERN_INFO + "sun_jsflash: unable to locate prom node\n"); + return -ENODEV; + } + + /* Now we must be on sun4m. And supposedly on Javastation */ + + + /* Get size & base address from prom, no guesses + * (in the kernel at least) */ + +#if 0 + jsflash_map.virt = + (unsigned long) ioremap_nocache(jsflash_map.phys, + jsflash_map.size); + if (jsflash_map.virt == 0) { + + printk("Failed to map device\n"); + return (-ENODEV); + } +#endif + +#if 0 + /* Try this */ + simple_map_init(&jsflash_map); +#endif + /* Try to probe around in the flash window */ + jsflash_mtd = do_map_probe("jedec_probe", &jsflash_map); + + if (!jsflash_mtd) { + printk(KERN_NOTICE MSG_PREFIX "probe unsuccesful\n"); + return (-ENODEV); + } + + jsflash_mtd->owner = THIS_MODULE; + +#ifdef CONFIG_MTD_PARTITIONS + + mtd_parts_nb = parse_mtd_partitions(jsflash_mtd, part_probes, + &mtd_parts, 0); + + if (mtd_parts_nb > 0) { + + printk(KERN_NOTICE MSG_PREFIX "adding %d partitions\n", + mtd_parts_nb); + + add_mtd_partitions(jsflash_mtd, mtd_parts, mtd_parts_nb); + + } else if (NUM_PARTITIONS > 0) { + + printk(KERN_NOTICE MSG_PREFIX + "using builtin partition definitions\n"); + + add_mtd_partitions(jsflash_mtd, jsflash_partitions, + NUM_PARTITIONS); + } +#endif + + add_mtd_device(jsflash_mtd); + return (0); +} + +static void __exit jsflash_cleanup(void) +{ + if (jsflash_mtd) { + +#ifdef CONFIG_MTD_PARTITIONS + if (mtd_parts_nb) { + del_mtd_partitions(jsflash_mtd); + kfree(mtd_parts); + } else if (NUM_PARTITIONS > 0) { + del_mtd_partitions(jsflash_mtd); + } else { + del_mtd_device(jsflash_mtd); + } +#else + del_mtd_device(jsflash_mtd); +#endif + map_destroy(jsflash_mtd); + } +} + +module_init(jsflash_init); +module_exit(jsflash_cleanup); + +MODULE_AUTHOR("Jasper van der Neut - Stulen "); +MODULE_DESCRIPTION("User-programmable flash device on Sun Javastations"); +MODULE_LICENSE("GPL");