From d12a0653654450d96f6c9b410db79791df40934c Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Tue, 24 Nov 2009 15:54:08 +0000 Subject: Properly re-initialise the PHY upon resume. ok deraadt@, claudio@, mlarkin@, pirofti@ --- sys/dev/mii/eephy.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/sys/dev/mii/eephy.c b/sys/dev/mii/eephy.c index 6e400defb6c..52b15707927 100644 --- a/sys/dev/mii/eephy.c +++ b/sys/dev/mii/eephy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eephy.c,v 1.48 2009/06/04 05:19:38 kettenis Exp $ */ +/* $OpenBSD: eephy.c,v 1.49 2009/11/24 15:54:07 kettenis Exp $ */ /* * Principal Author: Parag Patel * Copyright (c) 2001 @@ -56,20 +56,22 @@ #include -int eephy_service(struct mii_softc *, struct mii_data *, int); -void eephy_status(struct mii_softc *); -int eephymatch(struct device *, void *, void *); -void eephyattach(struct device *, struct device *, void *); +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), eephymatch, eephyattach, - mii_phy_detach, mii_phy_activate + sizeof (struct mii_softc), eephy_match, eephy_attach, + mii_phy_detach, eephy_activate }; 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 *); const struct mii_phy_funcs eephy_funcs = { @@ -119,7 +121,7 @@ static const struct mii_phydesc eephys[] = { }; int -eephymatch(struct device *parent, void *match, void *aux) +eephy_match(struct device *parent, void *match, void *aux) { struct mii_attach_args *ma = aux; @@ -130,7 +132,7 @@ eephymatch(struct device *parent, void *match, void *aux) } void -eephyattach(struct device *parent, struct device *self, void *aux) +eephy_attach(struct device *parent, struct device *self, void *aux) { struct mii_softc *sc = (struct mii_softc *)self; struct mii_attach_args *ma = aux; @@ -194,6 +196,30 @@ eephyattach(struct device *parent, struct device *self, void *aux) mii_phy_add_media(sc); + eephy_init(sc); +} + +int +eephy_activate(struct device *self, int act) +{ + struct mii_softc *sc = (void *)self; + + switch (act) { + case DVACT_SUSPEND: + break; + case DVACT_RESUME: + eephy_init(sc); + break; + } + + return (0); +} + +void +eephy_init(struct mii_softc *sc) +{ + int reg; + /* * Initialize PHY Specific Control Register. */ -- cgit v1.2.3