Module Name:    src
Committed By:   christos
Date:           Tue May 13 02:11:26 UTC 2014

Modified Files:
        src/sys/dev/mii: makphy.c

Log Message:
Add some code from FreeBSD to make the E1147* work. Still does not autoneg
to GiGE for some reason but it autonegs to 100BaseTX full-duplex.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/mii/makphy.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/mii/makphy.c
diff -u src/sys/dev/mii/makphy.c:1.38 src/sys/dev/mii/makphy.c:1.39
--- src/sys/dev/mii/makphy.c:1.38	Sat Dec 21 10:20:39 2013
+++ src/sys/dev/mii/makphy.c	Mon May 12 22:11:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: makphy.c,v 1.38 2013/12/21 15:20:39 kiyohara Exp $	*/
+/*	$NetBSD: makphy.c,v 1.39 2014/05/13 02:11:26 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.38 2013/12/21 15:20:39 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.39 2014/05/13 02:11:26 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -101,11 +101,12 @@ static const struct mii_phydesc makphys[
 	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1011,
 	  MII_STR_xxMARVELL_E1011 },
 
-#if 0
-/* doesn't work on eg. HP XW9400 */
+	/* XXX: reported not to work on eg. HP XW9400 */
 	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1149,
 	  MII_STR_xxMARVELL_E1149 },
-#endif
+
+	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1149R,
+	  MII_STR_xxMARVELL_E1149R },
 
 	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1111,
 	  MII_STR_xxMARVELL_E1111 },
@@ -153,6 +154,7 @@ makphyattach(device_t parent, device_t s
 	aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
 
 	sc->mii_dev = self;
+	sc->mii_mpd_model = MII_MODEL(ma->mii_id2);
 	sc->mii_inst = mii->mii_instance;
 	sc->mii_phy = ma->mii_phyno;
 	sc->mii_funcs = &makphy_funcs;
@@ -160,6 +162,31 @@ makphyattach(device_t parent, device_t s
 	sc->mii_flags = ma->mii_flags;
 	sc->mii_anegticks = MII_ANEGTICKS;
 
+	switch (sc->mii_mpd_model) {
+	case MII_MODEL_xxMARVELL_E1011:
+	case MII_MODEL_xxMARVELL_E1112:
+		if (PHY_READ(sc, MII_MAKPHY_ESSR) & ESSR_FIBER_LINK)
+			sc->mii_flags |= MIIF_HAVEFIBER;
+                break;
+	case MII_MODEL_xxMARVELL_E1149:
+	case MII_MODEL_xxMARVELL_E1149R:
+		/*
+		 * Some 88E1149 PHY's page select is initialized to
+		 * point to other bank instead of copper/fiber bank
+		 * which in turn resulted in wrong registers were
+		 * accessed during PHY operation. It is believed that
+		 * page 0 should be used for copper PHY so reinitialize
+		 * MII_MAKPHY_EADR to select default copper PHY. If parent
+		 * device know the type of PHY(either copper or fiber),
+		 * that information should be used to select default
+		 * type of PHY.
+		 */
+		PHY_WRITE(sc, MII_MAKPHY_EADR, 0);
+		break;
+	default:
+		break;
+	}
+
 	PHY_RESET(sc);
 
 	sc->mii_capabilities =

Reply via email to