if_re.c (207763) | if_re.c (213893) |
---|---|
1/*- 2 * Copyright (c) 1997, 1998-2003 3 * Bill Paul <wpaul@windriver.com>. 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-2003 3 * Bill Paul <wpaul@windriver.com>. 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/re/if_re.c 207763 2010-05-07 23:05:27Z yongari $"); | 34__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 213893 2010-10-15 14:52:11Z marius $"); |
35 36/* 37 * RealTek 8139C+/8169/8169S/8110S/8168/8111/8101E PCI NIC driver 38 * 39 * Written by Bill Paul <wpaul@windriver.com> 40 * Senior Networking Software Engineer 41 * Wind River Systems 42 */ --- 361 unchanged lines hidden (view full) --- 404 405static int 406re_gmii_readreg(device_t dev, int phy, int reg) 407{ 408 struct rl_softc *sc; 409 u_int32_t rval; 410 int i; 411 | 35 36/* 37 * RealTek 8139C+/8169/8169S/8110S/8168/8111/8101E PCI NIC driver 38 * 39 * Written by Bill Paul <wpaul@windriver.com> 40 * Senior Networking Software Engineer 41 * Wind River Systems 42 */ --- 361 unchanged lines hidden (view full) --- 404 405static int 406re_gmii_readreg(device_t dev, int phy, int reg) 407{ 408 struct rl_softc *sc; 409 u_int32_t rval; 410 int i; 411 |
412 if (phy != 1) 413 return (0); 414 | |
415 sc = device_get_softc(dev); 416 417 /* Let the rgephy driver read the GMEDIASTAT register */ 418 419 if (reg == RL_GMEDIASTAT) { 420 rval = CSR_READ_1(sc, RL_GMEDIASTAT); 421 return (rval); 422 } --- 53 unchanged lines hidden (view full) --- 476 477 sc = device_get_softc(dev); 478 479 if (sc->rl_type == RL_8169) { 480 rval = re_gmii_readreg(dev, phy, reg); 481 return (rval); 482 } 483 | 412 sc = device_get_softc(dev); 413 414 /* Let the rgephy driver read the GMEDIASTAT register */ 415 416 if (reg == RL_GMEDIASTAT) { 417 rval = CSR_READ_1(sc, RL_GMEDIASTAT); 418 return (rval); 419 } --- 53 unchanged lines hidden (view full) --- 473 474 sc = device_get_softc(dev); 475 476 if (sc->rl_type == RL_8169) { 477 rval = re_gmii_readreg(dev, phy, reg); 478 return (rval); 479 } 480 |
484 /* Pretend the internal PHY is only at address 0 */ 485 if (phy) { 486 return (0); 487 } | |
488 switch (reg) { 489 case MII_BMCR: 490 re8139_reg = RL_BMCR; 491 break; 492 case MII_BMSR: 493 re8139_reg = RL_BMSR; 494 break; 495 case MII_ANAR: --- 38 unchanged lines hidden (view full) --- 534 535 sc = device_get_softc(dev); 536 537 if (sc->rl_type == RL_8169) { 538 rval = re_gmii_writereg(dev, phy, reg, data); 539 return (rval); 540 } 541 | 481 switch (reg) { 482 case MII_BMCR: 483 re8139_reg = RL_BMCR; 484 break; 485 case MII_BMSR: 486 re8139_reg = RL_BMSR; 487 break; 488 case MII_ANAR: --- 38 unchanged lines hidden (view full) --- 527 528 sc = device_get_softc(dev); 529 530 if (sc->rl_type == RL_8169) { 531 rval = re_gmii_writereg(dev, phy, reg, data); 532 return (rval); 533 } 534 |
542 /* Pretend the internal PHY is only at address 0 */ 543 if (phy) 544 return (0); 545 | |
546 switch (reg) { 547 case MII_BMCR: 548 re8139_reg = RL_BMCR; 549 if (sc->rl_type == RL_8139CPLUS) { 550 /* 8139C+ has different bit layout. */ 551 data &= ~(BMCR_LOOP | BMCR_ISO); 552 } 553 break; --- 549 unchanged lines hidden (view full) --- 1103{ 1104 u_char eaddr[ETHER_ADDR_LEN]; 1105 u_int16_t as[ETHER_ADDR_LEN / 2]; 1106 struct rl_softc *sc; 1107 struct ifnet *ifp; 1108 struct rl_hwrev *hw_rev; 1109 int hwrev; 1110 u_int16_t devid, re_did = 0; | 535 switch (reg) { 536 case MII_BMCR: 537 re8139_reg = RL_BMCR; 538 if (sc->rl_type == RL_8139CPLUS) { 539 /* 8139C+ has different bit layout. */ 540 data &= ~(BMCR_LOOP | BMCR_ISO); 541 } 542 break; --- 549 unchanged lines hidden (view full) --- 1092{ 1093 u_char eaddr[ETHER_ADDR_LEN]; 1094 u_int16_t as[ETHER_ADDR_LEN / 2]; 1095 struct rl_softc *sc; 1096 struct ifnet *ifp; 1097 struct rl_hwrev *hw_rev; 1098 int hwrev; 1099 u_int16_t devid, re_did = 0; |
1111 int error = 0, rid, i; | 1100 int error = 0, i, phy, rid; |
1112 int msic, reg; 1113 uint8_t cfg; 1114 1115 sc = device_get_softc(dev); 1116 sc->rl_dev = dev; 1117 1118 mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 1119 MTX_DEF); --- 282 unchanged lines hidden (view full) --- 1402 /* Take PHY out of power down mode. */ 1403 if ((sc->rl_flags & RL_FLAG_PHYWAKE_PM) != 0) 1404 CSR_WRITE_1(sc, RL_PMCH, CSR_READ_1(sc, RL_PMCH) | 0x80); 1405 if ((sc->rl_flags & RL_FLAG_PHYWAKE) != 0) { 1406 re_gmii_writereg(dev, 1, 0x1f, 0); 1407 re_gmii_writereg(dev, 1, 0x0e, 0); 1408 } 1409 | 1101 int msic, reg; 1102 uint8_t cfg; 1103 1104 sc = device_get_softc(dev); 1105 sc->rl_dev = dev; 1106 1107 mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 1108 MTX_DEF); --- 282 unchanged lines hidden (view full) --- 1391 /* Take PHY out of power down mode. */ 1392 if ((sc->rl_flags & RL_FLAG_PHYWAKE_PM) != 0) 1393 CSR_WRITE_1(sc, RL_PMCH, CSR_READ_1(sc, RL_PMCH) | 0x80); 1394 if ((sc->rl_flags & RL_FLAG_PHYWAKE) != 0) { 1395 re_gmii_writereg(dev, 1, 0x1f, 0); 1396 re_gmii_writereg(dev, 1, 0x0e, 0); 1397 } 1398 |
1410 /* Do MII setup */ 1411 if (mii_phy_probe(dev, &sc->rl_miibus, 1412 re_ifmedia_upd, re_ifmedia_sts)) { 1413 device_printf(dev, "MII without any phy!\n"); 1414 error = ENXIO; | 1399#define RE_PHYAD_INTERNAL 0 1400 1401 /* Do MII setup. */ 1402 phy = RE_PHYAD_INTERNAL; 1403 if (sc->rl_type == RL_8169) 1404 phy = 1; 1405 error = mii_attach(dev, &sc->rl_miibus, ifp, re_ifmedia_upd, 1406 re_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0); 1407 if (error != 0) { 1408 device_printf(dev, "attaching PHYs failed\n"); |
1415 goto fail; 1416 } 1417 1418 ifp->if_softc = sc; 1419 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 1420 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 1421 ifp->if_ioctl = re_ioctl; 1422 ifp->if_start = re_start; --- 1767 unchanged lines hidden --- | 1409 goto fail; 1410 } 1411 1412 ifp->if_softc = sc; 1413 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 1414 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 1415 ifp->if_ioctl = re_ioctl; 1416 ifp->if_start = re_start; --- 1767 unchanged lines hidden --- |