summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc/shared/net
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2013-03-12 15:30:09 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2015-04-17 01:10:18 +0200
commita79c36ad1da6edc74ec2cc7dfc7cec36054e7558 (patch)
treedc6e44244af52acecc4d71cd7585742e1984a0fc /c/src/lib/libbsp/sparc/shared/net
parentGRETH: updated worker Deamon thread name (diff)
downloadrtems-a79c36ad1da6edc74ec2cc7dfc7cec36054e7558.tar.bz2
GRETH: forcing autonegotiation during PHY initialization
Looking at PHY Ctrl register without reseting it will give back old register content, that is not stable. Instead the PHY is reset and the autonogotiation capability is read out and started if present.
Diffstat (limited to 'c/src/lib/libbsp/sparc/shared/net')
-rw-r--r--c/src/lib/libbsp/sparc/shared/net/greth.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/net/greth.c b/c/src/lib/libbsp/sparc/shared/net/greth.c
index 733b2a4977..769de59016 100644
--- a/c/src/lib/libbsp/sparc/shared/net/greth.c
+++ b/c/src/lib/libbsp/sparc/shared/net/greth.c
@@ -328,14 +328,19 @@ greth_initialize_hardware (struct greth_softc *sc)
phyaddr = sc->phyaddr;
}
- /* get phy control register default values */
+ /* reset PHY */
+ write_mii(sc, phyaddr, 0, 0x8000);
+
+ /* Wait for reset to complete and get default values */
while ((phyctrl = read_mii(sc, phyaddr, 0)) & 0x8000) {}
-
- /* reset PHY and wait for completion */
- write_mii(sc, phyaddr, 0, 0x8000 | phyctrl);
- while ((read_mii(sc, phyaddr, 0)) & 0x8000) {}
-
+ /* If autonegotiation implemented we start it */
+ phystatus = read_mii(sc, phyaddr, 1);
+ if (phystatus & 0x0008) {
+ write_mii(sc, phyaddr, 0, phyctrl | 0x1200);
+ phyctrl = read_mii(sc, phyaddr, 0);
+ }
+
/* Check if PHY is autoneg capable and then determine operating mode,
otherwise force it to 10 Mbit halfduplex */
sc->gb = 0;