3 #include <linux/config.h>
4 #include <linux/version.h>
5 #include <linux/module.h>
6 #include <linux/init.h>
8 #include <linux/wait.h>
9 #include <linux/timer.h>
10 #include <linux/skbuff.h>
11 #include <linux/netdevice.h>
12 #include <linux/workqueue.h>
13 #include <linux/wireless.h>
14 #include <net/iw_handler.h>
16 #include <pcmcia/version.h>
17 #include <pcmcia/cs_types.h>
18 #include <pcmcia/cs.h>
19 #include <pcmcia/cistpl.h>
20 #include <pcmcia/cisreg.h>
21 #include <pcmcia/ds.h>
25 #include "hostap_wlan.h"
28 static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)";
29 static dev_info_t dev_info = "hostap_cs";
30 static dev_link_t *dev_list = NULL;
32 MODULE_AUTHOR("Jouni Malinen");
33 MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
35 MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PC Card)");
36 MODULE_LICENSE("GPL");
39 static int irq_mask = 0xdeb8;
40 module_param(irq_mask, int, 0444);
42 static int irq_list[4] = { -1 };
43 module_param_array(irq_list, int, NULL, 0444);
45 static int ignore_cis_vcc;
46 module_param(ignore_cis_vcc, int, 0444);
47 MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
50 #ifdef PRISM2_IO_DEBUG
52 static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
54 struct hostap_interface *iface;
58 iface = netdev_priv(dev);
60 spin_lock_irqsave(&local->lock, flags);
61 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
62 outb(v, dev->base_addr + a);
63 spin_unlock_irqrestore(&local->lock, flags);
66 static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
68 struct hostap_interface *iface;
73 iface = netdev_priv(dev);
75 spin_lock_irqsave(&local->lock, flags);
76 v = inb(dev->base_addr + a);
77 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
78 spin_unlock_irqrestore(&local->lock, flags);
82 static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
84 struct hostap_interface *iface;
88 iface = netdev_priv(dev);
90 spin_lock_irqsave(&local->lock, flags);
91 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
92 outw(v, dev->base_addr + a);
93 spin_unlock_irqrestore(&local->lock, flags);
96 static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
98 struct hostap_interface *iface;
103 iface = netdev_priv(dev);
104 local = iface->local;
105 spin_lock_irqsave(&local->lock, flags);
106 v = inw(dev->base_addr + a);
107 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
108 spin_unlock_irqrestore(&local->lock, flags);
112 static inline void hfa384x_outsw_debug(struct net_device *dev, int a,
115 struct hostap_interface *iface;
119 iface = netdev_priv(dev);
120 local = iface->local;
121 spin_lock_irqsave(&local->lock, flags);
122 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTSW, a, wc);
123 outsw(dev->base_addr + a, buf, wc);
124 spin_unlock_irqrestore(&local->lock, flags);
127 static inline void hfa384x_insw_debug(struct net_device *dev, int a,
130 struct hostap_interface *iface;
134 iface = netdev_priv(dev);
135 local = iface->local;
136 spin_lock_irqsave(&local->lock, flags);
137 prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INSW, a, wc);
138 insw(dev->base_addr + a, buf, wc);
139 spin_unlock_irqrestore(&local->lock, flags);
142 #define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v))
143 #define HFA384X_INB(a) hfa384x_inb_debug(dev, (a))
144 #define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v))
145 #define HFA384X_INW(a) hfa384x_inw_debug(dev, (a))
146 #define HFA384X_OUTSW(a, buf, wc) hfa384x_outsw_debug(dev, (a), (buf), (wc))
147 #define HFA384X_INSW(a, buf, wc) hfa384x_insw_debug(dev, (a), (buf), (wc))
149 #else /* PRISM2_IO_DEBUG */
151 #define HFA384X_OUTB(v,a) outb((v), dev->base_addr + (a))
152 #define HFA384X_INB(a) inb(dev->base_addr + (a))
153 #define HFA384X_OUTW(v,a) outw((v), dev->base_addr + (a))
154 #define HFA384X_INW(a) inw(dev->base_addr + (a))
155 #define HFA384X_INSW(a, buf, wc) insw(dev->base_addr + (a), buf, wc)
156 #define HFA384X_OUTSW(a, buf, wc) outsw(dev->base_addr + (a), buf, wc)
158 #endif /* PRISM2_IO_DEBUG */
161 static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
167 d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
171 HFA384X_INSW(d_off, buf, len / 2);
175 *((char *) pos) = HFA384X_INB(d_off);
181 static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
186 d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
190 HFA384X_OUTSW(d_off, buf, len / 2);
194 HFA384X_OUTB(*((char *) pos), d_off);
200 /* FIX: This might change at some point.. */
201 #include "hostap_hw.c"
205 static void prism2_detach(dev_link_t *link);
206 static void prism2_release(u_long arg);
207 static int prism2_event(event_t event, int priority,
208 event_callback_args_t *args);
211 static int prism2_pccard_card_present(local_info_t *local)
213 if (local->link != NULL &&
214 ((local->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
215 (DEV_PRESENT | DEV_CONFIG)))
222 * SanDisk CompactFlash WLAN Flashcard - Product Manual v1.0
223 * Document No. 20-10-00058, January 2004
224 * http://www.sandisk.com/pdf/industrial/ProdManualCFWLANv1.0.pdf
226 #define SANDISK_WLAN_ACTIVATION_OFF 0x40
227 #define SANDISK_HCR_OFF 0x42
230 static void sandisk_set_iobase(local_info_t *local)
236 reg.Action = CS_WRITE;
237 reg.Offset = 0x10; /* 0x3f0 IO base 1 */
238 reg.Value = local->link->io.BasePort1 & 0x00ff;
239 res = pcmcia_access_configuration_register(local->link->handle, ®);
240 if (res != CS_SUCCESS) {
241 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
247 reg.Action = CS_WRITE;
248 reg.Offset = 0x12; /* 0x3f2 IO base 2 */
249 reg.Value = (local->link->io.BasePort1 & 0xff00) >> 8;
250 res = pcmcia_access_configuration_register(local->link->handle, ®);
251 if (res != CS_SUCCESS) {
252 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
258 static void sandisk_write_hcr(local_info_t *local, int hcr)
260 struct net_device *dev = local->dev;
263 HFA384X_OUTB(0x80, SANDISK_WLAN_ACTIVATION_OFF);
265 for (i = 0; i < 10; i++) {
266 HFA384X_OUTB(hcr, SANDISK_HCR_OFF);
269 HFA384X_OUTB(0x45, SANDISK_WLAN_ACTIVATION_OFF);
273 static int sandisk_enable_wireless(struct net_device *dev)
277 struct hostap_interface *iface = dev->priv;
278 local_info_t *local = iface->local;
280 cisparse_t *parse = NULL;
283 if (local->link->io.NumPorts1 < 0x42) {
284 /* Not enough ports to be SanDisk multi-function card */
289 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
295 tuple.DesiredTuple = CISTPL_MANFID;
296 tuple.Attributes = TUPLE_RETURN_COMMON;
297 tuple.TupleData = buf;
298 tuple.TupleDataMax = sizeof(buf);
299 tuple.TupleOffset = 0;
300 if (pcmcia_get_first_tuple(local->link->handle, &tuple) ||
301 pcmcia_get_tuple_data(local->link->handle, &tuple) ||
302 pcmcia_parse_tuple(local->link->handle, &tuple, parse) ||
303 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
304 /* No SanDisk manfid found */
309 tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
310 if (pcmcia_get_first_tuple(local->link->handle, &tuple) ||
311 pcmcia_get_tuple_data(local->link->handle, &tuple) ||
312 pcmcia_parse_tuple(local->link->handle, &tuple, parse) ||
313 parse->longlink_mfc.nfn < 2) {
314 /* No multi-function links found */
319 printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected"
320 " - using vendor-specific initialization\n", dev->name);
321 local->sandisk_connectplus = 1;
324 reg.Action = CS_WRITE;
325 reg.Offset = CISREG_COR;
326 reg.Value = COR_SOFT_RESET;
327 res = pcmcia_access_configuration_register(local->link->handle, ®);
328 if (res != CS_SUCCESS) {
329 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
336 reg.Action = CS_WRITE;
337 reg.Offset = CISREG_COR;
339 * Do not enable interrupts here to avoid some bogus events. Interrupts
340 * will be enabled during the first cor_sreset call.
342 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA;
343 res = pcmcia_access_configuration_register(local->link->handle, ®);
344 if (res != CS_SUCCESS) {
345 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
351 sandisk_set_iobase(local);
353 HFA384X_OUTB(0xc5, SANDISK_WLAN_ACTIVATION_OFF);
355 HFA384X_OUTB(0x4b, SANDISK_WLAN_ACTIVATION_OFF);
364 static void prism2_pccard_cor_sreset(local_info_t *local)
369 if (!prism2_pccard_card_present(local))
373 reg.Action = CS_READ;
374 reg.Offset = CISREG_COR;
376 res = pcmcia_access_configuration_register(local->link->handle, ®);
377 if (res != CS_SUCCESS) {
378 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
382 printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n",
385 reg.Action = CS_WRITE;
386 reg.Value |= COR_SOFT_RESET;
387 res = pcmcia_access_configuration_register(local->link->handle, ®);
388 if (res != CS_SUCCESS) {
389 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
394 mdelay(local->sandisk_connectplus ? 5 : 2);
396 reg.Value &= ~COR_SOFT_RESET;
397 if (local->sandisk_connectplus)
398 reg.Value |= COR_IREQ_ENA;
399 res = pcmcia_access_configuration_register(local->link->handle, ®);
400 if (res != CS_SUCCESS) {
401 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
406 mdelay(local->sandisk_connectplus ? 5 : 2);
408 if (local->sandisk_connectplus)
409 sandisk_set_iobase(local);
413 static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
419 if (!prism2_pccard_card_present(local))
422 if (local->sandisk_connectplus) {
423 sandisk_write_hcr(local, hcr);
428 reg.Action = CS_READ;
429 reg.Offset = CISREG_COR;
431 res = pcmcia_access_configuration_register(local->link->handle, ®);
432 if (res != CS_SUCCESS) {
433 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
437 printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n",
441 reg.Action = CS_WRITE;
442 reg.Value |= COR_SOFT_RESET;
443 res = pcmcia_access_configuration_register(local->link->handle, ®);
444 if (res != CS_SUCCESS) {
445 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
452 /* Setup Genesis mode */
453 reg.Action = CS_WRITE;
455 reg.Offset = CISREG_CCSR;
456 res = pcmcia_access_configuration_register(local->link->handle, ®);
457 if (res != CS_SUCCESS) {
458 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
464 reg.Action = CS_WRITE;
465 reg.Offset = CISREG_COR;
466 reg.Value = old_cor & ~COR_SOFT_RESET;
467 res = pcmcia_access_configuration_register(local->link->handle, ®);
468 if (res != CS_SUCCESS) {
469 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
478 static int prism2_pccard_dev_open(local_info_t *local)
485 static int prism2_pccard_dev_close(local_info_t *local)
487 if (local == NULL || local->link == NULL)
490 if (!local->link->open) {
491 printk(KERN_WARNING "%s: prism2_pccard_dev_close(): "
492 "link not open?!\n", local->dev->name);
502 static struct prism2_helper_functions prism2_pccard_funcs =
504 .card_present = prism2_pccard_card_present,
505 .cor_sreset = prism2_pccard_cor_sreset,
506 .dev_open = prism2_pccard_dev_open,
507 .dev_close = prism2_pccard_dev_close,
508 .genesis_reset = prism2_pccard_genesis_reset,
509 .hw_type = HOSTAP_HW_PCCARD,
513 /* allocate local data and register with CardServices
514 * initialize dev_link structure, but do not configure the card yet */
515 static dev_link_t *prism2_attach(void)
518 client_reg_t client_reg;
521 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
525 memset(link, 0, sizeof(dev_link_t));
527 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
529 link->conf.IntType = INT_MEMORY_AND_IO;
531 /* register with CardServices */
532 link->next = dev_list;
534 client_reg.dev_info = &dev_info;
535 client_reg.Attributes = INFO_IO_CLIENT;
536 client_reg.EventMask = CS_EVENT_CARD_INSERTION |
537 CS_EVENT_CARD_REMOVAL |
538 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
539 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
540 client_reg.event_handler = &prism2_event;
541 client_reg.Version = 0x0210;
542 client_reg.event_callback_args.client_data = link;
543 ret = pcmcia_register_client(&link->handle, &client_reg);
544 if (ret != CS_SUCCESS) {
545 cs_error(link->handle, RegisterClient, ret);
553 static void prism2_detach(dev_link_t *link)
557 PDEBUG(DEBUG_FLOW, "prism2_detach\n");
559 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
562 if (*linkp == NULL) {
563 printk(KERN_WARNING "%s: Attempt to detach non-existing "
564 "PCMCIA client\n", dev_info);
568 if (link->state & DEV_CONFIG) {
569 prism2_release((u_long)link);
573 int res = pcmcia_deregister_client(link->handle);
575 printk("CardService(DeregisterClient) => %d\n", res);
576 cs_error(link->handle, DeregisterClient, res);
581 /* release net devices */
583 prism2_free_local_data((struct net_device *) link->priv);
590 #define CS_CHECK(fn, ret) \
591 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
593 #define CFG_CHECK2(fn, retf) \
594 do { int ret = (retf); \
596 PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \
597 cs_error(link->handle, fn, ret); \
603 /* run after a CARD_INSERTION event is received to configure the PCMCIA
604 * socket and make the device available to the system */
605 static int prism2_config(dev_link_t *link)
607 struct net_device *dev;
608 struct hostap_interface *iface;
613 int last_fn, last_ret;
616 cistpl_cftable_entry_t dflt = { 0 };
618 PDEBUG(DEBUG_FLOW, "prism2_config()\n");
620 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
626 tuple.DesiredTuple = CISTPL_CONFIG;
627 tuple.Attributes = 0;
628 tuple.TupleData = buf;
629 tuple.TupleDataMax = sizeof(buf);
630 tuple.TupleOffset = 0;
631 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
632 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link->handle, &tuple));
633 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link->handle, &tuple, parse));
634 link->conf.ConfigBase = parse->config.base;
635 link->conf.Present = parse->config.rmask[0];
637 CS_CHECK(GetConfigurationInfo,
638 pcmcia_get_configuration_info(link->handle, &conf));
639 PDEBUG(DEBUG_HW, "%s: %s Vcc=%d (from config)\n", dev_info,
640 ignore_cis_vcc ? "ignoring" : "setting", conf.Vcc);
641 link->conf.Vcc = conf.Vcc;
643 /* Look for an appropriate configuration table entry in the CIS */
644 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
645 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
647 cistpl_cftable_entry_t *cfg = &(parse->cftable_entry);
648 CFG_CHECK2(GetTupleData,
649 pcmcia_get_tuple_data(link->handle, &tuple));
650 CFG_CHECK2(ParseTuple,
651 pcmcia_parse_tuple(link->handle, &tuple, parse));
653 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
657 link->conf.ConfigIndex = cfg->index;
658 PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
659 "(default 0x%02X)\n", cfg->index, dflt.index);
661 /* Does this card need audio output? */
662 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
663 link->conf.Attributes |= CONF_ENABLE_SPKR;
664 link->conf.Status = CCSR_AUDIO_ENA;
667 /* Use power settings for Vcc and Vpp if present */
668 /* Note that the CIS values need to be rescaled */
669 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
670 if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
671 10000 && !ignore_cis_vcc) {
672 PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping"
676 } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
677 if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] /
678 10000 && !ignore_cis_vcc) {
679 PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch "
680 "- skipping this entry\n");
685 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
686 link->conf.Vpp1 = link->conf.Vpp2 =
687 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
688 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
689 link->conf.Vpp1 = link->conf.Vpp2 =
690 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
692 /* Do we need to allocate an interrupt? */
693 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
694 link->conf.Attributes |= CONF_ENABLE_IRQ;
695 else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) {
696 /* At least Compaq WL200 does not have IRQInfo1 set,
697 * but it does not work without interrupts.. */
698 printk("Config has no IRQ info, but trying to enable "
700 link->conf.Attributes |= CONF_ENABLE_IRQ;
703 /* IO window settings */
704 PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
706 cfg->io.nwin, dflt.io.nwin);
707 link->io.NumPorts1 = link->io.NumPorts2 = 0;
708 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
709 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
710 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
711 PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "
712 "io.base=0x%04x, len=%d\n", io->flags,
713 io->win[0].base, io->win[0].len);
714 if (!(io->flags & CISTPL_IO_8BIT))
715 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
716 if (!(io->flags & CISTPL_IO_16BIT))
717 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
718 link->io.IOAddrLines = io->flags &
719 CISTPL_IO_LINES_MASK;
720 link->io.BasePort1 = io->win[0].base;
721 link->io.NumPorts1 = io->win[0].len;
723 link->io.Attributes2 = link->io.Attributes1;
724 link->io.BasePort2 = io->win[1].base;
725 link->io.NumPorts2 = io->win[1].len;
729 /* This reserves IO space but doesn't actually enable it */
730 CFG_CHECK2(RequestIO,
731 pcmcia_request_io(link->handle, &link->io));
733 /* This configuration table entry is OK */
737 CS_CHECK(GetNextTuple,
738 pcmcia_get_next_tuple(link->handle, &tuple));
741 /* Need to allocate net_device before requesting IRQ handler */
742 dev = prism2_init_local_data(&prism2_pccard_funcs, 0);
748 * Allocate an interrupt line. Note that this does not assign a
749 * handler to the interrupt, unless the 'Handler' member of the
750 * irq structure is initialized.
752 if (link->conf.Attributes & CONF_ENABLE_IRQ) {
754 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
755 link->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_LEVEL_ID;
756 if (irq_list[0] == -1)
757 link->irq.IRQInfo2 = irq_mask;
759 for (i = 0; i < 4; i++)
760 link->irq.IRQInfo2 |= 1 << irq_list[i];
761 link->irq.Handler = prism2_interrupt;
762 link->irq.Instance = dev;
764 pcmcia_request_irq(link->handle, &link->irq));
768 * This actually configures the PCMCIA socket -- setting up
769 * the I/O windows and the interrupt mapping, and putting the
770 * card and host interface into "Memory and IO" mode.
772 CS_CHECK(RequestConfiguration,
773 pcmcia_request_configuration(link->handle, &link->conf));
775 dev->irq = link->irq.AssignedIRQ;
776 dev->base_addr = link->io.BasePort1;
778 /* Finally, report what we've done */
779 printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d",
780 dev_info, link->conf.ConfigIndex,
781 link->conf.Vcc / 10, link->conf.Vcc % 10);
783 printk(", Vpp %d.%d", link->conf.Vpp1 / 10,
784 link->conf.Vpp1 % 10);
785 if (link->conf.Attributes & CONF_ENABLE_IRQ)
786 printk(", irq %d", link->irq.AssignedIRQ);
787 if (link->io.NumPorts1)
788 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
789 link->io.BasePort1+link->io.NumPorts1-1);
790 if (link->io.NumPorts2)
791 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
792 link->io.BasePort2+link->io.NumPorts2-1);
795 link->state |= DEV_CONFIG;
796 link->state &= ~DEV_CONFIG_PENDING;
798 iface = netdev_priv(dev);
799 local = iface->local;
801 strcpy(local->node.dev_name, dev->name);
802 link->dev = &local->node;
806 sandisk_enable_wireless(dev);
808 ret = prism2_hw_config(dev, 1);
810 ret = hostap_hw_ready(dev);
811 if (ret == 0 && local->ddev)
812 strcpy(local->node.dev_name, local->ddev->name);
818 cs_error(link->handle, last_fn, last_ret);
822 prism2_release((u_long)link);
827 static void prism2_release(u_long arg)
829 dev_link_t *link = (dev_link_t *)arg;
831 PDEBUG(DEBUG_FLOW, "prism2_release\n");
834 struct net_device *dev = link->priv;
835 struct hostap_interface *iface;
837 iface = netdev_priv(dev);
838 if (link->state & DEV_CONFIG)
839 prism2_hw_shutdown(dev, 0);
840 iface->local->shutdown = 1;
844 pcmcia_release_window(link->win);
845 pcmcia_release_configuration(link->handle);
846 if (link->io.NumPorts1)
847 pcmcia_release_io(link->handle, &link->io);
848 if (link->irq.AssignedIRQ)
849 pcmcia_release_irq(link->handle, &link->irq);
851 link->state &= ~DEV_CONFIG;
853 PDEBUG(DEBUG_FLOW, "release - done\n");
857 static int prism2_event(event_t event, int priority,
858 event_callback_args_t *args)
860 dev_link_t *link = args->client_data;
861 struct net_device *dev = (struct net_device *) link->priv;
864 case CS_EVENT_CARD_INSERTION:
865 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info);
866 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
867 if (prism2_config(link)) {
868 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
872 case CS_EVENT_CARD_REMOVAL:
873 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_REMOVAL\n", dev_info);
874 link->state &= ~DEV_PRESENT;
875 if (link->state & DEV_CONFIG) {
876 netif_stop_queue(dev);
877 netif_device_detach(dev);
878 prism2_release((u_long) link);
882 case CS_EVENT_PM_SUSPEND:
883 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
884 link->state |= DEV_SUSPEND;
887 case CS_EVENT_RESET_PHYSICAL:
888 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_RESET_PHYSICAL\n", dev_info);
889 if (link->state & DEV_CONFIG) {
891 netif_stop_queue(dev);
892 netif_device_detach(dev);
895 pcmcia_release_configuration(link->handle);
899 case CS_EVENT_PM_RESUME:
900 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
901 link->state &= ~DEV_SUSPEND;
904 case CS_EVENT_CARD_RESET:
905 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_RESET\n", dev_info);
906 if (link->state & DEV_CONFIG) {
907 pcmcia_request_configuration(link->handle,
909 prism2_hw_shutdown(dev, 1);
910 prism2_hw_config(dev, link->open ? 0 : 1);
912 netif_device_attach(dev);
913 netif_start_queue(dev);
919 PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n",
927 static struct pcmcia_driver hostap_driver = {
931 .attach = prism2_attach,
932 .detach = prism2_detach,
933 .owner = THIS_MODULE,
936 static int __init init_prism2_pccard(void)
938 printk(KERN_INFO "%s: %s\n", dev_info, version);
939 return pcmcia_register_driver(&hostap_driver);
942 static void __exit exit_prism2_pccard(void)
944 pcmcia_unregister_driver(&hostap_driver);
945 printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
949 module_init(init_prism2_pccard);
950 module_exit(exit_prism2_pccard);