diff -urN -X ignore orig/linux-2.4.21-pre4/drivers/mtd/maps/Config.in new/linux-2.4.21-pre4/drivers/mtd/maps/Config.in --- orig/linux-2.4.21-pre4/drivers/mtd/maps/Config.in Fri Jun 27 09:04:27 2003 +++ new/linux-2.4.21-pre4/drivers/mtd/maps/Config.in Mon Feb 9 17:07:55 2004 @@ -72,6 +72,7 @@ fi dep_tristate ' Momenco Ocelot boot flash device' CONFIG_MTD_OCELOT $CONFIG_MOMENCO_OCELOT dep_tristate ' LASAT flash device' CONFIG_MTD_LASAT $CONFIG_MTD_CFI $CONFIG_LASAT + dep_tristate ' TB0229 flash rom' CONFIG_MTD_TB0229 $CONFIG_TANBAC_TB0229 fi if [ "$CONFIG_SUPERH" = "y" ]; then diff -urN -X ignore orig/linux-2.4.21-pre4/drivers/mtd/maps/Makefile new/linux-2.4.21-pre4/drivers/mtd/maps/Makefile --- orig/linux-2.4.21-pre4/drivers/mtd/maps/Makefile Fri Jun 27 09:04:34 2003 +++ new/linux-2.4.21-pre4/drivers/mtd/maps/Makefile Mon Feb 9 17:07:55 2004 @@ -65,5 +65,6 @@ obj-$(CONFIG_MTD_UCLINUX) += uclinux.o obj-$(CONFIG_MTD_NETtel) += nettel.o obj-$(CONFIG_MTD_SCB2_FLASH) += scb2_flash.o +obj-$(CONFIG_MTD_TB0229) += tb0229-flash.o include $(TOPDIR)/Rules.make diff -urN -X ignore orig/linux-2.4.21-pre4/drivers/mtd/maps/tb0229-flash.c new/linux-2.4.21-pre4/drivers/mtd/maps/tb0229-flash.c --- orig/linux-2.4.21-pre4/drivers/mtd/maps/tb0229-flash.c Thu Jan 1 09:00:00 1970 +++ new/linux-2.4.21-pre4/drivers/mtd/maps/tb0229-flash.c Mon Feb 9 17:13:16 2004 @@ -0,0 +1,192 @@ +/* + * $Id: partition.txt,v 1.1 2004/02/14 06:27:59 nari Exp $ + * + * Normal mappings of chips in physical memory + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define WINDOW_ADDR 0x1fc00000 +#define WINDOW_SIZE 0x00400000 + +static struct mtd_info *mymtd; + +#define VR4131_BCUCNTREG1 (*(volatile unsigned short *)0xaf000000) + +static inline void tb0229_flash_enable(void) +{ + VR4131_BCUCNTREG1 |= 0x0040; +} + +static inline void tb0229_flash_disable(void) +{ + VR4131_BCUCNTREG1 &= ~0x0040; +} + +__u8 tb0229_read8(struct map_info *map, unsigned long ofs) +{ + return __raw_readb(map->map_priv_1 + ofs); +} + +__u16 tb0229_read16(struct map_info *map, unsigned long ofs) +{ +#if 0 + return __raw_readw(map->map_priv_1 + ofs); +#else + __u16 d = __raw_readw(map->map_priv_1 + ofs); + printk("tb0229_read16(%lx,%lx)=%02x (%s:%d)\n",map->map_priv_1,ofs,d,__FILE__,__LINE__); + return d; +#endif +} + +__u32 tb0229_read32(struct map_info *map, unsigned long ofs) +{ + return __raw_readl(map->map_priv_1 + ofs); +} + +void tb0229_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) +{ + memcpy_fromio(to, map->map_priv_1 + from, len); +} + +void tb0229_write8(struct map_info *map, __u8 d, unsigned long adr) +{ + tb0229_flash_enable(); + __raw_writeb(d, map->map_priv_1 + adr); + mb(); + tb0229_flash_disable(); +} + +void tb0229_write16(struct map_info *map, __u16 d, unsigned long adr) +{ + tb0229_flash_enable(); + __raw_writew(d, map->map_priv_1 + adr); + mb(); + tb0229_flash_disable(); +} + +void tb0229_write32(struct map_info *map, __u32 d, unsigned long adr) +{ + tb0229_flash_enable(); + __raw_writel(d, map->map_priv_1 + adr); + mb(); + tb0229_flash_disable(); +} + +void tb0229_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) +{ + tb0229_flash_enable(); + memcpy_toio(map->map_priv_1 + to, from, len); + tb0229_flash_disable(); +} + +struct map_info tb0229map = { + name: "Tanbac TB0229 flash memory", + size: WINDOW_SIZE, + buswidth: 4, + read8: tb0229_read8, + read16: tb0229_read16, + read32: tb0229_read32, + copy_from: tb0229_copy_from, + write8: tb0229_write8, + write16: tb0229_write16, + write32: tb0229_write32, + copy_to: tb0229_copy_to +}; + +static struct mtd_partition tb0229map_partitions[] = { + { + name: "bootROM-0", + size: 0x8000, + offset: 0, + mask_flags: MTD_WRITEABLE, /* force read-only */ + }, { + name: "ROM Parameter", + size: 0x4000, + offset: 0x8000, + mask_flags: MTD_WRITEABLE, /* force read-only */ + }, { + name: "Reserved", + size: 0x4000, + offset: 0xc000, + mask_flags: MTD_WRITEABLE, /* force read-only */ + }, { + name: "bootROM-1", + size: 0x30000, + offset: 0x10000, + mask_flags: MTD_WRITEABLE, /* force read-only */ + }, { + name: "zImage", + size: 0x100000, + offset: 0x40000, + mask_flags: MTD_WRITEABLE, /* force read-only */ + }, { + name: "User FS", + size: 0x2c0000, + offset: 0x140000, + } +}; + +#define NUM_PARTITIONS (sizeof(tb0229map_partitions)/sizeof(struct mtd_partition)) + +int __init init_tb0229map(void) +{ + static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", 0 }; + const char **type; + + printk(KERN_NOTICE "tb0229 flash device: %x at %x\n", WINDOW_SIZE, WINDOW_ADDR); + tb0229map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE); + + if (!tb0229map.map_priv_1) { + printk("Failed to ioremap\n"); + return -EIO; + } + + mymtd = 0; + type = rom_probe_types; + for(; !mymtd && *type; type++) { + mymtd = do_map_probe(*type, &tb0229map); + } + if (mymtd) { + mymtd->module = THIS_MODULE; + + add_mtd_device(mymtd); + if (NUM_PARTITIONS != 0) + { + printk(KERN_NOTICE + "Using tb0229map partition definition\n"); + add_mtd_partitions (mymtd, tb0229map_partitions, NUM_PARTITIONS); + } + return 0; + } + + iounmap((void *)tb0229map.map_priv_1); + return -ENXIO; +} + +static void __exit cleanup_tb0229map(void) +{ + if (mymtd) { + del_mtd_device(mymtd); + map_destroy(mymtd); + } + if (tb0229map.map_priv_1) { + iounmap((void *)tb0229map.map_priv_1); + tb0229map.map_priv_1 = 0; + } +} + +module_init(init_tb0229map); +module_exit(cleanup_tb0229map); + + +MODULE_LICENSE("GPL"); +