Lines Matching +full:100 +full:base +full:- +full:tx
3 * sundance.c -- Etherboot device driver for the Sundance ST201 "Alta".
4 * Written 2002-2002 by Timothy Legge <tlegge@rogers.com>
22 * Written 1999-2002 by Donald Becker
28 * Linux Driver Version LK1.09a, 10-Jul-2003 (2.4.25)
32 * v1.1 01-01-2003 timlegge Initial implementation
33 * v1.7 04-10-2003 timlegge Transfers Linux Kernel (30 sec)
34 * v1.8 04-13-2003 timlegge Fix multiple transmission bug
35 * v1.9 08-19-2003 timlegge Support Multicast
36 * v1.10 01-17-2004 timlegge Initial driver output cleanup
37 * v1.11 03-21-2004 timlegge Remove unused variables
38 * v1.12 03-21-2004 timlegge Remove excess MII defines
39 * v1.13 03-24-2004 timlegge Update to Linux 2.4.25 driver
53 #define drv_date "2004-03-21"
62 #define HZ 100
91 /* Maximum number of multicast addresses to filter (vs. rx-all-multicast).
95 /* Set the copy breakpoint for the copy-only-tiny-frames scheme.
97 This chip can receive into any byte alignment buffers, so word-oriented
98 archs do not need a copy-align of the IP header. */
107 100mbps_hd 100Mbps half duplex.
108 100mbps_fd 100Mbps full duplex.
128 Unlike software-only systems, device drivers interact with complex hardware.
228 /* The Rx and Tx buffer descriptors.
253 /* Define the TX Descriptor */
256 /* Create a static buffer of size PKT_BUF_SZ for each TX Descriptor.
267 /* FIXME: Move BASE to the private structure */
268 static u32 BASE; variable
317 int mii_lpa = mdio_read(nic, sdc->phys[0], MII_LPA); in check_duplex()
318 int negotiated = mii_lpa & sdc->mii_if.advertising; in check_duplex()
322 if (!sdc->an_enable || mii_lpa == 0xffff) { in check_duplex()
323 if (sdc->mii_if.full_duplex) in check_duplex()
324 outw(inw(BASE + MACCtrl0) | EnbFullDuplex, in check_duplex()
325 BASE + MACCtrl0); in check_duplex()
331 if (sdc->mii_if.full_duplex != duplex) { in check_duplex()
332 sdc->mii_if.full_duplex = duplex; in check_duplex()
333 dprintf(("%s: Setting %s-duplex based on MII #%d " in check_duplex()
334 "negotiated capability %4.4x.\n", sdc->nic_name, in check_duplex()
335 duplex ? "full" : "half", sdc->phys[0], in check_duplex()
337 outw(inw(BASE + MACCtrl0) | duplex ? 0x20 : 0, in check_duplex()
338 BASE + MACCtrl0); in check_duplex()
344 * init_ring - setup the tx and rx descriptors
350 sdc->cur_rx = 0; in init_ring()
361 rx_ring[i - 1].next_desc = virt_to_le32desc(&rx_ring[0]); in init_ring()
386 * RESET - Reset Adapter
394 outl(virt_to_le32desc(&rx_ring[0]), BASE + RxListPtr); in sundance_reset()
395 /* The Tx List Pointer is written as packets are queued */ in sundance_reset()
402 addr16 = (nic->node_addr[0] | (nic->node_addr[1] << 8)); in sundance_reset()
403 outw(addr16, BASE + StationAddr); in sundance_reset()
404 addr16 = (nic->node_addr[2] | (nic->node_addr[3] << 8)); in sundance_reset()
405 outw(addr16, BASE + StationAddr + 2); in sundance_reset()
406 addr16 = (nic->node_addr[4] | (nic->node_addr[5] << 8)); in sundance_reset()
407 outw(addr16, BASE + StationAddr + 4); in sundance_reset()
410 outw(sdc->mtu + 14, BASE + MaxFrameSize); in sundance_reset()
411 if (sdc->mtu > 2047) /* this will never happen with default options */ in sundance_reset()
412 outl(inl(BASE + ASICCtrl) | 0x0c, BASE + ASICCtrl); in sundance_reset()
416 outw(0, BASE + DownCounter); in sundance_reset()
418 outb(100, BASE + RxDMAPollPeriod); in sundance_reset()
420 /* Fix DFE-580TX packet drop issue */ in sundance_reset()
421 if (sdc->pci_rev_id >= 0x14) in sundance_reset()
422 writeb(0x01, BASE + DebugCtrl1); in sundance_reset()
424 outw(RxEnable | TxEnable, BASE + MACCtrl1); in sundance_reset()
431 txb[0] = nic->node_addr[0]; in sundance_reset()
432 txb[1] = nic->node_addr[1]; in sundance_reset()
433 txb[2] = nic->node_addr[2]; in sundance_reset()
434 txb[3] = nic->node_addr[3]; in sundance_reset()
435 txb[4] = nic->node_addr[4]; in sundance_reset()
436 txb[5] = nic->node_addr[5]; in sundance_reset()
438 dprintf(("%s: Done sundance_reset, status: Rx %hX Tx %hX " in sundance_reset()
440 sdc->nic_name, (int) inl(BASE + RxStatus), in sundance_reset()
441 (int) inw(BASE + TxStatus), (int) inl(BASE + MACCtrl0), in sundance_reset()
442 (int) inw(BASE + MACCtrl1), (int) inw(BASE + MACCtrl0))); in sundance_reset()
446 IRQ - Wait for a frame
454 intr_status = inw(nic->ioaddr + IntrStatus); in sundance_irq()
458 outw(intr_status, nic->ioaddr + IntrEnable); in sundance_irq()
461 outw(0x0200, BASE + ASICCtrl); in sundance_irq()
466 POLL - Wait for a frame
471 /* nic->packet should contain data on return */ in sundance_poll()
472 /* nic->packetlen should contain length of data */ in sundance_poll()
473 int entry = sdc->cur_rx % RX_RING_SIZE; in sundance_poll()
485 intr_status = inw(nic->ioaddr + IntrStatus); in sundance_poll()
486 outw(intr_status, nic->ioaddr + IntrStatus); in sundance_poll()
497 nic->packetlen = pkt_len; in sundance_poll()
498 memcpy(nic->packet, rxb + in sundance_poll()
499 (sdc->cur_rx * PKT_BUF_SZ), nic->packetlen); in sundance_poll()
506 sdc->cur_rx = entry % RX_RING_SIZE; in sundance_poll()
508 nic->ioaddr + IntrStatus); in sundance_poll()
513 TRANSMIT - Transmit a frame
523 /* Disable the Tx */ in sundance_transmit()
524 outw(TxDisable, BASE + MACCtrl1); in sundance_transmit()
527 memcpy(txb + ETH_ALEN, nic->node_addr, ETH_ALEN); in sundance_transmit()
542 outl(virt_to_le32desc(&tx_ring[0]), BASE + TxListPtr); in sundance_transmit()
544 /* Enable Tx */ in sundance_transmit()
545 outw(TxEnable, BASE + MACCtrl1); in sundance_transmit()
547 outw(0, BASE + TxStatus); in sundance_transmit()
553 printf("TX Time Out"); in sundance_transmit()
555 /* Disable Tx */ in sundance_transmit()
556 outw(TxDisable, BASE + MACCtrl1); in sundance_transmit()
561 DISABLE - Turn off ethernet interface
575 outw(0x0000, BASE + IntrEnable); in sundance_disable()
576 /* Stop the Chipchips Tx and Rx Status */ in sundance_disable()
577 outw(TxDisable | RxDisable | StatsDisable, BASE + MACCtrl1); in sundance_disable()
583 PROBE - Look for an adapter, this routine's visible to the outside
593 if (pci->ioaddr == 0) in sundance_probe()
596 /* BASE is used throughout to address the card */ in sundance_probe()
597 BASE = pci->ioaddr; in sundance_probe()
599 pci->name, pci->vendor, pci->dev_id); in sundance_probe()
604 le16_to_cpu(eeprom_read(BASE, i + EEPROM_SA_OFFSET)); in sundance_probe()
608 nic->node_addr[i] = ee_data[i]; in sundance_probe()
614 // sdc->mii_if.dev = pci; in sundance_probe()
615 // sdc->mii_if.phy_id_mask = 0x1f; in sundance_probe()
616 // sdc->mii_if.reg_num_mask = 0x1f; in sundance_probe()
621 sdc->nic_name = pci->name; in sundance_probe()
622 sdc->mtu = mtu; in sundance_probe()
624 pci_read_config_byte(pci, PCI_REVISION_ID, &sdc->pci_rev_id); in sundance_probe()
625 dprintf(("Device revision id: %hx\n", sdc->pci_rev_id)); in sundance_probe()
627 printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr, BASE); in sundance_probe()
628 sdc->mii_preamble_required = 0; in sundance_probe()
631 sdc->phys[0] = 1; /* Default Setting */ in sundance_probe()
632 sdc->mii_preamble_required++; in sundance_probe()
636 sdc->phys[phy_idx++] = phy; in sundance_probe()
637 sdc->mii_if.advertising = in sundance_probe()
640 sdc->mii_preamble_required++; in sundance_probe()
642 …Y found at address %d, status " "%hX advertising %hX\n", sdc->nic_name, phy, mii_status, sdc->mii_… in sundance_probe()
645 sdc->mii_preamble_required--; in sundance_probe()
648 sdc->nic_name); in sundance_probe()
649 sdc->mii_if.phy_id = sdc->phys[0]; in sundance_probe()
653 sdc->an_enable = 1; in sundance_probe()
655 sdc->an_enable = 0; in sundance_probe()
656 if (strcasecmp(media, "100mbps_fd") == 0 || in sundance_probe()
658 sdc->speed = 100; in sundance_probe()
659 sdc->mii_if.full_duplex = 1; in sundance_probe()
660 } else if (strcasecmp(media, "100mbps_hd") == 0 in sundance_probe()
662 sdc->speed = 100; in sundance_probe()
663 sdc->mii_if.full_duplex = 0; in sundance_probe()
666 sdc->speed = 10; in sundance_probe()
667 sdc->mii_if.full_duplex = 1; in sundance_probe()
670 sdc->speed = 10; in sundance_probe()
671 sdc->mii_if.full_duplex = 0; in sundance_probe()
673 sdc->an_enable = 1; in sundance_probe()
677 sdc->flowctrl = 1; in sundance_probe()
680 if (inl(BASE + ASICCtrl) & 0x80) { in sundance_probe()
681 /* Default 100Mbps Full */ in sundance_probe()
682 if (sdc->an_enable) { in sundance_probe()
683 sdc->speed = 100; in sundance_probe()
684 sdc->mii_if.full_duplex = 1; in sundance_probe()
685 sdc->an_enable = 0; in sundance_probe()
694 if (!sdc->an_enable) { in sundance_probe()
696 mii_ctl |= (sdc->speed == 100) ? BMCR_SPEED100 : 0; in sundance_probe()
697 mii_ctl |= (sdc->mii_if.full_duplex) ? BMCR_FULLDPLX : 0; in sundance_probe()
698 mdio_write(nic, sdc->phys[0], MII_BMCR, mii_ctl); in sundance_probe()
700 sdc->speed, in sundance_probe()
701 sdc->mii_if.full_duplex ? "Full" : "Half"); in sundance_probe()
705 dprintf(("ASIC Control is %x.\n", inl(BASE + ASICCtrl))); in sundance_probe()
706 outw(0x007f, BASE + ASICCtrl + 2); in sundance_probe()
707 dprintf(("ASIC Control is now %x.\n", inl(BASE + ASICCtrl))); in sundance_probe()
710 if (sdc->an_enable) { in sundance_probe()
713 mdio_read(nic, sdc->phys[0], MII_ADVERTISE); in sundance_probe()
714 mii_lpa = mdio_read(nic, sdc->phys[0], MII_LPA); in sundance_probe()
717 sdc->speed = 100; in sundance_probe()
719 sdc->speed = 100; in sundance_probe()
721 sdc->speed = 10; in sundance_probe()
723 sdc->speed = 10; in sundance_probe()
725 mii_ctl = mdio_read(nic, sdc->phys[0], MII_BMCR); in sundance_probe()
726 speed = (mii_ctl & BMCR_SPEED100) ? 100 : 10; in sundance_probe()
727 sdc->speed = speed; in sundance_probe()
728 printf("%s: Link changed: %dMbps ,", sdc->nic_name, speed); in sundance_probe()
733 if (sdc->flowctrl && sdc->mii_if.full_duplex) { in sundance_probe()
734 outw(inw(BASE + MulticastFilter1 + 2) | 0x0200, in sundance_probe()
735 BASE + MulticastFilter1 + 2); in sundance_probe()
736 outw(inw(BASE + MACCtrl0) | EnbFlowCtrl, BASE + MACCtrl0); in sundance_probe()
738 printf("%dMbps, %s-Duplex\n", sdc->speed, in sundance_probe()
739 sdc->mii_if.full_duplex ? "Full" : "Half"); in sundance_probe()
742 dev->disable = sundance_disable; in sundance_probe()
743 nic->poll = sundance_poll; in sundance_probe()
744 nic->transmit = sundance_transmit; in sundance_probe()
745 nic->irqno = pci->irq; in sundance_probe()
746 nic->irq = sundance_irq; in sundance_probe()
747 nic->ioaddr = BASE; in sundance_probe()
763 while (--boguscnt > 0); in eeprom_read()
768 Read and write the MII registers using software-generated serial
796 while (--bits >= 0) { in mdio_sync()
807 long mdio_addr = BASE + MIICtrl; in mdio_read()
811 if (sdc->mii_preamble_required) in mdio_read()
815 for (i = 15; i >= 0; i--) { in mdio_read()
824 /* Read the two transition, 16 data, and wire-idle bits. */ in mdio_read()
825 for (i = 19; i > 0; i--) { in mdio_read()
840 long mdio_addr = BASE + MIICtrl; in mdio_write()
845 if (sdc->mii_preamble_required) in mdio_write()
849 for (i = 31; i >= 0; i--) { in mdio_write()
858 for (i = 2; i > 0; i--) { in mdio_write()
876 if (sdc->mii_if.full_duplex && sdc->flowctrl) in set_rx_mode()
879 outw(mc_filter[i], BASE + MulticastFilter0 + i * 2); in set_rx_mode()
880 outb(rx_mode, BASE + RxMode); in set_rx_mode()
886 PCI_ROM(0x1186, 0x1002, "dfe530txs", "D-Link DFE530TXS (Sundance ST201 Alta)"),