• Home
  • Raw
  • Download

Lines Matching refs:card

161 waitfor_idle(struct idt77252_dev *card)  in waitfor_idle()  argument
171 read_sram(struct idt77252_dev *card, unsigned long addr) in read_sram() argument
176 spin_lock_irqsave(&card->cmd_lock, flags); in read_sram()
178 waitfor_idle(card); in read_sram()
180 spin_unlock_irqrestore(&card->cmd_lock, flags); in read_sram()
185 write_sram(struct idt77252_dev *card, unsigned long addr, u32 value) in write_sram() argument
190 (((addr > card->tst[0] + card->tst_size - 2) && in write_sram()
191 (addr < card->tst[0] + card->tst_size)) || in write_sram()
192 ((addr > card->tst[1] + card->tst_size - 2) && in write_sram()
193 (addr < card->tst[1] + card->tst_size)))) { in write_sram()
195 card->name, addr, value); in write_sram()
198 spin_lock_irqsave(&card->cmd_lock, flags); in write_sram()
201 waitfor_idle(card); in write_sram()
202 spin_unlock_irqrestore(&card->cmd_lock, flags); in write_sram()
208 struct idt77252_dev *card = dev; in read_utility() local
212 if (!card) { in read_utility()
217 spin_lock_irqsave(&card->cmd_lock, flags); in read_utility()
219 waitfor_idle(card); in read_utility()
221 spin_unlock_irqrestore(&card->cmd_lock, flags); in read_utility()
228 struct idt77252_dev *card = dev; in write_utility() local
231 if (!card) { in write_utility()
236 spin_lock_irqsave(&card->cmd_lock, flags); in write_utility()
239 waitfor_idle(card); in write_utility()
240 spin_unlock_irqrestore(&card->cmd_lock, flags); in write_utility()
350 idt77252_read_gp(struct idt77252_dev *card) in idt77252_read_gp() argument
362 idt77252_write_gp(struct idt77252_dev *card, u32 value) in idt77252_write_gp() argument
372 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_write_gp()
373 waitfor_idle(card); in idt77252_write_gp()
375 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_write_gp()
379 idt77252_eeprom_read_status(struct idt77252_dev *card) in idt77252_eeprom_read_status() argument
385 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); in idt77252_eeprom_read_status()
388 idt77252_write_gp(card, gp | rdsrtab[i]); in idt77252_eeprom_read_status()
391 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_status()
398 idt77252_write_gp(card, gp | clktab[j++]); in idt77252_eeprom_read_status()
401 byte |= idt77252_read_gp(card) & SAR_GP_EEDI ? 1 : 0; in idt77252_eeprom_read_status()
403 idt77252_write_gp(card, gp | clktab[j++]); in idt77252_eeprom_read_status()
406 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_status()
413 idt77252_eeprom_read_byte(struct idt77252_dev *card, u8 offset) in idt77252_eeprom_read_byte() argument
419 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); in idt77252_eeprom_read_byte()
422 idt77252_write_gp(card, gp | rdtab[i]); in idt77252_eeprom_read_byte()
425 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_byte()
429 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_read_byte()
433 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_read_byte()
439 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_byte()
446 idt77252_write_gp(card, gp | clktab[j++]); in idt77252_eeprom_read_byte()
449 byte |= idt77252_read_gp(card) & SAR_GP_EEDI ? 1 : 0; in idt77252_eeprom_read_byte()
451 idt77252_write_gp(card, gp | clktab[j++]); in idt77252_eeprom_read_byte()
454 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_read_byte()
461 idt77252_eeprom_write_byte(struct idt77252_dev *card, u8 offset, u8 data) in idt77252_eeprom_write_byte() argument
466 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); in idt77252_eeprom_write_byte()
469 idt77252_write_gp(card, gp | wrentab[i]); in idt77252_eeprom_write_byte()
472 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_write_byte()
476 idt77252_write_gp(card, gp | wrtab[i]); in idt77252_eeprom_write_byte()
479 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_write_byte()
483 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_write_byte()
487 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_write_byte()
493 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_write_byte()
497 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_write_byte()
501 idt77252_write_gp(card, gp | clktab[j++] | in idt77252_eeprom_write_byte()
507 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_write_byte()
512 idt77252_eeprom_init(struct idt77252_dev *card) in idt77252_eeprom_init() argument
516 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); in idt77252_eeprom_init()
518 idt77252_write_gp(card, gp | SAR_GP_EECS | SAR_GP_EESCLK); in idt77252_eeprom_init()
520 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_init()
522 idt77252_write_gp(card, gp | SAR_GP_EECS | SAR_GP_EESCLK); in idt77252_eeprom_init()
524 idt77252_write_gp(card, gp | SAR_GP_EECS); in idt77252_eeprom_init()
532 dump_tct(struct idt77252_dev *card, int index) in dump_tct() argument
537 tct = (unsigned long) (card->tct_base + index * SAR_SRAM_TCT_SIZE); in dump_tct()
539 printk("%s: TCT %x:", card->name, index); in dump_tct()
541 printk(" %08x", read_sram(card, tct + i)); in dump_tct()
547 idt77252_tx_dump(struct idt77252_dev *card) in idt77252_tx_dump() argument
554 for (i = 0; i < card->tct_size; i++) { in idt77252_tx_dump()
555 vc = card->vcs[i]; in idt77252_tx_dump()
568 printk("%s: Connection %d:\n", card->name, vc->index); in idt77252_tx_dump()
569 dump_tct(card, vc->index); in idt77252_tx_dump()
582 sb_pool_add(struct idt77252_dev *card, struct sk_buff *skb, int queue) in sb_pool_add() argument
584 struct sb_pool *pool = &card->sbpool[queue]; in sb_pool_add()
602 sb_pool_remove(struct idt77252_dev *card, struct sk_buff *skb) in sb_pool_remove() argument
617 card->sbpool[queue].skb[index] = NULL; in sb_pool_remove()
621 sb_pool_skb(struct idt77252_dev *card, u32 handle) in sb_pool_skb() argument
633 return card->sbpool[queue].skb[index]; in sb_pool_skb()
637 alloc_scq(struct idt77252_dev *card, int class) in alloc_scq() argument
644 scq->base = dma_alloc_coherent(&card->pcidev->dev, SCQ_SIZE, in alloc_scq()
668 free_scq(struct idt77252_dev *card, struct scq_info *scq) in free_scq() argument
673 dma_free_coherent(&card->pcidev->dev, SCQ_SIZE, in free_scq()
677 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in free_scq()
688 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in free_scq()
703 push_on_scq(struct idt77252_dev *card, struct vc_map *vc, struct sk_buff *skb) in push_on_scq() argument
710 TXPRINTK("%s: SCQ: next 0x%p\n", card->name, scq->next); in push_on_scq()
756 write_sram(card, scq->scd, in push_on_scq()
771 card->name, atomic_read(&scq->used), in push_on_scq()
772 read_sram(card, scq->scd + 1), scq->next); in push_on_scq()
779 card->name, vc->tx_vcc->vpi, vc->tx_vcc->vci); in push_on_scq()
781 idt77252_tx_dump(card); in push_on_scq()
791 drain_scq(struct idt77252_dev *card, struct vc_map *vc) in drain_scq() argument
798 card->name, atomic_read(&scq->used), scq->next); in drain_scq()
802 TXPRINTK("%s: freeing skb at %p.\n", card->name, skb); in drain_scq()
804 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in drain_scq()
821 if (push_on_scq(card, vc, skb)) { in drain_scq()
830 queue_skb(struct idt77252_dev *card, struct vc_map *vc, in queue_skb() argument
841 printk("%s: invalid skb->len (%d)\n", card->name, skb->len); in queue_skb()
846 card->name, skb->len); in queue_skb()
853 IDT77252_PRV_PADDR(skb) = dma_map_single(&card->pcidev->dev, skb->data, in queue_skb()
868 vc = card->vcs[0]; in queue_skb()
874 printk("%s: Trying to transmit on reserved VC\n", card->name); in queue_skb()
909 printk("%s: Traffic type not supported.\n", card->name); in queue_skb()
919 if (push_on_scq(card, vc, skb)) { in queue_skb()
929 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in queue_skb()
935 get_free_scd(struct idt77252_dev *card, struct vc_map *vc) in get_free_scd() argument
939 for (i = 0; i < card->scd_size; i++) { in get_free_scd()
940 if (!card->scd2vc[i]) { in get_free_scd()
941 card->scd2vc[i] = vc; in get_free_scd()
943 return card->scd_base + i * SAR_SRAM_SCD_SIZE; in get_free_scd()
950 fill_scd(struct idt77252_dev *card, struct scq_info *scq, int class) in fill_scd() argument
952 write_sram(card, scq->scd, scq->paddr); in fill_scd()
953 write_sram(card, scq->scd + 1, 0x00000000); in fill_scd()
954 write_sram(card, scq->scd + 2, 0xffffffff); in fill_scd()
955 write_sram(card, scq->scd + 3, 0x00000000); in fill_scd()
959 clear_scd(struct idt77252_dev *card, struct scq_info *scq, int class) in clear_scd() argument
971 init_rsq(struct idt77252_dev *card) in init_rsq() argument
975 card->rsq.base = dma_alloc_coherent(&card->pcidev->dev, RSQSIZE, in init_rsq()
976 &card->rsq.paddr, GFP_KERNEL); in init_rsq()
977 if (card->rsq.base == NULL) { in init_rsq()
978 printk("%s: can't allocate RSQ.\n", card->name); in init_rsq()
982 card->rsq.last = card->rsq.base + RSQ_NUM_ENTRIES - 1; in init_rsq()
983 card->rsq.next = card->rsq.last; in init_rsq()
984 for (rsqe = card->rsq.base; rsqe <= card->rsq.last; rsqe++) in init_rsq()
987 writel((unsigned long) card->rsq.last - (unsigned long) card->rsq.base, in init_rsq()
989 writel(card->rsq.paddr, SAR_REG_RSQB); in init_rsq()
991 IPRINTK("%s: RSQ base at 0x%lx (0x%x).\n", card->name, in init_rsq()
992 (unsigned long) card->rsq.base, in init_rsq()
995 card->name, in init_rsq()
1004 deinit_rsq(struct idt77252_dev *card) in deinit_rsq() argument
1006 dma_free_coherent(&card->pcidev->dev, RSQSIZE, in deinit_rsq()
1007 card->rsq.base, card->rsq.paddr); in deinit_rsq()
1011 dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe) in dequeue_rx() argument
1025 card->name); in dequeue_rx()
1029 skb = sb_pool_skb(card, le32_to_cpu(rsqe->word_2)); in dequeue_rx()
1032 card->name, __func__, in dequeue_rx()
1043 card->name, vpi, vci, skb, skb->data); in dequeue_rx()
1045 if ((vpi >= (1 << card->vpibits)) || (vci != (vci & card->vcimask))) { in dequeue_rx()
1047 card->name, vpi, vci); in dequeue_rx()
1048 recycle_rx_skb(card, skb); in dequeue_rx()
1052 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in dequeue_rx()
1055 card->name, vpi, vci); in dequeue_rx()
1056 recycle_rx_skb(card, skb); in dequeue_rx()
1062 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in dequeue_rx()
1076 card->name); in dequeue_rx()
1082 card->name); in dequeue_rx()
1104 recycle_rx_skb(card, skb); in dequeue_rx()
1109 card->name, vcc->qos.aal); in dequeue_rx()
1110 recycle_rx_skb(card, skb); in dequeue_rx()
1129 RXPRINTK("%s: PDU has %d bytes.\n", card->name, len); in dequeue_rx()
1134 card->name, len, rpp->len, readl(SAR_REG_CDC)); in dequeue_rx()
1135 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1140 RXPRINTK("%s: AAL5 CRC error.\n", card->name); in dequeue_rx()
1141 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1151 card->name); in dequeue_rx()
1152 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1157 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1164 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1176 flush_rx_pool(card, rpp); in dequeue_rx()
1179 recycle_rx_skb(card, skb); in dequeue_rx()
1183 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in dequeue_rx()
1186 sb_pool_remove(card, skb); in dequeue_rx()
1196 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1); in dequeue_rx()
1198 add_rx_skb(card, 2, SAR_FB_SIZE_2, 1); in dequeue_rx()
1200 add_rx_skb(card, 1, SAR_FB_SIZE_1, 1); in dequeue_rx()
1202 add_rx_skb(card, 0, SAR_FB_SIZE_0, 1); in dequeue_rx()
1208 idt77252_rx(struct idt77252_dev *card) in idt77252_rx() argument
1212 if (card->rsq.next == card->rsq.last) in idt77252_rx()
1213 rsqe = card->rsq.base; in idt77252_rx()
1215 rsqe = card->rsq.next + 1; in idt77252_rx()
1218 RXPRINTK("%s: no entry in RSQ.\n", card->name); in idt77252_rx()
1223 dequeue_rx(card, rsqe); in idt77252_rx()
1225 card->rsq.next = rsqe; in idt77252_rx()
1226 if (card->rsq.next == card->rsq.last) in idt77252_rx()
1227 rsqe = card->rsq.base; in idt77252_rx()
1229 rsqe = card->rsq.next + 1; in idt77252_rx()
1232 writel((unsigned long) card->rsq.next - (unsigned long) card->rsq.base, in idt77252_rx()
1237 idt77252_rx_raw(struct idt77252_dev *card) in idt77252_rx_raw() argument
1245 if (card->raw_cell_head == NULL) { in idt77252_rx_raw()
1246 u32 handle = le32_to_cpu(*(card->raw_cell_hnd + 1)); in idt77252_rx_raw()
1247 card->raw_cell_head = sb_pool_skb(card, handle); in idt77252_rx_raw()
1250 queue = card->raw_cell_head; in idt77252_rx_raw()
1257 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(queue), in idt77252_rx_raw()
1275 card->name, (header >> 28) & 0x000f, in idt77252_rx_raw()
1286 if (vpi >= (1<<card->vpibits) || vci >= (1<<card->vcibits)) { in idt77252_rx_raw()
1288 card->name, vpi, vci); in idt77252_rx_raw()
1292 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in idt77252_rx_raw()
1295 card->name, vpi, vci); in idt77252_rx_raw()
1303 card->name, vpi, vci); in idt77252_rx_raw()
1310 card->name); in idt77252_rx_raw()
1317 card->name); in idt77252_rx_raw()
1344 next = sb_pool_skb(card, handle); in idt77252_rx_raw()
1345 recycle_rx_skb(card, queue); in idt77252_rx_raw()
1348 card->raw_cell_head = next; in idt77252_rx_raw()
1349 queue = card->raw_cell_head; in idt77252_rx_raw()
1350 dma_sync_single_for_cpu(&card->pcidev->dev, in idt77252_rx_raw()
1356 card->raw_cell_head = NULL; in idt77252_rx_raw()
1358 card->name); in idt77252_rx_raw()
1373 init_tsq(struct idt77252_dev *card) in init_tsq() argument
1377 card->tsq.base = dma_alloc_coherent(&card->pcidev->dev, RSQSIZE, in init_tsq()
1378 &card->tsq.paddr, GFP_KERNEL); in init_tsq()
1379 if (card->tsq.base == NULL) { in init_tsq()
1380 printk("%s: can't allocate TSQ.\n", card->name); in init_tsq()
1384 card->tsq.last = card->tsq.base + TSQ_NUM_ENTRIES - 1; in init_tsq()
1385 card->tsq.next = card->tsq.last; in init_tsq()
1386 for (tsqe = card->tsq.base; tsqe <= card->tsq.last; tsqe++) in init_tsq()
1389 writel(card->tsq.paddr, SAR_REG_TSQB); in init_tsq()
1390 writel((unsigned long) card->tsq.next - (unsigned long) card->tsq.base, in init_tsq()
1397 deinit_tsq(struct idt77252_dev *card) in deinit_tsq() argument
1399 dma_free_coherent(&card->pcidev->dev, TSQSIZE, in deinit_tsq()
1400 card->tsq.base, card->tsq.paddr); in deinit_tsq()
1404 idt77252_tx(struct idt77252_dev *card) in idt77252_tx() argument
1411 if (card->tsq.next == card->tsq.last) in idt77252_tx()
1412 tsqe = card->tsq.base; in idt77252_tx()
1414 tsqe = card->tsq.next + 1; in idt77252_tx()
1417 card->tsq.base, card->tsq.next, card->tsq.last); in idt77252_tx()
1435 TXPRINTK("%s: Timer RollOver detected.\n", card->name); in idt77252_tx()
1445 card->name, in idt77252_tx()
1451 vc = card->vcs[conn & 0x1fff]; in idt77252_tx()
1454 card->name, conn & 0x1fff); in idt77252_tx()
1459 card->name, vc->index); in idt77252_tx()
1468 vc = card->vcs[conn & 0x1fff]; in idt77252_tx()
1471 card->name, in idt77252_tx()
1476 drain_scq(card, vc); in idt77252_tx()
1486 if (vpi >= (1 << card->vpibits) || in idt77252_tx()
1487 vci >= (1 << card->vcibits)) { in idt77252_tx()
1490 card->name, vpi, vci); in idt77252_tx()
1494 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in idt77252_tx()
1498 card->name, vpi, vci); in idt77252_tx()
1502 drain_scq(card, vc); in idt77252_tx()
1508 card->tsq.next = tsqe; in idt77252_tx()
1509 if (card->tsq.next == card->tsq.last) in idt77252_tx()
1510 tsqe = card->tsq.base; in idt77252_tx()
1512 tsqe = card->tsq.next + 1; in idt77252_tx()
1515 card->tsq.base, card->tsq.next, card->tsq.last); in idt77252_tx()
1521 writel((unsigned long)card->tsq.next - (unsigned long)card->tsq.base, in idt77252_tx()
1525 card->index, readl(SAR_REG_TSQH), in idt77252_tx()
1526 readl(SAR_REG_TSQT), card->tsq.next); in idt77252_tx()
1533 struct idt77252_dev *card = from_timer(card, t, tst_timer); in tst_timer() local
1539 spin_lock_irqsave(&card->tst_lock, flags); in tst_timer()
1541 base = card->tst[card->tst_index]; in tst_timer()
1542 idle = card->tst[card->tst_index ^ 1]; in tst_timer()
1544 if (test_bit(TST_SWITCH_WAIT, &card->tst_state)) { in tst_timer()
1545 jump = base + card->tst_size - 2; in tst_timer()
1548 if ((pc ^ idle) & ~(card->tst_size - 1)) { in tst_timer()
1549 mod_timer(&card->tst_timer, jiffies + 1); in tst_timer()
1553 clear_bit(TST_SWITCH_WAIT, &card->tst_state); in tst_timer()
1555 card->tst_index ^= 1; in tst_timer()
1556 write_sram(card, jump, TSTE_OPC_JMP | (base << 2)); in tst_timer()
1558 base = card->tst[card->tst_index]; in tst_timer()
1559 idle = card->tst[card->tst_index ^ 1]; in tst_timer()
1561 for (e = 0; e < card->tst_size - 2; e++) { in tst_timer()
1562 if (card->soft_tst[e].tste & TSTE_PUSH_IDLE) { in tst_timer()
1563 write_sram(card, idle + e, in tst_timer()
1564 card->soft_tst[e].tste & TSTE_MASK); in tst_timer()
1565 card->soft_tst[e].tste &= ~(TSTE_PUSH_IDLE); in tst_timer()
1570 if (test_and_clear_bit(TST_SWITCH_PENDING, &card->tst_state)) { in tst_timer()
1572 for (e = 0; e < card->tst_size - 2; e++) { in tst_timer()
1573 if (card->soft_tst[e].tste & TSTE_PUSH_ACTIVE) { in tst_timer()
1574 write_sram(card, idle + e, in tst_timer()
1575 card->soft_tst[e].tste & TSTE_MASK); in tst_timer()
1576 card->soft_tst[e].tste &= ~(TSTE_PUSH_ACTIVE); in tst_timer()
1577 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in tst_timer()
1581 jump = base + card->tst_size - 2; in tst_timer()
1583 write_sram(card, jump, TSTE_OPC_NULL); in tst_timer()
1584 set_bit(TST_SWITCH_WAIT, &card->tst_state); in tst_timer()
1586 mod_timer(&card->tst_timer, jiffies + 1); in tst_timer()
1590 spin_unlock_irqrestore(&card->tst_lock, flags); in tst_timer()
1594 __fill_tst(struct idt77252_dev *card, struct vc_map *vc, in __fill_tst() argument
1602 avail = card->tst_size - 2; in __fill_tst()
1604 if (card->soft_tst[e].vc == NULL) in __fill_tst()
1608 printk("%s: No free TST entries found\n", card->name); in __fill_tst()
1613 card->name, vc ? vc->index : -1, e); in __fill_tst()
1621 idle = card->tst[card->tst_index ^ 1]; in __fill_tst()
1627 if ((cl >= avail) && (card->soft_tst[e].vc == NULL)) { in __fill_tst()
1629 card->soft_tst[e].vc = vc; in __fill_tst()
1631 card->soft_tst[e].vc = (void *)-1; in __fill_tst()
1633 card->soft_tst[e].tste = data; in __fill_tst()
1634 if (timer_pending(&card->tst_timer)) in __fill_tst()
1635 card->soft_tst[e].tste |= TSTE_PUSH_ACTIVE; in __fill_tst()
1637 write_sram(card, idle + e, data); in __fill_tst()
1638 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in __fill_tst()
1641 cl -= card->tst_size; in __fill_tst()
1654 fill_tst(struct idt77252_dev *card, struct vc_map *vc, int n, unsigned int opc) in fill_tst() argument
1659 spin_lock_irqsave(&card->tst_lock, flags); in fill_tst()
1661 res = __fill_tst(card, vc, n, opc); in fill_tst()
1663 set_bit(TST_SWITCH_PENDING, &card->tst_state); in fill_tst()
1664 if (!timer_pending(&card->tst_timer)) in fill_tst()
1665 mod_timer(&card->tst_timer, jiffies + 1); in fill_tst()
1667 spin_unlock_irqrestore(&card->tst_lock, flags); in fill_tst()
1672 __clear_tst(struct idt77252_dev *card, struct vc_map *vc) in __clear_tst() argument
1677 idle = card->tst[card->tst_index ^ 1]; in __clear_tst()
1679 for (e = 0; e < card->tst_size - 2; e++) { in __clear_tst()
1680 if (card->soft_tst[e].vc == vc) { in __clear_tst()
1681 card->soft_tst[e].vc = NULL; in __clear_tst()
1683 card->soft_tst[e].tste = TSTE_OPC_VAR; in __clear_tst()
1684 if (timer_pending(&card->tst_timer)) in __clear_tst()
1685 card->soft_tst[e].tste |= TSTE_PUSH_ACTIVE; in __clear_tst()
1687 write_sram(card, idle + e, TSTE_OPC_VAR); in __clear_tst()
1688 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in __clear_tst()
1697 clear_tst(struct idt77252_dev *card, struct vc_map *vc) in clear_tst() argument
1702 spin_lock_irqsave(&card->tst_lock, flags); in clear_tst()
1704 res = __clear_tst(card, vc); in clear_tst()
1706 set_bit(TST_SWITCH_PENDING, &card->tst_state); in clear_tst()
1707 if (!timer_pending(&card->tst_timer)) in clear_tst()
1708 mod_timer(&card->tst_timer, jiffies + 1); in clear_tst()
1710 spin_unlock_irqrestore(&card->tst_lock, flags); in clear_tst()
1715 change_tst(struct idt77252_dev *card, struct vc_map *vc, in change_tst() argument
1721 spin_lock_irqsave(&card->tst_lock, flags); in change_tst()
1723 __clear_tst(card, vc); in change_tst()
1724 res = __fill_tst(card, vc, n, opc); in change_tst()
1726 set_bit(TST_SWITCH_PENDING, &card->tst_state); in change_tst()
1727 if (!timer_pending(&card->tst_timer)) in change_tst()
1728 mod_timer(&card->tst_timer, jiffies + 1); in change_tst()
1730 spin_unlock_irqrestore(&card->tst_lock, flags); in change_tst()
1736 set_tct(struct idt77252_dev *card, struct vc_map *vc) in set_tct() argument
1740 tct = (unsigned long) (card->tct_base + vc->index * SAR_SRAM_TCT_SIZE); in set_tct()
1745 card->name, tct, vc->scq->scd); in set_tct()
1747 write_sram(card, tct + 0, TCT_CBR | vc->scq->scd); in set_tct()
1748 write_sram(card, tct + 1, 0); in set_tct()
1749 write_sram(card, tct + 2, 0); in set_tct()
1750 write_sram(card, tct + 3, 0); in set_tct()
1751 write_sram(card, tct + 4, 0); in set_tct()
1752 write_sram(card, tct + 5, 0); in set_tct()
1753 write_sram(card, tct + 6, 0); in set_tct()
1754 write_sram(card, tct + 7, 0); in set_tct()
1759 card->name, tct, vc->scq->scd); in set_tct()
1761 write_sram(card, tct + 0, TCT_UBR | vc->scq->scd); in set_tct()
1762 write_sram(card, tct + 1, 0); in set_tct()
1763 write_sram(card, tct + 2, TCT_TSIF); in set_tct()
1764 write_sram(card, tct + 3, TCT_HALT | TCT_IDLE); in set_tct()
1765 write_sram(card, tct + 4, 0); in set_tct()
1766 write_sram(card, tct + 5, vc->init_er); in set_tct()
1767 write_sram(card, tct + 6, 0); in set_tct()
1768 write_sram(card, tct + 7, TCT_FLAG_UBR); in set_tct()
1787 idt77252_fbq_level(struct idt77252_dev *card, int queue) in idt77252_fbq_level() argument
1793 idt77252_fbq_full(struct idt77252_dev *card, int queue) in idt77252_fbq_full() argument
1799 push_rx_skb(struct idt77252_dev *card, struct sk_buff *skb, int queue) in push_rx_skb() argument
1828 if (idt77252_fbq_full(card, queue)) in push_rx_skb()
1836 spin_lock_irqsave(&card->cmd_lock, flags); in push_rx_skb()
1837 writel(handle, card->fbq[queue]); in push_rx_skb()
1838 writel(addr, card->fbq[queue]); in push_rx_skb()
1839 spin_unlock_irqrestore(&card->cmd_lock, flags); in push_rx_skb()
1845 add_rx_skb(struct idt77252_dev *card, int queue, in add_rx_skb() argument
1857 if (sb_pool_add(card, skb, queue)) { in add_rx_skb()
1862 paddr = dma_map_single(&card->pcidev->dev, skb->data, in add_rx_skb()
1867 if (push_rx_skb(card, skb, queue)) { in add_rx_skb()
1876 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in add_rx_skb()
1880 card->sbpool[POOL_QUEUE(handle)].skb[POOL_INDEX(handle)] = NULL; in add_rx_skb()
1888 recycle_rx_skb(struct idt77252_dev *card, struct sk_buff *skb) in recycle_rx_skb() argument
1893 dma_sync_single_for_device(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in recycle_rx_skb()
1897 err = push_rx_skb(card, skb, POOL_QUEUE(handle)); in recycle_rx_skb()
1899 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in recycle_rx_skb()
1902 sb_pool_remove(card, skb); in recycle_rx_skb()
1908 flush_rx_pool(struct idt77252_dev *card, struct rx_pool *rpp) in flush_rx_pool() argument
1915 recycle_rx_pool_skb(struct idt77252_dev *card, struct rx_pool *rpp) in recycle_rx_pool_skb() argument
1920 recycle_rx_skb(card, skb); in recycle_rx_pool_skb()
1922 flush_rx_pool(card, rpp); in recycle_rx_pool_skb()
1947 struct idt77252_dev *card = dev->dev_data; in idt77252_send_skb() local
1952 printk("%s: NULL connection in send().\n", card->name); in idt77252_send_skb()
1958 printk("%s: Trying to transmit on a non-tx VC.\n", card->name); in idt77252_send_skb()
1970 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); in idt77252_send_skb()
1977 printk("%s: No scatter-gather yet.\n", card->name); in idt77252_send_skb()
1984 err = queue_skb(card, vc, skb, oam); in idt77252_send_skb()
2003 struct idt77252_dev *card = dev->dev_data; in idt77252_send_oam() local
2008 printk("%s: Out of memory in send_oam().\n", card->name); in idt77252_send_oam()
2065 idt77252_rate_logindex(struct idt77252_dev *card, int pcr) in idt77252_rate_logindex() argument
2080 struct idt77252_dev *card = vc->card; in idt77252_est_timer() local
2100 lacr = idt77252_rate_logindex(card, cps); in idt77252_est_timer()
2138 idt77252_init_cbr(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_cbr() argument
2148 card->name); in idt77252_init_cbr()
2153 tst_free = card->tst_free; in idt77252_init_cbr()
2161 TXPRINTK("%s: CBR target cell rate = %d\n", card->name, tcra); in idt77252_init_cbr()
2163 tmpl = (unsigned long) tcra * ((unsigned long) card->tst_size - 2); in idt77252_init_cbr()
2164 modl = tmpl % (unsigned long)card->utopia_pcr; in idt77252_init_cbr()
2166 tst_entries = (int) (tmpl / card->utopia_pcr); in idt77252_init_cbr()
2173 printk("%s: no CBR bandwidth free.\n", card->name); in idt77252_init_cbr()
2180 card->name); in idt77252_init_cbr()
2185 printk("%s: not enough CBR bandwidth free.\n", card->name); in idt77252_init_cbr()
2191 card->tst_free = tst_free - tst_entries; in idt77252_init_cbr()
2197 card->name, tst_used, tst_entries); in idt77252_init_cbr()
2198 change_tst(card, vc, tst_entries, TSTE_OPC_CBR); in idt77252_init_cbr()
2202 OPRINTK("%s: setting %d entries in TST.\n", card->name, tst_entries); in idt77252_init_cbr()
2203 fill_tst(card, vc, tst_entries, TSTE_OPC_CBR); in idt77252_init_cbr()
2208 idt77252_init_ubr(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_ubr() argument
2228 tcr = card->link_pcr; in idt77252_init_ubr()
2233 vc->init_er = idt77252_rate_logindex(card, tcr); in idt77252_init_ubr()
2244 idt77252_init_tx(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_tx() argument
2267 vc->scq = alloc_scq(card, vc->class); in idt77252_init_tx()
2269 printk("%s: can't get SCQ.\n", card->name); in idt77252_init_tx()
2273 vc->scq->scd = get_free_scd(card, vc); in idt77252_init_tx()
2275 printk("%s: no SCD available.\n", card->name); in idt77252_init_tx()
2276 free_scq(card, vc->scq); in idt77252_init_tx()
2280 fill_scd(card, vc->scq, vc->class); in idt77252_init_tx()
2282 if (set_tct(card, vc)) { in idt77252_init_tx()
2284 card->name, qos->txtp.traffic_class); in idt77252_init_tx()
2286 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2287 free_scq(card, vc->scq); in idt77252_init_tx()
2293 error = idt77252_init_cbr(card, vc, vcc, qos); in idt77252_init_tx()
2295 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2296 free_scq(card, vc->scq); in idt77252_init_tx()
2305 error = idt77252_init_ubr(card, vc, vcc, qos); in idt77252_init_tx()
2307 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2308 free_scq(card, vc->scq); in idt77252_init_tx()
2322 idt77252_init_rx(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_rx() argument
2338 flush_rx_pool(card, &vc->rcv.rx_pool); in idt77252_init_rx()
2372 addr = card->rct_base + (vc->index << 2); in idt77252_init_rx()
2374 OPRINTK("%s: writing RCT at 0x%lx\n", card->name, addr); in idt77252_init_rx()
2375 write_sram(card, addr, rcte); in idt77252_init_rx()
2377 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_init_rx()
2379 waitfor_idle(card); in idt77252_init_rx()
2380 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_init_rx()
2389 struct idt77252_dev *card = dev->dev_data; in idt77252_open() local
2400 if (vpi >= (1 << card->vpibits)) { in idt77252_open()
2401 printk("%s: unsupported VPI: %d\n", card->name, vpi); in idt77252_open()
2405 if (vci >= (1 << card->vcibits)) { in idt77252_open()
2406 printk("%s: unsupported VCI: %d\n", card->name, vci); in idt77252_open()
2412 mutex_lock(&card->mutex); in idt77252_open()
2414 OPRINTK("%s: opening vpi.vci: %d.%d\n", card->name, vpi, vci); in idt77252_open()
2422 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); in idt77252_open()
2423 mutex_unlock(&card->mutex); in idt77252_open()
2427 index = VPCI2VC(card, vpi, vci); in idt77252_open()
2428 if (!card->vcs[index]) { in idt77252_open()
2429 card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL); in idt77252_open()
2430 if (!card->vcs[index]) { in idt77252_open()
2431 printk("%s: can't alloc vc in open()\n", card->name); in idt77252_open()
2432 mutex_unlock(&card->mutex); in idt77252_open()
2435 card->vcs[index]->card = card; in idt77252_open()
2436 card->vcs[index]->index = index; in idt77252_open()
2438 spin_lock_init(&card->vcs[index]->lock); in idt77252_open()
2440 vc = card->vcs[index]; in idt77252_open()
2445 card->name, vc->index, vcc->vpi, vcc->vci, in idt77252_open()
2459 printk("%s: %s vci already in use.\n", card->name, in idt77252_open()
2461 mutex_unlock(&card->mutex); in idt77252_open()
2466 error = idt77252_init_tx(card, vc, vcc, &vcc->qos); in idt77252_open()
2468 mutex_unlock(&card->mutex); in idt77252_open()
2474 error = idt77252_init_rx(card, vc, vcc, &vcc->qos); in idt77252_open()
2476 mutex_unlock(&card->mutex); in idt77252_open()
2483 mutex_unlock(&card->mutex); in idt77252_open()
2491 struct idt77252_dev *card = dev->dev_data; in idt77252_close() local
2497 mutex_lock(&card->mutex); in idt77252_close()
2500 card->name, vc->index, vcc->vpi, vcc->vci); in idt77252_close()
2514 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; in idt77252_close()
2516 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_close()
2518 waitfor_idle(card); in idt77252_close()
2519 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_close()
2523 card->name); in idt77252_close()
2525 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); in idt77252_close()
2550 card->name, atomic_read(&vc->scq->used)); in idt77252_close()
2556 clear_scd(card, vc->scq, vc->class); in idt77252_close()
2559 clear_tst(card, vc); in idt77252_close()
2560 card->tst_free += vc->ntste; in idt77252_close()
2564 card->scd2vc[vc->scd_index] = NULL; in idt77252_close()
2565 free_scq(card, vc->scq); in idt77252_close()
2568 mutex_unlock(&card->mutex); in idt77252_close()
2575 struct idt77252_dev *card = dev->dev_data; in idt77252_change_qos() local
2579 mutex_lock(&card->mutex); in idt77252_change_qos()
2583 error = idt77252_init_tx(card, vc, vcc, qos); in idt77252_change_qos()
2589 error = idt77252_init_cbr(card, vc, vcc, qos); in idt77252_change_qos()
2595 error = idt77252_init_ubr(card, vc, vcc, qos); in idt77252_change_qos()
2615 error = idt77252_init_rx(card, vc, vcc, qos); in idt77252_change_qos()
2625 mutex_unlock(&card->mutex); in idt77252_change_qos()
2632 struct idt77252_dev *card = dev->dev_data; in idt77252_proc_read() local
2639 return sprintf(page, "TSIF: %lu\n", card->irqstat[15]); in idt77252_proc_read()
2641 return sprintf(page, "TXICP: %lu\n", card->irqstat[14]); in idt77252_proc_read()
2643 return sprintf(page, "TSQF: %lu\n", card->irqstat[12]); in idt77252_proc_read()
2645 return sprintf(page, "TMROF: %lu\n", card->irqstat[11]); in idt77252_proc_read()
2647 return sprintf(page, "PHYI: %lu\n", card->irqstat[10]); in idt77252_proc_read()
2649 return sprintf(page, "FBQ3A: %lu\n", card->irqstat[8]); in idt77252_proc_read()
2651 return sprintf(page, "FBQ2A: %lu\n", card->irqstat[7]); in idt77252_proc_read()
2653 return sprintf(page, "RSQF: %lu\n", card->irqstat[6]); in idt77252_proc_read()
2655 return sprintf(page, "EPDU: %lu\n", card->irqstat[5]); in idt77252_proc_read()
2657 return sprintf(page, "RAWCF: %lu\n", card->irqstat[4]); in idt77252_proc_read()
2659 return sprintf(page, "FBQ1A: %lu\n", card->irqstat[3]); in idt77252_proc_read()
2661 return sprintf(page, "FBQ0A: %lu\n", card->irqstat[2]); in idt77252_proc_read()
2663 return sprintf(page, "RSQAF: %lu\n", card->irqstat[1]); in idt77252_proc_read()
2667 for (i = 0; i < card->tct_size; i++) { in idt77252_proc_read()
2673 vc = card->vcs[i]; in idt77252_proc_read()
2687 tct = (unsigned long) (card->tct_base + i * SAR_SRAM_TCT_SIZE); in idt77252_proc_read()
2690 p += sprintf(p, " %08x", read_sram(card, tct + i)); in idt77252_proc_read()
2704 idt77252_collect_stat(struct idt77252_dev *card) in idt77252_collect_stat() argument
2715 struct idt77252_dev *card = dev_id; in idt77252_interrupt() local
2722 if (test_and_set_bit(IDT77252_BIT_INTERRUPT, &card->flags)) { in idt77252_interrupt()
2723 printk("%s: Re-entering irq_handler()\n", card->name); in idt77252_interrupt()
2730 INTPRINTK("%s: TSIF\n", card->name); in idt77252_interrupt()
2731 card->irqstat[15]++; in idt77252_interrupt()
2732 idt77252_tx(card); in idt77252_interrupt()
2735 INTPRINTK("%s: TXICP\n", card->name); in idt77252_interrupt()
2736 card->irqstat[14]++; in idt77252_interrupt()
2738 idt77252_tx_dump(card); in idt77252_interrupt()
2742 INTPRINTK("%s: TSQF\n", card->name); in idt77252_interrupt()
2743 card->irqstat[12]++; in idt77252_interrupt()
2744 idt77252_tx(card); in idt77252_interrupt()
2747 INTPRINTK("%s: TMROF\n", card->name); in idt77252_interrupt()
2748 card->irqstat[11]++; in idt77252_interrupt()
2749 idt77252_collect_stat(card); in idt77252_interrupt()
2753 INTPRINTK("%s: EPDU\n", card->name); in idt77252_interrupt()
2754 card->irqstat[5]++; in idt77252_interrupt()
2755 idt77252_rx(card); in idt77252_interrupt()
2758 INTPRINTK("%s: RSQAF\n", card->name); in idt77252_interrupt()
2759 card->irqstat[1]++; in idt77252_interrupt()
2760 idt77252_rx(card); in idt77252_interrupt()
2763 INTPRINTK("%s: RSQF\n", card->name); in idt77252_interrupt()
2764 card->irqstat[6]++; in idt77252_interrupt()
2765 idt77252_rx(card); in idt77252_interrupt()
2768 INTPRINTK("%s: RAWCF\n", card->name); in idt77252_interrupt()
2769 card->irqstat[4]++; in idt77252_interrupt()
2770 idt77252_rx_raw(card); in idt77252_interrupt()
2774 INTPRINTK("%s: PHYI", card->name); in idt77252_interrupt()
2775 card->irqstat[10]++; in idt77252_interrupt()
2776 if (card->atmdev->phy && card->atmdev->phy->interrupt) in idt77252_interrupt()
2777 card->atmdev->phy->interrupt(card->atmdev); in idt77252_interrupt()
2785 INTPRINTK("%s: FBQA: %04x\n", card->name, stat); in idt77252_interrupt()
2788 card->irqstat[2]++; in idt77252_interrupt()
2790 card->irqstat[3]++; in idt77252_interrupt()
2792 card->irqstat[7]++; in idt77252_interrupt()
2794 card->irqstat[8]++; in idt77252_interrupt()
2796 schedule_work(&card->tqueue); in idt77252_interrupt()
2800 clear_bit(IDT77252_BIT_INTERRUPT, &card->flags); in idt77252_interrupt()
2807 struct idt77252_dev *card = in idt77252_softint() local
2816 add_rx_skb(card, 0, SAR_FB_SIZE_0, 32); in idt77252_softint()
2822 add_rx_skb(card, 1, SAR_FB_SIZE_1, 32); in idt77252_softint()
2828 add_rx_skb(card, 2, SAR_FB_SIZE_2, 32); in idt77252_softint()
2834 add_rx_skb(card, 3, SAR_FB_SIZE_3, 32); in idt77252_softint()
2847 open_card_oam(struct idt77252_dev *card) in open_card_oam() argument
2856 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { in open_card_oam()
2858 index = VPCI2VC(card, vpi, vci); in open_card_oam()
2862 printk("%s: can't alloc vc\n", card->name); in open_card_oam()
2866 card->vcs[index] = vc; in open_card_oam()
2868 flush_rx_pool(card, &vc->rcv.rx_pool); in open_card_oam()
2875 addr = card->rct_base + (vc->index << 2); in open_card_oam()
2876 write_sram(card, addr, rcte); in open_card_oam()
2878 spin_lock_irqsave(&card->cmd_lock, flags); in open_card_oam()
2881 waitfor_idle(card); in open_card_oam()
2882 spin_unlock_irqrestore(&card->cmd_lock, flags); in open_card_oam()
2890 close_card_oam(struct idt77252_dev *card) in close_card_oam() argument
2898 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { in close_card_oam()
2900 index = VPCI2VC(card, vpi, vci); in close_card_oam()
2901 vc = card->vcs[index]; in close_card_oam()
2903 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; in close_card_oam()
2905 spin_lock_irqsave(&card->cmd_lock, flags); in close_card_oam()
2908 waitfor_idle(card); in close_card_oam()
2909 spin_unlock_irqrestore(&card->cmd_lock, flags); in close_card_oam()
2914 card->name); in close_card_oam()
2916 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); in close_card_oam()
2924 open_card_ubr0(struct idt77252_dev *card) in open_card_ubr0() argument
2930 printk("%s: can't alloc vc\n", card->name); in open_card_ubr0()
2933 card->vcs[0] = vc; in open_card_ubr0()
2936 vc->scq = alloc_scq(card, vc->class); in open_card_ubr0()
2938 printk("%s: can't get SCQ.\n", card->name); in open_card_ubr0()
2942 card->scd2vc[0] = vc; in open_card_ubr0()
2944 vc->scq->scd = card->scd_base; in open_card_ubr0()
2946 fill_scd(card, vc->scq, vc->class); in open_card_ubr0()
2948 write_sram(card, card->tct_base + 0, TCT_UBR | card->scd_base); in open_card_ubr0()
2949 write_sram(card, card->tct_base + 1, 0); in open_card_ubr0()
2950 write_sram(card, card->tct_base + 2, 0); in open_card_ubr0()
2951 write_sram(card, card->tct_base + 3, 0); in open_card_ubr0()
2952 write_sram(card, card->tct_base + 4, 0); in open_card_ubr0()
2953 write_sram(card, card->tct_base + 5, 0); in open_card_ubr0()
2954 write_sram(card, card->tct_base + 6, 0); in open_card_ubr0()
2955 write_sram(card, card->tct_base + 7, TCT_FLAG_UBR); in open_card_ubr0()
2963 close_card_ubr0(struct idt77252_dev *card) in close_card_ubr0() argument
2965 struct vc_map *vc = card->vcs[0]; in close_card_ubr0()
2967 free_scq(card, vc->scq); in close_card_ubr0()
2972 idt77252_dev_open(struct idt77252_dev *card) in idt77252_dev_open() argument
2976 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { in idt77252_dev_open()
2977 printk("%s: SAR not yet initialized.\n", card->name); in idt77252_dev_open()
3001 if (open_card_oam(card)) { in idt77252_dev_open()
3002 printk("%s: Error initializing OAM.\n", card->name); in idt77252_dev_open()
3006 if (open_card_ubr0(card)) { in idt77252_dev_open()
3007 printk("%s: Error initializing UBR0.\n", card->name); in idt77252_dev_open()
3011 IPRINTK("%s: opened IDT77252 ABR SAR.\n", card->name); in idt77252_dev_open()
3017 struct idt77252_dev *card = dev->dev_data; in idt77252_dev_close() local
3020 close_card_ubr0(card); in idt77252_dev_close()
3021 close_card_oam(card); in idt77252_dev_close()
3037 DIPRINTK("%s: closed IDT77252 ABR SAR.\n", card->name); in idt77252_dev_close()
3049 deinit_card(struct idt77252_dev *card) in deinit_card() argument
3054 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { in deinit_card()
3055 printk("%s: SAR not yet initialized.\n", card->name); in deinit_card()
3058 DIPRINTK("idt77252: deinitialize card %u\n", card->index); in deinit_card()
3062 if (card->atmdev) in deinit_card()
3063 atm_dev_deregister(card->atmdev); in deinit_card()
3067 skb = card->sbpool[i].skb[j]; in deinit_card()
3069 dma_unmap_single(&card->pcidev->dev, in deinit_card()
3074 card->sbpool[i].skb[j] = NULL; in deinit_card()
3080 vfree(card->soft_tst); in deinit_card()
3082 vfree(card->scd2vc); in deinit_card()
3084 vfree(card->vcs); in deinit_card()
3086 if (card->raw_cell_hnd) { in deinit_card()
3087 dma_free_coherent(&card->pcidev->dev, 2 * sizeof(u32), in deinit_card()
3088 card->raw_cell_hnd, card->raw_cell_paddr); in deinit_card()
3091 if (card->rsq.base) { in deinit_card()
3092 DIPRINTK("%s: Release RSQ ...\n", card->name); in deinit_card()
3093 deinit_rsq(card); in deinit_card()
3096 if (card->tsq.base) { in deinit_card()
3097 DIPRINTK("%s: Release TSQ ...\n", card->name); in deinit_card()
3098 deinit_tsq(card); in deinit_card()
3102 free_irq(card->pcidev->irq, card); in deinit_card()
3105 if (card->fbq[i]) in deinit_card()
3106 iounmap(card->fbq[i]); in deinit_card()
3109 if (card->membase) in deinit_card()
3110 iounmap(card->membase); in deinit_card()
3112 clear_bit(IDT77252_BIT_INIT, &card->flags); in deinit_card()
3113 DIPRINTK("%s: Card deinitialized.\n", card->name); in deinit_card()
3117 static void init_sram(struct idt77252_dev *card) in init_sram() argument
3121 for (i = 0; i < card->sramsize; i += 4) in init_sram()
3122 write_sram(card, (i >> 2), 0); in init_sram()
3125 if (card->sramsize == (512 * 1024)) { in init_sram()
3126 card->tct_base = SAR_SRAM_TCT_128_BASE; in init_sram()
3127 card->tct_size = (SAR_SRAM_TCT_128_TOP - card->tct_base + 1) in init_sram()
3129 card->rct_base = SAR_SRAM_RCT_128_BASE; in init_sram()
3130 card->rct_size = (SAR_SRAM_RCT_128_TOP - card->rct_base + 1) in init_sram()
3132 card->rt_base = SAR_SRAM_RT_128_BASE; in init_sram()
3133 card->scd_base = SAR_SRAM_SCD_128_BASE; in init_sram()
3134 card->scd_size = (SAR_SRAM_SCD_128_TOP - card->scd_base + 1) in init_sram()
3136 card->tst[0] = SAR_SRAM_TST1_128_BASE; in init_sram()
3137 card->tst[1] = SAR_SRAM_TST2_128_BASE; in init_sram()
3138 card->tst_size = SAR_SRAM_TST1_128_TOP - card->tst[0] + 1; in init_sram()
3139 card->abrst_base = SAR_SRAM_ABRSTD_128_BASE; in init_sram()
3140 card->abrst_size = SAR_ABRSTD_SIZE_8K; in init_sram()
3141 card->fifo_base = SAR_SRAM_FIFO_128_BASE; in init_sram()
3142 card->fifo_size = SAR_RXFD_SIZE_32K; in init_sram()
3144 card->tct_base = SAR_SRAM_TCT_32_BASE; in init_sram()
3145 card->tct_size = (SAR_SRAM_TCT_32_TOP - card->tct_base + 1) in init_sram()
3147 card->rct_base = SAR_SRAM_RCT_32_BASE; in init_sram()
3148 card->rct_size = (SAR_SRAM_RCT_32_TOP - card->rct_base + 1) in init_sram()
3150 card->rt_base = SAR_SRAM_RT_32_BASE; in init_sram()
3151 card->scd_base = SAR_SRAM_SCD_32_BASE; in init_sram()
3152 card->scd_size = (SAR_SRAM_SCD_32_TOP - card->scd_base + 1) in init_sram()
3154 card->tst[0] = SAR_SRAM_TST1_32_BASE; in init_sram()
3155 card->tst[1] = SAR_SRAM_TST2_32_BASE; in init_sram()
3156 card->tst_size = (SAR_SRAM_TST1_32_TOP - card->tst[0] + 1); in init_sram()
3157 card->abrst_base = SAR_SRAM_ABRSTD_32_BASE; in init_sram()
3158 card->abrst_size = SAR_ABRSTD_SIZE_1K; in init_sram()
3159 card->fifo_base = SAR_SRAM_FIFO_32_BASE; in init_sram()
3160 card->fifo_size = SAR_RXFD_SIZE_4K; in init_sram()
3164 for (i = 0; i < card->tct_size; i++) { in init_sram()
3165 write_sram(card, i * SAR_SRAM_TCT_SIZE + 0, 0); in init_sram()
3166 write_sram(card, i * SAR_SRAM_TCT_SIZE + 1, 0); in init_sram()
3167 write_sram(card, i * SAR_SRAM_TCT_SIZE + 2, 0); in init_sram()
3168 write_sram(card, i * SAR_SRAM_TCT_SIZE + 3, 0); in init_sram()
3169 write_sram(card, i * SAR_SRAM_TCT_SIZE + 4, 0); in init_sram()
3170 write_sram(card, i * SAR_SRAM_TCT_SIZE + 5, 0); in init_sram()
3171 write_sram(card, i * SAR_SRAM_TCT_SIZE + 6, 0); in init_sram()
3172 write_sram(card, i * SAR_SRAM_TCT_SIZE + 7, 0); in init_sram()
3176 for (i = 0; i < card->rct_size; i++) { in init_sram()
3177 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE, in init_sram()
3179 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 1, in init_sram()
3181 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 2, in init_sram()
3183 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 3, in init_sram()
3194 write_sram(card, card->rt_base + i, log_to_rate[i]); in init_sram()
3204 write_sram(card, card->rt_base + 256 + i, tmp); in init_sram()
3213 write_sram(card, card->rt_base + 512 + i, tmp); in init_sram()
3221 write_sram(card, card->rt_base + 640 + i, tmp); in init_sram()
3225 IPRINTK("%s: initialize rate table ...\n", card->name); in init_sram()
3226 writel(card->rt_base << 2, SAR_REG_RTBL); in init_sram()
3229 IPRINTK("%s: initialize TST ...\n", card->name); in init_sram()
3230 card->tst_free = card->tst_size - 2; /* last two are jumps */ in init_sram()
3232 for (i = card->tst[0]; i < card->tst[0] + card->tst_size - 2; i++) in init_sram()
3233 write_sram(card, i, TSTE_OPC_VAR); in init_sram()
3234 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); in init_sram()
3236 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); in init_sram()
3238 for (i = card->tst[1]; i < card->tst[1] + card->tst_size - 2; i++) in init_sram()
3239 write_sram(card, i, TSTE_OPC_VAR); in init_sram()
3240 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); in init_sram()
3242 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); in init_sram()
3245 card->tst_index = 0; in init_sram()
3246 writel(card->tst[0] << 2, SAR_REG_TSTB); in init_sram()
3249 IPRINTK("%s: initialize ABRSTD ...\n", card->name); in init_sram()
3250 writel(card->abrst_size | (card->abrst_base << 2), in init_sram()
3253 IPRINTK("%s: initialize receive fifo ...\n", card->name); in init_sram()
3254 writel(card->fifo_size | (card->fifo_base << 2), in init_sram()
3257 IPRINTK("%s: SRAM initialization complete.\n", card->name); in init_sram()
3262 struct idt77252_dev *card = dev->dev_data; in init_card() local
3263 struct pci_dev *pcidev = card->pcidev; in init_card()
3275 if (test_bit(IDT77252_BIT_INIT, &card->flags)) { in init_card()
3285 IPRINTK("%s: Checking PCI retries.\n", card->name); in init_card()
3287 printk("%s: can't read PCI retry timeout.\n", card->name); in init_card()
3288 deinit_card(card); in init_card()
3293 card->name, pci_byte); in init_card()
3296 card->name); in init_card()
3297 deinit_card(card); in init_card()
3301 IPRINTK("%s: Checking PCI TRDY.\n", card->name); in init_card()
3303 printk("%s: can't read PCI TRDY timeout.\n", card->name); in init_card()
3304 deinit_card(card); in init_card()
3309 card->name, pci_byte); in init_card()
3311 printk("%s: can't set PCI TRDY timeout.\n", card->name); in init_card()
3312 deinit_card(card); in init_card()
3318 printk("%s: resetting timer overflow.\n", card->name); in init_card()
3321 IPRINTK("%s: Request IRQ ... ", card->name); in init_card()
3323 card->name, card) != 0) { in init_card()
3324 printk("%s: can't allocate IRQ.\n", card->name); in init_card()
3325 deinit_card(card); in init_card()
3334 IPRINTK("%s: Initializing SRAM\n", card->name); in init_card()
3345 if (card->sramsize == (512 * 1024)) in init_card()
3368 init_sram(card); in init_card()
3374 if (0 != init_tsq(card)) { in init_card()
3375 deinit_card(card); in init_card()
3379 if (0 != init_rsq(card)) { in init_card()
3380 deinit_card(card); in init_card()
3384 card->vpibits = vpibits; in init_card()
3385 if (card->sramsize == (512 * 1024)) { in init_card()
3386 card->vcibits = 10 - card->vpibits; in init_card()
3388 card->vcibits = 9 - card->vpibits; in init_card()
3391 card->vcimask = 0; in init_card()
3392 for (k = 0, i = 1; k < card->vcibits; k++) { in init_card()
3393 card->vcimask |= i; in init_card()
3397 IPRINTK("%s: Setting VPI/VCI mask to zero.\n", card->name); in init_card()
3404 card->raw_cell_hnd = dma_alloc_coherent(&card->pcidev->dev, in init_card()
3406 &card->raw_cell_paddr, in init_card()
3408 if (!card->raw_cell_hnd) { in init_card()
3409 printk("%s: memory allocation failure.\n", card->name); in init_card()
3410 deinit_card(card); in init_card()
3413 writel(card->raw_cell_paddr, SAR_REG_RAWHND); in init_card()
3414 IPRINTK("%s: raw cell handle is at 0x%p.\n", card->name, in init_card()
3415 card->raw_cell_hnd); in init_card()
3417 size = sizeof(struct vc_map *) * card->tct_size; in init_card()
3418 IPRINTK("%s: allocate %d byte for VC map.\n", card->name, size); in init_card()
3419 card->vcs = vzalloc(size); in init_card()
3420 if (!card->vcs) { in init_card()
3421 printk("%s: memory allocation failure.\n", card->name); in init_card()
3422 deinit_card(card); in init_card()
3426 size = sizeof(struct vc_map *) * card->scd_size; in init_card()
3428 card->name, size); in init_card()
3429 card->scd2vc = vzalloc(size); in init_card()
3430 if (!card->scd2vc) { in init_card()
3431 printk("%s: memory allocation failure.\n", card->name); in init_card()
3432 deinit_card(card); in init_card()
3436 size = sizeof(struct tst_info) * (card->tst_size - 2); in init_card()
3438 card->name, size); in init_card()
3439 card->soft_tst = vmalloc(size); in init_card()
3440 if (!card->soft_tst) { in init_card()
3441 printk("%s: memory allocation failure.\n", card->name); in init_card()
3442 deinit_card(card); in init_card()
3445 for (i = 0; i < card->tst_size - 2; i++) { in init_card()
3446 card->soft_tst[i].tste = TSTE_OPC_VAR; in init_card()
3447 card->soft_tst[i].vc = NULL; in init_card()
3451 printk("%s: No LT device defined.\n", card->name); in init_card()
3452 deinit_card(card); in init_card()
3456 printk("%s: LT had no IOCTL function defined.\n", card->name); in init_card()
3457 deinit_card(card); in init_card()
3474 card->link_pcr = (linkrate / 8 / 53); in init_card()
3476 card->name, linkrate, card->link_pcr); in init_card()
3479 card->utopia_pcr = card->link_pcr; in init_card()
3481 card->utopia_pcr = (160000000 / 8 / 54); in init_card()
3485 if (card->utopia_pcr > card->link_pcr) in init_card()
3486 rsvdcr = card->utopia_pcr - card->link_pcr; in init_card()
3488 tmpl = (unsigned long) rsvdcr * ((unsigned long) card->tst_size - 2); in init_card()
3489 modl = tmpl % (unsigned long)card->utopia_pcr; in init_card()
3490 tst_entries = (int) (tmpl / (unsigned long)card->utopia_pcr); in init_card()
3493 card->tst_free -= tst_entries; in init_card()
3494 fill_tst(card, NULL, tst_entries, TSTE_OPC_NULL); in init_card()
3497 idt77252_eeprom_init(card); in init_card()
3498 printk("%s: EEPROM: %02x:", card->name, in init_card()
3499 idt77252_eeprom_read_status(card)); in init_card()
3503 idt77252_eeprom_read_byte(card, i) in init_card()
3512 sprintf(tname, "eth%d", card->index); in init_card()
3515 memcpy(card->atmdev->esi, tmp->dev_addr, 6); in init_card()
3517 printk("%s: ESI %pM\n", card->name, card->atmdev->esi); in init_card()
3526 set_bit(IDT77252_BIT_INIT, &card->flags); in init_card()
3528 XPRINTK("%s: IDT77252 ABR SAR initialization complete.\n", card->name); in init_card()
3540 static int idt77252_preset(struct idt77252_dev *card) in idt77252_preset() argument
3549 card->name); in idt77252_preset()
3550 if (pci_read_config_word(card->pcidev, PCI_COMMAND, &pci_command)) { in idt77252_preset()
3551 printk("%s: can't read PCI_COMMAND.\n", card->name); in idt77252_preset()
3552 deinit_card(card); in idt77252_preset()
3557 card->name, pci_command); in idt77252_preset()
3558 deinit_card(card); in idt77252_preset()
3562 if (pci_write_config_word(card->pcidev, PCI_COMMAND, pci_command)) { in idt77252_preset()
3563 printk("%s: can't write PCI_COMMAND.\n", card->name); in idt77252_preset()
3564 deinit_card(card); in idt77252_preset()
3576 IPRINTK("%s: Software resetted.\n", card->name); in idt77252_preset()
3581 static unsigned long probe_sram(struct idt77252_dev *card) in probe_sram() argument
3609 struct idt77252_dev *card; in idt77252_init_one() local
3624 card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL); in idt77252_init_one()
3625 if (!card) { in idt77252_init_one()
3630 card->revision = pcidev->revision; in idt77252_init_one()
3631 card->index = index; in idt77252_init_one()
3632 card->pcidev = pcidev; in idt77252_init_one()
3633 sprintf(card->name, "idt77252-%d", card->index); in idt77252_init_one()
3635 INIT_WORK(&card->tqueue, idt77252_softint); in idt77252_init_one()
3640 mutex_init(&card->mutex); in idt77252_init_one()
3641 spin_lock_init(&card->cmd_lock); in idt77252_init_one()
3642 spin_lock_init(&card->tst_lock); in idt77252_init_one()
3644 timer_setup(&card->tst_timer, tst_timer, 0); in idt77252_init_one()
3647 card->membase = ioremap(membase, 1024); in idt77252_init_one()
3648 if (!card->membase) { in idt77252_init_one()
3649 printk("%s: can't ioremap() membase\n", card->name); in idt77252_init_one()
3654 if (idt77252_preset(card)) { in idt77252_init_one()
3655 printk("%s: preset failed\n", card->name); in idt77252_init_one()
3663 printk("%s: can't register atm device\n", card->name); in idt77252_init_one()
3667 dev->dev_data = card; in idt77252_init_one()
3668 card->atmdev = dev; in idt77252_init_one()
3673 printk("%s: can't init SUNI\n", card->name); in idt77252_init_one()
3679 card->sramsize = probe_sram(card); in idt77252_init_one()
3682 card->fbq[i] = ioremap(srambase | 0x200000 | (i << 18), 4); in idt77252_init_one()
3683 if (!card->fbq[i]) { in idt77252_init_one()
3684 printk("%s: can't ioremap() FBQ%d\n", card->name, i); in idt77252_init_one()
3691 card->name, ((card->revision > 1) && (card->revision < 25)) ? in idt77252_init_one()
3692 'A' + card->revision - 1 : '?', membase, srambase, in idt77252_init_one()
3693 card->sramsize / 1024); in idt77252_init_one()
3696 printk("%s: init_card failed\n", card->name); in idt77252_init_one()
3701 dev->ci_range.vpi_bits = card->vpibits; in idt77252_init_one()
3702 dev->ci_range.vci_bits = card->vcibits; in idt77252_init_one()
3703 dev->link_rate = card->link_pcr; in idt77252_init_one()
3708 if (idt77252_dev_open(card)) { in idt77252_init_one()
3709 printk("%s: dev_open failed\n", card->name); in idt77252_init_one()
3714 *last = card; in idt77252_init_one()
3715 last = &card->next; in idt77252_init_one()
3725 deinit_card(card); in idt77252_init_one()
3728 iounmap(card->membase); in idt77252_init_one()
3731 kfree(card); in idt77252_init_one()
3772 struct idt77252_dev *card; in idt77252_exit() local
3778 card = idt77252_chain; in idt77252_exit()
3779 dev = card->atmdev; in idt77252_exit()
3780 idt77252_chain = card->next; in idt77252_exit()
3781 del_timer_sync(&card->tst_timer); in idt77252_exit()
3785 deinit_card(card); in idt77252_exit()
3786 pci_disable_device(card->pcidev); in idt77252_exit()
3787 kfree(card); in idt77252_exit()