[PATCH] pcmcia: remove dev_list from drivers
[linux-2.6.git] / drivers / bluetooth / dtl1_cs.c
1 /*
2  *
3  *  A driver for Nokia Connectivity Card DTL-1 devices
4  *
5  *  Copyright (C) 2001-2002  Marcel Holtmann <marcel@holtmann.org>
6  *
7  *
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;
11  *
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.
16  *
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.
20  *
21  */
22
23 #include <linux/config.h>
24 #include <linux/module.h>
25
26 #include <linux/kernel.h>
27 #include <linux/init.h>
28 #include <linux/slab.h>
29 #include <linux/types.h>
30 #include <linux/sched.h>
31 #include <linux/delay.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
38 #include <linux/skbuff.h>
39 #include <linux/string.h>
40 #include <linux/serial.h>
41 #include <linux/serial_reg.h>
42 #include <linux/bitops.h>
43 #include <asm/system.h>
44 #include <asm/io.h>
45
46 #include <pcmcia/cs_types.h>
47 #include <pcmcia/cs.h>
48 #include <pcmcia/cistpl.h>
49 #include <pcmcia/ciscode.h>
50 #include <pcmcia/ds.h>
51 #include <pcmcia/cisreg.h>
52
53 #include <net/bluetooth/bluetooth.h>
54 #include <net/bluetooth/hci_core.h>
55
56
57
58 /* ======================== Module parameters ======================== */
59
60
61 MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
62 MODULE_DESCRIPTION("Bluetooth driver for Nokia Connectivity Card DTL-1");
63 MODULE_LICENSE("GPL");
64
65
66
67 /* ======================== Local structures ======================== */
68
69
70 typedef struct dtl1_info_t {
71         dev_link_t link;
72         dev_node_t node;
73
74         struct hci_dev *hdev;
75
76         spinlock_t lock;                /* For serializing operations */
77
78         unsigned long flowmask;         /* HCI flow mask */
79         int ri_latch;
80
81         struct sk_buff_head txq;
82         unsigned long tx_state;
83
84         unsigned long rx_state;
85         unsigned long rx_count;
86         struct sk_buff *rx_skb;
87 } dtl1_info_t;
88
89
90 static void dtl1_config(dev_link_t *link);
91 static void dtl1_release(dev_link_t *link);
92 static int dtl1_event(event_t event, int priority, event_callback_args_t *args);
93
94 static dev_info_t dev_info = "dtl1_cs";
95
96 static dev_link_t *dtl1_attach(void);
97 static void dtl1_detach(struct pcmcia_device *p_dev);
98
99
100 /* Transmit states  */
101 #define XMIT_SENDING  1
102 #define XMIT_WAKEUP   2
103 #define XMIT_WAITING  8
104
105 /* Receiver States */
106 #define RECV_WAIT_NSH   0
107 #define RECV_WAIT_DATA  1
108
109
110 typedef struct {
111         u8 type;
112         u8 zero;
113         u16 len;
114 } __attribute__ ((packed)) nsh_t;       /* Nokia Specific Header */
115
116 #define NSHL  4                         /* Nokia Specific Header Length */
117
118
119
120 /* ======================== Interrupt handling ======================== */
121
122
123 static int dtl1_write(unsigned int iobase, int fifo_size, __u8 *buf, int len)
124 {
125         int actual = 0;
126
127         /* Tx FIFO should be empty */
128         if (!(inb(iobase + UART_LSR) & UART_LSR_THRE))
129                 return 0;
130
131         /* Fill FIFO with current frame */
132         while ((fifo_size-- > 0) && (actual < len)) {
133                 /* Transmit next byte */
134                 outb(buf[actual], iobase + UART_TX);
135                 actual++;
136         }
137
138         return actual;
139 }
140
141
142 static void dtl1_write_wakeup(dtl1_info_t *info)
143 {
144         if (!info) {
145                 BT_ERR("Unknown device");
146                 return;
147         }
148
149         if (test_bit(XMIT_WAITING, &(info->tx_state))) {
150                 set_bit(XMIT_WAKEUP, &(info->tx_state));
151                 return;
152         }
153
154         if (test_and_set_bit(XMIT_SENDING, &(info->tx_state))) {
155                 set_bit(XMIT_WAKEUP, &(info->tx_state));
156                 return;
157         }
158
159         do {
160                 register unsigned int iobase = info->link.io.BasePort1;
161                 register struct sk_buff *skb;
162                 register int len;
163
164                 clear_bit(XMIT_WAKEUP, &(info->tx_state));
165
166                 if (!(info->link.state & DEV_PRESENT))
167                         return;
168
169                 if (!(skb = skb_dequeue(&(info->txq))))
170                         break;
171
172                 /* Send frame */
173                 len = dtl1_write(iobase, 32, skb->data, skb->len);
174
175                 if (len == skb->len) {
176                         set_bit(XMIT_WAITING, &(info->tx_state));
177                         kfree_skb(skb);
178                 } else {
179                         skb_pull(skb, len);
180                         skb_queue_head(&(info->txq), skb);
181                 }
182
183                 info->hdev->stat.byte_tx += len;
184
185         } while (test_bit(XMIT_WAKEUP, &(info->tx_state)));
186
187         clear_bit(XMIT_SENDING, &(info->tx_state));
188 }
189
190
191 static void dtl1_control(dtl1_info_t *info, struct sk_buff *skb)
192 {
193         u8 flowmask = *(u8 *)skb->data;
194         int i;
195
196         printk(KERN_INFO "Bluetooth: Nokia control data =");
197         for (i = 0; i < skb->len; i++) {
198                 printk(" %02x", skb->data[i]);
199         }
200         printk("\n");
201
202         /* transition to active state */
203         if (((info->flowmask & 0x07) == 0) && ((flowmask & 0x07) != 0)) {
204                 clear_bit(XMIT_WAITING, &(info->tx_state));
205                 dtl1_write_wakeup(info);
206         }
207
208         info->flowmask = flowmask;
209
210         kfree_skb(skb);
211 }
212
213
214 static void dtl1_receive(dtl1_info_t *info)
215 {
216         unsigned int iobase;
217         nsh_t *nsh;
218         int boguscount = 0;
219
220         if (!info) {
221                 BT_ERR("Unknown device");
222                 return;
223         }
224
225         iobase = info->link.io.BasePort1;
226
227         do {
228                 info->hdev->stat.byte_rx++;
229
230                 /* Allocate packet */
231                 if (info->rx_skb == NULL)
232                         if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
233                                 BT_ERR("Can't allocate mem for new packet");
234                                 info->rx_state = RECV_WAIT_NSH;
235                                 info->rx_count = NSHL;
236                                 return;
237                         }
238
239                 *skb_put(info->rx_skb, 1) = inb(iobase + UART_RX);
240                 nsh = (nsh_t *)info->rx_skb->data;
241
242                 info->rx_count--;
243
244                 if (info->rx_count == 0) {
245
246                         switch (info->rx_state) {
247                         case RECV_WAIT_NSH:
248                                 info->rx_state = RECV_WAIT_DATA;
249                                 info->rx_count = nsh->len + (nsh->len & 0x0001);
250                                 break;
251                         case RECV_WAIT_DATA:
252                                 bt_cb(info->rx_skb)->pkt_type = nsh->type;
253
254                                 /* remove PAD byte if it exists */
255                                 if (nsh->len & 0x0001) {
256                                         info->rx_skb->tail--;
257                                         info->rx_skb->len--;
258                                 }
259
260                                 /* remove NSH */
261                                 skb_pull(info->rx_skb, NSHL);
262
263                                 switch (bt_cb(info->rx_skb)->pkt_type) {
264                                 case 0x80:
265                                         /* control data for the Nokia Card */
266                                         dtl1_control(info, info->rx_skb);
267                                         break;
268                                 case 0x82:
269                                 case 0x83:
270                                 case 0x84:
271                                         /* send frame to the HCI layer */
272                                         info->rx_skb->dev = (void *) info->hdev;
273                                         bt_cb(info->rx_skb)->pkt_type &= 0x0f;
274                                         hci_recv_frame(info->rx_skb);
275                                         break;
276                                 default:
277                                         /* unknown packet */
278                                         BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
279                                         kfree_skb(info->rx_skb);
280                                         break;
281                                 }
282
283                                 info->rx_state = RECV_WAIT_NSH;
284                                 info->rx_count = NSHL;
285                                 info->rx_skb = NULL;
286                                 break;
287                         }
288
289                 }
290
291                 /* Make sure we don't stay here too long */
292                 if (boguscount++ > 32)
293                         break;
294
295         } while (inb(iobase + UART_LSR) & UART_LSR_DR);
296 }
297
298
299 static irqreturn_t dtl1_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
300 {
301         dtl1_info_t *info = dev_inst;
302         unsigned int iobase;
303         unsigned char msr;
304         int boguscount = 0;
305         int iir, lsr;
306
307         if (!info || !info->hdev) {
308                 BT_ERR("Call of irq %d for unknown device", irq);
309                 return IRQ_NONE;
310         }
311
312         iobase = info->link.io.BasePort1;
313
314         spin_lock(&(info->lock));
315
316         iir = inb(iobase + UART_IIR) & UART_IIR_ID;
317         while (iir) {
318
319                 /* Clear interrupt */
320                 lsr = inb(iobase + UART_LSR);
321
322                 switch (iir) {
323                 case UART_IIR_RLSI:
324                         BT_ERR("RLSI");
325                         break;
326                 case UART_IIR_RDI:
327                         /* Receive interrupt */
328                         dtl1_receive(info);
329                         break;
330                 case UART_IIR_THRI:
331                         if (lsr & UART_LSR_THRE) {
332                                 /* Transmitter ready for data */
333                                 dtl1_write_wakeup(info);
334                         }
335                         break;
336                 default:
337                         BT_ERR("Unhandled IIR=%#x", iir);
338                         break;
339                 }
340
341                 /* Make sure we don't stay here too long */
342                 if (boguscount++ > 100)
343                         break;
344
345                 iir = inb(iobase + UART_IIR) & UART_IIR_ID;
346
347         }
348
349         msr = inb(iobase + UART_MSR);
350
351         if (info->ri_latch ^ (msr & UART_MSR_RI)) {
352                 info->ri_latch = msr & UART_MSR_RI;
353                 clear_bit(XMIT_WAITING, &(info->tx_state));
354                 dtl1_write_wakeup(info);
355         }
356
357         spin_unlock(&(info->lock));
358
359         return IRQ_HANDLED;
360 }
361
362
363
364 /* ======================== HCI interface ======================== */
365
366
367 static int dtl1_hci_open(struct hci_dev *hdev)
368 {
369         set_bit(HCI_RUNNING, &(hdev->flags));
370
371         return 0;
372 }
373
374
375 static int dtl1_hci_flush(struct hci_dev *hdev)
376 {
377         dtl1_info_t *info = (dtl1_info_t *)(hdev->driver_data);
378
379         /* Drop TX queue */
380         skb_queue_purge(&(info->txq));
381
382         return 0;
383 }
384
385
386 static int dtl1_hci_close(struct hci_dev *hdev)
387 {
388         if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags)))
389                 return 0;
390
391         dtl1_hci_flush(hdev);
392
393         return 0;
394 }
395
396
397 static int dtl1_hci_send_frame(struct sk_buff *skb)
398 {
399         dtl1_info_t *info;
400         struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
401         struct sk_buff *s;
402         nsh_t nsh;
403
404         if (!hdev) {
405                 BT_ERR("Frame for unknown HCI device (hdev=NULL)");
406                 return -ENODEV;
407         }
408
409         info = (dtl1_info_t *)(hdev->driver_data);
410
411         switch (bt_cb(skb)->pkt_type) {
412         case HCI_COMMAND_PKT:
413                 hdev->stat.cmd_tx++;
414                 nsh.type = 0x81;
415                 break;
416         case HCI_ACLDATA_PKT:
417                 hdev->stat.acl_tx++;
418                 nsh.type = 0x82;
419                 break;
420         case HCI_SCODATA_PKT:
421                 hdev->stat.sco_tx++;
422                 nsh.type = 0x83;
423                 break;
424         };
425
426         nsh.zero = 0;
427         nsh.len = skb->len;
428
429         s = bt_skb_alloc(NSHL + skb->len + 1, GFP_ATOMIC);
430         skb_reserve(s, NSHL);
431         memcpy(skb_put(s, skb->len), skb->data, skb->len);
432         if (skb->len & 0x0001)
433                 *skb_put(s, 1) = 0;     /* PAD */
434
435         /* Prepend skb with Nokia frame header and queue */
436         memcpy(skb_push(s, NSHL), &nsh, NSHL);
437         skb_queue_tail(&(info->txq), s);
438
439         dtl1_write_wakeup(info);
440
441         kfree_skb(skb);
442
443         return 0;
444 }
445
446
447 static void dtl1_hci_destruct(struct hci_dev *hdev)
448 {
449 }
450
451
452 static int dtl1_hci_ioctl(struct hci_dev *hdev, unsigned int cmd,  unsigned long arg)
453 {
454         return -ENOIOCTLCMD;
455 }
456
457
458
459 /* ======================== Card services HCI interaction ======================== */
460
461
462 static int dtl1_open(dtl1_info_t *info)
463 {
464         unsigned long flags;
465         unsigned int iobase = info->link.io.BasePort1;
466         struct hci_dev *hdev;
467
468         spin_lock_init(&(info->lock));
469
470         skb_queue_head_init(&(info->txq));
471
472         info->rx_state = RECV_WAIT_NSH;
473         info->rx_count = NSHL;
474         info->rx_skb = NULL;
475
476         set_bit(XMIT_WAITING, &(info->tx_state));
477
478         /* Initialize HCI device */
479         hdev = hci_alloc_dev();
480         if (!hdev) {
481                 BT_ERR("Can't allocate HCI device");
482                 return -ENOMEM;
483         }
484
485         info->hdev = hdev;
486
487         hdev->type = HCI_PCCARD;
488         hdev->driver_data = info;
489
490         hdev->open     = dtl1_hci_open;
491         hdev->close    = dtl1_hci_close;
492         hdev->flush    = dtl1_hci_flush;
493         hdev->send     = dtl1_hci_send_frame;
494         hdev->destruct = dtl1_hci_destruct;
495         hdev->ioctl    = dtl1_hci_ioctl;
496
497         hdev->owner = THIS_MODULE;
498
499         spin_lock_irqsave(&(info->lock), flags);
500
501         /* Reset UART */
502         outb(0, iobase + UART_MCR);
503
504         /* Turn off interrupts */
505         outb(0, iobase + UART_IER);
506
507         /* Initialize UART */
508         outb(UART_LCR_WLEN8, iobase + UART_LCR);        /* Reset DLAB */
509         outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR);
510
511         info->ri_latch = inb(info->link.io.BasePort1 + UART_MSR) & UART_MSR_RI;
512
513         /* Turn on interrupts */
514         outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER);
515
516         spin_unlock_irqrestore(&(info->lock), flags);
517
518         /* Timeout before it is safe to send the first HCI packet */
519         msleep(2000);
520
521         /* Register HCI device */
522         if (hci_register_dev(hdev) < 0) {
523                 BT_ERR("Can't register HCI device");
524                 info->hdev = NULL;
525                 hci_free_dev(hdev);
526                 return -ENODEV;
527         }
528
529         return 0;
530 }
531
532
533 static int dtl1_close(dtl1_info_t *info)
534 {
535         unsigned long flags;
536         unsigned int iobase = info->link.io.BasePort1;
537         struct hci_dev *hdev = info->hdev;
538
539         if (!hdev)
540                 return -ENODEV;
541
542         dtl1_hci_close(hdev);
543
544         spin_lock_irqsave(&(info->lock), flags);
545
546         /* Reset UART */
547         outb(0, iobase + UART_MCR);
548
549         /* Turn off interrupts */
550         outb(0, iobase + UART_IER);
551
552         spin_unlock_irqrestore(&(info->lock), flags);
553
554         if (hci_unregister_dev(hdev) < 0)
555                 BT_ERR("Can't unregister HCI device %s", hdev->name);
556
557         hci_free_dev(hdev);
558
559         return 0;
560 }
561
562 static dev_link_t *dtl1_attach(void)
563 {
564         dtl1_info_t *info;
565         client_reg_t client_reg;
566         dev_link_t *link;
567         int ret;
568
569         /* Create new info device */
570         info = kzalloc(sizeof(*info), GFP_KERNEL);
571         if (!info)
572                 return NULL;
573
574         link = &info->link;
575         link->priv = info;
576
577         link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
578         link->io.NumPorts1 = 8;
579         link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
580         link->irq.IRQInfo1 = IRQ_LEVEL_ID;
581
582         link->irq.Handler = dtl1_interrupt;
583         link->irq.Instance = info;
584
585         link->conf.Attributes = CONF_ENABLE_IRQ;
586         link->conf.Vcc = 50;
587         link->conf.IntType = INT_MEMORY_AND_IO;
588
589         /* Register with Card Services */
590         link->next = NULL;
591         client_reg.dev_info = &dev_info;
592         client_reg.Version = 0x0210;
593         client_reg.event_callback_args.client_data = link;
594
595         ret = pcmcia_register_client(&link->handle, &client_reg);
596         if (ret != CS_SUCCESS) {
597                 cs_error(link->handle, RegisterClient, ret);
598                 dtl1_detach(link->handle);
599                 return NULL;
600         }
601
602         return link;
603 }
604
605
606 static void dtl1_detach(struct pcmcia_device *p_dev)
607 {
608         dev_link_t *link = dev_to_instance(p_dev);
609         dtl1_info_t *info = link->priv;
610
611         if (link->state & DEV_CONFIG)
612                 dtl1_release(link);
613
614         kfree(info);
615 }
616
617 static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
618 {
619         int i;
620
621         i = pcmcia_get_tuple_data(handle, tuple);
622         if (i != CS_SUCCESS)
623                 return i;
624
625         return pcmcia_parse_tuple(handle, tuple, parse);
626 }
627
628 static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
629 {
630         if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS)
631                 return CS_NO_MORE_ITEMS;
632         return get_tuple(handle, tuple, parse);
633 }
634
635 static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
636 {
637         if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS)
638                 return CS_NO_MORE_ITEMS;
639         return get_tuple(handle, tuple, parse);
640 }
641
642 static void dtl1_config(dev_link_t *link)
643 {
644         client_handle_t handle = link->handle;
645         dtl1_info_t *info = link->priv;
646         tuple_t tuple;
647         u_short buf[256];
648         cisparse_t parse;
649         cistpl_cftable_entry_t *cf = &parse.cftable_entry;
650         config_info_t config;
651         int i, last_ret, last_fn;
652
653         tuple.TupleData = (cisdata_t *)buf;
654         tuple.TupleOffset = 0;
655         tuple.TupleDataMax = 255;
656         tuple.Attributes = 0;
657
658         /* Get configuration register information */
659         tuple.DesiredTuple = CISTPL_CONFIG;
660         last_ret = first_tuple(handle, &tuple, &parse);
661         if (last_ret != CS_SUCCESS) {
662                 last_fn = ParseTuple;
663                 goto cs_failed;
664         }
665         link->conf.ConfigBase = parse.config.base;
666         link->conf.Present = parse.config.rmask[0];
667
668         /* Configure card */
669         link->state |= DEV_CONFIG;
670         i = pcmcia_get_configuration_info(handle, &config);
671         link->conf.Vcc = config.Vcc;
672
673         tuple.TupleData = (cisdata_t *)buf;
674         tuple.TupleOffset = 0;
675         tuple.TupleDataMax = 255;
676         tuple.Attributes = 0;
677         tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
678
679         /* Look for a generic full-sized window */
680         link->io.NumPorts1 = 8;
681         i = first_tuple(handle, &tuple, &parse);
682         while (i != CS_NO_MORE_ITEMS) {
683                 if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && (cf->io.win[0].len > 8)) {
684                         link->conf.ConfigIndex = cf->index;
685                         link->io.BasePort1 = cf->io.win[0].base;
686                         link->io.NumPorts1 = cf->io.win[0].len; /*yo */
687                         link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK;
688                         i = pcmcia_request_io(link->handle, &link->io);
689                         if (i == CS_SUCCESS)
690                                 break;
691                 }
692                 i = next_tuple(handle, &tuple, &parse);
693         }
694
695         if (i != CS_SUCCESS) {
696                 cs_error(link->handle, RequestIO, i);
697                 goto failed;
698         }
699
700         i = pcmcia_request_irq(link->handle, &link->irq);
701         if (i != CS_SUCCESS) {
702                 cs_error(link->handle, RequestIRQ, i);
703                 link->irq.AssignedIRQ = 0;
704         }
705
706         i = pcmcia_request_configuration(link->handle, &link->conf);
707         if (i != CS_SUCCESS) {
708                 cs_error(link->handle, RequestConfiguration, i);
709                 goto failed;
710         }
711
712         if (dtl1_open(info) != 0)
713                 goto failed;
714
715         strcpy(info->node.dev_name, info->hdev->name);
716         link->dev = &info->node;
717         link->state &= ~DEV_CONFIG_PENDING;
718
719         return;
720
721 cs_failed:
722         cs_error(link->handle, last_fn, last_ret);
723
724 failed:
725         dtl1_release(link);
726 }
727
728
729 static void dtl1_release(dev_link_t *link)
730 {
731         dtl1_info_t *info = link->priv;
732
733         if (link->state & DEV_PRESENT)
734                 dtl1_close(info);
735
736         link->dev = NULL;
737
738         pcmcia_release_configuration(link->handle);
739         pcmcia_release_io(link->handle, &link->io);
740         pcmcia_release_irq(link->handle, &link->irq);
741
742         link->state &= ~DEV_CONFIG;
743 }
744
745 static int dtl1_suspend(struct pcmcia_device *dev)
746 {
747         dev_link_t *link = dev_to_instance(dev);
748
749         link->state |= DEV_SUSPEND;
750         if (link->state & DEV_CONFIG)
751                 pcmcia_release_configuration(link->handle);
752
753         return 0;
754 }
755
756 static int dtl1_resume(struct pcmcia_device *dev)
757 {
758         dev_link_t *link = dev_to_instance(dev);
759
760         link->state &= ~DEV_SUSPEND;
761         if (DEV_OK(link))
762                 pcmcia_request_configuration(link->handle, &link->conf);
763
764         return 0;
765 }
766
767 static int dtl1_event(event_t event, int priority, event_callback_args_t *args)
768 {
769         dev_link_t *link = args->client_data;
770
771         switch (event) {
772         case CS_EVENT_CARD_INSERTION:
773                 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
774                 dtl1_config(link);
775                 break;
776         }
777
778         return 0;
779 }
780
781 static struct pcmcia_device_id dtl1_ids[] = {
782         PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d),
783         PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863),
784         PCMCIA_DEVICE_NULL
785 };
786 MODULE_DEVICE_TABLE(pcmcia, dtl1_ids);
787
788 static struct pcmcia_driver dtl1_driver = {
789         .owner          = THIS_MODULE,
790         .drv            = {
791                 .name   = "dtl1_cs",
792         },
793         .attach         = dtl1_attach,
794         .event          = dtl1_event,
795         .remove         = dtl1_detach,
796         .id_table       = dtl1_ids,
797         .suspend        = dtl1_suspend,
798         .resume         = dtl1_resume,
799 };
800
801 static int __init init_dtl1_cs(void)
802 {
803         return pcmcia_register_driver(&dtl1_driver);
804 }
805
806
807 static void __exit exit_dtl1_cs(void)
808 {
809         pcmcia_unregister_driver(&dtl1_driver);
810 }
811
812 module_init(init_dtl1_cs);
813 module_exit(exit_dtl1_cs);