2 * $Id: pcmciamtd.c,v 1.51 2004/07/12 22:38:29 dwmw2 Exp $
4 * pcmciamtd.c - MTD driver for PCMCIA flash memory cards
6 * Author: Simon Evans <spse@secret.org.uk>
8 * Copyright (C) 2002 Simon Evans
14 #include <linux/module.h>
15 #include <linux/slab.h>
16 #include <linux/timer.h>
17 #include <linux/init.h>
19 #include <asm/system.h>
21 #include <pcmcia/cs_types.h>
22 #include <pcmcia/cs.h>
23 #include <pcmcia/cistpl.h>
24 #include <pcmcia/ds.h>
26 #include <linux/mtd/map.h>
27 #include <linux/mtd/mtd.h>
29 #ifdef CONFIG_MTD_DEBUG
30 static int debug = CONFIG_MTD_DEBUG_VERBOSE;
31 MODULE_PARM(debug, "i");
32 MODULE_PARM_DESC(debug, "Set Debug Level 0=quiet, 5=noisy");
34 #define DEBUG(n, format, arg...) \
36 printk(KERN_DEBUG __FILE__ ":%s(): " format "\n", __FUNCTION__ , ## arg); \
41 #define DEBUG(n, arg...)
42 static const int debug = 0;
45 #define err(format, arg...) printk(KERN_ERR "pcmciamtd: " format "\n" , ## arg)
46 #define info(format, arg...) printk(KERN_INFO "pcmciamtd: " format "\n" , ## arg)
47 #define warn(format, arg...) printk(KERN_WARNING "pcmciamtd: " format "\n" , ## arg)
50 #define DRIVER_DESC "PCMCIA Flash memory card driver"
51 #define DRIVER_VERSION "$Revision: 1.51 $"
53 /* Size of the PCMCIA address space: 26 bits = 64 MB */
54 #define MAX_PCMCIA_ADDR 0x4000000
56 struct pcmciamtd_dev {
57 dev_link_t link; /* PCMCIA link */
58 dev_node_t node; /* device node */
59 caddr_t win_base; /* ioremapped address of PCMCIA window */
60 unsigned int win_size; /* size of window */
61 unsigned int offset; /* offset into card the window currently points at */
62 struct map_info pcmcia_map;
63 struct mtd_info *mtd_info;
65 char mtd_name[sizeof(struct cistpl_vers_1_t)];
69 static dev_info_t dev_info = "pcmciamtd";
70 static dev_link_t *dev_list;
72 /* Module parameters */
74 /* 2 = do 16-bit transfers, 1 = do 8-bit transfers */
75 static int bankwidth = 2;
77 /* Speed of memory accesses, in ns */
80 /* Force the size of an SRAM card */
81 static int force_size;
89 /* Force card to be treated as FLASH, ROM or RAM */
92 MODULE_LICENSE("GPL");
93 MODULE_AUTHOR("Simon Evans <spse@secret.org.uk>");
94 MODULE_DESCRIPTION(DRIVER_DESC);
95 MODULE_PARM(bankwidth, "i");
96 MODULE_PARM_DESC(bankwidth, "Set bankwidth (1=8 bit, 2=16 bit, default=2)");
97 MODULE_PARM(mem_speed, "i");
98 MODULE_PARM_DESC(mem_speed, "Set memory access speed in ns");
99 MODULE_PARM(force_size, "i");
100 MODULE_PARM_DESC(force_size, "Force size of card in MiB (1-64)");
101 MODULE_PARM(setvpp, "i");
102 MODULE_PARM_DESC(setvpp, "Set Vpp (0=Never, 1=On writes, 2=Always on, default=0)");
103 MODULE_PARM(vpp, "i");
104 MODULE_PARM_DESC(vpp, "Vpp value in 1/10ths eg 33=3.3V 120=12V (Dangerous)");
105 MODULE_PARM(mem_type, "i");
106 MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)");
109 /* read/write{8,16} copy_{from,to} routines with window remapping to access whole card */
110 static caddr_t remap_window(struct map_info *map, unsigned long to)
112 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
113 window_handle_t win = (window_handle_t)map->map_priv_2;
117 if(!(dev->link.state & DEV_PRESENT)) {
118 DEBUG(1, "device removed state = 0x%4.4X", dev->link.state);
122 mrq.CardOffset = to & ~(dev->win_size-1);
123 if(mrq.CardOffset != dev->offset) {
124 DEBUG(2, "Remapping window from 0x%8.8x to 0x%8.8x",
125 dev->offset, mrq.CardOffset);
127 if( (ret = pcmcia_map_mem_page(win, &mrq)) != CS_SUCCESS) {
128 cs_error(dev->link.handle, MapMemPage, ret);
131 dev->offset = mrq.CardOffset;
133 return dev->win_base + (to & (dev->win_size-1));
137 static map_word pcmcia_read8_remap(struct map_info *map, unsigned long ofs)
142 addr = remap_window(map, ofs);
146 d.x[0] = readb(addr);
147 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, addr, d.x[0]);
152 static map_word pcmcia_read16_remap(struct map_info *map, unsigned long ofs)
157 addr = remap_window(map, ofs);
161 d.x[0] = readw(addr);
162 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, addr, d.x[0]);
167 static void pcmcia_copy_from_remap(struct map_info *map, void *to, unsigned long from, ssize_t len)
169 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
170 unsigned long win_size = dev->win_size;
172 DEBUG(3, "to = %p from = %lu len = %u", to, from, len);
174 int toread = win_size - (from & (win_size-1));
180 addr = remap_window(map, from);
184 DEBUG(4, "memcpy from %p to %p len = %d", addr, to, toread);
185 memcpy_fromio(to, addr, toread);
193 static void pcmcia_write8_remap(struct map_info *map, map_word d, unsigned long adr)
195 caddr_t addr = remap_window(map, adr);
200 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, addr, d.x[0]);
201 writeb(d.x[0], addr);
205 static void pcmcia_write16_remap(struct map_info *map, map_word d, unsigned long adr)
207 caddr_t addr = remap_window(map, adr);
211 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, addr, d.x[0]);
212 writew(d.x[0], addr);
216 static void pcmcia_copy_to_remap(struct map_info *map, unsigned long to, const void *from, ssize_t len)
218 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
219 unsigned long win_size = dev->win_size;
221 DEBUG(3, "to = %lu from = %p len = %u", to, from, len);
223 int towrite = win_size - (to & (win_size-1));
229 addr = remap_window(map, to);
233 DEBUG(4, "memcpy from %p to %p len = %d", from, addr, towrite);
234 memcpy_toio(addr, from, towrite);
242 /* read/write{8,16} copy_{from,to} routines with direct access */
244 #define DEV_REMOVED(x) (!(*(u_int *)x->map_priv_1 & DEV_PRESENT))
246 static map_word pcmcia_read8(struct map_info *map, unsigned long ofs)
248 caddr_t win_base = (caddr_t)map->map_priv_2;
254 d.x[0] = readb(win_base + ofs);
255 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, win_base + ofs, d.x[0]);
260 static map_word pcmcia_read16(struct map_info *map, unsigned long ofs)
262 caddr_t win_base = (caddr_t)map->map_priv_2;
268 d.x[0] = readw(win_base + ofs);
269 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, win_base + ofs, d.x[0]);
274 static void pcmcia_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
276 caddr_t win_base = (caddr_t)map->map_priv_2;
281 DEBUG(3, "to = %p from = %lu len = %u", to, from, len);
282 memcpy_fromio(to, win_base + from, len);
286 static void pcmcia_write8(struct map_info *map, u8 d, unsigned long adr)
288 caddr_t win_base = (caddr_t)map->map_priv_2;
293 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, win_base + adr, d);
294 writeb(d, win_base + adr);
298 static void pcmcia_write16(struct map_info *map, u16 d, unsigned long adr)
300 caddr_t win_base = (caddr_t)map->map_priv_2;
305 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, win_base + adr, d);
306 writew(d, win_base + adr);
310 static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
312 caddr_t win_base = (caddr_t)map->map_priv_2;
317 DEBUG(3, "to = %lu from = %p len = %u", to, from, len);
318 memcpy_toio(win_base + to, from, len);
322 static void pcmciamtd_set_vpp(struct map_info *map, int on)
324 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
325 dev_link_t *link = &dev->link;
329 mod.Attributes = CONF_VPP1_CHANGE_VALID | CONF_VPP2_CHANGE_VALID;
331 mod.Vpp1 = mod.Vpp2 = on ? dev->vpp : 0;
333 DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp);
334 ret = pcmcia_modify_configuration(link->handle, &mod);
335 if(ret != CS_SUCCESS) {
336 cs_error(link->handle, ModifyConfiguration, ret);
341 /* After a card is removed, pcmciamtd_release() will unregister the
342 * device, and release the PCMCIA configuration. If the device is
343 * still open, this will be postponed until it is closed.
346 static void pcmciamtd_release(dev_link_t *link)
348 struct pcmciamtd_dev *dev = link->priv;
350 DEBUG(3, "link = 0x%p", link);
354 iounmap(dev->win_base);
355 dev->win_base = NULL;
357 pcmcia_release_window(link->win);
359 pcmcia_release_configuration(link->handle);
360 link->state &= ~DEV_CONFIG;
364 static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_name)
371 tuple.Attributes = 0;
372 tuple.TupleData = (cisdata_t *)buf;
373 tuple.TupleDataMax = sizeof(buf);
374 tuple.TupleOffset = 0;
375 tuple.DesiredTuple = RETURN_FIRST_TUPLE;
377 rc = pcmcia_get_first_tuple(link->handle, &tuple);
378 while(rc == CS_SUCCESS) {
379 rc = pcmcia_get_tuple_data(link->handle, &tuple);
380 if(rc != CS_SUCCESS) {
381 cs_error(link->handle, GetTupleData, rc);
384 rc = pcmcia_parse_tuple(link->handle, &tuple, &parse);
385 if(rc != CS_SUCCESS) {
386 cs_error(link->handle, ParseTuple, rc);
390 switch(tuple.TupleCode) {
391 case CISTPL_FORMAT: {
392 cistpl_format_t *t = &parse.format;
393 (void)t; /* Shut up, gcc */
394 DEBUG(2, "Format type: %u, Error Detection: %u, offset = %u, length =%u",
395 t->type, t->edc, t->offset, t->length);
400 case CISTPL_DEVICE: {
401 cistpl_device_t *t = &parse.device;
403 DEBUG(2, "Common memory:");
404 dev->pcmcia_map.size = t->dev[0].size;
405 for(i = 0; i < t->ndev; i++) {
406 DEBUG(2, "Region %d, type = %u", i, t->dev[i].type);
407 DEBUG(2, "Region %d, wp = %u", i, t->dev[i].wp);
408 DEBUG(2, "Region %d, speed = %u ns", i, t->dev[i].speed);
409 DEBUG(2, "Region %d, size = %u bytes", i, t->dev[i].size);
414 case CISTPL_VERS_1: {
415 cistpl_vers_1_t *t = &parse.version_1;
418 dev->mtd_name[0] = '\0';
419 for(i = 0; i < t->ns; i++) {
421 strcat(dev->mtd_name, " ");
422 strcat(dev->mtd_name, t->str+t->ofs[i]);
425 DEBUG(2, "Found name: %s", dev->mtd_name);
429 case CISTPL_JEDEC_C: {
430 cistpl_jedec_t *t = &parse.jedec;
432 for(i = 0; i < t->nid; i++) {
433 DEBUG(2, "JEDEC: 0x%02x 0x%02x", t->id[i].mfr, t->id[i].info);
438 case CISTPL_DEVICE_GEO: {
439 cistpl_device_geo_t *t = &parse.device_geo;
441 dev->pcmcia_map.bankwidth = t->geo[0].buswidth;
442 for(i = 0; i < t->ngeo; i++) {
443 DEBUG(2, "region: %d bankwidth = %u", i, t->geo[i].buswidth);
444 DEBUG(2, "region: %d erase_block = %u", i, t->geo[i].erase_block);
445 DEBUG(2, "region: %d read_block = %u", i, t->geo[i].read_block);
446 DEBUG(2, "region: %d write_block = %u", i, t->geo[i].write_block);
447 DEBUG(2, "region: %d partition = %u", i, t->geo[i].partition);
448 DEBUG(2, "region: %d interleave = %u", i, t->geo[i].interleave);
454 DEBUG(2, "Unknown tuple code %d", tuple.TupleCode);
457 rc = pcmcia_get_next_tuple(link->handle, &tuple);
459 if(!dev->pcmcia_map.size)
460 dev->pcmcia_map.size = MAX_PCMCIA_ADDR;
462 if(!dev->pcmcia_map.bankwidth)
463 dev->pcmcia_map.bankwidth = 2;
466 dev->pcmcia_map.size = force_size << 20;
467 DEBUG(2, "size forced to %dM", force_size);
471 dev->pcmcia_map.bankwidth = bankwidth;
472 DEBUG(2, "bankwidth forced to %d", bankwidth);
475 dev->pcmcia_map.name = dev->mtd_name;
476 if(!dev->mtd_name[0]) {
477 strcpy(dev->mtd_name, "PCMCIA Memory card");
481 DEBUG(1, "Device: Size: %lu Width:%d Name: %s",
482 dev->pcmcia_map.size, dev->pcmcia_map.bankwidth << 3, dev->mtd_name);
486 /* pcmciamtd_config() is scheduled to run after a CARD_INSERTION event
487 * is received, to configure the PCMCIA socket, and to make the
488 * MTD device available to the system.
491 #define CS_CHECK(fn, ret) \
492 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
494 static void pcmciamtd_config(dev_link_t *link)
496 struct pcmciamtd_dev *dev = link->priv;
497 struct mtd_info *mtd = NULL;
500 int last_ret = 0, last_fn = 0;
504 static char *probes[] = { "jedec_probe", "cfi_probe" };
508 DEBUG(3, "link=0x%p", link);
511 link->state |= DEV_CONFIG;
513 DEBUG(2, "Validating CIS");
514 ret = pcmcia_validate_cis(link->handle, &cisinfo);
515 if(ret != CS_SUCCESS) {
516 cs_error(link->handle, GetTupleData, ret);
518 DEBUG(2, "ValidateCIS found %d chains", cisinfo.Chains);
521 card_settings(dev, link, &new_name);
523 dev->pcmcia_map.phys = NO_XIP;
524 dev->pcmcia_map.copy_from = pcmcia_copy_from_remap;
525 dev->pcmcia_map.copy_to = pcmcia_copy_to_remap;
526 if (dev->pcmcia_map.bankwidth == 1) {
527 dev->pcmcia_map.read = pcmcia_read8_remap;
528 dev->pcmcia_map.write = pcmcia_write8_remap;
530 dev->pcmcia_map.read = pcmcia_read16_remap;
531 dev->pcmcia_map.write = pcmcia_write16_remap;
534 dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp;
536 /* Request a memory window for PCMCIA. Some architeures can map windows upto the maximum
537 that PCMCIA can support (64MiB) - this is ideal and we aim for a window the size of the
538 whole card - otherwise we try smaller windows until we succeed */
540 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE;
541 req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16;
543 req.AccessSpeed = mem_speed;
544 link->win = (window_handle_t)link->handle;
545 req.Size = (force_size) ? force_size << 20 : MAX_PCMCIA_ADDR;
550 DEBUG(2, "requesting window with size = %dKiB memspeed = %d",
551 req.Size >> 10, req.AccessSpeed);
552 ret = pcmcia_request_window(&link->handle, &req, &link->win);
553 DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size);
557 DEBUG(2, "Got window of size %dKiB", req.Size >> 10);
558 dev->win_size = req.Size;
561 } while(req.Size >= 0x1000);
563 DEBUG(2, "dev->win_size = %d", dev->win_size);
566 err("Cant allocate memory window");
567 pcmciamtd_release(link);
570 DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10);
572 /* Get write protect status */
573 CS_CHECK(GetStatus, pcmcia_get_status(link->handle, &status));
574 DEBUG(2, "status value: 0x%x window handle = 0x%8.8lx",
575 status.CardState, (unsigned long)link->win);
576 dev->win_base = ioremap(req.Base, req.Size);
578 err("ioremap(%lu, %u) failed", req.Base, req.Size);
579 pcmciamtd_release(link);
582 DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x",
583 dev, req.Base, dev->win_base, req.Size);
586 dev->pcmcia_map.map_priv_1 = (unsigned long)dev;
587 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win;
589 DEBUG(2, "Getting configuration");
590 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link->handle, &t));
591 DEBUG(2, "Vcc = %d Vpp1 = %d Vpp2 = %d", t.Vcc, t.Vpp1, t.Vpp2);
592 dev->vpp = (vpp) ? vpp : t.Vpp1;
593 link->conf.Attributes = 0;
594 link->conf.Vcc = t.Vcc;
596 link->conf.Vpp1 = dev->vpp;
597 link->conf.Vpp2 = dev->vpp;
603 link->conf.IntType = INT_MEMORY;
604 link->conf.ConfigBase = t.ConfigBase;
605 link->conf.Status = t.Status;
606 link->conf.Pin = t.Pin;
607 link->conf.Copy = t.Copy;
608 link->conf.ExtStatus = t.ExtStatus;
609 link->conf.ConfigIndex = 0;
610 link->conf.Present = t.Present;
611 DEBUG(2, "Setting Configuration");
612 ret = pcmcia_request_configuration(link->handle, &link->conf);
613 if(ret != CS_SUCCESS) {
614 cs_error(link->handle, RequestConfiguration, ret);
618 mtd = do_map_probe("map_ram", &dev->pcmcia_map);
619 } else if(mem_type == 2) {
620 mtd = do_map_probe("map_rom", &dev->pcmcia_map);
622 for(i = 0; i < sizeof(probes) / sizeof(char *); i++) {
623 DEBUG(1, "Trying %s", probes[i]);
624 mtd = do_map_probe(probes[i], &dev->pcmcia_map);
628 DEBUG(1, "FAILED: %s", probes[i]);
633 DEBUG(1, "Cant find an MTD");
634 pcmciamtd_release(link);
639 mtd->owner = THIS_MODULE;
644 /* Since we are using a default name, make it better by adding in the
646 if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */
647 size = mtd->size >> 10;
650 size = mtd->size >> 20;
653 snprintf(dev->mtd_name, sizeof(dev->mtd_name), "%d%ciB %s", size, unit, "PCMCIA Memory card");
656 /* If the memory found is fits completely into the mapped PCMCIA window,
657 use the faster non-remapping read/write functions */
658 if(mtd->size <= dev->win_size) {
659 DEBUG(1, "Using non remapping memory functions");
660 dev->pcmcia_map.map_priv_1 = (unsigned long)&(dev->link.state);
661 dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base;
662 if (dev->pcmcia_map.bankwidth == 1) {
663 dev->pcmcia_map.read = pcmcia_read8;
664 dev->pcmcia_map.write = pcmcia_write8;
666 dev->pcmcia_map.read = pcmcia_read16;
667 dev->pcmcia_map.write = pcmcia_write16;
669 dev->pcmcia_map.copy_from = pcmcia_copy_from;
670 dev->pcmcia_map.copy_to = pcmcia_copy_to;
673 if(add_mtd_device(mtd)) {
675 dev->mtd_info = NULL;
676 err("Couldnt register MTD device");
677 pcmciamtd_release(link);
680 snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index);
681 info("mtd%d: %s", mtd->index, mtd->name);
682 link->state &= ~DEV_CONFIG_PENDING;
683 link->dev = &dev->node;
687 cs_error(link->handle, last_fn, last_ret);
688 err("CS Error, exiting");
689 pcmciamtd_release(link);
694 /* The card status event handler. Mostly, this schedules other
695 * stuff to run after an event is received. A CARD_REMOVAL event
696 * also sets some flags to discourage the driver from trying
697 * to talk to the card any more.
700 static int pcmciamtd_event(event_t event, int priority,
701 event_callback_args_t *args)
703 dev_link_t *link = args->client_data;
705 DEBUG(1, "event=0x%06x", event);
707 case CS_EVENT_CARD_REMOVAL:
708 DEBUG(2, "EVENT_CARD_REMOVAL");
709 link->state &= ~DEV_PRESENT;
710 if (link->state & DEV_CONFIG) {
711 struct pcmciamtd_dev *dev = link->priv;
713 del_mtd_device(dev->mtd_info);
714 info("mtd%d: Removed", dev->mtd_info->index);
716 pcmciamtd_release(link);
719 case CS_EVENT_CARD_INSERTION:
720 DEBUG(2, "EVENT_CARD_INSERTION");
721 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
722 pcmciamtd_config(link);
724 case CS_EVENT_PM_SUSPEND:
725 DEBUG(2, "EVENT_PM_SUSPEND");
726 link->state |= DEV_SUSPEND;
727 /* Fall through... */
728 case CS_EVENT_RESET_PHYSICAL:
729 DEBUG(2, "EVENT_RESET_PHYSICAL");
730 /* get_lock(link); */
732 case CS_EVENT_PM_RESUME:
733 DEBUG(2, "EVENT_PM_RESUME");
734 link->state &= ~DEV_SUSPEND;
735 /* Fall through... */
736 case CS_EVENT_CARD_RESET:
737 DEBUG(2, "EVENT_CARD_RESET");
738 /* free_lock(link); */
741 DEBUG(2, "Unknown event %d", event);
747 /* This deletes a driver "instance". The device is de-registered
748 * with Card Services. If it has been released, all local data
749 * structures are freed. Otherwise, the structures will be freed
750 * when the device is released.
753 static void pcmciamtd_detach(dev_link_t *link)
755 DEBUG(3, "link=0x%p", link);
757 if(link->state & DEV_CONFIG) {
758 pcmciamtd_release(link);
763 DEBUG(2, "Deregistering with card services");
764 ret = pcmcia_deregister_client(link->handle);
765 if (ret != CS_SUCCESS)
766 cs_error(link->handle, DeregisterClient, ret);
769 link->state |= DEV_STALE_LINK;
773 /* pcmciamtd_attach() creates an "instance" of the driver, allocating
774 * local data structures for one device. The device is registered
775 * with Card Services.
778 static dev_link_t *pcmciamtd_attach(void)
780 struct pcmciamtd_dev *dev;
782 client_reg_t client_reg;
785 /* Create new memory card device */
786 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
787 if (!dev) return NULL;
788 DEBUG(1, "dev=0x%p", dev);
790 memset(dev, 0, sizeof(*dev));
794 link->conf.Attributes = 0;
795 link->conf.IntType = INT_MEMORY;
797 link->next = dev_list;
800 /* Register with Card Services */
801 client_reg.dev_info = &dev_info;
802 client_reg.Version = 0x0210;
803 client_reg.event_callback_args.client_data = link;
804 DEBUG(2, "Calling RegisterClient");
805 ret = pcmcia_register_client(&link->handle, &client_reg);
807 cs_error(link->handle, RegisterClient, ret);
808 pcmciamtd_detach(link);
811 DEBUG(2, "link = %p", link);
815 static struct pcmcia_device_id pcmciamtd_ids[] = {
816 PCMCIA_DEVICE_FUNC_ID(1),
817 PCMCIA_DEVICE_PROD_ID123("IO DATA", "PCS-2M", "2MB SRAM", 0x547e66dc, 0x1fed36cd, 0x36eadd21),
818 PCMCIA_DEVICE_PROD_ID12("IBM", "2MB SRAM", 0xb569a6e5, 0x36eadd21),
819 PCMCIA_DEVICE_PROD_ID12("IBM", "4MB FLASH", 0xb569a6e5, 0x8bc54d2a),
820 PCMCIA_DEVICE_PROD_ID12("IBM", "8MB FLASH", 0xb569a6e5, 0x6df1be3e),
821 PCMCIA_DEVICE_PROD_ID12("Intel", "S2E20SW", 0x816cc815, 0xd14c9dcf),
822 PCMCIA_DEVICE_PROD_ID12("Intel", "S2E8 SW", 0x816cc815, 0xa2d7dedb),
823 PCMCIA_DEVICE_PROD_ID12("intel", "SERIES2-02 ", 0x40ade711, 0x145cea5c),
824 PCMCIA_DEVICE_PROD_ID12("intel", "SERIES2-04 ", 0x40ade711, 0x42064dda),
825 PCMCIA_DEVICE_PROD_ID12("intel", "SERIES2-20 ", 0x40ade711, 0x25ee5cb0),
826 PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8),
827 PCMCIA_DEVICE_PROD_ID12("KINGMAX TECHNOLOGY INC.", "SRAM 256K Bytes", 0x54d0c69c, 0xad12c29c),
828 PCMCIA_DEVICE_PROD_ID12("Maxtor", "MAXFL MobileMax Flash Memory Card", 0xb68968c8, 0x2dfb47b0),
829 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b),
830 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB513EN20", 0xf9876baf, 0xe8d884ad),
831 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca),
832 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944),
833 /* the following was commented out in pcmcia-cs-3.2.7 */
834 /* PCMCIA_DEVICE_PROD_ID12("RATOC Systems,Inc.", "SmartMedia ADAPTER PC Card", 0xf4a2fefe, 0x5885b2ae), */
835 #ifdef CONFIG_MTD_PCMCIA_ANONYMOUS
836 { .match_flags = PCMCIA_DEV_ID_MATCH_ANONYMOUS, },
840 MODULE_DEVICE_TABLE(pcmcia, pcmciamtd_ids);
842 static struct pcmcia_driver pcmciamtd_driver = {
846 .attach = pcmciamtd_attach,
847 .event = pcmciamtd_event,
848 .detach = pcmciamtd_detach,
849 .owner = THIS_MODULE,
850 .id_table = pcmciamtd_ids,
854 static int __init init_pcmciamtd(void)
856 info(DRIVER_DESC " " DRIVER_VERSION);
858 if(bankwidth && bankwidth != 1 && bankwidth != 2) {
859 info("bad bankwidth (%d), using default", bankwidth);
862 if(force_size && (force_size < 1 || force_size > 64)) {
863 info("bad force_size (%d), using default", force_size);
866 if(mem_type && mem_type != 1 && mem_type != 2) {
867 info("bad mem_type (%d), using default", mem_type);
870 return pcmcia_register_driver(&pcmciamtd_driver);
874 static void __exit exit_pcmciamtd(void)
876 DEBUG(1, DRIVER_DESC " unloading");
877 pcmcia_unregister_driver(&pcmciamtd_driver);
878 BUG_ON(dev_list != NULL);
881 module_init(init_pcmciamtd);
882 module_exit(exit_pcmciamtd);