12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/pci.h>
23 #include <linux/kernelcapi.h>
24 #include <linux/slab.h>
27 #include <asm/uaccess.h>
28 #include <linux/netdevice.h>
34 static char *
revision =
"$Revision: 1.1.2.2 $";
75 cinfo = kzalloc(
sizeof(*cinfo) * nr_controllers,
GFP_KERNEL);
82 for (i = 0; i < nr_controllers; i++) {
83 INIT_LIST_HEAD(&cinfo[i].ncci_head);
129 for (onoff = !0, i = 0; i < 10; i++) {
130 b1_set_test_bit(base, cardtype, onoff);
131 if (b1_get_test_bit(base, cardtype) != onoff)
139 if ((b1_rd_reg(base,
B1_STAT1(cardtype)) & 0x0f) != 0x01)
151 #define FWBUF_SIZE 256
169 if (b1_save_put_byte(base, buf[i]) < 0) {
184 for (i = 0; i <
left; i++)
185 if (b1_save_put_byte(base, buf[i]) < 0) {
205 b1_put_word(base, 1);
207 b1_put_word(base, left);
218 for (j = 0; j < 4; j++) {
219 b1_put_byte(base, buf[i++]);
232 for (i = 0; i <
left; ) {
234 for (j = 0; j < 4; j++) {
236 b1_put_byte(base, buf[i++]);
238 b1_put_byte(base, 0);
250 unsigned long tout = 2;
253 if (b1_tx_empty(base))
256 if (!b1_tx_empty(base)) {
263 if (b1_rx_full(base)) {
267 printk(
KERN_ERR "%s: b1_loaded: got 0x%x, firmware not running\n",
295 b1_disable_irq(port);
316 b1_put_word(port, ctrl->
cnr - 1);
317 spin_unlock_irqrestore(&card->
lock, flags);
335 spin_unlock_irqrestore(&card->
lock, flags);
349 if (want > 0) nconn = want;
355 b1_put_word(port, appl);
356 b1_put_word(port, 1024 * (nconn + 1));
357 b1_put_word(port, nconn);
360 spin_unlock_irqrestore(&card->
lock, flags);
373 b1_put_word(port, appl);
374 spin_unlock_irqrestore(&card->
lock, flags);
395 spin_unlock_irqrestore(&card->
lock, flags);
402 b1_put_slice(port, skb->
data, len);
403 b1_put_slice(port, skb->
data + len, dlen);
406 b1_put_slice(port, skb->
data, len);
408 spin_unlock_irqrestore(&card->
lock, flags);
426 cinfo->
version[j] =
"\0\0" + 1;
442 (dversion[5] -
'0') * 10 + ((dversion[6] -
'0') & 0xf);
446 flag = ((
u8 *)(profp->
manu))[1];
457 default:
sprintf(cinfo->
cardname,
"AVM?%u", (
unsigned int)flag);
break;
462 flag = ((
u8 *)(profp->
manu))[3];
467 (flag & 0x01) ?
" DSS1" :
"",
468 (flag & 0x02) ?
" CT1" :
"",
469 (flag & 0x04) ?
" VN3" :
"",
470 (flag & 0x08) ?
" NI1" :
"",
471 (flag & 0x10) ?
" AUSTEL" :
"",
472 (flag & 0x20) ?
" ESS" :
"",
473 (flag & 0x40) ?
" 1TR6" :
""
476 flag = ((
u8 *)(profp->
manu))[5];
481 (flag & 0x01) ?
" point to point" :
"",
482 (flag & 0x02) ?
" point to multipoint" :
"",
483 (flag & 0x08) ?
" leased line without D-channel" :
"",
484 (flag & 0x04) ?
" leased line with D-channel" :
""
507 if (!b1_rx_full(card->
port)) {
508 spin_unlock_irqrestore(&card->
lock, flags);
512 b1cmd = b1_get_byte(card->
port);
518 ApplId = (unsigned) b1_get_word(card->
port);
519 MsgLen = b1_get_slice(card->
port, card->
msgbuf);
520 DataB3Len = b1_get_slice(card->
port, card->
databuf);
521 spin_unlock_irqrestore(&card->
lock, flags);
528 if (!(skb = alloc_skb(DataB3Len + MsgLen,
GFP_ATOMIC))) {
540 ApplId = (unsigned) b1_get_word(card->
port);
541 MsgLen = b1_get_slice(card->
port, card->
msgbuf);
545 spin_unlock_irqrestore(&card->
lock, flags);
552 spin_unlock_irqrestore(&card->
lock, flags);
559 ApplId = b1_get_word(card->
port);
560 NCCI = b1_get_word(card->
port);
561 WindowSize = b1_get_word(card->
port);
563 spin_unlock_irqrestore(&card->
lock, flags);
568 ApplId = b1_get_word(card->
port);
569 NCCI = b1_get_word(card->
port);
570 if (NCCI != 0xffffffff)
572 spin_unlock_irqrestore(&card->
lock, flags);
577 spin_unlock_irqrestore(&card->
lock, flags);
582 spin_unlock_irqrestore(&card->
lock, flags);
589 spin_unlock_irqrestore(&card->
lock, flags);
599 ApplId = (unsigned) b1_get_word(card->
port);
600 MsgLen = b1_get_slice(card->
port, card->
msgbuf);
601 spin_unlock_irqrestore(&card->
lock, flags);
604 && (card->
msgbuf[MsgLen - 1] ==
'\n'
605 || card->
msgbuf[MsgLen - 1] ==
'\r')) {
606 card->
msgbuf[MsgLen - 1] = 0;
614 MsgLen = b1_get_slice(card->
port, card->
msgbuf);
615 spin_unlock_irqrestore(&card->
lock, flags);
618 && (card->
msgbuf[MsgLen - 1] ==
'\n'
619 || card->
msgbuf[MsgLen - 1] ==
'\r')) {
620 card->
msgbuf[MsgLen - 1] = 0;
627 spin_unlock_irqrestore(&card->
lock, flags);
631 spin_unlock_irqrestore(&card->
lock, flags);
640 static int b1ctl_proc_show(
struct seq_file *
m,
void *
v)
655 case avm_m1: s =
"M1";
break;
656 case avm_m2: s =
"M2";
break;
657 case avm_t1isa: s =
"T1 ISA (HEMA)";
break;
659 case avm_c4: s =
"C4";
break;
660 case avm_c2: s =
"C2";
break;
661 default: s =
"???";
break;
669 seq_printf(m,
"%-16s %s\n",
"ver_cardtype", s);
678 (flag & 0x01) ?
" DSS1" :
"",
679 (flag & 0x02) ?
" CT1" :
"",
680 (flag & 0x04) ?
" VN3" :
"",
681 (flag & 0x08) ?
" NI1" :
"",
682 (flag & 0x10) ?
" AUSTEL" :
"",
683 (flag & 0x20) ?
" ESS" :
"",
684 (flag & 0x40) ?
" 1TR6" :
""
692 (flag & 0x01) ?
" point to point" :
"",
693 (flag & 0x02) ?
" point to multipoint" :
"",
694 (flag & 0x08) ?
" leased line without D-channel" :
"",
695 (flag & 0x04) ?
" leased line with D-channel" :
""
710 .open = b1ctl_proc_open,
745 goto err_free_consistent;
795 static int __init b1_init(
void)
802 if ((p =
strchr(rev,
'$')) !=
NULL && p > rev)
812 static void __exit b1_exit(
void)