3
* Bluetooth driver for the Anycom BlueCard (LSE039/LSE041)
5
* Copyright (C) 2001-2002 Marcel Holtmann <marcel@holtmann.org>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License version 2 as
10
* published by the Free Software Foundation;
12
* Software distributed under the License is distributed on an "AS
13
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14
* implied. See the License for the specific language governing
15
* rights and limitations under the License.
17
* The initial developer of the original code is David A. Hinds
18
* <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
19
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
23
#include <linux/module.h>
25
#include <linux/kernel.h>
26
#include <linux/init.h>
27
#include <linux/slab.h>
28
#include <linux/types.h>
29
#include <linux/sched.h>
30
#include <linux/delay.h>
31
#include <linux/timer.h>
32
#include <linux/errno.h>
33
#include <linux/ptrace.h>
34
#include <linux/ioport.h>
35
#include <linux/spinlock.h>
36
#include <linux/moduleparam.h>
37
#include <linux/wait.h>
39
#include <linux/skbuff.h>
42
#include <pcmcia/cistpl.h>
43
#include <pcmcia/ciscode.h>
44
#include <pcmcia/ds.h>
45
#include <pcmcia/cisreg.h>
47
#include <net/bluetooth/bluetooth.h>
48
#include <net/bluetooth/hci_core.h>
52
/* ======================== Module parameters ======================== */
55
MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
56
MODULE_DESCRIPTION("Bluetooth driver for the Anycom BlueCard (LSE039/LSE041)");
57
MODULE_LICENSE("GPL");
61
/* ======================== Local structures ======================== */
64
typedef struct bluecard_info_t {
65
struct pcmcia_device *p_dev;
69
spinlock_t lock; /* For serializing operations */
70
struct timer_list timer; /* For LED control */
72
struct sk_buff_head txq;
73
unsigned long tx_state;
75
unsigned long rx_state;
76
unsigned long rx_count;
77
struct sk_buff *rx_skb;
79
unsigned char ctrl_reg;
80
unsigned long hw_state; /* Status of the hardware and LED control */
84
static int bluecard_config(struct pcmcia_device *link);
85
static void bluecard_release(struct pcmcia_device *link);
87
static void bluecard_detach(struct pcmcia_device *p_dev);
90
/* Default baud rate: 57600, 115200, 230400 or 460800 */
91
#define DEFAULT_BAUD_RATE 230400
96
#define CARD_HAS_PCCARD_ID 4
97
#define CARD_HAS_POWER_LED 5
98
#define CARD_HAS_ACTIVITY_LED 6
100
/* Transmit states */
101
#define XMIT_SENDING 1
102
#define XMIT_WAKEUP 2
103
#define XMIT_BUFFER_NUMBER 5 /* unset = buffer one, set = buffer two */
104
#define XMIT_BUF_ONE_READY 6
105
#define XMIT_BUF_TWO_READY 7
106
#define XMIT_SENDING_READY 8
108
/* Receiver states */
109
#define RECV_WAIT_PACKET_TYPE 0
110
#define RECV_WAIT_EVENT_HEADER 1
111
#define RECV_WAIT_ACL_HEADER 2
112
#define RECV_WAIT_SCO_HEADER 3
113
#define RECV_WAIT_DATA 4
115
/* Special packet types */
116
#define PKT_BAUD_RATE_57600 0x80
117
#define PKT_BAUD_RATE_115200 0x81
118
#define PKT_BAUD_RATE_230400 0x82
119
#define PKT_BAUD_RATE_460800 0x83
122
/* These are the register offsets */
123
#define REG_COMMAND 0x20
124
#define REG_INTERRUPT 0x21
125
#define REG_CONTROL 0x22
126
#define REG_RX_CONTROL 0x24
127
#define REG_CARD_RESET 0x30
128
#define REG_LED_CTRL 0x30
131
#define REG_COMMAND_TX_BUF_ONE 0x01
132
#define REG_COMMAND_TX_BUF_TWO 0x02
133
#define REG_COMMAND_RX_BUF_ONE 0x04
134
#define REG_COMMAND_RX_BUF_TWO 0x08
135
#define REG_COMMAND_RX_WIN_ONE 0x00
136
#define REG_COMMAND_RX_WIN_TWO 0x10
139
#define REG_CONTROL_BAUD_RATE_57600 0x00
140
#define REG_CONTROL_BAUD_RATE_115200 0x01
141
#define REG_CONTROL_BAUD_RATE_230400 0x02
142
#define REG_CONTROL_BAUD_RATE_460800 0x03
143
#define REG_CONTROL_RTS 0x04
144
#define REG_CONTROL_BT_ON 0x08
145
#define REG_CONTROL_BT_RESET 0x10
146
#define REG_CONTROL_BT_RES_PU 0x20
147
#define REG_CONTROL_INTERRUPT 0x40
148
#define REG_CONTROL_CARD_RESET 0x80
151
#define RTS_LEVEL_SHIFT_BITS 0x02
155
/* ======================== LED handling routines ======================== */
158
static void bluecard_activity_led_timeout(u_long arg)
160
bluecard_info_t *info = (bluecard_info_t *)arg;
161
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
162
unsigned int iobase = info->p_dev->resource[0]->start;
164
unsigned int iobase = info->p_dev->io.BasePort1;
168
if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))
171
if (test_bit(CARD_HAS_ACTIVITY_LED, &(info->hw_state))) {
172
/* Disable activity LED */
173
outb(0x08 | 0x20, iobase + 0x30);
175
/* Disable power LED */
176
outb(0x00, iobase + 0x30);
181
static void bluecard_enable_activity_led(bluecard_info_t *info)
183
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
184
unsigned int iobase = info->p_dev->resource[0]->start;
186
unsigned int iobase = info->p_dev->io.BasePort1;
189
if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))
192
if (test_bit(CARD_HAS_ACTIVITY_LED, &(info->hw_state))) {
193
/* Enable activity LED */
194
outb(0x10 | 0x40, iobase + 0x30);
196
/* Stop the LED after HZ/4 */
197
mod_timer(&(info->timer), jiffies + HZ / 4);
199
/* Enable power LED */
200
outb(0x08 | 0x20, iobase + 0x30);
202
/* Stop the LED after HZ/2 */
203
mod_timer(&(info->timer), jiffies + HZ / 2);
209
/* ======================== Interrupt handling ======================== */
212
static int bluecard_write(unsigned int iobase, unsigned int offset, __u8 *buf, int len)
216
actual = (len > 15) ? 15 : len;
218
outb_p(actual, iobase + offset);
220
for (i = 0; i < actual; i++)
221
outb_p(buf[i], iobase + offset + i + 1);
227
static void bluecard_write_wakeup(bluecard_info_t *info)
230
BT_ERR("Unknown device");
234
if (!test_bit(XMIT_SENDING_READY, &(info->tx_state)))
237
if (test_and_set_bit(XMIT_SENDING, &(info->tx_state))) {
238
set_bit(XMIT_WAKEUP, &(info->tx_state));
243
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
244
unsigned int iobase = info->p_dev->resource[0]->start;
246
unsigned int iobase = info->p_dev->io.BasePort1;
249
unsigned char command;
250
unsigned long ready_bit;
251
register struct sk_buff *skb;
254
clear_bit(XMIT_WAKEUP, &(info->tx_state));
256
if (!pcmcia_dev_present(info->p_dev))
259
if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) {
260
if (!test_bit(XMIT_BUF_TWO_READY, &(info->tx_state)))
263
command = REG_COMMAND_TX_BUF_TWO;
264
ready_bit = XMIT_BUF_TWO_READY;
266
if (!test_bit(XMIT_BUF_ONE_READY, &(info->tx_state)))
269
command = REG_COMMAND_TX_BUF_ONE;
270
ready_bit = XMIT_BUF_ONE_READY;
273
if (!(skb = skb_dequeue(&(info->txq))))
276
if (bt_cb(skb)->pkt_type & 0x80) {
278
info->ctrl_reg |= REG_CONTROL_RTS;
279
outb(info->ctrl_reg, iobase + REG_CONTROL);
283
bluecard_enable_activity_led(info);
286
len = bluecard_write(iobase, offset, skb->data, skb->len);
288
/* Tell the FPGA to send the data */
289
outb_p(command, iobase + REG_COMMAND);
291
/* Mark the buffer as dirty */
292
clear_bit(ready_bit, &(info->tx_state));
294
if (bt_cb(skb)->pkt_type & 0x80) {
295
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
298
unsigned char baud_reg;
300
switch (bt_cb(skb)->pkt_type) {
301
case PKT_BAUD_RATE_460800:
302
baud_reg = REG_CONTROL_BAUD_RATE_460800;
304
case PKT_BAUD_RATE_230400:
305
baud_reg = REG_CONTROL_BAUD_RATE_230400;
307
case PKT_BAUD_RATE_115200:
308
baud_reg = REG_CONTROL_BAUD_RATE_115200;
310
case PKT_BAUD_RATE_57600:
311
/* Fall through... */
313
baud_reg = REG_CONTROL_BAUD_RATE_57600;
317
/* Wait until the command reaches the baseband */
318
prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);
319
schedule_timeout(HZ/10);
320
finish_wait(&wq, &wait);
322
/* Set baud on baseband */
323
info->ctrl_reg &= ~0x03;
324
info->ctrl_reg |= baud_reg;
325
outb(info->ctrl_reg, iobase + REG_CONTROL);
328
info->ctrl_reg &= ~REG_CONTROL_RTS;
329
outb(info->ctrl_reg, iobase + REG_CONTROL);
331
/* Wait before the next HCI packet can be send */
332
prepare_to_wait(&wq, &wait, TASK_INTERRUPTIBLE);
333
schedule_timeout(HZ);
334
finish_wait(&wq, &wait);
337
if (len == skb->len) {
341
skb_queue_head(&(info->txq), skb);
344
info->hdev->stat.byte_tx += len;
347
change_bit(XMIT_BUFFER_NUMBER, &(info->tx_state));
349
} while (test_bit(XMIT_WAKEUP, &(info->tx_state)));
351
clear_bit(XMIT_SENDING, &(info->tx_state));
355
static int bluecard_read(unsigned int iobase, unsigned int offset, __u8 *buf, int size)
359
outb(REG_COMMAND_RX_WIN_ONE, iobase + REG_COMMAND);
361
len = inb(iobase + offset);
368
outb(REG_COMMAND_RX_WIN_TWO, iobase + REG_COMMAND);
372
buf[n] = inb(iobase + offset + i);
383
static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
386
unsigned char buf[31];
390
BT_ERR("Unknown device");
394
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
395
iobase = info->p_dev->resource[0]->start;
397
iobase = info->p_dev->io.BasePort1;
400
if (test_bit(XMIT_SENDING_READY, &(info->tx_state)))
401
bluecard_enable_activity_led(info);
403
len = bluecard_read(iobase, offset, buf, sizeof(buf));
405
for (i = 0; i < len; i++) {
407
/* Allocate packet */
408
if (info->rx_skb == NULL) {
409
info->rx_state = RECV_WAIT_PACKET_TYPE;
411
if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
412
BT_ERR("Can't allocate mem for new packet");
417
if (info->rx_state == RECV_WAIT_PACKET_TYPE) {
419
info->rx_skb->dev = (void *) info->hdev;
420
bt_cb(info->rx_skb)->pkt_type = buf[i];
422
switch (bt_cb(info->rx_skb)->pkt_type) {
426
if (offset != 0x00) {
427
set_bit(XMIT_BUF_ONE_READY, &(info->tx_state));
428
set_bit(XMIT_BUF_TWO_READY, &(info->tx_state));
429
set_bit(XMIT_SENDING_READY, &(info->tx_state));
430
bluecard_write_wakeup(info);
433
kfree_skb(info->rx_skb);
438
info->rx_state = RECV_WAIT_EVENT_HEADER;
439
info->rx_count = HCI_EVENT_HDR_SIZE;
442
case HCI_ACLDATA_PKT:
443
info->rx_state = RECV_WAIT_ACL_HEADER;
444
info->rx_count = HCI_ACL_HDR_SIZE;
447
case HCI_SCODATA_PKT:
448
info->rx_state = RECV_WAIT_SCO_HEADER;
449
info->rx_count = HCI_SCO_HDR_SIZE;
454
BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
455
info->hdev->stat.err_rx++;
457
kfree_skb(info->rx_skb);
465
*skb_put(info->rx_skb, 1) = buf[i];
468
if (info->rx_count == 0) {
471
struct hci_event_hdr *eh;
472
struct hci_acl_hdr *ah;
473
struct hci_sco_hdr *sh;
475
switch (info->rx_state) {
477
case RECV_WAIT_EVENT_HEADER:
478
eh = hci_event_hdr(info->rx_skb);
479
info->rx_state = RECV_WAIT_DATA;
480
info->rx_count = eh->plen;
483
case RECV_WAIT_ACL_HEADER:
484
ah = hci_acl_hdr(info->rx_skb);
485
dlen = __le16_to_cpu(ah->dlen);
486
info->rx_state = RECV_WAIT_DATA;
487
info->rx_count = dlen;
490
case RECV_WAIT_SCO_HEADER:
491
sh = hci_sco_hdr(info->rx_skb);
492
info->rx_state = RECV_WAIT_DATA;
493
info->rx_count = sh->dlen;
497
hci_recv_frame(info->rx_skb);
510
info->hdev->stat.byte_rx += len;
514
static irqreturn_t bluecard_interrupt(int irq, void *dev_inst)
516
bluecard_info_t *info = dev_inst;
520
if (!info || !info->hdev)
521
/* our irq handler is shared */
524
if (!test_bit(CARD_READY, &(info->hw_state)))
527
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
528
iobase = info->p_dev->resource[0]->start;
530
iobase = info->p_dev->io.BasePort1;
533
spin_lock(&(info->lock));
535
/* Disable interrupt */
536
info->ctrl_reg &= ~REG_CONTROL_INTERRUPT;
537
outb(info->ctrl_reg, iobase + REG_CONTROL);
539
reg = inb(iobase + REG_INTERRUPT);
541
if ((reg != 0x00) && (reg != 0xff)) {
544
bluecard_receive(info, 0x00);
545
outb(0x04, iobase + REG_INTERRUPT);
546
outb(REG_COMMAND_RX_BUF_ONE, iobase + REG_COMMAND);
550
bluecard_receive(info, 0x10);
551
outb(0x08, iobase + REG_INTERRUPT);
552
outb(REG_COMMAND_RX_BUF_TWO, iobase + REG_COMMAND);
556
set_bit(XMIT_BUF_ONE_READY, &(info->tx_state));
557
outb(0x01, iobase + REG_INTERRUPT);
558
bluecard_write_wakeup(info);
562
set_bit(XMIT_BUF_TWO_READY, &(info->tx_state));
563
outb(0x02, iobase + REG_INTERRUPT);
564
bluecard_write_wakeup(info);
569
/* Enable interrupt */
570
info->ctrl_reg |= REG_CONTROL_INTERRUPT;
571
outb(info->ctrl_reg, iobase + REG_CONTROL);
573
spin_unlock(&(info->lock));
580
/* ======================== Device specific HCI commands ======================== */
583
static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud)
585
bluecard_info_t *info = hci_get_drvdata(hdev);
588
/* Ericsson baud rate command */
589
unsigned char cmd[] = { HCI_COMMAND_PKT, 0x09, 0xfc, 0x01, 0x03 };
591
if (!(skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
592
BT_ERR("Can't allocate mem for new packet");
599
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_460800;
603
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_230400;
607
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_115200;
610
/* Fall through... */
613
bt_cb(skb)->pkt_type = PKT_BAUD_RATE_57600;
617
memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd));
619
skb_queue_tail(&(info->txq), skb);
621
bluecard_write_wakeup(info);
628
/* ======================== HCI interface ======================== */
631
static int bluecard_hci_flush(struct hci_dev *hdev)
633
bluecard_info_t *info = hci_get_drvdata(hdev);
636
skb_queue_purge(&(info->txq));
642
static int bluecard_hci_open(struct hci_dev *hdev)
644
bluecard_info_t *info = hci_get_drvdata(hdev);
646
if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))
647
bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE);
649
if (test_and_set_bit(HCI_RUNNING, &(hdev->flags)))
652
if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) {
653
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
654
unsigned int iobase = info->p_dev->resource[0]->start;
656
unsigned int iobase = info->p_dev->io.BasePort1;
660
outb(0x08 | 0x20, iobase + 0x30);
667
static int bluecard_hci_close(struct hci_dev *hdev)
669
bluecard_info_t *info = hci_get_drvdata(hdev);
671
if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags)))
674
bluecard_hci_flush(hdev);
676
if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) {
677
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
678
unsigned int iobase = info->p_dev->resource[0]->start;
680
unsigned int iobase = info->p_dev->io.BasePort1;
684
outb(0x00, iobase + 0x30);
691
static int bluecard_hci_send_frame(struct sk_buff *skb)
693
bluecard_info_t *info;
694
struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
697
BT_ERR("Frame for unknown HCI device (hdev=NULL)");
701
info = hci_get_drvdata(hdev);
703
switch (bt_cb(skb)->pkt_type) {
704
case HCI_COMMAND_PKT:
707
case HCI_ACLDATA_PKT:
710
case HCI_SCODATA_PKT:
715
/* Prepend skb with frame type */
716
memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
717
skb_queue_tail(&(info->txq), skb);
719
bluecard_write_wakeup(info);
725
static int bluecard_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
732
/* ======================== Card services HCI interaction ======================== */
735
static int bluecard_open(bluecard_info_t *info)
737
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
738
unsigned int iobase = info->p_dev->resource[0]->start;
740
unsigned int iobase = info->p_dev->io.BasePort1;
742
struct hci_dev *hdev;
745
spin_lock_init(&(info->lock));
747
init_timer(&(info->timer));
748
info->timer.function = &bluecard_activity_led_timeout;
749
info->timer.data = (u_long)info;
751
skb_queue_head_init(&(info->txq));
753
info->rx_state = RECV_WAIT_PACKET_TYPE;
757
/* Initialize HCI device */
758
hdev = hci_alloc_dev();
760
BT_ERR("Can't allocate HCI device");
766
hdev->bus = HCI_PCCARD;
767
hci_set_drvdata(hdev, info);
768
SET_HCIDEV_DEV(hdev, &info->p_dev->dev);
770
hdev->open = bluecard_hci_open;
771
hdev->close = bluecard_hci_close;
772
hdev->flush = bluecard_hci_flush;
773
hdev->send = bluecard_hci_send_frame;
774
hdev->ioctl = bluecard_hci_ioctl;
776
id = inb(iobase + 0x30);
778
if ((id & 0x0f) == 0x02)
779
set_bit(CARD_HAS_PCCARD_ID, &(info->hw_state));
782
set_bit(CARD_HAS_POWER_LED, &(info->hw_state));
785
set_bit(CARD_HAS_ACTIVITY_LED, &(info->hw_state));
788
info->ctrl_reg = REG_CONTROL_BT_RESET | REG_CONTROL_CARD_RESET;
789
outb(info->ctrl_reg, iobase + REG_CONTROL);
792
outb(0x80, iobase + 0x30);
798
outb(0x00, iobase + 0x30);
801
info->ctrl_reg = REG_CONTROL_BT_ON | REG_CONTROL_BT_RES_PU;
802
outb(info->ctrl_reg, iobase + REG_CONTROL);
804
/* Enable interrupt */
805
outb(0xff, iobase + REG_INTERRUPT);
806
info->ctrl_reg |= REG_CONTROL_INTERRUPT;
807
outb(info->ctrl_reg, iobase + REG_CONTROL);
809
if ((id & 0x0f) == 0x03) {
811
info->ctrl_reg |= REG_CONTROL_RTS;
812
outb(info->ctrl_reg, iobase + REG_CONTROL);
815
info->ctrl_reg |= 0x03;
816
outb(info->ctrl_reg, iobase + REG_CONTROL);
819
info->ctrl_reg &= ~REG_CONTROL_RTS;
820
outb(info->ctrl_reg, iobase + REG_CONTROL);
822
set_bit(XMIT_BUF_ONE_READY, &(info->tx_state));
823
set_bit(XMIT_BUF_TWO_READY, &(info->tx_state));
824
set_bit(XMIT_SENDING_READY, &(info->tx_state));
827
/* Start the RX buffers */
828
outb(REG_COMMAND_RX_BUF_ONE, iobase + REG_COMMAND);
829
outb(REG_COMMAND_RX_BUF_TWO, iobase + REG_COMMAND);
831
/* Signal that the hardware is ready */
832
set_bit(CARD_READY, &(info->hw_state));
835
skb_queue_purge(&(info->txq));
837
/* Control the point at which RTS is enabled */
838
outb((0x0f << RTS_LEVEL_SHIFT_BITS) | 1, iobase + REG_RX_CONTROL);
840
/* Timeout before it is safe to send the first HCI packet */
843
/* Register HCI device */
844
if (hci_register_dev(hdev) < 0) {
845
BT_ERR("Can't register HCI device");
855
static int bluecard_close(bluecard_info_t *info)
857
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
858
unsigned int iobase = info->p_dev->resource[0]->start;
860
unsigned int iobase = info->p_dev->io.BasePort1;
862
struct hci_dev *hdev = info->hdev;
867
bluecard_hci_close(hdev);
869
clear_bit(CARD_READY, &(info->hw_state));
872
info->ctrl_reg = REG_CONTROL_BT_RESET | REG_CONTROL_CARD_RESET;
873
outb(info->ctrl_reg, iobase + REG_CONTROL);
876
outb(0x80, iobase + 0x30);
878
hci_unregister_dev(hdev);
884
static int bluecard_probe(struct pcmcia_device *link)
886
bluecard_info_t *info;
888
/* Create new info device */
889
info = kzalloc(sizeof(*info), GFP_KERNEL);
896
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
897
link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
899
link->irq.Handler = bluecard_interrupt;
902
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
903
link->config_flags |= CONF_ENABLE_IRQ;
905
link->conf.Attributes = CONF_ENABLE_IRQ;
906
link->conf.IntType = INT_MEMORY_AND_IO;
909
return bluecard_config(link);
913
static void bluecard_detach(struct pcmcia_device *link)
915
bluecard_info_t *info = link->priv;
917
bluecard_release(link);
922
static int bluecard_config(struct pcmcia_device *link)
924
bluecard_info_t *info = link->priv;
927
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
928
link->config_index = 0x20;
930
link->conf.ConfigIndex = 0x20;
933
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
934
link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
935
link->resource[0]->end = 64;
938
link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
939
link->io.NumPorts1 = 64;
940
link->io.IOAddrLines = 6;
943
for (n = 0; n < 0x400; n += 0x40) {
944
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
945
link->resource[0]->start = n ^ 0x300;
946
i = pcmcia_request_io(link);
948
link->io.BasePort1 = n ^ 0x300;
949
i = pcmcia_request_io(link, &link->io);
958
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
959
i = pcmcia_request_irq(link, bluecard_interrupt);
963
i = pcmcia_request_irq(link, &link->irq);
965
link->irq.AssignedIRQ = 0;
968
i = pcmcia_enable_device(link);
972
if (bluecard_open(info) != 0)
978
bluecard_release(link);
983
static void bluecard_release(struct pcmcia_device *link)
985
bluecard_info_t *info = link->priv;
987
bluecard_close(info);
989
del_timer(&(info->timer));
991
pcmcia_disable_device(link);
994
static const struct pcmcia_device_id bluecard_ids[] = {
995
PCMCIA_DEVICE_PROD_ID12("BlueCard", "LSE041", 0xbaf16fbf, 0x657cc15e),
996
PCMCIA_DEVICE_PROD_ID12("BTCFCARD", "LSE139", 0xe3987764, 0x2524b59c),
997
PCMCIA_DEVICE_PROD_ID12("WSS", "LSE039", 0x0a0736ec, 0x24e6dfab),
1000
MODULE_DEVICE_TABLE(pcmcia, bluecard_ids);
1002
static struct pcmcia_driver bluecard_driver = {
1003
.owner = THIS_MODULE,
1004
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
1005
.name = "bluecard_cs",
1008
.name = "bluecard_cs",
1011
.probe = bluecard_probe,
1012
.remove = bluecard_detach,
1013
.id_table = bluecard_ids,
1016
static int __init init_bluecard_cs(void)
1018
return pcmcia_register_driver(&bluecard_driver);
1022
static void __exit exit_bluecard_cs(void)
1024
pcmcia_unregister_driver(&bluecard_driver);
1027
module_init(init_bluecard_cs);
1028
module_exit(exit_bluecard_cs);