Lines Matching refs:dev

227 static void write_eeprom(struct eth_device *dev, long addr, int location,
230 static int read_eeprom(struct eth_device *dev, long addr, int location);
231 static int mdio_read(struct eth_device *dev, int phy_id, int location);
232 static int natsemi_init(struct eth_device *dev, bd_t * bis);
233 static void natsemi_reset(struct eth_device *dev);
234 static void natsemi_init_rxfilter(struct eth_device *dev);
235 static void natsemi_init_txd(struct eth_device *dev);
236 static void natsemi_init_rxd(struct eth_device *dev);
237 static void natsemi_set_rx_mode(struct eth_device *dev);
238 static void natsemi_check_duplex(struct eth_device *dev);
239 static int natsemi_send(struct eth_device *dev, void *packet, int length);
240 static int natsemi_poll(struct eth_device *dev);
241 static void natsemi_disable(struct eth_device *dev);
248 #define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, a)
249 #define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, a)
252 INW(struct eth_device *dev, u_long addr) in INW() argument
254 return le16_to_cpu(*(vu_short *) (addr + dev->iobase)); in INW()
258 INL(struct eth_device *dev, u_long addr) in INL() argument
260 return le32_to_cpu(*(vu_long *) (addr + dev->iobase)); in INL()
264 OUTW(struct eth_device *dev, int command, u_long addr) in OUTW() argument
266 *(vu_short *) ((addr + dev->iobase)) = cpu_to_le16(command); in OUTW()
270 OUTL(struct eth_device *dev, int command, u_long addr) in OUTL() argument
272 *(vu_long *) ((addr + dev->iobase)) = cpu_to_le32(command); in OUTL()
293 struct eth_device *dev; in natsemi_initialize() local
321 dev = (struct eth_device *) malloc(sizeof *dev); in natsemi_initialize()
322 if (!dev) { in natsemi_initialize()
326 memset(dev, 0, sizeof(*dev)); in natsemi_initialize()
328 sprintf(dev->name, "dp83815#%d", card_number); in natsemi_initialize()
329 dev->iobase = bus_to_phys(iobase); in natsemi_initialize()
331 printf("natsemi: NatSemi ns8381[56] @ %#x\n", dev->iobase); in natsemi_initialize()
333 dev->priv = (void *) devno; in natsemi_initialize()
334 dev->init = natsemi_init; in natsemi_initialize()
335 dev->halt = natsemi_disable; in natsemi_initialize()
336 dev->send = natsemi_send; in natsemi_initialize()
337 dev->recv = natsemi_poll; in natsemi_initialize()
339 eth_register(dev); in natsemi_initialize()
360 short eedata = read_eeprom(dev, EECtrl, i); in natsemi_initialize()
366 prev_eedata = read_eeprom(dev, EECtrl, 6); in natsemi_initialize()
368 int eedata = read_eeprom(dev, EECtrl, i + 7); in natsemi_initialize()
369 dev->enetaddr[i*2] = (eedata << 1) + (prev_eedata >> 15); in natsemi_initialize()
370 dev->enetaddr[i*2+1] = eedata >> 7; in natsemi_initialize()
375 OUTL(dev, ChipReset, ChipCmd); in natsemi_initialize()
377 advertising = mdio_read(dev, 1, 4); in natsemi_initialize()
378 chip_config = INL(dev, ChipConfig); in natsemi_initialize()
381 dev->name, (int) INL(dev, BasicStatus), advertising); in natsemi_initialize()
383 dev->name, chip_config & AnegMask ? "enabled, advertise" : in natsemi_initialize()
390 dev->name, chip_config & AnegMask ? "enabled, advertise" : in natsemi_initialize()
395 OUTL(dev, (chip_config | PhyRst), ChipConfig); in natsemi_initialize()
397 OUTL(dev, chip_config, ChipConfig); in natsemi_initialize()
405 SavedClkRun = INL(dev, ClkRun); in natsemi_initialize()
406 OUTL(dev, SavedClkRun & ~0x100, ClkRun); in natsemi_initialize()
417 #define eeprom_delay(ee_addr) INL(dev, ee_addr)
436 write_eeprom(struct eth_device *dev, long addr, int location, short value)
445 dev->iobase + ee_addr, write_cmd, value);
450 OUTL(dev, cmdval, ee_addr);
452 OUTL(dev, cmdval | EE_ShiftClk, ee_addr);
456 OUTL(dev, 0, ee_addr); /*bring chip select low*/
457 OUTL(dev, EE_ShiftClk, ee_addr);
463 OUTL(dev, cmdval, ee_addr);
465 OUTL(dev, cmdval | EE_ShiftClk, ee_addr);
471 OUTL(dev, cmdval, ee_addr);
473 OUTL(dev, cmdval | EE_ShiftClk, ee_addr);
477 OUTL(dev, 0, ee_addr); /*bring chip select low*/
478 OUTL(dev, EE_ShiftClk, ee_addr);
480 OUTL(dev, EE_Write0, ee_addr); /*poll for done*/
481 if (INL(dev, ee_addr) & EE_DataOut) {
488 OUTL(dev, EE_Write0, ee_addr);
489 OUTL(dev, 0, ee_addr);
495 read_eeprom(struct eth_device *dev, long addr, int location) in read_eeprom() argument
502 OUTL(dev, EE_Write0, ee_addr); in read_eeprom()
507 OUTL(dev, dataval, ee_addr); in read_eeprom()
509 OUTL(dev, dataval | EE_ShiftClk, ee_addr); in read_eeprom()
512 OUTL(dev, EE_ChipSelect, ee_addr); in read_eeprom()
516 OUTL(dev, EE_ChipSelect | EE_ShiftClk, ee_addr); in read_eeprom()
518 retval |= (INL(dev, ee_addr) & EE_DataOut) ? 1 << i : 0; in read_eeprom()
519 OUTL(dev, EE_ChipSelect, ee_addr); in read_eeprom()
524 OUTL(dev, EE_Write0, ee_addr); in read_eeprom()
525 OUTL(dev, 0, ee_addr); in read_eeprom()
529 dev->iobase + ee_addr, read_cmd, retval); in read_eeprom()
539 mdio_read(struct eth_device *dev, int phy_id, int location) in mdio_read() argument
542 return INL(dev, BasicControl+(location<<2))&0xffff; in mdio_read()
558 natsemi_init(struct eth_device *dev, bd_t * bis) in natsemi_init() argument
561 natsemi_reset(dev); in natsemi_init()
569 OUTL(dev, SavedClkRun & ~0x100, ClkRun); in natsemi_init()
571 natsemi_init_rxfilter(dev); in natsemi_init()
572 natsemi_init_txd(dev); in natsemi_init()
573 natsemi_init_rxd(dev); in natsemi_init()
580 printf("%s: Setting TxConfig Register %#08X\n", dev->name, tx_config); in natsemi_init()
581 printf("%s: Setting RxConfig Register %#08X\n", dev->name, rx_config); in natsemi_init()
583 OUTL(dev, tx_config, TxConfig); in natsemi_init()
584 OUTL(dev, rx_config, RxConfig); in natsemi_init()
586 natsemi_check_duplex(dev); in natsemi_init()
587 natsemi_set_rx_mode(dev); in natsemi_init()
589 OUTL(dev, (RxOn | TxOn), ChipCmd); in natsemi_init()
603 natsemi_reset(struct eth_device *dev) in natsemi_reset() argument
605 OUTL(dev, ChipReset, ChipCmd); in natsemi_reset()
611 if (INL(dev, SiliconRev) == 0x302) { in natsemi_reset()
612 OUTW(dev, 0x0001, PGSEL); in natsemi_reset()
613 OUTW(dev, 0x189C, PMDCSR); in natsemi_reset()
614 OUTW(dev, 0x0000, TSTDAT); in natsemi_reset()
615 OUTW(dev, 0x5040, DSPCFG); in natsemi_reset()
616 OUTW(dev, 0x008C, SDCFG); in natsemi_reset()
619 OUTL(dev, 0, IntrMask); in natsemi_reset()
620 OUTL(dev, 0, IntrEnable); in natsemi_reset()
633 natsemi_init_rxfilter(struct eth_device *dev) in natsemi_init_rxfilter() argument
638 OUTL(dev, i, RxFilterAddr); in natsemi_init_rxfilter()
639 OUTW(dev, dev->enetaddr[i] + (dev->enetaddr[i + 1] << 8), in natsemi_init_rxfilter()
655 natsemi_init_txd(struct eth_device *dev) in natsemi_init_txd() argument
662 OUTL(dev, (u32) & txd, TxRingPtr); in natsemi_init_txd()
665 INL(dev, TxRingPtr)); in natsemi_init_txd()
679 natsemi_init_rxd(struct eth_device *dev) in natsemi_init_rxd() argument
703 OUTL(dev, (u32) & rxd[0], RxRingPtr); in natsemi_init_rxd()
707 INL(dev, RxRingPtr)); in natsemi_init_rxd()
723 natsemi_set_rx_mode(struct eth_device *dev) in natsemi_set_rx_mode() argument
727 OUTL(dev, rx_mode, RxFilterAddr); in natsemi_set_rx_mode()
731 natsemi_check_duplex(struct eth_device *dev) in natsemi_check_duplex() argument
733 int duplex = INL(dev, ChipConfig) & FullDuplex ? 1 : 0; in natsemi_check_duplex()
737 " capability.\n", dev->name, duplex ? "full" : "half"); in natsemi_check_duplex()
746 OUTL(dev, tx_config, TxConfig); in natsemi_check_duplex()
747 OUTL(dev, rx_config, RxConfig); in natsemi_check_duplex()
755 static int natsemi_send(struct eth_device *dev, void *packet, int length) in natsemi_send() argument
763 OUTL(dev, TxOff, ChipCmd); in natsemi_send()
776 OUTL(dev, phys_to_bus((u32) & txd), TxRingPtr); in natsemi_send()
780 INL(dev, TxRingPtr)); in natsemi_send()
783 OUTL(dev, TxOn, ChipCmd); in natsemi_send()
791 dev->name, tx_status); in natsemi_send()
822 natsemi_poll(struct eth_device *dev) in natsemi_poll() argument
856 OUTL(dev, RxOn, ChipCmd); in natsemi_poll()
871 natsemi_disable(struct eth_device *dev) in natsemi_disable() argument
874 OUTL(dev, 0, IntrMask); in natsemi_disable()
875 OUTL(dev, 0, IntrEnable); in natsemi_disable()
878 OUTL(dev, RxOff | TxOff, ChipCmd); in natsemi_disable()
881 OUTL(dev, SavedClkRun, ClkRun); in natsemi_disable()