Lines Matching refs:nic
176 static int read_eeprom(struct nic *nic, int location, int addr_len);
177 static void rtl_reset(struct nic *nic);
178 static void rtl_transmit(struct nic *nic, const char *destaddr,
180 static int rtl_poll(struct nic *nic, int retrieve);
182 static void rtl_irq(struct nic *nic, irq_action_t action);
187 struct nic *nic = (struct nic *)dev; in rtl8139_probe() local
191 unsigned short *ap = (unsigned short*)nic->node_addr; in rtl8139_probe()
198 nic->ioaddr = pci->ioaddr & ~3; in rtl8139_probe()
201 nic->irqno = pci->irq; in rtl8139_probe()
206 outb(0x00, nic->ioaddr + Config1); in rtl8139_probe()
208 addr_len = read_eeprom(nic,0,8) == 0x8129 ? 8 : 6; in rtl8139_probe()
210 *ap++ = read_eeprom(nic,i + 7,addr_len); in rtl8139_probe()
212 speed10 = inb(nic->ioaddr + MediaStatus) & MSRSpeed10; in rtl8139_probe()
213 fullduplex = inw(nic->ioaddr + MII_BMCR) & BMCRDuplex; in rtl8139_probe()
214 printf("ioaddr %#hX, irq %d, addr %! %sMbps %s-duplex\n", nic->ioaddr, in rtl8139_probe()
215 nic->irqno, nic->node_addr, speed10 ? "10" : "100", in rtl8139_probe()
218 rtl_reset(nic); in rtl8139_probe()
220 if (inb(nic->ioaddr + MediaStatus) & MSRLinkFail) { in rtl8139_probe()
226 nic->poll = rtl_poll; in rtl8139_probe()
227 nic->transmit = rtl_transmit; in rtl8139_probe()
228 nic->irq = rtl_irq; in rtl8139_probe()
256 static int read_eeprom(struct nic *nic, int location, int addr_len) in read_eeprom() argument
260 long ee_addr = nic->ioaddr + Cfg9346; in read_eeprom()
297 static void set_rx_mode(struct nic *nic) { in set_rx_mode() argument
304 outl(rtl8139_rx_config | rx_mode, nic->ioaddr + RxConfig); in set_rx_mode()
306 outl(mc_filter[0], nic->ioaddr + MAR0 + 0); in set_rx_mode()
307 outl(mc_filter[1], nic->ioaddr + MAR0 + 4); in set_rx_mode()
310 static void rtl_reset(struct nic* nic) in rtl_reset() argument
314 outb(CmdReset, nic->ioaddr + ChipCmd); in rtl_reset()
321 while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 && in rtl_reset()
326 outb(nic->node_addr[i], nic->ioaddr + MAC0 + i); in rtl_reset()
329 outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd); in rtl_reset()
331 nic->ioaddr + RxConfig); /* accept no frames yet! */ in rtl_reset()
332 outl((TX_DMA_BURST<<8)|0x03000000, nic->ioaddr + TxConfig); in rtl_reset()
345 outl((unsigned long)virt_to_bus(rx_ring), nic->ioaddr + RxBuf); in rtl_reset()
353 outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd); in rtl_reset()
355 outl(rtl8139_rx_config, nic->ioaddr + RxConfig); in rtl_reset()
358 outl(0, nic->ioaddr + RxMissed); in rtl_reset()
361 set_rx_mode(nic); in rtl_reset()
364 outw(0, nic->ioaddr + IntrMask); in rtl_reset()
367 static void rtl_transmit(struct nic *nic, const char *destaddr, in rtl_transmit() argument
376 memcpy(tx_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN); in rtl_transmit()
391 outl((unsigned long)virt_to_bus(tx_buffer), nic->ioaddr + TxAddr0 + cur_tx*4); in rtl_transmit()
393 nic->ioaddr + TxStatus0 + cur_tx*4); in rtl_transmit()
398 status = inw(nic->ioaddr + IntrStatus); in rtl_transmit()
402 outw(status & (TxOK | TxErr | PCIErr), nic->ioaddr + IntrStatus); in rtl_transmit()
406 txstatus = inl(nic->ioaddr+ TxStatus0 + cur_tx*4); in rtl_transmit()
419 rtl_reset(nic); in rtl_transmit()
423 static int rtl_poll(struct nic *nic, int retrieve) in rtl_poll() argument
429 if (inb(nic->ioaddr + ChipCmd) & RxBufEmpty) { in rtl_poll()
436 status = inw(nic->ioaddr + IntrStatus); in rtl_poll()
438 outw(status & ~(RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus); in rtl_poll()
452 rtl_reset(nic); /* this clears all interrupts still pending */ in rtl_poll()
457 nic->packetlen = rx_size - 4; /* no one cares about the FCS */ in rtl_poll()
461 memcpy(nic->packet, rx_ring + ring_offs + 4, semi_count); in rtl_poll()
462 memcpy(nic->packet+semi_count, rx_ring, rx_size-4-semi_count); in rtl_poll()
467 memcpy(nic->packet, rx_ring + ring_offs + 4, nic->packetlen); in rtl_poll()
475 nic->packet[12], nic->packet[13], rx_status); in rtl_poll()
478 outw(cur_rx - 16, nic->ioaddr + RxBufPtr); in rtl_poll()
482 outw(status & (RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus); in rtl_poll()
486 static void rtl_irq(struct nic *nic, irq_action_t action) in rtl_irq() argument
495 mask = inw(nic->ioaddr + IntrMask); in rtl_irq()
498 outw(mask, nic->ioaddr + IntrMask); in rtl_irq()
507 outb(EROK, nic->ioaddr + RxEarlyStatus); in rtl_irq()
514 struct nic *nic = (struct nic *)dev; in rtl_disable() local
516 rtl_reset(nic); in rtl_disable()
519 outb(CmdReset, nic->ioaddr + ChipCmd); in rtl_disable()
523 while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 && timer2_running()) in rtl_disable()