Module Name: src Committed By: msaitoh Date: Tue Jul 18 08:05:03 UTC 2017
Modified Files: src/sys/dev/pci: if_wm.c Log Message: Move some initialization stuff in wm_attach() before wm_reset(). Some flags and callback function is required to set correctly before wm_reset() because wm_reset() and some helper functions refer them. To generate a diff of this commit: cvs rdiff -u -r1.526 -r1.527 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.526 src/sys/dev/pci/if_wm.c:1.527 --- src/sys/dev/pci/if_wm.c:1.526 Tue Jul 18 08:01:07 2017 +++ src/sys/dev/pci/if_wm.c Tue Jul 18 08:05:03 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.526 2017/07/18 08:01:07 msaitoh Exp $ */ +/* $NetBSD: if_wm.c,v 1.527 2017/07/18 08:05:03 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -83,7 +83,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.526 2017/07/18 08:01:07 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.527 2017/07/18 08:05:03 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -2188,9 +2188,6 @@ alloc_retry: break; } - /* Reset the chip to a known state. */ - wm_reset(sc); - /* Ensure the SMBI bit is clear before first NVM or PHY access */ switch (sc->sc_type) { case WM_T_82571: @@ -2237,9 +2234,6 @@ alloc_retry: sc->sc_flags |= WM_F_EEPROM_INVALID; } - /* Set device properties (macflags) */ - prop_dictionary_set_uint32(dict, "macflags", sc->sc_flags); - if (sc->sc_flags & WM_F_EEPROM_INVALID) aprint_verbose_dev(sc->sc_dev, "No EEPROM"); else { @@ -2263,6 +2257,15 @@ alloc_retry: wm_nvm_version(sc); aprint_verbose("\n"); + /* + * XXX The first call of wm_gmii_setup_phytype. The result might be + * incorrect. + */ + wm_gmii_setup_phytype(sc, 0, 0); + + /* Reset the chip to a known state. */ + wm_reset(sc); + /* Check for I21[01] PLL workaround */ if (sc->sc_type == WM_T_I210) sc->sc_flags |= WM_F_PLL_WA_I210; @@ -2575,6 +2578,9 @@ alloc_retry: snprintb(buf, sizeof(buf), WM_FLAGS, sc->sc_flags); aprint_verbose_dev(sc->sc_dev, "%s\n", buf); + /* Set device properties (macflags) */ + prop_dictionary_set_uint32(dict, "macflags", sc->sc_flags); + ifp = &sc->sc_ethercom.ec_if; xname = device_xname(sc->sc_dev); strlcpy(ifp->if_xname, xname, IFNAMSIZ); @@ -9416,12 +9422,6 @@ wm_gmii_mediainit(struct wm_softc *sc, p /* Initialize our media structures and probe the GMII. */ mii->mii_ifp = ifp; - /* - * The first call of wm_mii_setup_phytype. The result might be - * incorrect. - */ - wm_gmii_setup_phytype(sc, 0, 0); - mii->mii_statchg = wm_gmii_statchg; /* get PHY control from SMBus to PCIe */ @@ -9514,7 +9514,7 @@ wm_gmii_mediainit(struct wm_softc *sc, p /* * PHY Found! Check PHY type again by the second call of - * wm_mii_setup_phytype. + * wm_gmii_setup_phytype. */ wm_gmii_setup_phytype(sc, child->mii_mpd_oui, child->mii_mpd_model);