diff options
Diffstat (limited to 'drivers/isdn/hardware/avm/b1dma.c')
-rw-r--r-- | drivers/isdn/hardware/avm/b1dma.c | 178 |
1 files changed, 89 insertions, 89 deletions
diff --git a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c index a0ed668d4d2a..0896aa86fc08 100644 --- a/drivers/isdn/hardware/avm/b1dma.c +++ b/drivers/isdn/hardware/avm/b1dma.c @@ -1,9 +1,9 @@ /* $Id: b1dma.c,v 1.1.2.3 2004/02/10 01:07:12 keil Exp $ - * + * * Common module for AVM B1 cards that support dma with AMCC - * + * * Copyright 2000 by Carsten Paeth <calle@calle.de> - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -110,11 +110,11 @@ static int b1dma_tolink(avmcard *card, void *buf, unsigned int len) unsigned long stop = jiffies + 1 * HZ; /* maximum wait time 1 sec */ unsigned char *s = (unsigned char *)buf; while (len--) { - while ( !b1dma_tx_empty(card->port) + while (!b1dma_tx_empty(card->port) && time_before(jiffies, stop)); - if (!b1dma_tx_empty(card->port)) + if (!b1dma_tx_empty(card->port)) return -1; - t1outp(card->port, 0x01, *s++); + t1outp(card->port, 0x01, *s++); } return 0; } @@ -124,11 +124,11 @@ static int b1dma_fromlink(avmcard *card, void *buf, unsigned int len) unsigned long stop = jiffies + 1 * HZ; /* maximum wait time 1 sec */ unsigned char *s = (unsigned char *)buf; while (len--) { - while ( !b1dma_rx_full(card->port) + while (!b1dma_rx_full(card->port) && time_before(jiffies, stop)); - if (!b1dma_rx_full(card->port)) + if (!b1dma_rx_full(card->port)) return -1; - *s++ = t1inp(card->port, 0x00); + *s++ = t1inp(card->port, 0x00); } return 0; } @@ -136,7 +136,7 @@ static int b1dma_fromlink(avmcard *card, void *buf, unsigned int len) static int WriteReg(avmcard *card, u32 reg, u8 val) { u8 cmd = 0x00; - if ( b1dma_tolink(card, &cmd, 1) == 0 + if (b1dma_tolink(card, &cmd, 1) == 0 && b1dma_tolink(card, ®, 4) == 0) { u32 tmp = val; return b1dma_tolink(card, &tmp, 4); @@ -147,7 +147,7 @@ static int WriteReg(avmcard *card, u32 reg, u8 val) static u8 ReadReg(avmcard *card, u32 reg) { u8 cmd = 0x01; - if ( b1dma_tolink(card, &cmd, 1) == 0 + if (b1dma_tolink(card, &cmd, 1) == 0 && b1dma_tolink(card, ®, 4) == 0) { u32 tmp; if (b1dma_fromlink(card, &tmp, 4) == 0) @@ -258,30 +258,30 @@ static int b1dma_detect(avmcard *card) b1dma_writel(card, 0xffffffff, AMCC_RXPTR); b1dma_writel(card, 0xffffffff, AMCC_TXPTR); - if ( b1dma_readl(card, AMCC_RXPTR) != 0xfffffffc + if (b1dma_readl(card, AMCC_RXPTR) != 0xfffffffc || b1dma_readl(card, AMCC_TXPTR) != 0xfffffffc) return 2; b1dma_writel(card, 0x0, AMCC_RXPTR); b1dma_writel(card, 0x0, AMCC_TXPTR); - if ( b1dma_readl(card, AMCC_RXPTR) != 0x0 + if (b1dma_readl(card, AMCC_RXPTR) != 0x0 || b1dma_readl(card, AMCC_TXPTR) != 0x0) return 3; t1outp(card->port, 0x10, 0x00); t1outp(card->port, 0x07, 0x00); - + t1outp(card->port, 0x02, 0x02); t1outp(card->port, 0x03, 0x02); - if ( (t1inp(card->port, 0x02) & 0xFE) != 0x02 + if ((t1inp(card->port, 0x02) & 0xFE) != 0x02 || t1inp(card->port, 0x3) != 0x03) return 4; t1outp(card->port, 0x02, 0x00); t1outp(card->port, 0x03, 0x00); - if ( (t1inp(card->port, 0x02) & 0xFE) != 0x00 + if ((t1inp(card->port, 0x02) & 0xFE) != 0x00 || t1inp(card->port, 0x3) != 0x01) return 5; @@ -294,28 +294,28 @@ int t1pci_detect(avmcard *card) if ((ret = b1dma_detect(card)) != 0) return ret; - + /* Transputer test */ - - if ( WriteReg(card, 0x80001000, 0x11) != 0 + + if (WriteReg(card, 0x80001000, 0x11) != 0 || WriteReg(card, 0x80101000, 0x22) != 0 || WriteReg(card, 0x80201000, 0x33) != 0 || WriteReg(card, 0x80301000, 0x44) != 0) return 6; - if ( ReadReg(card, 0x80001000) != 0x11 + if (ReadReg(card, 0x80001000) != 0x11 || ReadReg(card, 0x80101000) != 0x22 || ReadReg(card, 0x80201000) != 0x33 || ReadReg(card, 0x80301000) != 0x44) return 7; - if ( WriteReg(card, 0x80001000, 0x55) != 0 + if (WriteReg(card, 0x80001000, 0x55) != 0 || WriteReg(card, 0x80101000, 0x66) != 0 || WriteReg(card, 0x80201000, 0x77) != 0 || WriteReg(card, 0x80301000, 0x88) != 0) return 8; - if ( ReadReg(card, 0x80001000) != 0x55 + if (ReadReg(card, 0x80001000) != 0x55 || ReadReg(card, 0x80101000) != 0x66 || ReadReg(card, 0x80201000) != 0x77 || ReadReg(card, 0x80301000) != 0x88) @@ -330,20 +330,20 @@ int b1pciv4_detect(avmcard *card) if ((ret = b1dma_detect(card)) != 0) return ret; - - for (i=0; i < 5 ; i++) { + + for (i = 0; i < 5; i++) { if (WriteReg(card, 0x80A00000, 0x21) != 0) return 6; if ((ReadReg(card, 0x80A00000) & 0x01) != 0x01) return 7; } - for (i=0; i < 5 ; i++) { + for (i = 0; i < 5; i++) { if (WriteReg(card, 0x80A00000, 0x20) != 0) return 8; if ((ReadReg(card, 0x80A00000) & 0x01) != 0x00) return 9; } - + return 0; } @@ -373,7 +373,7 @@ static void b1dma_dispatch_tx(avmcard *card) u16 len; u32 txlen; void *p; - + skb = skb_dequeue(&dma->send_queue); len = CAPIMSG_LEN(skb->data); @@ -398,13 +398,13 @@ static void b1dma_dispatch_tx(avmcard *card) printk(KERN_DEBUG "tx: put msg len=%d\n", txlen); #endif } else { - txlen = skb->len-2; + txlen = skb->len - 2; #ifdef AVM_B1DMA_POLLDEBUG if (skb->data[2] == SEND_POLLACK) printk(KERN_INFO "%s: send ack\n", card->name); #endif #ifdef AVM_B1DMA_DEBUG - printk(KERN_DEBUG "tx: put 0x%x len=%d\n", + printk(KERN_DEBUG "tx: put 0x%x len=%d\n", skb->data[2], txlen); #endif skb_copy_from_linear_data_offset(skb, 2, dma->sendbuf.dmabuf, @@ -430,7 +430,7 @@ static void queue_pollack(avmcard *card) skb = alloc_skb(3, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost poll ack\n", - card->name); + card->name); return; } p = skb->data; @@ -450,14 +450,14 @@ static void b1dma_handle_rx(avmcard *card) avmcard_dmainfo *dma = card->dma; struct capi_ctr *ctrl = &cinfo->capi_ctrl; struct sk_buff *skb; - void *p = dma->recvbuf.dmabuf+4; + void *p = dma->recvbuf.dmabuf + 4; u32 ApplId, MsgLen, DataB3Len, NCCI, WindowSize; u8 b1cmd = _get_byte(&p); #ifdef AVM_B1DMA_DEBUG printk(KERN_DEBUG "rx: 0x%x %lu\n", b1cmd, (unsigned long)dma->recvlen); #endif - + switch (b1cmd) { case RECEIVE_DATA_B3_IND: @@ -466,13 +466,13 @@ static void b1dma_handle_rx(avmcard *card) DataB3Len = _get_slice(&p, card->databuf); if (MsgLen < 30) { /* not CAPI 64Bit */ - memset(card->msgbuf+MsgLen, 0, 30-MsgLen); + memset(card->msgbuf + MsgLen, 0, 30 - MsgLen); MsgLen = 30; CAPIMSG_SETLEN(card->msgbuf, 30); } - if (!(skb = alloc_skb(DataB3Len+MsgLen, GFP_ATOMIC))) { + if (!(skb = alloc_skb(DataB3Len + MsgLen, GFP_ATOMIC))) { printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); @@ -486,14 +486,14 @@ static void b1dma_handle_rx(avmcard *card) MsgLen = _get_slice(&p, card->msgbuf); if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) { printk(KERN_ERR "%s: incoming packet dropped\n", - card->name); + card->name); } else { memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_CONF) { spin_lock(&card->lock); capilib_data_b3_conf(&cinfo->ncci_head, ApplId, - CAPIMSG_NCCI(skb->data), - CAPIMSG_MSGID(skb->data)); + CAPIMSG_NCCI(skb->data), + CAPIMSG_MSGID(skb->data)); spin_unlock(&card->lock); } capi_ctr_handle_message(ctrl, ApplId, skb); @@ -550,23 +550,23 @@ static void b1dma_handle_rx(avmcard *card) ApplId = (unsigned) _get_word(&p); MsgLen = _get_slice(&p, card->msgbuf); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: task %d \"%s\" ready.\n", - card->name, ApplId, card->msgbuf); + card->name, ApplId, card->msgbuf); break; case RECEIVE_DEBUGMSG: MsgLen = _get_slice(&p, card->msgbuf); card->msgbuf[MsgLen] = 0; - while ( MsgLen > 0 - && ( card->msgbuf[MsgLen-1] == '\n' - || card->msgbuf[MsgLen-1] == '\r')) { - card->msgbuf[MsgLen-1] = 0; + while (MsgLen > 0 + && (card->msgbuf[MsgLen - 1] == '\n' + || card->msgbuf[MsgLen - 1] == '\r')) { + card->msgbuf[MsgLen - 1] = 0; MsgLen--; } printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf); @@ -574,7 +574,7 @@ static void b1dma_handle_rx(avmcard *card) default: printk(KERN_ERR "%s: b1dma_interrupt: 0x%x ???\n", - card->name, b1cmd); + card->name, b1cmd); return; } } @@ -594,7 +594,7 @@ static void b1dma_handle_interrupt(avmcard *card) return; } - newcsr = card->csr | (status & ALL_INT); + newcsr = card->csr | (status & ALL_INT); if (status & TX_TC_INT) newcsr &= ~EN_TX_TC_INT; if (status & RX_TC_INT) newcsr &= ~EN_RX_TC_INT; b1dma_writel(card, newcsr, AMCC_INTCSR); @@ -602,23 +602,23 @@ static void b1dma_handle_interrupt(avmcard *card) if ((status & RX_TC_INT) != 0) { struct avmcard_dmainfo *dma = card->dma; u32 rxlen; - if (card->dma->recvlen == 0) { - rxlen = b1dma_readl(card, AMCC_RXLEN); + if (card->dma->recvlen == 0) { + rxlen = b1dma_readl(card, AMCC_RXLEN); if (rxlen == 0) { dma->recvlen = *((u32 *)dma->recvbuf.dmabuf); rxlen = (dma->recvlen + 3) & ~3; - b1dma_writel(card, dma->recvbuf.dmaaddr+4, AMCC_RXPTR); + b1dma_writel(card, dma->recvbuf.dmaaddr + 4, AMCC_RXPTR); b1dma_writel(card, rxlen, AMCC_RXLEN); #ifdef AVM_B1DMA_DEBUG } else { printk(KERN_ERR "%s: rx not complete (%d).\n", - card->name, rxlen); + card->name, rxlen); #endif } } else { spin_unlock(&card->lock); b1dma_handle_rx(card); - dma->recvlen = 0; + dma->recvlen = 0; spin_lock(&card->lock); b1dma_writel(card, dma->recvbuf.dmaaddr, AMCC_RXPTR); b1dma_writel(card, 4, AMCC_RXLEN); @@ -659,7 +659,7 @@ static int b1dma_loaded(avmcard *card) } if (!b1_tx_empty(base)) { printk(KERN_ERR "%s: b1dma_loaded: tx err, corrupted t4 file ?\n", - card->name); + card->name); return 0; } b1_put_byte(base, SEND_POLLACK); @@ -686,7 +686,7 @@ static void b1dma_send_init(avmcard *card) skb = alloc_skb(15, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost register appl.\n", - card->name); + card->name); return; } p = skb->data; @@ -694,7 +694,7 @@ static void b1dma_send_init(avmcard *card) _put_byte(&p, 0); _put_byte(&p, SEND_INIT); _put_word(&p, CAPI_MAXAPPL); - _put_word(&p, AVM_NCCI_PER_CHANNEL*30); + _put_word(&p, AVM_NCCI_PER_CHANNEL * 30); _put_word(&p, card->cardnr - 1); skb_put(skb, (u8 *)p - (u8 *)skb->data); @@ -712,7 +712,7 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) if ((retval = b1_load_t4file(card, &data->firmware))) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load t4file!!\n", - card->name); + card->name); return retval; } @@ -720,7 +720,7 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) if ((retval = b1_load_config(card, &data->configuration))) { b1dma_reset(card); printk(KERN_ERR "%s: failed to load config!!\n", - card->name); + card->name); return retval; } } @@ -733,8 +733,8 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) card->csr = AVM_FLAG; b1dma_writel(card, card->csr, AMCC_INTCSR); - b1dma_writel(card, EN_A2P_TRANSFERS|EN_P2A_TRANSFERS|A2P_HI_PRIORITY| - P2A_HI_PRIORITY|RESET_A2P_FLAGS|RESET_P2A_FLAGS, + b1dma_writel(card, EN_A2P_TRANSFERS | EN_P2A_TRANSFERS | A2P_HI_PRIORITY | + P2A_HI_PRIORITY | RESET_A2P_FLAGS | RESET_P2A_FLAGS, AMCC_MCSR); t1outp(card->port, 0x07, 0x30); t1outp(card->port, 0x10, 0xF0); @@ -745,7 +745,7 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) card->csr |= EN_RX_TC_INT; b1dma_writel(card, card->csr, AMCC_INTCSR); - b1dma_send_init(card); + b1dma_send_init(card); return 0; } @@ -757,7 +757,7 @@ void b1dma_reset_ctr(struct capi_ctr *ctrl) unsigned long flags; spin_lock_irqsave(&card->lock, flags); - b1dma_reset(card); + b1dma_reset(card); memset(cinfo->version, 0, sizeof(cinfo->version)); capilib_release(&cinfo->ncci_head); @@ -768,8 +768,8 @@ void b1dma_reset_ctr(struct capi_ctr *ctrl) /* ------------------------------------------------------------- */ void b1dma_register_appl(struct capi_ctr *ctrl, - u16 appl, - capi_register_params *rp) + u16 appl, + capi_register_params *rp) { avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmcard *card = cinfo->card; @@ -785,7 +785,7 @@ void b1dma_register_appl(struct capi_ctr *ctrl, skb = alloc_skb(23, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost register appl.\n", - card->name); + card->name); return; } p = skb->data; @@ -793,7 +793,7 @@ void b1dma_register_appl(struct capi_ctr *ctrl, _put_byte(&p, 0); _put_byte(&p, SEND_REGISTER); _put_word(&p, appl); - _put_word(&p, 1024 * (nconn+1)); + _put_word(&p, 1024 * (nconn + 1)); _put_word(&p, nconn); _put_word(&p, rp->datablkcnt); _put_word(&p, rp->datablklen); @@ -819,7 +819,7 @@ void b1dma_release_appl(struct capi_ctr *ctrl, u16 appl) skb = alloc_skb(7, GFP_ATOMIC); if (!skb) { printk(KERN_CRIT "%s: no memory, lost release appl.\n", - card->name); + card->name); return; } p = skb->data; @@ -841,7 +841,7 @@ u16 b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) avmcard *card = cinfo->card; u16 retval = CAPI_NOERROR; - if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_REQ) { + if (CAPIMSG_CMD(skb->data) == CAPI_DATA_B3_REQ) { unsigned long flags; spin_lock_irqsave(&card->lock, flags); retval = capilib_data_b3_req(&cinfo->ncci_head, @@ -850,7 +850,7 @@ u16 b1dma_send_message(struct capi_ctr *ctrl, struct sk_buff *skb) CAPIMSG_MSGID(skb->data)); spin_unlock_irqrestore(&card->lock, flags); } - if (retval == CAPI_NOERROR) + if (retval == CAPI_NOERROR) b1dma_queue_tx(card, skb); return retval; @@ -893,29 +893,29 @@ static int b1dmactl_proc_show(struct seq_file *m, void *v) seq_printf(m, "%-16s %s\n", "ver_serial", s); if (card->cardtype != avm_m1) { - flag = ((u8 *)(ctrl->profile.manu))[3]; - if (flag) + flag = ((u8 *)(ctrl->profile.manu))[3]; + if (flag) seq_printf(m, "%-16s%s%s%s%s%s%s%s\n", - "protocol", - (flag & 0x01) ? " DSS1" : "", - (flag & 0x02) ? " CT1" : "", - (flag & 0x04) ? " VN3" : "", - (flag & 0x08) ? " NI1" : "", - (flag & 0x10) ? " AUSTEL" : "", - (flag & 0x20) ? " ESS" : "", - (flag & 0x40) ? " 1TR6" : "" - ); + "protocol", + (flag & 0x01) ? " DSS1" : "", + (flag & 0x02) ? " CT1" : "", + (flag & 0x04) ? " VN3" : "", + (flag & 0x08) ? " NI1" : "", + (flag & 0x10) ? " AUSTEL" : "", + (flag & 0x20) ? " ESS" : "", + (flag & 0x40) ? " 1TR6" : "" + ); } if (card->cardtype != avm_m1) { - flag = ((u8 *)(ctrl->profile.manu))[5]; + flag = ((u8 *)(ctrl->profile.manu))[5]; if (flag) seq_printf(m, "%-16s%s%s%s%s\n", - "linetype", - (flag & 0x01) ? " point to point" : "", - (flag & 0x02) ? " point to multipoint" : "", - (flag & 0x08) ? " leased line without D-channel" : "", - (flag & 0x04) ? " leased line with D-channel" : "" - ); + "linetype", + (flag & 0x01) ? " point to point" : "", + (flag & 0x02) ? " point to multipoint" : "", + (flag & 0x08) ? " leased line without D-channel" : "", + (flag & 0x04) ? " leased line with D-channel" : "" + ); } seq_printf(m, "%-16s %s\n", "cardname", cinfo->cardname); @@ -977,7 +977,7 @@ static int __init b1dma_init(void) if ((p = strchr(revision, ':')) != NULL && p[1]) { strlcpy(rev, p + 2, sizeof(rev)); if ((p = strchr(rev, '$')) != NULL && p > rev) - *(p-1) = 0; + *(p - 1) = 0; } else strcpy(rev, "1.0"); |