aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hardware/mISDN/hfcpci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/hardware/mISDN/hfcpci.c')
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c105
1 files changed, 59 insertions, 46 deletions
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index 641a9cd1a532..228ffbed1286 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -257,7 +257,7 @@ reset_hfcpci(struct hfc_pci *hc)
257 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1); 257 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
258 258
259 /* Clear already pending ints */ 259 /* Clear already pending ints */
260 if (Read_hfc(hc, HFCPCI_INT_S1)); 260 val = Read_hfc(hc, HFCPCI_INT_S1);
261 261
262 /* set NT/TE mode */ 262 /* set NT/TE mode */
263 hfcpci_setmode(hc); 263 hfcpci_setmode(hc);
@@ -452,7 +452,7 @@ hfcpci_empty_bfifo(struct bchannel *bch, struct bzfifo *bz,
452 } 452 }
453 bz->za[new_f2].z2 = cpu_to_le16(new_z2); 453 bz->za[new_f2].z2 = cpu_to_le16(new_z2);
454 bz->f2 = new_f2; /* next buffer */ 454 bz->f2 = new_f2; /* next buffer */
455 recv_Bchannel(bch); 455 recv_Bchannel(bch, MISDN_ID_ANY);
456 } 456 }
457} 457}
458 458
@@ -499,7 +499,8 @@ receive_dmsg(struct hfc_pci *hc)
499 df->f2 = ((df->f2 + 1) & MAX_D_FRAMES) | 499 df->f2 = ((df->f2 + 1) & MAX_D_FRAMES) |
500 (MAX_D_FRAMES + 1); /* next buffer */ 500 (MAX_D_FRAMES + 1); /* next buffer */
501 df->za[df->f2 & D_FREG_MASK].z2 = 501 df->za[df->f2 & D_FREG_MASK].z2 =
502 cpu_to_le16((le16_to_cpu(zp->z2) + rcnt) & (D_FIFO_SIZE - 1)); 502 cpu_to_le16((le16_to_cpu(zp->z2) + rcnt) &
503 (D_FIFO_SIZE - 1));
503 } else { 504 } else {
504 dch->rx_skb = mI_alloc_skb(rcnt - 3, GFP_ATOMIC); 505 dch->rx_skb = mI_alloc_skb(rcnt - 3, GFP_ATOMIC);
505 if (!dch->rx_skb) { 506 if (!dch->rx_skb) {
@@ -541,35 +542,45 @@ receive_dmsg(struct hfc_pci *hc)
541 * check for transparent receive data and read max one 'poll' size if avail 542 * check for transparent receive data and read max one 'poll' size if avail
542 */ 543 */
543static void 544static void
544hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata) 545hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *rxbz,
546 struct bzfifo *txbz, u_char *bdata)
545{ 547{
546 __le16 *z1r, *z2r; 548 __le16 *z1r, *z2r, *z1t, *z2t;
547 int new_z2, fcnt, maxlen; 549 int new_z2, fcnt_rx, fcnt_tx, maxlen;
548 u_char *ptr, *ptr1; 550 u_char *ptr, *ptr1;
549 551
550 z1r = &bz->za[MAX_B_FRAMES].z1; /* pointer to z reg */ 552 z1r = &rxbz->za[MAX_B_FRAMES].z1; /* pointer to z reg */
551 z2r = z1r + 1; 553 z2r = z1r + 1;
554 z1t = &txbz->za[MAX_B_FRAMES].z1;
555 z2t = z1t + 1;
552 556
553 fcnt = le16_to_cpu(*z1r) - le16_to_cpu(*z2r); 557 fcnt_rx = le16_to_cpu(*z1r) - le16_to_cpu(*z2r);
554 if (!fcnt) 558 if (!fcnt_rx)
555 return; /* no data avail */ 559 return; /* no data avail */
556 560
557 if (fcnt <= 0) 561 if (fcnt_rx <= 0)
558 fcnt += B_FIFO_SIZE; /* bytes actually buffered */ 562 fcnt_rx += B_FIFO_SIZE; /* bytes actually buffered */
559 new_z2 = le16_to_cpu(*z2r) + fcnt; /* new position in fifo */ 563 new_z2 = le16_to_cpu(*z2r) + fcnt_rx; /* new position in fifo */
560 if (new_z2 >= (B_FIFO_SIZE + B_SUB_VAL)) 564 if (new_z2 >= (B_FIFO_SIZE + B_SUB_VAL))
561 new_z2 -= B_FIFO_SIZE; /* buffer wrap */ 565 new_z2 -= B_FIFO_SIZE; /* buffer wrap */
562 566
563 if (fcnt > MAX_DATA_SIZE) { /* flush, if oversized */ 567 if (fcnt_rx > MAX_DATA_SIZE) { /* flush, if oversized */
564 *z2r = cpu_to_le16(new_z2); /* new position */ 568 *z2r = cpu_to_le16(new_z2); /* new position */
565 return; 569 return;
566 } 570 }
567 571
568 bch->rx_skb = mI_alloc_skb(fcnt, GFP_ATOMIC); 572 fcnt_tx = le16_to_cpu(*z2t) - le16_to_cpu(*z1t);
573 if (fcnt_tx <= 0)
574 fcnt_tx += B_FIFO_SIZE;
575 /* fcnt_tx contains available bytes in tx-fifo */
576 fcnt_tx = B_FIFO_SIZE - fcnt_tx;
577 /* remaining bytes to send (bytes in tx-fifo) */
578
579 bch->rx_skb = mI_alloc_skb(fcnt_rx, GFP_ATOMIC);
569 if (bch->rx_skb) { 580 if (bch->rx_skb) {
570 ptr = skb_put(bch->rx_skb, fcnt); 581 ptr = skb_put(bch->rx_skb, fcnt_rx);
571 if (le16_to_cpu(*z2r) + fcnt <= B_FIFO_SIZE + B_SUB_VAL) 582 if (le16_to_cpu(*z2r) + fcnt_rx <= B_FIFO_SIZE + B_SUB_VAL)
572 maxlen = fcnt; /* complete transfer */ 583 maxlen = fcnt_rx; /* complete transfer */
573 else 584 else
574 maxlen = B_FIFO_SIZE + B_SUB_VAL - le16_to_cpu(*z2r); 585 maxlen = B_FIFO_SIZE + B_SUB_VAL - le16_to_cpu(*z2r);
575 /* maximum */ 586 /* maximum */
@@ -577,14 +588,14 @@ hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata)
577 ptr1 = bdata + (le16_to_cpu(*z2r) - B_SUB_VAL); 588 ptr1 = bdata + (le16_to_cpu(*z2r) - B_SUB_VAL);
578 /* start of data */ 589 /* start of data */
579 memcpy(ptr, ptr1, maxlen); /* copy data */ 590 memcpy(ptr, ptr1, maxlen); /* copy data */
580 fcnt -= maxlen; 591 fcnt_rx -= maxlen;
581 592
582 if (fcnt) { /* rest remaining */ 593 if (fcnt_rx) { /* rest remaining */
583 ptr += maxlen; 594 ptr += maxlen;
584 ptr1 = bdata; /* start of buffer */ 595 ptr1 = bdata; /* start of buffer */
585 memcpy(ptr, ptr1, fcnt); /* rest */ 596 memcpy(ptr, ptr1, fcnt_rx); /* rest */
586 } 597 }
587 recv_Bchannel(bch); 598 recv_Bchannel(bch, fcnt_tx); /* bch, id */
588 } else 599 } else
589 printk(KERN_WARNING "HFCPCI: receive out of memory\n"); 600 printk(KERN_WARNING "HFCPCI: receive out of memory\n");
590 601
@@ -600,26 +611,28 @@ main_rec_hfcpci(struct bchannel *bch)
600 struct hfc_pci *hc = bch->hw; 611 struct hfc_pci *hc = bch->hw;
601 int rcnt, real_fifo; 612 int rcnt, real_fifo;
602 int receive = 0, count = 5; 613 int receive = 0, count = 5;
603 struct bzfifo *bz; 614 struct bzfifo *txbz, *rxbz;
604 u_char *bdata; 615 u_char *bdata;
605 struct zt *zp; 616 struct zt *zp;
606 617
607 if ((bch->nr & 2) && (!hc->hw.bswapped)) { 618 if ((bch->nr & 2) && (!hc->hw.bswapped)) {
608 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b2; 619 rxbz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b2;
620 txbz = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b2;
609 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b2; 621 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b2;
610 real_fifo = 1; 622 real_fifo = 1;
611 } else { 623 } else {
612 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b1; 624 rxbz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b1;
625 txbz = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b1;
613 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b1; 626 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b1;
614 real_fifo = 0; 627 real_fifo = 0;
615 } 628 }
616Begin: 629Begin:
617 count--; 630 count--;
618 if (bz->f1 != bz->f2) { 631 if (rxbz->f1 != rxbz->f2) {
619 if (bch->debug & DEBUG_HW_BCHANNEL) 632 if (bch->debug & DEBUG_HW_BCHANNEL)
620 printk(KERN_DEBUG "hfcpci rec ch(%x) f1(%d) f2(%d)\n", 633 printk(KERN_DEBUG "hfcpci rec ch(%x) f1(%d) f2(%d)\n",
621 bch->nr, bz->f1, bz->f2); 634 bch->nr, rxbz->f1, rxbz->f2);
622 zp = &bz->za[bz->f2]; 635 zp = &rxbz->za[rxbz->f2];
623 636
624 rcnt = le16_to_cpu(zp->z1) - le16_to_cpu(zp->z2); 637 rcnt = le16_to_cpu(zp->z1) - le16_to_cpu(zp->z2);
625 if (rcnt < 0) 638 if (rcnt < 0)
@@ -630,8 +643,8 @@ Begin:
630 "hfcpci rec ch(%x) z1(%x) z2(%x) cnt(%d)\n", 643 "hfcpci rec ch(%x) z1(%x) z2(%x) cnt(%d)\n",
631 bch->nr, le16_to_cpu(zp->z1), 644 bch->nr, le16_to_cpu(zp->z1),
632 le16_to_cpu(zp->z2), rcnt); 645 le16_to_cpu(zp->z2), rcnt);
633 hfcpci_empty_bfifo(bch, bz, bdata, rcnt); 646 hfcpci_empty_bfifo(bch, rxbz, bdata, rcnt);
634 rcnt = bz->f1 - bz->f2; 647 rcnt = rxbz->f1 - rxbz->f2;
635 if (rcnt < 0) 648 if (rcnt < 0)
636 rcnt += MAX_B_FRAMES + 1; 649 rcnt += MAX_B_FRAMES + 1;
637 if (hc->hw.last_bfifo_cnt[real_fifo] > rcnt + 1) { 650 if (hc->hw.last_bfifo_cnt[real_fifo] > rcnt + 1) {
@@ -644,7 +657,7 @@ Begin:
644 else 657 else
645 receive = 0; 658 receive = 0;
646 } else if (test_bit(FLG_TRANSPARENT, &bch->Flags)) { 659 } else if (test_bit(FLG_TRANSPARENT, &bch->Flags)) {
647 hfcpci_empty_fifo_trans(bch, bz, bdata); 660 hfcpci_empty_fifo_trans(bch, rxbz, txbz, bdata);
648 return; 661 return;
649 } else 662 } else
650 receive = 0; 663 receive = 0;
@@ -954,6 +967,7 @@ static void
954ph_state_nt(struct dchannel *dch) 967ph_state_nt(struct dchannel *dch)
955{ 968{
956 struct hfc_pci *hc = dch->hw; 969 struct hfc_pci *hc = dch->hw;
970 u_char val;
957 971
958 if (dch->debug) 972 if (dch->debug)
959 printk(KERN_DEBUG "%s: NT newstate %x\n", 973 printk(KERN_DEBUG "%s: NT newstate %x\n",
@@ -967,7 +981,7 @@ ph_state_nt(struct dchannel *dch)
967 hc->hw.int_m1 &= ~HFCPCI_INTS_TIMER; 981 hc->hw.int_m1 &= ~HFCPCI_INTS_TIMER;
968 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1); 982 Write_hfc(hc, HFCPCI_INT_M1, hc->hw.int_m1);
969 /* Clear already pending ints */ 983 /* Clear already pending ints */
970 if (Read_hfc(hc, HFCPCI_INT_S1)); 984 val = Read_hfc(hc, HFCPCI_INT_S1);
971 Write_hfc(hc, HFCPCI_STATES, 4 | HFCPCI_LOAD_STATE); 985 Write_hfc(hc, HFCPCI_STATES, 4 | HFCPCI_LOAD_STATE);
972 udelay(10); 986 udelay(10);
973 Write_hfc(hc, HFCPCI_STATES, 4); 987 Write_hfc(hc, HFCPCI_STATES, 4);
@@ -1256,8 +1270,7 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
1256 rx_slot = (bc>>8) & 0xff; 1270 rx_slot = (bc>>8) & 0xff;
1257 tx_slot = (bc>>16) & 0xff; 1271 tx_slot = (bc>>16) & 0xff;
1258 bc = bc & 0xff; 1272 bc = bc & 0xff;
1259 } else if (test_bit(HFC_CFG_PCM, &hc->cfg) && 1273 } else if (test_bit(HFC_CFG_PCM, &hc->cfg) && (protocol > ISDN_P_NONE))
1260 (protocol > ISDN_P_NONE))
1261 printk(KERN_WARNING "%s: no pcm channel id but HFC_CFG_PCM\n", 1274 printk(KERN_WARNING "%s: no pcm channel id but HFC_CFG_PCM\n",
1262 __func__); 1275 __func__);
1263 if (hc->chanlimit > 1) { 1276 if (hc->chanlimit > 1) {
@@ -1315,8 +1328,8 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
1315 case (ISDN_P_B_RAW): 1328 case (ISDN_P_B_RAW):
1316 bch->state = protocol; 1329 bch->state = protocol;
1317 bch->nr = bc; 1330 bch->nr = bc;
1318 hfcpci_clear_fifo_rx(hc, (fifo2 & 2)?1:0); 1331 hfcpci_clear_fifo_rx(hc, (fifo2 & 2) ? 1 : 0);
1319 hfcpci_clear_fifo_tx(hc, (fifo2 & 2)?1:0); 1332 hfcpci_clear_fifo_tx(hc, (fifo2 & 2) ? 1 : 0);
1320 if (bc & 2) { 1333 if (bc & 2) {
1321 hc->hw.sctrl |= SCTRL_B2_ENA; 1334 hc->hw.sctrl |= SCTRL_B2_ENA;
1322 hc->hw.sctrl_r |= SCTRL_B2_ENA; 1335 hc->hw.sctrl_r |= SCTRL_B2_ENA;
@@ -1350,8 +1363,8 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
1350 case (ISDN_P_B_HDLC): 1363 case (ISDN_P_B_HDLC):
1351 bch->state = protocol; 1364 bch->state = protocol;
1352 bch->nr = bc; 1365 bch->nr = bc;
1353 hfcpci_clear_fifo_rx(hc, (fifo2 & 2)?1:0); 1366 hfcpci_clear_fifo_rx(hc, (fifo2 & 2) ? 1 : 0);
1354 hfcpci_clear_fifo_tx(hc, (fifo2 & 2)?1:0); 1367 hfcpci_clear_fifo_tx(hc, (fifo2 & 2) ? 1 : 0);
1355 if (bc & 2) { 1368 if (bc & 2) {
1356 hc->hw.sctrl |= SCTRL_B2_ENA; 1369 hc->hw.sctrl |= SCTRL_B2_ENA;
1357 hc->hw.sctrl_r |= SCTRL_B2_ENA; 1370 hc->hw.sctrl_r |= SCTRL_B2_ENA;
@@ -1445,7 +1458,7 @@ set_hfcpci_rxtest(struct bchannel *bch, int protocol, int chan)
1445 switch (protocol) { 1458 switch (protocol) {
1446 case (ISDN_P_B_RAW): 1459 case (ISDN_P_B_RAW):
1447 bch->state = protocol; 1460 bch->state = protocol;
1448 hfcpci_clear_fifo_rx(hc, (chan & 2)?1:0); 1461 hfcpci_clear_fifo_rx(hc, (chan & 2) ? 1 : 0);
1449 if (chan & 2) { 1462 if (chan & 2) {
1450 hc->hw.sctrl_r |= SCTRL_B2_ENA; 1463 hc->hw.sctrl_r |= SCTRL_B2_ENA;
1451 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2RX; 1464 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2RX;
@@ -1470,7 +1483,7 @@ set_hfcpci_rxtest(struct bchannel *bch, int protocol, int chan)
1470 break; 1483 break;
1471 case (ISDN_P_B_HDLC): 1484 case (ISDN_P_B_HDLC):
1472 bch->state = protocol; 1485 bch->state = protocol;
1473 hfcpci_clear_fifo_rx(hc, (chan & 2)?1:0); 1486 hfcpci_clear_fifo_rx(hc, (chan & 2) ? 1 : 0);
1474 if (chan & 2) { 1487 if (chan & 2) {
1475 hc->hw.sctrl_r |= SCTRL_B2_ENA; 1488 hc->hw.sctrl_r |= SCTRL_B2_ENA;
1476 hc->hw.last_bfifo_cnt[1] = 0; 1489 hc->hw.last_bfifo_cnt[1] = 0;
@@ -1793,10 +1806,9 @@ init_card(struct hfc_pci *hc)
1793 printk(KERN_WARNING 1806 printk(KERN_WARNING
1794 "HFC PCI: IRQ(%d) getting no interrupts " 1807 "HFC PCI: IRQ(%d) getting no interrupts "
1795 "during init %d\n", hc->irq, 4 - cnt); 1808 "during init %d\n", hc->irq, 4 - cnt);
1796 if (cnt == 1) { 1809 if (cnt == 1)
1797 spin_unlock_irqrestore(&hc->lock, flags); 1810 break;
1798 return -EIO; 1811 else {
1799 } else {
1800 reset_hfcpci(hc); 1812 reset_hfcpci(hc);
1801 cnt--; 1813 cnt--;
1802 } 1814 }
@@ -2035,7 +2047,8 @@ setup_hw(struct hfc_pci *hc)
2035 printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n"); 2047 printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n");
2036 return 1; 2048 return 1;
2037 } 2049 }
2038 hc->hw.pci_io = (char __iomem *)(unsigned long)hc->pdev->resource[1].start; 2050 hc->hw.pci_io =
2051 (char __iomem *)(unsigned long)hc->pdev->resource[1].start;
2039 2052
2040 if (!hc->hw.pci_io) { 2053 if (!hc->hw.pci_io) {
2041 printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n"); 2054 printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
@@ -2277,7 +2290,7 @@ hfc_remove_pci(struct pci_dev *pdev)
2277 release_card(card); 2290 release_card(card);
2278 else 2291 else
2279 if (debug) 2292 if (debug)
2280 printk(KERN_WARNING "%s: drvdata already removed\n", 2293 printk(KERN_DEBUG "%s: drvdata already removed\n",
2281 __func__); 2294 __func__);
2282} 2295}
2283 2296