2 * Flash memory access on IDT 79S334 boards
4 * (C) 2001 Pete Popov <ppopov@mvista.com>
6 * $Id: usi-flash.c,v 1.1.1.1 2005/04/11 02:50:26 jack Exp $
9 #include <linux/config.h>
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/map.h>
16 #include <linux/mtd/partitions.h>
19 //#include <asm/au1000.h>
22 #define DBG(x...) printk(x)
28 //#define WINDOW_ADDR 0xFF800000
29 //#define WINDOW_SIZE 0x800000
30 #define WINDOW_ADDR 0xFFC00000
31 #define WINDOW_SIZE 0x400000
33 __u8 physmap_read8(struct map_info *map, unsigned long ofs)
36 ret = readb(map->map_priv_1 + ofs);
37 DBG("read8 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret);
41 __u16 physmap_read16(struct map_info *map, unsigned long ofs)
44 ret = readw(map->map_priv_1 + ofs);
45 DBG("read16 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret);
49 __u32 physmap_read32(struct map_info *map, unsigned long ofs)
52 ret = readl(map->map_priv_1 + ofs);
53 DBG("read32 from %x, %x\n", (unsigned)(map->map_priv_1 + ofs), ret);
57 void physmap_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
59 DBG("physmap_copy from %x to %x\n", (unsigned)from, (unsigned)to);
60 memcpy_fromio(to, map->map_priv_1 + from, len);
63 void physmap_write8(struct map_info *map, __u8 d, unsigned long adr)
65 DBG("write8 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d);
66 writeb(d, map->map_priv_1 + adr);
70 void physmap_write16(struct map_info *map, __u16 d, unsigned long adr)
72 DBG("write16 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d);
73 writew(d, map->map_priv_1 + adr);
77 void physmap_write32(struct map_info *map, __u32 d, unsigned long adr)
79 DBG("write32 at %x, %x\n", (unsigned)(map->map_priv_1 + adr), d);
80 writel(d, map->map_priv_1 + adr);
84 void physmap_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
86 DBG("physmap_copy_to %x from %x\n", (unsigned)to, (unsigned)from);
87 memcpy_toio(map->map_priv_1 + to, from, len);
92 static struct map_info usi_map = {
93 name: "USI Intel flash",
95 read16: physmap_read16,
96 read32: physmap_read32,
97 copy_from: physmap_copy_from,
98 write8: physmap_write8,
99 write16: physmap_write16,
100 write32: physmap_write32,
101 copy_to: physmap_copy_to,
103 //map_priv_1: WINDOW_ADDR,
107 //static unsigned long flash_size = 0x00800000;
108 static unsigned long flash_size = 0x00400000;
110 static unsigned char flash_buswidth = 1;
111 //static struct mtd_partition usi_partitions[] = {
113 // name: "Linux Kernel",
117 // name: "Linux Ramdisk",
119 // offset: 0x00100000,
121 // name: "U-BOOT BOOT LOADER",
123 // offset: 0x00700000,
127 // offset: 0x00740000,
131 static struct mtd_partition usi_partitions[] = {
141 name: "Linux Ramdisk",
145 name: "U-BOOT BOOT LOADER",
149 name: "Linux Kernel",
155 #define NB_OF(x) (sizeof(x)/sizeof(x[0]))
157 static struct mtd_partition *parsed_parts;
158 static struct mtd_info *mymtd;
160 int __init usi_mtd_init(void)
162 struct mtd_partition *parts;
166 /* Default flash buswidth */
167 usi_map.buswidth = flash_buswidth;
170 * Static partition definition selection
172 part_type = "static";
173 parts = usi_partitions;
174 nb_parts = NB_OF(usi_partitions);
175 usi_map.size = flash_size;
178 * Now let's probe for the actual flash. Do it here since
179 * specific machine settings might have been set above.
181 printk(KERN_NOTICE "USI AMD/FUJITSU flash: probing %d-bit flash bus\n",
184 (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
185 mymtd = do_map_probe("cfi_probe", &usi_map);
186 if (!mymtd) return -ENXIO;
187 mymtd->module = THIS_MODULE;
189 add_mtd_partitions(mymtd, parts, nb_parts);
193 static void __exit usi_mtd_cleanup(void)
196 del_mtd_partitions(mymtd);
203 module_init(usi_mtd_init);
204 module_exit(usi_mtd_cleanup);
206 MODULE_AUTHOR("Pete Popov");
207 MODULE_DESCRIPTION("USI Intel CFI map driver");
208 MODULE_LICENSE("GPL");