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_zalloc_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
840 printk("%s: invalid skb->len (%d)\n", card->name, skb->len); in queue_skb()
845 card->name, skb->len); in queue_skb()
850 IDT77252_PRV_PADDR(skb) = dma_map_single(&card->pcidev->dev, skb->data, in queue_skb()
866 vc = card->vcs[0]; in queue_skb()
872 printk("%s: Trying to transmit on reserved VC\n", card->name); in queue_skb()
908 printk("%s: Traffic type not supported.\n", card->name); in queue_skb()
918 if (push_on_scq(card, vc, skb)) { in queue_skb()
928 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in queue_skb()
934 get_free_scd(struct idt77252_dev *card, struct vc_map *vc) in get_free_scd() argument
938 for (i = 0; i < card->scd_size; i++) { in get_free_scd()
939 if (!card->scd2vc[i]) { in get_free_scd()
940 card->scd2vc[i] = vc; in get_free_scd()
942 return card->scd_base + i * SAR_SRAM_SCD_SIZE; in get_free_scd()
949 fill_scd(struct idt77252_dev *card, struct scq_info *scq, int class) in fill_scd() argument
951 write_sram(card, scq->scd, scq->paddr); in fill_scd()
952 write_sram(card, scq->scd + 1, 0x00000000); in fill_scd()
953 write_sram(card, scq->scd + 2, 0xffffffff); in fill_scd()
954 write_sram(card, scq->scd + 3, 0x00000000); in fill_scd()
958 clear_scd(struct idt77252_dev *card, struct scq_info *scq, int class) in clear_scd() argument
970 init_rsq(struct idt77252_dev *card) in init_rsq() argument
974 card->rsq.base = dma_zalloc_coherent(&card->pcidev->dev, RSQSIZE, in init_rsq()
975 &card->rsq.paddr, GFP_KERNEL); in init_rsq()
976 if (card->rsq.base == NULL) { in init_rsq()
977 printk("%s: can't allocate RSQ.\n", card->name); in init_rsq()
981 card->rsq.last = card->rsq.base + RSQ_NUM_ENTRIES - 1; in init_rsq()
982 card->rsq.next = card->rsq.last; in init_rsq()
983 for (rsqe = card->rsq.base; rsqe <= card->rsq.last; rsqe++) in init_rsq()
986 writel((unsigned long) card->rsq.last - (unsigned long) card->rsq.base, in init_rsq()
988 writel(card->rsq.paddr, SAR_REG_RSQB); in init_rsq()
990 IPRINTK("%s: RSQ base at 0x%lx (0x%x).\n", card->name, in init_rsq()
991 (unsigned long) card->rsq.base, in init_rsq()
994 card->name, in init_rsq()
1003 deinit_rsq(struct idt77252_dev *card) in deinit_rsq() argument
1005 dma_free_coherent(&card->pcidev->dev, RSQSIZE, in deinit_rsq()
1006 card->rsq.base, card->rsq.paddr); in deinit_rsq()
1010 dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe) in dequeue_rx() argument
1024 card->name); in dequeue_rx()
1028 skb = sb_pool_skb(card, le32_to_cpu(rsqe->word_2)); in dequeue_rx()
1031 card->name, __func__, in dequeue_rx()
1042 card->name, vpi, vci, skb, skb->data); in dequeue_rx()
1044 if ((vpi >= (1 << card->vpibits)) || (vci != (vci & card->vcimask))) { in dequeue_rx()
1046 card->name, vpi, vci); in dequeue_rx()
1047 recycle_rx_skb(card, skb); in dequeue_rx()
1051 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in dequeue_rx()
1054 card->name, vpi, vci); in dequeue_rx()
1055 recycle_rx_skb(card, skb); in dequeue_rx()
1061 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in dequeue_rx()
1075 card->name); in dequeue_rx()
1081 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()
1165 recycle_rx_pool_skb(card, rpp); in dequeue_rx()
1177 flush_rx_pool(card, rpp); in dequeue_rx()
1180 recycle_rx_skb(card, skb); in dequeue_rx()
1184 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in dequeue_rx()
1187 sb_pool_remove(card, skb); in dequeue_rx()
1197 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1); in dequeue_rx()
1199 add_rx_skb(card, 2, SAR_FB_SIZE_2, 1); in dequeue_rx()
1201 add_rx_skb(card, 1, SAR_FB_SIZE_1, 1); in dequeue_rx()
1203 add_rx_skb(card, 0, SAR_FB_SIZE_0, 1); in dequeue_rx()
1209 idt77252_rx(struct idt77252_dev *card) in idt77252_rx() argument
1213 if (card->rsq.next == card->rsq.last) in idt77252_rx()
1214 rsqe = card->rsq.base; in idt77252_rx()
1216 rsqe = card->rsq.next + 1; in idt77252_rx()
1219 RXPRINTK("%s: no entry in RSQ.\n", card->name); in idt77252_rx()
1224 dequeue_rx(card, rsqe); in idt77252_rx()
1226 card->rsq.next = rsqe; in idt77252_rx()
1227 if (card->rsq.next == card->rsq.last) in idt77252_rx()
1228 rsqe = card->rsq.base; in idt77252_rx()
1230 rsqe = card->rsq.next + 1; in idt77252_rx()
1233 writel((unsigned long) card->rsq.next - (unsigned long) card->rsq.base, in idt77252_rx()
1238 idt77252_rx_raw(struct idt77252_dev *card) in idt77252_rx_raw() argument
1246 if (card->raw_cell_head == NULL) { in idt77252_rx_raw()
1247 u32 handle = le32_to_cpu(*(card->raw_cell_hnd + 1)); in idt77252_rx_raw()
1248 card->raw_cell_head = sb_pool_skb(card, handle); in idt77252_rx_raw()
1251 queue = card->raw_cell_head; in idt77252_rx_raw()
1258 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(queue), in idt77252_rx_raw()
1276 card->name, (header >> 28) & 0x000f, in idt77252_rx_raw()
1287 if (vpi >= (1<<card->vpibits) || vci >= (1<<card->vcibits)) { in idt77252_rx_raw()
1289 card->name, vpi, vci); in idt77252_rx_raw()
1293 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in idt77252_rx_raw()
1296 card->name, vpi, vci); in idt77252_rx_raw()
1304 card->name, vpi, vci); in idt77252_rx_raw()
1311 card->name); in idt77252_rx_raw()
1318 card->name); in idt77252_rx_raw()
1346 next = sb_pool_skb(card, handle); in idt77252_rx_raw()
1347 recycle_rx_skb(card, queue); in idt77252_rx_raw()
1350 card->raw_cell_head = next; in idt77252_rx_raw()
1351 queue = card->raw_cell_head; in idt77252_rx_raw()
1352 dma_sync_single_for_cpu(&card->pcidev->dev, in idt77252_rx_raw()
1358 card->raw_cell_head = NULL; in idt77252_rx_raw()
1360 card->name); in idt77252_rx_raw()
1375 init_tsq(struct idt77252_dev *card) in init_tsq() argument
1379 card->tsq.base = dma_alloc_coherent(&card->pcidev->dev, RSQSIZE, in init_tsq()
1380 &card->tsq.paddr, GFP_KERNEL); in init_tsq()
1381 if (card->tsq.base == NULL) { in init_tsq()
1382 printk("%s: can't allocate TSQ.\n", card->name); in init_tsq()
1385 memset(card->tsq.base, 0, TSQSIZE); in init_tsq()
1387 card->tsq.last = card->tsq.base + TSQ_NUM_ENTRIES - 1; in init_tsq()
1388 card->tsq.next = card->tsq.last; in init_tsq()
1389 for (tsqe = card->tsq.base; tsqe <= card->tsq.last; tsqe++) in init_tsq()
1392 writel(card->tsq.paddr, SAR_REG_TSQB); in init_tsq()
1393 writel((unsigned long) card->tsq.next - (unsigned long) card->tsq.base, in init_tsq()
1400 deinit_tsq(struct idt77252_dev *card) in deinit_tsq() argument
1402 dma_free_coherent(&card->pcidev->dev, TSQSIZE, in deinit_tsq()
1403 card->tsq.base, card->tsq.paddr); in deinit_tsq()
1407 idt77252_tx(struct idt77252_dev *card) in idt77252_tx() argument
1414 if (card->tsq.next == card->tsq.last) in idt77252_tx()
1415 tsqe = card->tsq.base; in idt77252_tx()
1417 tsqe = card->tsq.next + 1; in idt77252_tx()
1420 card->tsq.base, card->tsq.next, card->tsq.last); in idt77252_tx()
1438 TXPRINTK("%s: Timer RollOver detected.\n", card->name); in idt77252_tx()
1448 card->name, in idt77252_tx()
1454 vc = card->vcs[conn & 0x1fff]; in idt77252_tx()
1457 card->name, conn & 0x1fff); in idt77252_tx()
1462 card->name, vc->index); in idt77252_tx()
1471 vc = card->vcs[conn & 0x1fff]; in idt77252_tx()
1474 card->name, in idt77252_tx()
1479 drain_scq(card, vc); in idt77252_tx()
1489 if (vpi >= (1 << card->vpibits) || in idt77252_tx()
1490 vci >= (1 << card->vcibits)) { in idt77252_tx()
1493 card->name, vpi, vci); in idt77252_tx()
1497 vc = card->vcs[VPCI2VC(card, vpi, vci)]; in idt77252_tx()
1501 card->name, vpi, vci); in idt77252_tx()
1505 drain_scq(card, vc); in idt77252_tx()
1511 card->tsq.next = tsqe; in idt77252_tx()
1512 if (card->tsq.next == card->tsq.last) in idt77252_tx()
1513 tsqe = card->tsq.base; in idt77252_tx()
1515 tsqe = card->tsq.next + 1; in idt77252_tx()
1518 card->tsq.base, card->tsq.next, card->tsq.last); in idt77252_tx()
1524 writel((unsigned long)card->tsq.next - (unsigned long)card->tsq.base, in idt77252_tx()
1528 card->index, readl(SAR_REG_TSQH), in idt77252_tx()
1529 readl(SAR_REG_TSQT), card->tsq.next); in idt77252_tx()
1536 struct idt77252_dev *card = (struct idt77252_dev *)data; in tst_timer() local
1542 spin_lock_irqsave(&card->tst_lock, flags); in tst_timer()
1544 base = card->tst[card->tst_index]; in tst_timer()
1545 idle = card->tst[card->tst_index ^ 1]; in tst_timer()
1547 if (test_bit(TST_SWITCH_WAIT, &card->tst_state)) { in tst_timer()
1548 jump = base + card->tst_size - 2; in tst_timer()
1551 if ((pc ^ idle) & ~(card->tst_size - 1)) { in tst_timer()
1552 mod_timer(&card->tst_timer, jiffies + 1); in tst_timer()
1556 clear_bit(TST_SWITCH_WAIT, &card->tst_state); in tst_timer()
1558 card->tst_index ^= 1; in tst_timer()
1559 write_sram(card, jump, TSTE_OPC_JMP | (base << 2)); in tst_timer()
1561 base = card->tst[card->tst_index]; in tst_timer()
1562 idle = card->tst[card->tst_index ^ 1]; in tst_timer()
1564 for (e = 0; e < card->tst_size - 2; e++) { in tst_timer()
1565 if (card->soft_tst[e].tste & TSTE_PUSH_IDLE) { in tst_timer()
1566 write_sram(card, idle + e, in tst_timer()
1567 card->soft_tst[e].tste & TSTE_MASK); in tst_timer()
1568 card->soft_tst[e].tste &= ~(TSTE_PUSH_IDLE); in tst_timer()
1573 if (test_and_clear_bit(TST_SWITCH_PENDING, &card->tst_state)) { in tst_timer()
1575 for (e = 0; e < card->tst_size - 2; e++) { in tst_timer()
1576 if (card->soft_tst[e].tste & TSTE_PUSH_ACTIVE) { in tst_timer()
1577 write_sram(card, idle + e, in tst_timer()
1578 card->soft_tst[e].tste & TSTE_MASK); in tst_timer()
1579 card->soft_tst[e].tste &= ~(TSTE_PUSH_ACTIVE); in tst_timer()
1580 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in tst_timer()
1584 jump = base + card->tst_size - 2; in tst_timer()
1586 write_sram(card, jump, TSTE_OPC_NULL); in tst_timer()
1587 set_bit(TST_SWITCH_WAIT, &card->tst_state); in tst_timer()
1589 mod_timer(&card->tst_timer, jiffies + 1); in tst_timer()
1593 spin_unlock_irqrestore(&card->tst_lock, flags); in tst_timer()
1597 __fill_tst(struct idt77252_dev *card, struct vc_map *vc, in __fill_tst() argument
1605 avail = card->tst_size - 2; in __fill_tst()
1607 if (card->soft_tst[e].vc == NULL) in __fill_tst()
1611 printk("%s: No free TST entries found\n", card->name); in __fill_tst()
1616 card->name, vc ? vc->index : -1, e); in __fill_tst()
1624 idle = card->tst[card->tst_index ^ 1]; in __fill_tst()
1630 if ((cl >= avail) && (card->soft_tst[e].vc == NULL)) { in __fill_tst()
1632 card->soft_tst[e].vc = vc; in __fill_tst()
1634 card->soft_tst[e].vc = (void *)-1; in __fill_tst()
1636 card->soft_tst[e].tste = data; in __fill_tst()
1637 if (timer_pending(&card->tst_timer)) in __fill_tst()
1638 card->soft_tst[e].tste |= TSTE_PUSH_ACTIVE; in __fill_tst()
1640 write_sram(card, idle + e, data); in __fill_tst()
1641 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in __fill_tst()
1644 cl -= card->tst_size; in __fill_tst()
1657 fill_tst(struct idt77252_dev *card, struct vc_map *vc, int n, unsigned int opc) in fill_tst() argument
1662 spin_lock_irqsave(&card->tst_lock, flags); in fill_tst()
1664 res = __fill_tst(card, vc, n, opc); in fill_tst()
1666 set_bit(TST_SWITCH_PENDING, &card->tst_state); in fill_tst()
1667 if (!timer_pending(&card->tst_timer)) in fill_tst()
1668 mod_timer(&card->tst_timer, jiffies + 1); in fill_tst()
1670 spin_unlock_irqrestore(&card->tst_lock, flags); in fill_tst()
1675 __clear_tst(struct idt77252_dev *card, struct vc_map *vc) in __clear_tst() argument
1680 idle = card->tst[card->tst_index ^ 1]; in __clear_tst()
1682 for (e = 0; e < card->tst_size - 2; e++) { in __clear_tst()
1683 if (card->soft_tst[e].vc == vc) { in __clear_tst()
1684 card->soft_tst[e].vc = NULL; in __clear_tst()
1686 card->soft_tst[e].tste = TSTE_OPC_VAR; in __clear_tst()
1687 if (timer_pending(&card->tst_timer)) in __clear_tst()
1688 card->soft_tst[e].tste |= TSTE_PUSH_ACTIVE; in __clear_tst()
1690 write_sram(card, idle + e, TSTE_OPC_VAR); in __clear_tst()
1691 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; in __clear_tst()
1700 clear_tst(struct idt77252_dev *card, struct vc_map *vc) in clear_tst() argument
1705 spin_lock_irqsave(&card->tst_lock, flags); in clear_tst()
1707 res = __clear_tst(card, vc); in clear_tst()
1709 set_bit(TST_SWITCH_PENDING, &card->tst_state); in clear_tst()
1710 if (!timer_pending(&card->tst_timer)) in clear_tst()
1711 mod_timer(&card->tst_timer, jiffies + 1); in clear_tst()
1713 spin_unlock_irqrestore(&card->tst_lock, flags); in clear_tst()
1718 change_tst(struct idt77252_dev *card, struct vc_map *vc, in change_tst() argument
1724 spin_lock_irqsave(&card->tst_lock, flags); in change_tst()
1726 __clear_tst(card, vc); in change_tst()
1727 res = __fill_tst(card, vc, n, opc); in change_tst()
1729 set_bit(TST_SWITCH_PENDING, &card->tst_state); in change_tst()
1730 if (!timer_pending(&card->tst_timer)) in change_tst()
1731 mod_timer(&card->tst_timer, jiffies + 1); in change_tst()
1733 spin_unlock_irqrestore(&card->tst_lock, flags); in change_tst()
1739 set_tct(struct idt77252_dev *card, struct vc_map *vc) in set_tct() argument
1743 tct = (unsigned long) (card->tct_base + vc->index * SAR_SRAM_TCT_SIZE); in set_tct()
1748 card->name, tct, vc->scq->scd); in set_tct()
1750 write_sram(card, tct + 0, TCT_CBR | vc->scq->scd); in set_tct()
1751 write_sram(card, tct + 1, 0); in set_tct()
1752 write_sram(card, tct + 2, 0); in set_tct()
1753 write_sram(card, tct + 3, 0); in set_tct()
1754 write_sram(card, tct + 4, 0); in set_tct()
1755 write_sram(card, tct + 5, 0); in set_tct()
1756 write_sram(card, tct + 6, 0); in set_tct()
1757 write_sram(card, tct + 7, 0); in set_tct()
1762 card->name, tct, vc->scq->scd); in set_tct()
1764 write_sram(card, tct + 0, TCT_UBR | vc->scq->scd); in set_tct()
1765 write_sram(card, tct + 1, 0); in set_tct()
1766 write_sram(card, tct + 2, TCT_TSIF); in set_tct()
1767 write_sram(card, tct + 3, TCT_HALT | TCT_IDLE); in set_tct()
1768 write_sram(card, tct + 4, 0); in set_tct()
1769 write_sram(card, tct + 5, vc->init_er); in set_tct()
1770 write_sram(card, tct + 6, 0); in set_tct()
1771 write_sram(card, tct + 7, TCT_FLAG_UBR); in set_tct()
1790 idt77252_fbq_level(struct idt77252_dev *card, int queue) in idt77252_fbq_level() argument
1796 idt77252_fbq_full(struct idt77252_dev *card, int queue) in idt77252_fbq_full() argument
1802 push_rx_skb(struct idt77252_dev *card, struct sk_buff *skb, int queue) in push_rx_skb() argument
1831 if (idt77252_fbq_full(card, queue)) in push_rx_skb()
1839 spin_lock_irqsave(&card->cmd_lock, flags); in push_rx_skb()
1840 writel(handle, card->fbq[queue]); in push_rx_skb()
1841 writel(addr, card->fbq[queue]); in push_rx_skb()
1842 spin_unlock_irqrestore(&card->cmd_lock, flags); in push_rx_skb()
1848 add_rx_skb(struct idt77252_dev *card, int queue, in add_rx_skb() argument
1860 if (sb_pool_add(card, skb, queue)) { in add_rx_skb()
1865 paddr = dma_map_single(&card->pcidev->dev, skb->data, in add_rx_skb()
1870 if (push_rx_skb(card, skb, queue)) { in add_rx_skb()
1879 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in add_rx_skb()
1883 card->sbpool[POOL_QUEUE(handle)].skb[POOL_INDEX(handle)] = NULL; in add_rx_skb()
1891 recycle_rx_skb(struct idt77252_dev *card, struct sk_buff *skb) in recycle_rx_skb() argument
1896 dma_sync_single_for_device(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in recycle_rx_skb()
1900 err = push_rx_skb(card, skb, POOL_QUEUE(handle)); in recycle_rx_skb()
1902 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), in recycle_rx_skb()
1905 sb_pool_remove(card, skb); in recycle_rx_skb()
1911 flush_rx_pool(struct idt77252_dev *card, struct rx_pool *rpp) in flush_rx_pool() argument
1918 recycle_rx_pool_skb(struct idt77252_dev *card, struct rx_pool *rpp) in recycle_rx_pool_skb() argument
1923 recycle_rx_skb(card, skb); in recycle_rx_pool_skb()
1925 flush_rx_pool(card, rpp); in recycle_rx_pool_skb()
1950 struct idt77252_dev *card = dev->dev_data; in idt77252_send_skb() local
1955 printk("%s: NULL connection in send().\n", card->name); in idt77252_send_skb()
1961 printk("%s: Trying to transmit on a non-tx VC.\n", card->name); in idt77252_send_skb()
1973 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); in idt77252_send_skb()
1980 printk("%s: No scatter-gather yet.\n", card->name); in idt77252_send_skb()
1987 err = queue_skb(card, vc, skb, oam); in idt77252_send_skb()
2006 struct idt77252_dev *card = dev->dev_data; in idt77252_send_oam() local
2011 printk("%s: Out of memory in send_oam().\n", card->name); in idt77252_send_oam()
2068 idt77252_rate_logindex(struct idt77252_dev *card, int pcr) in idt77252_rate_logindex() argument
2082 struct idt77252_dev *card = vc->card; in idt77252_est_timer() local
2105 lacr = idt77252_rate_logindex(card, cps); in idt77252_est_timer()
2146 idt77252_init_cbr(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_cbr() argument
2156 card->name); in idt77252_init_cbr()
2161 tst_free = card->tst_free; in idt77252_init_cbr()
2169 TXPRINTK("%s: CBR target cell rate = %d\n", card->name, tcra); in idt77252_init_cbr()
2171 tmpl = (unsigned long) tcra * ((unsigned long) card->tst_size - 2); in idt77252_init_cbr()
2172 modl = tmpl % (unsigned long)card->utopia_pcr; in idt77252_init_cbr()
2174 tst_entries = (int) (tmpl / card->utopia_pcr); in idt77252_init_cbr()
2181 printk("%s: no CBR bandwidth free.\n", card->name); in idt77252_init_cbr()
2188 card->name); in idt77252_init_cbr()
2193 printk("%s: not enough CBR bandwidth free.\n", card->name); in idt77252_init_cbr()
2199 card->tst_free = tst_free - tst_entries; in idt77252_init_cbr()
2205 card->name, tst_used, tst_entries); in idt77252_init_cbr()
2206 change_tst(card, vc, tst_entries, TSTE_OPC_CBR); in idt77252_init_cbr()
2210 OPRINTK("%s: setting %d entries in TST.\n", card->name, tst_entries); in idt77252_init_cbr()
2211 fill_tst(card, vc, tst_entries, TSTE_OPC_CBR); in idt77252_init_cbr()
2216 idt77252_init_ubr(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_ubr() argument
2232 tcr = card->link_pcr; in idt77252_init_ubr()
2237 vc->init_er = idt77252_rate_logindex(card, tcr); in idt77252_init_ubr()
2248 idt77252_init_tx(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_tx() argument
2271 vc->scq = alloc_scq(card, vc->class); in idt77252_init_tx()
2273 printk("%s: can't get SCQ.\n", card->name); in idt77252_init_tx()
2277 vc->scq->scd = get_free_scd(card, vc); in idt77252_init_tx()
2279 printk("%s: no SCD available.\n", card->name); in idt77252_init_tx()
2280 free_scq(card, vc->scq); in idt77252_init_tx()
2284 fill_scd(card, vc->scq, vc->class); in idt77252_init_tx()
2286 if (set_tct(card, vc)) { in idt77252_init_tx()
2288 card->name, qos->txtp.traffic_class); in idt77252_init_tx()
2290 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2291 free_scq(card, vc->scq); in idt77252_init_tx()
2297 error = idt77252_init_cbr(card, vc, vcc, qos); in idt77252_init_tx()
2299 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2300 free_scq(card, vc->scq); in idt77252_init_tx()
2309 error = idt77252_init_ubr(card, vc, vcc, qos); in idt77252_init_tx()
2311 card->scd2vc[vc->scd_index] = NULL; in idt77252_init_tx()
2312 free_scq(card, vc->scq); in idt77252_init_tx()
2326 idt77252_init_rx(struct idt77252_dev *card, struct vc_map *vc, in idt77252_init_rx() argument
2342 flush_rx_pool(card, &vc->rcv.rx_pool); in idt77252_init_rx()
2376 addr = card->rct_base + (vc->index << 2); in idt77252_init_rx()
2378 OPRINTK("%s: writing RCT at 0x%lx\n", card->name, addr); in idt77252_init_rx()
2379 write_sram(card, addr, rcte); in idt77252_init_rx()
2381 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_init_rx()
2383 waitfor_idle(card); in idt77252_init_rx()
2384 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_init_rx()
2393 struct idt77252_dev *card = dev->dev_data; in idt77252_open() local
2404 if (vpi >= (1 << card->vpibits)) { in idt77252_open()
2405 printk("%s: unsupported VPI: %d\n", card->name, vpi); in idt77252_open()
2409 if (vci >= (1 << card->vcibits)) { in idt77252_open()
2410 printk("%s: unsupported VCI: %d\n", card->name, vci); in idt77252_open()
2416 mutex_lock(&card->mutex); in idt77252_open()
2418 OPRINTK("%s: opening vpi.vci: %d.%d\n", card->name, vpi, vci); in idt77252_open()
2426 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); in idt77252_open()
2427 mutex_unlock(&card->mutex); in idt77252_open()
2431 index = VPCI2VC(card, vpi, vci); in idt77252_open()
2432 if (!card->vcs[index]) { in idt77252_open()
2433 card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL); in idt77252_open()
2434 if (!card->vcs[index]) { in idt77252_open()
2435 printk("%s: can't alloc vc in open()\n", card->name); in idt77252_open()
2436 mutex_unlock(&card->mutex); in idt77252_open()
2439 card->vcs[index]->card = card; in idt77252_open()
2440 card->vcs[index]->index = index; in idt77252_open()
2442 spin_lock_init(&card->vcs[index]->lock); in idt77252_open()
2444 vc = card->vcs[index]; in idt77252_open()
2449 card->name, vc->index, vcc->vpi, vcc->vci, in idt77252_open()
2463 printk("%s: %s vci already in use.\n", card->name, in idt77252_open()
2465 mutex_unlock(&card->mutex); in idt77252_open()
2470 error = idt77252_init_tx(card, vc, vcc, &vcc->qos); in idt77252_open()
2472 mutex_unlock(&card->mutex); in idt77252_open()
2478 error = idt77252_init_rx(card, vc, vcc, &vcc->qos); in idt77252_open()
2480 mutex_unlock(&card->mutex); in idt77252_open()
2487 mutex_unlock(&card->mutex); in idt77252_open()
2495 struct idt77252_dev *card = dev->dev_data; in idt77252_close() local
2501 mutex_lock(&card->mutex); in idt77252_close()
2504 card->name, vc->index, vcc->vpi, vcc->vci); in idt77252_close()
2518 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; in idt77252_close()
2520 spin_lock_irqsave(&card->cmd_lock, flags); in idt77252_close()
2522 waitfor_idle(card); in idt77252_close()
2523 spin_unlock_irqrestore(&card->cmd_lock, flags); in idt77252_close()
2527 card->name); in idt77252_close()
2529 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); in idt77252_close()
2554 card->name, atomic_read(&vc->scq->used)); in idt77252_close()
2560 clear_scd(card, vc->scq, vc->class); in idt77252_close()
2563 clear_tst(card, vc); in idt77252_close()
2564 card->tst_free += vc->ntste; in idt77252_close()
2568 card->scd2vc[vc->scd_index] = NULL; in idt77252_close()
2569 free_scq(card, vc->scq); in idt77252_close()
2572 mutex_unlock(&card->mutex); in idt77252_close()
2579 struct idt77252_dev *card = dev->dev_data; in idt77252_change_qos() local
2583 mutex_lock(&card->mutex); in idt77252_change_qos()
2587 error = idt77252_init_tx(card, vc, vcc, qos); in idt77252_change_qos()
2593 error = idt77252_init_cbr(card, vc, vcc, qos); in idt77252_change_qos()
2599 error = idt77252_init_ubr(card, vc, vcc, qos); in idt77252_change_qos()
2619 error = idt77252_init_rx(card, vc, vcc, qos); in idt77252_change_qos()
2629 mutex_unlock(&card->mutex); in idt77252_change_qos()
2636 struct idt77252_dev *card = dev->dev_data; in idt77252_proc_read() local
2643 return sprintf(page, "TSIF: %lu\n", card->irqstat[15]); in idt77252_proc_read()
2645 return sprintf(page, "TXICP: %lu\n", card->irqstat[14]); in idt77252_proc_read()
2647 return sprintf(page, "TSQF: %lu\n", card->irqstat[12]); in idt77252_proc_read()
2649 return sprintf(page, "TMROF: %lu\n", card->irqstat[11]); in idt77252_proc_read()
2651 return sprintf(page, "PHYI: %lu\n", card->irqstat[10]); in idt77252_proc_read()
2653 return sprintf(page, "FBQ3A: %lu\n", card->irqstat[8]); in idt77252_proc_read()
2655 return sprintf(page, "FBQ2A: %lu\n", card->irqstat[7]); in idt77252_proc_read()
2657 return sprintf(page, "RSQF: %lu\n", card->irqstat[6]); in idt77252_proc_read()
2659 return sprintf(page, "EPDU: %lu\n", card->irqstat[5]); in idt77252_proc_read()
2661 return sprintf(page, "RAWCF: %lu\n", card->irqstat[4]); in idt77252_proc_read()
2663 return sprintf(page, "FBQ1A: %lu\n", card->irqstat[3]); in idt77252_proc_read()
2665 return sprintf(page, "FBQ0A: %lu\n", card->irqstat[2]); in idt77252_proc_read()
2667 return sprintf(page, "RSQAF: %lu\n", card->irqstat[1]); in idt77252_proc_read()
2671 for (i = 0; i < card->tct_size; i++) { in idt77252_proc_read()
2677 vc = card->vcs[i]; in idt77252_proc_read()
2691 tct = (unsigned long) (card->tct_base + i * SAR_SRAM_TCT_SIZE); in idt77252_proc_read()
2694 p += sprintf(p, " %08x", read_sram(card, tct + i)); in idt77252_proc_read()
2708 idt77252_collect_stat(struct idt77252_dev *card) in idt77252_collect_stat() argument
2719 struct idt77252_dev *card = dev_id; in idt77252_interrupt() local
2726 if (test_and_set_bit(IDT77252_BIT_INTERRUPT, &card->flags)) { in idt77252_interrupt()
2727 printk("%s: Re-entering irq_handler()\n", card->name); in idt77252_interrupt()
2734 INTPRINTK("%s: TSIF\n", card->name); in idt77252_interrupt()
2735 card->irqstat[15]++; in idt77252_interrupt()
2736 idt77252_tx(card); in idt77252_interrupt()
2739 INTPRINTK("%s: TXICP\n", card->name); in idt77252_interrupt()
2740 card->irqstat[14]++; in idt77252_interrupt()
2742 idt77252_tx_dump(card); in idt77252_interrupt()
2746 INTPRINTK("%s: TSQF\n", card->name); in idt77252_interrupt()
2747 card->irqstat[12]++; in idt77252_interrupt()
2748 idt77252_tx(card); in idt77252_interrupt()
2751 INTPRINTK("%s: TMROF\n", card->name); in idt77252_interrupt()
2752 card->irqstat[11]++; in idt77252_interrupt()
2753 idt77252_collect_stat(card); in idt77252_interrupt()
2757 INTPRINTK("%s: EPDU\n", card->name); in idt77252_interrupt()
2758 card->irqstat[5]++; in idt77252_interrupt()
2759 idt77252_rx(card); in idt77252_interrupt()
2762 INTPRINTK("%s: RSQAF\n", card->name); in idt77252_interrupt()
2763 card->irqstat[1]++; in idt77252_interrupt()
2764 idt77252_rx(card); in idt77252_interrupt()
2767 INTPRINTK("%s: RSQF\n", card->name); in idt77252_interrupt()
2768 card->irqstat[6]++; in idt77252_interrupt()
2769 idt77252_rx(card); in idt77252_interrupt()
2772 INTPRINTK("%s: RAWCF\n", card->name); in idt77252_interrupt()
2773 card->irqstat[4]++; in idt77252_interrupt()
2774 idt77252_rx_raw(card); in idt77252_interrupt()
2778 INTPRINTK("%s: PHYI", card->name); in idt77252_interrupt()
2779 card->irqstat[10]++; in idt77252_interrupt()
2780 if (card->atmdev->phy && card->atmdev->phy->interrupt) in idt77252_interrupt()
2781 card->atmdev->phy->interrupt(card->atmdev); in idt77252_interrupt()
2789 INTPRINTK("%s: FBQA: %04x\n", card->name, stat); in idt77252_interrupt()
2792 card->irqstat[2]++; in idt77252_interrupt()
2794 card->irqstat[3]++; in idt77252_interrupt()
2796 card->irqstat[7]++; in idt77252_interrupt()
2798 card->irqstat[8]++; in idt77252_interrupt()
2800 schedule_work(&card->tqueue); in idt77252_interrupt()
2804 clear_bit(IDT77252_BIT_INTERRUPT, &card->flags); in idt77252_interrupt()
2811 struct idt77252_dev *card = in idt77252_softint() local
2820 add_rx_skb(card, 0, SAR_FB_SIZE_0, 32); in idt77252_softint()
2826 add_rx_skb(card, 1, SAR_FB_SIZE_1, 32); in idt77252_softint()
2832 add_rx_skb(card, 2, SAR_FB_SIZE_2, 32); in idt77252_softint()
2838 add_rx_skb(card, 3, SAR_FB_SIZE_3, 32); in idt77252_softint()
2851 open_card_oam(struct idt77252_dev *card) in open_card_oam() argument
2860 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { in open_card_oam()
2862 index = VPCI2VC(card, vpi, vci); in open_card_oam()
2866 printk("%s: can't alloc vc\n", card->name); in open_card_oam()
2870 card->vcs[index] = vc; in open_card_oam()
2872 flush_rx_pool(card, &vc->rcv.rx_pool); in open_card_oam()
2879 addr = card->rct_base + (vc->index << 2); in open_card_oam()
2880 write_sram(card, addr, rcte); in open_card_oam()
2882 spin_lock_irqsave(&card->cmd_lock, flags); in open_card_oam()
2885 waitfor_idle(card); in open_card_oam()
2886 spin_unlock_irqrestore(&card->cmd_lock, flags); in open_card_oam()
2894 close_card_oam(struct idt77252_dev *card) in close_card_oam() argument
2902 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { in close_card_oam()
2904 index = VPCI2VC(card, vpi, vci); in close_card_oam()
2905 vc = card->vcs[index]; in close_card_oam()
2907 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; in close_card_oam()
2909 spin_lock_irqsave(&card->cmd_lock, flags); in close_card_oam()
2912 waitfor_idle(card); in close_card_oam()
2913 spin_unlock_irqrestore(&card->cmd_lock, flags); in close_card_oam()
2918 card->name); in close_card_oam()
2920 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); in close_card_oam()
2927 open_card_ubr0(struct idt77252_dev *card) in open_card_ubr0() argument
2933 printk("%s: can't alloc vc\n", card->name); in open_card_ubr0()
2936 card->vcs[0] = vc; in open_card_ubr0()
2939 vc->scq = alloc_scq(card, vc->class); in open_card_ubr0()
2941 printk("%s: can't get SCQ.\n", card->name); in open_card_ubr0()
2945 card->scd2vc[0] = vc; in open_card_ubr0()
2947 vc->scq->scd = card->scd_base; in open_card_ubr0()
2949 fill_scd(card, vc->scq, vc->class); in open_card_ubr0()
2951 write_sram(card, card->tct_base + 0, TCT_UBR | card->scd_base); in open_card_ubr0()
2952 write_sram(card, card->tct_base + 1, 0); in open_card_ubr0()
2953 write_sram(card, card->tct_base + 2, 0); in open_card_ubr0()
2954 write_sram(card, card->tct_base + 3, 0); in open_card_ubr0()
2955 write_sram(card, card->tct_base + 4, 0); in open_card_ubr0()
2956 write_sram(card, card->tct_base + 5, 0); in open_card_ubr0()
2957 write_sram(card, card->tct_base + 6, 0); in open_card_ubr0()
2958 write_sram(card, card->tct_base + 7, TCT_FLAG_UBR); in open_card_ubr0()
2966 idt77252_dev_open(struct idt77252_dev *card) in idt77252_dev_open() argument
2970 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { in idt77252_dev_open()
2971 printk("%s: SAR not yet initialized.\n", card->name); in idt77252_dev_open()
2995 if (open_card_oam(card)) { in idt77252_dev_open()
2996 printk("%s: Error initializing OAM.\n", card->name); in idt77252_dev_open()
3000 if (open_card_ubr0(card)) { in idt77252_dev_open()
3001 printk("%s: Error initializing UBR0.\n", card->name); in idt77252_dev_open()
3005 IPRINTK("%s: opened IDT77252 ABR SAR.\n", card->name); in idt77252_dev_open()
3011 struct idt77252_dev *card = dev->dev_data; in idt77252_dev_close() local
3014 close_card_oam(card); in idt77252_dev_close()
3030 DIPRINTK("%s: closed IDT77252 ABR SAR.\n", card->name); in idt77252_dev_close()
3042 deinit_card(struct idt77252_dev *card) in deinit_card() argument
3047 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { in deinit_card()
3048 printk("%s: SAR not yet initialized.\n", card->name); in deinit_card()
3051 DIPRINTK("idt77252: deinitialize card %u\n", card->index); in deinit_card()
3055 if (card->atmdev) in deinit_card()
3056 atm_dev_deregister(card->atmdev); in deinit_card()
3060 skb = card->sbpool[i].skb[j]; in deinit_card()
3062 dma_unmap_single(&card->pcidev->dev, in deinit_card()
3067 card->sbpool[i].skb[j] = NULL; in deinit_card()
3073 vfree(card->soft_tst); in deinit_card()
3075 vfree(card->scd2vc); in deinit_card()
3077 vfree(card->vcs); in deinit_card()
3079 if (card->raw_cell_hnd) { in deinit_card()
3080 dma_free_coherent(&card->pcidev->dev, 2 * sizeof(u32), in deinit_card()
3081 card->raw_cell_hnd, card->raw_cell_paddr); in deinit_card()
3084 if (card->rsq.base) { in deinit_card()
3085 DIPRINTK("%s: Release RSQ ...\n", card->name); in deinit_card()
3086 deinit_rsq(card); in deinit_card()
3089 if (card->tsq.base) { in deinit_card()
3090 DIPRINTK("%s: Release TSQ ...\n", card->name); in deinit_card()
3091 deinit_tsq(card); in deinit_card()
3095 free_irq(card->pcidev->irq, card); in deinit_card()
3098 if (card->fbq[i]) in deinit_card()
3099 iounmap(card->fbq[i]); in deinit_card()
3102 if (card->membase) in deinit_card()
3103 iounmap(card->membase); in deinit_card()
3105 clear_bit(IDT77252_BIT_INIT, &card->flags); in deinit_card()
3106 DIPRINTK("%s: Card deinitialized.\n", card->name); in deinit_card()
3110 static void init_sram(struct idt77252_dev *card) in init_sram() argument
3114 for (i = 0; i < card->sramsize; i += 4) in init_sram()
3115 write_sram(card, (i >> 2), 0); in init_sram()
3118 if (card->sramsize == (512 * 1024)) { in init_sram()
3119 card->tct_base = SAR_SRAM_TCT_128_BASE; in init_sram()
3120 card->tct_size = (SAR_SRAM_TCT_128_TOP - card->tct_base + 1) in init_sram()
3122 card->rct_base = SAR_SRAM_RCT_128_BASE; in init_sram()
3123 card->rct_size = (SAR_SRAM_RCT_128_TOP - card->rct_base + 1) in init_sram()
3125 card->rt_base = SAR_SRAM_RT_128_BASE; in init_sram()
3126 card->scd_base = SAR_SRAM_SCD_128_BASE; in init_sram()
3127 card->scd_size = (SAR_SRAM_SCD_128_TOP - card->scd_base + 1) in init_sram()
3129 card->tst[0] = SAR_SRAM_TST1_128_BASE; in init_sram()
3130 card->tst[1] = SAR_SRAM_TST2_128_BASE; in init_sram()
3131 card->tst_size = SAR_SRAM_TST1_128_TOP - card->tst[0] + 1; in init_sram()
3132 card->abrst_base = SAR_SRAM_ABRSTD_128_BASE; in init_sram()
3133 card->abrst_size = SAR_ABRSTD_SIZE_8K; in init_sram()
3134 card->fifo_base = SAR_SRAM_FIFO_128_BASE; in init_sram()
3135 card->fifo_size = SAR_RXFD_SIZE_32K; in init_sram()
3137 card->tct_base = SAR_SRAM_TCT_32_BASE; in init_sram()
3138 card->tct_size = (SAR_SRAM_TCT_32_TOP - card->tct_base + 1) in init_sram()
3140 card->rct_base = SAR_SRAM_RCT_32_BASE; in init_sram()
3141 card->rct_size = (SAR_SRAM_RCT_32_TOP - card->rct_base + 1) in init_sram()
3143 card->rt_base = SAR_SRAM_RT_32_BASE; in init_sram()
3144 card->scd_base = SAR_SRAM_SCD_32_BASE; in init_sram()
3145 card->scd_size = (SAR_SRAM_SCD_32_TOP - card->scd_base + 1) in init_sram()
3147 card->tst[0] = SAR_SRAM_TST1_32_BASE; in init_sram()
3148 card->tst[1] = SAR_SRAM_TST2_32_BASE; in init_sram()
3149 card->tst_size = (SAR_SRAM_TST1_32_TOP - card->tst[0] + 1); in init_sram()
3150 card->abrst_base = SAR_SRAM_ABRSTD_32_BASE; in init_sram()
3151 card->abrst_size = SAR_ABRSTD_SIZE_1K; in init_sram()
3152 card->fifo_base = SAR_SRAM_FIFO_32_BASE; in init_sram()
3153 card->fifo_size = SAR_RXFD_SIZE_4K; in init_sram()
3157 for (i = 0; i < card->tct_size; i++) { in init_sram()
3158 write_sram(card, i * SAR_SRAM_TCT_SIZE + 0, 0); in init_sram()
3159 write_sram(card, i * SAR_SRAM_TCT_SIZE + 1, 0); in init_sram()
3160 write_sram(card, i * SAR_SRAM_TCT_SIZE + 2, 0); in init_sram()
3161 write_sram(card, i * SAR_SRAM_TCT_SIZE + 3, 0); in init_sram()
3162 write_sram(card, i * SAR_SRAM_TCT_SIZE + 4, 0); in init_sram()
3163 write_sram(card, i * SAR_SRAM_TCT_SIZE + 5, 0); in init_sram()
3164 write_sram(card, i * SAR_SRAM_TCT_SIZE + 6, 0); in init_sram()
3165 write_sram(card, i * SAR_SRAM_TCT_SIZE + 7, 0); in init_sram()
3169 for (i = 0; i < card->rct_size; i++) { in init_sram()
3170 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE, in init_sram()
3172 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 1, in init_sram()
3174 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 2, in init_sram()
3176 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 3, in init_sram()
3191 write_sram(card, card->rt_base + i, log_to_rate[i]); in init_sram()
3201 write_sram(card, card->rt_base + 256 + i, tmp); in init_sram()
3210 write_sram(card, card->rt_base + 512 + i, tmp); in init_sram()
3218 write_sram(card, card->rt_base + 640 + i, tmp); in init_sram()
3222 IPRINTK("%s: initialize rate table ...\n", card->name); in init_sram()
3223 writel(card->rt_base << 2, SAR_REG_RTBL); in init_sram()
3226 IPRINTK("%s: initialize TST ...\n", card->name); in init_sram()
3227 card->tst_free = card->tst_size - 2; /* last two are jumps */ in init_sram()
3229 for (i = card->tst[0]; i < card->tst[0] + card->tst_size - 2; i++) in init_sram()
3230 write_sram(card, i, TSTE_OPC_VAR); in init_sram()
3231 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); in init_sram()
3233 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); in init_sram()
3235 for (i = card->tst[1]; i < card->tst[1] + card->tst_size - 2; i++) in init_sram()
3236 write_sram(card, i, TSTE_OPC_VAR); in init_sram()
3237 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); in init_sram()
3239 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); in init_sram()
3242 card->tst_index = 0; in init_sram()
3243 writel(card->tst[0] << 2, SAR_REG_TSTB); in init_sram()
3246 IPRINTK("%s: initialize ABRSTD ...\n", card->name); in init_sram()
3247 writel(card->abrst_size | (card->abrst_base << 2), in init_sram()
3250 IPRINTK("%s: initialize receive fifo ...\n", card->name); in init_sram()
3251 writel(card->fifo_size | (card->fifo_base << 2), in init_sram()
3254 IPRINTK("%s: SRAM initialization complete.\n", card->name); in init_sram()
3259 struct idt77252_dev *card = dev->dev_data; in init_card() local
3260 struct pci_dev *pcidev = card->pcidev; in init_card()
3272 if (test_bit(IDT77252_BIT_INIT, &card->flags)) { in init_card()
3282 IPRINTK("%s: Checking PCI retries.\n", card->name); in init_card()
3284 printk("%s: can't read PCI retry timeout.\n", card->name); in init_card()
3285 deinit_card(card); in init_card()
3290 card->name, pci_byte); in init_card()
3293 card->name); in init_card()
3294 deinit_card(card); in init_card()
3298 IPRINTK("%s: Checking PCI TRDY.\n", card->name); in init_card()
3300 printk("%s: can't read PCI TRDY timeout.\n", card->name); in init_card()
3301 deinit_card(card); in init_card()
3306 card->name, pci_byte); in init_card()
3308 printk("%s: can't set PCI TRDY timeout.\n", card->name); in init_card()
3309 deinit_card(card); in init_card()
3315 printk("%s: resetting timer overflow.\n", card->name); in init_card()
3318 IPRINTK("%s: Request IRQ ... ", card->name); in init_card()
3320 card->name, card) != 0) { in init_card()
3321 printk("%s: can't allocate IRQ.\n", card->name); in init_card()
3322 deinit_card(card); in init_card()
3331 IPRINTK("%s: Initializing SRAM\n", card->name); in init_card()
3342 if (card->sramsize == (512 * 1024)) in init_card()
3365 init_sram(card); in init_card()
3371 if (0 != init_tsq(card)) { in init_card()
3372 deinit_card(card); in init_card()
3376 if (0 != init_rsq(card)) { in init_card()
3377 deinit_card(card); in init_card()
3381 card->vpibits = vpibits; in init_card()
3382 if (card->sramsize == (512 * 1024)) { in init_card()
3383 card->vcibits = 10 - card->vpibits; in init_card()
3385 card->vcibits = 9 - card->vpibits; in init_card()
3388 card->vcimask = 0; in init_card()
3389 for (k = 0, i = 1; k < card->vcibits; k++) { in init_card()
3390 card->vcimask |= i; in init_card()
3394 IPRINTK("%s: Setting VPI/VCI mask to zero.\n", card->name); in init_card()
3401 card->raw_cell_hnd = dma_zalloc_coherent(&card->pcidev->dev, in init_card()
3403 &card->raw_cell_paddr, in init_card()
3405 if (!card->raw_cell_hnd) { in init_card()
3406 printk("%s: memory allocation failure.\n", card->name); in init_card()
3407 deinit_card(card); in init_card()
3410 writel(card->raw_cell_paddr, SAR_REG_RAWHND); in init_card()
3411 IPRINTK("%s: raw cell handle is at 0x%p.\n", card->name, in init_card()
3412 card->raw_cell_hnd); in init_card()
3414 size = sizeof(struct vc_map *) * card->tct_size; in init_card()
3415 IPRINTK("%s: allocate %d byte for VC map.\n", card->name, size); in init_card()
3416 card->vcs = vzalloc(size); in init_card()
3417 if (!card->vcs) { in init_card()
3418 printk("%s: memory allocation failure.\n", card->name); in init_card()
3419 deinit_card(card); in init_card()
3423 size = sizeof(struct vc_map *) * card->scd_size; in init_card()
3425 card->name, size); in init_card()
3426 card->scd2vc = vzalloc(size); in init_card()
3427 if (!card->scd2vc) { in init_card()
3428 printk("%s: memory allocation failure.\n", card->name); in init_card()
3429 deinit_card(card); in init_card()
3433 size = sizeof(struct tst_info) * (card->tst_size - 2); in init_card()
3435 card->name, size); in init_card()
3436 card->soft_tst = vmalloc(size); in init_card()
3437 if (!card->soft_tst) { in init_card()
3438 printk("%s: memory allocation failure.\n", card->name); in init_card()
3439 deinit_card(card); in init_card()
3442 for (i = 0; i < card->tst_size - 2; i++) { in init_card()
3443 card->soft_tst[i].tste = TSTE_OPC_VAR; in init_card()
3444 card->soft_tst[i].vc = NULL; in init_card()
3448 printk("%s: No LT device defined.\n", card->name); in init_card()
3449 deinit_card(card); in init_card()
3453 printk("%s: LT had no IOCTL function defined.\n", card->name); in init_card()
3454 deinit_card(card); in init_card()
3471 card->link_pcr = (linkrate / 8 / 53); in init_card()
3473 card->name, linkrate, card->link_pcr); in init_card()
3476 card->utopia_pcr = card->link_pcr; in init_card()
3478 card->utopia_pcr = (160000000 / 8 / 54); in init_card()
3482 if (card->utopia_pcr > card->link_pcr) in init_card()
3483 rsvdcr = card->utopia_pcr - card->link_pcr; in init_card()
3485 tmpl = (unsigned long) rsvdcr * ((unsigned long) card->tst_size - 2); in init_card()
3486 modl = tmpl % (unsigned long)card->utopia_pcr; in init_card()
3487 tst_entries = (int) (tmpl / (unsigned long)card->utopia_pcr); in init_card()
3490 card->tst_free -= tst_entries; in init_card()
3491 fill_tst(card, NULL, tst_entries, TSTE_OPC_NULL); in init_card()
3494 idt77252_eeprom_init(card); in init_card()
3495 printk("%s: EEPROM: %02x:", card->name, in init_card()
3496 idt77252_eeprom_read_status(card)); in init_card()
3500 idt77252_eeprom_read_byte(card, i) in init_card()
3509 sprintf(tname, "eth%d", card->index); in init_card()
3512 memcpy(card->atmdev->esi, tmp->dev_addr, 6); in init_card()
3514 printk("%s: ESI %pM\n", card->name, card->atmdev->esi); in init_card()
3523 set_bit(IDT77252_BIT_INIT, &card->flags); in init_card()
3525 XPRINTK("%s: IDT77252 ABR SAR initialization complete.\n", card->name); in init_card()
3537 static int idt77252_preset(struct idt77252_dev *card) in idt77252_preset() argument
3546 card->name); in idt77252_preset()
3547 if (pci_read_config_word(card->pcidev, PCI_COMMAND, &pci_command)) { in idt77252_preset()
3548 printk("%s: can't read PCI_COMMAND.\n", card->name); in idt77252_preset()
3549 deinit_card(card); in idt77252_preset()
3554 card->name, pci_command); in idt77252_preset()
3555 deinit_card(card); in idt77252_preset()
3559 if (pci_write_config_word(card->pcidev, PCI_COMMAND, pci_command)) { in idt77252_preset()
3560 printk("%s: can't write PCI_COMMAND.\n", card->name); in idt77252_preset()
3561 deinit_card(card); in idt77252_preset()
3573 IPRINTK("%s: Software resetted.\n", card->name); in idt77252_preset()
3578 static unsigned long probe_sram(struct idt77252_dev *card) in probe_sram() argument
3606 struct idt77252_dev *card; in idt77252_init_one() local
3621 card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL); in idt77252_init_one()
3622 if (!card) { in idt77252_init_one()
3627 card->revision = pcidev->revision; in idt77252_init_one()
3628 card->index = index; in idt77252_init_one()
3629 card->pcidev = pcidev; in idt77252_init_one()
3630 sprintf(card->name, "idt77252-%d", card->index); in idt77252_init_one()
3632 INIT_WORK(&card->tqueue, idt77252_softint); in idt77252_init_one()
3637 mutex_init(&card->mutex); in idt77252_init_one()
3638 spin_lock_init(&card->cmd_lock); in idt77252_init_one()
3639 spin_lock_init(&card->tst_lock); in idt77252_init_one()
3641 init_timer(&card->tst_timer); in idt77252_init_one()
3642 card->tst_timer.data = (unsigned long)card; in idt77252_init_one()
3643 card->tst_timer.function = tst_timer; in idt77252_init_one()
3646 card->membase = ioremap(membase, 1024); in idt77252_init_one()
3647 if (!card->membase) { in idt77252_init_one()
3648 printk("%s: can't ioremap() membase\n", card->name); in idt77252_init_one()
3653 if (idt77252_preset(card)) { in idt77252_init_one()
3654 printk("%s: preset failed\n", card->name); in idt77252_init_one()
3662 printk("%s: can't register atm device\n", card->name); in idt77252_init_one()
3666 dev->dev_data = card; in idt77252_init_one()
3667 card->atmdev = dev; in idt77252_init_one()
3672 printk("%s: can't init SUNI\n", card->name); in idt77252_init_one()
3678 card->sramsize = probe_sram(card); in idt77252_init_one()
3681 card->fbq[i] = ioremap(srambase | 0x200000 | (i << 18), 4); in idt77252_init_one()
3682 if (!card->fbq[i]) { in idt77252_init_one()
3683 printk("%s: can't ioremap() FBQ%d\n", card->name, i); in idt77252_init_one()
3690 card->name, ((card->revision > 1) && (card->revision < 25)) ? in idt77252_init_one()
3691 'A' + card->revision - 1 : '?', membase, srambase, in idt77252_init_one()
3692 card->sramsize / 1024); in idt77252_init_one()
3695 printk("%s: init_card failed\n", card->name); in idt77252_init_one()
3700 dev->ci_range.vpi_bits = card->vpibits; in idt77252_init_one()
3701 dev->ci_range.vci_bits = card->vcibits; in idt77252_init_one()
3702 dev->link_rate = card->link_pcr; in idt77252_init_one()
3707 if (idt77252_dev_open(card)) { in idt77252_init_one()
3708 printk("%s: dev_open failed\n", card->name); in idt77252_init_one()
3713 *last = card; in idt77252_init_one()
3714 last = &card->next; in idt77252_init_one()
3724 deinit_card(card); in idt77252_init_one()
3727 iounmap(card->membase); in idt77252_init_one()
3730 kfree(card); in idt77252_init_one()
3771 struct idt77252_dev *card; in idt77252_exit() local
3777 card = idt77252_chain; in idt77252_exit()
3778 dev = card->atmdev; in idt77252_exit()
3779 idt77252_chain = card->next; in idt77252_exit()
3783 deinit_card(card); in idt77252_exit()
3784 pci_disable_device(card->pcidev); in idt77252_exit()
3785 kfree(card); in idt77252_exit()