3 #include <linux/config.h>
4 #include <linux/module.h>
5 #include <linux/init.h>
7 #include <linux/wait.h>
8 #include <linux/timer.h>
9 #include <linux/skbuff.h>
10 #include <linux/netdevice.h>
11 #include <linux/workqueue.h>
12 #include <linux/wireless.h>
13 #include <net/iw_handler.h>
15 #include <pcmcia/cs_types.h>
16 #include <pcmcia/cs.h>
17 #include <pcmcia/cistpl.h>
18 #include <pcmcia/cisreg.h>
19 #include <pcmcia/ds.h>
23 #include "hostap_wlan.h"
26 static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)";
27 static dev_info_t dev_info = "hostap_cs";
28 static dev_link_t *dev_list = NULL;
30 MODULE_AUTHOR("Jouni Malinen");
31 MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
33 MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PC Card)");
34 MODULE_LICENSE("GPL");
35 MODULE_VERSION(PRISM2_VERSION);
38 static int ignore_cis_vcc;
39 module_param(ignore_cis_vcc, int, 0444);
40 MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
43 #ifdef PRISM2_IO_DEBUG
45 static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
47 struct hostap_interface *iface;
51 iface = netdev_priv(dev);
53 spin_lock_irqsave(&local->lock, flags);
54 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
55 outb(v, dev->base_addr + a);
56 spin_unlock_irqrestore(&local->lock, flags);
59 static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
61 struct hostap_interface *iface;
66 iface = netdev_priv(dev);
68 spin_lock_irqsave(&local->lock, flags);
69 v = inb(dev->base_addr + a);
70 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
71 spin_unlock_irqrestore(&local->lock, flags);
75 static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
77 struct hostap_interface *iface;
81 iface = netdev_priv(dev);
83 spin_lock_irqsave(&local->lock, flags);
84 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
85 outw(v, dev->base_addr + a);
86 spin_unlock_irqrestore(&local->lock, flags);
89 static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
91 struct hostap_interface *iface;
96 iface = netdev_priv(dev);
98 spin_lock_irqsave(&local->lock, flags);
99 v = inw(dev->base_addr + a);
100 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
101 spin_unlock_irqrestore(&local->lock, flags);
105 static inline void hfa384x_outsw_debug(struct net_device *dev, int a,
108 struct hostap_interface *iface;
112 iface = netdev_priv(dev);
113 local = iface->local;
114 spin_lock_irqsave(&local->lock, flags);
115 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTSW, a, wc);
116 outsw(dev->base_addr + a, buf, wc);
117 spin_unlock_irqrestore(&local->lock, flags);
120 static inline void hfa384x_insw_debug(struct net_device *dev, int a,
123 struct hostap_interface *iface;
127 iface = netdev_priv(dev);
128 local = iface->local;
129 spin_lock_irqsave(&local->lock, flags);
130 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INSW, a, wc);
131 insw(dev->base_addr + a, buf, wc);
132 spin_unlock_irqrestore(&local->lock, flags);
135 #define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v))
136 #define HFA384X_INB(a) hfa384x_inb_debug(dev, (a))
137 #define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v))
138 #define HFA384X_INW(a) hfa384x_inw_debug(dev, (a))
139 #define HFA384X_OUTSW(a, buf, wc) hfa384x_outsw_debug(dev, (a), (buf), (wc))
140 #define HFA384X_INSW(a, buf, wc) hfa384x_insw_debug(dev, (a), (buf), (wc))
142 #else /* PRISM2_IO_DEBUG */
144 #define HFA384X_OUTB(v,a) outb((v), dev->base_addr + (a))
145 #define HFA384X_INB(a) inb(dev->base_addr + (a))
146 #define HFA384X_OUTW(v,a) outw((v), dev->base_addr + (a))
147 #define HFA384X_INW(a) inw(dev->base_addr + (a))
148 #define HFA384X_INSW(a, buf, wc) insw(dev->base_addr + (a), buf, wc)
149 #define HFA384X_OUTSW(a, buf, wc) outsw(dev->base_addr + (a), buf, wc)
151 #endif /* PRISM2_IO_DEBUG */
154 static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
160 d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
164 HFA384X_INSW(d_off, buf, len / 2);
168 *((char *) pos) = HFA384X_INB(d_off);
174 static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
179 d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
183 HFA384X_OUTSW(d_off, buf, len / 2);
187 HFA384X_OUTB(*((char *) pos), d_off);
193 /* FIX: This might change at some point.. */
194 #include "hostap_hw.c"
198 static void prism2_detach(dev_link_t *link);
199 static void prism2_release(u_long arg);
200 static int prism2_event(event_t event, int priority,
201 event_callback_args_t *args);
204 static int prism2_pccard_card_present(local_info_t *local)
206 if (local->link != NULL &&
207 ((local->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
208 (DEV_PRESENT | DEV_CONFIG)))
215 * SanDisk CompactFlash WLAN Flashcard - Product Manual v1.0
216 * Document No. 20-10-00058, January 2004
217 * http://www.sandisk.com/pdf/industrial/ProdManualCFWLANv1.0.pdf
219 #define SANDISK_WLAN_ACTIVATION_OFF 0x40
220 #define SANDISK_HCR_OFF 0x42
223 static void sandisk_set_iobase(local_info_t *local)
229 reg.Action = CS_WRITE;
230 reg.Offset = 0x10; /* 0x3f0 IO base 1 */
231 reg.Value = local->link->io.BasePort1 & 0x00ff;
232 res = pcmcia_access_configuration_register(local->link->handle, ®);
233 if (res != CS_SUCCESS) {
234 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
240 reg.Action = CS_WRITE;
241 reg.Offset = 0x12; /* 0x3f2 IO base 2 */
242 reg.Value = (local->link->io.BasePort1 & 0xff00) >> 8;
243 res = pcmcia_access_configuration_register(local->link->handle, ®);
244 if (res != CS_SUCCESS) {
245 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
251 static void sandisk_write_hcr(local_info_t *local, int hcr)
253 struct net_device *dev = local->dev;
256 HFA384X_OUTB(0x80, SANDISK_WLAN_ACTIVATION_OFF);
258 for (i = 0; i < 10; i++) {
259 HFA384X_OUTB(hcr, SANDISK_HCR_OFF);
262 HFA384X_OUTB(0x45, SANDISK_WLAN_ACTIVATION_OFF);
266 static int sandisk_enable_wireless(struct net_device *dev)
270 struct hostap_interface *iface = dev->priv;
271 local_info_t *local = iface->local;
273 cisparse_t *parse = NULL;
276 if (local->link->io.NumPorts1 < 0x42) {
277 /* Not enough ports to be SanDisk multi-function card */
282 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
288 tuple.DesiredTuple = CISTPL_MANFID;
289 tuple.Attributes = TUPLE_RETURN_COMMON;
290 tuple.TupleData = buf;
291 tuple.TupleDataMax = sizeof(buf);
292 tuple.TupleOffset = 0;
293 if (pcmcia_get_first_tuple(local->link->handle, &tuple) ||
294 pcmcia_get_tuple_data(local->link->handle, &tuple) ||
295 pcmcia_parse_tuple(local->link->handle, &tuple, parse) ||
296 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
297 /* No SanDisk manfid found */
302 tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
303 if (pcmcia_get_first_tuple(local->link->handle, &tuple) ||
304 pcmcia_get_tuple_data(local->link->handle, &tuple) ||
305 pcmcia_parse_tuple(local->link->handle, &tuple, parse) ||
306 parse->longlink_mfc.nfn < 2) {
307 /* No multi-function links found */
312 printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected"
313 " - using vendor-specific initialization\n", dev->name);
314 local->sandisk_connectplus = 1;
317 reg.Action = CS_WRITE;
318 reg.Offset = CISREG_COR;
319 reg.Value = COR_SOFT_RESET;
320 res = pcmcia_access_configuration_register(local->link->handle, ®);
321 if (res != CS_SUCCESS) {
322 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
329 reg.Action = CS_WRITE;
330 reg.Offset = CISREG_COR;
332 * Do not enable interrupts here to avoid some bogus events. Interrupts
333 * will be enabled during the first cor_sreset call.
335 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA;
336 res = pcmcia_access_configuration_register(local->link->handle, ®);
337 if (res != CS_SUCCESS) {
338 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
344 sandisk_set_iobase(local);
346 HFA384X_OUTB(0xc5, SANDISK_WLAN_ACTIVATION_OFF);
348 HFA384X_OUTB(0x4b, SANDISK_WLAN_ACTIVATION_OFF);
357 static void prism2_pccard_cor_sreset(local_info_t *local)
362 if (!prism2_pccard_card_present(local))
366 reg.Action = CS_READ;
367 reg.Offset = CISREG_COR;
369 res = pcmcia_access_configuration_register(local->link->handle, ®);
370 if (res != CS_SUCCESS) {
371 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
375 printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n",
378 reg.Action = CS_WRITE;
379 reg.Value |= COR_SOFT_RESET;
380 res = pcmcia_access_configuration_register(local->link->handle, ®);
381 if (res != CS_SUCCESS) {
382 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
387 mdelay(local->sandisk_connectplus ? 5 : 2);
389 reg.Value &= ~COR_SOFT_RESET;
390 if (local->sandisk_connectplus)
391 reg.Value |= COR_IREQ_ENA;
392 res = pcmcia_access_configuration_register(local->link->handle, ®);
393 if (res != CS_SUCCESS) {
394 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
399 mdelay(local->sandisk_connectplus ? 5 : 2);
401 if (local->sandisk_connectplus)
402 sandisk_set_iobase(local);
406 static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
412 if (!prism2_pccard_card_present(local))
415 if (local->sandisk_connectplus) {
416 sandisk_write_hcr(local, hcr);
421 reg.Action = CS_READ;
422 reg.Offset = CISREG_COR;
424 res = pcmcia_access_configuration_register(local->link->handle, ®);
425 if (res != CS_SUCCESS) {
426 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
430 printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n",
434 reg.Action = CS_WRITE;
435 reg.Value |= COR_SOFT_RESET;
436 res = pcmcia_access_configuration_register(local->link->handle, ®);
437 if (res != CS_SUCCESS) {
438 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
445 /* Setup Genesis mode */
446 reg.Action = CS_WRITE;
448 reg.Offset = CISREG_CCSR;
449 res = pcmcia_access_configuration_register(local->link->handle, ®);
450 if (res != CS_SUCCESS) {
451 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
457 reg.Action = CS_WRITE;
458 reg.Offset = CISREG_COR;
459 reg.Value = old_cor & ~COR_SOFT_RESET;
460 res = pcmcia_access_configuration_register(local->link->handle, ®);
461 if (res != CS_SUCCESS) {
462 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
471 static int prism2_pccard_dev_open(local_info_t *local)
478 static int prism2_pccard_dev_close(local_info_t *local)
480 if (local == NULL || local->link == NULL)
483 if (!local->link->open) {
484 printk(KERN_WARNING "%s: prism2_pccard_dev_close(): "
485 "link not open?!\n", local->dev->name);
495 static struct prism2_helper_functions prism2_pccard_funcs =
497 .card_present = prism2_pccard_card_present,
498 .cor_sreset = prism2_pccard_cor_sreset,
499 .dev_open = prism2_pccard_dev_open,
500 .dev_close = prism2_pccard_dev_close,
501 .genesis_reset = prism2_pccard_genesis_reset,
502 .hw_type = HOSTAP_HW_PCCARD,
506 /* allocate local data and register with CardServices
507 * initialize dev_link structure, but do not configure the card yet */
508 static dev_link_t *prism2_attach(void)
511 client_reg_t client_reg;
514 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
518 memset(link, 0, sizeof(dev_link_t));
520 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
522 link->conf.IntType = INT_MEMORY_AND_IO;
524 /* register with CardServices */
525 link->next = dev_list;
527 client_reg.dev_info = &dev_info;
528 client_reg.Version = 0x0210;
529 client_reg.event_callback_args.client_data = link;
530 ret = pcmcia_register_client(&link->handle, &client_reg);
531 if (ret != CS_SUCCESS) {
532 cs_error(link->handle, RegisterClient, ret);
540 static void prism2_detach(dev_link_t *link)
544 PDEBUG(DEBUG_FLOW, "prism2_detach\n");
546 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
549 if (*linkp == NULL) {
550 printk(KERN_WARNING "%s: Attempt to detach non-existing "
551 "PCMCIA client\n", dev_info);
555 if (link->state & DEV_CONFIG) {
556 prism2_release((u_long)link);
560 int res = pcmcia_deregister_client(link->handle);
562 printk("CardService(DeregisterClient) => %d\n", res);
563 cs_error(link->handle, DeregisterClient, res);
568 /* release net devices */
570 prism2_free_local_data((struct net_device *) link->priv);
577 #define CS_CHECK(fn, ret) \
578 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
580 #define CFG_CHECK2(fn, retf) \
581 do { int ret = (retf); \
583 PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \
584 cs_error(link->handle, fn, ret); \
590 /* run after a CARD_INSERTION event is received to configure the PCMCIA
591 * socket and make the device available to the system */
592 static int prism2_config(dev_link_t *link)
594 struct net_device *dev;
595 struct hostap_interface *iface;
600 int last_fn, last_ret;
603 cistpl_cftable_entry_t dflt = { 0 };
605 PDEBUG(DEBUG_FLOW, "prism2_config()\n");
607 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
613 tuple.DesiredTuple = CISTPL_CONFIG;
614 tuple.Attributes = 0;
615 tuple.TupleData = buf;
616 tuple.TupleDataMax = sizeof(buf);
617 tuple.TupleOffset = 0;
618 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
619 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link->handle, &tuple));
620 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link->handle, &tuple, parse));
621 link->conf.ConfigBase = parse->config.base;
622 link->conf.Present = parse->config.rmask[0];
624 CS_CHECK(GetConfigurationInfo,
625 pcmcia_get_configuration_info(link->handle, &conf));
626 PDEBUG(DEBUG_HW, "%s: %s Vcc=%d (from config)\n", dev_info,
627 ignore_cis_vcc ? "ignoring" : "setting", conf.Vcc);
628 link->conf.Vcc = conf.Vcc;
630 /* Look for an appropriate configuration table entry in the CIS */
631 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
632 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
634 cistpl_cftable_entry_t *cfg = &(parse->cftable_entry);
635 CFG_CHECK2(GetTupleData,
636 pcmcia_get_tuple_data(link->handle, &tuple));
637 CFG_CHECK2(ParseTuple,
638 pcmcia_parse_tuple(link->handle, &tuple, parse));
640 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
644 link->conf.ConfigIndex = cfg->index;
645 PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
646 "(default 0x%02X)\n", cfg->index, dflt.index);
648 /* Does this card need audio output? */
649 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
650 link->conf.Attributes |= CONF_ENABLE_SPKR;
651 link->conf.Status = CCSR_AUDIO_ENA;
654 /* Use power settings for Vcc and Vpp if present */
655 /* Note that the CIS values need to be rescaled */
656 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
657 if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
658 10000 && !ignore_cis_vcc) {
659 PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping"
663 } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
664 if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] /
665 10000 && !ignore_cis_vcc) {
666 PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch "
667 "- skipping this entry\n");
672 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
673 link->conf.Vpp1 = link->conf.Vpp2 =
674 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
675 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
676 link->conf.Vpp1 = link->conf.Vpp2 =
677 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
679 /* Do we need to allocate an interrupt? */
680 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
681 link->conf.Attributes |= CONF_ENABLE_IRQ;
682 else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) {
683 /* At least Compaq WL200 does not have IRQInfo1 set,
684 * but it does not work without interrupts.. */
685 printk("Config has no IRQ info, but trying to enable "
687 link->conf.Attributes |= CONF_ENABLE_IRQ;
690 /* IO window settings */
691 PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
693 cfg->io.nwin, dflt.io.nwin);
694 link->io.NumPorts1 = link->io.NumPorts2 = 0;
695 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
696 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
697 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
698 PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "
699 "io.base=0x%04x, len=%d\n", io->flags,
700 io->win[0].base, io->win[0].len);
701 if (!(io->flags & CISTPL_IO_8BIT))
702 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
703 if (!(io->flags & CISTPL_IO_16BIT))
704 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
705 link->io.IOAddrLines = io->flags &
706 CISTPL_IO_LINES_MASK;
707 link->io.BasePort1 = io->win[0].base;
708 link->io.NumPorts1 = io->win[0].len;
710 link->io.Attributes2 = link->io.Attributes1;
711 link->io.BasePort2 = io->win[1].base;
712 link->io.NumPorts2 = io->win[1].len;
716 /* This reserves IO space but doesn't actually enable it */
717 CFG_CHECK2(RequestIO,
718 pcmcia_request_io(link->handle, &link->io));
720 /* This configuration table entry is OK */
724 CS_CHECK(GetNextTuple,
725 pcmcia_get_next_tuple(link->handle, &tuple));
728 /* Need to allocate net_device before requesting IRQ handler */
729 dev = prism2_init_local_data(&prism2_pccard_funcs, 0,
730 &handle_to_dev(link->handle));
736 * Allocate an interrupt line. Note that this does not assign a
737 * handler to the interrupt, unless the 'Handler' member of the
738 * irq structure is initialized.
740 if (link->conf.Attributes & CONF_ENABLE_IRQ) {
741 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
742 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
743 link->irq.Handler = prism2_interrupt;
744 link->irq.Instance = dev;
746 pcmcia_request_irq(link->handle, &link->irq));
750 * This actually configures the PCMCIA socket -- setting up
751 * the I/O windows and the interrupt mapping, and putting the
752 * card and host interface into "Memory and IO" mode.
754 CS_CHECK(RequestConfiguration,
755 pcmcia_request_configuration(link->handle, &link->conf));
757 dev->irq = link->irq.AssignedIRQ;
758 dev->base_addr = link->io.BasePort1;
760 /* Finally, report what we've done */
761 printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d",
762 dev_info, link->conf.ConfigIndex,
763 link->conf.Vcc / 10, link->conf.Vcc % 10);
765 printk(", Vpp %d.%d", link->conf.Vpp1 / 10,
766 link->conf.Vpp1 % 10);
767 if (link->conf.Attributes & CONF_ENABLE_IRQ)
768 printk(", irq %d", link->irq.AssignedIRQ);
769 if (link->io.NumPorts1)
770 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
771 link->io.BasePort1+link->io.NumPorts1-1);
772 if (link->io.NumPorts2)
773 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
774 link->io.BasePort2+link->io.NumPorts2-1);
777 link->state |= DEV_CONFIG;
778 link->state &= ~DEV_CONFIG_PENDING;
780 iface = netdev_priv(dev);
781 local = iface->local;
783 strcpy(local->node.dev_name, dev->name);
784 link->dev = &local->node;
788 sandisk_enable_wireless(dev);
790 ret = prism2_hw_config(dev, 1);
792 ret = hostap_hw_ready(dev);
793 if (ret == 0 && local->ddev)
794 strcpy(local->node.dev_name, local->ddev->name);
800 cs_error(link->handle, last_fn, last_ret);
804 prism2_release((u_long)link);
809 static void prism2_release(u_long arg)
811 dev_link_t *link = (dev_link_t *)arg;
813 PDEBUG(DEBUG_FLOW, "prism2_release\n");
816 struct net_device *dev = link->priv;
817 struct hostap_interface *iface;
819 iface = netdev_priv(dev);
820 if (link->state & DEV_CONFIG)
821 prism2_hw_shutdown(dev, 0);
822 iface->local->shutdown = 1;
826 pcmcia_release_window(link->win);
827 pcmcia_release_configuration(link->handle);
828 if (link->io.NumPorts1)
829 pcmcia_release_io(link->handle, &link->io);
830 if (link->irq.AssignedIRQ)
831 pcmcia_release_irq(link->handle, &link->irq);
833 link->state &= ~DEV_CONFIG;
835 PDEBUG(DEBUG_FLOW, "release - done\n");
839 static int prism2_event(event_t event, int priority,
840 event_callback_args_t *args)
842 dev_link_t *link = args->client_data;
843 struct net_device *dev = (struct net_device *) link->priv;
846 case CS_EVENT_CARD_INSERTION:
847 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info);
848 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
849 if (prism2_config(link)) {
850 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
854 case CS_EVENT_CARD_REMOVAL:
855 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_REMOVAL\n", dev_info);
856 link->state &= ~DEV_PRESENT;
857 if (link->state & DEV_CONFIG) {
858 netif_stop_queue(dev);
859 netif_device_detach(dev);
860 prism2_release((u_long) link);
864 case CS_EVENT_PM_SUSPEND:
865 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
866 link->state |= DEV_SUSPEND;
869 case CS_EVENT_RESET_PHYSICAL:
870 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_RESET_PHYSICAL\n", dev_info);
871 if (link->state & DEV_CONFIG) {
873 netif_stop_queue(dev);
874 netif_device_detach(dev);
877 pcmcia_release_configuration(link->handle);
881 case CS_EVENT_PM_RESUME:
882 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
883 link->state &= ~DEV_SUSPEND;
886 case CS_EVENT_CARD_RESET:
887 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_RESET\n", dev_info);
888 if (link->state & DEV_CONFIG) {
889 pcmcia_request_configuration(link->handle,
891 prism2_hw_shutdown(dev, 1);
892 prism2_hw_config(dev, link->open ? 0 : 1);
894 netif_device_attach(dev);
895 netif_start_queue(dev);
901 PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n",
909 static struct pcmcia_device_id hostap_cs_ids[] = {
910 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100),
911 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),
912 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777),
913 PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000),
914 PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),
915 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002),
916 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002),
917 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612),
918 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613),
919 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002),
920 PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002),
921 PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),
922 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),
923 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
924 PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000),
925 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
926 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
927 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
928 PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus",
929 0x7a954bd9, 0x74be00c6),
930 PCMCIA_DEVICE_PROD_ID1234(
931 "Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P",
933 0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e),
934 PCMCIA_DEVICE_PROD_ID123(
935 "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02",
936 0xe6ec52ce, 0x08649af2, 0x4b74baa0),
937 PCMCIA_DEVICE_PROD_ID123(
938 "D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02",
939 0x71b18589, 0xb6f1b0ab, 0x4b74baa0),
940 PCMCIA_DEVICE_PROD_ID123(
941 "Instant Wireless ", " Network PC CARD", "Version 01.02",
942 0x11d901af, 0x6e9bd926, 0x4b74baa0),
943 PCMCIA_DEVICE_PROD_ID123(
944 "SMC", "SMC2632W", "Version 01.02",
945 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0),
946 PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card",
947 0x54f7c49c, 0x15a75e5b),
948 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE",
949 0x74c5e40d, 0xdb472a18),
950 PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card",
951 0x0733cc81, 0x0c52f395),
952 PCMCIA_DEVICE_PROD_ID12(
953 "ZoomAir 11Mbps High", "Rate wireless Networking",
954 0x273fe3db, 0x32a1eaee),
957 MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);
960 static struct pcmcia_driver hostap_driver = {
964 .attach = prism2_attach,
965 .detach = prism2_detach,
966 .owner = THIS_MODULE,
967 .event = prism2_event,
968 .id_table = hostap_cs_ids,
971 static int __init init_prism2_pccard(void)
973 printk(KERN_INFO "%s: %s\n", dev_info, version);
974 return pcmcia_register_driver(&hostap_driver);
977 static void __exit exit_prism2_pccard(void)
979 pcmcia_unregister_driver(&hostap_driver);
980 printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
984 module_init(init_prism2_pccard);
985 module_exit(exit_prism2_pccard);