summaryrefslogtreecommitdiff
path: root/sys/dev/mii
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2008-05-24 01:08:22 +0000
committerBrad Smith <brad@cvs.openbsd.org>2008-05-24 01:08:22 +0000
commit74f2154bee03479ede5553e042e803431d0c7f11 (patch)
tree274dc159e6353002ab8a82706c11faa8bbf3408d /sys/dev/mii
parenta17d41bfba66ed9e57f41a10e4891c6c0ab0815d (diff)
Store the model and revision information in the appropriate softc
fields that already exist and reference those fields when necessary instead of reading the registers everytime. ok kettenis@
Diffstat (limited to 'sys/dev/mii')
-rw-r--r--sys/dev/mii/rgephy.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/sys/dev/mii/rgephy.c b/sys/dev/mii/rgephy.c
index 54506784031..72d5b4ec9b7 100644
--- a/sys/dev/mii/rgephy.c
+++ b/sys/dev/mii/rgephy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rgephy.c,v 1.26 2008/05/23 23:14:21 kettenis Exp $ */
+/* $OpenBSD: rgephy.c,v 1.27 2008/05/24 01:08:21 brad Exp $ */
/*
* Copyright (c) 2003
* Bill Paul <wpaul@windriver.com>. All rights reserved.
@@ -126,6 +126,8 @@ rgephyattach(struct device *parent, struct device *self, void *aux)
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
sc->mii_funcs = &rgephy_funcs;
+ sc->mii_model = MII_MODEL(ma->mii_id2);
+ sc->mii_rev = MII_REV(ma->mii_id2);
sc->mii_pdata = mii;
sc->mii_flags = ma->mii_flags;
sc->mii_anegticks = MII_ANEGTICKS_GIGE;
@@ -148,7 +150,6 @@ rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
{
struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
int anar, reg, speed, gig = 0;
- uint16_t id2;
switch (cmd) {
case MII_POLLSTAT:
@@ -254,8 +255,7 @@ setit:
* need to restart the autonegotiation process. Read
* the BMSR twice in case it's latched.
*/
- id2 = PHY_READ(sc, MII_PHYIDR2);
- if (MII_REV(id2) < 2) {
+ if (sc->mii_rev < 2) {
reg = PHY_READ(sc, RL_GMEDIASTAT);
if (reg & RL_GMEDIASTAT_LINK)
break;
@@ -300,14 +300,11 @@ rgephy_status(struct mii_softc *sc)
{
struct mii_data *mii = sc->mii_pdata;
int bmsr, bmcr, gtsr;
- uint16_t id2;
mii->mii_media_status = IFM_AVALID;
mii->mii_media_active = IFM_ETHER;
- id2 = PHY_READ(sc, MII_PHYIDR2);
-
- if (MII_REV(id2) < 2) {
+ if (sc->mii_rev < 2) {
bmsr = PHY_READ(sc, RL_GMEDIASTAT);
if (bmsr & RL_GMEDIASTAT_LINK)
@@ -333,7 +330,7 @@ rgephy_status(struct mii_softc *sc)
}
}
- if (MII_REV(id2) < 2) {
+ if (sc->mii_rev < 2) {
bmsr = PHY_READ(sc, RL_GMEDIASTAT);
if (bmsr & RL_GMEDIASTAT_1000MBPS)
mii->mii_media_active |= IFM_1000_T;
@@ -398,11 +395,9 @@ void
rgephy_loop(struct mii_softc *sc)
{
u_int32_t bmsr;
- uint16_t id2;
int i;
- id2 = PHY_READ(sc, MII_PHYIDR2);
- if (MII_REV(id2) < 2) {
+ if (sc->mii_rev < 2) {
PHY_WRITE(sc, RGEPHY_MII_BMCR, RGEPHY_BMCR_PDOWN);
DELAY(1000);
}
@@ -431,10 +426,8 @@ void
rgephy_load_dspcode(struct mii_softc *sc)
{
int val;
- u_int16_t id2;
- id2 = PHY_READ(sc, MII_PHYIDR2);
- if (MII_REV(id2) > 1)
+ if (sc->mii_rev > 1)
return;
PHY_WRITE(sc, 31, 0x0001);