Subject: hme+nsphy and autonegotiation problem
To: None <port-sparc64@netbsd.org>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: port-sparc64
Date: 01/19/2002 04:52:36
PCI hme and nsphy on my Ultra5 sometimes fails autonegotiation
between switching hub during boot. The attached patch from OpenBSD
seems to fix the problem, but does anyone else see the similar problem
on U5 and PCI hme?

OpenBSD's log message said:
http://www.openbsd.org/cgi-bin/cvsweb/src/sys/dev/mii/nsphy.c
Revision 1.3:
 :
o hme doesn't advertise everything it supports, so
  during reset, set the ANAR according to the supported media in BMSR.
---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp

Index: nsphy.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/mii/nsphy.c,v
retrieving revision 1.33
diff -u -r1.33 nsphy.c
--- nsphy.c	2001/11/13 07:41:37	1.33
+++ nsphy.c	2002/01/18 19:45:25
@@ -101,9 +101,10 @@
 
 int	nsphy_service(struct mii_softc *, struct mii_data *, int);
 void	nsphy_status(struct mii_softc *);
+void	nsphy_reset(struct mii_softc *);
 
 const struct mii_phy_funcs nsphy_funcs = {
-	nsphy_service, nsphy_status, mii_phy_reset,
+	nsphy_service, nsphy_status, nsphy_reset,
 };
 
 const struct mii_phydesc nsphys[] = {
@@ -327,4 +328,15 @@
 #endif
 	} else
 		mii->mii_media_active = ife->ifm_media;
+}
+
+void
+nsphy_reset(struct mii_softc *sc)
+{
+	int anar;
+
+	mii_phy_reset(sc);
+	anar = PHY_READ(sc, MII_ANAR);
+	anar |= BMSR_MEDIA_TO_ANAR(PHY_READ(sc, MII_BMSR));
+	PHY_WRITE(sc, MII_ANAR, anar);
 }