From owner-svn-src-user@FreeBSD.ORG Sun Apr 25 05:09:09 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A6B2106564A; Sun, 25 Apr 2010 05:09:09 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 20E498FC12; Sun, 25 Apr 2010 05:09:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3P599mJ053928; Sun, 25 Apr 2010 05:09:09 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3P598GX053927; Sun, 25 Apr 2010 05:09:08 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201004250509.o3P598GX053927@svn.freebsd.org> From: Juli Mallett Date: Sun, 25 Apr 2010 05:09:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207185 - user/jmallett/octeon/sys/mips/cavium/octe X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Apr 2010 05:09:09 -0000 Author: jmallett Date: Sun Apr 25 05:09:08 2010 New Revision: 207185 URL: http://svn.freebsd.org/changeset/base/207185 Log: o) Allow miibus attachment to fail, falling back to non-MII media handling. o) Only allow miibus access to *our* PHY on the shared MII bus. XXX The PHY numbering that we get from the Simple Executive seems to be off or we're not configuring something right at the MII layer or something; the miibus correctly finds the RTL8212 chips on the CAM-0100 and says they are at PHY 2 and PHY 3. Except octe0 and octe1 think their PHYs are #4 and #9 respectively. Modified: user/jmallett/octeon/sys/mips/cavium/octe/octe.c Modified: user/jmallett/octeon/sys/mips/cavium/octe/octe.c ============================================================================== --- user/jmallett/octeon/sys/mips/cavium/octe/octe.c Sun Apr 25 04:04:22 2010 (r207184) +++ user/jmallett/octeon/sys/mips/cavium/octe/octe.c Sun Apr 25 05:09:08 2010 (r207185) @@ -145,20 +145,21 @@ octe_attach(device_t dev) if_initname(ifp, device_get_name(dev), device_get_unit(dev)); - ifmedia_init(&priv->media, 0, octe_medchange, octe_medstat); - if (priv->phy_id == -1) { - ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL); - ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO); - } else { + if (priv->phy_id != -1) { error = mii_phy_probe(dev, &priv->miibus, octe_mii_medchange, octe_mii_medstat); if (error != 0) { - device_printf(dev, "could not find PHY!\n"); - /* XXX Cleanup. */ - return (error); + device_printf(dev, "missing phy %u\n", priv->phy_id); } } + if (priv->miibus == NULL) { + ifmedia_init(&priv->media, 0, octe_medchange, octe_medstat); + + ifmedia_add(&priv->media, IFM_ETHER | IFM_AUTO, 0, NULL); + ifmedia_set(&priv->media, IFM_ETHER | IFM_AUTO); + } + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_init = octe_init; ifp->if_ioctl = octe_ioctl; @@ -199,6 +200,9 @@ octe_miibus_readreg(device_t dev, int ph priv = device_get_softc(dev); + if (phy != priv->phy_id) + return (0); + return (cvm_oct_mdio_read(priv->ifp, phy, reg)); } @@ -209,6 +213,9 @@ octe_miibus_writereg(device_t dev, int p priv = device_get_softc(dev); + KASSERT(phy == priv->phy_id, + ("write to phy %u but our phy is %u", phy, priv->phy_id)); + cvm_oct_mdio_write(priv->ifp, phy, reg, val); return (0);