if_vr.c (211766) | if_vr.c (213893) |
---|---|
1/*- 2 * Copyright (c) 1997, 1998 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997, 1998 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/dev/vr/if_vr.c 211766 2010-08-24 18:44:12Z yongari $"); | 34__FBSDID("$FreeBSD: head/sys/dev/vr/if_vr.c 213893 2010-10-15 14:52:11Z marius $"); |
35 36/* 37 * VIA Rhine fast ethernet PCI NIC driver 38 * 39 * Supports various network adapters based on the VIA Rhine 40 * and Rhine II PCI controllers, including the D-Link DFE530TX. 41 * Datasheets are available at http://www.via.com.tw. 42 * --- 201 unchanged lines hidden (view full) --- 244 245static int 246vr_miibus_readreg(device_t dev, int phy, int reg) 247{ 248 struct vr_softc *sc; 249 int i; 250 251 sc = device_get_softc(dev); | 35 36/* 37 * VIA Rhine fast ethernet PCI NIC driver 38 * 39 * Supports various network adapters based on the VIA Rhine 40 * and Rhine II PCI controllers, including the D-Link DFE530TX. 41 * Datasheets are available at http://www.via.com.tw. 42 * --- 201 unchanged lines hidden (view full) --- 244 245static int 246vr_miibus_readreg(device_t dev, int phy, int reg) 247{ 248 struct vr_softc *sc; 249 int i; 250 251 sc = device_get_softc(dev); |
252 if (sc->vr_phyaddr != phy) 253 return (0); | |
254 255 /* Set the register address. */ 256 CSR_WRITE_1(sc, VR_MIIADDR, reg); 257 VR_SETBIT(sc, VR_MIICMD, VR_MIICMD_READ_ENB); 258 259 for (i = 0; i < VR_MII_TIMEOUT; i++) { 260 DELAY(1); 261 if ((CSR_READ_1(sc, VR_MIICMD) & VR_MIICMD_READ_ENB) == 0) --- 7 unchanged lines hidden (view full) --- 269 270static int 271vr_miibus_writereg(device_t dev, int phy, int reg, int data) 272{ 273 struct vr_softc *sc; 274 int i; 275 276 sc = device_get_softc(dev); | 252 253 /* Set the register address. */ 254 CSR_WRITE_1(sc, VR_MIIADDR, reg); 255 VR_SETBIT(sc, VR_MIICMD, VR_MIICMD_READ_ENB); 256 257 for (i = 0; i < VR_MII_TIMEOUT; i++) { 258 DELAY(1); 259 if ((CSR_READ_1(sc, VR_MIICMD) & VR_MIICMD_READ_ENB) == 0) --- 7 unchanged lines hidden (view full) --- 267 268static int 269vr_miibus_writereg(device_t dev, int phy, int reg, int data) 270{ 271 struct vr_softc *sc; 272 int i; 273 274 sc = device_get_softc(dev); |
277 if (sc->vr_phyaddr != phy) 278 return (0); | |
279 280 /* Set the register address and data to write. */ 281 CSR_WRITE_1(sc, VR_MIIADDR, reg); 282 CSR_WRITE_2(sc, VR_MIIDATA, data); 283 VR_SETBIT(sc, VR_MIICMD, VR_MIICMD_WRITE_ENB); 284 285 for (i = 0; i < VR_MII_TIMEOUT; i++) { 286 DELAY(1); --- 321 unchanged lines hidden (view full) --- 608static int 609vr_attach(device_t dev) 610{ 611 struct vr_softc *sc; 612 struct ifnet *ifp; 613 struct vr_type *t; 614 uint8_t eaddr[ETHER_ADDR_LEN]; 615 int error, rid; | 275 276 /* Set the register address and data to write. */ 277 CSR_WRITE_1(sc, VR_MIIADDR, reg); 278 CSR_WRITE_2(sc, VR_MIIDATA, data); 279 VR_SETBIT(sc, VR_MIICMD, VR_MIICMD_WRITE_ENB); 280 281 for (i = 0; i < VR_MII_TIMEOUT; i++) { 282 DELAY(1); --- 321 unchanged lines hidden (view full) --- 604static int 605vr_attach(device_t dev) 606{ 607 struct vr_softc *sc; 608 struct ifnet *ifp; 609 struct vr_type *t; 610 uint8_t eaddr[ETHER_ADDR_LEN]; 611 int error, rid; |
616 int i, pmc; | 612 int i, phy, pmc; |
617 618 sc = device_get_softc(dev); 619 sc->vr_dev = dev; 620 t = vr_match(dev); 621 KASSERT(t != NULL, ("Lost if_vr device match")); 622 sc->vr_quirks = t->vr_quirks; 623 device_printf(dev, "Quirks: 0x%x\n", sc->vr_quirks); 624 --- 150 unchanged lines hidden (view full) --- 775 /* Disable MII AUTOPOLL. */ 776 VR_CLRBIT(sc, VR_MIICMD, VR_MIICMD_AUTOPOLL); 777 778 if (vr_dma_alloc(sc) != 0) { 779 error = ENXIO; 780 goto fail; 781 } 782 | 613 614 sc = device_get_softc(dev); 615 sc->vr_dev = dev; 616 t = vr_match(dev); 617 KASSERT(t != NULL, ("Lost if_vr device match")); 618 sc->vr_quirks = t->vr_quirks; 619 device_printf(dev, "Quirks: 0x%x\n", sc->vr_quirks); 620 --- 150 unchanged lines hidden (view full) --- 771 /* Disable MII AUTOPOLL. */ 772 VR_CLRBIT(sc, VR_MIICMD, VR_MIICMD_AUTOPOLL); 773 774 if (vr_dma_alloc(sc) != 0) { 775 error = ENXIO; 776 goto fail; 777 } 778 |
783 /* Save PHY address. */ | 779 /* Do MII setup. */ |
784 if (sc->vr_revid >= REV_ID_VT6105_A0) | 780 if (sc->vr_revid >= REV_ID_VT6105_A0) |
785 sc->vr_phyaddr = 1; | 781 phy = 1; |
786 else | 782 else |
787 sc->vr_phyaddr = CSR_READ_1(sc, VR_PHYADDR) & VR_PHYADDR_MASK; 788 789 /* Do MII setup. */ 790 if (mii_phy_probe(dev, &sc->vr_miibus, 791 vr_ifmedia_upd, vr_ifmedia_sts)) { 792 device_printf(dev, "MII without any phy!\n"); 793 error = ENXIO; | 783 phy = CSR_READ_1(sc, VR_PHYADDR) & VR_PHYADDR_MASK; 784 error = mii_attach(dev, &sc->vr_miibus, ifp, vr_ifmedia_upd, 785 vr_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0); 786 if (error != 0) { 787 device_printf(dev, "attaching PHYs failed\n"); |
794 goto fail; 795 } 796 797 /* Call MI attach routine. */ 798 ether_ifattach(ifp, eaddr); 799 /* 800 * Tell the upper layer(s) we support long frames. 801 * Must appear after the call to ether_ifattach() because --- 1823 unchanged lines hidden --- | 788 goto fail; 789 } 790 791 /* Call MI attach routine. */ 792 ether_ifattach(ifp, eaddr); 793 /* 794 * Tell the upper layer(s) we support long frames. 795 * Must appear after the call to ether_ifattach() because --- 1823 unchanged lines hidden --- |