Module Name: src
Committed By: martin
Date: Sun Sep 1 10:14:20 UTC 2019
Modified Files:
src/sys/dev/mii [netbsd-8]: micphy.c
Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1349:
sys/dev/mii/micphy.c 1.6 via patch
Add KSZ8081 support from FreeBSD.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.10.1 src/sys/dev/mii/micphy.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/micphy.c
diff -u src/sys/dev/mii/micphy.c:1.4 src/sys/dev/mii/micphy.c:1.4.10.1
--- src/sys/dev/mii/micphy.c:1.4 Thu Jul 7 06:55:41 2016
+++ src/sys/dev/mii/micphy.c Sun Sep 1 10:14:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: micphy.c,v 1.4 2016/07/07 06:55:41 msaitoh Exp $ */
+/* $NetBSD: micphy.c,v 1.4.10.1 2019/09/01 10:14:20 martin 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.4 2016/07/07 06:55:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: micphy.c,v 1.4.10.1 2019/09/01 10:14:20 martin Exp $");
#include "opt_mii.h"
@@ -79,6 +79,8 @@ __KERNEL_RCSID(0, "$NetBSD: micphy.c,v 1
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 int micphy_service(struct mii_sof
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 @@ static const struct mii_phydesc micphys[
NULL },
};
+#define MII_KSZ8081_PHYCTL2 0x1f
+
static int
micphymatch(device_t parent, cfdata_t match, void *aux)
{
@@ -148,6 +155,24 @@ micphyattach(device_t parent, device_t s
aprint_normal("\n");
}
+static void
+micphy_reset(struct mii_softc *sc)
+{
+ int 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)
+ reg = PHY_READ(sc, MII_KSZ8081_PHYCTL2);
+ 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)
{