Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci - Remove an 82578 workaround which was for PCH r...



details:   https://anonhg.NetBSD.org/src/rev/339ccc8c21dc
branches:  trunk
changeset: 348590:339ccc8c21dc
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Oct 28 05:21:48 2016 +0000

description:
- Remove an 82578 workaround which was for PCH rev < 3. FreeBSD removed this
  workaround in r228386.
- Add an 82578 workaround which is for PHY rev < 2. From FreeBSD and Linux.
- Add some DPRINTF()s.

diffstat:

 sys/dev/pci/if_wm.c |  39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 deletions(-)

diffs (91 lines):

diff -r fe4e643c36e9 -r 339ccc8c21dc sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Fri Oct 28 04:14:13 2016 +0000
+++ b/sys/dev/pci/if_wm.c       Fri Oct 28 05:21:48 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.429 2016/10/28 04:14:13 knakahara Exp $    */
+/*     $NetBSD: if_wm.c,v 1.430 2016/10/28 05:21:48 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.429 2016/10/28 04:14:13 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.430 2016/10/28 05:21:48 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -12120,6 +12120,9 @@
 {
        uint32_t reg;
 
+       DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        reg = CSR_READ(sc, WMREG_PHY_CTRL);
        reg &= ~(PHY_CTRL_GBE_DIS | PHY_CTRL_D0A_LPLU);
        CSR_WRITE(sc, WMREG_PHY_CTRL, reg);
@@ -12130,6 +12133,9 @@
 {
        uint32_t reg;
 
+       DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
+
        reg = wm_gmii_hv_readreg(sc->sc_dev, 1, HV_OEM_BITS);
        reg &= ~(HV_OEM_BITS_A1KDIS | HV_OEM_BITS_LPLU);
        reg |= HV_OEM_BITS_ANEGNOW;
@@ -12240,6 +12246,8 @@
 wm_hv_phy_workaround_ich8lan(struct wm_softc *sc)
 {
 
+       DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
        KASSERT(sc->sc_type == WM_T_PCH);
 
        if (sc->sc_phytype == WMPHY_82577)
@@ -12251,20 +12259,23 @@
 
        /* 82578 */
        if (sc->sc_phytype == WMPHY_82578) {
-               /* PCH rev. < 3 */
-               if (sc->sc_rev < 3) {
-                       /* XXX 6 bit shift? Why? Is it page2? */
-                       wm_gmii_hv_writereg(sc->sc_dev, 1, ((1 << 6) | 0x29),
-                           0x66c0);
-                       wm_gmii_hv_writereg(sc->sc_dev, 1, ((1 << 6) | 0x1e),
-                           0xffff);
-               }
-
-               /* XXX phy rev. < 2 */
+               struct mii_softc *child;
+
+               /*
+                * Return registers to default by doing a soft reset then
+                * writing 0x3140 to the control register
+                * 0x3140 == BMCR_SPEED0 | BMCR_AUTOEN | BMCR_FDX | BMCR_SPEED1
+                */
+               child = LIST_FIRST(&sc->sc_mii.mii_phys);
+               if ((child != NULL) && (child->mii_mpd_rev < 2)) {
+                       printf("XXX 82578 rev < 2\n");
+                       PHY_RESET(child);
+                       sc->sc_mii.mii_writereg(sc->sc_dev, 2, MII_BMCR,
+                           0x3140);
+               }
        }
 
        /* Select page 0 */
-
        sc->phy.acquire(sc);
        wm_gmii_mdic_writereg(sc->sc_dev, 1, MII_IGPHY_PAGE_SELECT, 0);
        sc->phy.release(sc);
@@ -12280,6 +12291,8 @@
 wm_lv_phy_workaround_ich8lan(struct wm_softc *sc)
 {
 
+       DPRINTF(WM_DEBUG_INIT, ("%s: %s called\n",
+               device_xname(sc->sc_dev), __func__));
        KASSERT(sc->sc_type == WM_T_PCH2);
 
        wm_set_mdio_slow_mode_hv(sc);



Home | Main Index | Thread Index | Old Index