2 * $Id: iq80310.c,v 1.9 2002/01/01 22:45:02 rmk Exp $
4 * Mapping for the Intel XScale IQ80310 evaluation board
6 * Author: Nicolas Pitre
7 * Copyright: (C) 2001 MontaVista Software Inc.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/module.h>
15 #include <linux/types.h>
16 #include <linux/kernel.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
20 #include <linux/mtd/partitions.h>
24 #define WINDOW_SIZE 8*1024*1024
27 static struct mtd_info *mymtd;
29 static __u8 iq80310_read8(struct map_info *map, unsigned long ofs)
31 return *(__u8 *)(map->map_priv_1 + ofs);
34 static __u16 iq80310_read16(struct map_info *map, unsigned long ofs)
36 return *(__u16 *)(map->map_priv_1 + ofs);
39 static __u32 iq80310_read32(struct map_info *map, unsigned long ofs)
41 return *(__u32 *)(map->map_priv_1 + ofs);
44 static void iq80310_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
46 memcpy(to, (void *)(map->map_priv_1 + from), len);
49 static void iq80310_write8(struct map_info *map, __u8 d, unsigned long adr)
51 *(__u8 *)(map->map_priv_1 + adr) = d;
54 static void iq80310_write16(struct map_info *map, __u16 d, unsigned long adr)
56 *(__u16 *)(map->map_priv_1 + adr) = d;
59 static void iq80310_write32(struct map_info *map, __u32 d, unsigned long adr)
61 *(__u32 *)(map->map_priv_1 + adr) = d;
64 static void iq80310_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
66 memcpy((void *)(map->map_priv_1 + to), from, len);
69 static struct map_info iq80310_map = {
70 name: "IQ80310 flash",
74 read16: iq80310_read16,
75 read32: iq80310_read32,
76 copy_from: iq80310_copy_from,
77 write8: iq80310_write8,
78 write16: iq80310_write16,
79 write32: iq80310_write32,
80 copy_to: iq80310_copy_to
83 static struct mtd_partition iq80310_partitions[4] = {
88 mask_flags: MTD_WRITEABLE /* force read-only */
101 mask_flags: MTD_WRITEABLE
105 #define NB_OF(x) (sizeof(x)/sizeof(x[0]))
107 static struct mtd_info *mymtd;
108 static struct mtd_partition *parsed_parts;
110 extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);
112 static int __init init_iq80310(void)
114 struct mtd_partition *parts;
116 int parsed_nr_parts = 0;
117 char *part_type = "static";
119 iq80310_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
120 if (!iq80310_map.map_priv_1) {
121 printk("Failed to ioremap\n");
124 mymtd = do_map_probe("cfi_probe", &iq80310_map);
126 iounmap((void *)iq80310_map.map_priv_1);
129 mymtd->module = THIS_MODULE;
131 #ifdef CONFIG_MTD_REDBOOT_PARTS
132 if (parsed_nr_parts == 0) {
133 int ret = parse_redboot_partitions(mymtd, &parsed_parts);
136 part_type = "RedBoot";
137 parsed_nr_parts = ret;
142 if (parsed_nr_parts > 0) {
143 parts = parsed_parts;
144 nb_parts = parsed_nr_parts;
146 parts = iq80310_partitions;
147 nb_parts = NB_OF(iq80310_partitions);
149 printk(KERN_NOTICE "Using %s partition definition\n", part_type);
150 add_mtd_partitions(mymtd, parts, nb_parts);
154 static void __exit cleanup_iq80310(void)
157 del_mtd_partitions(mymtd);
162 if (iq80310_map.map_priv_1)
163 iounmap((void *)iq80310_map.map_priv_1);
166 module_init(init_iq80310);
167 module_exit(cleanup_iq80310);
170 MODULE_LICENSE("GPL");
171 MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
172 MODULE_DESCRIPTION("MTD map driver for Intel XScale IQ80310 evaluation board");