Lines Matching refs:dev
115 static int smc_get_ethaddr(bd_t *bd, struct eth_device *dev);
116 static int get_rom_mac(struct eth_device *dev, unsigned char *v_rom_mac);
142 void dump_memory_info(struct eth_device *dev) in dump_memory_info() argument
147 old_bank = SMC_inw(dev, LAN91C96_BANK_SELECT) & 0xF; in dump_memory_info()
149 SMC_SELECT_BANK(dev, 0); in dump_memory_info()
150 mem_info = SMC_inw(dev, LAN91C96_MIR); in dump_memory_info()
153 SMC_SELECT_BANK(dev, old_bank); in dump_memory_info()
163 static int poll4int (struct eth_device *dev, byte mask, int timeout) in poll4int() argument
167 word old_bank = SMC_inw(dev, LAN91C96_BANK_SELECT); in poll4int()
170 SMC_SELECT_BANK(dev, 2); in poll4int()
171 while ((SMC_inw(dev, LAN91C96_INT_STATS) & mask) == 0) { in poll4int()
179 SMC_SELECT_BANK(dev, old_bank); in poll4int()
204 static void smc_reset(struct eth_device *dev) in smc_reset() argument
206 PRINTK2("%s:smc_reset\n", dev->name); in smc_reset()
210 SMC_SELECT_BANK(dev, 0); in smc_reset()
211 SMC_outw(dev, LAN91C96_RCR_SOFT_RST, LAN91C96_RCR); in smc_reset()
216 SMC_outw(dev, 0, LAN91C96_RCR); in smc_reset()
217 SMC_outw(dev, 0, LAN91C96_TCR); in smc_reset()
220 SMC_SELECT_BANK(dev, 1); in smc_reset()
221 SMC_outw(dev, SMC_inw(dev, LAN91C96_CONTROL) | LAN91C96_CTR_BIT_8, in smc_reset()
225 SMC_outb(dev, 0, LAN91C96_INT_MASK); in smc_reset()
236 static void smc_enable(struct eth_device *dev) in smc_enable() argument
238 PRINTK2("%s:smc_enable\n", dev->name); in smc_enable()
239 SMC_SELECT_BANK(dev, 0); in smc_enable()
243 SMC_outw(dev, LAN91C96_MCR_TRANSMIT_PAGES, LAN91C96_MCR); in smc_enable()
246 SMC_outw(dev, LAN91C96_TCR_TXENA, LAN91C96_TCR); in smc_enable()
253 SMC_outw(dev, LAN91C96_RCR_RXEN | LAN91C96_RCR_PRMS, LAN91C96_RCR); in smc_enable()
270 static void smc_shutdown(struct eth_device *dev) in smc_shutdown() argument
272 PRINTK2("%s:smc_shutdown\n", dev->name); in smc_shutdown()
275 SMC_SELECT_BANK(dev, 2); in smc_shutdown()
276 SMC_outb(dev, 0, LAN91C96_INT_MASK); in smc_shutdown()
279 SMC_SELECT_BANK(dev, 0); in smc_shutdown()
280 SMC_outb(dev, 0, LAN91C96_RCR); in smc_shutdown()
281 SMC_outb(dev, 0, LAN91C96_TCR); in smc_shutdown()
303 static int smc_send_packet(struct eth_device *dev, void *packet, in smc_send_packet() argument
315 PRINTK3("%s:smc_hardware_send_packet\n", dev->name); in smc_send_packet()
335 printf("%s: Far too big packet error. \n", dev->name); in smc_send_packet()
341 SMC_SELECT_BANK(dev, 2); in smc_send_packet()
342 SMC_outw(dev, LAN91C96_MMUCR_ALLOC_TX | numPages, LAN91C96_MMU); in smc_send_packet()
348 status = SMC_inb(dev, LAN91C96_INT_STATS); in smc_send_packet()
351 SMC_outb(dev, LAN91C96_IST_ALLOC_INT, in smc_send_packet()
359 dev->name, try); in smc_send_packet()
367 dev->name, try); in smc_send_packet()
373 packet_no = SMC_inb(dev, LAN91C96_ARR); in smc_send_packet()
376 printf("%s: Memory allocation failed. \n", dev->name); in smc_send_packet()
381 SMC_outb(dev, packet_no, LAN91C96_PNR); in smc_send_packet()
384 SMC_outw(dev, LAN91C96_PTR_AUTO_INCR, LAN91C96_POINTER); in smc_send_packet()
387 dev->name, length); in smc_send_packet()
397 SMC_outl(dev, (length + 6) << 16, LAN91C96_DATA_HIGH); in smc_send_packet()
399 SMC_outw(dev, 0, LAN91C96_DATA_HIGH); in smc_send_packet()
401 SMC_outw(dev, (length + 6), LAN91C96_DATA_HIGH); in smc_send_packet()
412 SMC_outsl(dev, LAN91C96_DATA_HIGH, buf, length >> 2); in smc_send_packet()
414 SMC_outw(dev, *((word *) (buf + (length & 0xFFFFFFFC))), in smc_send_packet()
417 SMC_outsw(dev, LAN91C96_DATA_HIGH, buf, (length) >> 1); in smc_send_packet()
422 SMC_outw(dev, 0, LAN91C96_DATA_HIGH); in smc_send_packet()
424 SMC_outw(dev, buf[length - 1] | 0x2000, LAN91C96_DATA_HIGH); in smc_send_packet()
428 SMC_outw(dev, LAN91C96_MMUCR_ENQUEUE, LAN91C96_MMU); in smc_send_packet()
431 if (poll4int (dev, LAN91C96_MSK_TX_INT, SMC_TX_TIMEOUT)) { in smc_send_packet()
433 PRINTK2("%s: TX timeout, sending failed...\n", dev->name); in smc_send_packet()
436 SMC_outw(dev, LAN91C96_MMUCR_RELEASE_TX, LAN91C96_MMU); in smc_send_packet()
439 while (SMC_inw(dev, LAN91C96_MMU) & LAN91C96_MMUCR_NO_BUSY) in smc_send_packet()
448 SMC_outw(dev, LAN91C96_IST_TX_INT, LAN91C96_INT_STATS); in smc_send_packet()
450 PRINTK2("%s: Sent packet of length %d \n", dev->name, length); in smc_send_packet()
453 SMC_outw(dev, LAN91C96_MMUCR_RELEASE_TX, LAN91C96_MMU); in smc_send_packet()
456 while (SMC_inw(dev, LAN91C96_MMU) & LAN91C96_MMUCR_NO_BUSY) in smc_send_packet()
472 static int smc_open(bd_t *bd, struct eth_device *dev) in smc_open() argument
476 PRINTK2("%s:smc_open\n", dev->name); in smc_open()
480 smc_reset(dev); in smc_open()
481 smc_enable(dev); in smc_open()
483 SMC_SELECT_BANK(dev, 1); in smc_open()
485 err = smc_get_ethaddr(bd, dev); in smc_open()
494 SMC_outw(dev, address, LAN91C96_IA0 + i); in smc_open()
498 SMC_outb(dev, smc_mac_addr[i], LAN91C96_IA0 + i); in smc_open()
515 static int smc_rcv(struct eth_device *dev) in smc_rcv() argument
527 SMC_SELECT_BANK(dev, 2); in smc_rcv()
528 packet_number = SMC_inw(dev, LAN91C96_FIFO); in smc_rcv()
534 PRINTK3("%s:smc_rcv\n", dev->name); in smc_rcv()
536 SMC_outw(dev, LAN91C96_PTR_READ | LAN91C96_PTR_RCV | in smc_rcv()
541 stat_len = SMC_inl(dev, LAN91C96_DATA_HIGH); in smc_rcv()
545 status = SMC_inw(dev, LAN91C96_DATA_HIGH); in smc_rcv()
546 packet_length = SMC_inw(dev, LAN91C96_DATA_HIGH); in smc_rcv()
570 SMC_insl(dev, LAN91C96_DATA_HIGH, net_rx_packets[0], in smc_rcv()
578 dword leftover = SMC_inl(dev, LAN91C96_DATA_HIGH); in smc_rcv()
586 SMC_insw(dev, LAN91C96_DATA_HIGH, net_rx_packets[0], in smc_rcv()
601 while (SMC_inw(dev, LAN91C96_MMU) & LAN91C96_MMUCR_NO_BUSY) in smc_rcv()
605 SMC_outw(dev, LAN91C96_MMUCR_RELEASE_RX, LAN91C96_MMU); in smc_rcv()
607 while (SMC_inw(dev, LAN91C96_MMU) & LAN91C96_MMUCR_NO_BUSY) in smc_rcv()
628 static int smc_close(struct eth_device *dev) in smc_close() argument
630 PRINTK2("%s:smc_close\n", dev->name); in smc_close()
633 smc_shutdown(dev); in smc_close()
675 static int lan91c96_init(struct eth_device *dev, bd_t *bd) in lan91c96_init() argument
677 return smc_open(bd, dev); in lan91c96_init()
680 static void lan91c96_halt(struct eth_device *dev) in lan91c96_halt() argument
682 smc_close(dev); in lan91c96_halt()
685 static int lan91c96_recv(struct eth_device *dev) in lan91c96_recv() argument
687 return smc_rcv(dev); in lan91c96_recv()
690 static int lan91c96_send(struct eth_device *dev, void *packet, in lan91c96_send() argument
693 return smc_send_packet(dev, packet, length); in lan91c96_send()
702 static int smc_get_ethaddr(bd_t *bd, struct eth_device *dev) in smc_get_ethaddr() argument
708 if (!get_rom_mac(dev, v_mac)) { in smc_get_ethaddr()
725 static int get_rom_mac(struct eth_device *dev, unsigned char *v_rom_mac) in get_rom_mac() argument
728 SMC_SELECT_BANK(dev, 1); in get_rom_mac()
731 v_rom_mac[i] = SMC_inb(dev, LAN91C96_IA0 + i); in get_rom_mac()
755 static int lan91c96_detect_chip(struct eth_device *dev) in lan91c96_detect_chip() argument
759 SMC_SELECT_BANK(dev, 3); in lan91c96_detect_chip()
760 chip_id = (SMC_inw(dev, 0xA) & LAN91C96_REV_CHIPID) >> 4; in lan91c96_detect_chip()
761 SMC_SELECT_BANK(dev, 0); in lan91c96_detect_chip()
770 struct eth_device *dev; in lan91c96_initialize() local
773 dev = malloc(sizeof(*dev)); in lan91c96_initialize()
774 if (!dev) { in lan91c96_initialize()
777 memset(dev, 0, sizeof(*dev)); in lan91c96_initialize()
779 dev->iobase = base_addr; in lan91c96_initialize()
782 r = lan91c96_detect_chip(dev); in lan91c96_initialize()
784 free(dev); in lan91c96_initialize()
787 get_rom_mac(dev, dev->enetaddr); in lan91c96_initialize()
789 dev->init = lan91c96_init; in lan91c96_initialize()
790 dev->halt = lan91c96_halt; in lan91c96_initialize()
791 dev->send = lan91c96_send; in lan91c96_initialize()
792 dev->recv = lan91c96_recv; in lan91c96_initialize()
793 sprintf(dev->name, "%s-%hu", supported_chips[r].name, dev_num); in lan91c96_initialize()
795 eth_register(dev); in lan91c96_initialize()