2 * $Id: map_funcs.c,v 1.2 2003/05/21 15:15:07 dwmw2 Exp $
4 * Out-of-line map I/O functions for simple maps when CONFIG_COMPLEX_MAPPINGS
8 #include <linux/kernel.h>
9 #include <linux/module.h>
10 #include <linux/config.h>
11 #include <linux/types.h>
12 #include <linux/string.h>
15 #include <linux/mtd/map.h>
16 #include <linux/mtd/cfi.h>
18 static u8 simple_map_read8(struct map_info *map, unsigned long ofs)
20 return __raw_readb(map->virt + ofs);
23 static u16 simple_map_read16(struct map_info *map, unsigned long ofs)
25 return __raw_readw(map->virt + ofs);
28 static u32 simple_map_read32(struct map_info *map, unsigned long ofs)
30 return __raw_readl(map->virt + ofs);
33 static u64 simple_map_read64(struct map_info *map, unsigned long ofs)
35 #ifndef CONFIG_MTD_CFI_B8 /* 64-bit mappings */
39 return __raw_readll(map->virt + ofs);
43 static void simple_map_write8(struct map_info *map, u8 datum, unsigned long ofs)
45 __raw_writeb(datum, map->virt + ofs);
49 static void simple_map_write16(struct map_info *map, u16 datum, unsigned long ofs)
51 __raw_writew(datum, map->virt + ofs);
55 static void simple_map_write32(struct map_info *map, u32 datum, unsigned long ofs)
57 __raw_writel(datum, map->virt + ofs);
61 static void simple_map_write64(struct map_info *map, u64 datum, unsigned long ofs)
63 #ifndef CONFIG_MTD_CFI_B8 /* 64-bit mappings */
66 __raw_writell(datum, map->virt + ofs);
71 static void simple_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
73 memcpy_fromio(to, map->virt + from, len);
76 static void simple_map_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
78 memcpy_toio(map->virt + to, from, len);
81 void simple_map_init(struct map_info *map)
83 map->read8 = simple_map_read8;
84 map->read16 = simple_map_read16;
85 map->read32 = simple_map_read32;
86 map->read64 = simple_map_read64;
87 map->write8 = simple_map_write8;
88 map->write16 = simple_map_write16;
89 map->write32 = simple_map_write32;
90 map->write64 = simple_map_write64;
91 map->copy_from = simple_map_copy_from;
92 map->copy_to = simple_map_copy_to;
95 EXPORT_SYMBOL(simple_map_init);
96 MODULE_LICENSE("GPL");