diff options
author | yongari <yongari@FreeBSD.org> | 2010-11-08 19:15:31 +0000 |
---|---|---|
committer | yongari <yongari@FreeBSD.org> | 2010-11-08 19:15:31 +0000 |
commit | 68b9094fc9e048f6691f0466df3cbe90742ce848 (patch) | |
tree | c81463568216232984103aba527a0d2d908322a2 | |
parent | 68210d116b4f01d99b3c3498a0b475de9e577300 (diff) | |
download | FreeBSD-src-68b9094fc9e048f6691f0466df3cbe90742ce848.zip FreeBSD-src-68b9094fc9e048f6691f0466df3cbe90742ce848.tar.gz |
Reduce spin wait time consumed in GMII register access routine.
There were a couple of attempts in the past to reduce it since it
took more than 1ms. Because mii_tick() periodically polls link
status, waiting more than 1ms for each GMII register access was
overkill. Unfortunately all previous attempts were failed with
various ways on different controllers.
This time, add additional 20us dealy at the end of GMII register
access which seems to requirement of all RealTek controllers to
issue next GMII register access request. This is the same way what
Linux does.
-rw-r--r-- | sys/dev/re/if_re.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c index 95983af..8f8cfa1 100644 --- a/sys/dev/re/if_re.c +++ b/sys/dev/re/if_re.c @@ -423,13 +423,12 @@ re_gmii_readreg(device_t dev, int phy, int reg) } CSR_WRITE_4(sc, RL_PHYAR, reg << 16); - DELAY(1000); for (i = 0; i < RL_PHY_TIMEOUT; i++) { rval = CSR_READ_4(sc, RL_PHYAR); if (rval & RL_PHYAR_BUSY) break; - DELAY(100); + DELAY(25); } if (i == RL_PHY_TIMEOUT) { @@ -437,6 +436,11 @@ re_gmii_readreg(device_t dev, int phy, int reg) return (0); } + /* + * Controller requires a 20us delay to process next MDIO request. + */ + DELAY(20); + return (rval & RL_PHYAR_PHYDATA); } @@ -451,13 +455,12 @@ re_gmii_writereg(device_t dev, int phy, int reg, int data) CSR_WRITE_4(sc, RL_PHYAR, (reg << 16) | (data & RL_PHYAR_PHYDATA) | RL_PHYAR_BUSY); - DELAY(1000); for (i = 0; i < RL_PHY_TIMEOUT; i++) { rval = CSR_READ_4(sc, RL_PHYAR); if (!(rval & RL_PHYAR_BUSY)) break; - DELAY(100); + DELAY(25); } if (i == RL_PHY_TIMEOUT) { @@ -465,6 +468,11 @@ re_gmii_writereg(device_t dev, int phy, int reg, int data) return (0); } + /* + * Controller requires a 20us delay to process next MDIO request. + */ + DELAY(20); + return (0); } |