From b15317c43192e806f2db7d725dcec84aff9c30d8 Mon Sep 17 00:00:00 2001 From: Michael Zhilin Date: Mon, 21 Nov 2016 19:26:22 +0000 Subject: [PATCH] [etherswitch] add ukswitch hint that is phy offset at mdio register This patch allows to specify PHY register offset for ukswitch. For instance, switch MAICREL KS8995XA connected via MDIO to SoC, but PHY register starts at 1. So hint for this case is: hint.ukswitch.0.phyoffset=1 No change/effect if hint is not set. Submitted by: Hiroki Mori Reviewed by: adrian, mizhka Approved by: adrian(mentor) Differential Revision: https://reviews.freebsd.org/D8584 --- sys/dev/etherswitch/ukswitch/ukswitch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/dev/etherswitch/ukswitch/ukswitch.c b/sys/dev/etherswitch/ukswitch/ukswitch.c index 876aa9da226..5d8c95eabb8 100644 --- a/sys/dev/etherswitch/ukswitch/ukswitch.c +++ b/sys/dev/etherswitch/ukswitch/ukswitch.c @@ -67,6 +67,7 @@ struct ukswitch_softc { int media; /* cpu port media */ int cpuport; /* which PHY is connected to the CPU */ int phymask; /* PHYs we manage */ + int phyoffset; /* PHYs register offset */ int numports; /* number of ports */ int ifpport[MII_NPHY]; int *portphy; @@ -133,7 +134,7 @@ ukswitch_attach_phys(struct ukswitch_softc *sc) M_WAITOK | M_ZERO); err = mii_attach(sc->sc_dev, sc->miibus[port], sc->ifp[port], ukswitch_ifmedia_upd, ukswitch_ifmedia_sts, \ - BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0); + BMSR_DEFCAPMASK, phy + sc->phyoffset, MII_OFFSET_ANY, 0); DPRINTF(sc->sc_dev, "%s attached to pseudo interface %s\n", device_get_nameunit(*sc->miibus[port]), sc->ifp[port]->if_xname); @@ -166,6 +167,7 @@ ukswitch_attach(device_t dev) /* XXX Defaults */ sc->numports = 6; sc->phymask = 0x0f; + sc->phyoffset = 0; sc->cpuport = -1; sc->media = 100; @@ -173,6 +175,8 @@ ukswitch_attach(device_t dev) "numports", &sc->numports); (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "phymask", &sc->phymask); + (void) resource_int_value(device_get_name(dev), device_get_unit(dev), + "phyoffset", &sc->phyoffset); (void) resource_int_value(device_get_name(dev), device_get_unit(dev), "cpuport", &sc->cpuport); (void) resource_int_value(device_get_name(dev), device_get_unit(dev),