Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * pcmciamtd.c - MTD driver for PCMCIA flash memory cards |
| 3 | * |
| 4 | * Author: Simon Evans <spse@secret.org.uk> |
| 5 | * |
| 6 | * Copyright (C) 2002 Simon Evans |
| 7 | * |
| 8 | * Licence: GPL |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/slab.h> |
| 14 | #include <linux/timer.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <asm/io.h> |
| 17 | #include <asm/system.h> |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <pcmcia/cs_types.h> |
| 20 | #include <pcmcia/cs.h> |
| 21 | #include <pcmcia/cistpl.h> |
| 22 | #include <pcmcia/ds.h> |
| 23 | |
| 24 | #include <linux/mtd/map.h> |
| 25 | #include <linux/mtd/mtd.h> |
| 26 | |
| 27 | #ifdef CONFIG_MTD_DEBUG |
| 28 | static int debug = CONFIG_MTD_DEBUG_VERBOSE; |
Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 29 | module_param(debug, int, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | MODULE_PARM_DESC(debug, "Set Debug Level 0=quiet, 5=noisy"); |
| 31 | #undef DEBUG |
| 32 | #define DEBUG(n, format, arg...) \ |
| 33 | if (n <= debug) { \ |
Harvey Harrison | cb53b3b | 2008-04-18 13:44:19 -0700 | [diff] [blame] | 34 | printk(KERN_DEBUG __FILE__ ":%s(): " format "\n", __func__ , ## arg); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | #else |
| 38 | #undef DEBUG |
| 39 | #define DEBUG(n, arg...) |
| 40 | static const int debug = 0; |
| 41 | #endif |
| 42 | |
| 43 | #define err(format, arg...) printk(KERN_ERR "pcmciamtd: " format "\n" , ## arg) |
| 44 | #define info(format, arg...) printk(KERN_INFO "pcmciamtd: " format "\n" , ## arg) |
| 45 | #define warn(format, arg...) printk(KERN_WARNING "pcmciamtd: " format "\n" , ## arg) |
| 46 | |
| 47 | |
| 48 | #define DRIVER_DESC "PCMCIA Flash memory card driver" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | /* Size of the PCMCIA address space: 26 bits = 64 MB */ |
| 51 | #define MAX_PCMCIA_ADDR 0x4000000 |
| 52 | |
| 53 | struct pcmciamtd_dev { |
Dominik Brodowski | fd23823 | 2006-03-05 10:45:09 +0100 | [diff] [blame] | 54 | struct pcmcia_device *p_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | dev_node_t node; /* device node */ |
| 56 | caddr_t win_base; /* ioremapped address of PCMCIA window */ |
| 57 | unsigned int win_size; /* size of window */ |
| 58 | unsigned int offset; /* offset into card the window currently points at */ |
| 59 | struct map_info pcmcia_map; |
| 60 | struct mtd_info *mtd_info; |
| 61 | int vpp; |
| 62 | char mtd_name[sizeof(struct cistpl_vers_1_t)]; |
| 63 | }; |
| 64 | |
| 65 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | /* Module parameters */ |
| 67 | |
| 68 | /* 2 = do 16-bit transfers, 1 = do 8-bit transfers */ |
| 69 | static int bankwidth = 2; |
| 70 | |
| 71 | /* Speed of memory accesses, in ns */ |
| 72 | static int mem_speed; |
| 73 | |
| 74 | /* Force the size of an SRAM card */ |
| 75 | static int force_size; |
| 76 | |
| 77 | /* Force Vpp */ |
| 78 | static int vpp; |
| 79 | |
| 80 | /* Set Vpp */ |
| 81 | static int setvpp; |
| 82 | |
| 83 | /* Force card to be treated as FLASH, ROM or RAM */ |
| 84 | static int mem_type; |
| 85 | |
| 86 | MODULE_LICENSE("GPL"); |
| 87 | MODULE_AUTHOR("Simon Evans <spse@secret.org.uk>"); |
| 88 | MODULE_DESCRIPTION(DRIVER_DESC); |
Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 89 | module_param(bankwidth, int, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | MODULE_PARM_DESC(bankwidth, "Set bankwidth (1=8 bit, 2=16 bit, default=2)"); |
Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 91 | module_param(mem_speed, int, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | MODULE_PARM_DESC(mem_speed, "Set memory access speed in ns"); |
Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 93 | module_param(force_size, int, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | MODULE_PARM_DESC(force_size, "Force size of card in MiB (1-64)"); |
Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 95 | module_param(setvpp, int, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | MODULE_PARM_DESC(setvpp, "Set Vpp (0=Never, 1=On writes, 2=Always on, default=0)"); |
Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 97 | module_param(vpp, int, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | MODULE_PARM_DESC(vpp, "Vpp value in 1/10ths eg 33=3.3V 120=12V (Dangerous)"); |
Rusty Russell | 8d3b33f | 2006-03-25 03:07:05 -0800 | [diff] [blame] | 99 | module_param(mem_type, int, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)"); |
| 101 | |
| 102 | |
| 103 | /* read/write{8,16} copy_{from,to} routines with window remapping to access whole card */ |
| 104 | static caddr_t remap_window(struct map_info *map, unsigned long to) |
| 105 | { |
| 106 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
| 107 | window_handle_t win = (window_handle_t)map->map_priv_2; |
| 108 | memreq_t mrq; |
| 109 | int ret; |
| 110 | |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 111 | if (!pcmcia_dev_present(dev->p_dev)) { |
| 112 | DEBUG(1, "device removed"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | mrq.CardOffset = to & ~(dev->win_size-1); |
| 117 | if(mrq.CardOffset != dev->offset) { |
| 118 | DEBUG(2, "Remapping window from 0x%8.8x to 0x%8.8x", |
| 119 | dev->offset, mrq.CardOffset); |
| 120 | mrq.Page = 0; |
Dominik Brodowski | 4c89e88 | 2008-08-03 10:07:45 +0200 | [diff] [blame] | 121 | ret = pcmcia_map_mem_page(win, &mrq); |
| 122 | if (ret != 0) { |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 123 | cs_error(dev->p_dev, MapMemPage, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | return NULL; |
| 125 | } |
| 126 | dev->offset = mrq.CardOffset; |
| 127 | } |
| 128 | return dev->win_base + (to & (dev->win_size-1)); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | static map_word pcmcia_read8_remap(struct map_info *map, unsigned long ofs) |
| 133 | { |
| 134 | caddr_t addr; |
| 135 | map_word d = {{0}}; |
| 136 | |
| 137 | addr = remap_window(map, ofs); |
| 138 | if(!addr) |
| 139 | return d; |
| 140 | |
| 141 | d.x[0] = readb(addr); |
| 142 | DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, addr, d.x[0]); |
| 143 | return d; |
| 144 | } |
| 145 | |
| 146 | |
| 147 | static map_word pcmcia_read16_remap(struct map_info *map, unsigned long ofs) |
| 148 | { |
| 149 | caddr_t addr; |
| 150 | map_word d = {{0}}; |
| 151 | |
| 152 | addr = remap_window(map, ofs); |
| 153 | if(!addr) |
| 154 | return d; |
| 155 | |
| 156 | d.x[0] = readw(addr); |
| 157 | DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, addr, d.x[0]); |
| 158 | return d; |
| 159 | } |
| 160 | |
| 161 | |
| 162 | static void pcmcia_copy_from_remap(struct map_info *map, void *to, unsigned long from, ssize_t len) |
| 163 | { |
| 164 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
| 165 | unsigned long win_size = dev->win_size; |
| 166 | |
| 167 | DEBUG(3, "to = %p from = %lu len = %u", to, from, len); |
| 168 | while(len) { |
| 169 | int toread = win_size - (from & (win_size-1)); |
| 170 | caddr_t addr; |
| 171 | |
| 172 | if(toread > len) |
| 173 | toread = len; |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 174 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | addr = remap_window(map, from); |
| 176 | if(!addr) |
| 177 | return; |
| 178 | |
| 179 | DEBUG(4, "memcpy from %p to %p len = %d", addr, to, toread); |
| 180 | memcpy_fromio(to, addr, toread); |
| 181 | len -= toread; |
| 182 | to += toread; |
| 183 | from += toread; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | |
| 188 | static void pcmcia_write8_remap(struct map_info *map, map_word d, unsigned long adr) |
| 189 | { |
| 190 | caddr_t addr = remap_window(map, adr); |
| 191 | |
| 192 | if(!addr) |
| 193 | return; |
| 194 | |
| 195 | DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, addr, d.x[0]); |
| 196 | writeb(d.x[0], addr); |
| 197 | } |
| 198 | |
| 199 | |
| 200 | static void pcmcia_write16_remap(struct map_info *map, map_word d, unsigned long adr) |
| 201 | { |
| 202 | caddr_t addr = remap_window(map, adr); |
| 203 | if(!addr) |
| 204 | return; |
| 205 | |
| 206 | DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, addr, d.x[0]); |
| 207 | writew(d.x[0], addr); |
| 208 | } |
| 209 | |
| 210 | |
| 211 | static void pcmcia_copy_to_remap(struct map_info *map, unsigned long to, const void *from, ssize_t len) |
| 212 | { |
| 213 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
| 214 | unsigned long win_size = dev->win_size; |
| 215 | |
| 216 | DEBUG(3, "to = %lu from = %p len = %u", to, from, len); |
| 217 | while(len) { |
| 218 | int towrite = win_size - (to & (win_size-1)); |
| 219 | caddr_t addr; |
| 220 | |
| 221 | if(towrite > len) |
| 222 | towrite = len; |
| 223 | |
| 224 | addr = remap_window(map, to); |
| 225 | if(!addr) |
| 226 | return; |
| 227 | |
| 228 | DEBUG(4, "memcpy from %p to %p len = %d", from, addr, towrite); |
| 229 | memcpy_toio(addr, from, towrite); |
| 230 | len -= towrite; |
| 231 | to += towrite; |
| 232 | from += towrite; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | |
| 237 | /* read/write{8,16} copy_{from,to} routines with direct access */ |
| 238 | |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 239 | #define DEV_REMOVED(x) (!(pcmcia_dev_present(((struct pcmciamtd_dev *)map->map_priv_1)->p_dev))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | |
| 241 | static map_word pcmcia_read8(struct map_info *map, unsigned long ofs) |
| 242 | { |
| 243 | caddr_t win_base = (caddr_t)map->map_priv_2; |
| 244 | map_word d = {{0}}; |
| 245 | |
| 246 | if(DEV_REMOVED(map)) |
| 247 | return d; |
| 248 | |
| 249 | d.x[0] = readb(win_base + ofs); |
| 250 | DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, win_base + ofs, d.x[0]); |
| 251 | return d; |
| 252 | } |
| 253 | |
| 254 | |
| 255 | static map_word pcmcia_read16(struct map_info *map, unsigned long ofs) |
| 256 | { |
| 257 | caddr_t win_base = (caddr_t)map->map_priv_2; |
| 258 | map_word d = {{0}}; |
| 259 | |
| 260 | if(DEV_REMOVED(map)) |
| 261 | return d; |
| 262 | |
| 263 | d.x[0] = readw(win_base + ofs); |
| 264 | DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, win_base + ofs, d.x[0]); |
| 265 | return d; |
| 266 | } |
| 267 | |
| 268 | |
| 269 | static void pcmcia_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) |
| 270 | { |
| 271 | caddr_t win_base = (caddr_t)map->map_priv_2; |
| 272 | |
| 273 | if(DEV_REMOVED(map)) |
| 274 | return; |
| 275 | |
| 276 | DEBUG(3, "to = %p from = %lu len = %u", to, from, len); |
| 277 | memcpy_fromio(to, win_base + from, len); |
| 278 | } |
| 279 | |
| 280 | |
| 281 | static void pcmcia_write8(struct map_info *map, u8 d, unsigned long adr) |
| 282 | { |
| 283 | caddr_t win_base = (caddr_t)map->map_priv_2; |
| 284 | |
| 285 | if(DEV_REMOVED(map)) |
| 286 | return; |
| 287 | |
| 288 | DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, win_base + adr, d); |
| 289 | writeb(d, win_base + adr); |
| 290 | } |
| 291 | |
| 292 | |
| 293 | static void pcmcia_write16(struct map_info *map, u16 d, unsigned long adr) |
| 294 | { |
| 295 | caddr_t win_base = (caddr_t)map->map_priv_2; |
| 296 | |
| 297 | if(DEV_REMOVED(map)) |
| 298 | return; |
| 299 | |
| 300 | DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, win_base + adr, d); |
| 301 | writew(d, win_base + adr); |
| 302 | } |
| 303 | |
| 304 | |
| 305 | static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) |
| 306 | { |
| 307 | caddr_t win_base = (caddr_t)map->map_priv_2; |
| 308 | |
| 309 | if(DEV_REMOVED(map)) |
| 310 | return; |
| 311 | |
| 312 | DEBUG(3, "to = %lu from = %p len = %u", to, from, len); |
| 313 | memcpy_toio(win_base + to, from, len); |
| 314 | } |
| 315 | |
| 316 | |
| 317 | static void pcmciamtd_set_vpp(struct map_info *map, int on) |
| 318 | { |
| 319 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 320 | struct pcmcia_device *link = dev->p_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | modconf_t mod; |
| 322 | int ret; |
| 323 | |
| 324 | mod.Attributes = CONF_VPP1_CHANGE_VALID | CONF_VPP2_CHANGE_VALID; |
| 325 | mod.Vcc = 0; |
| 326 | mod.Vpp1 = mod.Vpp2 = on ? dev->vpp : 0; |
| 327 | |
| 328 | DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 329 | ret = pcmcia_modify_configuration(link, &mod); |
Dominik Brodowski | 4c89e88 | 2008-08-03 10:07:45 +0200 | [diff] [blame] | 330 | if (ret != 0) |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 331 | cs_error(link, ModifyConfiguration, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | |
| 335 | /* After a card is removed, pcmciamtd_release() will unregister the |
| 336 | * device, and release the PCMCIA configuration. If the device is |
| 337 | * still open, this will be postponed until it is closed. |
| 338 | */ |
| 339 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 340 | static void pcmciamtd_release(struct pcmcia_device *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | { |
| 342 | struct pcmciamtd_dev *dev = link->priv; |
| 343 | |
| 344 | DEBUG(3, "link = 0x%p", link); |
| 345 | |
| 346 | if (link->win) { |
| 347 | if(dev->win_base) { |
| 348 | iounmap(dev->win_base); |
| 349 | dev->win_base = NULL; |
| 350 | } |
| 351 | pcmcia_release_window(link->win); |
| 352 | } |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 353 | pcmcia_disable_device(link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 357 | static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, int *new_name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | { |
| 359 | int rc; |
| 360 | tuple_t tuple; |
| 361 | cisparse_t parse; |
| 362 | u_char buf[64]; |
| 363 | |
| 364 | tuple.Attributes = 0; |
| 365 | tuple.TupleData = (cisdata_t *)buf; |
| 366 | tuple.TupleDataMax = sizeof(buf); |
| 367 | tuple.TupleOffset = 0; |
| 368 | tuple.DesiredTuple = RETURN_FIRST_TUPLE; |
| 369 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 370 | rc = pcmcia_get_first_tuple(link, &tuple); |
Dominik Brodowski | 4c89e88 | 2008-08-03 10:07:45 +0200 | [diff] [blame] | 371 | while (rc == 0) { |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 372 | rc = pcmcia_get_tuple_data(link, &tuple); |
Dominik Brodowski | 4c89e88 | 2008-08-03 10:07:45 +0200 | [diff] [blame] | 373 | if (rc != 0) { |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 374 | cs_error(link, GetTupleData, rc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | break; |
| 376 | } |
Dominik Brodowski | 2f3061e | 2008-08-31 15:50:33 +0200 | [diff] [blame] | 377 | rc = pcmcia_parse_tuple(&tuple, &parse); |
Dominik Brodowski | 4c89e88 | 2008-08-03 10:07:45 +0200 | [diff] [blame] | 378 | if (rc != 0) { |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 379 | cs_error(link, ParseTuple, rc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | break; |
| 381 | } |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | switch(tuple.TupleCode) { |
| 384 | case CISTPL_FORMAT: { |
| 385 | cistpl_format_t *t = &parse.format; |
| 386 | (void)t; /* Shut up, gcc */ |
| 387 | DEBUG(2, "Format type: %u, Error Detection: %u, offset = %u, length =%u", |
| 388 | t->type, t->edc, t->offset, t->length); |
| 389 | break; |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 390 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 392 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | case CISTPL_DEVICE: { |
| 394 | cistpl_device_t *t = &parse.device; |
| 395 | int i; |
| 396 | DEBUG(2, "Common memory:"); |
| 397 | dev->pcmcia_map.size = t->dev[0].size; |
| 398 | for(i = 0; i < t->ndev; i++) { |
| 399 | DEBUG(2, "Region %d, type = %u", i, t->dev[i].type); |
| 400 | DEBUG(2, "Region %d, wp = %u", i, t->dev[i].wp); |
| 401 | DEBUG(2, "Region %d, speed = %u ns", i, t->dev[i].speed); |
| 402 | DEBUG(2, "Region %d, size = %u bytes", i, t->dev[i].size); |
| 403 | } |
| 404 | break; |
| 405 | } |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 406 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | case CISTPL_VERS_1: { |
| 408 | cistpl_vers_1_t *t = &parse.version_1; |
| 409 | int i; |
| 410 | if(t->ns) { |
| 411 | dev->mtd_name[0] = '\0'; |
| 412 | for(i = 0; i < t->ns; i++) { |
| 413 | if(i) |
| 414 | strcat(dev->mtd_name, " "); |
| 415 | strcat(dev->mtd_name, t->str+t->ofs[i]); |
| 416 | } |
| 417 | } |
| 418 | DEBUG(2, "Found name: %s", dev->mtd_name); |
| 419 | break; |
| 420 | } |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 421 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | case CISTPL_JEDEC_C: { |
| 423 | cistpl_jedec_t *t = &parse.jedec; |
| 424 | int i; |
| 425 | for(i = 0; i < t->nid; i++) { |
| 426 | DEBUG(2, "JEDEC: 0x%02x 0x%02x", t->id[i].mfr, t->id[i].info); |
| 427 | } |
| 428 | break; |
| 429 | } |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 430 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | case CISTPL_DEVICE_GEO: { |
| 432 | cistpl_device_geo_t *t = &parse.device_geo; |
| 433 | int i; |
| 434 | dev->pcmcia_map.bankwidth = t->geo[0].buswidth; |
| 435 | for(i = 0; i < t->ngeo; i++) { |
| 436 | DEBUG(2, "region: %d bankwidth = %u", i, t->geo[i].buswidth); |
| 437 | DEBUG(2, "region: %d erase_block = %u", i, t->geo[i].erase_block); |
| 438 | DEBUG(2, "region: %d read_block = %u", i, t->geo[i].read_block); |
| 439 | DEBUG(2, "region: %d write_block = %u", i, t->geo[i].write_block); |
| 440 | DEBUG(2, "region: %d partition = %u", i, t->geo[i].partition); |
| 441 | DEBUG(2, "region: %d interleave = %u", i, t->geo[i].interleave); |
| 442 | } |
| 443 | break; |
| 444 | } |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 445 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | default: |
| 447 | DEBUG(2, "Unknown tuple code %d", tuple.TupleCode); |
| 448 | } |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 449 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 450 | rc = pcmcia_get_next_tuple(link, &tuple); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | } |
| 452 | if(!dev->pcmcia_map.size) |
| 453 | dev->pcmcia_map.size = MAX_PCMCIA_ADDR; |
| 454 | |
| 455 | if(!dev->pcmcia_map.bankwidth) |
| 456 | dev->pcmcia_map.bankwidth = 2; |
| 457 | |
| 458 | if(force_size) { |
| 459 | dev->pcmcia_map.size = force_size << 20; |
| 460 | DEBUG(2, "size forced to %dM", force_size); |
| 461 | } |
| 462 | |
| 463 | if(bankwidth) { |
| 464 | dev->pcmcia_map.bankwidth = bankwidth; |
| 465 | DEBUG(2, "bankwidth forced to %d", bankwidth); |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 466 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | |
| 468 | dev->pcmcia_map.name = dev->mtd_name; |
| 469 | if(!dev->mtd_name[0]) { |
| 470 | strcpy(dev->mtd_name, "PCMCIA Memory card"); |
| 471 | *new_name = 1; |
| 472 | } |
| 473 | |
| 474 | DEBUG(1, "Device: Size: %lu Width:%d Name: %s", |
| 475 | dev->pcmcia_map.size, dev->pcmcia_map.bankwidth << 3, dev->mtd_name); |
| 476 | } |
| 477 | |
| 478 | |
| 479 | /* pcmciamtd_config() is scheduled to run after a CARD_INSERTION event |
| 480 | * is received, to configure the PCMCIA socket, and to make the |
| 481 | * MTD device available to the system. |
| 482 | */ |
| 483 | |
| 484 | #define CS_CHECK(fn, ret) \ |
| 485 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
| 486 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 487 | static int pcmciamtd_config(struct pcmcia_device *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | { |
| 489 | struct pcmciamtd_dev *dev = link->priv; |
| 490 | struct mtd_info *mtd = NULL; |
| 491 | cs_status_t status; |
| 492 | win_req_t req; |
| 493 | int last_ret = 0, last_fn = 0; |
| 494 | int ret; |
| 495 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | static char *probes[] = { "jedec_probe", "cfi_probe" }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | int new_name = 0; |
| 498 | |
| 499 | DEBUG(3, "link=0x%p", link); |
| 500 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | card_settings(dev, link, &new_name); |
| 502 | |
| 503 | dev->pcmcia_map.phys = NO_XIP; |
| 504 | dev->pcmcia_map.copy_from = pcmcia_copy_from_remap; |
| 505 | dev->pcmcia_map.copy_to = pcmcia_copy_to_remap; |
| 506 | if (dev->pcmcia_map.bankwidth == 1) { |
| 507 | dev->pcmcia_map.read = pcmcia_read8_remap; |
| 508 | dev->pcmcia_map.write = pcmcia_write8_remap; |
| 509 | } else { |
| 510 | dev->pcmcia_map.read = pcmcia_read16_remap; |
| 511 | dev->pcmcia_map.write = pcmcia_write16_remap; |
| 512 | } |
| 513 | if(setvpp == 1) |
| 514 | dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp; |
| 515 | |
| 516 | /* Request a memory window for PCMCIA. Some architeures can map windows upto the maximum |
| 517 | that PCMCIA can support (64MiB) - this is ideal and we aim for a window the size of the |
| 518 | whole card - otherwise we try smaller windows until we succeed */ |
| 519 | |
| 520 | req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; |
| 521 | req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; |
| 522 | req.Base = 0; |
| 523 | req.AccessSpeed = mem_speed; |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 524 | link->win = (window_handle_t)link; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | req.Size = (force_size) ? force_size << 20 : MAX_PCMCIA_ADDR; |
| 526 | dev->win_size = 0; |
| 527 | |
| 528 | do { |
| 529 | int ret; |
| 530 | DEBUG(2, "requesting window with size = %dKiB memspeed = %d", |
| 531 | req.Size >> 10, req.AccessSpeed); |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 532 | ret = pcmcia_request_window(&link, &req, &link->win); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size); |
| 534 | if(ret) { |
| 535 | req.Size >>= 1; |
| 536 | } else { |
| 537 | DEBUG(2, "Got window of size %dKiB", req.Size >> 10); |
| 538 | dev->win_size = req.Size; |
| 539 | break; |
| 540 | } |
| 541 | } while(req.Size >= 0x1000); |
| 542 | |
| 543 | DEBUG(2, "dev->win_size = %d", dev->win_size); |
| 544 | |
| 545 | if(!dev->win_size) { |
| 546 | err("Cant allocate memory window"); |
| 547 | pcmciamtd_release(link); |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 548 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | } |
| 550 | DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 551 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | /* Get write protect status */ |
Dominik Brodowski | 4aeba01 | 2008-06-20 13:24:31 +0200 | [diff] [blame] | 553 | DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | dev->win_base = ioremap(req.Base, req.Size); |
| 555 | if(!dev->win_base) { |
| 556 | err("ioremap(%lu, %u) failed", req.Base, req.Size); |
| 557 | pcmciamtd_release(link); |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 558 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | } |
| 560 | DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x", |
| 561 | dev, req.Base, dev->win_base, req.Size); |
| 562 | |
| 563 | dev->offset = 0; |
| 564 | dev->pcmcia_map.map_priv_1 = (unsigned long)dev; |
| 565 | dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; |
| 566 | |
Dominik Brodowski | ef313e3 | 2008-08-02 16:25:26 +0200 | [diff] [blame] | 567 | dev->vpp = (vpp) ? vpp : link->socket.socket.Vpp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | link->conf.Attributes = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | if(setvpp == 2) { |
Dominik Brodowski | 70294b4 | 2006-01-15 12:43:16 +0100 | [diff] [blame] | 570 | link->conf.Vpp = dev->vpp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | } else { |
Dominik Brodowski | 70294b4 | 2006-01-15 12:43:16 +0100 | [diff] [blame] | 572 | link->conf.Vpp = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | link->conf.IntType = INT_MEMORY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | link->conf.ConfigIndex = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | DEBUG(2, "Setting Configuration"); |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 578 | ret = pcmcia_request_configuration(link, &link->conf); |
Dominik Brodowski | 4c89e88 | 2008-08-03 10:07:45 +0200 | [diff] [blame] | 579 | if (ret != 0) { |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 580 | cs_error(link, RequestConfiguration, ret); |
Amol Lad | 25f0c65 | 2006-09-21 18:12:43 +0530 | [diff] [blame] | 581 | if (dev->win_base) { |
| 582 | iounmap(dev->win_base); |
| 583 | dev->win_base = NULL; |
| 584 | } |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 585 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | if(mem_type == 1) { |
| 589 | mtd = do_map_probe("map_ram", &dev->pcmcia_map); |
| 590 | } else if(mem_type == 2) { |
| 591 | mtd = do_map_probe("map_rom", &dev->pcmcia_map); |
| 592 | } else { |
Tobias Klauser | 87d10f3 | 2006-03-31 02:29:45 -0800 | [diff] [blame] | 593 | for(i = 0; i < ARRAY_SIZE(probes); i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | DEBUG(1, "Trying %s", probes[i]); |
| 595 | mtd = do_map_probe(probes[i], &dev->pcmcia_map); |
| 596 | if(mtd) |
| 597 | break; |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 598 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | DEBUG(1, "FAILED: %s", probes[i]); |
| 600 | } |
| 601 | } |
Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 602 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | if(!mtd) { |
| 604 | DEBUG(1, "Cant find an MTD"); |
| 605 | pcmciamtd_release(link); |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 606 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | dev->mtd_info = mtd; |
| 610 | mtd->owner = THIS_MODULE; |
| 611 | |
| 612 | if(new_name) { |
| 613 | int size = 0; |
| 614 | char unit = ' '; |
| 615 | /* Since we are using a default name, make it better by adding in the |
| 616 | size */ |
| 617 | if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */ |
| 618 | size = mtd->size >> 10; |
| 619 | unit = 'K'; |
| 620 | } else { |
| 621 | size = mtd->size >> 20; |
| 622 | unit = 'M'; |
| 623 | } |
| 624 | snprintf(dev->mtd_name, sizeof(dev->mtd_name), "%d%ciB %s", size, unit, "PCMCIA Memory card"); |
| 625 | } |
| 626 | |
| 627 | /* If the memory found is fits completely into the mapped PCMCIA window, |
| 628 | use the faster non-remapping read/write functions */ |
| 629 | if(mtd->size <= dev->win_size) { |
| 630 | DEBUG(1, "Using non remapping memory functions"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base; |
| 632 | if (dev->pcmcia_map.bankwidth == 1) { |
| 633 | dev->pcmcia_map.read = pcmcia_read8; |
| 634 | dev->pcmcia_map.write = pcmcia_write8; |
| 635 | } else { |
| 636 | dev->pcmcia_map.read = pcmcia_read16; |
| 637 | dev->pcmcia_map.write = pcmcia_write16; |
| 638 | } |
| 639 | dev->pcmcia_map.copy_from = pcmcia_copy_from; |
| 640 | dev->pcmcia_map.copy_to = pcmcia_copy_to; |
| 641 | } |
| 642 | |
| 643 | if(add_mtd_device(mtd)) { |
| 644 | map_destroy(mtd); |
| 645 | dev->mtd_info = NULL; |
| 646 | err("Couldnt register MTD device"); |
| 647 | pcmciamtd_release(link); |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 648 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | } |
| 650 | snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index); |
| 651 | info("mtd%d: %s", mtd->index, mtd->name); |
Dominik Brodowski | fd23823 | 2006-03-05 10:45:09 +0100 | [diff] [blame] | 652 | link->dev_node = &dev->node; |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 653 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | |
| 655 | cs_failed: |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 656 | cs_error(link, last_fn, last_ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | err("CS Error, exiting"); |
| 658 | pcmciamtd_release(link); |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 659 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 663 | static int pcmciamtd_suspend(struct pcmcia_device *dev) |
| 664 | { |
| 665 | DEBUG(2, "EVENT_PM_RESUME"); |
| 666 | |
| 667 | /* get_lock(link); */ |
| 668 | |
| 669 | return 0; |
| 670 | } |
| 671 | |
| 672 | static int pcmciamtd_resume(struct pcmcia_device *dev) |
| 673 | { |
| 674 | DEBUG(2, "EVENT_PM_SUSPEND"); |
| 675 | |
| 676 | /* free_lock(link); */ |
| 677 | |
| 678 | return 0; |
| 679 | } |
| 680 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | |
| 682 | /* This deletes a driver "instance". The device is de-registered |
| 683 | * with Card Services. If it has been released, all local data |
| 684 | * structures are freed. Otherwise, the structures will be freed |
| 685 | * when the device is released. |
| 686 | */ |
| 687 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 688 | static void pcmciamtd_detach(struct pcmcia_device *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | { |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 690 | struct pcmciamtd_dev *dev = link->priv; |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 691 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | DEBUG(3, "link=0x%p", link); |
| 693 | |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 694 | if(dev->mtd_info) { |
| 695 | del_mtd_device(dev->mtd_info); |
Sean Young | 599fb32 | 2006-05-17 11:47:48 +0100 | [diff] [blame] | 696 | map_destroy(dev->mtd_info); |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 697 | info("mtd%d: Removed", dev->mtd_info->index); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | } |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 699 | |
| 700 | pcmciamtd_release(link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | |
| 704 | /* pcmciamtd_attach() creates an "instance" of the driver, allocating |
| 705 | * local data structures for one device. The device is registered |
| 706 | * with Card Services. |
| 707 | */ |
| 708 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 709 | static int pcmciamtd_probe(struct pcmcia_device *link) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | { |
| 711 | struct pcmciamtd_dev *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | |
| 713 | /* Create new memory card device */ |
Burman Yan | 95b93a0 | 2006-11-15 21:10:29 +0200 | [diff] [blame] | 714 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
Dominik Brodowski | f8cfa61 | 2005-11-14 21:25:51 +0100 | [diff] [blame] | 715 | if (!dev) return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 716 | DEBUG(1, "dev=0x%p", dev); |
| 717 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 718 | dev->p_dev = link; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | link->priv = dev; |
| 720 | |
| 721 | link->conf.Attributes = 0; |
| 722 | link->conf.IntType = INT_MEMORY; |
| 723 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 724 | return pcmciamtd_config(link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | } |
| 726 | |
Dominik Brodowski | 11d28a3 | 2005-06-27 16:28:32 -0700 | [diff] [blame] | 727 | static struct pcmcia_device_id pcmciamtd_ids[] = { |
| 728 | PCMCIA_DEVICE_FUNC_ID(1), |
| 729 | PCMCIA_DEVICE_PROD_ID123("IO DATA", "PCS-2M", "2MB SRAM", 0x547e66dc, 0x1fed36cd, 0x36eadd21), |
| 730 | PCMCIA_DEVICE_PROD_ID12("IBM", "2MB SRAM", 0xb569a6e5, 0x36eadd21), |
| 731 | PCMCIA_DEVICE_PROD_ID12("IBM", "4MB FLASH", 0xb569a6e5, 0x8bc54d2a), |
| 732 | PCMCIA_DEVICE_PROD_ID12("IBM", "8MB FLASH", 0xb569a6e5, 0x6df1be3e), |
| 733 | PCMCIA_DEVICE_PROD_ID12("Intel", "S2E20SW", 0x816cc815, 0xd14c9dcf), |
| 734 | PCMCIA_DEVICE_PROD_ID12("Intel", "S2E8 SW", 0x816cc815, 0xa2d7dedb), |
| 735 | PCMCIA_DEVICE_PROD_ID12("intel", "SERIES2-02 ", 0x40ade711, 0x145cea5c), |
| 736 | PCMCIA_DEVICE_PROD_ID12("intel", "SERIES2-04 ", 0x40ade711, 0x42064dda), |
| 737 | PCMCIA_DEVICE_PROD_ID12("intel", "SERIES2-20 ", 0x40ade711, 0x25ee5cb0), |
| 738 | PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8), |
| 739 | PCMCIA_DEVICE_PROD_ID12("KINGMAX TECHNOLOGY INC.", "SRAM 256K Bytes", 0x54d0c69c, 0xad12c29c), |
| 740 | PCMCIA_DEVICE_PROD_ID12("Maxtor", "MAXFL MobileMax Flash Memory Card", 0xb68968c8, 0x2dfb47b0), |
| 741 | PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b), |
| 742 | PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB513EN20", 0xf9876baf, 0xe8d884ad), |
| 743 | PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca), |
| 744 | PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944), |
| 745 | /* the following was commented out in pcmcia-cs-3.2.7 */ |
| 746 | /* PCMCIA_DEVICE_PROD_ID12("RATOC Systems,Inc.", "SmartMedia ADAPTER PC Card", 0xf4a2fefe, 0x5885b2ae), */ |
| 747 | #ifdef CONFIG_MTD_PCMCIA_ANONYMOUS |
| 748 | { .match_flags = PCMCIA_DEV_ID_MATCH_ANONYMOUS, }, |
| 749 | #endif |
| 750 | PCMCIA_DEVICE_NULL |
| 751 | }; |
| 752 | MODULE_DEVICE_TABLE(pcmcia, pcmciamtd_ids); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | |
| 754 | static struct pcmcia_driver pcmciamtd_driver = { |
| 755 | .drv = { |
| 756 | .name = "pcmciamtd" |
| 757 | }, |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 758 | .probe = pcmciamtd_probe, |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 759 | .remove = pcmciamtd_detach, |
Dominik Brodowski | 11d28a3 | 2005-06-27 16:28:32 -0700 | [diff] [blame] | 760 | .owner = THIS_MODULE, |
| 761 | .id_table = pcmciamtd_ids, |
Dominik Brodowski | 98e4c28 | 2005-11-14 21:21:18 +0100 | [diff] [blame] | 762 | .suspend = pcmciamtd_suspend, |
| 763 | .resume = pcmciamtd_resume, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | }; |
| 765 | |
| 766 | |
| 767 | static int __init init_pcmciamtd(void) |
| 768 | { |
Adrian Bunk | 59018b6 | 2008-05-20 01:03:52 +0300 | [diff] [blame] | 769 | info(DRIVER_DESC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | |
| 771 | if(bankwidth && bankwidth != 1 && bankwidth != 2) { |
| 772 | info("bad bankwidth (%d), using default", bankwidth); |
| 773 | bankwidth = 2; |
| 774 | } |
| 775 | if(force_size && (force_size < 1 || force_size > 64)) { |
| 776 | info("bad force_size (%d), using default", force_size); |
| 777 | force_size = 0; |
| 778 | } |
| 779 | if(mem_type && mem_type != 1 && mem_type != 2) { |
| 780 | info("bad mem_type (%d), using default", mem_type); |
| 781 | mem_type = 0; |
| 782 | } |
| 783 | return pcmcia_register_driver(&pcmciamtd_driver); |
| 784 | } |
| 785 | |
| 786 | |
| 787 | static void __exit exit_pcmciamtd(void) |
| 788 | { |
| 789 | DEBUG(1, DRIVER_DESC " unloading"); |
| 790 | pcmcia_unregister_driver(&pcmciamtd_driver); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | } |
| 792 | |
| 793 | module_init(init_pcmciamtd); |
| 794 | module_exit(exit_pcmciamtd); |