Lines Matching full:card

42 /*      Number of ports (per card) and cards supported
53 * of frames on the way down to the card
54 * so that we can keep the card busy
88 /* Card shared memory layout
105 #define FST_MEMSIZE 0x100000 /* Size of card memory (1Mb) */
177 /* Interrupts from the card are caused by various events which are presented
318 /* Number of times the card thinks the host has
426 struct fst_card_info *card; /* Card we're associated with */ member
427 int index; /* Port index on the card */
443 /* Per card information
446 char __iomem *mem; /* Card memory mapped to kernel space */
452 unsigned int type; /* Type index of card */
453 unsigned int state; /* State of card */
455 unsigned short pci_conf; /* PCI card config in I/O space */
459 int card_no; /* Inst of the card on the system */
555 * Interrupt Service routine, we will declare a work queue per Card
562 static void do_bottom_half_tx(struct fst_card_info *card);
563 static void do_bottom_half_rx(struct fst_card_info *card);
586 * a bit for the card indicating that there is work to do in the in fst_q_work_item()
587 * bottom half for the card. Note the limitation of 64 cards. in fst_q_work_item()
610 /* Call the bottom half for each card with work waiting in fst_process_tx_work_q()
615 dbg(DBG_TX, "Calling tx bh for card %d\n", i); in fst_process_tx_work_q()
638 /* Call the bottom half for each card with work waiting in fst_process_int_work_q()
644 "Calling rx & tx bh for card %d\n", i); in fst_process_int_work_q()
653 /* Card control functions
658 * Used to be a simple write to card control space but a glitch in the latest
664 fst_cpureset(struct fst_card_info *card) in fst_cpureset() argument
669 if (card->family == FST_FAMILY_TXU) { in fst_cpureset()
671 (card->device, PCI_INTERRUPT_LINE, &interrupt_line_register)) { in fst_cpureset()
678 outw(0x440f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
679 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
683 outw(0x240f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
687 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
690 (card->device, PCI_INTERRUPT_LINE, interrupt_line_register)) { in fst_cpureset()
696 regval = inl(card->pci_conf + CNTRL_9052); in fst_cpureset()
698 outl(regval | 0x40000000, card->pci_conf + CNTRL_9052); in fst_cpureset()
699 outl(regval & ~0x40000000, card->pci_conf + CNTRL_9052); in fst_cpureset()
706 fst_cpurelease(struct fst_card_info *card) in fst_cpurelease() argument
708 if (card->family == FST_FAMILY_TXU) { in fst_cpurelease()
711 (void)readb(card->mem); in fst_cpurelease()
716 outw(0x040e, card->pci_conf + CNTRL_9054 + 2); in fst_cpurelease()
717 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); in fst_cpurelease()
719 (void)readb(card->ctlmem); in fst_cpurelease()
726 fst_clear_intr(struct fst_card_info *card) in fst_clear_intr() argument
728 if (card->family == FST_FAMILY_TXU) { in fst_clear_intr()
729 (void)readb(card->ctlmem); in fst_clear_intr()
733 outw(0x0543, card->pci_conf + INTCSR_9052); in fst_clear_intr()
737 /* Enable card interrupts
740 fst_enable_intr(struct fst_card_info *card) in fst_enable_intr() argument
742 if (card->family == FST_FAMILY_TXU) in fst_enable_intr()
743 outl(0x0f0c0900, card->pci_conf + INTCSR_9054); in fst_enable_intr()
745 outw(0x0543, card->pci_conf + INTCSR_9052); in fst_enable_intr()
748 /* Disable card interrupts
751 fst_disable_intr(struct fst_card_info *card) in fst_disable_intr() argument
753 if (card->family == FST_FAMILY_TXU) in fst_disable_intr()
754 outl(0x00000000, card->pci_conf + INTCSR_9054); in fst_disable_intr()
756 outw(0x0000, card->pci_conf + INTCSR_9052); in fst_disable_intr()
782 fst_init_dma(struct fst_card_info *card) in fst_init_dma() argument
786 if (card->family == FST_FAMILY_TXU) { in fst_init_dma()
787 pci_set_master(card->device); in fst_init_dma()
788 outl(0x00020441, card->pci_conf + DMAMODE0); in fst_init_dma()
789 outl(0x00020441, card->pci_conf + DMAMODE1); in fst_init_dma()
790 outl(0x0, card->pci_conf + DMATHR); in fst_init_dma()
797 fst_tx_dma_complete(struct fst_card_info *card, struct fst_port_info *port, in fst_tx_dma_complete() argument
802 /* Everything is now set, just tell the card to go in fst_tx_dma_complete()
805 FST_WRB(card, txDescrRing[port->index][txpos].bits, in fst_tx_dma_complete()
825 fst_rx_dma_complete(struct fst_card_info *card, struct fst_port_info *port, in fst_rx_dma_complete() argument
834 skb_put_data(skb, card->rx_dma_handle_host, len); in fst_rx_dma_complete()
837 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_rx_dma_complete()
858 fst_rx_dma(struct fst_card_info *card, dma_addr_t dma, u32 mem, int len) in fst_rx_dma() argument
864 if (card->dmarx_in_progress) in fst_rx_dma()
867 outl(dma, card->pci_conf + DMAPADR0); /* Copy to here */ in fst_rx_dma()
868 outl(mem, card->pci_conf + DMALADR0); /* from here */ in fst_rx_dma()
869 outl(len, card->pci_conf + DMASIZ0); /* for this length */ in fst_rx_dma()
870 outl(0x00000000c, card->pci_conf + DMADPR0); /* In this direction */ in fst_rx_dma()
874 card->dmarx_in_progress = 1; in fst_rx_dma()
875 outb(0x03, card->pci_conf + DMACSR0); /* Start the transfer */ in fst_rx_dma()
881 fst_tx_dma(struct fst_card_info *card, dma_addr_t dma, u32 mem, int len) in fst_tx_dma() argument
887 if (card->dmatx_in_progress) in fst_tx_dma()
890 outl(dma, card->pci_conf + DMAPADR1); /* Copy from here */ in fst_tx_dma()
891 outl(mem, card->pci_conf + DMALADR1); /* to here */ in fst_tx_dma()
892 outl(len, card->pci_conf + DMASIZ1); /* for this length */ in fst_tx_dma()
893 outl(0x000000004, card->pci_conf + DMADPR1); /* In this direction */ in fst_tx_dma()
897 card->dmatx_in_progress = 1; in fst_tx_dma()
898 outb(0x03, card->pci_conf + DMACSR1); /* Start the transfer */ in fst_tx_dma()
908 struct fst_card_info *card; in fst_issue_cmd() local
913 card = port->card; in fst_issue_cmd()
914 spin_lock_irqsave(&card->card_lock, flags); in fst_issue_cmd()
915 mbval = FST_RDW(card, portMailbox[port->index][0]); in fst_issue_cmd()
920 spin_unlock_irqrestore(&card->card_lock, flags); in fst_issue_cmd()
922 spin_lock_irqsave(&card->card_lock, flags); in fst_issue_cmd()
929 mbval = FST_RDW(card, portMailbox[port->index][0]); in fst_issue_cmd()
937 FST_WRW(card, portMailbox[port->index][0], cmd); in fst_issue_cmd()
945 spin_unlock_irqrestore(&card->card_lock, flags); in fst_issue_cmd()
953 outputs |= FST_RDL(port->card, v24OpSts[port->index]); in fst_op_raise()
954 FST_WRL(port->card, v24OpSts[port->index], outputs); in fst_op_raise()
963 outputs = ~outputs & FST_RDL(port->card, v24OpSts[port->index]); in fst_op_lower()
964 FST_WRL(port->card, v24OpSts[port->index], outputs); in fst_op_lower()
979 struct fst_card_info *card; in fst_rx_config() local
982 card = port->card; in fst_rx_config()
983 spin_lock_irqsave(&card->card_lock, flags); in fst_rx_config()
987 FST_WRW(card, rxDescrRing[pi][i].ladr, (u16)offset); in fst_rx_config()
988 FST_WRB(card, rxDescrRing[pi][i].hadr, (u8)(offset >> 16)); in fst_rx_config()
989 FST_WRW(card, rxDescrRing[pi][i].bcnt, cnv_bcnt(LEN_RX_BUFFER)); in fst_rx_config()
990 FST_WRW(card, rxDescrRing[pi][i].mcnt, LEN_RX_BUFFER); in fst_rx_config()
991 FST_WRB(card, rxDescrRing[pi][i].bits, DMA_OWN); in fst_rx_config()
994 spin_unlock_irqrestore(&card->card_lock, flags); in fst_rx_config()
1006 struct fst_card_info *card; in fst_tx_config() local
1009 card = port->card; in fst_tx_config()
1010 spin_lock_irqsave(&card->card_lock, flags); in fst_tx_config()
1014 FST_WRW(card, txDescrRing[pi][i].ladr, (u16)offset); in fst_tx_config()
1015 FST_WRB(card, txDescrRing[pi][i].hadr, (u8)(offset >> 16)); in fst_tx_config()
1016 FST_WRW(card, txDescrRing[pi][i].bcnt, 0); in fst_tx_config()
1017 FST_WRB(card, txDescrRing[pi][i].bits, 0); in fst_tx_config()
1022 spin_unlock_irqrestore(&card->card_lock, flags); in fst_tx_config()
1028 fst_intr_te1_alarm(struct fst_card_info *card, struct fst_port_info *port) in fst_intr_te1_alarm() argument
1034 los = FST_RDB(card, suStatus.lossOfSignal); in fst_intr_te1_alarm()
1035 rra = FST_RDB(card, suStatus.receiveRemoteAlarm); in fst_intr_te1_alarm()
1036 ais = FST_RDB(card, suStatus.alarmIndicationSignal); in fst_intr_te1_alarm()
1072 fst_intr_ctlchg(struct fst_card_info *card, struct fst_port_info *port) in fst_intr_ctlchg() argument
1076 signals = FST_RDL(card, v24DebouncedSts[port->index]); in fst_intr_ctlchg()
1095 fst_log_rx_error(struct fst_card_info *card, struct fst_port_info *port, in fst_log_rx_error() argument
1105 dbg(DBG_ASS, "Rx fifo error on card %d port %d buffer %d\n", in fst_log_rx_error()
1106 card->card_no, port->index, rxp); in fst_log_rx_error()
1110 dbg(DBG_ASS, "Rx crc error on card %d port %d\n", in fst_log_rx_error()
1111 card->card_no, port->index); in fst_log_rx_error()
1115 dbg(DBG_ASS, "Rx frame error on card %d port %d\n", in fst_log_rx_error()
1116 card->card_no, port->index); in fst_log_rx_error()
1120 dbg(DBG_ASS, "Rx length error (%d) on card %d port %d\n", in fst_log_rx_error()
1121 len, card->card_no, port->index); in fst_log_rx_error()
1128 fst_recover_rx_error(struct fst_card_info *card, struct fst_port_info *port, in fst_recover_rx_error() argument
1141 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_recover_rx_error()
1148 dmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits); in fst_recover_rx_error()
1155 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_recover_rx_error()
1164 fst_intr_rx(struct fst_card_info *card, struct fst_port_info *port) in fst_intr_rx() argument
1177 dmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits); in fst_intr_rx()
1183 if (card->dmarx_in_progress) in fst_intr_rx()
1187 len = FST_RDW(card, rxDescrRing[pi][rxp].mcnt); in fst_intr_rx()
1194 pr_err("Frame received with 0 length. Card %d Port %d\n", in fst_intr_rx()
1195 card->card_no, port->index); in fst_intr_rx()
1196 /* Return descriptor to card */ in fst_intr_rx()
1197 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_intr_rx()
1210 fst_log_rx_error(card, port, dmabits, rxp, len); in fst_intr_rx()
1211 fst_recover_rx_error(card, port, dmabits, rxp, len); in fst_intr_rx()
1222 /* Return descriptor to card */ in fst_intr_rx()
1223 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_intr_rx()
1235 if (len < FST_MIN_DMA_LEN || card->family == FST_FAMILY_TXP) { in fst_intr_rx()
1237 card->mem + BUF_OFFSET(rxBuffer[pi][rxp][0]), in fst_intr_rx()
1241 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_intr_rx()
1258 card->dma_skb_rx = skb; in fst_intr_rx()
1259 card->dma_port_rx = port; in fst_intr_rx()
1260 card->dma_len_rx = len; in fst_intr_rx()
1261 card->dma_rxpos = rxp; in fst_intr_rx()
1262 fst_rx_dma(card, card->rx_dma_handle_card, in fst_intr_rx()
1278 do_bottom_half_tx(struct fst_card_info *card) in do_bottom_half_tx() argument
1288 * Step through each port on this card in do_bottom_half_tx()
1292 for (pi = 0, port = card->ports; pi < card->nports; pi++, port++) { in do_bottom_half_tx()
1297 while (!(FST_RDB(card, txDescrRing[pi][port->txpos].bits) & in do_bottom_half_tx()
1299 !(card->dmatx_in_progress)) { in do_bottom_half_tx()
1304 spin_lock_irqsave(&card->card_lock, flags); in do_bottom_half_tx()
1312 spin_unlock_irqrestore(&card->card_lock, flags); in do_bottom_half_tx()
1316 spin_lock_irqsave(&card->card_lock, flags); in do_bottom_half_tx()
1322 spin_unlock_irqrestore(&card->card_lock, flags); in do_bottom_half_tx()
1324 * card. in do_bottom_half_tx()
1326 FST_WRW(card, txDescrRing[pi][port->txpos].bcnt, in do_bottom_half_tx()
1329 card->family == FST_FAMILY_TXP) { in do_bottom_half_tx()
1331 memcpy_toio(card->mem + in do_bottom_half_tx()
1336 FST_WRB(card, in do_bottom_half_tx()
1345 memcpy(card->tx_dma_handle_host, in do_bottom_half_tx()
1347 card->dma_port_tx = port; in do_bottom_half_tx()
1348 card->dma_len_tx = skb->len; in do_bottom_half_tx()
1349 card->dma_txpos = port->txpos; in do_bottom_half_tx()
1350 fst_tx_dma(card, in do_bottom_half_tx()
1351 card->tx_dma_handle_card, in do_bottom_half_tx()
1378 do_bottom_half_rx(struct fst_card_info *card) in do_bottom_half_rx() argument
1384 /* Check for rx completions on all ports on this card */ in do_bottom_half_rx()
1386 for (pi = 0, port = card->ports; pi < card->nports; pi++, port++) { in do_bottom_half_rx()
1390 while (!(FST_RDB(card, rxDescrRing[pi][port->rxpos].bits) in do_bottom_half_rx()
1391 & DMA_OWN) && !(card->dmarx_in_progress)) { in do_bottom_half_rx()
1396 fst_q_work_item(&fst_work_intq, card->card_no); in do_bottom_half_rx()
1400 fst_intr_rx(card, port); in do_bottom_half_rx()
1412 struct fst_card_info *card = dev_id; in fst_intr() local
1421 /* Check to see if the interrupt was for this card in fst_intr()
1425 dbg(DBG_INTR, "intr: %d %p\n", card->irq, card); in fst_intr()
1426 if (card->state != FST_RUNNING) { in fst_intr()
1427 pr_err("Interrupt received for card %d in a non running state (%d)\n", in fst_intr()
1428 card->card_no, card->state); in fst_intr()
1431 * a running card in fst_intr()
1434 fst_clear_intr(card); in fst_intr()
1439 fst_clear_intr(card); in fst_intr()
1441 /* Is the interrupt for this card (handshake == 1) in fst_intr()
1444 if (FST_RDB(card, interruptHandshake) == 1) { in fst_intr()
1447 FST_WRB(card, interruptHandshake, 0xEE); in fst_intr()
1449 if (card->family == FST_FAMILY_TXU) { in fst_intr()
1452 dma_intcsr = inl(card->pci_conf + INTCSR_9054); in fst_intr()
1457 outb(0x8, card->pci_conf + DMACSR0); in fst_intr()
1458 fst_rx_dma_complete(card, card->dma_port_rx, in fst_intr()
1459 card->dma_len_rx, card->dma_skb_rx, in fst_intr()
1460 card->dma_rxpos); in fst_intr()
1461 card->dmarx_in_progress = 0; in fst_intr()
1468 outb(0x8, card->pci_conf + DMACSR1); in fst_intr()
1469 fst_tx_dma_complete(card, card->dma_port_tx, in fst_intr()
1470 card->dma_len_tx, card->dma_txpos); in fst_intr()
1471 card->dmatx_in_progress = 0; in fst_intr()
1478 int_retry_count = FST_RDL(card, interruptRetryCount); in fst_intr()
1480 dbg(DBG_ASS, "Card %d int_retry_count is %d\n", in fst_intr()
1481 card->card_no, int_retry_count); in fst_intr()
1482 FST_WRL(card, interruptRetryCount, 0); in fst_intr()
1489 fst_q_work_item(&fst_work_intq, card->card_no); in fst_intr()
1493 rdidx = FST_RDB(card, interruptEvent.rdindex) & 0x1f; in fst_intr()
1494 wridx = FST_RDB(card, interruptEvent.wrindex) & 0x1f; in fst_intr()
1496 event = FST_RDB(card, interruptEvent.evntbuff[rdidx]); in fst_intr()
1497 port = &card->ports[event & 0x03]; in fst_intr()
1505 fst_intr_te1_alarm(card, port); in fst_intr()
1513 fst_intr_ctlchg(card, port); in fst_intr()
1533 dbg(DBG_ASS, "Tx underflow on card %d port %d\n", in fst_intr()
1534 card->card_no, port->index); in fst_intr()
1538 dbg(DBG_INIT, "Card init OK intr\n"); in fst_intr()
1542 dbg(DBG_INIT, "Card init FAILED intr\n"); in fst_intr()
1543 card->state = FST_IFAILED; in fst_intr()
1547 pr_err("intr: unknown card event %d. ignored\n", event); in fst_intr()
1555 FST_WRB(card, interruptEvent.rdindex, rdidx); in fst_intr()
1563 check_started_ok(struct fst_card_info *card) in check_started_ok() argument
1568 if (FST_RDW(card, smcVersion) != SMC_VERSION) { in check_started_ok()
1570 FST_RDW(card, smcVersion), SMC_VERSION); in check_started_ok()
1571 card->state = FST_BADVERSION; in check_started_ok()
1574 if (FST_RDL(card, endOfSmcSignature) != END_SIG) { in check_started_ok()
1576 card->state = FST_BADVERSION; in check_started_ok()
1580 i = FST_RDB(card, taskStatus); in check_started_ok()
1582 card->state = FST_RUNNING; in check_started_ok()
1584 pr_err("Firmware initialisation failed. Card halted\n"); in check_started_ok()
1585 card->state = FST_HALTED; in check_started_ok()
1589 card->state = FST_HALTED; in check_started_ok()
1594 * number we assumed at card detection. Should never happen with in check_started_ok()
1597 if (FST_RDL(card, numberOfPorts) != card->nports) { in check_started_ok()
1598 pr_warn("Port count mismatch on card %d. Firmware thinks %d we say %d\n", in check_started_ok()
1599 card->card_no, in check_started_ok()
1600 FST_RDL(card, numberOfPorts), card->nports); in check_started_ok()
1605 set_conf_from_info(struct fst_card_info *card, struct fst_port_info *port, in set_conf_from_info() argument
1630 FST_WRB(card, portConfig[port->index].invertClock, in set_conf_from_info()
1633 FST_WRW(card, cardMode, info->cardMode); in set_conf_from_info()
1635 FST_WRL(card, suConfig.dataRate, info->lineSpeed); in set_conf_from_info()
1636 FST_WRB(card, suConfig.clocking, info->clockSource); in set_conf_from_info()
1644 FST_WRB(card, suConfig.framing, my_framing); in set_conf_from_info()
1645 FST_WRB(card, suConfig.structure, info->structure); in set_conf_from_info()
1646 FST_WRB(card, suConfig.interface, info->interface); in set_conf_from_info()
1647 FST_WRB(card, suConfig.coding, info->coding); in set_conf_from_info()
1648 FST_WRB(card, suConfig.lineBuildOut, info->lineBuildOut); in set_conf_from_info()
1649 FST_WRB(card, suConfig.equalizer, info->equalizer); in set_conf_from_info()
1650 FST_WRB(card, suConfig.transparentMode, info->transparentMode); in set_conf_from_info()
1651 FST_WRB(card, suConfig.loopMode, info->loopMode); in set_conf_from_info()
1652 FST_WRB(card, suConfig.range, info->range); in set_conf_from_info()
1653 FST_WRB(card, suConfig.txBufferMode, info->txBufferMode); in set_conf_from_info()
1654 FST_WRB(card, suConfig.rxBufferMode, info->rxBufferMode); in set_conf_from_info()
1655 FST_WRB(card, suConfig.startingSlot, info->startingSlot); in set_conf_from_info()
1656 FST_WRB(card, suConfig.losThreshold, info->losThreshold); in set_conf_from_info()
1658 FST_WRB(card, suConfig.enableIdleCode, 1); in set_conf_from_info()
1660 FST_WRB(card, suConfig.enableIdleCode, 0); in set_conf_from_info()
1661 FST_WRB(card, suConfig.idleCode, info->idleCode); in set_conf_from_info()
1694 gather_conf_info(struct fst_card_info *card, struct fst_port_info *port, in gather_conf_info() argument
1703 info->nports = card->nports; in gather_conf_info()
1704 info->type = card->type; in gather_conf_info()
1705 info->state = card->state; in gather_conf_info()
1712 /* Only mark information as valid if card is running. in gather_conf_info()
1715 info->valid = ((card->state == FST_RUNNING) ? FSTVAL_ALL : FSTVAL_CARD) in gather_conf_info()
1721 info->lineInterface = FST_RDW(card, portConfig[i].lineInterface); in gather_conf_info()
1722 info->internalClock = FST_RDB(card, portConfig[i].internalClock); in gather_conf_info()
1723 info->lineSpeed = FST_RDL(card, portConfig[i].lineSpeed); in gather_conf_info()
1724 info->invertClock = FST_RDB(card, portConfig[i].invertClock); in gather_conf_info()
1725 info->v24IpSts = FST_RDL(card, v24IpSts[i]); in gather_conf_info()
1726 info->v24OpSts = FST_RDL(card, v24OpSts[i]); in gather_conf_info()
1727 info->clockStatus = FST_RDW(card, clockStatus[i]); in gather_conf_info()
1728 info->cableStatus = FST_RDW(card, cableStatus); in gather_conf_info()
1729 info->cardMode = FST_RDW(card, cardMode); in gather_conf_info()
1730 info->smcFirmwareVersion = FST_RDL(card, smcFirmwareVersion); in gather_conf_info()
1736 if (card->family == FST_FAMILY_TXU) { in gather_conf_info()
1750 if (card->type == FST_TYPE_TE1) { in gather_conf_info()
1751 info->lineSpeed = FST_RDL(card, suConfig.dataRate); in gather_conf_info()
1752 info->clockSource = FST_RDB(card, suConfig.clocking); in gather_conf_info()
1753 info->framing = FST_RDB(card, suConfig.framing); in gather_conf_info()
1754 info->structure = FST_RDB(card, suConfig.structure); in gather_conf_info()
1755 info->interface = FST_RDB(card, suConfig.interface); in gather_conf_info()
1756 info->coding = FST_RDB(card, suConfig.coding); in gather_conf_info()
1757 info->lineBuildOut = FST_RDB(card, suConfig.lineBuildOut); in gather_conf_info()
1758 info->equalizer = FST_RDB(card, suConfig.equalizer); in gather_conf_info()
1759 info->loopMode = FST_RDB(card, suConfig.loopMode); in gather_conf_info()
1760 info->range = FST_RDB(card, suConfig.range); in gather_conf_info()
1761 info->txBufferMode = FST_RDB(card, suConfig.txBufferMode); in gather_conf_info()
1762 info->rxBufferMode = FST_RDB(card, suConfig.rxBufferMode); in gather_conf_info()
1763 info->startingSlot = FST_RDB(card, suConfig.startingSlot); in gather_conf_info()
1764 info->losThreshold = FST_RDB(card, suConfig.losThreshold); in gather_conf_info()
1765 if (FST_RDB(card, suConfig.enableIdleCode)) in gather_conf_info()
1766 info->idleCode = FST_RDB(card, suConfig.idleCode); in gather_conf_info()
1770 FST_RDL(card, suStatus.receiveBufferDelay); in gather_conf_info()
1772 FST_RDL(card, suStatus.framingErrorCount); in gather_conf_info()
1774 FST_RDL(card, suStatus.codeViolationCount); in gather_conf_info()
1775 info->crcErrorCount = FST_RDL(card, suStatus.crcErrorCount); in gather_conf_info()
1776 info->lineAttenuation = FST_RDL(card, suStatus.lineAttenuation); in gather_conf_info()
1777 info->lossOfSignal = FST_RDB(card, suStatus.lossOfSignal); in gather_conf_info()
1779 FST_RDB(card, suStatus.receiveRemoteAlarm); in gather_conf_info()
1781 FST_RDB(card, suStatus.alarmIndicationSignal); in gather_conf_info()
1786 fst_set_iface(struct fst_card_info *card, struct fst_port_info *port, in fst_set_iface() argument
1805 FST_WRW(card, portConfig[i].lineInterface, V35); in fst_set_iface()
1810 FST_WRW(card, portConfig[i].lineInterface, V24); in fst_set_iface()
1815 FST_WRW(card, portConfig[i].lineInterface, X21); in fst_set_iface()
1820 FST_WRW(card, portConfig[i].lineInterface, X21D); in fst_set_iface()
1825 FST_WRW(card, portConfig[i].lineInterface, T1); in fst_set_iface()
1830 FST_WRW(card, portConfig[i].lineInterface, E1); in fst_set_iface()
1843 FST_WRB(card, portConfig[i].internalClock, EXTCLK); in fst_set_iface()
1847 FST_WRB(card, portConfig[i].internalClock, INTCLK); in fst_set_iface()
1853 FST_WRL(card, portConfig[i].lineSpeed, sync.clock_rate); in fst_set_iface()
1858 fst_get_iface(struct fst_card_info *card, struct fst_port_info *port, in fst_get_iface() argument
1897 sync.clock_rate = FST_RDL(card, portConfig[i].lineSpeed); in fst_get_iface()
1898 /* Lucky card and linux use same encoding here */ in fst_get_iface()
1899 sync.clock_type = FST_RDB(card, portConfig[i].internalClock) == in fst_get_iface()
1913 struct fst_card_info *card; in fst_siocdevprivate() local
1923 card = port->card; in fst_siocdevprivate()
1930 fst_cpureset(card); in fst_siocdevprivate()
1931 card->state = FST_RESET; in fst_siocdevprivate()
1935 fst_cpurelease(card); in fst_siocdevprivate()
1936 card->state = FST_STARTING; in fst_siocdevprivate()
1957 /* Now copy the data to the card. */ in fst_siocdevprivate()
1964 memcpy_toio(card->mem + wrthdr.offset, buf, wrthdr.size); in fst_siocdevprivate()
1967 /* Writes to the memory of a card in the reset state constitute in fst_siocdevprivate()
1970 if (card->state == FST_RESET) in fst_siocdevprivate()
1971 card->state = FST_DOWNLOAD; in fst_siocdevprivate()
1977 /* If card has just been started check the shared memory config in fst_siocdevprivate()
1980 if (card->state == FST_STARTING) { in fst_siocdevprivate()
1981 check_started_ok(card); in fst_siocdevprivate()
1983 /* If everything checked out enable card interrupts */ in fst_siocdevprivate()
1984 if (card->state == FST_RUNNING) { in fst_siocdevprivate()
1985 spin_lock_irqsave(&card->card_lock, flags); in fst_siocdevprivate()
1986 fst_enable_intr(card); in fst_siocdevprivate()
1987 FST_WRB(card, interruptHandshake, 0xEE); in fst_siocdevprivate()
1988 spin_unlock_irqrestore(&card->card_lock, flags); in fst_siocdevprivate()
1995 gather_conf_info(card, port, &info); in fst_siocdevprivate()
2007 if (card->state != FST_RUNNING) { in fst_siocdevprivate()
2008 pr_err("Attempt to configure card %d in non-running state (%d)\n", in fst_siocdevprivate()
2009 card->card_no, card->state); in fst_siocdevprivate()
2015 return set_conf_from_info(card, port, &info); in fst_siocdevprivate()
2024 struct fst_card_info *card; in fst_ioctl() local
2030 card = port->card; in fst_ioctl()
2037 return fst_get_iface(card, port, ifs); in fst_ioctl()
2046 return fst_set_iface(card, port, ifs); in fst_ioctl()
2072 /* Only init things if card is actually running. This allows open to in fst_openport()
2075 if (port->card->state == FST_RUNNING) { in fst_openport()
2090 signals = FST_RDL(port->card, v24DebouncedSts[port->index]); in fst_openport()
2105 if (port->card->state == FST_RUNNING) { in fst_closeport()
2144 struct fst_card_info *card; in fst_close() local
2149 card = port->card; in fst_close()
2151 tx_dma_done = inb(card->pci_conf + DMACSR1); in fst_close()
2152 rx_dma_done = inb(card->pci_conf + DMACSR0); in fst_close()
2155 card->dmatx_in_progress, tx_dma_done, card->dmarx_in_progress, in fst_close()
2170 /* Setting currently fixed in FarSync card so we check and forget in fst_attach()
2181 struct fst_card_info *card; in fst_tx_timeout() local
2184 card = port->card; in fst_tx_timeout()
2187 dbg(DBG_ASS, "Tx timeout card %d port %d\n", in fst_tx_timeout()
2188 card->card_no, port->index); in fst_tx_timeout()
2199 struct fst_card_info *card; in fst_start_xmit() local
2205 card = port->card; in fst_start_xmit()
2214 "Tried to transmit but no carrier on card %d port %d\n", in fst_start_xmit()
2215 card->card_no, port->index); in fst_start_xmit()
2232 spin_lock_irqsave(&card->card_lock, flags); in fst_start_xmit()
2240 spin_unlock_irqrestore(&card->card_lock, flags); in fst_start_xmit()
2254 dbg(DBG_ASS, "Tx queue overflow card %d port %d\n", in fst_start_xmit()
2255 card->card_no, port->index); in fst_start_xmit()
2261 spin_lock_irqsave(&card->card_lock, flags); in fst_start_xmit()
2266 spin_unlock_irqrestore(&card->card_lock, flags); in fst_start_xmit()
2269 fst_q_work_item(&fst_work_txq, card->card_no); in fst_start_xmit()
2275 /* Card setup having checked hardware resources.
2292 fst_init_card(struct fst_card_info *card) in fst_init_card() argument
2297 /* We're working on a number of ports based on the card ID. If the in fst_init_card()
2301 for (i = 0; i < card->nports; i++) { in fst_init_card()
2302 err = register_hdlc_device(card->ports[i].dev); in fst_init_card()
2307 unregister_hdlc_device(card->ports[i].dev); in fst_init_card()
2313 port_to_dev(&card->ports[0])->name, in fst_init_card()
2314 port_to_dev(&card->ports[card->nports - 1])->name, in fst_init_card()
2315 type_strings[card->type], card->irq, card->nports); in fst_init_card()
2328 /* Initialise card when detected.
2335 struct fst_card_info *card; in fst_add_one() local
2362 card = kzalloc(sizeof(struct fst_card_info), GFP_KERNEL); in fst_add_one()
2363 if (!card) in fst_add_one()
2369 pr_err("Failed to enable card. Err %d\n", -err); in fst_add_one()
2380 card->pci_conf = pci_resource_start(pdev, 1); in fst_add_one()
2381 card->phys_mem = pci_resource_start(pdev, 2); in fst_add_one()
2382 card->phys_ctlmem = pci_resource_start(pdev, 3); in fst_add_one()
2383 card->mem = ioremap(card->phys_mem, FST_MEMSIZE); in fst_add_one()
2384 if (!card->mem) { in fst_add_one()
2389 card->ctlmem = ioremap(card->phys_ctlmem, 0x10); in fst_add_one()
2390 if (!card->ctlmem) { in fst_add_one()
2395 dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem); in fst_add_one()
2398 if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) { in fst_add_one()
2399 pr_err("Unable to register interrupt %d\n", card->irq); in fst_add_one()
2405 card->irq = pdev->irq; in fst_add_one()
2406 card->type = ent->driver_data; in fst_add_one()
2407 card->family = ((ent->driver_data == FST_TYPE_T2P) || in fst_add_one()
2412 card->nports = 1; in fst_add_one()
2414 card->nports = ((ent->driver_data == FST_TYPE_T2P) || in fst_add_one()
2417 card->state = FST_UNINIT; in fst_add_one()
2418 spin_lock_init(&card->card_lock); in fst_add_one()
2420 for (i = 0; i < card->nports; i++) { in fst_add_one()
2421 struct net_device *dev = alloc_hdlcdev(&card->ports[i]); in fst_add_one()
2426 free_netdev(card->ports[i].dev); in fst_add_one()
2431 card->ports[i].dev = dev; in fst_add_one()
2432 card->ports[i].card = card; in fst_add_one()
2433 card->ports[i].index = i; in fst_add_one()
2434 card->ports[i].run = 0; in fst_add_one()
2441 * and basic card I/O. in fst_add_one()
2443 dev->mem_start = card->phys_mem in fst_add_one()
2445 dev->mem_end = card->phys_mem in fst_add_one()
2447 dev->base_addr = card->pci_conf; in fst_add_one()
2448 dev->irq = card->irq; in fst_add_one()
2457 card->device = pdev; in fst_add_one()
2459 dbg(DBG_PCI, "type %d nports %d irq %d\n", card->type, in fst_add_one()
2460 card->nports, card->irq); in fst_add_one()
2462 card->pci_conf, card->phys_mem, card->phys_ctlmem); in fst_add_one()
2464 /* Reset the card's processor */ in fst_add_one()
2465 fst_cpureset(card); in fst_add_one()
2466 card->state = FST_RESET; in fst_add_one()
2469 fst_init_dma(card); in fst_add_one()
2472 pci_set_drvdata(pdev, card); in fst_add_one()
2474 /* Remainder of card setup */ in fst_add_one()
2480 fst_card_array[no_of_cards_added] = card; in fst_add_one()
2481 card->card_no = no_of_cards_added++; /* Record instance and bump it */ in fst_add_one()
2482 err = fst_init_card(card); in fst_add_one()
2485 if (card->family == FST_FAMILY_TXU) { in fst_add_one()
2488 card->rx_dma_handle_host = in fst_add_one()
2489 dma_alloc_coherent(&card->device->dev, FST_MAX_MTU, in fst_add_one()
2490 &card->rx_dma_handle_card, GFP_KERNEL); in fst_add_one()
2491 if (!card->rx_dma_handle_host) { in fst_add_one()
2496 card->tx_dma_handle_host = in fst_add_one()
2497 dma_alloc_coherent(&card->device->dev, FST_MAX_MTU, in fst_add_one()
2498 &card->tx_dma_handle_card, GFP_KERNEL); in fst_add_one()
2499 if (!card->tx_dma_handle_host) { in fst_add_one()
2508 dma_free_coherent(&card->device->dev, FST_MAX_MTU, in fst_add_one()
2509 card->rx_dma_handle_host, card->rx_dma_handle_card); in fst_add_one()
2511 fst_disable_intr(card); in fst_add_one()
2512 for (i = 0 ; i < card->nports ; i++) in fst_add_one()
2513 unregister_hdlc_device(card->ports[i].dev); in fst_add_one()
2515 fst_card_array[card->card_no] = NULL; in fst_add_one()
2517 for (i = 0 ; i < card->nports ; i++) in fst_add_one()
2518 free_netdev(card->ports[i].dev); in fst_add_one()
2520 free_irq(card->irq, card); in fst_add_one()
2522 iounmap(card->ctlmem); in fst_add_one()
2524 iounmap(card->mem); in fst_add_one()
2530 kfree(card); in fst_add_one()
2534 /* Cleanup and close down a card
2539 struct fst_card_info *card; in fst_remove_one() local
2542 card = pci_get_drvdata(pdev); in fst_remove_one()
2544 for (i = 0; i < card->nports; i++) { in fst_remove_one()
2545 struct net_device *dev = port_to_dev(&card->ports[i]); in fst_remove_one()
2551 fst_disable_intr(card); in fst_remove_one()
2552 free_irq(card->irq, card); in fst_remove_one()
2554 iounmap(card->ctlmem); in fst_remove_one()
2555 iounmap(card->mem); in fst_remove_one()
2557 if (card->family == FST_FAMILY_TXU) { in fst_remove_one()
2560 dma_free_coherent(&card->device->dev, FST_MAX_MTU, in fst_remove_one()
2561 card->rx_dma_handle_host, in fst_remove_one()
2562 card->rx_dma_handle_card); in fst_remove_one()
2563 dma_free_coherent(&card->device->dev, FST_MAX_MTU, in fst_remove_one()
2564 card->tx_dma_handle_host, in fst_remove_one()
2565 card->tx_dma_handle_card); in fst_remove_one()
2567 fst_card_array[card->card_no] = NULL; in fst_remove_one()
2568 kfree(card); in fst_remove_one()