added mtd driver
authorDobrica Pavlinusic <dpavlin@brr.lan>
Mon, 14 May 2007 05:23:29 +0000 (00:23 -0500)
committerDobrica Pavlinusic <dpavlin@brr.lan>
Mon, 14 May 2007 05:23:29 +0000 (00:23 -0500)
drivers/mtd/maps/Makefile
drivers/mtd/maps/usi-flash.c [new file with mode: 0755]

index 9e86863..488d1b8 100644 (file)
@@ -10,6 +10,7 @@ O_TARGET      := mapslink.o
 endif
 
 # Chip mappings
+obj-$(CONFIG_SANDPOINT)                += usi-flash.o
 obj-$(CONFIG_MTD_CDB89712)     += cdb89712.o
 obj-$(CONFIG_MTD_ARM_INTEGRATOR)+= integrator-flash.o
 obj-$(CONFIG_MTD_CFI_FLAGADM)  += cfi_flagadm.o
diff --git a/drivers/mtd/maps/usi-flash.c b/drivers/mtd/maps/usi-flash.c
new file mode 100755 (executable)
index 0000000..dd02a89
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * Flash memory access on IDT 79S334 boards
+ * 
+ * (C) 2001 Pete Popov <ppopov@mvista.com>
+ * 
+ * $Id: usi-flash.c,v 1.1.1.1 2005/04/11 02:50:26 jack Exp $
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/io.h>
+//#include <asm/au1000.h>
+
+#ifdef         DEBUG_RW
+#define        DBG(x...)       printk(x)
+#else
+#define        DBG(x...)       
+#endif
+
+//jackl
+//#define WINDOW_ADDR 0xFF800000
+//#define WINDOW_SIZE 0x800000
+#define WINDOW_ADDR 0xFFC00000
+#define WINDOW_SIZE 0x400000
+
+__u8 physmap_read8(struct map_info *map, unsigned long ofs)
+{
+       __u8 ret;
+       ret = readb(map->map_priv_1 + ofs);
+       DBG("read8 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret);
+       return ret;
+}
+
+__u16 physmap_read16(struct map_info *map, unsigned long ofs)
+{
+       __u16 ret;
+       ret = readw(map->map_priv_1 + ofs);
+       DBG("read16 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret);
+       return ret;
+}
+
+__u32 physmap_read32(struct map_info *map, unsigned long ofs)
+{
+       __u32 ret;
+       ret = readl(map->map_priv_1 + ofs);
+       DBG("read32 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret);
+       return ret;
+}
+
+void physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+{
+       DBG("physmap_copy from %x to %x\n", (unsigned)from, (unsigned)to);
+       memcpy_fromio(to, map->map_priv_1 + from, len);
+}
+
+void physmap_write8(struct map_info *map, __u8 d, unsigned long adr)
+{
+       DBG("write8 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d);
+       writeb(d, map->map_priv_1 + adr);
+       mb();
+}
+
+void physmap_write16(struct map_info *map, __u16 d, unsigned long adr)
+{
+       DBG("write16 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d);
+       writew(d, map->map_priv_1 + adr);
+       mb();
+}
+
+void physmap_write32(struct map_info *map, __u32 d, unsigned long adr)
+{
+       DBG("write32 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d);
+       writel(d, map->map_priv_1 + adr);
+       mb();
+}
+
+void physmap_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
+{
+       DBG("physmap_copy_to %x from %x\n", (unsigned)to, (unsigned)from);
+       memcpy_toio(map->map_priv_1 + to, from, len);
+}
+
+
+
+static struct map_info usi_map = {
+       name:           "USI Intel flash",
+       read8:          physmap_read8,
+       read16:         physmap_read16,
+       read32:         physmap_read32,
+       copy_from:      physmap_copy_from,
+       write8:         physmap_write8,
+       write16:        physmap_write16,
+       write32:        physmap_write32,
+       copy_to:        physmap_copy_to,
+
+       //map_priv_1:     WINDOW_ADDR,   
+};
+
+//jackl
+//static unsigned long flash_size = 0x00800000;
+static unsigned long flash_size = 0x00400000;
+
+static unsigned char flash_buswidth = 1;
+//static struct mtd_partition usi_partitions[] = {
+//        {
+//                name: "Linux Kernel",
+//                size: 0x00100000,
+//                offset: 0,
+//        },{ 
+//                name: "Linux Ramdisk",
+//                size: 0x00600000,
+//                offset: 0x00100000,
+//        },{               
+//             name: "U-BOOT BOOT LOADER",
+//                size: 0x00040000,
+//                offset: 0x00700000,
+//        },{               
+//             name: "ETC",
+//                size: 0x000C0000,
+//                offset: 0x00740000,
+//       }
+//};
+
+static struct mtd_partition usi_partitions[] = {
+        {
+                name: "Linux mtd1",
+                size: 0x00010000,
+                offset: 0,
+        },{ 
+                name: "Linux mtd2",
+                size: 0x00010000,
+                offset: 0x00010000,
+        },{
+                       name: "Linux Ramdisk",
+                size: 0x002e0000,
+                offset: 0x00020000,
+        },{
+               name: "U-BOOT BOOT LOADER",
+                size: 0x00010000,
+                offset: 0x00300000,
+        },{               
+               name: "Linux Kernel",
+                size: 0x000f0000,
+                offset: 0x00310000,
+       }
+};
+
+#define NB_OF(x)  (sizeof(x)/sizeof(x[0]))
+
+static struct mtd_partition *parsed_parts;
+static struct mtd_info *mymtd;
+
+int __init usi_mtd_init(void)
+{
+       struct mtd_partition *parts;
+       int nb_parts = 0;
+       char *part_type;
+       
+       /* Default flash buswidth */
+       usi_map.buswidth = flash_buswidth;
+
+       /*
+        * Static partition definition selection
+        */
+       part_type = "static";
+       parts = usi_partitions;
+       nb_parts = NB_OF(usi_partitions);
+       usi_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 "USI AMD/FUJITSU flash: probing %d-bit flash bus\n", 
+                       usi_map.buswidth*8);
+       usi_map.map_priv_1 = 
+               (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
+       mymtd = do_map_probe("cfi_probe", &usi_map);
+       if (!mymtd) return -ENXIO;
+       mymtd->module = THIS_MODULE;
+
+       add_mtd_partitions(mymtd, parts, nb_parts);
+       return 0;
+}
+
+static void __exit usi_mtd_cleanup(void)
+{
+       if (mymtd) {
+               del_mtd_partitions(mymtd);
+               map_destroy(mymtd);
+               if (parsed_parts)
+                       kfree(parsed_parts);
+       }
+}
+
+module_init(usi_mtd_init);
+module_exit(usi_mtd_cleanup);
+
+MODULE_AUTHOR("Pete Popov");
+MODULE_DESCRIPTION("USI Intel CFI map driver");
+MODULE_LICENSE("GPL");