From c02be73add3248e8b2a6784b4054dc49842beb1b Mon Sep 17 00:00:00 2001 From: deraadt Date: Sat, 28 Dec 2013 03:28:45 +0000 Subject: [PATCH] Move the fairly heavy eephy_init sequence [which was only done at attach() and activate() time] into the eephy_reset() routine. This means that a bit more work gets done at PHY_RESET time, but it means also means it gets done in all scenarios. Why? For the next commit... This was in snapshots for about 2 weeks. --- sys/dev/mii/eephy.c | 53 ++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/sys/dev/mii/eephy.c b/sys/dev/mii/eephy.c index 144b771c10f..5664b4cdfaa 100644 --- a/sys/dev/mii/eephy.c +++ b/sys/dev/mii/eephy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eephy.c,v 1.51 2013/12/08 15:53:01 deraadt Exp $ */ +/* $OpenBSD: eephy.c,v 1.52 2013/12/28 03:28:45 deraadt Exp $ */ /* * Principal Author: Parag Patel * Copyright (c) 2001 @@ -58,18 +58,15 @@ int eephy_match(struct device *, void *, void *); void eephy_attach(struct device *, struct device *, void *); -int eephy_activate(struct device *, int); struct cfattach eephy_ca = { - sizeof (struct mii_softc), eephy_match, eephy_attach, - mii_phy_detach, eephy_activate + sizeof (struct mii_softc), eephy_match, eephy_attach, mii_phy_detach }; struct cfdriver eephy_cd = { NULL, "eephy", DV_DULL }; -void eephy_init(struct mii_softc *); int eephy_service(struct mii_softc *, struct mii_data *, int); void eephy_status(struct mii_softc *); void eephy_reset(struct mii_softc *); @@ -198,32 +195,27 @@ eephy_attach(struct device *parent, struct device *self, void *aux) mii_phy_add_media(sc); - eephy_init(sc); } -int -eephy_activate(struct device *self, int act) +void +eephy_reset(struct mii_softc *sc) { - struct mii_softc *sc = (void *)self; + int reg, i; - switch (act) { - case DVACT_RESUME: - eephy_init(sc); - break; + reg = PHY_READ(sc, E1000_CR); + reg |= E1000_CR_RESET; + PHY_WRITE(sc, E1000_CR, reg); + + for (i = 0; i < 500; i++) { + DELAY(1); + reg = PHY_READ(sc, E1000_CR); + if (!(reg & E1000_CR_RESET)) + break; } - return (0); -} - -void -eephy_init(struct mii_softc *sc) -{ - int reg; - /* * Initialize PHY Specific Control Register. */ - reg = PHY_READ(sc, E1000_SCR); /* Assert CRS on transmit. */ @@ -292,23 +284,6 @@ eephy_init(struct mii_softc *sc) PHY_WRITE(sc, E1000_CR, reg | E1000_CR_RESET); } -void -eephy_reset(struct mii_softc *sc) -{ - int reg, i; - - reg = PHY_READ(sc, E1000_CR); - reg |= E1000_CR_RESET; - PHY_WRITE(sc, E1000_CR, reg); - - for (i = 0; i < 500; i++) { - DELAY(1); - reg = PHY_READ(sc, E1000_CR); - if (!(reg & E1000_CR_RESET)) - break; - } -} - int eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) { -- 2.20.1