1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25
26#include <linux/module.h>
27#include <linux/slab.h>
28#include <linux/delay.h>
29#include <linux/moduleparam.h>
30#include <linux/firmware.h>
31#include <linux/netdevice.h>
32
33#include <pcmcia/cistpl.h>
34#include <pcmcia/ds.h>
35
36#include <linux/io.h>
37
38#define DRV_NAME "libertas_cs"
39
40#include "decl.h"
41#include "defs.h"
42#include "dev.h"
43
44
45
46
47
48
49MODULE_AUTHOR("Holger Schurig <hs4233@mail.mn-solutions.de>");
50MODULE_DESCRIPTION("Driver for Marvell 83xx compact flash WLAN cards");
51MODULE_LICENSE("GPL");
52
53
54
55
56
57
58
59struct if_cs_card {
60 struct pcmcia_device *p_dev;
61 struct lbs_private *priv;
62 void __iomem *iobase;
63 bool align_regs;
64 u32 model;
65};
66
67
68enum {
69 MODEL_UNKNOWN = 0x00,
70 MODEL_8305 = 0x01,
71 MODEL_8381 = 0x02,
72 MODEL_8385 = 0x03
73};
74
75static const struct lbs_fw_table fw_table[] = {
76 { MODEL_8305, "libertas/cf8305.bin", NULL },
77 { MODEL_8305, "libertas_cs_helper.fw", NULL },
78 { MODEL_8381, "libertas/cf8381_helper.bin", "libertas/cf8381.bin" },
79 { MODEL_8381, "libertas_cs_helper.fw", "libertas_cs.fw" },
80 { MODEL_8385, "libertas/cf8385_helper.bin", "libertas/cf8385.bin" },
81 { MODEL_8385, "libertas_cs_helper.fw", "libertas_cs.fw" },
82 { 0, NULL, NULL }
83};
84MODULE_FIRMWARE("libertas/cf8305.bin");
85MODULE_FIRMWARE("libertas/cf8381_helper.bin");
86MODULE_FIRMWARE("libertas/cf8381.bin");
87MODULE_FIRMWARE("libertas/cf8385_helper.bin");
88MODULE_FIRMWARE("libertas/cf8385.bin");
89MODULE_FIRMWARE("libertas_cs_helper.fw");
90MODULE_FIRMWARE("libertas_cs.fw");
91
92
93
94
95
96
97
98
99
100
101
102#ifdef DEBUG_IO
103static int debug_output = 0;
104#else
105
106#define debug_output 0
107#endif
108
109static inline unsigned int if_cs_read8(struct if_cs_card *card, uint reg)
110{
111 unsigned int val = ioread8(card->iobase + reg);
112 if (debug_output)
113 printk(KERN_INFO "inb %08x<%02x\n", reg, val);
114 return val;
115}
116static inline unsigned int if_cs_read16(struct if_cs_card *card, uint reg)
117{
118 unsigned int val = ioread16(card->iobase + reg);
119 if (debug_output)
120 printk(KERN_INFO "inw %08x<%04x\n", reg, val);
121 return val;
122}
123static inline void if_cs_read16_rep(
124 struct if_cs_card *card,
125 uint reg,
126 void *buf,
127 unsigned long count)
128{
129 if (debug_output)
130 printk(KERN_INFO "insw %08x<(0x%lx words)\n",
131 reg, count);
132 ioread16_rep(card->iobase + reg, buf, count);
133}
134
135static inline void if_cs_write8(struct if_cs_card *card, uint reg, u8 val)
136{
137 if (debug_output)
138 printk(KERN_INFO "outb %08x>%02x\n", reg, val);
139 iowrite8(val, card->iobase + reg);
140}
141
142static inline void if_cs_write16(struct if_cs_card *card, uint reg, u16 val)
143{
144 if (debug_output)
145 printk(KERN_INFO "outw %08x>%04x\n", reg, val);
146 iowrite16(val, card->iobase + reg);
147}
148
149static inline void if_cs_write16_rep(
150 struct if_cs_card *card,
151 uint reg,
152 const void *buf,
153 unsigned long count)
154{
155 if (debug_output)
156 printk(KERN_INFO "outsw %08x>(0x%lx words)\n",
157 reg, count);
158 iowrite16_rep(card->iobase + reg, buf, count);
159}
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 reg)
175{
176 int i;
177
178 for (i = 0; i < 100000; i++) {
179 u8 val = if_cs_read8(card, addr);
180 if (val == reg)
181 return 0;
182 udelay(5);
183 }
184 return -ETIME;
185}
186
187
188
189
190
191
192#define IF_CS_BIT_TX 0x0001
193#define IF_CS_BIT_RX 0x0002
194#define IF_CS_BIT_COMMAND 0x0004
195#define IF_CS_BIT_RESP 0x0008
196#define IF_CS_BIT_EVENT 0x0010
197#define IF_CS_BIT_MASK 0x001f
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212#define IF_CS_HOST_STATUS 0x00000000
213
214
215
216
217
218
219
220
221
222
223
224#define IF_CS_HOST_INT_CAUSE 0x00000002
225
226
227
228
229
230#define IF_CS_HOST_INT_MASK 0x00000004
231
232
233
234
235#define IF_CS_WRITE 0x00000016
236#define IF_CS_WRITE_LEN 0x00000014
237#define IF_CS_READ 0x00000010
238#define IF_CS_READ_LEN 0x00000024
239
240
241
242
243
244#define IF_CS_CMD 0x0000001A
245#define IF_CS_CMD_LEN 0x00000018
246#define IF_CS_RESP 0x00000012
247#define IF_CS_RESP_LEN 0x00000030
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266#define IF_CS_CARD_STATUS 0x00000020
267#define IF_CS_CARD_STATUS_MASK 0x7f00
268
269
270
271
272
273
274
275
276
277
278
279#define IF_CS_CARD_INT_CAUSE 0x00000022
280
281
282
283
284
285#define IF_CS_SQ_READ_LOW 0x00000028
286#define IF_CS_SQ_HELPER_OK 0x10
287
288
289
290
291
292
293
294#define IF_CS_SCRATCH 0x0000003F
295#define IF_CS_SCRATCH_BOOT_OK 0x00
296#define IF_CS_SCRATCH_HELPER_OK 0x5a
297
298
299
300
301#define IF_CS_PRODUCT_ID 0x0000001C
302#define IF_CS_CF8385_B1_REV 0x12
303#define IF_CS_CF8381_B3_REV 0x04
304#define IF_CS_CF8305_B1_REV 0x03
305
306
307
308
309
310#define CF8305_MANFID 0x02db
311#define CF8305_CARDID 0x8103
312#define CF8381_MANFID 0x02db
313#define CF8381_CARDID 0x6064
314#define CF8385_MANFID 0x02df
315#define CF8385_CARDID 0x8103
316
317
318
319
320
321static inline u32 get_model(u16 manf_id, u16 card_id)
322{
323
324 if (manf_id == CF8305_MANFID && card_id == CF8305_CARDID)
325 return MODEL_8305;
326 else if (manf_id == CF8381_MANFID && card_id == CF8381_CARDID)
327 return MODEL_8381;
328 else if (manf_id == CF8385_MANFID && card_id == CF8385_CARDID)
329 return MODEL_8385;
330 return MODEL_UNKNOWN;
331}
332
333
334
335
336
337static inline void if_cs_enable_ints(struct if_cs_card *card)
338{
339 if_cs_write16(card, IF_CS_HOST_INT_MASK, 0);
340}
341
342static inline void if_cs_disable_ints(struct if_cs_card *card)
343{
344 if_cs_write16(card, IF_CS_HOST_INT_MASK, IF_CS_BIT_MASK);
345}
346
347
348
349
350static int if_cs_send_cmd(struct lbs_private *priv, u8 *buf, u16 nb)
351{
352 struct if_cs_card *card = (struct if_cs_card *)priv->card;
353 int ret = -1;
354 int loops = 0;
355
356 if_cs_disable_ints(card);
357
358
359 while (1) {
360 u16 status = if_cs_read16(card, IF_CS_CARD_STATUS);
361 if (status & IF_CS_BIT_COMMAND)
362 break;
363 if (++loops > 100) {
364 netdev_err(priv->dev, "card not ready for commands\n");
365 goto done;
366 }
367 mdelay(1);
368 }
369
370 if_cs_write16(card, IF_CS_CMD_LEN, nb);
371
372 if_cs_write16_rep(card, IF_CS_CMD, buf, nb / 2);
373
374 if (nb & 1)
375 if_cs_write8(card, IF_CS_CMD, buf[nb-1]);
376
377
378
379 if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND);
380
381
382
383 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND);
384 ret = 0;
385
386done:
387 if_cs_enable_ints(card);
388 return ret;
389}
390
391
392
393
394static void if_cs_send_data(struct lbs_private *priv, u8 *buf, u16 nb)
395{
396 struct if_cs_card *card = (struct if_cs_card *)priv->card;
397 u16 status;
398
399 if_cs_disable_ints(card);
400
401 status = if_cs_read16(card, IF_CS_CARD_STATUS);
402 BUG_ON((status & IF_CS_BIT_TX) == 0);
403
404 if_cs_write16(card, IF_CS_WRITE_LEN, nb);
405
406
407 if_cs_write16_rep(card, IF_CS_WRITE, buf, nb / 2);
408 if (nb & 1)
409 if_cs_write8(card, IF_CS_WRITE, buf[nb-1]);
410
411 if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_TX);
412 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_TX);
413 if_cs_enable_ints(card);
414}
415
416
417
418
419static int if_cs_receive_cmdres(struct lbs_private *priv, u8 *data, u32 *len)
420{
421 unsigned long flags;
422 int ret = -1;
423 u16 status;
424
425
426 status = if_cs_read16(priv->card, IF_CS_CARD_STATUS);
427 if ((status & IF_CS_BIT_RESP) == 0) {
428 netdev_err(priv->dev, "no cmd response in card\n");
429 *len = 0;
430 goto out;
431 }
432
433 *len = if_cs_read16(priv->card, IF_CS_RESP_LEN);
434 if ((*len == 0) || (*len > LBS_CMD_BUFFER_SIZE)) {
435 netdev_err(priv->dev,
436 "card cmd buffer has invalid # of bytes (%d)\n",
437 *len);
438 goto out;
439 }
440
441
442 if_cs_read16_rep(priv->card, IF_CS_RESP, data, *len/sizeof(u16));
443 if (*len & 1)
444 data[*len-1] = if_cs_read8(priv->card, IF_CS_RESP);
445
446
447
448 *len -= 8;
449 ret = 0;
450
451
452 spin_lock_irqsave(&priv->driver_lock, flags);
453 priv->dnld_sent = DNLD_RES_RECEIVED;
454 spin_unlock_irqrestore(&priv->driver_lock, flags);
455
456out:
457 return ret;
458}
459
460static struct sk_buff *if_cs_receive_data(struct lbs_private *priv)
461{
462 struct sk_buff *skb = NULL;
463 u16 len;
464 u8 *data;
465
466 len = if_cs_read16(priv->card, IF_CS_READ_LEN);
467 if (len == 0 || len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) {
468 netdev_err(priv->dev,
469 "card data buffer has invalid # of bytes (%d)\n",
470 len);
471 priv->dev->stats.rx_dropped++;
472 goto dat_err;
473 }
474
475 skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE + 2);
476 if (!skb)
477 goto out;
478 skb_put(skb, len);
479 skb_reserve(skb, 2);
480 data = skb->data;
481
482
483 if_cs_read16_rep(priv->card, IF_CS_READ, data, len/sizeof(u16));
484 if (len & 1)
485 data[len-1] = if_cs_read8(priv->card, IF_CS_READ);
486
487dat_err:
488 if_cs_write16(priv->card, IF_CS_HOST_STATUS, IF_CS_BIT_RX);
489 if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_RX);
490
491out:
492 return skb;
493}
494
495static irqreturn_t if_cs_interrupt(int irq, void *data)
496{
497 struct if_cs_card *card = data;
498 struct lbs_private *priv = card->priv;
499 u16 cause;
500
501
502 cause = if_cs_read16(card, IF_CS_CARD_INT_CAUSE);
503 lbs_deb_cs("cause 0x%04x\n", cause);
504
505 if (cause == 0) {
506
507 return IRQ_NONE;
508 }
509
510 if (cause == 0xffff) {
511
512 card->priv->surpriseremoved = 1;
513 return IRQ_HANDLED;
514 }
515
516 if (cause & IF_CS_BIT_RX) {
517 struct sk_buff *skb;
518 lbs_deb_cs("rx packet\n");
519 skb = if_cs_receive_data(priv);
520 if (skb)
521 lbs_process_rxed_packet(priv, skb);
522 }
523
524 if (cause & IF_CS_BIT_TX) {
525 lbs_deb_cs("tx done\n");
526 lbs_host_to_card_done(priv);
527 }
528
529 if (cause & IF_CS_BIT_RESP) {
530 unsigned long flags;
531 u8 i;
532
533 lbs_deb_cs("cmd resp\n");
534 spin_lock_irqsave(&priv->driver_lock, flags);
535 i = (priv->resp_idx == 0) ? 1 : 0;
536 spin_unlock_irqrestore(&priv->driver_lock, flags);
537
538 BUG_ON(priv->resp_len[i]);
539 if_cs_receive_cmdres(priv, priv->resp_buf[i],
540 &priv->resp_len[i]);
541
542 spin_lock_irqsave(&priv->driver_lock, flags);
543 lbs_notify_command_response(priv, i);
544 spin_unlock_irqrestore(&priv->driver_lock, flags);
545 }
546
547 if (cause & IF_CS_BIT_EVENT) {
548 u16 status = if_cs_read16(priv->card, IF_CS_CARD_STATUS);
549 if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE,
550 IF_CS_BIT_EVENT);
551 lbs_queue_event(priv, (status & IF_CS_CARD_STATUS_MASK) >> 8);
552 }
553
554
555 if_cs_write16(card, IF_CS_CARD_INT_CAUSE, cause & IF_CS_BIT_MASK);
556
557 return IRQ_HANDLED;
558}
559
560
561
562
563
564
565
566
567
568
569
570
571
572static int if_cs_prog_helper(struct if_cs_card *card, const struct firmware *fw)
573{
574 int ret = 0;
575 int sent = 0;
576 u8 scratch;
577
578
579
580
581
582
583 if (card->align_regs)
584 scratch = if_cs_read16(card, IF_CS_SCRATCH) >> 8;
585 else
586 scratch = if_cs_read8(card, IF_CS_SCRATCH);
587
588
589
590
591 if (scratch == IF_CS_SCRATCH_HELPER_OK)
592 goto done;
593
594
595 if (scratch != IF_CS_SCRATCH_BOOT_OK) {
596 ret = -ENODEV;
597 goto done;
598 }
599
600 lbs_deb_cs("helper size %td\n", fw->size);
601
602
603
604
605 for (;;) {
606
607 int count = 256;
608 int remain = fw->size - sent;
609
610 if (remain < count)
611 count = remain;
612
613
614
615
616
617 if_cs_write16(card, IF_CS_CMD_LEN, count);
618
619
620 if (count)
621 if_cs_write16_rep(card, IF_CS_CMD,
622 &fw->data[sent],
623 count >> 1);
624
625
626
627
628
629 if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND);
630
631
632
633
634
635 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND);
636
637
638
639
640
641 ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS,
642 IF_CS_BIT_COMMAND);
643 if (ret < 0) {
644 pr_err("can't download helper at 0x%x, ret %d\n",
645 sent, ret);
646 goto done;
647 }
648
649 if (count == 0)
650 break;
651
652 sent += count;
653 }
654
655done:
656 return ret;
657}
658
659
660static int if_cs_prog_real(struct if_cs_card *card, const struct firmware *fw)
661{
662 int ret = 0;
663 int retry = 0;
664 int len = 0;
665 int sent;
666
667 lbs_deb_cs("fw size %td\n", fw->size);
668
669 ret = if_cs_poll_while_fw_download(card, IF_CS_SQ_READ_LOW,
670 IF_CS_SQ_HELPER_OK);
671 if (ret < 0) {
672 pr_err("helper firmware doesn't answer\n");
673 goto done;
674 }
675
676 for (sent = 0; sent < fw->size; sent += len) {
677 len = if_cs_read16(card, IF_CS_SQ_READ_LOW);
678 if (len & 1) {
679 retry++;
680 pr_info("odd, need to retry this firmware block\n");
681 } else {
682 retry = 0;
683 }
684
685 if (retry > 20) {
686 pr_err("could not download firmware\n");
687 ret = -ENODEV;
688 goto done;
689 }
690 if (retry) {
691 sent -= len;
692 }
693
694
695 if_cs_write16(card, IF_CS_CMD_LEN, len);
696
697 if_cs_write16_rep(card, IF_CS_CMD,
698 &fw->data[sent],
699 (len+1) >> 1);
700 if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND);
701 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND);
702
703 ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS,
704 IF_CS_BIT_COMMAND);
705 if (ret < 0) {
706 pr_err("can't download firmware at 0x%x\n", sent);
707 goto done;
708 }
709 }
710
711 ret = if_cs_poll_while_fw_download(card, IF_CS_SCRATCH, 0x5a);
712 if (ret < 0)
713 pr_err("firmware download failed\n");
714
715done:
716 return ret;
717}
718
719static void if_cs_prog_firmware(struct lbs_private *priv, int ret,
720 const struct firmware *helper,
721 const struct firmware *mainfw)
722{
723 struct if_cs_card *card = priv->card;
724
725 if (ret) {
726 pr_err("failed to find firmware (%d)\n", ret);
727 return;
728 }
729
730
731 ret = if_cs_prog_helper(card, helper);
732 if (ret == 0 && (card->model != MODEL_8305))
733 ret = if_cs_prog_real(card, mainfw);
734 if (ret)
735 return;
736
737
738 ret = request_irq(card->p_dev->irq, if_cs_interrupt,
739 IRQF_SHARED, DRV_NAME, card);
740 if (ret) {
741 pr_err("error in request_irq\n");
742 return;
743 }
744
745
746
747
748
749 if_cs_write16(card, IF_CS_CARD_INT_CAUSE, IF_CS_BIT_MASK);
750 if_cs_enable_ints(card);
751
752
753 priv->fw_ready = 1;
754 if (lbs_start_card(priv) != 0) {
755 pr_err("could not activate card\n");
756 free_irq(card->p_dev->irq, card);
757 }
758}
759
760
761
762
763
764
765
766static int if_cs_host_to_card(struct lbs_private *priv,
767 u8 type,
768 u8 *buf,
769 u16 nb)
770{
771 int ret = -1;
772
773 switch (type) {
774 case MVMS_DAT:
775 priv->dnld_sent = DNLD_DATA_SENT;
776 if_cs_send_data(priv, buf, nb);
777 ret = 0;
778 break;
779 case MVMS_CMD:
780 priv->dnld_sent = DNLD_CMD_SENT;
781 ret = if_cs_send_cmd(priv, buf, nb);
782 break;
783 default:
784 netdev_err(priv->dev, "%s: unsupported type %d\n",
785 __func__, type);
786 }
787
788 return ret;
789}
790
791
792static void if_cs_release(struct pcmcia_device *p_dev)
793{
794 struct if_cs_card *card = p_dev->priv;
795
796 free_irq(p_dev->irq, card);
797 pcmcia_disable_device(p_dev);
798 if (card->iobase)
799 ioport_unmap(card->iobase);
800}
801
802
803static int if_cs_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
804{
805 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
806 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
807
808 if (p_dev->resource[1]->end) {
809 pr_err("wrong CIS (check number of IO windows)\n");
810 return -ENODEV;
811 }
812
813
814 return pcmcia_request_io(p_dev);
815}
816
817static int if_cs_probe(struct pcmcia_device *p_dev)
818{
819 int ret = -ENOMEM;
820 unsigned int prod_id;
821 struct lbs_private *priv;
822 struct if_cs_card *card;
823
824 card = kzalloc(sizeof(struct if_cs_card), GFP_KERNEL);
825 if (!card)
826 goto out;
827
828 card->p_dev = p_dev;
829 p_dev->priv = card;
830
831 p_dev->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
832
833 if (pcmcia_loop_config(p_dev, if_cs_ioprobe, NULL)) {
834 pr_err("error in pcmcia_loop_config\n");
835 goto out1;
836 }
837
838
839
840
841
842
843 if (!p_dev->irq)
844 goto out1;
845
846
847 card->iobase = ioport_map(p_dev->resource[0]->start,
848 resource_size(p_dev->resource[0]));
849 if (!card->iobase) {
850 pr_err("error in ioport_map\n");
851 ret = -EIO;
852 goto out1;
853 }
854
855 ret = pcmcia_enable_device(p_dev);
856 if (ret) {
857 pr_err("error in pcmcia_enable_device\n");
858 goto out2;
859 }
860
861
862 lbs_deb_cs("irq %d, io %pR", p_dev->irq, p_dev->resource[0]);
863
864
865
866
867
868 card->align_regs = false;
869
870 card->model = get_model(p_dev->manf_id, p_dev->card_id);
871 if (card->model == MODEL_UNKNOWN) {
872 pr_err("unsupported manf_id 0x%04x / card_id 0x%04x\n",
873 p_dev->manf_id, p_dev->card_id);
874 ret = -ENODEV;
875 goto out2;
876 }
877
878
879 prod_id = if_cs_read8(card, IF_CS_PRODUCT_ID);
880 if (card->model == MODEL_8305) {
881 card->align_regs = true;
882 if (prod_id < IF_CS_CF8305_B1_REV) {
883 pr_err("8305 rev B0 and older are not supported\n");
884 ret = -ENODEV;
885 goto out2;
886 }
887 }
888
889 if ((card->model == MODEL_8381) && prod_id < IF_CS_CF8381_B3_REV) {
890 pr_err("8381 rev B2 and older are not supported\n");
891 ret = -ENODEV;
892 goto out2;
893 }
894
895 if ((card->model == MODEL_8385) && prod_id < IF_CS_CF8385_B1_REV) {
896 pr_err("8385 rev B0 and older are not supported\n");
897 ret = -ENODEV;
898 goto out2;
899 }
900
901
902 priv = lbs_add_card(card, &p_dev->dev);
903 if (!priv) {
904 ret = -ENOMEM;
905 goto out2;
906 }
907
908
909 card->priv = priv;
910 priv->card = card;
911 priv->hw_host_to_card = if_cs_host_to_card;
912 priv->enter_deep_sleep = NULL;
913 priv->exit_deep_sleep = NULL;
914 priv->reset_deep_sleep_wakeup = NULL;
915
916
917 ret = lbs_get_firmware_async(priv, &p_dev->dev, card->model, fw_table,
918 if_cs_prog_firmware);
919 if (ret) {
920 pr_err("failed to find firmware (%d)\n", ret);
921 goto out3;
922 }
923
924 goto out;
925
926out3:
927 lbs_remove_card(priv);
928out2:
929 ioport_unmap(card->iobase);
930out1:
931 pcmcia_disable_device(p_dev);
932out:
933 return ret;
934}
935
936
937static void if_cs_detach(struct pcmcia_device *p_dev)
938{
939 struct if_cs_card *card = p_dev->priv;
940
941 lbs_stop_card(card->priv);
942 lbs_remove_card(card->priv);
943 if_cs_disable_ints(card);
944 if_cs_release(p_dev);
945 kfree(card);
946}
947
948
949
950
951
952
953
954static const struct pcmcia_device_id if_cs_ids[] = {
955 PCMCIA_DEVICE_MANF_CARD(CF8305_MANFID, CF8305_CARDID),
956 PCMCIA_DEVICE_MANF_CARD(CF8381_MANFID, CF8381_CARDID),
957 PCMCIA_DEVICE_MANF_CARD(CF8385_MANFID, CF8385_CARDID),
958
959 PCMCIA_DEVICE_NULL,
960};
961MODULE_DEVICE_TABLE(pcmcia, if_cs_ids);
962
963static struct pcmcia_driver lbs_driver = {
964 .owner = THIS_MODULE,
965 .name = DRV_NAME,
966 .probe = if_cs_probe,
967 .remove = if_cs_detach,
968 .id_table = if_cs_ids,
969};
970module_pcmcia_driver(lbs_driver);
971