Lines Matching refs:zatm_dev

130 #define zin_n(r) inl(zatm_dev->base+r*4)
131 #define zin(r) inl(zatm_dev->base+uPD98401_##r*4)
132 #define zout(v,r) outl(v,zatm_dev->base+uPD98401_##r*4)
145 static void zpokel(struct zatm_dev *zatm_dev,u32 value,u32 addr) in zpokel() argument
154 static u32 zpeekl(struct zatm_dev *zatm_dev,u32 addr) in zpeekl() argument
185 struct zatm_dev *zatm_dev; in refill_pool() local
192 zatm_dev = ZATM_DEV(dev); in refill_pool()
201 offset = zatm_dev->pool_info[pool].offset+ in refill_pool()
207 free = zpeekl(zatm_dev,zatm_dev->pool_base+2*pool) & in refill_pool()
210 if (free >= zatm_dev->pool_info[pool].low_water) return; in refill_pool()
212 zpeekl(zatm_dev,zatm_dev->pool_base+2*pool), in refill_pool()
213 zpeekl(zatm_dev,zatm_dev->pool_base+2*pool+1)); in refill_pool()
217 while (free < zatm_dev->pool_info[pool].high_water) { in refill_pool()
239 if (zatm_dev->last_free[pool]) in refill_pool()
240 ((struct rx_buffer_head *) (zatm_dev->last_free[pool]-> in refill_pool()
242 zatm_dev->last_free[pool] = skb; in refill_pool()
243 skb_queue_tail(&zatm_dev->pool[pool],skb); in refill_pool()
255 zpeekl(zatm_dev,zatm_dev->pool_base+2*pool), in refill_pool()
256 zpeekl(zatm_dev,zatm_dev->pool_base+2*pool+1)); in refill_pool()
286 struct zatm_dev *zatm_dev; in use_pool() local
290 zatm_dev = ZATM_DEV(dev); in use_pool()
291 if (!(zatm_dev->pool_info[pool].ref_count++)) { in use_pool()
292 skb_queue_head_init(&zatm_dev->pool[pool]); in use_pool()
298 zpokel(zatm_dev,((zatm_dev->pool_info[pool].low_water/4) << in use_pool()
302 zatm_dev->pool_base+pool*2); in use_pool()
303 zpokel(zatm_dev,(unsigned long) dummy,zatm_dev->pool_base+ in use_pool()
306 zatm_dev->last_free[pool] = NULL; in use_pool()
309 DPRINTK("pool %d: %d\n",pool,zatm_dev->pool_info[pool].ref_count); in use_pool()
364 static inline struct timeval exact_time(struct zatm_dev *zatm_dev,u32 ticks) in exact_time() argument
368 tmp = zatm_dev->last_time; in exact_time()
369 tmp.tv_usec += ((s64) (ticks-zatm_dev->last_clk)* in exact_time()
370 (s64) zatm_dev->factor) >> TIMER_SHIFT; in exact_time()
378 struct zatm_dev *zatm_dev; in zatm_clock_sync() local
380 for (atm_dev = zatm_boards; atm_dev; atm_dev = zatm_dev->more) { in zatm_clock_sync()
386 zatm_dev = ZATM_DEV(atm_dev); in zatm_clock_sync()
389 ticks = zpeekl(zatm_dev,uPD98401_TSR); in zatm_clock_sync()
392 expected = exact_time(zatm_dev,ticks); in zatm_clock_sync()
395 zatm_dev->timer_history[zatm_dev->th_curr].real = now; in zatm_clock_sync()
396 zatm_dev->timer_history[zatm_dev->th_curr].expected = expected; in zatm_clock_sync()
397 zatm_dev->th_curr = (zatm_dev->th_curr+1) & in zatm_clock_sync()
399 interval = 1000000*(now.tv_sec-zatm_dev->last_real_time.tv_sec) in zatm_clock_sync()
400 +(now.tv_usec-zatm_dev->last_real_time.tv_usec); in zatm_clock_sync()
402 zatm_dev->timer_diffs = 0; in zatm_clock_sync()
405 if (++zatm_dev->timer_diffs >= ADJ_MSG_THRES) in zatm_clock_sync()
408 zatm_dev->timer_diffs = 0; in zatm_clock_sync()
413 zatm_dev->last_real_time.tv_sec, in zatm_clock_sync()
414 zatm_dev->last_real_time.tv_usec, in zatm_clock_sync()
417 zatm_dev->last_clk,ticks,ticks-zatm_dev->last_clk); in zatm_clock_sync()
418 printk(KERN_DEBUG " factor %u\n",zatm_dev->factor); in zatm_clock_sync()
424 zatm_dev->last_time = now; in zatm_clock_sync()
425 zatm_dev->factor = in zatm_clock_sync()
426 (1000 << TIMER_SHIFT)/(zatm_dev->khz+1); in zatm_clock_sync()
429 zatm_dev->last_time = expected; in zatm_clock_sync()
448 : "=a" (zatm_dev->factor) in zatm_clock_sync()
450 "g" (zatm_dev->last_clk) in zatm_clock_sync()
456 interval,TIMER_SHIFT,ticks,zatm_dev->last_clk, in zatm_clock_sync()
457 zatm_dev->factor); in zatm_clock_sync()
460 zatm_dev->last_real_time = now; in zatm_clock_sync()
461 zatm_dev->last_clk = ticks; in zatm_clock_sync()
467 static void __init zatm_clock_init(struct zatm_dev *zatm_dev) in zatm_clock_init() argument
472 zatm_dev->factor = (1000 << TIMER_SHIFT)/(zatm_dev->khz+1); in zatm_clock_init()
473 zatm_dev->timer_diffs = 0; in zatm_clock_init()
474 memset(zatm_dev->timer_history,0,sizeof(zatm_dev->timer_history)); in zatm_clock_init()
475 zatm_dev->th_curr = 0; in zatm_clock_init()
478 do_gettimeofday(&zatm_dev->last_time); in zatm_clock_init()
479 zatm_dev->last_clk = zpeekl(zatm_dev,uPD98401_TSR); in zatm_clock_init()
501 struct zatm_dev *zatm_dev = ZATM_DEV(vcc->dev);
509 zpeekl(zatm_dev,zatm_vcc->tx_chan*VC_SIZE/4+i));
512 zpeekl(zatm_dev,uPD98401_IM(zatm_vcc->shaper)+16*i));
513 qrp = (unsigned long *) zpeekl(zatm_dev,zatm_vcc->tx_chan*VC_SIZE/4+
543 struct zatm_dev *zatm_dev; in poll_rx() local
549 zatm_dev = ZATM_DEV(dev); in poll_rx()
550 pos = (zatm_dev->mbx_start[mbx] & ~0xffffUL) | zin(MTA(mbx)); in poll_rx()
559 if (((pos += 16) & 0xffff) == zatm_dev->mbx_end[mbx]) in poll_rx()
560 pos = zatm_dev->mbx_start[mbx]; in poll_rx()
566 printk("POOL: 0x%08x, 0x%08x\n",zpeekl(zatm_dev, in poll_rx()
567 zatm_dev->pool_base), in poll_rx()
568 zpeekl(zatm_dev,zatm_dev->pool_base+1)); in poll_rx()
585 skb->stamp = exact_time(zatm_dev,here[1]); in poll_rx()
604 if (chan < zatm_dev->chans && zatm_dev->rx_map[chan]) { in poll_rx()
605 vcc = zatm_dev->rx_map[chan]; in poll_rx()
606 if (skb == zatm_dev->last_free[ZATM_VCC(vcc)->pool]) in poll_rx()
607 zatm_dev->last_free[ZATM_VCC(vcc)->pool] = NULL; in poll_rx()
668 struct zatm_dev *zatm_dev; in open_rx_first() local
675 zatm_dev = ZATM_DEV(vcc->dev); in open_rx_first()
707 zpokel(zatm_dev,zatm_vcc->pool << uPD98401_RXVC_POOL_SHIFT, in open_rx_first()
709 zpokel(zatm_dev,uPD98401_RXVC_OD | (vcc->qos.aal == ATM_AAL5 ? in open_rx_first()
711 zpokel(zatm_dev,0,chan*VC_SIZE/4+2); in open_rx_first()
713 zatm_dev->rx_map[chan] = vcc; in open_rx_first()
721 struct zatm_dev *zatm_dev; in open_rx_second() local
727 zatm_dev = ZATM_DEV(vcc->dev); in open_rx_second()
735 zpokel(zatm_dev,(zpeekl(zatm_dev,pos) & ~(0xffff << shift)) | in open_rx_second()
744 struct zatm_dev *zatm_dev; in close_rx() local
750 zatm_dev = ZATM_DEV(vcc->dev); in close_rx()
759 zpokel(zatm_dev,zpeekl(zatm_dev,pos) & ~(0xffff << shift),pos); in close_rx()
779 zatm_dev->rx_map[zatm_vcc->rx_chan] = NULL; in close_rx()
787 struct zatm_dev *zatm_dev; in start_rx() local
791 zatm_dev = ZATM_DEV(dev); in start_rx()
792 size = sizeof(struct atm_vcc *)*zatm_dev->chans; in start_rx()
793 zatm_dev->rx_map = (struct atm_vcc **) kmalloc(size,GFP_KERNEL); in start_rx()
794 if (!zatm_dev->rx_map) return -ENOMEM; in start_rx()
795 memset(zatm_dev->rx_map,0,size); in start_rx()
797 zpokel(zatm_dev,(1 << dev->ci_range.vci_bits)-1,uPD98401_VRR); in start_rx()
800 zatm_dev->pool_info[i].ref_count = 0; in start_rx()
801 zatm_dev->pool_info[i].rqa_count = 0; in start_rx()
802 zatm_dev->pool_info[i].rqu_count = 0; in start_rx()
803 zatm_dev->pool_info[i].low_water = LOW_MARK; in start_rx()
804 zatm_dev->pool_info[i].high_water = HIGH_MARK; in start_rx()
805 zatm_dev->pool_info[i].offset = 0; in start_rx()
806 zatm_dev->pool_info[i].next_off = 0; in start_rx()
807 zatm_dev->pool_info[i].next_cnt = 0; in start_rx()
808 zatm_dev->pool_info[i].next_thres = OFF_CNG_THRES; in start_rx()
820 struct zatm_dev *zatm_dev; in do_tx() local
828 zatm_dev = ZATM_DEV(vcc->dev); in do_tx()
885 DPRINTK("QRP=0x%08lx\n",zpeekl(zatm_dev,zatm_vcc->tx_chan*VC_SIZE/4+ in do_tx()
930 struct zatm_dev *zatm_dev; in poll_tx() local
935 zatm_dev = ZATM_DEV(dev); in poll_tx()
936 pos = (zatm_dev->mbx_start[mbx] & ~0xffffUL) | zin(MTA(mbx)); in poll_tx()
952 chan = (zatm_dev->mbx_start[mbx][pos >> 2] & uPD98401_TXI_CONN) in poll_tx()
955 if (chan < zatm_dev->chans && zatm_dev->tx_map[chan]) in poll_tx()
956 dequeue_tx(zatm_dev->tx_map[chan]); in poll_tx()
962 if (((pos += 4) & 0xffff) == zatm_dev->mbx_end[mbx]) in poll_tx()
963 pos = zatm_dev->mbx_start[mbx]; in poll_tx()
975 struct zatm_dev *zatm_dev; in alloc_shaper() local
981 zatm_dev = ZATM_DEV(dev); in alloc_shaper()
982 if (!zatm_dev->free_shapers) return -EAGAIN; in alloc_shaper()
983 for (shaper = 0; !((zatm_dev->free_shapers >> shaper) & 1); shaper++); in alloc_shaper()
984 zatm_dev->free_shapers &= ~1 << shaper; in alloc_shaper()
988 zatm_dev->ubr_ref_cnt++; in alloc_shaper()
989 zatm_dev->ubr = shaper; in alloc_shaper()
1003 if (max > zatm_dev->tx_bw) max = zatm_dev->tx_bw; in alloc_shaper()
1021 if (zatm_dev->tx_bw < *pcr) return -EAGAIN; in alloc_shaper()
1022 zatm_dev->tx_bw -= *pcr; in alloc_shaper()
1027 zpokel(zatm_dev,(i << uPD98401_IM_I_SHIFT) | m,uPD98401_IM(shaper)); in alloc_shaper()
1028 zpokel(zatm_dev,c << uPD98401_PC_C_SHIFT,uPD98401_PC(shaper)); in alloc_shaper()
1029 zpokel(zatm_dev,0,uPD98401_X(shaper)); in alloc_shaper()
1030 zpokel(zatm_dev,0,uPD98401_Y(shaper)); in alloc_shaper()
1031 zpokel(zatm_dev,uPD98401_PS_E,uPD98401_PS(shaper)); in alloc_shaper()
1039 struct zatm_dev *zatm_dev; in dealloc_shaper() local
1042 zatm_dev = ZATM_DEV(dev); in dealloc_shaper()
1043 if (shaper == zatm_dev->ubr) { in dealloc_shaper()
1044 if (--zatm_dev->ubr_ref_cnt) return; in dealloc_shaper()
1045 zatm_dev->ubr = -1; in dealloc_shaper()
1049 zpokel(zatm_dev,zpeekl(zatm_dev,uPD98401_PS(shaper)) & ~uPD98401_PS_E, in dealloc_shaper()
1052 zatm_dev->free_shapers |= 1 << shaper; in dealloc_shaper()
1058 struct zatm_dev *zatm_dev; in close_tx() local
1066 zatm_dev = ZATM_DEV(vcc->dev); in close_tx()
1102 zatm_dev->tx_map[chan] = NULL; in close_tx()
1103 if (zatm_vcc->shaper != zatm_dev->ubr) { in close_tx()
1104 zatm_dev->tx_bw += vcc->qos.txtp.min_pcr; in close_tx()
1113 struct zatm_dev *zatm_dev; in open_tx_first() local
1121 zatm_dev = ZATM_DEV(vcc->dev); in open_tx_first()
1138 if (unlimited && zatm_dev->ubr != -1) zatm_vcc->shaper = zatm_dev->ubr; in open_tx_first()
1164 zpokel(zatm_dev,virt_to_bus(zatm_vcc->ring), in open_tx_first()
1172 struct zatm_dev *zatm_dev; in open_tx_second() local
1177 zatm_dev = ZATM_DEV(vcc->dev); in open_tx_second()
1183 zpokel(zatm_dev,0,zatm_vcc->tx_chan*VC_SIZE/4); in open_tx_second()
1184 zpokel(zatm_dev,uPD98401_TXVC_L | (zatm_vcc->shaper << in open_tx_second()
1187 zpokel(zatm_dev,0,zatm_vcc->tx_chan*VC_SIZE/4+2); in open_tx_second()
1189 zatm_dev->tx_map[zatm_vcc->tx_chan] = vcc; in open_tx_second()
1196 struct zatm_dev *zatm_dev; in start_tx() local
1200 zatm_dev = ZATM_DEV(dev); in start_tx()
1201 zatm_dev->tx_map = (struct atm_vcc **) kmalloc(sizeof(struct atm_vcc *)* in start_tx()
1202 zatm_dev->chans,GFP_KERNEL); in start_tx()
1203 if (!zatm_dev->tx_map) return -ENOMEM; in start_tx()
1204 zatm_dev->tx_bw = ATM_OC3_PCR; in start_tx()
1205 zatm_dev->free_shapers = (1 << NR_SHAPERS)-1; in start_tx()
1206 zatm_dev->ubr = -1; in start_tx()
1207 zatm_dev->ubr_ref_cnt = 0; in start_tx()
1209 for (i = 0; i < NR_SHAPERS; i++) zpokel(zatm_dev,0,uPD98401_PS(i)); in start_tx()
1220 struct zatm_dev *zatm_dev; in zatm_int() local
1224 zatm_dev = ZATM_DEV(dev); in zatm_int()
1240 zatm_dev->pool_info[i].rqa_count++; in zatm_int()
1255 zatm_dev->pool_info[i].rqu_count++; in zatm_int()
1294 static void __init eprom_set(struct zatm_dev *zatm_dev,unsigned long value, in eprom_set() argument
1299 if ((error = pci_write_config_dword(zatm_dev->pci_dev,cmd,value))) in eprom_set()
1305 static unsigned long __init eprom_get(struct zatm_dev *zatm_dev, in eprom_get() argument
1311 if ((error = pci_read_config_dword(zatm_dev->pci_dev,cmd,&value))) in eprom_get()
1318 static void __init eprom_put_bits(struct zatm_dev *zatm_dev, in eprom_put_bits() argument
1326 eprom_set(zatm_dev,value,cmd); in eprom_put_bits()
1327 eprom_set(zatm_dev,value | ZEPROM_SK,cmd); in eprom_put_bits()
1328 eprom_set(zatm_dev,value,cmd); in eprom_put_bits()
1333 static void __init eprom_get_byte(struct zatm_dev *zatm_dev, in eprom_get_byte() argument
1340 eprom_set(zatm_dev,ZEPROM_CS,cmd); in eprom_get_byte()
1341 eprom_set(zatm_dev,ZEPROM_CS | ZEPROM_SK,cmd); in eprom_get_byte()
1343 if (eprom_get(zatm_dev,cmd) & ZEPROM_DO) *byte |= 1; in eprom_get_byte()
1344 eprom_set(zatm_dev,ZEPROM_CS,cmd); in eprom_get_byte()
1353 struct zatm_dev *zatm_dev; in eprom_try_esi() local
1356 zatm_dev = ZATM_DEV(dev); in eprom_try_esi()
1358 eprom_set(zatm_dev,ZEPROM_CS,cmd); /* select EPROM */ in eprom_try_esi()
1359 eprom_put_bits(zatm_dev,ZEPROM_CMD_READ,ZEPROM_CMD_LEN,cmd); in eprom_try_esi()
1360 eprom_put_bits(zatm_dev,i >> 1,ZEPROM_ADDR_LEN,cmd); in eprom_try_esi()
1361 eprom_get_byte(zatm_dev,buf+i+swap,cmd); in eprom_try_esi()
1362 eprom_get_byte(zatm_dev,buf+i+1-swap,cmd); in eprom_try_esi()
1363 eprom_set(zatm_dev,0,cmd); /* deselect EPROM */ in eprom_try_esi()
1382 struct zatm_dev *zatm_dev; in zatm_init() local
1390 zatm_dev = ZATM_DEV(dev); in zatm_init()
1391 pci_dev = zatm_dev->pci_dev; in zatm_init()
1392 zatm_dev->base = pci_resource_start(pci_dev, 0); in zatm_init()
1393 zatm_dev->irq = pci_dev->irq; in zatm_init()
1408 dev->number,revision,zatm_dev->base,zatm_dev->irq); in zatm_init()
1415 zpokel(zatm_dev,0x55555555,i); in zatm_init()
1416 if (zpeekl(zatm_dev,i) != 0x55555555) last = i; in zatm_init()
1418 zpokel(zatm_dev,0xAAAAAAAA,i); in zatm_init()
1419 if (zpeekl(zatm_dev,i) != 0xAAAAAAAA) last = i; in zatm_init()
1420 else zpokel(zatm_dev,i,i); in zatm_init()
1424 if (zpeekl(zatm_dev,i) != i) break; in zatm_init()
1425 zatm_dev->mem = i << 2; in zatm_init()
1426 while (i) zpokel(zatm_dev,0,--i); in zatm_init()
1433 printk("mem=%dkB,%s (",zatm_dev->mem >> 10,zatm_dev->copper ? "UTP" : in zatm_init()
1442 t0 = zpeekl(zatm_dev,uPD98401_TSR); in zatm_init()
1444 t1 = zpeekl(zatm_dev,uPD98401_TSR); in zatm_init()
1446 t2 = zpeekl(zatm_dev,uPD98401_TSR); in zatm_init()
1450 zatm_dev->khz = t2-2*t1+t0; in zatm_init()
1454 zin(VER) & uPD98401_MINOR,zatm_dev->khz/1000,zatm_dev->khz % 1000); in zatm_init()
1456 zatm_clock_init(zatm_dev); in zatm_init()
1464 struct zatm_dev *zatm_dev; in zatm_start() local
1470 zatm_dev = ZATM_DEV(dev); in zatm_start()
1471 zatm_dev->rx_map = zatm_dev->tx_map = NULL; in zatm_start()
1473 zatm_dev->mbx_start[i] = 0; in zatm_start()
1474 if (request_irq(zatm_dev->irq,&zatm_int,SA_SHIRQ,DEV_LABEL,dev)) { in zatm_start()
1476 dev->number,zatm_dev->irq); in zatm_start()
1479 request_region(zatm_dev->base,uPD98401_PORTS,DEV_LABEL); in zatm_start()
1484 vccs = (zatm_dev->mem-NR_SHAPERS*SHAPER_SIZE-pools*POOL_SIZE)/ in zatm_start()
1491 zatm_dev->chans = vccs; /* ??? */ in zatm_start()
1494 zpokel(zatm_dev,curr,uPD98401_PMA); /* receive pool */ in zatm_start()
1495 zatm_dev->pool_base = curr; in zatm_start()
1498 zpokel(zatm_dev,curr,uPD98401_SMA); /* shapers */ in zatm_start()
1501 zpokel(zatm_dev,curr,uPD98401_TOS); /* free pool */ in zatm_start()
1504 (zatm_dev->mem-curr*4)/VC_SIZE); in zatm_start()
1518 zatm_dev->mbx_start[i] = here; in zatm_start()
1527 zatm_dev->mbx_end[i] = (here+MBX_SIZE(i)) & 0xffff; in zatm_start()
1546 if (zatm_dev->mbx_start[i] != 0) in zatm_start()
1547 kfree((void *) zatm_dev->mbx_start[i]); in zatm_start()
1548 if (zatm_dev->rx_map != NULL) in zatm_start()
1549 kfree(zatm_dev->rx_map); in zatm_start()
1550 if (zatm_dev->tx_map != NULL) in zatm_start()
1551 kfree(zatm_dev->tx_map); in zatm_start()
1552 free_irq(zatm_dev->irq, dev); in zatm_start()
1575 struct zatm_dev *zatm_dev; in zatm_open() local
1580 zatm_dev = ZATM_DEV(vcc->dev); in zatm_open()
1632 struct zatm_dev *zatm_dev; in zatm_ioctl() local
1635 zatm_dev = ZATM_DEV(dev); in zatm_ioctl()
1652 info = zatm_dev->pool_info[pool]; in zatm_ioctl()
1654 zatm_dev->pool_info[pool].rqa_count = 0; in zatm_ioctl()
1655 zatm_dev->pool_info[pool].rqu_count = 0; in zatm_ioctl()
1677 info.low_water = zatm_dev-> in zatm_ioctl()
1680 info.high_water = zatm_dev-> in zatm_ioctl()
1683 info.next_thres = zatm_dev-> in zatm_ioctl()
1690 zatm_dev->pool_info[pool].low_water = in zatm_ioctl()
1692 zatm_dev->pool_info[pool].high_water = in zatm_ioctl()
1694 zatm_dev->pool_info[pool].next_thres = in zatm_ioctl()
1707 hs[i] = zatm_dev->timer_history[ in zatm_ioctl()
1708 (zatm_dev->th_curr+i) & in zatm_ioctl()
1772 struct zatm_dev *zatm_dev; in zatm_phy_put() local
1774 zatm_dev = ZATM_DEV(dev); in zatm_phy_put()
1784 struct zatm_dev *zatm_dev; in zatm_phy_get() local
1786 zatm_dev = ZATM_DEV(dev); in zatm_phy_get()
1813 struct zatm_dev *zatm_dev; in zatm_detect() local
1816 zatm_dev = (struct zatm_dev *) kmalloc(sizeof(struct zatm_dev), in zatm_detect()
1818 if (!zatm_dev) return -ENOMEM; in zatm_detect()
1830 zatm_dev->pci_dev = pci_dev; in zatm_detect()
1831 dev->dev_data = zatm_dev; in zatm_detect()
1832 zatm_dev->copper = type; in zatm_detect()
1837 zatm_dev->more = zatm_boards; in zatm_detect()
1840 zatm_dev = (struct zatm_dev *) kmalloc(sizeof(struct in zatm_detect()
1841 zatm_dev),GFP_KERNEL); in zatm_detect()
1842 if (!zatm_dev) { in zatm_detect()
1848 kfree(zatm_dev); in zatm_detect()