From owner-svn-src-all@freebsd.org Sat May 6 05:53:43 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98D37D613CA; Sat, 6 May 2017 05:53:43 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 744D3169A; Sat, 6 May 2017 05:53:43 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v465rgwM076918; Sat, 6 May 2017 05:53:42 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v465rgc0076916; Sat, 6 May 2017 05:53:42 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201705060553.v465rgc0076916@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 6 May 2017 05:53:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317866 - head/sys/dev/etherswitch/ip17x X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 May 2017 05:53:43 -0000 Author: adrian Date: Sat May 6 05:53:42 2017 New Revision: 317866 URL: https://svnweb.freebsd.org/changeset/base/317866 Log: [ip17x] [etherswitch] fdt away and mii hang workaround on ip17x Add workaround mii access because of rt1310 is hang up on etherswitch mii poll. And FDT away on arm platform. Tested: * wzr2-g300n Submitted by: Hiroki Mori Reviewed by: mizhka Differential Revision: https://reviews.freebsd.org/D10295 Modified: head/sys/dev/etherswitch/ip17x/ip17x.c head/sys/dev/etherswitch/ip17x/ip17x_var.h Modified: head/sys/dev/etherswitch/ip17x/ip17x.c ============================================================================== --- head/sys/dev/etherswitch/ip17x/ip17x.c Sat May 6 05:52:01 2017 (r317865) +++ head/sys/dev/etherswitch/ip17x/ip17x.c Sat May 6 05:53:42 2017 (r317866) @@ -28,6 +28,8 @@ * $FreeBSD$ */ +#include "opt_platform.h" + #include #include #include @@ -61,6 +63,12 @@ #include #include +#ifdef FDT +#include +#include +#include +#endif + #include "mdio_if.h" #include "miibus_if.h" #include "etherswitch_if.h" @@ -72,11 +80,28 @@ static void ip17x_tick(void *); static int ip17x_ifmedia_upd(struct ifnet *); static void ip17x_ifmedia_sts(struct ifnet *, struct ifmediareq *); +static void +ip17x_identify(driver_t *driver, device_t parent) +{ + if (device_find_child(parent, "ip17x", -1) == NULL) + BUS_ADD_CHILD(parent, 0, "ip17x", -1); +} + static int ip17x_probe(device_t dev) { struct ip17x_softc *sc; uint32_t oui, model, phy_id1, phy_id2; +#ifdef FDT + phandle_t ip17x_node; + pcell_t cell; + + ip17x_node = fdt_find_compatible(OF_finddevice("/"), + "icplus,ip17x", 0); + + if (ip17x_node == 0) + return (ENXIO); +#endif sc = device_get_softc(dev); @@ -118,6 +143,15 @@ ip17x_probe(device_t dev) sc->sc_switchtype = IP17X_SWITCH_IP178C; } + sc->miipoll = 1; +#ifdef FDT + if ((OF_getencprop(ip17x_node, "mii-poll", + &cell, sizeof(cell))) > 0) + sc->miipoll = cell ? 1 : 0; +#else + (void) resource_int_value(device_get_name(dev), device_get_unit(dev), + "mii-poll", &sc->miipoll); +#endif device_set_desc_copy(dev, "IC+ IP17x switch driver"); return (BUS_PROBE_DEFAULT); } @@ -229,9 +263,11 @@ ip17x_attach(device_t dev) if (err != 0) return (err); - callout_init(&sc->callout_tick, 0); + if (sc->miipoll) { + callout_init(&sc->callout_tick, 0); - ip17x_tick(sc); + ip17x_tick(sc); + } return (0); } @@ -243,7 +279,8 @@ ip17x_detach(device_t dev) int i, port; sc = device_get_softc(dev); - callout_drain(&sc->callout_tick); + if (sc->miipoll) + callout_drain(&sc->callout_tick); for (i=0; i < MII_NPHY; i++) { if (((1 << i) & sc->phymask) == 0) @@ -564,6 +601,7 @@ ip17x_setconf(device_t dev, etherswitch_ static device_method_t ip17x_methods[] = { /* Device interface */ + DEVMETHOD(device_identify, ip17x_identify), DEVMETHOD(device_probe, ip17x_probe), DEVMETHOD(device_attach, ip17x_attach), DEVMETHOD(device_detach, ip17x_detach), @@ -604,8 +642,13 @@ static devclass_t ip17x_devclass; DRIVER_MODULE(ip17x, mdio, ip17x_driver, ip17x_devclass, 0, 0); DRIVER_MODULE(miibus, ip17x, miibus_driver, miibus_devclass, 0, 0); -DRIVER_MODULE(mdio, ip17x, mdio_driver, mdio_devclass, 0, 0); DRIVER_MODULE(etherswitch, ip17x, etherswitch_driver, etherswitch_devclass, 0, 0); MODULE_VERSION(ip17x, 1); + +#ifdef FDT +MODULE_DEPEND(ip17x, mdio, 1, 1, 1); /* XXX which versions? */ +#else +DRIVER_MODULE(mdio, ip17x, mdio_driver, mdio_devclass, 0, 0); MODULE_DEPEND(ip17x, miibus, 1, 1, 1); /* XXX which versions? */ MODULE_DEPEND(ip17x, etherswitch, 1, 1, 1); /* XXX which versions? */ +#endif Modified: head/sys/dev/etherswitch/ip17x/ip17x_var.h ============================================================================== --- head/sys/dev/etherswitch/ip17x/ip17x_var.h Sat May 6 05:52:01 2017 (r317865) +++ head/sys/dev/etherswitch/ip17x/ip17x_var.h Sat May 6 05:53:42 2017 (r317866) @@ -53,6 +53,7 @@ struct ip17x_softc { int numports; /* number of ports */ int *portphy; device_t **miibus; + int miipoll; etherswitch_info_t info; ip17x_switch_type sc_switchtype; struct callout callout_tick;