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");
37 static int irq_mask = 0xdeb8;
38 module_param(irq_mask, int, 0444);
40 static int irq_list[4] = { -1 };
41 module_param_array(irq_list, int, NULL, 0444);
43 static int ignore_cis_vcc;
44 module_param(ignore_cis_vcc, int, 0444);
45 MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
48 #ifdef PRISM2_IO_DEBUG
50 static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
52 struct hostap_interface *iface;
56 iface = netdev_priv(dev);
58 spin_lock_irqsave(&local->lock, flags);
59 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
60 outb(v, dev->base_addr + a);
61 spin_unlock_irqrestore(&local->lock, flags);
64 static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
66 struct hostap_interface *iface;
71 iface = netdev_priv(dev);
73 spin_lock_irqsave(&local->lock, flags);
74 v = inb(dev->base_addr + a);
75 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
76 spin_unlock_irqrestore(&local->lock, flags);
80 static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
82 struct hostap_interface *iface;
86 iface = netdev_priv(dev);
88 spin_lock_irqsave(&local->lock, flags);
89 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
90 outw(v, dev->base_addr + a);
91 spin_unlock_irqrestore(&local->lock, flags);
94 static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
96 struct hostap_interface *iface;
101 iface = netdev_priv(dev);
102 local = iface->local;
103 spin_lock_irqsave(&local->lock, flags);
104 v = inw(dev->base_addr + a);
105 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
106 spin_unlock_irqrestore(&local->lock, flags);
110 static inline void hfa384x_outsw_debug(struct net_device *dev, int a,
113 struct hostap_interface *iface;
117 iface = netdev_priv(dev);
118 local = iface->local;
119 spin_lock_irqsave(&local->lock, flags);
120 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTSW, a, wc);
121 outsw(dev->base_addr + a, buf, wc);
122 spin_unlock_irqrestore(&local->lock, flags);
125 static inline void hfa384x_insw_debug(struct net_device *dev, int a,
128 struct hostap_interface *iface;
132 iface = netdev_priv(dev);
133 local = iface->local;
134 spin_lock_irqsave(&local->lock, flags);
135 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INSW, a, wc);
136 insw(dev->base_addr + a, buf, wc);
137 spin_unlock_irqrestore(&local->lock, flags);
140 #define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v))
141 #define HFA384X_INB(a) hfa384x_inb_debug(dev, (a))
142 #define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v))
143 #define HFA384X_INW(a) hfa384x_inw_debug(dev, (a))
144 #define HFA384X_OUTSW(a, buf, wc) hfa384x_outsw_debug(dev, (a), (buf), (wc))
145 #define HFA384X_INSW(a, buf, wc) hfa384x_insw_debug(dev, (a), (buf), (wc))
147 #else /* PRISM2_IO_DEBUG */
149 #define HFA384X_OUTB(v,a) outb((v), dev->base_addr + (a))
150 #define HFA384X_INB(a) inb(dev->base_addr + (a))
151 #define HFA384X_OUTW(v,a) outw((v), dev->base_addr + (a))
152 #define HFA384X_INW(a) inw(dev->base_addr + (a))
153 #define HFA384X_INSW(a, buf, wc) insw(dev->base_addr + (a), buf, wc)
154 #define HFA384X_OUTSW(a, buf, wc) outsw(dev->base_addr + (a), buf, wc)
156 #endif /* PRISM2_IO_DEBUG */
159 static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
165 d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
169 HFA384X_INSW(d_off, buf, len / 2);
173 *((char *) pos) = HFA384X_INB(d_off);
179 static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
184 d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
188 HFA384X_OUTSW(d_off, buf, len / 2);
192 HFA384X_OUTB(*((char *) pos), d_off);
198 /* FIX: This might change at some point.. */
199 #include "hostap_hw.c"
203 static void prism2_detach(dev_link_t *link);
204 static void prism2_release(u_long arg);
205 static int prism2_event(event_t event, int priority,
206 event_callback_args_t *args);
209 static int prism2_pccard_card_present(local_info_t *local)
211 if (local->link != NULL &&
212 ((local->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
213 (DEV_PRESENT | DEV_CONFIG)))
220 * SanDisk CompactFlash WLAN Flashcard - Product Manual v1.0
221 * Document No. 20-10-00058, January 2004
222 * http://www.sandisk.com/pdf/industrial/ProdManualCFWLANv1.0.pdf
224 #define SANDISK_WLAN_ACTIVATION_OFF 0x40
225 #define SANDISK_HCR_OFF 0x42
228 static void sandisk_set_iobase(local_info_t *local)
234 reg.Action = CS_WRITE;
235 reg.Offset = 0x10; /* 0x3f0 IO base 1 */
236 reg.Value = local->link->io.BasePort1 & 0x00ff;
237 res = pcmcia_access_configuration_register(local->link->handle, ®);
238 if (res != CS_SUCCESS) {
239 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
245 reg.Action = CS_WRITE;
246 reg.Offset = 0x12; /* 0x3f2 IO base 2 */
247 reg.Value = (local->link->io.BasePort1 & 0xff00) >> 8;
248 res = pcmcia_access_configuration_register(local->link->handle, ®);
249 if (res != CS_SUCCESS) {
250 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
256 static void sandisk_write_hcr(local_info_t *local, int hcr)
258 struct net_device *dev = local->dev;
261 HFA384X_OUTB(0x80, SANDISK_WLAN_ACTIVATION_OFF);
263 for (i = 0; i < 10; i++) {
264 HFA384X_OUTB(hcr, SANDISK_HCR_OFF);
267 HFA384X_OUTB(0x45, SANDISK_WLAN_ACTIVATION_OFF);
271 static int sandisk_enable_wireless(struct net_device *dev)
275 struct hostap_interface *iface = dev->priv;
276 local_info_t *local = iface->local;
278 cisparse_t *parse = NULL;
281 if (local->link->io.NumPorts1 < 0x42) {
282 /* Not enough ports to be SanDisk multi-function card */
287 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
293 tuple.DesiredTuple = CISTPL_MANFID;
294 tuple.Attributes = TUPLE_RETURN_COMMON;
295 tuple.TupleData = buf;
296 tuple.TupleDataMax = sizeof(buf);
297 tuple.TupleOffset = 0;
298 if (pcmcia_get_first_tuple(local->link->handle, &tuple) ||
299 pcmcia_get_tuple_data(local->link->handle, &tuple) ||
300 pcmcia_parse_tuple(local->link->handle, &tuple, parse) ||
301 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
302 /* No SanDisk manfid found */
307 tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
308 if (pcmcia_get_first_tuple(local->link->handle, &tuple) ||
309 pcmcia_get_tuple_data(local->link->handle, &tuple) ||
310 pcmcia_parse_tuple(local->link->handle, &tuple, parse) ||
311 parse->longlink_mfc.nfn < 2) {
312 /* No multi-function links found */
317 printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected"
318 " - using vendor-specific initialization\n", dev->name);
319 local->sandisk_connectplus = 1;
322 reg.Action = CS_WRITE;
323 reg.Offset = CISREG_COR;
324 reg.Value = COR_SOFT_RESET;
325 res = pcmcia_access_configuration_register(local->link->handle, ®);
326 if (res != CS_SUCCESS) {
327 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
334 reg.Action = CS_WRITE;
335 reg.Offset = CISREG_COR;
337 * Do not enable interrupts here to avoid some bogus events. Interrupts
338 * will be enabled during the first cor_sreset call.
340 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA;
341 res = pcmcia_access_configuration_register(local->link->handle, ®);
342 if (res != CS_SUCCESS) {
343 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
349 sandisk_set_iobase(local);
351 HFA384X_OUTB(0xc5, SANDISK_WLAN_ACTIVATION_OFF);
353 HFA384X_OUTB(0x4b, SANDISK_WLAN_ACTIVATION_OFF);
362 static void prism2_pccard_cor_sreset(local_info_t *local)
367 if (!prism2_pccard_card_present(local))
371 reg.Action = CS_READ;
372 reg.Offset = CISREG_COR;
374 res = pcmcia_access_configuration_register(local->link->handle, ®);
375 if (res != CS_SUCCESS) {
376 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
380 printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n",
383 reg.Action = CS_WRITE;
384 reg.Value |= COR_SOFT_RESET;
385 res = pcmcia_access_configuration_register(local->link->handle, ®);
386 if (res != CS_SUCCESS) {
387 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
392 mdelay(local->sandisk_connectplus ? 5 : 2);
394 reg.Value &= ~COR_SOFT_RESET;
395 if (local->sandisk_connectplus)
396 reg.Value |= COR_IREQ_ENA;
397 res = pcmcia_access_configuration_register(local->link->handle, ®);
398 if (res != CS_SUCCESS) {
399 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
404 mdelay(local->sandisk_connectplus ? 5 : 2);
406 if (local->sandisk_connectplus)
407 sandisk_set_iobase(local);
411 static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
417 if (!prism2_pccard_card_present(local))
420 if (local->sandisk_connectplus) {
421 sandisk_write_hcr(local, hcr);
426 reg.Action = CS_READ;
427 reg.Offset = CISREG_COR;
429 res = pcmcia_access_configuration_register(local->link->handle, ®);
430 if (res != CS_SUCCESS) {
431 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
435 printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n",
439 reg.Action = CS_WRITE;
440 reg.Value |= COR_SOFT_RESET;
441 res = pcmcia_access_configuration_register(local->link->handle, ®);
442 if (res != CS_SUCCESS) {
443 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
450 /* Setup Genesis mode */
451 reg.Action = CS_WRITE;
453 reg.Offset = CISREG_CCSR;
454 res = pcmcia_access_configuration_register(local->link->handle, ®);
455 if (res != CS_SUCCESS) {
456 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
462 reg.Action = CS_WRITE;
463 reg.Offset = CISREG_COR;
464 reg.Value = old_cor & ~COR_SOFT_RESET;
465 res = pcmcia_access_configuration_register(local->link->handle, ®);
466 if (res != CS_SUCCESS) {
467 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
476 static int prism2_pccard_dev_open(local_info_t *local)
483 static int prism2_pccard_dev_close(local_info_t *local)
485 if (local == NULL || local->link == NULL)
488 if (!local->link->open) {
489 printk(KERN_WARNING "%s: prism2_pccard_dev_close(): "
490 "link not open?!\n", local->dev->name);
500 static struct prism2_helper_functions prism2_pccard_funcs =
502 .card_present = prism2_pccard_card_present,
503 .cor_sreset = prism2_pccard_cor_sreset,
504 .dev_open = prism2_pccard_dev_open,
505 .dev_close = prism2_pccard_dev_close,
506 .genesis_reset = prism2_pccard_genesis_reset,
507 .hw_type = HOSTAP_HW_PCCARD,
511 /* allocate local data and register with CardServices
512 * initialize dev_link structure, but do not configure the card yet */
513 static dev_link_t *prism2_attach(void)
516 client_reg_t client_reg;
519 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
523 memset(link, 0, sizeof(dev_link_t));
525 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
527 link->conf.IntType = INT_MEMORY_AND_IO;
529 /* register with CardServices */
530 link->next = dev_list;
532 client_reg.dev_info = &dev_info;
533 client_reg.Version = 0x0210;
534 client_reg.event_callback_args.client_data = link;
535 ret = pcmcia_register_client(&link->handle, &client_reg);
536 if (ret != CS_SUCCESS) {
537 cs_error(link->handle, RegisterClient, ret);
545 static void prism2_detach(dev_link_t *link)
549 PDEBUG(DEBUG_FLOW, "prism2_detach\n");
551 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
554 if (*linkp == NULL) {
555 printk(KERN_WARNING "%s: Attempt to detach non-existing "
556 "PCMCIA client\n", dev_info);
560 if (link->state & DEV_CONFIG) {
561 prism2_release((u_long)link);
565 int res = pcmcia_deregister_client(link->handle);
567 printk("CardService(DeregisterClient) => %d\n", res);
568 cs_error(link->handle, DeregisterClient, res);
573 /* release net devices */
575 prism2_free_local_data((struct net_device *) link->priv);
582 #define CS_CHECK(fn, ret) \
583 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
585 #define CFG_CHECK2(fn, retf) \
586 do { int ret = (retf); \
588 PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \
589 cs_error(link->handle, fn, ret); \
595 /* run after a CARD_INSERTION event is received to configure the PCMCIA
596 * socket and make the device available to the system */
597 static int prism2_config(dev_link_t *link)
599 struct net_device *dev;
600 struct hostap_interface *iface;
605 int last_fn, last_ret;
608 cistpl_cftable_entry_t dflt = { 0 };
610 PDEBUG(DEBUG_FLOW, "prism2_config()\n");
612 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
618 tuple.DesiredTuple = CISTPL_CONFIG;
619 tuple.Attributes = 0;
620 tuple.TupleData = buf;
621 tuple.TupleDataMax = sizeof(buf);
622 tuple.TupleOffset = 0;
623 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
624 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link->handle, &tuple));
625 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link->handle, &tuple, parse));
626 link->conf.ConfigBase = parse->config.base;
627 link->conf.Present = parse->config.rmask[0];
629 CS_CHECK(GetConfigurationInfo,
630 pcmcia_get_configuration_info(link->handle, &conf));
631 PDEBUG(DEBUG_HW, "%s: %s Vcc=%d (from config)\n", dev_info,
632 ignore_cis_vcc ? "ignoring" : "setting", conf.Vcc);
633 link->conf.Vcc = conf.Vcc;
635 /* Look for an appropriate configuration table entry in the CIS */
636 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
637 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
639 cistpl_cftable_entry_t *cfg = &(parse->cftable_entry);
640 CFG_CHECK2(GetTupleData,
641 pcmcia_get_tuple_data(link->handle, &tuple));
642 CFG_CHECK2(ParseTuple,
643 pcmcia_parse_tuple(link->handle, &tuple, parse));
645 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
649 link->conf.ConfigIndex = cfg->index;
650 PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
651 "(default 0x%02X)\n", cfg->index, dflt.index);
653 /* Does this card need audio output? */
654 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
655 link->conf.Attributes |= CONF_ENABLE_SPKR;
656 link->conf.Status = CCSR_AUDIO_ENA;
659 /* Use power settings for Vcc and Vpp if present */
660 /* Note that the CIS values need to be rescaled */
661 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
662 if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
663 10000 && !ignore_cis_vcc) {
664 PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping"
668 } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
669 if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] /
670 10000 && !ignore_cis_vcc) {
671 PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch "
672 "- skipping this entry\n");
677 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
678 link->conf.Vpp1 = link->conf.Vpp2 =
679 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
680 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
681 link->conf.Vpp1 = link->conf.Vpp2 =
682 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
684 /* Do we need to allocate an interrupt? */
685 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
686 link->conf.Attributes |= CONF_ENABLE_IRQ;
687 else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) {
688 /* At least Compaq WL200 does not have IRQInfo1 set,
689 * but it does not work without interrupts.. */
690 printk("Config has no IRQ info, but trying to enable "
692 link->conf.Attributes |= CONF_ENABLE_IRQ;
695 /* IO window settings */
696 PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
698 cfg->io.nwin, dflt.io.nwin);
699 link->io.NumPorts1 = link->io.NumPorts2 = 0;
700 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
701 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
702 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
703 PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "
704 "io.base=0x%04x, len=%d\n", io->flags,
705 io->win[0].base, io->win[0].len);
706 if (!(io->flags & CISTPL_IO_8BIT))
707 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
708 if (!(io->flags & CISTPL_IO_16BIT))
709 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
710 link->io.IOAddrLines = io->flags &
711 CISTPL_IO_LINES_MASK;
712 link->io.BasePort1 = io->win[0].base;
713 link->io.NumPorts1 = io->win[0].len;
715 link->io.Attributes2 = link->io.Attributes1;
716 link->io.BasePort2 = io->win[1].base;
717 link->io.NumPorts2 = io->win[1].len;
721 /* This reserves IO space but doesn't actually enable it */
722 CFG_CHECK2(RequestIO,
723 pcmcia_request_io(link->handle, &link->io));
725 /* This configuration table entry is OK */
729 CS_CHECK(GetNextTuple,
730 pcmcia_get_next_tuple(link->handle, &tuple));
733 /* Need to allocate net_device before requesting IRQ handler */
734 dev = prism2_init_local_data(&prism2_pccard_funcs, 0);
740 * Allocate an interrupt line. Note that this does not assign a
741 * handler to the interrupt, unless the 'Handler' member of the
742 * irq structure is initialized.
744 if (link->conf.Attributes & CONF_ENABLE_IRQ) {
746 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
747 link->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_LEVEL_ID;
748 if (irq_list[0] == -1)
749 link->irq.IRQInfo2 = irq_mask;
751 for (i = 0; i < 4; i++)
752 link->irq.IRQInfo2 |= 1 << irq_list[i];
753 link->irq.Handler = prism2_interrupt;
754 link->irq.Instance = dev;
756 pcmcia_request_irq(link->handle, &link->irq));
760 * This actually configures the PCMCIA socket -- setting up
761 * the I/O windows and the interrupt mapping, and putting the
762 * card and host interface into "Memory and IO" mode.
764 CS_CHECK(RequestConfiguration,
765 pcmcia_request_configuration(link->handle, &link->conf));
767 dev->irq = link->irq.AssignedIRQ;
768 dev->base_addr = link->io.BasePort1;
770 /* Finally, report what we've done */
771 printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d",
772 dev_info, link->conf.ConfigIndex,
773 link->conf.Vcc / 10, link->conf.Vcc % 10);
775 printk(", Vpp %d.%d", link->conf.Vpp1 / 10,
776 link->conf.Vpp1 % 10);
777 if (link->conf.Attributes & CONF_ENABLE_IRQ)
778 printk(", irq %d", link->irq.AssignedIRQ);
779 if (link->io.NumPorts1)
780 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
781 link->io.BasePort1+link->io.NumPorts1-1);
782 if (link->io.NumPorts2)
783 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
784 link->io.BasePort2+link->io.NumPorts2-1);
787 link->state |= DEV_CONFIG;
788 link->state &= ~DEV_CONFIG_PENDING;
790 iface = netdev_priv(dev);
791 local = iface->local;
793 strcpy(local->node.dev_name, dev->name);
794 link->dev = &local->node;
798 sandisk_enable_wireless(dev);
800 ret = prism2_hw_config(dev, 1);
802 ret = hostap_hw_ready(dev);
803 if (ret == 0 && local->ddev)
804 strcpy(local->node.dev_name, local->ddev->name);
810 cs_error(link->handle, last_fn, last_ret);
814 prism2_release((u_long)link);
819 static void prism2_release(u_long arg)
821 dev_link_t *link = (dev_link_t *)arg;
823 PDEBUG(DEBUG_FLOW, "prism2_release\n");
826 struct net_device *dev = link->priv;
827 struct hostap_interface *iface;
829 iface = netdev_priv(dev);
830 if (link->state & DEV_CONFIG)
831 prism2_hw_shutdown(dev, 0);
832 iface->local->shutdown = 1;
836 pcmcia_release_window(link->win);
837 pcmcia_release_configuration(link->handle);
838 if (link->io.NumPorts1)
839 pcmcia_release_io(link->handle, &link->io);
840 if (link->irq.AssignedIRQ)
841 pcmcia_release_irq(link->handle, &link->irq);
843 link->state &= ~DEV_CONFIG;
845 PDEBUG(DEBUG_FLOW, "release - done\n");
849 static int prism2_event(event_t event, int priority,
850 event_callback_args_t *args)
852 dev_link_t *link = args->client_data;
853 struct net_device *dev = (struct net_device *) link->priv;
856 case CS_EVENT_CARD_INSERTION:
857 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info);
858 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
859 if (prism2_config(link)) {
860 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
864 case CS_EVENT_CARD_REMOVAL:
865 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_REMOVAL\n", dev_info);
866 link->state &= ~DEV_PRESENT;
867 if (link->state & DEV_CONFIG) {
868 netif_stop_queue(dev);
869 netif_device_detach(dev);
870 prism2_release((u_long) link);
874 case CS_EVENT_PM_SUSPEND:
875 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
876 link->state |= DEV_SUSPEND;
879 case CS_EVENT_RESET_PHYSICAL:
880 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_RESET_PHYSICAL\n", dev_info);
881 if (link->state & DEV_CONFIG) {
883 netif_stop_queue(dev);
884 netif_device_detach(dev);
887 pcmcia_release_configuration(link->handle);
891 case CS_EVENT_PM_RESUME:
892 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
893 link->state &= ~DEV_SUSPEND;
896 case CS_EVENT_CARD_RESET:
897 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_RESET\n", dev_info);
898 if (link->state & DEV_CONFIG) {
899 pcmcia_request_configuration(link->handle,
901 prism2_hw_shutdown(dev, 1);
902 prism2_hw_config(dev, link->open ? 0 : 1);
904 netif_device_attach(dev);
905 netif_start_queue(dev);
911 PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n",
919 static struct pcmcia_driver hostap_driver = {
923 .attach = prism2_attach,
924 .detach = prism2_detach,
925 .owner = THIS_MODULE,
926 .event = prism2_event,
929 static int __init init_prism2_pccard(void)
931 printk(KERN_INFO "%s: %s\n", dev_info, version);
932 return pcmcia_register_driver(&hostap_driver);
935 static void __exit exit_prism2_pccard(void)
937 pcmcia_unregister_driver(&hostap_driver);
938 printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
942 module_init(init_prism2_pccard);
943 module_exit(exit_prism2_pccard);