2 * $Id: b1dma.c,v 1.11.6.3 2001/03/21 08:52:21 kai Exp $
4 * Common module for AVM B1 cards that support dma with AMCC
6 * (c) Copyright 2000 by Carsten Paeth (calle@calle.in-berlin.de)
9 * Revision 1.11.6.3 2001/03/21 08:52:21 kai
10 * merge from main branch: fix buffer for revision string (calle)
12 * Revision 1.11.6.2 2001/03/15 15:11:23 kai
13 * *** empty log message ***
15 * Revision 1.11.6.1 2001/02/13 11:43:29 kai
16 * more compatility changes for 2.2.19
18 * Revision 1.11 2000/11/19 17:02:47 kai
19 * compatibility cleanup - part 3
21 * Revision 1.10 2000/11/19 17:01:53 kai
22 * compatibility cleanup - part 2
24 * Revision 1.9 2000/11/01 14:05:02 calle
25 * - use module_init/module_exit from linux/init.h.
26 * - all static struct variables are initialized with "membername:" now.
27 * - avm_cs.c, let it work with newer pcmcia-cs.
29 * Revision 1.8 2000/10/10 17:44:19 kai
30 * changes from/for 2.2.18
32 * Revision 1.7 2000/08/04 12:20:08 calle
33 * - Fix unsigned/signed warning in the right way ...
35 * Revision 1.6 2000/06/29 13:59:06 calle
36 * Bugfix: reinit txdma without interrupt will confuse some AMCC chips.
38 * Revision 1.5 2000/06/19 16:51:53 keil
39 * don't free skb in irq context
41 * Revision 1.4 2000/04/03 16:38:05 calle
42 * made suppress_pollack static.
44 * Revision 1.3 2000/02/26 01:00:53 keil
47 * Revision 1.2 2000/01/25 14:44:47 calle
48 * typo in b1pciv4_detect().
50 * Revision 1.1 2000/01/25 14:36:43 calle
51 * common function for T1 PCI and B1 PCI V4.
56 #include <linux/config.h>
57 #include <linux/module.h>
58 #include <linux/kernel.h>
59 #include <linux/skbuff.h>
60 #include <linux/delay.h>
62 #include <linux/interrupt.h>
63 #include <linux/ioport.h>
64 #include <linux/capi.h>
66 #include <linux/init.h>
67 #include <asm/uaccess.h>
68 #include <linux/netdevice.h>
74 static char *revision = "$Revision: 1.11.6.3 $";
76 /* ------------------------------------------------------------- */
78 MODULE_AUTHOR("Carsten Paeth <calle@calle.in-berlin.de>");
80 static int suppress_pollack = 0;
81 MODULE_PARM(suppress_pollack, "0-1i");
83 /* ------------------------------------------------------------- */
85 static void b1dma_dispatch_tx(avmcard *card);
87 /* ------------------------------------------------------------- */
91 #define AMCC_RXPTR 0x24
92 #define AMCC_RXLEN 0x28
93 #define AMCC_TXPTR 0x2c
94 #define AMCC_TXLEN 0x30
96 #define AMCC_INTCSR 0x38
97 # define EN_READ_TC_INT 0x00008000L
98 # define EN_WRITE_TC_INT 0x00004000L
99 # define EN_TX_TC_INT EN_READ_TC_INT
100 # define EN_RX_TC_INT EN_WRITE_TC_INT
101 # define AVM_FLAG 0x30000000L
103 # define ANY_S5933_INT 0x00800000L
104 # define READ_TC_INT 0x00080000L
105 # define WRITE_TC_INT 0x00040000L
106 # define TX_TC_INT READ_TC_INT
107 # define RX_TC_INT WRITE_TC_INT
108 # define MASTER_ABORT_INT 0x00100000L
109 # define TARGET_ABORT_INT 0x00200000L
110 # define BUS_MASTER_INT 0x00200000L
111 # define ALL_INT 0x000C0000L
113 #define AMCC_MCSR 0x3c
114 # define A2P_HI_PRIORITY 0x00000100L
115 # define EN_A2P_TRANSFERS 0x00000400L
116 # define P2A_HI_PRIORITY 0x00001000L
117 # define EN_P2A_TRANSFERS 0x00004000L
118 # define RESET_A2P_FLAGS 0x04000000L
119 # define RESET_P2A_FLAGS 0x02000000L
121 /* ------------------------------------------------------------- */
123 #define b1dmaoutmeml(addr, value) writel(value, addr)
124 #define b1dmainmeml(addr) readl(addr)
125 #define b1dmaoutmemw(addr, value) writew(value, addr)
126 #define b1dmainmemw(addr) readw(addr)
127 #define b1dmaoutmemb(addr, value) writeb(value, addr)
128 #define b1dmainmemb(addr) readb(addr)
130 /* ------------------------------------------------------------- */
132 static inline int b1dma_tx_empty(unsigned int port)
134 return inb(port + 0x03) & 0x1;
137 static inline int b1dma_rx_full(unsigned int port)
139 return inb(port + 0x02) & 0x1;
142 static int b1dma_tolink(avmcard *card, void *buf, unsigned int len)
144 unsigned long stop = jiffies + 1 * HZ; /* maximum wait time 1 sec */
145 unsigned char *s = (unsigned char *)buf;
147 while ( !b1dma_tx_empty(card->port)
148 && time_before(jiffies, stop));
149 if (!b1dma_tx_empty(card->port))
151 t1outp(card->port, 0x01, *s++);
156 static int b1dma_fromlink(avmcard *card, void *buf, unsigned int len)
158 unsigned long stop = jiffies + 1 * HZ; /* maximum wait time 1 sec */
159 unsigned char *s = (unsigned char *)buf;
161 while ( !b1dma_rx_full(card->port)
162 && time_before(jiffies, stop));
163 if (!b1dma_rx_full(card->port))
165 *s++ = t1inp(card->port, 0x00);
170 static int WriteReg(avmcard *card, __u32 reg, __u8 val)
173 if ( b1dma_tolink(card, &cmd, 1) == 0
174 && b1dma_tolink(card, ®, 4) == 0) {
176 return b1dma_tolink(card, &tmp, 4);
181 static __u8 ReadReg(avmcard *card, __u32 reg)
184 if ( b1dma_tolink(card, &cmd, 1) == 0
185 && b1dma_tolink(card, ®, 4) == 0) {
187 if (b1dma_fromlink(card, &tmp, 4) == 0)
193 /* ------------------------------------------------------------- */
195 static inline void _put_byte(void **pp, __u8 val)
202 static inline void _put_word(void **pp, __u32 val)
206 *s++ = (val >> 8) & 0xff;
207 *s++ = (val >> 16) & 0xff;
208 *s++ = (val >> 24) & 0xff;
212 static inline void _put_slice(void **pp, unsigned char *dp, unsigned int len)
217 _put_byte(pp, *dp++);
220 static inline __u8 _get_byte(void **pp)
229 static inline __u32 _get_word(void **pp)
241 static inline __u32 _get_slice(void **pp, unsigned char *dp)
245 len = i = _get_word(pp);
246 while (i-- > 0) *dp++ = _get_byte(pp);
250 /* ------------------------------------------------------------- */
252 void b1dma_reset(avmcard *card)
259 b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
260 b1dmaoutmeml(card->mbase+AMCC_MCSR, 0);
261 b1dmaoutmeml(card->mbase+AMCC_RXLEN, 0);
262 b1dmaoutmeml(card->mbase+AMCC_TXLEN, 0);
264 t1outp(card->port, 0x10, 0x00);
265 t1outp(card->port, 0x07, 0x00);
267 restore_flags(flags);
269 b1dmaoutmeml(card->mbase+AMCC_MCSR, 0);
271 b1dmaoutmeml(card->mbase+AMCC_MCSR, 0x0f000000); /* reset all */
273 b1dmaoutmeml(card->mbase+AMCC_MCSR, 0);
274 if (card->cardtype == avm_t1pci)
280 /* ------------------------------------------------------------- */
282 int b1dma_detect(avmcard *card)
284 b1dmaoutmeml(card->mbase+AMCC_MCSR, 0);
286 b1dmaoutmeml(card->mbase+AMCC_MCSR, 0x0f000000); /* reset all */
288 b1dmaoutmeml(card->mbase+AMCC_MCSR, 0);
291 b1dmaoutmeml(card->mbase+AMCC_RXLEN, 0);
292 b1dmaoutmeml(card->mbase+AMCC_TXLEN, 0);
294 b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
296 if (b1dmainmeml(card->mbase+AMCC_MCSR) != 0x000000E6)
299 b1dmaoutmeml(card->mbase+AMCC_RXPTR, 0xffffffff);
300 b1dmaoutmeml(card->mbase+AMCC_TXPTR, 0xffffffff);
301 if ( b1dmainmeml(card->mbase+AMCC_RXPTR) != 0xfffffffc
302 || b1dmainmeml(card->mbase+AMCC_TXPTR) != 0xfffffffc)
305 b1dmaoutmeml(card->mbase+AMCC_RXPTR, 0x0);
306 b1dmaoutmeml(card->mbase+AMCC_TXPTR, 0x0);
307 if ( b1dmainmeml(card->mbase+AMCC_RXPTR) != 0x0
308 || b1dmainmeml(card->mbase+AMCC_TXPTR) != 0x0)
311 t1outp(card->port, 0x10, 0x00);
312 t1outp(card->port, 0x07, 0x00);
314 t1outp(card->port, 0x02, 0x02);
315 t1outp(card->port, 0x03, 0x02);
317 if ( (t1inp(card->port, 0x02) & 0xFE) != 0x02
318 || t1inp(card->port, 0x3) != 0x03)
321 t1outp(card->port, 0x02, 0x00);
322 t1outp(card->port, 0x03, 0x00);
324 if ( (t1inp(card->port, 0x02) & 0xFE) != 0x00
325 || t1inp(card->port, 0x3) != 0x01)
331 int t1pci_detect(avmcard *card)
335 if ((ret = b1dma_detect(card)) != 0)
338 /* Transputer test */
340 if ( WriteReg(card, 0x80001000, 0x11) != 0
341 || WriteReg(card, 0x80101000, 0x22) != 0
342 || WriteReg(card, 0x80201000, 0x33) != 0
343 || WriteReg(card, 0x80301000, 0x44) != 0)
346 if ( ReadReg(card, 0x80001000) != 0x11
347 || ReadReg(card, 0x80101000) != 0x22
348 || ReadReg(card, 0x80201000) != 0x33
349 || ReadReg(card, 0x80301000) != 0x44)
352 if ( WriteReg(card, 0x80001000, 0x55) != 0
353 || WriteReg(card, 0x80101000, 0x66) != 0
354 || WriteReg(card, 0x80201000, 0x77) != 0
355 || WriteReg(card, 0x80301000, 0x88) != 0)
358 if ( ReadReg(card, 0x80001000) != 0x55
359 || ReadReg(card, 0x80101000) != 0x66
360 || ReadReg(card, 0x80201000) != 0x77
361 || ReadReg(card, 0x80301000) != 0x88)
367 int b1pciv4_detect(avmcard *card)
371 if ((ret = b1dma_detect(card)) != 0)
374 for (i=0; i < 5 ; i++) {
375 if (WriteReg(card, 0x80A00000, 0x21) != 0)
377 if ((ReadReg(card, 0x80A00000) & 0x01) != 0x01)
380 for (i=0; i < 5 ; i++) {
381 if (WriteReg(card, 0x80A00000, 0x20) != 0)
383 if ((ReadReg(card, 0x80A00000) & 0x01) != 0x00)
390 /* ------------------------------------------------------------- */
392 static void b1dma_dispatch_tx(avmcard *card)
394 avmcard_dmainfo *dma = card->dma;
406 inint = card->interrupt;
408 if (card->csr & EN_TX_TC_INT) { /* tx busy */
409 restore_flags(flags);
413 skb = skb_dequeue(&dma->send_queue);
415 #ifdef CONFIG_B1DMA_DEBUG
416 printk(KERN_DEBUG "tx(%d): underrun\n", inint);
418 restore_flags(flags);
422 len = CAPIMSG_LEN(skb->data);
425 cmd = CAPIMSG_COMMAND(skb->data);
426 subcmd = CAPIMSG_SUBCOMMAND(skb->data);
430 if (CAPICMD(cmd, subcmd) == CAPI_DATA_B3_REQ) {
431 __u16 dlen = CAPIMSG_DATALEN(skb->data);
432 _put_byte(&p, SEND_DATA_B3_REQ);
433 _put_slice(&p, skb->data, len);
434 _put_slice(&p, skb->data + len, dlen);
436 _put_byte(&p, SEND_MESSAGE);
437 _put_slice(&p, skb->data, len);
439 txlen = (__u8 *)p - (__u8 *)dma->sendbuf;
440 #ifdef CONFIG_B1DMA_DEBUG
441 printk(KERN_DEBUG "tx(%d): put msg len=%d\n",
446 #ifdef CONFIG_B1DMA_POLLDEBUG
447 if (skb->data[2] == SEND_POLLACK)
448 printk(KERN_INFO "%s: send ack\n", card->name);
450 #ifdef CONFIG_B1DMA_DEBUG
451 printk(KERN_DEBUG "tx(%d): put 0x%x len=%d\n",
452 inint, skb->data[2], txlen);
454 memcpy(dma->sendbuf, skb->data+2, skb->len-2);
456 txlen = (txlen + 3) & ~3;
458 b1dmaoutmeml(card->mbase+AMCC_TXPTR, virt_to_phys(dma->sendbuf));
459 b1dmaoutmeml(card->mbase+AMCC_TXLEN, txlen);
461 card->csr |= EN_TX_TC_INT;
464 b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
466 restore_flags(flags);
467 dev_kfree_skb_any(skb);
470 /* ------------------------------------------------------------- */
472 static void queue_pollack(avmcard *card)
477 skb = alloc_skb(3, GFP_ATOMIC);
479 printk(KERN_CRIT "%s: no memory, lost poll ack\n",
486 _put_byte(&p, SEND_POLLACK);
487 skb_put(skb, (__u8 *)p - (__u8 *)skb->data);
489 skb_queue_tail(&card->dma->send_queue, skb);
490 b1dma_dispatch_tx(card);
493 /* ------------------------------------------------------------- */
495 static void b1dma_handle_rx(avmcard *card)
497 avmctrl_info *cinfo = &card->ctrlinfo[0];
498 avmcard_dmainfo *dma = card->dma;
499 struct capi_ctr *ctrl = cinfo->capi_ctrl;
501 void *p = dma->recvbuf+4;
502 __u32 ApplId, MsgLen, DataB3Len, NCCI, WindowSize;
503 __u8 b1cmd = _get_byte(&p);
505 #ifdef CONFIG_B1DMA_DEBUG
506 printk(KERN_DEBUG "rx: 0x%x %lu\n", b1cmd, (unsigned long)dma->recvlen);
510 case RECEIVE_DATA_B3_IND:
512 ApplId = (unsigned) _get_word(&p);
513 MsgLen = _get_slice(&p, card->msgbuf);
514 DataB3Len = _get_slice(&p, card->databuf);
516 if (MsgLen < 30) { /* not CAPI 64Bit */
517 memset(card->msgbuf+MsgLen, 0, 30-MsgLen);
519 CAPIMSG_SETLEN(card->msgbuf, 30);
521 if (!(skb = alloc_skb(DataB3Len+MsgLen, GFP_ATOMIC))) {
522 printk(KERN_ERR "%s: incoming packet dropped\n",
525 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
526 memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len);
527 ctrl->handle_capimsg(ctrl, ApplId, skb);
531 case RECEIVE_MESSAGE:
533 ApplId = (unsigned) _get_word(&p);
534 MsgLen = _get_slice(&p, card->msgbuf);
535 if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) {
536 printk(KERN_ERR "%s: incoming packet dropped\n",
539 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen);
540 ctrl->handle_capimsg(ctrl, ApplId, skb);
544 case RECEIVE_NEW_NCCI:
546 ApplId = _get_word(&p);
547 NCCI = _get_word(&p);
548 WindowSize = _get_word(&p);
550 ctrl->new_ncci(ctrl, ApplId, NCCI, WindowSize);
554 case RECEIVE_FREE_NCCI:
556 ApplId = _get_word(&p);
557 NCCI = _get_word(&p);
559 if (NCCI != 0xffffffff)
560 ctrl->free_ncci(ctrl, ApplId, NCCI);
561 else ctrl->appl_released(ctrl, ApplId);
565 #ifdef CONFIG_B1DMA_POLLDEBUG
566 printk(KERN_INFO "%s: receive poll\n", card->name);
568 if (!suppress_pollack)
570 ctrl->resume_output(ctrl);
574 ctrl->suspend_output(ctrl);
579 cinfo->versionlen = _get_slice(&p, cinfo->versionbuf);
580 b1_parse_version(cinfo);
581 printk(KERN_INFO "%s: %s-card (%s) now active\n",
583 cinfo->version[VER_CARDTYPE],
584 cinfo->version[VER_DRIVER]);
588 case RECEIVE_TASK_READY:
589 ApplId = (unsigned) _get_word(&p);
590 MsgLen = _get_slice(&p, card->msgbuf);
591 card->msgbuf[MsgLen] = 0;
593 && ( card->msgbuf[MsgLen-1] == '\n'
594 || card->msgbuf[MsgLen-1] == '\r')) {
595 card->msgbuf[MsgLen-1] = 0;
598 printk(KERN_INFO "%s: task %d \"%s\" ready.\n",
599 card->name, ApplId, card->msgbuf);
602 case RECEIVE_DEBUGMSG:
603 MsgLen = _get_slice(&p, card->msgbuf);
604 card->msgbuf[MsgLen] = 0;
606 && ( card->msgbuf[MsgLen-1] == '\n'
607 || card->msgbuf[MsgLen-1] == '\r')) {
608 card->msgbuf[MsgLen-1] = 0;
611 printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf);
615 printk(KERN_ERR "%s: b1dma_interrupt: 0x%x ???\n",
621 /* ------------------------------------------------------------- */
623 static void b1dma_handle_interrupt(avmcard *card)
625 __u32 status = b1dmainmeml(card->mbase+AMCC_INTCSR);
628 if ((status & ANY_S5933_INT) == 0)
631 newcsr = card->csr | (status & ALL_INT);
632 if (status & TX_TC_INT) newcsr &= ~EN_TX_TC_INT;
633 if (status & RX_TC_INT) newcsr &= ~EN_RX_TC_INT;
634 b1dmaoutmeml(card->mbase+AMCC_INTCSR, newcsr);
636 if ((status & RX_TC_INT) != 0) {
637 __u8 *recvbuf = card->dma->recvbuf;
639 if (card->dma->recvlen == 0) {
640 card->dma->recvlen = *((__u32 *)recvbuf);
641 rxlen = (card->dma->recvlen + 3) & ~3;
642 b1dmaoutmeml(card->mbase+AMCC_RXPTR,
643 virt_to_phys(recvbuf+4));
644 b1dmaoutmeml(card->mbase+AMCC_RXLEN, rxlen);
646 b1dma_handle_rx(card);
647 card->dma->recvlen = 0;
648 b1dmaoutmeml(card->mbase+AMCC_RXPTR, virt_to_phys(recvbuf));
649 b1dmaoutmeml(card->mbase+AMCC_RXLEN, 4);
653 if ((status & TX_TC_INT) != 0) {
654 card->csr &= ~EN_TX_TC_INT;
655 b1dma_dispatch_tx(card);
657 b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
660 void b1dma_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
664 card = (avmcard *) devptr;
667 printk(KERN_WARNING "b1dma: interrupt: wrong device\n");
670 if (card->interrupt) {
671 printk(KERN_ERR "%s: reentering interrupt hander\n", card->name);
677 b1dma_handle_interrupt(card);
682 /* ------------------------------------------------------------- */
684 static int b1dma_loaded(avmcard *card)
688 unsigned long tout = 2;
689 unsigned int base = card->port;
691 for (stop = jiffies + tout * HZ; time_before(jiffies, stop);) {
692 if (b1_tx_empty(base))
695 if (!b1_tx_empty(base)) {
696 printk(KERN_ERR "%s: b1dma_loaded: tx err, corrupted t4 file ?\n",
700 b1_put_byte(base, SEND_POLLACK);
701 for (stop = jiffies + tout * HZ; time_before(jiffies, stop);) {
702 if (b1_rx_full(base)) {
703 if ((ans = b1_get_byte(base)) == RECEIVE_POLLDWORD) {
706 printk(KERN_ERR "%s: b1dma_loaded: got 0x%x, firmware not running in dword mode\n", card->name, ans);
710 printk(KERN_ERR "%s: b1dma_loaded: firmware not running\n", card->name);
714 /* ------------------------------------------------------------- */
716 static void b1dma_send_init(avmcard *card)
721 skb = alloc_skb(15, GFP_ATOMIC);
723 printk(KERN_CRIT "%s: no memory, lost register appl.\n",
730 _put_byte(&p, SEND_INIT);
731 _put_word(&p, AVM_NAPPS);
732 _put_word(&p, AVM_NCCI_PER_CHANNEL*30);
733 _put_word(&p, card->cardnr - 1);
734 skb_put(skb, (__u8 *)p - (__u8 *)skb->data);
736 skb_queue_tail(&card->dma->send_queue, skb);
737 b1dma_dispatch_tx(card);
740 int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
742 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
743 avmcard *card = cinfo->card;
749 if ((retval = b1_load_t4file(card, &data->firmware))) {
751 printk(KERN_ERR "%s: failed to load t4file!!\n",
756 if (data->configuration.len > 0 && data->configuration.data) {
757 if ((retval = b1_load_config(card, &data->configuration))) {
759 printk(KERN_ERR "%s: failed to load config!!\n",
765 if (!b1dma_loaded(card)) {
767 printk(KERN_ERR "%s: failed to load t4file.\n", card->name);
774 card->csr = AVM_FLAG;
775 b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
776 b1dmaoutmeml(card->mbase+AMCC_MCSR,
777 EN_A2P_TRANSFERS|EN_P2A_TRANSFERS
778 |A2P_HI_PRIORITY|P2A_HI_PRIORITY
779 |RESET_A2P_FLAGS|RESET_P2A_FLAGS);
780 t1outp(card->port, 0x07, 0x30);
781 t1outp(card->port, 0x10, 0xF0);
783 card->dma->recvlen = 0;
784 b1dmaoutmeml(card->mbase+AMCC_RXPTR, virt_to_phys(card->dma->recvbuf));
785 b1dmaoutmeml(card->mbase+AMCC_RXLEN, 4);
786 card->csr |= EN_RX_TC_INT;
787 b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
788 restore_flags(flags);
790 b1dma_send_init(card);
795 void b1dma_reset_ctr(struct capi_ctr *ctrl)
797 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
798 avmcard *card = cinfo->card;
802 memset(cinfo->version, 0, sizeof(cinfo->version));
807 /* ------------------------------------------------------------- */
810 void b1dma_register_appl(struct capi_ctr *ctrl,
812 capi_register_params *rp)
814 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
815 avmcard *card = cinfo->card;
817 int want = rp->level3cnt;
821 if (want > 0) nconn = want;
822 else nconn = ctrl->profile.nbchannel * -want;
823 if (nconn == 0) nconn = ctrl->profile.nbchannel;
825 skb = alloc_skb(23, GFP_ATOMIC);
827 printk(KERN_CRIT "%s: no memory, lost register appl.\n",
834 _put_byte(&p, SEND_REGISTER);
836 _put_word(&p, 1024 * (nconn+1));
837 _put_word(&p, nconn);
838 _put_word(&p, rp->datablkcnt);
839 _put_word(&p, rp->datablklen);
840 skb_put(skb, (__u8 *)p - (__u8 *)skb->data);
842 skb_queue_tail(&card->dma->send_queue, skb);
843 b1dma_dispatch_tx(card);
845 ctrl->appl_registered(ctrl, appl);
848 /* ------------------------------------------------------------- */
850 void b1dma_release_appl(struct capi_ctr *ctrl, __u16 appl)
852 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
853 avmcard *card = cinfo->card;
857 skb = alloc_skb(7, GFP_ATOMIC);
859 printk(KERN_CRIT "%s: no memory, lost release appl.\n",
866 _put_byte(&p, SEND_RELEASE);
869 skb_put(skb, (__u8 *)p - (__u8 *)skb->data);
870 skb_queue_tail(&card->dma->send_queue, skb);
871 b1dma_dispatch_tx(card);
874 /* ------------------------------------------------------------- */
876 void b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
878 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
879 avmcard *card = cinfo->card;
880 skb_queue_tail(&card->dma->send_queue, skb);
881 b1dma_dispatch_tx(card);
884 /* ------------------------------------------------------------- */
886 int b1dmactl_read_proc(char *page, char **start, off_t off,
887 int count, int *eof, struct capi_ctr *ctrl)
889 avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
890 avmcard *card = cinfo->card;
895 __u32 txaddr, txlen, rxaddr, rxlen, csr;
897 len += sprintf(page+len, "%-16s %s\n", "name", card->name);
898 len += sprintf(page+len, "%-16s 0x%x\n", "io", card->port);
899 len += sprintf(page+len, "%-16s %d\n", "irq", card->irq);
900 len += sprintf(page+len, "%-16s 0x%lx\n", "membase", card->membase);
901 switch (card->cardtype) {
902 case avm_b1isa: s = "B1 ISA"; break;
903 case avm_b1pci: s = "B1 PCI"; break;
904 case avm_b1pcmcia: s = "B1 PCMCIA"; break;
905 case avm_m1: s = "M1"; break;
906 case avm_m2: s = "M2"; break;
907 case avm_t1isa: s = "T1 ISA (HEMA)"; break;
908 case avm_t1pci: s = "T1 PCI"; break;
909 case avm_c4: s = "C4"; break;
910 default: s = "???"; break;
912 len += sprintf(page+len, "%-16s %s\n", "type", s);
913 if ((s = cinfo->version[VER_DRIVER]) != 0)
914 len += sprintf(page+len, "%-16s %s\n", "ver_driver", s);
915 if ((s = cinfo->version[VER_CARDTYPE]) != 0)
916 len += sprintf(page+len, "%-16s %s\n", "ver_cardtype", s);
917 if ((s = cinfo->version[VER_SERIAL]) != 0)
918 len += sprintf(page+len, "%-16s %s\n", "ver_serial", s);
920 if (card->cardtype != avm_m1) {
921 flag = ((__u8 *)(ctrl->profile.manu))[3];
923 len += sprintf(page+len, "%-16s%s%s%s%s%s%s%s\n",
925 (flag & 0x01) ? " DSS1" : "",
926 (flag & 0x02) ? " CT1" : "",
927 (flag & 0x04) ? " VN3" : "",
928 (flag & 0x08) ? " NI1" : "",
929 (flag & 0x10) ? " AUSTEL" : "",
930 (flag & 0x20) ? " ESS" : "",
931 (flag & 0x40) ? " 1TR6" : ""
934 if (card->cardtype != avm_m1) {
935 flag = ((__u8 *)(ctrl->profile.manu))[5];
937 len += sprintf(page+len, "%-16s%s%s%s%s\n",
939 (flag & 0x01) ? " point to point" : "",
940 (flag & 0x02) ? " point to multipoint" : "",
941 (flag & 0x08) ? " leased line without D-channel" : "",
942 (flag & 0x04) ? " leased line with D-channel" : ""
945 len += sprintf(page+len, "%-16s %s\n", "cardname", cinfo->cardname);
950 txaddr = (__u32)phys_to_virt(b1dmainmeml(card->mbase+0x2c));
951 txaddr -= (__u32)card->dma->sendbuf;
952 txlen = b1dmainmeml(card->mbase+0x30);
954 rxaddr = (__u32)phys_to_virt(b1dmainmeml(card->mbase+0x24));
955 rxaddr -= (__u32)card->dma->recvbuf;
956 rxlen = b1dmainmeml(card->mbase+0x28);
958 csr = b1dmainmeml(card->mbase+AMCC_INTCSR);
960 restore_flags(flags);
962 len += sprintf(page+len, "%-16s 0x%lx\n",
963 "csr (cached)", (unsigned long)card->csr);
964 len += sprintf(page+len, "%-16s 0x%lx\n",
965 "csr", (unsigned long)csr);
966 len += sprintf(page+len, "%-16s %lu\n",
967 "txoff", (unsigned long)txaddr);
968 len += sprintf(page+len, "%-16s %lu\n",
969 "txlen", (unsigned long)txlen);
970 len += sprintf(page+len, "%-16s %lu\n",
971 "rxoff", (unsigned long)rxaddr);
972 len += sprintf(page+len, "%-16s %lu\n",
973 "rxlen", (unsigned long)rxlen);
975 if (off+count >= len)
980 return ((count < len-off) ? count : len-off);
983 /* ------------------------------------------------------------- */
985 EXPORT_SYMBOL(b1dma_reset);
986 EXPORT_SYMBOL(t1pci_detect);
987 EXPORT_SYMBOL(b1pciv4_detect);
988 EXPORT_SYMBOL(b1dma_interrupt);
990 EXPORT_SYMBOL(b1dma_load_firmware);
991 EXPORT_SYMBOL(b1dma_reset_ctr);
992 EXPORT_SYMBOL(b1dma_register_appl);
993 EXPORT_SYMBOL(b1dma_release_appl);
994 EXPORT_SYMBOL(b1dma_send_message);
995 EXPORT_SYMBOL(b1dmactl_read_proc);
1002 if ((p = strchr(revision, ':')) != 0 && p[1]) {
1003 strncpy(rev, p + 2, sizeof(rev));
1004 rev[sizeof(rev)-1] = 0;
1005 if ((p = strchr(rev, '$')) != 0 && p > rev)
1010 printk(KERN_INFO "b1dma: revision %s\n", rev);
1015 void b1dma_exit(void)
1019 module_init(b1dma_init);
1020 module_exit(b1dma_exit);