3 * Driver for the 3Com Bluetooth PCMCIA card
5 * Copyright (C) 2001-2002 Marcel Holtmann <marcel@holtmann.org>
6 * Jose Orlando Pereira <jop@di.uminho.pt>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation;
13 * Software distributed under the License is distributed on an "AS
14 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15 * implied. See the License for the specific language governing
16 * rights and limitations under the License.
18 * The initial developer of the original code is David A. Hinds
19 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
20 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
24 #include <linux/config.h>
25 #include <linux/module.h>
27 #include <linux/kernel.h>
28 #include <linux/init.h>
29 #include <linux/slab.h>
30 #include <linux/types.h>
31 #include <linux/sched.h>
32 #include <linux/delay.h>
33 #include <linux/errno.h>
34 #include <linux/ptrace.h>
35 #include <linux/ioport.h>
36 #include <linux/spinlock.h>
38 #include <linux/skbuff.h>
39 #include <linux/string.h>
40 #include <linux/serial.h>
41 #include <linux/serial_reg.h>
42 #include <asm/system.h>
43 #include <asm/bitops.h>
46 #include <linux/device.h>
47 #include <linux/firmware.h>
49 #include <pcmcia/version.h>
50 #include <pcmcia/cs_types.h>
51 #include <pcmcia/cs.h>
52 #include <pcmcia/cistpl.h>
53 #include <pcmcia/ciscode.h>
54 #include <pcmcia/ds.h>
55 #include <pcmcia/cisreg.h>
57 #include <net/bluetooth/bluetooth.h>
58 #include <net/bluetooth/hci_core.h>
62 /* ======================== Module parameters ======================== */
65 /* Bit map of interrupts to choose from */
66 static u_int irq_mask
= 0xffff;
67 static int irq_list
[4] = { -1 };
69 MODULE_PARM(irq_mask
, "i");
70 MODULE_PARM(irq_list
, "1-4i");
72 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>, Jose Orlando Pereira <jop@di.uminho.pt>");
73 MODULE_DESCRIPTION("Bluetooth driver for the 3Com Bluetooth PCMCIA card");
74 MODULE_LICENSE("GPL");
78 /* ======================== Local structures ======================== */
81 typedef struct bt3c_info_t
{
87 spinlock_t lock
; /* For serializing operations */
89 struct sk_buff_head txq
;
90 unsigned long tx_state
;
92 unsigned long rx_state
;
93 unsigned long rx_count
;
94 struct sk_buff
*rx_skb
;
98 void bt3c_config(dev_link_t
*link
);
99 void bt3c_release(dev_link_t
*link
);
100 int bt3c_event(event_t event
, int priority
, event_callback_args_t
*args
);
102 static dev_info_t dev_info
= "bt3c_cs";
104 dev_link_t
*bt3c_attach(void);
105 void bt3c_detach(dev_link_t
*);
107 static dev_link_t
*dev_list
= NULL
;
110 /* Transmit states */
111 #define XMIT_SENDING 1
112 #define XMIT_WAKEUP 2
113 #define XMIT_WAITING 8
115 /* Receiver states */
116 #define RECV_WAIT_PACKET_TYPE 0
117 #define RECV_WAIT_EVENT_HEADER 1
118 #define RECV_WAIT_ACL_HEADER 2
119 #define RECV_WAIT_SCO_HEADER 3
120 #define RECV_WAIT_DATA 4
124 /* ======================== Special I/O functions ======================== */
134 inline void bt3c_address(unsigned int iobase
, unsigned short addr
)
136 outb(addr
& 0xff, iobase
+ ADDR_L
);
137 outb((addr
>> 8) & 0xff, iobase
+ ADDR_H
);
141 inline void bt3c_put(unsigned int iobase
, unsigned short value
)
143 outb(value
& 0xff, iobase
+ DATA_L
);
144 outb((value
>> 8) & 0xff, iobase
+ DATA_H
);
148 inline void bt3c_io_write(unsigned int iobase
, unsigned short addr
, unsigned short value
)
150 bt3c_address(iobase
, addr
);
151 bt3c_put(iobase
, value
);
155 inline unsigned short bt3c_get(unsigned int iobase
)
157 unsigned short value
= inb(iobase
+ DATA_L
);
159 value
|= inb(iobase
+ DATA_H
) << 8;
165 inline unsigned short bt3c_read(unsigned int iobase
, unsigned short addr
)
167 bt3c_address(iobase
, addr
);
169 return bt3c_get(iobase
);
174 /* ======================== Interrupt handling ======================== */
177 static int bt3c_write(unsigned int iobase
, int fifo_size
, __u8
*buf
, int len
)
181 bt3c_address(iobase
, 0x7080);
183 /* Fill FIFO with current frame */
184 while (actual
< len
) {
185 /* Transmit next byte */
186 bt3c_put(iobase
, buf
[actual
]);
190 bt3c_io_write(iobase
, 0x7005, actual
);
196 static void bt3c_write_wakeup(bt3c_info_t
*info
)
199 BT_ERR("Unknown device");
203 if (test_and_set_bit(XMIT_SENDING
, &(info
->tx_state
)))
207 register unsigned int iobase
= info
->link
.io
.BasePort1
;
208 register struct sk_buff
*skb
;
211 if (!(info
->link
.state
& DEV_PRESENT
))
215 if (!(skb
= skb_dequeue(&(info
->txq
)))) {
216 clear_bit(XMIT_SENDING
, &(info
->tx_state
));
221 len
= bt3c_write(iobase
, 256, skb
->data
, skb
->len
);
223 if (len
!= skb
->len
) {
224 BT_ERR("Very strange");
229 info
->hdev
->stat
.byte_tx
+= len
;
235 static void bt3c_receive(bt3c_info_t
*info
)
241 BT_ERR("Unknown device");
245 iobase
= info
->link
.io
.BasePort1
;
247 avail
= bt3c_read(iobase
, 0x7006);
248 //printk("bt3c_cs: receiving %d bytes\n", avail);
250 bt3c_address(iobase
, 0x7480);
251 while (size
< avail
) {
253 info
->hdev
->stat
.byte_rx
++;
255 /* Allocate packet */
256 if (info
->rx_skb
== NULL
) {
257 info
->rx_state
= RECV_WAIT_PACKET_TYPE
;
259 if (!(info
->rx_skb
= bt_skb_alloc(HCI_MAX_FRAME_SIZE
, GFP_ATOMIC
))) {
260 BT_ERR("Can't allocate mem for new packet");
266 if (info
->rx_state
== RECV_WAIT_PACKET_TYPE
) {
268 info
->rx_skb
->dev
= (void *) info
->hdev
;
269 info
->rx_skb
->pkt_type
= inb(iobase
+ DATA_L
);
270 inb(iobase
+ DATA_H
);
271 //printk("bt3c: PACKET_TYPE=%02x\n", info->rx_skb->pkt_type);
273 switch (info
->rx_skb
->pkt_type
) {
276 info
->rx_state
= RECV_WAIT_EVENT_HEADER
;
277 info
->rx_count
= HCI_EVENT_HDR_SIZE
;
280 case HCI_ACLDATA_PKT
:
281 info
->rx_state
= RECV_WAIT_ACL_HEADER
;
282 info
->rx_count
= HCI_ACL_HDR_SIZE
;
285 case HCI_SCODATA_PKT
:
286 info
->rx_state
= RECV_WAIT_SCO_HEADER
;
287 info
->rx_count
= HCI_SCO_HDR_SIZE
;
292 BT_ERR("Unknown HCI packet with type 0x%02x received", info
->rx_skb
->pkt_type
);
293 info
->hdev
->stat
.err_rx
++;
294 clear_bit(HCI_RUNNING
, &(info
->hdev
->flags
));
296 kfree_skb(info
->rx_skb
);
304 __u8 x
= inb(iobase
+ DATA_L
);
306 *skb_put(info
->rx_skb
, 1) = x
;
307 inb(iobase
+ DATA_H
);
310 if (info
->rx_count
== 0) {
313 struct hci_event_hdr
*eh
;
314 struct hci_acl_hdr
*ah
;
315 struct hci_sco_hdr
*sh
;
317 switch (info
->rx_state
) {
319 case RECV_WAIT_EVENT_HEADER
:
320 eh
= (struct hci_event_hdr
*)(info
->rx_skb
->data
);
321 info
->rx_state
= RECV_WAIT_DATA
;
322 info
->rx_count
= eh
->plen
;
325 case RECV_WAIT_ACL_HEADER
:
326 ah
= (struct hci_acl_hdr
*)(info
->rx_skb
->data
);
327 dlen
= __le16_to_cpu(ah
->dlen
);
328 info
->rx_state
= RECV_WAIT_DATA
;
329 info
->rx_count
= dlen
;
332 case RECV_WAIT_SCO_HEADER
:
333 sh
= (struct hci_sco_hdr
*)(info
->rx_skb
->data
);
334 info
->rx_state
= RECV_WAIT_DATA
;
335 info
->rx_count
= sh
->dlen
;
339 hci_recv_frame(info
->rx_skb
);
351 bt3c_io_write(iobase
, 0x7006, 0x0000);
355 static irqreturn_t
bt3c_interrupt(int irq
, void *dev_inst
, struct pt_regs
*regs
)
357 bt3c_info_t
*info
= dev_inst
;
361 if (!info
|| !info
->hdev
) {
362 BT_ERR("Call of irq %d for unknown device", irq
);
366 iobase
= info
->link
.io
.BasePort1
;
368 spin_lock(&(info
->lock
));
370 iir
= inb(iobase
+ CONTROL
);
372 int stat
= bt3c_read(iobase
, 0x7001);
374 if ((stat
& 0xff) == 0x7f) {
375 BT_ERR("Very strange (stat=0x%04x)", stat
);
376 } else if ((stat
& 0xff) != 0xff) {
378 int stat
= bt3c_read(iobase
, 0x7002) & 0x10;
379 BT_INFO("%s: Antenna %s", info
->hdev
->name
,
380 stat
? "out" : "in");
385 //BT_ERR("Ack (stat=0x%04x)", stat);
386 clear_bit(XMIT_SENDING
, &(info
->tx_state
));
387 bt3c_write_wakeup(info
);
390 bt3c_io_write(iobase
, 0x7001, 0x0000);
392 outb(iir
, iobase
+ CONTROL
);
396 spin_unlock(&(info
->lock
));
403 /* ======================== HCI interface ======================== */
406 static int bt3c_hci_flush(struct hci_dev
*hdev
)
408 bt3c_info_t
*info
= (bt3c_info_t
*)(hdev
->driver_data
);
411 skb_queue_purge(&(info
->txq
));
417 static int bt3c_hci_open(struct hci_dev
*hdev
)
419 set_bit(HCI_RUNNING
, &(hdev
->flags
));
425 static int bt3c_hci_close(struct hci_dev
*hdev
)
427 if (!test_and_clear_bit(HCI_RUNNING
, &(hdev
->flags
)))
430 bt3c_hci_flush(hdev
);
436 static int bt3c_hci_send_frame(struct sk_buff
*skb
)
439 struct hci_dev
*hdev
= (struct hci_dev
*)(skb
->dev
);
443 BT_ERR("Frame for unknown HCI device (hdev=NULL)");
447 info
= (bt3c_info_t
*) (hdev
->driver_data
);
449 switch (skb
->pkt_type
) {
450 case HCI_COMMAND_PKT
:
453 case HCI_ACLDATA_PKT
:
456 case HCI_SCODATA_PKT
:
461 /* Prepend skb with frame type */
462 memcpy(skb_push(skb
, 1), &(skb
->pkt_type
), 1);
463 skb_queue_tail(&(info
->txq
), skb
);
465 spin_lock_irqsave(&(info
->lock
), flags
);
467 bt3c_write_wakeup(info
);
469 spin_unlock_irqrestore(&(info
->lock
), flags
);
475 static void bt3c_hci_destruct(struct hci_dev
*hdev
)
480 static int bt3c_hci_ioctl(struct hci_dev
*hdev
, unsigned int cmd
, unsigned long arg
)
487 /* ======================== Card services HCI interaction ======================== */
490 static struct device
*bt3c_device(void)
492 static char *kobj_name
= "bt3c";
494 static struct device dev
= {
497 dev
.kobj
.k_name
= kmalloc(strlen(kobj_name
) + 1, GFP_KERNEL
);
498 strcpy(dev
.kobj
.k_name
, kobj_name
);
499 kobject_init(&dev
.kobj
);
505 static int bt3c_load_firmware(bt3c_info_t
*info
, unsigned char *firmware
, int count
)
507 char *ptr
= (char *) firmware
;
509 unsigned int iobase
, size
, addr
, fcs
, tmp
;
512 iobase
= info
->link
.io
.BasePort1
;
515 bt3c_io_write(iobase
, 0x8040, 0x0404);
516 bt3c_io_write(iobase
, 0x8040, 0x0400);
520 bt3c_io_write(iobase
, 0x8040, 0x0404);
527 BT_ERR("Bad address in firmware");
532 memset(b
, 0, sizeof(b
));
533 memcpy(b
, ptr
+ 2, 2);
534 size
= simple_strtol(b
, NULL
, 16);
536 memset(b
, 0, sizeof(b
));
537 memcpy(b
, ptr
+ 4, 8);
538 addr
= simple_strtol(b
, NULL
, 16);
540 memset(b
, 0, sizeof(b
));
541 memcpy(b
, ptr
+ (size
* 2) + 2, 2);
542 fcs
= simple_strtol(b
, NULL
, 16);
544 memset(b
, 0, sizeof(b
));
545 for (tmp
= 0, i
= 0; i
< size
; i
++) {
546 memcpy(b
, ptr
+ (i
* 2) + 2, 2);
547 tmp
+= simple_strtol(b
, NULL
, 16);
550 if (((tmp
+ fcs
) & 0xff) != 0xff) {
551 BT_ERR("Checksum error in firmware");
557 bt3c_address(iobase
, addr
);
559 memset(b
, 0, sizeof(b
));
560 for (i
= 0; i
< (size
- 4) / 2; i
++) {
561 memcpy(b
, ptr
+ (i
* 4) + 12, 4);
562 tmp
= simple_strtol(b
, NULL
, 16);
563 bt3c_put(iobase
, tmp
);
567 ptr
+= (size
* 2) + 6;
568 count
-= (size
* 2) + 6;
574 bt3c_address(iobase
, 0x3000);
575 outb(inb(iobase
+ CONTROL
) | 0x40, iobase
+ CONTROL
);
581 bt3c_io_write(iobase
, 0x7006, 0x0000);
582 bt3c_io_write(iobase
, 0x7005, 0x0000);
583 bt3c_io_write(iobase
, 0x7001, 0x0000);
589 int bt3c_open(bt3c_info_t
*info
)
591 const struct firmware
*firmware
;
592 struct hci_dev
*hdev
;
595 spin_lock_init(&(info
->lock
));
597 skb_queue_head_init(&(info
->txq
));
599 info
->rx_state
= RECV_WAIT_PACKET_TYPE
;
603 /* Initialize HCI device */
604 hdev
= hci_alloc_dev();
606 BT_ERR("Can't allocate HCI device");
612 hdev
->type
= HCI_PCCARD
;
613 hdev
->driver_data
= info
;
615 hdev
->open
= bt3c_hci_open
;
616 hdev
->close
= bt3c_hci_close
;
617 hdev
->flush
= bt3c_hci_flush
;
618 hdev
->send
= bt3c_hci_send_frame
;
619 hdev
->destruct
= bt3c_hci_destruct
;
620 hdev
->ioctl
= bt3c_hci_ioctl
;
622 hdev
->owner
= THIS_MODULE
;
625 err
= request_firmware(&firmware
, "BT3CPCC.bin", bt3c_device());
627 BT_ERR("Firmware request failed");
631 err
= bt3c_load_firmware(info
, firmware
->data
, firmware
->size
);
633 release_firmware(firmware
);
636 BT_ERR("Firmware loading failed");
640 /* Timeout before it is safe to send the first HCI packet */
643 /* Register HCI device */
644 err
= hci_register_dev(hdev
);
646 BT_ERR("Can't register HCI device");
659 int bt3c_close(bt3c_info_t
*info
)
661 struct hci_dev
*hdev
= info
->hdev
;
666 bt3c_hci_close(hdev
);
668 if (hci_unregister_dev(hdev
) < 0)
669 BT_ERR("Can't unregister HCI device %s", hdev
->name
);
676 dev_link_t
*bt3c_attach(void)
679 client_reg_t client_reg
;
683 /* Create new info device */
684 info
= kmalloc(sizeof(*info
), GFP_KERNEL
);
687 memset(info
, 0, sizeof(*info
));
692 link
->io
.Attributes1
= IO_DATA_PATH_WIDTH_8
;
693 link
->io
.NumPorts1
= 8;
694 link
->irq
.Attributes
= IRQ_TYPE_EXCLUSIVE
| IRQ_HANDLE_PRESENT
;
695 link
->irq
.IRQInfo1
= IRQ_INFO2_VALID
| IRQ_LEVEL_ID
;
697 if (irq_list
[0] == -1)
698 link
->irq
.IRQInfo2
= irq_mask
;
700 for (i
= 0; i
< 4; i
++)
701 link
->irq
.IRQInfo2
|= 1 << irq_list
[i
];
703 link
->irq
.Handler
= bt3c_interrupt
;
704 link
->irq
.Instance
= info
;
706 link
->conf
.Attributes
= CONF_ENABLE_IRQ
;
708 link
->conf
.IntType
= INT_MEMORY_AND_IO
;
710 /* Register with Card Services */
711 link
->next
= dev_list
;
713 client_reg
.dev_info
= &dev_info
;
714 client_reg
.Attributes
= INFO_IO_CLIENT
| INFO_CARD_SHARE
;
715 client_reg
.EventMask
=
716 CS_EVENT_CARD_INSERTION
| CS_EVENT_CARD_REMOVAL
|
717 CS_EVENT_RESET_PHYSICAL
| CS_EVENT_CARD_RESET
|
718 CS_EVENT_PM_SUSPEND
| CS_EVENT_PM_RESUME
;
719 client_reg
.event_handler
= &bt3c_event
;
720 client_reg
.Version
= 0x0210;
721 client_reg
.event_callback_args
.client_data
= link
;
723 ret
= pcmcia_register_client(&link
->handle
, &client_reg
);
724 if (ret
!= CS_SUCCESS
) {
725 cs_error(link
->handle
, RegisterClient
, ret
);
734 void bt3c_detach(dev_link_t
*link
)
736 bt3c_info_t
*info
= link
->priv
;
740 /* Locate device structure */
741 for (linkp
= &dev_list
; *linkp
; linkp
= &(*linkp
)->next
)
748 if (link
->state
& DEV_CONFIG
)
752 ret
= pcmcia_deregister_client(link
->handle
);
753 if (ret
!= CS_SUCCESS
)
754 cs_error(link
->handle
, DeregisterClient
, ret
);
757 /* Unlink device structure, free bits */
763 static int get_tuple(client_handle_t handle
, tuple_t
*tuple
, cisparse_t
*parse
)
767 i
= pcmcia_get_tuple_data(handle
, tuple
);
771 return pcmcia_parse_tuple(handle
, tuple
, parse
);
774 static int first_tuple(client_handle_t handle
, tuple_t
*tuple
, cisparse_t
*parse
)
776 if (pcmcia_get_first_tuple(handle
, tuple
) != CS_SUCCESS
)
777 return CS_NO_MORE_ITEMS
;
778 return get_tuple(handle
, tuple
, parse
);
781 static int next_tuple(client_handle_t handle
, tuple_t
*tuple
, cisparse_t
*parse
)
783 if (pcmcia_get_next_tuple(handle
, tuple
) != CS_SUCCESS
)
784 return CS_NO_MORE_ITEMS
;
785 return get_tuple(handle
, tuple
, parse
);
788 void bt3c_config(dev_link_t
*link
)
790 static ioaddr_t base
[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
791 client_handle_t handle
= link
->handle
;
792 bt3c_info_t
*info
= link
->priv
;
796 cistpl_cftable_entry_t
*cf
= &parse
.cftable_entry
;
797 config_info_t config
;
798 int i
, j
, try, last_ret
, last_fn
;
800 tuple
.TupleData
= (cisdata_t
*)buf
;
801 tuple
.TupleOffset
= 0;
802 tuple
.TupleDataMax
= 255;
803 tuple
.Attributes
= 0;
805 /* Get configuration register information */
806 tuple
.DesiredTuple
= CISTPL_CONFIG
;
807 last_ret
= first_tuple(handle
, &tuple
, &parse
);
808 if (last_ret
!= CS_SUCCESS
) {
809 last_fn
= ParseTuple
;
812 link
->conf
.ConfigBase
= parse
.config
.base
;
813 link
->conf
.Present
= parse
.config
.rmask
[0];
816 link
->state
|= DEV_CONFIG
;
817 i
= pcmcia_get_configuration_info(handle
, &config
);
818 link
->conf
.Vcc
= config
.Vcc
;
820 /* First pass: look for a config entry that looks normal. */
821 tuple
.TupleData
= (cisdata_t
*)buf
;
822 tuple
.TupleOffset
= 0;
823 tuple
.TupleDataMax
= 255;
824 tuple
.Attributes
= 0;
825 tuple
.DesiredTuple
= CISTPL_CFTABLE_ENTRY
;
826 /* Two tries: without IO aliases, then with aliases */
827 for (try = 0; try < 2; try++) {
828 i
= first_tuple(handle
, &tuple
, &parse
);
829 while (i
!= CS_NO_MORE_ITEMS
) {
832 if (cf
->vpp1
.present
& (1 << CISTPL_POWER_VNOM
))
833 link
->conf
.Vpp1
= link
->conf
.Vpp2
= cf
->vpp1
.param
[CISTPL_POWER_VNOM
] / 10000;
834 if ((cf
->io
.nwin
> 0) && (cf
->io
.win
[0].len
== 8) && (cf
->io
.win
[0].base
!= 0)) {
835 link
->conf
.ConfigIndex
= cf
->index
;
836 link
->io
.BasePort1
= cf
->io
.win
[0].base
;
837 link
->io
.IOAddrLines
= (try == 0) ? 16 : cf
->io
.flags
& CISTPL_IO_LINES_MASK
;
838 i
= pcmcia_request_io(link
->handle
, &link
->io
);
843 i
= next_tuple(handle
, &tuple
, &parse
);
847 /* Second pass: try to find an entry that isn't picky about
848 its base address, then try to grab any standard serial port
849 address, and finally try to get any free port. */
850 i
= first_tuple(handle
, &tuple
, &parse
);
851 while (i
!= CS_NO_MORE_ITEMS
) {
852 if ((i
== CS_SUCCESS
) && (cf
->io
.nwin
> 0) && ((cf
->io
.flags
& CISTPL_IO_LINES_MASK
) <= 3)) {
853 link
->conf
.ConfigIndex
= cf
->index
;
854 for (j
= 0; j
< 5; j
++) {
855 link
->io
.BasePort1
= base
[j
];
856 link
->io
.IOAddrLines
= base
[j
] ? 16 : 3;
857 i
= pcmcia_request_io(link
->handle
, &link
->io
);
862 i
= next_tuple(handle
, &tuple
, &parse
);
866 if (i
!= CS_SUCCESS
) {
867 BT_ERR("No usable port range found");
868 cs_error(link
->handle
, RequestIO
, i
);
872 i
= pcmcia_request_irq(link
->handle
, &link
->irq
);
873 if (i
!= CS_SUCCESS
) {
874 cs_error(link
->handle
, RequestIRQ
, i
);
875 link
->irq
.AssignedIRQ
= 0;
878 i
= pcmcia_request_configuration(link
->handle
, &link
->conf
);
879 if (i
!= CS_SUCCESS
) {
880 cs_error(link
->handle
, RequestConfiguration
, i
);
884 if (bt3c_open(info
) != 0)
887 strcpy(info
->node
.dev_name
, info
->hdev
->name
);
888 link
->dev
= &info
->node
;
889 link
->state
&= ~DEV_CONFIG_PENDING
;
894 cs_error(link
->handle
, last_fn
, last_ret
);
901 void bt3c_release(dev_link_t
*link
)
903 bt3c_info_t
*info
= link
->priv
;
905 if (link
->state
& DEV_PRESENT
)
910 pcmcia_release_configuration(link
->handle
);
911 pcmcia_release_io(link
->handle
, &link
->io
);
912 pcmcia_release_irq(link
->handle
, &link
->irq
);
914 link
->state
&= ~DEV_CONFIG
;
918 int bt3c_event(event_t event
, int priority
, event_callback_args_t
*args
)
920 dev_link_t
*link
= args
->client_data
;
921 bt3c_info_t
*info
= link
->priv
;
924 case CS_EVENT_CARD_REMOVAL
:
925 link
->state
&= ~DEV_PRESENT
;
926 if (link
->state
& DEV_CONFIG
) {
931 case CS_EVENT_CARD_INSERTION
:
932 link
->state
|= DEV_PRESENT
| DEV_CONFIG_PENDING
;
935 case CS_EVENT_PM_SUSPEND
:
936 link
->state
|= DEV_SUSPEND
;
937 /* Fall through... */
938 case CS_EVENT_RESET_PHYSICAL
:
939 if (link
->state
& DEV_CONFIG
)
940 pcmcia_release_configuration(link
->handle
);
942 case CS_EVENT_PM_RESUME
:
943 link
->state
&= ~DEV_SUSPEND
;
944 /* Fall through... */
945 case CS_EVENT_CARD_RESET
:
947 pcmcia_request_configuration(link
->handle
, &link
->conf
);
954 static struct pcmcia_driver bt3c_driver
= {
955 .owner
= THIS_MODULE
,
959 .attach
= bt3c_attach
,
960 .detach
= bt3c_detach
,
963 static int __init
init_bt3c_cs(void)
965 return pcmcia_register_driver(&bt3c_driver
);
969 static void __exit
exit_bt3c_cs(void)
971 pcmcia_unregister_driver(&bt3c_driver
);
973 /* XXX: this really needs to move into generic code.. */
974 while (dev_list
!= NULL
)
975 bt3c_detach(dev_list
);
978 module_init(init_bt3c_cs
);
979 module_exit(exit_bt3c_cs
);