Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/mii Add KSZ8081 support from FreeBSD.



details:   https://anonhg.NetBSD.org/src/rev/c51c0add1dd7
branches:  trunk
changeset: 448924:c51c0add1dd7
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Feb 14 04:13:40 2019 +0000

description:
Add KSZ8081 support from FreeBSD.

diffstat:

 sys/dev/mii/micphy.c |  31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diffs (76 lines):

diff -r b0971c1daddc -r c51c0add1dd7 sys/dev/mii/micphy.c
--- a/sys/dev/mii/micphy.c      Thu Feb 14 03:33:55 2019 +0000
+++ b/sys/dev/mii/micphy.c      Thu Feb 14 04:13:40 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: micphy.c,v 1.5 2019/01/22 17:41:06 skrll Exp $ */
+/*     $NetBSD: micphy.c,v 1.6 2019/02/14 04:13:40 msaitoh Exp $       */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: micphy.c,v 1.5 2019/01/22 17:41:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: micphy.c,v 1.6 2019/02/14 04:13:40 msaitoh Exp $");
 
 #include "opt_mii.h"
 
@@ -79,6 +79,8 @@
 
 static int     micphymatch(device_t, cfdata_t, void *);
 static void    micphyattach(device_t, device_t, void *);
+static void    micphy_reset(struct mii_softc *);
+static int     micphy_service(struct mii_softc *, struct mii_data *, int);
 
 CFATTACH_DECL3_NEW(micphy, sizeof(struct mii_softc),
     micphymatch, micphyattach, mii_phy_detach, mii_phy_activate, NULL, NULL,
@@ -88,10 +90,13 @@
 static void    micphy_fixup(struct mii_softc *, int, int, device_t);
 
 static const struct mii_phy_funcs micphy_funcs = {
-       micphy_service, ukphy_status, mii_phy_reset,
+       micphy_service, ukphy_status, micphy_reset,
 };
 
 static const struct mii_phydesc micphys[] = {
+       { MII_OUI_MICREL,               MII_MODEL_MICREL_KSZ8081,
+         MII_STR_MICREL_KSZ8081 },
+
        { MII_OUI_MICREL,               MII_MODEL_MICREL_KSZ9021RNI,
          MII_STR_MICREL_KSZ9021RNI },
 
@@ -99,6 +104,8 @@
          NULL },
 };
 
+#define        MII_KSZ8081_PHYCTL2                     0x1f
+
 static int
 micphymatch(device_t parent, cfdata_t match, void *aux)
 {
@@ -149,6 +156,24 @@
        aprint_normal("\n");
 }
 
+static void
+micphy_reset(struct mii_softc *sc)
+{
+       uint16_t reg;
+
+       /*
+        * The 8081 has no "sticky bits" that survive a soft reset; several bits
+        * in the Phy Control Register 2 must be preserved across the reset.
+        * These bits are set up by the bootloader; they control how the phy
+        * interfaces to the board (such as clock frequency and LED behavior).
+        */
+       if (sc->mii_mpd_model == MII_MODEL_MICREL_KSZ8081)
+               PHY_READ(sc, MII_KSZ8081_PHYCTL2, &reg);
+       mii_phy_reset(sc);
+       if (sc->mii_mpd_model == MII_MODEL_MICREL_KSZ8081)
+               PHY_WRITE(sc, MII_KSZ8081_PHYCTL2, reg);
+}
+
 static int
 micphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {



Home | Main Index | Thread Index | Old Index