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 /* struct local_info::hw_priv */
44 struct hostap_cs_priv
{
47 int sandisk_connectplus
;
51 #ifdef PRISM2_IO_DEBUG
53 static inline void hfa384x_outb_debug(struct net_device
*dev
, int a
, u8 v
)
55 struct hostap_interface
*iface
;
59 iface
= netdev_priv(dev
);
61 spin_lock_irqsave(&local
->lock
, flags
);
62 prism2_io_debug_add(dev
, PRISM2_IO_DEBUG_CMD_OUTB
, a
, v
);
63 outb(v
, dev
->base_addr
+ a
);
64 spin_unlock_irqrestore(&local
->lock
, flags
);
67 static inline u8
hfa384x_inb_debug(struct net_device
*dev
, int a
)
69 struct hostap_interface
*iface
;
74 iface
= netdev_priv(dev
);
76 spin_lock_irqsave(&local
->lock
, flags
);
77 v
= inb(dev
->base_addr
+ a
);
78 prism2_io_debug_add(dev
, PRISM2_IO_DEBUG_CMD_INB
, a
, v
);
79 spin_unlock_irqrestore(&local
->lock
, flags
);
83 static inline void hfa384x_outw_debug(struct net_device
*dev
, int a
, u16 v
)
85 struct hostap_interface
*iface
;
89 iface
= netdev_priv(dev
);
91 spin_lock_irqsave(&local
->lock
, flags
);
92 prism2_io_debug_add(dev
, PRISM2_IO_DEBUG_CMD_OUTW
, a
, v
);
93 outw(v
, dev
->base_addr
+ a
);
94 spin_unlock_irqrestore(&local
->lock
, flags
);
97 static inline u16
hfa384x_inw_debug(struct net_device
*dev
, int a
)
99 struct hostap_interface
*iface
;
104 iface
= netdev_priv(dev
);
105 local
= iface
->local
;
106 spin_lock_irqsave(&local
->lock
, flags
);
107 v
= inw(dev
->base_addr
+ a
);
108 prism2_io_debug_add(dev
, PRISM2_IO_DEBUG_CMD_INW
, a
, v
);
109 spin_unlock_irqrestore(&local
->lock
, flags
);
113 static inline void hfa384x_outsw_debug(struct net_device
*dev
, int a
,
116 struct hostap_interface
*iface
;
120 iface
= netdev_priv(dev
);
121 local
= iface
->local
;
122 spin_lock_irqsave(&local
->lock
, flags
);
123 prism2_io_debug_add(dev
, PRISM2_IO_DEBUG_CMD_OUTSW
, a
, wc
);
124 outsw(dev
->base_addr
+ a
, buf
, wc
);
125 spin_unlock_irqrestore(&local
->lock
, flags
);
128 static inline void hfa384x_insw_debug(struct net_device
*dev
, int a
,
131 struct hostap_interface
*iface
;
135 iface
= netdev_priv(dev
);
136 local
= iface
->local
;
137 spin_lock_irqsave(&local
->lock
, flags
);
138 prism2_io_debug_add(dev
, PRISM2_IO_DEBUG_CMD_INSW
, a
, wc
);
139 insw(dev
->base_addr
+ a
, buf
, wc
);
140 spin_unlock_irqrestore(&local
->lock
, flags
);
143 #define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v))
144 #define HFA384X_INB(a) hfa384x_inb_debug(dev, (a))
145 #define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v))
146 #define HFA384X_INW(a) hfa384x_inw_debug(dev, (a))
147 #define HFA384X_OUTSW(a, buf, wc) hfa384x_outsw_debug(dev, (a), (buf), (wc))
148 #define HFA384X_INSW(a, buf, wc) hfa384x_insw_debug(dev, (a), (buf), (wc))
150 #else /* PRISM2_IO_DEBUG */
152 #define HFA384X_OUTB(v,a) outb((v), dev->base_addr + (a))
153 #define HFA384X_INB(a) inb(dev->base_addr + (a))
154 #define HFA384X_OUTW(v,a) outw((v), dev->base_addr + (a))
155 #define HFA384X_INW(a) inw(dev->base_addr + (a))
156 #define HFA384X_INSW(a, buf, wc) insw(dev->base_addr + (a), buf, wc)
157 #define HFA384X_OUTSW(a, buf, wc) outsw(dev->base_addr + (a), buf, wc)
159 #endif /* PRISM2_IO_DEBUG */
162 static int hfa384x_from_bap(struct net_device
*dev
, u16 bap
, void *buf
,
168 d_off
= (bap
== 1) ? HFA384X_DATA1_OFF
: HFA384X_DATA0_OFF
;
172 HFA384X_INSW(d_off
, buf
, len
/ 2);
176 *((char *) pos
) = HFA384X_INB(d_off
);
182 static int hfa384x_to_bap(struct net_device
*dev
, u16 bap
, void *buf
, int len
)
187 d_off
= (bap
== 1) ? HFA384X_DATA1_OFF
: HFA384X_DATA0_OFF
;
191 HFA384X_OUTSW(d_off
, buf
, len
/ 2);
195 HFA384X_OUTB(*((char *) pos
), d_off
);
201 /* FIX: This might change at some point.. */
202 #include "hostap_hw.c"
206 static void prism2_detach(dev_link_t
*link
);
207 static void prism2_release(u_long arg
);
208 static int prism2_event(event_t event
, int priority
,
209 event_callback_args_t
*args
);
212 static int prism2_pccard_card_present(local_info_t
*local
)
214 struct hostap_cs_priv
*hw_priv
= local
->hw_priv
;
215 if (hw_priv
!= NULL
&& hw_priv
->link
!= NULL
&&
216 ((hw_priv
->link
->state
& (DEV_PRESENT
| DEV_CONFIG
)) ==
217 (DEV_PRESENT
| DEV_CONFIG
)))
224 * SanDisk CompactFlash WLAN Flashcard - Product Manual v1.0
225 * Document No. 20-10-00058, January 2004
226 * http://www.sandisk.com/pdf/industrial/ProdManualCFWLANv1.0.pdf
228 #define SANDISK_WLAN_ACTIVATION_OFF 0x40
229 #define SANDISK_HCR_OFF 0x42
232 static void sandisk_set_iobase(local_info_t
*local
)
236 struct hostap_cs_priv
*hw_priv
= local
->hw_priv
;
239 reg
.Action
= CS_WRITE
;
240 reg
.Offset
= 0x10; /* 0x3f0 IO base 1 */
241 reg
.Value
= hw_priv
->link
->io
.BasePort1
& 0x00ff;
242 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
244 if (res
!= CS_SUCCESS
) {
245 printk(KERN_DEBUG
"Prism3 SanDisk - failed to set I/O base 0 -"
251 reg
.Action
= CS_WRITE
;
252 reg
.Offset
= 0x12; /* 0x3f2 IO base 2 */
253 reg
.Value
= (hw_priv
->link
->io
.BasePort1
& 0xff00) >> 8;
254 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
256 if (res
!= CS_SUCCESS
) {
257 printk(KERN_DEBUG
"Prism3 SanDisk - failed to set I/O base 1 -"
263 static void sandisk_write_hcr(local_info_t
*local
, int hcr
)
265 struct net_device
*dev
= local
->dev
;
268 HFA384X_OUTB(0x80, SANDISK_WLAN_ACTIVATION_OFF
);
270 for (i
= 0; i
< 10; i
++) {
271 HFA384X_OUTB(hcr
, SANDISK_HCR_OFF
);
274 HFA384X_OUTB(0x45, SANDISK_WLAN_ACTIVATION_OFF
);
278 static int sandisk_enable_wireless(struct net_device
*dev
)
282 struct hostap_interface
*iface
= dev
->priv
;
283 local_info_t
*local
= iface
->local
;
285 cisparse_t
*parse
= NULL
;
287 struct hostap_cs_priv
*hw_priv
= local
->hw_priv
;
289 if (hw_priv
->link
->io
.NumPorts1
< 0x42) {
290 /* Not enough ports to be SanDisk multi-function card */
295 parse
= kmalloc(sizeof(cisparse_t
), GFP_KERNEL
);
301 tuple
.DesiredTuple
= CISTPL_MANFID
;
302 tuple
.Attributes
= TUPLE_RETURN_COMMON
;
303 tuple
.TupleData
= buf
;
304 tuple
.TupleDataMax
= sizeof(buf
);
305 tuple
.TupleOffset
= 0;
306 if (pcmcia_get_first_tuple(hw_priv
->link
->handle
, &tuple
) ||
307 pcmcia_get_tuple_data(hw_priv
->link
->handle
, &tuple
) ||
308 pcmcia_parse_tuple(hw_priv
->link
->handle
, &tuple
, parse
) ||
309 parse
->manfid
.manf
!= 0xd601 || parse
->manfid
.card
!= 0x0101) {
310 /* No SanDisk manfid found */
315 tuple
.DesiredTuple
= CISTPL_LONGLINK_MFC
;
316 if (pcmcia_get_first_tuple(hw_priv
->link
->handle
, &tuple
) ||
317 pcmcia_get_tuple_data(hw_priv
->link
->handle
, &tuple
) ||
318 pcmcia_parse_tuple(hw_priv
->link
->handle
, &tuple
, parse
) ||
319 parse
->longlink_mfc
.nfn
< 2) {
320 /* No multi-function links found */
325 printk(KERN_DEBUG
"%s: Multi-function SanDisk ConnectPlus detected"
326 " - using vendor-specific initialization\n", dev
->name
);
327 hw_priv
->sandisk_connectplus
= 1;
330 reg
.Action
= CS_WRITE
;
331 reg
.Offset
= CISREG_COR
;
332 reg
.Value
= COR_SOFT_RESET
;
333 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
335 if (res
!= CS_SUCCESS
) {
336 printk(KERN_DEBUG
"%s: SanDisk - COR sreset failed (%d)\n",
343 reg
.Action
= CS_WRITE
;
344 reg
.Offset
= CISREG_COR
;
346 * Do not enable interrupts here to avoid some bogus events. Interrupts
347 * will be enabled during the first cor_sreset call.
349 reg
.Value
= COR_LEVEL_REQ
| 0x8 | COR_ADDR_DECODE
| COR_FUNC_ENA
;
350 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
352 if (res
!= CS_SUCCESS
) {
353 printk(KERN_DEBUG
"%s: SanDisk - COR sreset failed (%d)\n",
359 sandisk_set_iobase(local
);
361 HFA384X_OUTB(0xc5, SANDISK_WLAN_ACTIVATION_OFF
);
363 HFA384X_OUTB(0x4b, SANDISK_WLAN_ACTIVATION_OFF
);
372 static void prism2_pccard_cor_sreset(local_info_t
*local
)
376 struct hostap_cs_priv
*hw_priv
= local
->hw_priv
;
378 if (!prism2_pccard_card_present(local
))
382 reg
.Action
= CS_READ
;
383 reg
.Offset
= CISREG_COR
;
385 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
387 if (res
!= CS_SUCCESS
) {
388 printk(KERN_DEBUG
"prism2_pccard_cor_sreset failed 1 (%d)\n",
392 printk(KERN_DEBUG
"prism2_pccard_cor_sreset: original COR %02x\n",
395 reg
.Action
= CS_WRITE
;
396 reg
.Value
|= COR_SOFT_RESET
;
397 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
399 if (res
!= CS_SUCCESS
) {
400 printk(KERN_DEBUG
"prism2_pccard_cor_sreset failed 2 (%d)\n",
405 mdelay(hw_priv
->sandisk_connectplus
? 5 : 2);
407 reg
.Value
&= ~COR_SOFT_RESET
;
408 if (hw_priv
->sandisk_connectplus
)
409 reg
.Value
|= COR_IREQ_ENA
;
410 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
412 if (res
!= CS_SUCCESS
) {
413 printk(KERN_DEBUG
"prism2_pccard_cor_sreset failed 3 (%d)\n",
418 mdelay(hw_priv
->sandisk_connectplus
? 5 : 2);
420 if (hw_priv
->sandisk_connectplus
)
421 sandisk_set_iobase(local
);
425 static void prism2_pccard_genesis_reset(local_info_t
*local
, int hcr
)
430 struct hostap_cs_priv
*hw_priv
= local
->hw_priv
;
432 if (!prism2_pccard_card_present(local
))
435 if (hw_priv
->sandisk_connectplus
) {
436 sandisk_write_hcr(local
, hcr
);
441 reg
.Action
= CS_READ
;
442 reg
.Offset
= CISREG_COR
;
444 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
446 if (res
!= CS_SUCCESS
) {
447 printk(KERN_DEBUG
"prism2_pccard_genesis_sreset failed 1 "
451 printk(KERN_DEBUG
"prism2_pccard_genesis_sreset: original COR %02x\n",
455 reg
.Action
= CS_WRITE
;
456 reg
.Value
|= COR_SOFT_RESET
;
457 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
459 if (res
!= CS_SUCCESS
) {
460 printk(KERN_DEBUG
"prism2_pccard_genesis_sreset failed 2 "
467 /* Setup Genesis mode */
468 reg
.Action
= CS_WRITE
;
470 reg
.Offset
= CISREG_CCSR
;
471 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
473 if (res
!= CS_SUCCESS
) {
474 printk(KERN_DEBUG
"prism2_pccard_genesis_sreset failed 3 "
480 reg
.Action
= CS_WRITE
;
481 reg
.Offset
= CISREG_COR
;
482 reg
.Value
= old_cor
& ~COR_SOFT_RESET
;
483 res
= pcmcia_access_configuration_register(hw_priv
->link
->handle
,
485 if (res
!= CS_SUCCESS
) {
486 printk(KERN_DEBUG
"prism2_pccard_genesis_sreset failed 4 "
495 static struct prism2_helper_functions prism2_pccard_funcs
=
497 .card_present
= prism2_pccard_card_present
,
498 .cor_sreset
= prism2_pccard_cor_sreset
,
499 .genesis_reset
= prism2_pccard_genesis_reset
,
500 .hw_type
= HOSTAP_HW_PCCARD
,
504 /* allocate local data and register with CardServices
505 * initialize dev_link structure, but do not configure the card yet */
506 static dev_link_t
*prism2_attach(void)
509 client_reg_t client_reg
;
512 link
= kmalloc(sizeof(dev_link_t
), GFP_KERNEL
);
516 memset(link
, 0, sizeof(dev_link_t
));
518 PDEBUG(DEBUG_HW
, "%s: setting Vcc=33 (constant)\n", dev_info
);
520 link
->conf
.IntType
= INT_MEMORY_AND_IO
;
522 /* register with CardServices */
523 link
->next
= dev_list
;
525 client_reg
.dev_info
= &dev_info
;
526 client_reg
.Version
= 0x0210;
527 client_reg
.event_callback_args
.client_data
= link
;
528 ret
= pcmcia_register_client(&link
->handle
, &client_reg
);
529 if (ret
!= CS_SUCCESS
) {
530 cs_error(link
->handle
, RegisterClient
, ret
);
538 static void prism2_detach(dev_link_t
*link
)
542 PDEBUG(DEBUG_FLOW
, "prism2_detach\n");
544 for (linkp
= &dev_list
; *linkp
; linkp
= &(*linkp
)->next
)
547 if (*linkp
== NULL
) {
548 printk(KERN_WARNING
"%s: Attempt to detach non-existing "
549 "PCMCIA client\n", dev_info
);
553 if (link
->state
& DEV_CONFIG
) {
554 prism2_release((u_long
)link
);
558 int res
= pcmcia_deregister_client(link
->handle
);
560 printk("CardService(DeregisterClient) => %d\n", res
);
561 cs_error(link
->handle
, DeregisterClient
, res
);
566 /* release net devices */
568 struct hostap_cs_priv
*hw_priv
;
569 struct net_device
*dev
;
570 struct hostap_interface
*iface
;
572 iface
= netdev_priv(dev
);
573 hw_priv
= iface
->local
->hw_priv
;
574 prism2_free_local_data(dev
);
581 #define CS_CHECK(fn, ret) \
582 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
584 #define CFG_CHECK2(fn, retf) \
585 do { int ret = (retf); \
587 PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \
588 cs_error(link->handle, fn, ret); \
594 /* run after a CARD_INSERTION event is received to configure the PCMCIA
595 * socket and make the device available to the system */
596 static int prism2_config(dev_link_t
*link
)
598 struct net_device
*dev
;
599 struct hostap_interface
*iface
;
604 int last_fn
, last_ret
;
607 cistpl_cftable_entry_t dflt
= { 0 };
608 struct hostap_cs_priv
*hw_priv
;
610 PDEBUG(DEBUG_FLOW
, "prism2_config()\n");
612 parse
= kmalloc(sizeof(cisparse_t
), GFP_KERNEL
);
613 hw_priv
= kmalloc(sizeof(*hw_priv
), GFP_KERNEL
);
614 if (parse
== NULL
|| hw_priv
== NULL
) {
620 memset(hw_priv
, 0, sizeof(*hw_priv
));
622 tuple
.DesiredTuple
= CISTPL_CONFIG
;
623 tuple
.Attributes
= 0;
624 tuple
.TupleData
= buf
;
625 tuple
.TupleDataMax
= sizeof(buf
);
626 tuple
.TupleOffset
= 0;
627 CS_CHECK(GetFirstTuple
, pcmcia_get_first_tuple(link
->handle
, &tuple
));
628 CS_CHECK(GetTupleData
, pcmcia_get_tuple_data(link
->handle
, &tuple
));
629 CS_CHECK(ParseTuple
, pcmcia_parse_tuple(link
->handle
, &tuple
, parse
));
630 link
->conf
.ConfigBase
= parse
->config
.base
;
631 link
->conf
.Present
= parse
->config
.rmask
[0];
633 CS_CHECK(GetConfigurationInfo
,
634 pcmcia_get_configuration_info(link
->handle
, &conf
));
635 PDEBUG(DEBUG_HW
, "%s: %s Vcc=%d (from config)\n", dev_info
,
636 ignore_cis_vcc
? "ignoring" : "setting", conf
.Vcc
);
637 link
->conf
.Vcc
= conf
.Vcc
;
639 /* Look for an appropriate configuration table entry in the CIS */
640 tuple
.DesiredTuple
= CISTPL_CFTABLE_ENTRY
;
641 CS_CHECK(GetFirstTuple
, pcmcia_get_first_tuple(link
->handle
, &tuple
));
643 cistpl_cftable_entry_t
*cfg
= &(parse
->cftable_entry
);
644 CFG_CHECK2(GetTupleData
,
645 pcmcia_get_tuple_data(link
->handle
, &tuple
));
646 CFG_CHECK2(ParseTuple
,
647 pcmcia_parse_tuple(link
->handle
, &tuple
, parse
));
649 if (cfg
->flags
& CISTPL_CFTABLE_DEFAULT
)
653 link
->conf
.ConfigIndex
= cfg
->index
;
654 PDEBUG(DEBUG_EXTRA
, "Checking CFTABLE_ENTRY 0x%02X "
655 "(default 0x%02X)\n", cfg
->index
, dflt
.index
);
657 /* Does this card need audio output? */
658 if (cfg
->flags
& CISTPL_CFTABLE_AUDIO
) {
659 link
->conf
.Attributes
|= CONF_ENABLE_SPKR
;
660 link
->conf
.Status
= CCSR_AUDIO_ENA
;
663 /* Use power settings for Vcc and Vpp if present */
664 /* Note that the CIS values need to be rescaled */
665 if (cfg
->vcc
.present
& (1 << CISTPL_POWER_VNOM
)) {
666 if (conf
.Vcc
!= cfg
->vcc
.param
[CISTPL_POWER_VNOM
] /
667 10000 && !ignore_cis_vcc
) {
668 PDEBUG(DEBUG_EXTRA
, " Vcc mismatch - skipping"
672 } else if (dflt
.vcc
.present
& (1 << CISTPL_POWER_VNOM
)) {
673 if (conf
.Vcc
!= dflt
.vcc
.param
[CISTPL_POWER_VNOM
] /
674 10000 && !ignore_cis_vcc
) {
675 PDEBUG(DEBUG_EXTRA
, " Vcc (default) mismatch "
676 "- skipping this entry\n");
681 if (cfg
->vpp1
.present
& (1 << CISTPL_POWER_VNOM
))
682 link
->conf
.Vpp1
= link
->conf
.Vpp2
=
683 cfg
->vpp1
.param
[CISTPL_POWER_VNOM
] / 10000;
684 else if (dflt
.vpp1
.present
& (1 << CISTPL_POWER_VNOM
))
685 link
->conf
.Vpp1
= link
->conf
.Vpp2
=
686 dflt
.vpp1
.param
[CISTPL_POWER_VNOM
] / 10000;
688 /* Do we need to allocate an interrupt? */
689 if (cfg
->irq
.IRQInfo1
|| dflt
.irq
.IRQInfo1
)
690 link
->conf
.Attributes
|= CONF_ENABLE_IRQ
;
691 else if (!(link
->conf
.Attributes
& CONF_ENABLE_IRQ
)) {
692 /* At least Compaq WL200 does not have IRQInfo1 set,
693 * but it does not work without interrupts.. */
694 printk("Config has no IRQ info, but trying to enable "
696 link
->conf
.Attributes
|= CONF_ENABLE_IRQ
;
699 /* IO window settings */
700 PDEBUG(DEBUG_EXTRA
, "IO window settings: cfg->io.nwin=%d "
702 cfg
->io
.nwin
, dflt
.io
.nwin
);
703 link
->io
.NumPorts1
= link
->io
.NumPorts2
= 0;
704 if ((cfg
->io
.nwin
> 0) || (dflt
.io
.nwin
> 0)) {
705 cistpl_io_t
*io
= (cfg
->io
.nwin
) ? &cfg
->io
: &dflt
.io
;
706 link
->io
.Attributes1
= IO_DATA_PATH_WIDTH_AUTO
;
707 PDEBUG(DEBUG_EXTRA
, "io->flags = 0x%04X, "
708 "io.base=0x%04x, len=%d\n", io
->flags
,
709 io
->win
[0].base
, io
->win
[0].len
);
710 if (!(io
->flags
& CISTPL_IO_8BIT
))
711 link
->io
.Attributes1
= IO_DATA_PATH_WIDTH_16
;
712 if (!(io
->flags
& CISTPL_IO_16BIT
))
713 link
->io
.Attributes1
= IO_DATA_PATH_WIDTH_8
;
714 link
->io
.IOAddrLines
= io
->flags
&
715 CISTPL_IO_LINES_MASK
;
716 link
->io
.BasePort1
= io
->win
[0].base
;
717 link
->io
.NumPorts1
= io
->win
[0].len
;
719 link
->io
.Attributes2
= link
->io
.Attributes1
;
720 link
->io
.BasePort2
= io
->win
[1].base
;
721 link
->io
.NumPorts2
= io
->win
[1].len
;
725 /* This reserves IO space but doesn't actually enable it */
726 CFG_CHECK2(RequestIO
,
727 pcmcia_request_io(link
->handle
, &link
->io
));
729 /* This configuration table entry is OK */
733 CS_CHECK(GetNextTuple
,
734 pcmcia_get_next_tuple(link
->handle
, &tuple
));
737 /* Need to allocate net_device before requesting IRQ handler */
738 dev
= prism2_init_local_data(&prism2_pccard_funcs
, 0,
739 &handle_to_dev(link
->handle
));
744 iface
= netdev_priv(dev
);
745 local
= iface
->local
;
746 local
->hw_priv
= hw_priv
;
747 hw_priv
->link
= link
;
748 strcpy(hw_priv
->node
.dev_name
, dev
->name
);
749 link
->dev
= &hw_priv
->node
;
752 * Allocate an interrupt line. Note that this does not assign a
753 * handler to the interrupt, unless the 'Handler' member of the
754 * irq structure is initialized.
756 if (link
->conf
.Attributes
& CONF_ENABLE_IRQ
) {
757 link
->irq
.Attributes
= IRQ_TYPE_EXCLUSIVE
| IRQ_HANDLE_PRESENT
;
758 link
->irq
.IRQInfo1
= IRQ_LEVEL_ID
;
759 link
->irq
.Handler
= prism2_interrupt
;
760 link
->irq
.Instance
= dev
;
762 pcmcia_request_irq(link
->handle
, &link
->irq
));
766 * This actually configures the PCMCIA socket -- setting up
767 * the I/O windows and the interrupt mapping, and putting the
768 * card and host interface into "Memory and IO" mode.
770 CS_CHECK(RequestConfiguration
,
771 pcmcia_request_configuration(link
->handle
, &link
->conf
));
773 dev
->irq
= link
->irq
.AssignedIRQ
;
774 dev
->base_addr
= link
->io
.BasePort1
;
776 /* Finally, report what we've done */
777 printk(KERN_INFO
"%s: index 0x%02x: Vcc %d.%d",
778 dev_info
, link
->conf
.ConfigIndex
,
779 link
->conf
.Vcc
/ 10, link
->conf
.Vcc
% 10);
781 printk(", Vpp %d.%d", link
->conf
.Vpp1
/ 10,
782 link
->conf
.Vpp1
% 10);
783 if (link
->conf
.Attributes
& CONF_ENABLE_IRQ
)
784 printk(", irq %d", link
->irq
.AssignedIRQ
);
785 if (link
->io
.NumPorts1
)
786 printk(", io 0x%04x-0x%04x", link
->io
.BasePort1
,
787 link
->io
.BasePort1
+link
->io
.NumPorts1
-1);
788 if (link
->io
.NumPorts2
)
789 printk(" & 0x%04x-0x%04x", link
->io
.BasePort2
,
790 link
->io
.BasePort2
+link
->io
.NumPorts2
-1);
793 link
->state
|= DEV_CONFIG
;
794 link
->state
&= ~DEV_CONFIG_PENDING
;
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(hw_priv
->node
.dev_name
, local
->ddev
->name
);
810 cs_error(link
->handle
, last_fn
, last_ret
);
815 prism2_release((u_long
)link
);
820 static void prism2_release(u_long arg
)
822 dev_link_t
*link
= (dev_link_t
*)arg
;
824 PDEBUG(DEBUG_FLOW
, "prism2_release\n");
827 struct net_device
*dev
= link
->priv
;
828 struct hostap_interface
*iface
;
830 iface
= netdev_priv(dev
);
831 if (link
->state
& DEV_CONFIG
)
832 prism2_hw_shutdown(dev
, 0);
833 iface
->local
->shutdown
= 1;
837 pcmcia_release_window(link
->win
);
838 pcmcia_release_configuration(link
->handle
);
839 if (link
->io
.NumPorts1
)
840 pcmcia_release_io(link
->handle
, &link
->io
);
841 if (link
->irq
.AssignedIRQ
)
842 pcmcia_release_irq(link
->handle
, &link
->irq
);
844 link
->state
&= ~DEV_CONFIG
;
846 PDEBUG(DEBUG_FLOW
, "release - done\n");
850 static int prism2_event(event_t event
, int priority
,
851 event_callback_args_t
*args
)
853 dev_link_t
*link
= args
->client_data
;
854 struct net_device
*dev
= (struct net_device
*) link
->priv
;
857 if (link
->state
& DEV_CONFIG
) {
858 struct hostap_interface
*iface
= netdev_priv(dev
);
859 if (iface
&& iface
->local
)
860 dev_open
= iface
->local
->num_dev_open
> 0;
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
, dev_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_device_id hostap_cs_ids
[] = {
928 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100),
929 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),
930 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777),
931 PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000),
932 PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),
933 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002),
934 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002),
935 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b),
936 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612),
937 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613),
938 PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002),
939 PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002),
940 PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),
941 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),
942 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
943 PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000),
944 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
945 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
946 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
947 PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus",
948 0x7a954bd9, 0x74be00c6),
949 PCMCIA_DEVICE_PROD_ID1234(
950 "Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P",
952 0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e),
953 PCMCIA_DEVICE_PROD_ID123(
954 "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02",
955 0xe6ec52ce, 0x08649af2, 0x4b74baa0),
956 PCMCIA_DEVICE_PROD_ID123(
957 "D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02",
958 0x71b18589, 0xb6f1b0ab, 0x4b74baa0),
959 PCMCIA_DEVICE_PROD_ID123(
960 "Instant Wireless ", " Network PC CARD", "Version 01.02",
961 0x11d901af, 0x6e9bd926, 0x4b74baa0),
962 PCMCIA_DEVICE_PROD_ID123(
963 "SMC", "SMC2632W", "Version 01.02",
964 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0),
965 PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G",
966 0x2decece3, 0x82067c18),
967 PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card",
968 0x54f7c49c, 0x15a75e5b),
969 PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE",
970 0x74c5e40d, 0xdb472a18),
971 PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card",
972 0x0733cc81, 0x0c52f395),
973 PCMCIA_DEVICE_PROD_ID12(
974 "ZoomAir 11Mbps High", "Rate wireless Networking",
975 0x273fe3db, 0x32a1eaee),
978 MODULE_DEVICE_TABLE(pcmcia
, hostap_cs_ids
);
981 static struct pcmcia_driver hostap_driver
= {
985 .attach
= prism2_attach
,
986 .detach
= prism2_detach
,
987 .owner
= THIS_MODULE
,
988 .event
= prism2_event
,
989 .id_table
= hostap_cs_ids
,
992 static int __init
init_prism2_pccard(void)
994 printk(KERN_INFO
"%s: %s\n", dev_info
, version
);
995 return pcmcia_register_driver(&hostap_driver
);
998 static void __exit
exit_prism2_pccard(void)
1000 pcmcia_unregister_driver(&hostap_driver
);
1001 printk(KERN_INFO
"%s: Driver unloaded\n", dev_info
);
1005 module_init(init_prism2_pccard
);
1006 module_exit(exit_prism2_pccard
);