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