summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2013-12-28 03:28:46 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2013-12-28 03:28:46 +0000
commitc793bd7ca68b94034eae254d6ade483101248e61 (patch)
tree1bc3b9440233b5991b5227ff1f75790ce936c6b9
parent759776a75d72803515068c174b67651431b598f0 (diff)
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.
-rw-r--r--sys/dev/mii/eephy.c53
1 files 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)
{