Lines Matching full:card

44 /*      Number of ports (per card) and cards supported
54 * of frames on the way down to the card
55 * so that we can keep the card busy
88 /* Card shared memory layout
105 #define FST_MEMSIZE 0x100000 /* Size of card memory (1Mb) */
175 /* Interrupts from the card are caused by various events which are presented
316 /* Number of times the card thinks the host has
425 struct fst_card_info *card; /* Card we're associated with */ member
426 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 */
560 * Interrupt Service routine, we will declare a work queue per Card
567 static void do_bottom_half_tx(struct fst_card_info *card);
568 static void do_bottom_half_rx(struct fst_card_info *card);
593 * a bit for the card indicating that there is work to do in the in fst_q_work_item()
594 * bottom half for the card. Note the limitation of 64 cards. in fst_q_work_item()
619 * Call the bottom half for each card with work waiting in fst_process_tx_work_q()
624 dbg(DBG_TX, "Calling tx bh for card %d\n", i); in fst_process_tx_work_q()
649 * Call the bottom half for each card with work waiting in fst_process_int_work_q()
655 "Calling rx & tx bh for card %d\n", i); in fst_process_int_work_q()
664 /* Card control functions
669 * Used to be a simple write to card control space but a glitch in the latest
675 fst_cpureset(struct fst_card_info *card) in fst_cpureset() argument
680 if (card->family == FST_FAMILY_TXU) { in fst_cpureset()
682 (card->device, PCI_INTERRUPT_LINE, &interrupt_line_register)) { in fst_cpureset()
690 outw(0x440f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
691 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
696 outw(0x240f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
701 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); in fst_cpureset()
704 (card->device, PCI_INTERRUPT_LINE, interrupt_line_register)) { in fst_cpureset()
710 regval = inl(card->pci_conf + CNTRL_9052); in fst_cpureset()
712 outl(regval | 0x40000000, card->pci_conf + CNTRL_9052); in fst_cpureset()
713 outl(regval & ~0x40000000, card->pci_conf + CNTRL_9052); in fst_cpureset()
720 fst_cpurelease(struct fst_card_info *card) in fst_cpurelease() argument
722 if (card->family == FST_FAMILY_TXU) { in fst_cpurelease()
726 (void) readb(card->mem); in fst_cpurelease()
732 outw(0x040e, card->pci_conf + CNTRL_9054 + 2); in fst_cpurelease()
733 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); in fst_cpurelease()
735 (void) readb(card->ctlmem); in fst_cpurelease()
742 fst_clear_intr(struct fst_card_info *card) in fst_clear_intr() argument
744 if (card->family == FST_FAMILY_TXU) { in fst_clear_intr()
745 (void) readb(card->ctlmem); in fst_clear_intr()
749 outw(0x0543, card->pci_conf + INTCSR_9052); in fst_clear_intr()
753 /* Enable card interrupts
756 fst_enable_intr(struct fst_card_info *card) in fst_enable_intr() argument
758 if (card->family == FST_FAMILY_TXU) { in fst_enable_intr()
759 outl(0x0f0c0900, card->pci_conf + INTCSR_9054); in fst_enable_intr()
761 outw(0x0543, card->pci_conf + INTCSR_9052); in fst_enable_intr()
765 /* Disable card interrupts
768 fst_disable_intr(struct fst_card_info *card) in fst_disable_intr() argument
770 if (card->family == FST_FAMILY_TXU) { in fst_disable_intr()
771 outl(0x00000000, card->pci_conf + INTCSR_9054); in fst_disable_intr()
773 outw(0x0000, card->pci_conf + INTCSR_9052); in fst_disable_intr()
801 fst_init_dma(struct fst_card_info *card) in fst_init_dma() argument
806 if (card->family == FST_FAMILY_TXU) { in fst_init_dma()
807 pci_set_master(card->device); in fst_init_dma()
808 outl(0x00020441, card->pci_conf + DMAMODE0); in fst_init_dma()
809 outl(0x00020441, card->pci_conf + DMAMODE1); in fst_init_dma()
810 outl(0x0, card->pci_conf + DMATHR); in fst_init_dma()
817 fst_tx_dma_complete(struct fst_card_info *card, struct fst_port_info *port, in fst_tx_dma_complete() argument
823 * Everything is now set, just tell the card to go in fst_tx_dma_complete()
826 FST_WRB(card, txDescrRing[port->index][txpos].bits, in fst_tx_dma_complete()
847 fst_rx_dma_complete(struct fst_card_info *card, struct fst_port_info *port, in fst_rx_dma_complete() argument
856 skb_put_data(skb, card->rx_dma_handle_host, len); in fst_rx_dma_complete()
859 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_rx_dma_complete()
881 fst_rx_dma(struct fst_card_info *card, dma_addr_t dma, u32 mem, int len) in fst_rx_dma() argument
888 if (card->dmarx_in_progress) { in fst_rx_dma()
892 outl(dma, card->pci_conf + DMAPADR0); /* Copy to here */ in fst_rx_dma()
893 outl(mem, card->pci_conf + DMALADR0); /* from here */ in fst_rx_dma()
894 outl(len, card->pci_conf + DMASIZ0); /* for this length */ in fst_rx_dma()
895 outl(0x00000000c, card->pci_conf + DMADPR0); /* In this direction */ in fst_rx_dma()
900 card->dmarx_in_progress = 1; in fst_rx_dma()
901 outb(0x03, card->pci_conf + DMACSR0); /* Start the transfer */ in fst_rx_dma()
908 fst_tx_dma(struct fst_card_info *card, dma_addr_t dma, u32 mem, int len) in fst_tx_dma() argument
915 if (card->dmatx_in_progress) { in fst_tx_dma()
919 outl(dma, card->pci_conf + DMAPADR1); /* Copy from here */ in fst_tx_dma()
920 outl(mem, card->pci_conf + DMALADR1); /* to here */ in fst_tx_dma()
921 outl(len, card->pci_conf + DMASIZ1); /* for this length */ in fst_tx_dma()
922 outl(0x000000004, card->pci_conf + DMADPR1); /* In this direction */ in fst_tx_dma()
927 card->dmatx_in_progress = 1; in fst_tx_dma()
928 outb(0x03, card->pci_conf + DMACSR1); /* Start the transfer */ in fst_tx_dma()
938 struct fst_card_info *card; in fst_issue_cmd() local
943 card = port->card; in fst_issue_cmd()
944 spin_lock_irqsave(&card->card_lock, flags); in fst_issue_cmd()
945 mbval = FST_RDW(card, portMailbox[port->index][0]); in fst_issue_cmd()
950 spin_unlock_irqrestore(&card->card_lock, flags); in fst_issue_cmd()
952 spin_lock_irqsave(&card->card_lock, flags); in fst_issue_cmd()
959 mbval = FST_RDW(card, portMailbox[port->index][0]); in fst_issue_cmd()
968 FST_WRW(card, portMailbox[port->index][0], cmd); in fst_issue_cmd()
976 spin_unlock_irqrestore(&card->card_lock, flags); in fst_issue_cmd()
984 outputs |= FST_RDL(port->card, v24OpSts[port->index]); in fst_op_raise()
985 FST_WRL(port->card, v24OpSts[port->index], outputs); in fst_op_raise()
994 outputs = ~outputs & FST_RDL(port->card, v24OpSts[port->index]); in fst_op_lower()
995 FST_WRL(port->card, v24OpSts[port->index], outputs); in fst_op_lower()
1011 struct fst_card_info *card; in fst_rx_config() local
1014 card = port->card; in fst_rx_config()
1015 spin_lock_irqsave(&card->card_lock, flags); in fst_rx_config()
1019 FST_WRW(card, rxDescrRing[pi][i].ladr, (u16) offset); in fst_rx_config()
1020 FST_WRB(card, rxDescrRing[pi][i].hadr, (u8) (offset >> 16)); in fst_rx_config()
1021 FST_WRW(card, rxDescrRing[pi][i].bcnt, cnv_bcnt(LEN_RX_BUFFER)); in fst_rx_config()
1022 FST_WRW(card, rxDescrRing[pi][i].mcnt, LEN_RX_BUFFER); in fst_rx_config()
1023 FST_WRB(card, rxDescrRing[pi][i].bits, DMA_OWN); in fst_rx_config()
1026 spin_unlock_irqrestore(&card->card_lock, flags); in fst_rx_config()
1039 struct fst_card_info *card; in fst_tx_config() local
1042 card = port->card; in fst_tx_config()
1043 spin_lock_irqsave(&card->card_lock, flags); in fst_tx_config()
1047 FST_WRW(card, txDescrRing[pi][i].ladr, (u16) offset); in fst_tx_config()
1048 FST_WRB(card, txDescrRing[pi][i].hadr, (u8) (offset >> 16)); in fst_tx_config()
1049 FST_WRW(card, txDescrRing[pi][i].bcnt, 0); in fst_tx_config()
1050 FST_WRB(card, txDescrRing[pi][i].bits, 0); in fst_tx_config()
1055 spin_unlock_irqrestore(&card->card_lock, flags); in fst_tx_config()
1061 fst_intr_te1_alarm(struct fst_card_info *card, struct fst_port_info *port) in fst_intr_te1_alarm() argument
1067 los = FST_RDB(card, suStatus.lossOfSignal); in fst_intr_te1_alarm()
1068 rra = FST_RDB(card, suStatus.receiveRemoteAlarm); in fst_intr_te1_alarm()
1069 ais = FST_RDB(card, suStatus.alarmIndicationSignal); in fst_intr_te1_alarm()
1107 fst_intr_ctlchg(struct fst_card_info *card, struct fst_port_info *port) in fst_intr_ctlchg() argument
1111 signals = FST_RDL(card, v24DebouncedSts[port->index]); in fst_intr_ctlchg()
1130 fst_log_rx_error(struct fst_card_info *card, struct fst_port_info *port, in fst_log_rx_error() argument
1141 dbg(DBG_ASS, "Rx fifo error on card %d port %d buffer %d\n", in fst_log_rx_error()
1142 card->card_no, port->index, rxp); in fst_log_rx_error()
1146 dbg(DBG_ASS, "Rx crc error on card %d port %d\n", in fst_log_rx_error()
1147 card->card_no, port->index); in fst_log_rx_error()
1151 dbg(DBG_ASS, "Rx frame error on card %d port %d\n", in fst_log_rx_error()
1152 card->card_no, port->index); in fst_log_rx_error()
1156 dbg(DBG_ASS, "Rx length error (%d) on card %d port %d\n", in fst_log_rx_error()
1157 len, card->card_no, port->index); in fst_log_rx_error()
1164 fst_recover_rx_error(struct fst_card_info *card, struct fst_port_info *port, in fst_recover_rx_error() argument
1178 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_recover_rx_error()
1185 dmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits); in fst_recover_rx_error()
1192 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_recover_rx_error()
1203 fst_intr_rx(struct fst_card_info *card, struct fst_port_info *port) in fst_intr_rx() argument
1216 dmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits); in fst_intr_rx()
1222 if (card->dmarx_in_progress) { in fst_intr_rx()
1227 len = FST_RDW(card, rxDescrRing[pi][rxp].mcnt); in fst_intr_rx()
1235 pr_err("Frame received with 0 length. Card %d Port %d\n", in fst_intr_rx()
1236 card->card_no, port->index); in fst_intr_rx()
1237 /* Return descriptor to card */ in fst_intr_rx()
1238 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_intr_rx()
1251 fst_log_rx_error(card, port, dmabits, rxp, len); in fst_intr_rx()
1252 fst_recover_rx_error(card, port, dmabits, rxp, len); in fst_intr_rx()
1262 /* Return descriptor to card */ in fst_intr_rx()
1263 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_intr_rx()
1276 if ((len < FST_MIN_DMA_LEN) || (card->family == FST_FAMILY_TXP)) { in fst_intr_rx()
1278 card->mem + BUF_OFFSET(rxBuffer[pi][rxp][0]), in fst_intr_rx()
1282 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); in fst_intr_rx()
1299 card->dma_skb_rx = skb; in fst_intr_rx()
1300 card->dma_port_rx = port; in fst_intr_rx()
1301 card->dma_len_rx = len; in fst_intr_rx()
1302 card->dma_rxpos = rxp; in fst_intr_rx()
1303 fst_rx_dma(card, card->rx_dma_handle_card, in fst_intr_rx()
1320 do_bottom_half_tx(struct fst_card_info *card) in do_bottom_half_tx() argument
1331 * Step through each port on this card in do_bottom_half_tx()
1335 for (pi = 0, port = card->ports; pi < card->nports; pi++, port++) { in do_bottom_half_tx()
1340 while (!(FST_RDB(card, txDescrRing[pi][port->txpos].bits) & in do_bottom_half_tx()
1342 !(card->dmatx_in_progress)) { in do_bottom_half_tx()
1348 spin_lock_irqsave(&card->card_lock, flags); in do_bottom_half_tx()
1356 spin_unlock_irqrestore(&card->card_lock, flags); in do_bottom_half_tx()
1361 spin_lock_irqsave(&card->card_lock, flags); in do_bottom_half_tx()
1367 spin_unlock_irqrestore(&card->card_lock, flags); in do_bottom_half_tx()
1370 * card. in do_bottom_half_tx()
1372 FST_WRW(card, txDescrRing[pi][port->txpos].bcnt, in do_bottom_half_tx()
1375 (card->family == FST_FAMILY_TXP)) { in do_bottom_half_tx()
1377 memcpy_toio(card->mem + in do_bottom_half_tx()
1382 FST_WRB(card, in do_bottom_half_tx()
1391 memcpy(card->tx_dma_handle_host, in do_bottom_half_tx()
1393 card->dma_port_tx = port; in do_bottom_half_tx()
1394 card->dma_len_tx = skb->len; in do_bottom_half_tx()
1395 card->dma_txpos = port->txpos; in do_bottom_half_tx()
1396 fst_tx_dma(card, in do_bottom_half_tx()
1397 card->tx_dma_handle_card, in do_bottom_half_tx()
1426 do_bottom_half_rx(struct fst_card_info *card) in do_bottom_half_rx() argument
1432 /* Check for rx completions on all ports on this card */ in do_bottom_half_rx()
1434 for (pi = 0, port = card->ports; pi < card->nports; pi++, port++) { in do_bottom_half_rx()
1438 while (!(FST_RDB(card, rxDescrRing[pi][port->rxpos].bits) in do_bottom_half_rx()
1439 & DMA_OWN) && !(card->dmarx_in_progress)) { in do_bottom_half_rx()
1445 fst_q_work_item(&fst_work_intq, card->card_no); in do_bottom_half_rx()
1449 fst_intr_rx(card, port); in do_bottom_half_rx()
1462 struct fst_card_info *card = dev_id; in fst_intr() local
1472 * Check to see if the interrupt was for this card in fst_intr()
1476 dbg(DBG_INTR, "intr: %d %p\n", card->irq, card); in fst_intr()
1477 if (card->state != FST_RUNNING) { in fst_intr()
1478 pr_err("Interrupt received for card %d in a non running state (%d)\n", in fst_intr()
1479 card->card_no, card->state); in fst_intr()
1483 * a running card in fst_intr()
1486 fst_clear_intr(card); in fst_intr()
1491 fst_clear_intr(card); in fst_intr()
1494 * Is the interrupt for this card (handshake == 1) in fst_intr()
1497 if (FST_RDB(card, interruptHandshake) == 1) { in fst_intr()
1500 FST_WRB(card, interruptHandshake, 0xEE); in fst_intr()
1502 if (card->family == FST_FAMILY_TXU) { in fst_intr()
1506 dma_intcsr = inl(card->pci_conf + INTCSR_9054); in fst_intr()
1512 outb(0x8, card->pci_conf + DMACSR0); in fst_intr()
1513 fst_rx_dma_complete(card, card->dma_port_rx, in fst_intr()
1514 card->dma_len_rx, card->dma_skb_rx, in fst_intr()
1515 card->dma_rxpos); in fst_intr()
1516 card->dmarx_in_progress = 0; in fst_intr()
1524 outb(0x8, card->pci_conf + DMACSR1); in fst_intr()
1525 fst_tx_dma_complete(card, card->dma_port_tx, in fst_intr()
1526 card->dma_len_tx, card->dma_txpos); in fst_intr()
1527 card->dmatx_in_progress = 0; in fst_intr()
1535 int_retry_count = FST_RDL(card, interruptRetryCount); in fst_intr()
1537 dbg(DBG_ASS, "Card %d int_retry_count is %d\n", in fst_intr()
1538 card->card_no, int_retry_count); in fst_intr()
1539 FST_WRL(card, interruptRetryCount, 0); in fst_intr()
1547 fst_q_work_item(&fst_work_intq, card->card_no); in fst_intr()
1551 rdidx = FST_RDB(card, interruptEvent.rdindex) & 0x1f; in fst_intr()
1552 wridx = FST_RDB(card, interruptEvent.wrindex) & 0x1f; in fst_intr()
1554 event = FST_RDB(card, interruptEvent.evntbuff[rdidx]); in fst_intr()
1555 port = &card->ports[event & 0x03]; in fst_intr()
1563 fst_intr_te1_alarm(card, port); in fst_intr()
1571 fst_intr_ctlchg(card, port); in fst_intr()
1591 dbg(DBG_ASS, "Tx underflow on card %d port %d\n", in fst_intr()
1592 card->card_no, port->index); in fst_intr()
1596 dbg(DBG_INIT, "Card init OK intr\n"); in fst_intr()
1600 dbg(DBG_INIT, "Card init FAILED intr\n"); in fst_intr()
1601 card->state = FST_IFAILED; in fst_intr()
1605 pr_err("intr: unknown card event %d. ignored\n", event); in fst_intr()
1613 FST_WRB(card, interruptEvent.rdindex, rdidx); in fst_intr()
1621 check_started_ok(struct fst_card_info *card) in check_started_ok() argument
1626 if (FST_RDW(card, smcVersion) != SMC_VERSION) { in check_started_ok()
1628 FST_RDW(card, smcVersion), SMC_VERSION); in check_started_ok()
1629 card->state = FST_BADVERSION; in check_started_ok()
1632 if (FST_RDL(card, endOfSmcSignature) != END_SIG) { in check_started_ok()
1634 card->state = FST_BADVERSION; in check_started_ok()
1638 if ((i = FST_RDB(card, taskStatus)) == 0x01) { in check_started_ok()
1639 card->state = FST_RUNNING; in check_started_ok()
1641 pr_err("Firmware initialisation failed. Card halted\n"); in check_started_ok()
1642 card->state = FST_HALTED; in check_started_ok()
1646 card->state = FST_HALTED; in check_started_ok()
1651 * number we assumed at card detection. Should never happen with in check_started_ok()
1654 if (FST_RDL(card, numberOfPorts) != card->nports) { in check_started_ok()
1655 pr_warn("Port count mismatch on card %d. Firmware thinks %d we say %d\n", in check_started_ok()
1656 card->card_no, in check_started_ok()
1657 FST_RDL(card, numberOfPorts), card->nports); in check_started_ok()
1662 set_conf_from_info(struct fst_card_info *card, struct fst_port_info *port, in set_conf_from_info() argument
1687 FST_WRB(card, portConfig[port->index].invertClock, in set_conf_from_info()
1690 FST_WRW(card, cardMode, info->cardMode); in set_conf_from_info()
1692 FST_WRL(card, suConfig.dataRate, info->lineSpeed); in set_conf_from_info()
1693 FST_WRB(card, suConfig.clocking, info->clockSource); in set_conf_from_info()
1701 FST_WRB(card, suConfig.framing, my_framing); in set_conf_from_info()
1702 FST_WRB(card, suConfig.structure, info->structure); in set_conf_from_info()
1703 FST_WRB(card, suConfig.interface, info->interface); in set_conf_from_info()
1704 FST_WRB(card, suConfig.coding, info->coding); in set_conf_from_info()
1705 FST_WRB(card, suConfig.lineBuildOut, info->lineBuildOut); in set_conf_from_info()
1706 FST_WRB(card, suConfig.equalizer, info->equalizer); in set_conf_from_info()
1707 FST_WRB(card, suConfig.transparentMode, info->transparentMode); in set_conf_from_info()
1708 FST_WRB(card, suConfig.loopMode, info->loopMode); in set_conf_from_info()
1709 FST_WRB(card, suConfig.range, info->range); in set_conf_from_info()
1710 FST_WRB(card, suConfig.txBufferMode, info->txBufferMode); in set_conf_from_info()
1711 FST_WRB(card, suConfig.rxBufferMode, info->rxBufferMode); in set_conf_from_info()
1712 FST_WRB(card, suConfig.startingSlot, info->startingSlot); in set_conf_from_info()
1713 FST_WRB(card, suConfig.losThreshold, info->losThreshold); in set_conf_from_info()
1715 FST_WRB(card, suConfig.enableIdleCode, 1); in set_conf_from_info()
1717 FST_WRB(card, suConfig.enableIdleCode, 0); in set_conf_from_info()
1718 FST_WRB(card, suConfig.idleCode, info->idleCode); in set_conf_from_info()
1752 gather_conf_info(struct fst_card_info *card, struct fst_port_info *port, in gather_conf_info() argument
1761 info->nports = card->nports; in gather_conf_info()
1762 info->type = card->type; in gather_conf_info()
1763 info->state = card->state; in gather_conf_info()
1770 /* Only mark information as valid if card is running. in gather_conf_info()
1773 info->valid = ((card->state == FST_RUNNING) ? FSTVAL_ALL : FSTVAL_CARD) in gather_conf_info()
1779 info->lineInterface = FST_RDW(card, portConfig[i].lineInterface); in gather_conf_info()
1780 info->internalClock = FST_RDB(card, portConfig[i].internalClock); in gather_conf_info()
1781 info->lineSpeed = FST_RDL(card, portConfig[i].lineSpeed); in gather_conf_info()
1782 info->invertClock = FST_RDB(card, portConfig[i].invertClock); in gather_conf_info()
1783 info->v24IpSts = FST_RDL(card, v24IpSts[i]); in gather_conf_info()
1784 info->v24OpSts = FST_RDL(card, v24OpSts[i]); in gather_conf_info()
1785 info->clockStatus = FST_RDW(card, clockStatus[i]); in gather_conf_info()
1786 info->cableStatus = FST_RDW(card, cableStatus); in gather_conf_info()
1787 info->cardMode = FST_RDW(card, cardMode); in gather_conf_info()
1788 info->smcFirmwareVersion = FST_RDL(card, smcFirmwareVersion); in gather_conf_info()
1795 if (card->family == FST_FAMILY_TXU) { in gather_conf_info()
1812 if (card->type == FST_TYPE_TE1) { in gather_conf_info()
1813 info->lineSpeed = FST_RDL(card, suConfig.dataRate); in gather_conf_info()
1814 info->clockSource = FST_RDB(card, suConfig.clocking); in gather_conf_info()
1815 info->framing = FST_RDB(card, suConfig.framing); in gather_conf_info()
1816 info->structure = FST_RDB(card, suConfig.structure); in gather_conf_info()
1817 info->interface = FST_RDB(card, suConfig.interface); in gather_conf_info()
1818 info->coding = FST_RDB(card, suConfig.coding); in gather_conf_info()
1819 info->lineBuildOut = FST_RDB(card, suConfig.lineBuildOut); in gather_conf_info()
1820 info->equalizer = FST_RDB(card, suConfig.equalizer); in gather_conf_info()
1821 info->loopMode = FST_RDB(card, suConfig.loopMode); in gather_conf_info()
1822 info->range = FST_RDB(card, suConfig.range); in gather_conf_info()
1823 info->txBufferMode = FST_RDB(card, suConfig.txBufferMode); in gather_conf_info()
1824 info->rxBufferMode = FST_RDB(card, suConfig.rxBufferMode); in gather_conf_info()
1825 info->startingSlot = FST_RDB(card, suConfig.startingSlot); in gather_conf_info()
1826 info->losThreshold = FST_RDB(card, suConfig.losThreshold); in gather_conf_info()
1827 if (FST_RDB(card, suConfig.enableIdleCode)) in gather_conf_info()
1828 info->idleCode = FST_RDB(card, suConfig.idleCode); in gather_conf_info()
1832 FST_RDL(card, suStatus.receiveBufferDelay); in gather_conf_info()
1834 FST_RDL(card, suStatus.framingErrorCount); in gather_conf_info()
1836 FST_RDL(card, suStatus.codeViolationCount); in gather_conf_info()
1837 info->crcErrorCount = FST_RDL(card, suStatus.crcErrorCount); in gather_conf_info()
1838 info->lineAttenuation = FST_RDL(card, suStatus.lineAttenuation); in gather_conf_info()
1839 info->lossOfSignal = FST_RDB(card, suStatus.lossOfSignal); in gather_conf_info()
1841 FST_RDB(card, suStatus.receiveRemoteAlarm); in gather_conf_info()
1843 FST_RDB(card, suStatus.alarmIndicationSignal); in gather_conf_info()
1848 fst_set_iface(struct fst_card_info *card, struct fst_port_info *port, in fst_set_iface() argument
1870 FST_WRW(card, portConfig[i].lineInterface, V35); in fst_set_iface()
1875 FST_WRW(card, portConfig[i].lineInterface, V24); in fst_set_iface()
1880 FST_WRW(card, portConfig[i].lineInterface, X21); in fst_set_iface()
1885 FST_WRW(card, portConfig[i].lineInterface, X21D); in fst_set_iface()
1890 FST_WRW(card, portConfig[i].lineInterface, T1); in fst_set_iface()
1895 FST_WRW(card, portConfig[i].lineInterface, E1); in fst_set_iface()
1908 FST_WRB(card, portConfig[i].internalClock, EXTCLK); in fst_set_iface()
1912 FST_WRB(card, portConfig[i].internalClock, INTCLK); in fst_set_iface()
1918 FST_WRL(card, portConfig[i].lineSpeed, sync.clock_rate); in fst_set_iface()
1923 fst_get_iface(struct fst_card_info *card, struct fst_port_info *port, in fst_get_iface() argument
1963 sync.clock_rate = FST_RDL(card, portConfig[i].lineSpeed); in fst_get_iface()
1964 /* Lucky card and linux use same encoding here */ in fst_get_iface()
1965 sync.clock_type = FST_RDB(card, portConfig[i].internalClock) == in fst_get_iface()
1980 struct fst_card_info *card; in fst_ioctl() local
1990 card = port->card; in fst_ioctl()
1997 fst_cpureset(card); in fst_ioctl()
1998 card->state = FST_RESET; in fst_ioctl()
2002 fst_cpurelease(card); in fst_ioctl()
2003 card->state = FST_STARTING; in fst_ioctl()
2027 /* Now copy the data to the card. */ in fst_ioctl()
2034 memcpy_toio(card->mem + wrthdr.offset, buf, wrthdr.size); in fst_ioctl()
2037 /* Writes to the memory of a card in the reset state constitute in fst_ioctl()
2040 if (card->state == FST_RESET) { in fst_ioctl()
2041 card->state = FST_DOWNLOAD; in fst_ioctl()
2047 /* If card has just been started check the shared memory config in fst_ioctl()
2050 if (card->state == FST_STARTING) { in fst_ioctl()
2051 check_started_ok(card); in fst_ioctl()
2053 /* If everything checked out enable card interrupts */ in fst_ioctl()
2054 if (card->state == FST_RUNNING) { in fst_ioctl()
2055 spin_lock_irqsave(&card->card_lock, flags); in fst_ioctl()
2056 fst_enable_intr(card); in fst_ioctl()
2057 FST_WRB(card, interruptHandshake, 0xEE); in fst_ioctl()
2058 spin_unlock_irqrestore(&card->card_lock, flags); in fst_ioctl()
2066 gather_conf_info(card, port, &info); in fst_ioctl()
2080 if (card->state != FST_RUNNING) { in fst_ioctl()
2081 pr_err("Attempt to configure card %d in non-running state (%d)\n", in fst_ioctl()
2082 card->card_no, card->state); in fst_ioctl()
2089 return set_conf_from_info(card, port, &info); in fst_ioctl()
2094 return fst_get_iface(card, port, ifr); in fst_ioctl()
2103 return fst_set_iface(card, port, ifr); in fst_ioctl()
2134 /* Only init things if card is actually running. This allows open to in fst_openport()
2137 if (port->card->state == FST_RUNNING) { in fst_openport()
2152 signals = FST_RDL(port->card, v24DebouncedSts[port->index]); in fst_openport()
2168 if (port->card->state == FST_RUNNING) { in fst_closeport()
2207 struct fst_card_info *card; in fst_close() local
2212 card = port->card; in fst_close()
2214 tx_dma_done = inb(card->pci_conf + DMACSR1); in fst_close()
2215 rx_dma_done = inb(card->pci_conf + DMACSR0); in fst_close()
2218 card->dmatx_in_progress, tx_dma_done, card->dmarx_in_progress, in fst_close()
2234 * Setting currently fixed in FarSync card so we check and forget in fst_attach()
2245 struct fst_card_info *card; in fst_tx_timeout() local
2248 card = port->card; in fst_tx_timeout()
2251 dbg(DBG_ASS, "Tx timeout card %d port %d\n", in fst_tx_timeout()
2252 card->card_no, port->index); in fst_tx_timeout()
2263 struct fst_card_info *card; in fst_start_xmit() local
2269 card = port->card; in fst_start_xmit()
2278 "Tried to transmit but no carrier on card %d port %d\n", in fst_start_xmit()
2279 card->card_no, port->index); in fst_start_xmit()
2297 spin_lock_irqsave(&card->card_lock, flags); in fst_start_xmit()
2305 spin_unlock_irqrestore(&card->card_lock, flags); in fst_start_xmit()
2321 dbg(DBG_ASS, "Tx queue overflow card %d port %d\n", in fst_start_xmit()
2322 card->card_no, port->index); in fst_start_xmit()
2329 spin_lock_irqsave(&card->card_lock, flags); in fst_start_xmit()
2334 spin_unlock_irqrestore(&card->card_lock, flags); in fst_start_xmit()
2337 fst_q_work_item(&fst_work_txq, card->card_no); in fst_start_xmit()
2344 * Card setup having checked hardware resources.
2361 fst_init_card(struct fst_card_info *card) in fst_init_card() argument
2366 /* We're working on a number of ports based on the card ID. If the in fst_init_card()
2370 for (i = 0; i < card->nports; i++) { in fst_init_card()
2371 err = register_hdlc_device(card->ports[i].dev); in fst_init_card()
2376 unregister_hdlc_device(card->ports[i].dev); in fst_init_card()
2382 port_to_dev(&card->ports[0])->name, in fst_init_card()
2383 port_to_dev(&card->ports[card->nports - 1])->name, in fst_init_card()
2384 type_strings[card->type], card->irq, card->nports); in fst_init_card()
2397 * Initialise card when detected.
2404 struct fst_card_info *card; in fst_add_one() local
2433 card = kzalloc(sizeof(struct fst_card_info), GFP_KERNEL); in fst_add_one()
2434 if (card == NULL) in fst_add_one()
2439 pr_err("Failed to enable card. Err %d\n", -err); in fst_add_one()
2449 card->pci_conf = pci_resource_start(pdev, 1); in fst_add_one()
2450 card->phys_mem = pci_resource_start(pdev, 2); in fst_add_one()
2451 card->phys_ctlmem = pci_resource_start(pdev, 3); in fst_add_one()
2452 if ((card->mem = ioremap(card->phys_mem, FST_MEMSIZE)) == NULL) { in fst_add_one()
2457 if ((card->ctlmem = ioremap(card->phys_ctlmem, 0x10)) == NULL) { in fst_add_one()
2462 dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem); in fst_add_one()
2465 if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) { in fst_add_one()
2466 pr_err("Unable to register interrupt %d\n", card->irq); in fst_add_one()
2472 card->irq = pdev->irq; in fst_add_one()
2473 card->type = ent->driver_data; in fst_add_one()
2474 card->family = ((ent->driver_data == FST_TYPE_T2P) || in fst_add_one()
2479 card->nports = 1; in fst_add_one()
2481 card->nports = ((ent->driver_data == FST_TYPE_T2P) || in fst_add_one()
2484 card->state = FST_UNINIT; in fst_add_one()
2485 spin_lock_init ( &card->card_lock ); in fst_add_one()
2487 for ( i = 0 ; i < card->nports ; i++ ) { in fst_add_one()
2488 struct net_device *dev = alloc_hdlcdev(&card->ports[i]); in fst_add_one()
2492 free_netdev(card->ports[i].dev); in fst_add_one()
2497 card->ports[i].dev = dev; in fst_add_one()
2498 card->ports[i].card = card; in fst_add_one()
2499 card->ports[i].index = i; in fst_add_one()
2500 card->ports[i].run = 0; in fst_add_one()
2507 * and basic card I/O. in fst_add_one()
2509 dev->mem_start = card->phys_mem in fst_add_one()
2511 dev->mem_end = card->phys_mem in fst_add_one()
2513 dev->base_addr = card->pci_conf; in fst_add_one()
2514 dev->irq = card->irq; in fst_add_one()
2523 card->device = pdev; in fst_add_one()
2525 dbg(DBG_PCI, "type %d nports %d irq %d\n", card->type, in fst_add_one()
2526 card->nports, card->irq); in fst_add_one()
2528 card->pci_conf, card->phys_mem, card->phys_ctlmem); in fst_add_one()
2530 /* Reset the card's processor */ in fst_add_one()
2531 fst_cpureset(card); in fst_add_one()
2532 card->state = FST_RESET; in fst_add_one()
2535 fst_init_dma(card); in fst_add_one()
2538 pci_set_drvdata(pdev, card); in fst_add_one()
2540 /* Remainder of card setup */ in fst_add_one()
2546 fst_card_array[no_of_cards_added] = card; in fst_add_one()
2547 card->card_no = no_of_cards_added++; /* Record instance and bump it */ in fst_add_one()
2548 err = fst_init_card(card); in fst_add_one()
2551 if (card->family == FST_FAMILY_TXU) { in fst_add_one()
2555 card->rx_dma_handle_host = in fst_add_one()
2556 dma_alloc_coherent(&card->device->dev, FST_MAX_MTU, in fst_add_one()
2557 &card->rx_dma_handle_card, GFP_KERNEL); in fst_add_one()
2558 if (card->rx_dma_handle_host == NULL) { in fst_add_one()
2563 card->tx_dma_handle_host = in fst_add_one()
2564 dma_alloc_coherent(&card->device->dev, FST_MAX_MTU, in fst_add_one()
2565 &card->tx_dma_handle_card, GFP_KERNEL); in fst_add_one()
2566 if (card->tx_dma_handle_host == NULL) { in fst_add_one()
2575 dma_free_coherent(&card->device->dev, FST_MAX_MTU, in fst_add_one()
2576 card->rx_dma_handle_host, card->rx_dma_handle_card); in fst_add_one()
2578 fst_disable_intr(card); in fst_add_one()
2579 for (i = 0 ; i < card->nports ; i++) in fst_add_one()
2580 unregister_hdlc_device(card->ports[i].dev); in fst_add_one()
2582 fst_card_array[card->card_no] = NULL; in fst_add_one()
2584 for (i = 0 ; i < card->nports ; i++) in fst_add_one()
2585 free_netdev(card->ports[i].dev); in fst_add_one()
2587 free_irq(card->irq, card); in fst_add_one()
2589 iounmap(card->ctlmem); in fst_add_one()
2591 iounmap(card->mem); in fst_add_one()
2597 kfree(card); in fst_add_one()
2602 * Cleanup and close down a card
2607 struct fst_card_info *card; in fst_remove_one() local
2610 card = pci_get_drvdata(pdev); in fst_remove_one()
2612 for (i = 0; i < card->nports; i++) { in fst_remove_one()
2613 struct net_device *dev = port_to_dev(&card->ports[i]); in fst_remove_one()
2617 fst_disable_intr(card); in fst_remove_one()
2618 free_irq(card->irq, card); in fst_remove_one()
2620 iounmap(card->ctlmem); in fst_remove_one()
2621 iounmap(card->mem); in fst_remove_one()
2623 if (card->family == FST_FAMILY_TXU) { in fst_remove_one()
2627 dma_free_coherent(&card->device->dev, FST_MAX_MTU, in fst_remove_one()
2628 card->rx_dma_handle_host, in fst_remove_one()
2629 card->rx_dma_handle_card); in fst_remove_one()
2630 dma_free_coherent(&card->device->dev, FST_MAX_MTU, in fst_remove_one()
2631 card->tx_dma_handle_host, in fst_remove_one()
2632 card->tx_dma_handle_card); in fst_remove_one()
2634 fst_card_array[card->card_no] = NULL; in fst_remove_one()