[PATCH] aic7xxx_osm build fix
[cris-mirror.git] / drivers / isdn / hardware / avm / b1.c
blob0c7061d550273792c749e83d40dc1b86ff53896a
1 /* $Id: b1.c,v 1.1.2.2 2004/01/16 21:09:27 keil Exp $
2 *
3 * Common module for AVM B1 cards.
4 *
5 * Copyright 1999 by Carsten Paeth <calle@calle.de>
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/pci.h>
15 #include <linux/skbuff.h>
16 #include <linux/delay.h>
17 #include <linux/mm.h>
18 #include <linux/interrupt.h>
19 #include <linux/ioport.h>
20 #include <linux/capi.h>
21 #include <linux/kernelcapi.h>
22 #include <asm/io.h>
23 #include <linux/init.h>
24 #include <asm/uaccess.h>
25 #include <linux/netdevice.h>
26 #include <linux/isdn/capilli.h>
27 #include "avmcard.h"
28 #include <linux/isdn/capicmd.h>
29 #include <linux/isdn/capiutil.h>
31 static char *revision = "$Revision: 1.1.2.2 $";
33 /* ------------------------------------------------------------- */
35 MODULE_DESCRIPTION("CAPI4Linux: Common support for active AVM cards");
36 MODULE_AUTHOR("Carsten Paeth");
37 MODULE_LICENSE("GPL");
39 /* ------------------------------------------------------------- */
41 int b1_irq_table[16] =
42 {0,
45 192, /* irq 3 */
46 32, /* irq 4 */
47 160, /* irq 5 */
48 96, /* irq 6 */
49 224, /* irq 7 */
51 64, /* irq 9 */
52 80, /* irq 10 */
53 208, /* irq 11 */
54 48, /* irq 12 */
57 112, /* irq 15 */
60 /* ------------------------------------------------------------- */
62 avmcard *b1_alloc_card(int nr_controllers)
64 avmcard *card;
65 avmctrl_info *cinfo;
66 int i;
68 card = kmalloc(sizeof(*card), GFP_KERNEL);
69 if (!card)
70 return NULL;
72 memset(card, 0, sizeof(*card));
74 cinfo = kmalloc(sizeof(*cinfo) * nr_controllers, GFP_KERNEL);
75 if (!cinfo) {
76 kfree(card);
77 return NULL;
79 memset(cinfo, 0, sizeof(*cinfo) * nr_controllers);
81 card->ctrlinfo = cinfo;
82 for (i = 0; i < nr_controllers; i++) {
83 INIT_LIST_HEAD(&cinfo[i].ncci_head);
84 cinfo[i].card = card;
86 spin_lock_init(&card->lock);
87 card->nr_controllers = nr_controllers;
89 return card;
92 /* ------------------------------------------------------------- */
94 void b1_free_card(avmcard *card)
96 kfree(card->ctrlinfo);
97 kfree(card);
100 /* ------------------------------------------------------------- */
102 int b1_detect(unsigned int base, enum avmcardtype cardtype)
104 int onoff, i;
107 * Statusregister 0000 00xx
109 if ((inb(base + B1_INSTAT) & 0xfc)
110 || (inb(base + B1_OUTSTAT) & 0xfc))
111 return 1;
113 * Statusregister 0000 001x
115 b1outp(base, B1_INSTAT, 0x2); /* enable irq */
116 /* b1outp(base, B1_OUTSTAT, 0x2); */
117 if ((inb(base + B1_INSTAT) & 0xfe) != 0x2
118 /* || (inb(base + B1_OUTSTAT) & 0xfe) != 0x2 */)
119 return 2;
121 * Statusregister 0000 000x
123 b1outp(base, B1_INSTAT, 0x0); /* disable irq */
124 b1outp(base, B1_OUTSTAT, 0x0);
125 if ((inb(base + B1_INSTAT) & 0xfe)
126 || (inb(base + B1_OUTSTAT) & 0xfe))
127 return 3;
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)
132 return 4;
133 onoff = !onoff;
136 if (cardtype == avm_m1)
137 return 0;
139 if ((b1_rd_reg(base, B1_STAT1(cardtype)) & 0x0f) != 0x01)
140 return 5;
142 return 0;
145 void b1_getrevision(avmcard *card)
147 card->class = inb(card->port + B1_ANALYSE);
148 card->revision = inb(card->port + B1_REVISION);
151 #define FWBUF_SIZE 256
152 int b1_load_t4file(avmcard *card, capiloaddatapart * t4file)
154 unsigned char buf[FWBUF_SIZE];
155 unsigned char *dp;
156 int i, left;
157 unsigned int base = card->port;
159 dp = t4file->data;
160 left = t4file->len;
161 while (left > FWBUF_SIZE) {
162 if (t4file->user) {
163 if (copy_from_user(buf, dp, FWBUF_SIZE))
164 return -EFAULT;
165 } else {
166 memcpy(buf, dp, FWBUF_SIZE);
168 for (i = 0; i < FWBUF_SIZE; i++)
169 if (b1_save_put_byte(base, buf[i]) < 0) {
170 printk(KERN_ERR "%s: corrupted firmware file ?\n",
171 card->name);
172 return -EIO;
174 left -= FWBUF_SIZE;
175 dp += FWBUF_SIZE;
177 if (left) {
178 if (t4file->user) {
179 if (copy_from_user(buf, dp, left))
180 return -EFAULT;
181 } else {
182 memcpy(buf, dp, left);
184 for (i = 0; i < left; i++)
185 if (b1_save_put_byte(base, buf[i]) < 0) {
186 printk(KERN_ERR "%s: corrupted firmware file ?\n",
187 card->name);
188 return -EIO;
191 return 0;
194 int b1_load_config(avmcard *card, capiloaddatapart * config)
196 unsigned char buf[FWBUF_SIZE];
197 unsigned char *dp;
198 unsigned int base = card->port;
199 int i, j, left;
201 dp = config->data;
202 left = config->len;
203 if (left) {
204 b1_put_byte(base, SEND_CONFIG);
205 b1_put_word(base, 1);
206 b1_put_byte(base, SEND_CONFIG);
207 b1_put_word(base, left);
209 while (left > FWBUF_SIZE) {
210 if (config->user) {
211 if (copy_from_user(buf, dp, FWBUF_SIZE))
212 return -EFAULT;
213 } else {
214 memcpy(buf, dp, FWBUF_SIZE);
216 for (i = 0; i < FWBUF_SIZE; ) {
217 b1_put_byte(base, SEND_CONFIG);
218 for (j=0; j < 4; j++) {
219 b1_put_byte(base, buf[i++]);
222 left -= FWBUF_SIZE;
223 dp += FWBUF_SIZE;
225 if (left) {
226 if (config->user) {
227 if (copy_from_user(buf, dp, left))
228 return -EFAULT;
229 } else {
230 memcpy(buf, dp, left);
232 for (i = 0; i < left; ) {
233 b1_put_byte(base, SEND_CONFIG);
234 for (j=0; j < 4; j++) {
235 if (i < left)
236 b1_put_byte(base, buf[i++]);
237 else
238 b1_put_byte(base, 0);
242 return 0;
245 int b1_loaded(avmcard *card)
247 unsigned int base = card->port;
248 unsigned long stop;
249 unsigned char ans;
250 unsigned long tout = 2;
252 for (stop = jiffies + tout * HZ; time_before(jiffies, stop);) {
253 if (b1_tx_empty(base))
254 break;
256 if (!b1_tx_empty(base)) {
257 printk(KERN_ERR "%s: b1_loaded: tx err, corrupted t4 file ?\n",
258 card->name);
259 return 0;
261 b1_put_byte(base, SEND_POLL);
262 for (stop = jiffies + tout * HZ; time_before(jiffies, stop);) {
263 if (b1_rx_full(base)) {
264 if ((ans = b1_get_byte(base)) == RECEIVE_POLL) {
265 return 1;
267 printk(KERN_ERR "%s: b1_loaded: got 0x%x, firmware not running\n",
268 card->name, ans);
269 return 0;
272 printk(KERN_ERR "%s: b1_loaded: firmware not running\n", card->name);
273 return 0;
276 /* ------------------------------------------------------------- */
278 int b1_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
280 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
281 avmcard *card = cinfo->card;
282 unsigned int port = card->port;
283 unsigned long flags;
284 int retval;
286 b1_reset(port);
288 if ((retval = b1_load_t4file(card, &data->firmware))) {
289 b1_reset(port);
290 printk(KERN_ERR "%s: failed to load t4file!!\n",
291 card->name);
292 return retval;
295 b1_disable_irq(port);
297 if (data->configuration.len > 0 && data->configuration.data) {
298 if ((retval = b1_load_config(card, &data->configuration))) {
299 b1_reset(port);
300 printk(KERN_ERR "%s: failed to load config!!\n",
301 card->name);
302 return retval;
306 if (!b1_loaded(card)) {
307 printk(KERN_ERR "%s: failed to load t4file.\n", card->name);
308 return -EIO;
311 spin_lock_irqsave(&card->lock, flags);
312 b1_setinterrupt(port, card->irq, card->cardtype);
313 b1_put_byte(port, SEND_INIT);
314 b1_put_word(port, CAPI_MAXAPPL);
315 b1_put_word(port, AVM_NCCI_PER_CHANNEL*2);
316 b1_put_word(port, ctrl->cnr - 1);
317 spin_unlock_irqrestore(&card->lock, flags);
319 return 0;
322 void b1_reset_ctr(struct capi_ctr *ctrl)
324 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
325 avmcard *card = cinfo->card;
326 unsigned int port = card->port;
328 b1_reset(port);
329 b1_reset(port);
331 memset(cinfo->version, 0, sizeof(cinfo->version));
332 capilib_release(&cinfo->ncci_head);
333 capi_ctr_reseted(ctrl);
336 void b1_register_appl(struct capi_ctr *ctrl,
337 u16 appl,
338 capi_register_params *rp)
340 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
341 avmcard *card = cinfo->card;
342 unsigned int port = card->port;
343 unsigned long flags;
344 int nconn, want = rp->level3cnt;
346 if (want > 0) nconn = want;
347 else nconn = ctrl->profile.nbchannel * -want;
348 if (nconn == 0) nconn = ctrl->profile.nbchannel;
350 spin_lock_irqsave(&card->lock, flags);
351 b1_put_byte(port, SEND_REGISTER);
352 b1_put_word(port, appl);
353 b1_put_word(port, 1024 * (nconn+1));
354 b1_put_word(port, nconn);
355 b1_put_word(port, rp->datablkcnt);
356 b1_put_word(port, rp->datablklen);
357 spin_unlock_irqrestore(&card->lock, flags);
360 void b1_release_appl(struct capi_ctr *ctrl, u16 appl)
362 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
363 avmcard *card = cinfo->card;
364 unsigned int port = card->port;
365 unsigned long flags;
367 capilib_release_appl(&cinfo->ncci_head, appl);
369 spin_lock_irqsave(&card->lock, flags);
370 b1_put_byte(port, SEND_RELEASE);
371 b1_put_word(port, appl);
372 spin_unlock_irqrestore(&card->lock, flags);
375 u16 b1_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
377 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
378 avmcard *card = cinfo->card;
379 unsigned int port = card->port;
380 unsigned long flags;
381 u16 len = CAPIMSG_LEN(skb->data);
382 u8 cmd = CAPIMSG_COMMAND(skb->data);
383 u8 subcmd = CAPIMSG_SUBCOMMAND(skb->data);
384 u16 dlen, retval;
386 if (CAPICMD(cmd, subcmd) == CAPI_DATA_B3_REQ) {
387 retval = capilib_data_b3_req(&cinfo->ncci_head,
388 CAPIMSG_APPID(skb->data),
389 CAPIMSG_NCCI(skb->data),
390 CAPIMSG_MSGID(skb->data));
391 if (retval != CAPI_NOERROR)
392 return retval;
394 dlen = CAPIMSG_DATALEN(skb->data);
396 spin_lock_irqsave(&card->lock, flags);
397 b1_put_byte(port, SEND_DATA_B3_REQ);
398 b1_put_slice(port, skb->data, len);
399 b1_put_slice(port, skb->data + len, dlen);
400 spin_unlock_irqrestore(&card->lock, flags);
401 } else {
402 spin_lock_irqsave(&card->lock, flags);
403 b1_put_byte(port, SEND_MESSAGE);
404 b1_put_slice(port, skb->data, len);
405 spin_unlock_irqrestore(&card->lock, flags);
408 dev_kfree_skb_any(skb);
409 return CAPI_NOERROR;
412 /* ------------------------------------------------------------- */
414 void b1_parse_version(avmctrl_info *cinfo)
416 struct capi_ctr *ctrl = &cinfo->capi_ctrl;
417 avmcard *card = cinfo->card;
418 capi_profile *profp;
419 u8 *dversion;
420 u8 flag;
421 int i, j;
423 for (j = 0; j < AVM_MAXVERSION; j++)
424 cinfo->version[j] = "\0\0" + 1;
425 for (i = 0, j = 0;
426 j < AVM_MAXVERSION && i < cinfo->versionlen;
427 j++, i += cinfo->versionbuf[i] + 1)
428 cinfo->version[j] = &cinfo->versionbuf[i + 1];
430 strlcpy(ctrl->serial, cinfo->version[VER_SERIAL], sizeof(ctrl->serial));
431 memcpy(&ctrl->profile, cinfo->version[VER_PROFILE],sizeof(capi_profile));
432 strlcpy(ctrl->manu, "AVM GmbH", sizeof(ctrl->manu));
433 dversion = cinfo->version[VER_DRIVER];
434 ctrl->version.majorversion = 2;
435 ctrl->version.minorversion = 0;
436 ctrl->version.majormanuversion = (((dversion[0] - '0') & 0xf) << 4);
437 ctrl->version.majormanuversion |= ((dversion[2] - '0') & 0xf);
438 ctrl->version.minormanuversion = (dversion[3] - '0') << 4;
439 ctrl->version.minormanuversion |=
440 (dversion[5] - '0') * 10 + ((dversion[6] - '0') & 0xf);
442 profp = &ctrl->profile;
444 flag = ((u8 *)(profp->manu))[1];
445 switch (flag) {
446 case 0: if (cinfo->version[VER_CARDTYPE])
447 strcpy(cinfo->cardname, cinfo->version[VER_CARDTYPE]);
448 else strcpy(cinfo->cardname, "B1");
449 break;
450 case 3: strcpy(cinfo->cardname,"PCMCIA B"); break;
451 case 4: strcpy(cinfo->cardname,"PCMCIA M1"); break;
452 case 5: strcpy(cinfo->cardname,"PCMCIA M2"); break;
453 case 6: strcpy(cinfo->cardname,"B1 V3.0"); break;
454 case 7: strcpy(cinfo->cardname,"B1 PCI"); break;
455 default: sprintf(cinfo->cardname, "AVM?%u", (unsigned int)flag); break;
457 printk(KERN_NOTICE "%s: card %d \"%s\" ready.\n",
458 card->name, ctrl->cnr, cinfo->cardname);
460 flag = ((u8 *)(profp->manu))[3];
461 if (flag)
462 printk(KERN_NOTICE "%s: card %d Protocol:%s%s%s%s%s%s%s\n",
463 card->name,
464 ctrl->cnr,
465 (flag & 0x01) ? " DSS1" : "",
466 (flag & 0x02) ? " CT1" : "",
467 (flag & 0x04) ? " VN3" : "",
468 (flag & 0x08) ? " NI1" : "",
469 (flag & 0x10) ? " AUSTEL" : "",
470 (flag & 0x20) ? " ESS" : "",
471 (flag & 0x40) ? " 1TR6" : ""
474 flag = ((u8 *)(profp->manu))[5];
475 if (flag)
476 printk(KERN_NOTICE "%s: card %d Linetype:%s%s%s%s\n",
477 card->name,
478 ctrl->cnr,
479 (flag & 0x01) ? " point to point" : "",
480 (flag & 0x02) ? " point to multipoint" : "",
481 (flag & 0x08) ? " leased line without D-channel" : "",
482 (flag & 0x04) ? " leased line with D-channel" : ""
486 /* ------------------------------------------------------------- */
488 irqreturn_t b1_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
490 avmcard *card = devptr;
491 avmctrl_info *cinfo = &card->ctrlinfo[0];
492 struct capi_ctr *ctrl = &cinfo->capi_ctrl;
493 unsigned char b1cmd;
494 struct sk_buff *skb;
496 unsigned ApplId;
497 unsigned MsgLen;
498 unsigned DataB3Len;
499 unsigned NCCI;
500 unsigned WindowSize;
501 unsigned long flags;
503 spin_lock_irqsave(&card->lock, flags);
505 if (!b1_rx_full(card->port)) {
506 spin_unlock_irqrestore(&card->lock, flags);
507 return IRQ_NONE;
510 b1cmd = b1_get_byte(card->port);
512 switch (b1cmd) {
514 case RECEIVE_DATA_B3_IND:
516 ApplId = (unsigned) b1_get_word(card->port);
517 MsgLen = b1_get_slice(card->port, card->msgbuf);
518 DataB3Len = b1_get_slice(card->port, card->databuf);
519 spin_unlock_irqrestore(&card->lock, flags);
521 if (MsgLen < 30) { /* not CAPI 64Bit */
522 memset(card->msgbuf+MsgLen, 0, 30-MsgLen);
523 MsgLen = 30;
524 CAPIMSG_SETLEN(card->msgbuf, 30);
526 if (!(skb = alloc_skb(DataB3Len + MsgLen, GFP_ATOMIC))) {
527 printk(KERN_ERR "%s: incoming packet dropped\n",
528 card->name);
529 } else {
530 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
531 memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
532 capi_ctr_handle_message(ctrl, ApplId, skb);
534 break;
536 case RECEIVE_MESSAGE:
538 ApplId = (unsigned) b1_get_word(card->port);
539 MsgLen = b1_get_slice(card->port, card->msgbuf);
540 spin_unlock_irqrestore(&card->lock, flags);
541 if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) {
542 printk(KERN_ERR "%s: incoming packet dropped\n",
543 card->name);
544 } else {
545 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
546 if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF)
547 capilib_data_b3_conf(&cinfo->ncci_head, ApplId,
548 CAPIMSG_NCCI(skb->data),
549 CAPIMSG_MSGID(skb->data));
551 capi_ctr_handle_message(ctrl, ApplId, skb);
553 break;
555 case RECEIVE_NEW_NCCI:
557 ApplId = b1_get_word(card->port);
558 NCCI = b1_get_word(card->port);
559 WindowSize = b1_get_word(card->port);
560 spin_unlock_irqrestore(&card->lock, flags);
562 capilib_new_ncci(&cinfo->ncci_head, ApplId, NCCI, WindowSize);
564 break;
566 case RECEIVE_FREE_NCCI:
568 ApplId = b1_get_word(card->port);
569 NCCI = b1_get_word(card->port);
570 spin_unlock_irqrestore(&card->lock, flags);
572 if (NCCI != 0xffffffff)
573 capilib_free_ncci(&cinfo->ncci_head, ApplId, NCCI);
575 break;
577 case RECEIVE_START:
578 /* b1_put_byte(card->port, SEND_POLLACK); */
579 spin_unlock_irqrestore(&card->lock, flags);
580 capi_ctr_resume_output(ctrl);
581 break;
583 case RECEIVE_STOP:
584 spin_unlock_irqrestore(&card->lock, flags);
585 capi_ctr_suspend_output(ctrl);
586 break;
588 case RECEIVE_INIT:
590 cinfo->versionlen = b1_get_slice(card->port, cinfo->versionbuf);
591 spin_unlock_irqrestore(&card->lock, flags);
592 b1_parse_version(cinfo);
593 printk(KERN_INFO "%s: %s-card (%s) now active\n",
594 card->name,
595 cinfo->version[VER_CARDTYPE],
596 cinfo->version[VER_DRIVER]);
597 capi_ctr_ready(ctrl);
598 break;
600 case RECEIVE_TASK_READY:
601 ApplId = (unsigned) b1_get_word(card->port);
602 MsgLen = b1_get_slice(card->port, card->msgbuf);
603 spin_unlock_irqrestore(&card->lock, flags);
604 card->msgbuf[MsgLen] = 0;
605 while ( MsgLen > 0
606 && ( card->msgbuf[MsgLen-1] == '\n'
607 || card->msgbuf[MsgLen-1] == '\r')) {
608 card->msgbuf[MsgLen-1] = 0;
609 MsgLen--;
611 printk(KERN_INFO "%s: task %d \"%s\" ready.\n",
612 card->name, ApplId, card->msgbuf);
613 break;
615 case RECEIVE_DEBUGMSG:
616 MsgLen = b1_get_slice(card->port, card->msgbuf);
617 spin_unlock_irqrestore(&card->lock, flags);
618 card->msgbuf[MsgLen] = 0;
619 while ( MsgLen > 0
620 && ( card->msgbuf[MsgLen-1] == '\n'
621 || card->msgbuf[MsgLen-1] == '\r')) {
622 card->msgbuf[MsgLen-1] = 0;
623 MsgLen--;
625 printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf);
626 break;
628 case 0xff:
629 spin_unlock_irqrestore(&card->lock, flags);
630 printk(KERN_ERR "%s: card removed ?\n", card->name);
631 return IRQ_NONE;
632 default:
633 spin_unlock_irqrestore(&card->lock, flags);
634 printk(KERN_ERR "%s: b1_interrupt: 0x%x ???\n",
635 card->name, b1cmd);
636 return IRQ_HANDLED;
638 return IRQ_HANDLED;
641 /* ------------------------------------------------------------- */
642 int b1ctl_read_proc(char *page, char **start, off_t off,
643 int count, int *eof, struct capi_ctr *ctrl)
645 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
646 avmcard *card = cinfo->card;
647 u8 flag;
648 int len = 0;
649 char *s;
651 len += sprintf(page+len, "%-16s %s\n", "name", card->name);
652 len += sprintf(page+len, "%-16s 0x%x\n", "io", card->port);
653 len += sprintf(page+len, "%-16s %d\n", "irq", card->irq);
654 switch (card->cardtype) {
655 case avm_b1isa: s = "B1 ISA"; break;
656 case avm_b1pci: s = "B1 PCI"; break;
657 case avm_b1pcmcia: s = "B1 PCMCIA"; break;
658 case avm_m1: s = "M1"; break;
659 case avm_m2: s = "M2"; break;
660 case avm_t1isa: s = "T1 ISA (HEMA)"; break;
661 case avm_t1pci: s = "T1 PCI"; break;
662 case avm_c4: s = "C4"; break;
663 case avm_c2: s = "C2"; break;
664 default: s = "???"; break;
666 len += sprintf(page+len, "%-16s %s\n", "type", s);
667 if (card->cardtype == avm_t1isa)
668 len += sprintf(page+len, "%-16s %d\n", "cardnr", card->cardnr);
669 if ((s = cinfo->version[VER_DRIVER]) != 0)
670 len += sprintf(page+len, "%-16s %s\n", "ver_driver", s);
671 if ((s = cinfo->version[VER_CARDTYPE]) != 0)
672 len += sprintf(page+len, "%-16s %s\n", "ver_cardtype", s);
673 if ((s = cinfo->version[VER_SERIAL]) != 0)
674 len += sprintf(page+len, "%-16s %s\n", "ver_serial", s);
676 if (card->cardtype != avm_m1) {
677 flag = ((u8 *)(ctrl->profile.manu))[3];
678 if (flag)
679 len += sprintf(page+len, "%-16s%s%s%s%s%s%s%s\n",
680 "protocol",
681 (flag & 0x01) ? " DSS1" : "",
682 (flag & 0x02) ? " CT1" : "",
683 (flag & 0x04) ? " VN3" : "",
684 (flag & 0x08) ? " NI1" : "",
685 (flag & 0x10) ? " AUSTEL" : "",
686 (flag & 0x20) ? " ESS" : "",
687 (flag & 0x40) ? " 1TR6" : ""
690 if (card->cardtype != avm_m1) {
691 flag = ((u8 *)(ctrl->profile.manu))[5];
692 if (flag)
693 len += sprintf(page+len, "%-16s%s%s%s%s\n",
694 "linetype",
695 (flag & 0x01) ? " point to point" : "",
696 (flag & 0x02) ? " point to multipoint" : "",
697 (flag & 0x08) ? " leased line without D-channel" : "",
698 (flag & 0x04) ? " leased line with D-channel" : ""
701 len += sprintf(page+len, "%-16s %s\n", "cardname", cinfo->cardname);
703 if (off+count >= len)
704 *eof = 1;
705 if (len < off)
706 return 0;
707 *start = page + off;
708 return ((count < len-off) ? count : len-off);
711 /* ------------------------------------------------------------- */
713 #ifdef CONFIG_PCI
715 avmcard_dmainfo *
716 avmcard_dma_alloc(char *name, struct pci_dev *pdev, long rsize, long ssize)
718 avmcard_dmainfo *p;
719 void *buf;
721 p = kmalloc(sizeof(avmcard_dmainfo), GFP_KERNEL);
722 if (!p) {
723 printk(KERN_WARNING "%s: no memory.\n", name);
724 goto err;
726 memset(p, 0, sizeof(avmcard_dmainfo));
728 p->recvbuf.size = rsize;
729 buf = pci_alloc_consistent(pdev, rsize, &p->recvbuf.dmaaddr);
730 if (!buf) {
731 printk(KERN_WARNING "%s: allocation of receive dma buffer failed.\n", name);
732 goto err_kfree;
734 p->recvbuf.dmabuf = buf;
736 p->sendbuf.size = ssize;
737 buf = pci_alloc_consistent(pdev, ssize, &p->sendbuf.dmaaddr);
738 if (!buf) {
739 printk(KERN_WARNING "%s: allocation of send dma buffer failed.\n", name);
740 goto err_free_consistent;
743 p->sendbuf.dmabuf = buf;
744 skb_queue_head_init(&p->send_queue);
746 return p;
748 err_free_consistent:
749 pci_free_consistent(p->pcidev, p->recvbuf.size,
750 p->recvbuf.dmabuf, p->recvbuf.dmaaddr);
751 err_kfree:
752 kfree(p);
753 err:
754 return NULL;
757 void avmcard_dma_free(avmcard_dmainfo *p)
759 pci_free_consistent(p->pcidev, p->recvbuf.size,
760 p->recvbuf.dmabuf, p->recvbuf.dmaaddr);
761 pci_free_consistent(p->pcidev, p->sendbuf.size,
762 p->sendbuf.dmabuf, p->sendbuf.dmaaddr);
763 skb_queue_purge(&p->send_queue);
764 kfree(p);
767 EXPORT_SYMBOL(avmcard_dma_alloc);
768 EXPORT_SYMBOL(avmcard_dma_free);
770 #endif
772 EXPORT_SYMBOL(b1_irq_table);
774 EXPORT_SYMBOL(b1_alloc_card);
775 EXPORT_SYMBOL(b1_free_card);
776 EXPORT_SYMBOL(b1_detect);
777 EXPORT_SYMBOL(b1_getrevision);
778 EXPORT_SYMBOL(b1_load_t4file);
779 EXPORT_SYMBOL(b1_load_config);
780 EXPORT_SYMBOL(b1_loaded);
781 EXPORT_SYMBOL(b1_load_firmware);
782 EXPORT_SYMBOL(b1_reset_ctr);
783 EXPORT_SYMBOL(b1_register_appl);
784 EXPORT_SYMBOL(b1_release_appl);
785 EXPORT_SYMBOL(b1_send_message);
787 EXPORT_SYMBOL(b1_parse_version);
788 EXPORT_SYMBOL(b1_interrupt);
790 EXPORT_SYMBOL(b1ctl_read_proc);
792 static int __init b1_init(void)
794 char *p;
795 char rev[32];
797 if ((p = strchr(revision, ':')) != 0 && p[1]) {
798 strlcpy(rev, p + 2, 32);
799 if ((p = strchr(rev, '$')) != 0 && p > rev)
800 *(p-1) = 0;
801 } else
802 strcpy(rev, "1.0");
804 printk(KERN_INFO "b1: revision %s\n", rev);
806 return 0;
809 static void __exit b1_exit(void)
813 module_init(b1_init);
814 module_exit(b1_exit);