From owner-svn-src-all@FreeBSD.ORG Wed Feb 19 06:02:48 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 938EBC8B; Wed, 19 Feb 2014 06:02:48 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 64F2A1C70; Wed, 19 Feb 2014 06:02:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1J62m89063962; Wed, 19 Feb 2014 06:02:48 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1J62mD6063961; Wed, 19 Feb 2014 06:02:48 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201402190602.s1J62mD6063961@svn.freebsd.org> From: Adrian Chadd Date: Wed, 19 Feb 2014 06:02:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262205 - head/sys/dev/etherswitch/arswitch 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.17 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: Wed, 19 Feb 2014 06:02:48 -0000 Author: adrian Date: Wed Feb 19 06:02:47 2014 New Revision: 262205 URL: http://svnweb.freebsd.org/changeset/base/262205 Log: Teach the PHY register path about the different MDIO bus address for the AR8327. Tested: * AR8327, DB120 Modified: head/sys/dev/etherswitch/arswitch/arswitch_phy.c Modified: head/sys/dev/etherswitch/arswitch/arswitch_phy.c ============================================================================== --- head/sys/dev/etherswitch/arswitch/arswitch_phy.c Wed Feb 19 06:01:40 2014 (r262204) +++ head/sys/dev/etherswitch/arswitch/arswitch_phy.c Wed Feb 19 06:02:47 2014 (r262205) @@ -76,6 +76,7 @@ arswitch_readphy(device_t dev, int phy, struct arswitch_softc *sc; uint32_t data = 0, ctrl; int err, timeout; + uint32_t a; sc = device_get_softc(dev); ARSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED); @@ -85,8 +86,13 @@ arswitch_readphy(device_t dev, int phy, if (reg < 0 || reg >= 32) return (ENXIO); + if (AR8X16_IS_SWITCH(sc, AR8327)) + a = AR8327_REG_MDIO_CTRL; + else + a = AR8X16_REG_MDIO_CTRL; + ARSWITCH_LOCK(sc); - err = arswitch_writereg_msb(dev, AR8X16_REG_MDIO_CTRL, + err = arswitch_writereg_msb(dev, a, AR8X16_MDIO_CTRL_BUSY | AR8X16_MDIO_CTRL_MASTER_EN | AR8X16_MDIO_CTRL_CMD_READ | (phy << AR8X16_MDIO_CTRL_PHY_ADDR_SHIFT) | @@ -95,13 +101,13 @@ arswitch_readphy(device_t dev, int phy, if (err != 0) goto fail; for (timeout = 100; timeout--; ) { - ctrl = arswitch_readreg_msb(dev, AR8X16_REG_MDIO_CTRL); + ctrl = arswitch_readreg_msb(dev, a); if ((ctrl & AR8X16_MDIO_CTRL_BUSY) == 0) break; } if (timeout < 0) goto fail; - data = arswitch_readreg_lsb(dev, AR8X16_REG_MDIO_CTRL) & + data = arswitch_readreg_lsb(dev, a) & AR8X16_MDIO_CTRL_DATA_MASK; ARSWITCH_UNLOCK(sc); return (data); @@ -117,6 +123,7 @@ arswitch_writephy(device_t dev, int phy, struct arswitch_softc *sc; uint32_t ctrl; int err, timeout; + uint32_t a; sc = device_get_softc(dev); ARSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED); @@ -124,8 +131,13 @@ arswitch_writephy(device_t dev, int phy, if (reg < 0 || reg >= 32) return (ENXIO); + if (AR8X16_IS_SWITCH(sc, AR8327)) + a = AR8327_REG_MDIO_CTRL; + else + a = AR8X16_REG_MDIO_CTRL; + ARSWITCH_LOCK(sc); - err = arswitch_writereg(dev, AR8X16_REG_MDIO_CTRL, + err = arswitch_writereg(dev, a, AR8X16_MDIO_CTRL_BUSY | AR8X16_MDIO_CTRL_MASTER_EN | AR8X16_MDIO_CTRL_CMD_WRITE | @@ -135,7 +147,7 @@ arswitch_writephy(device_t dev, int phy, if (err != 0) goto out; for (timeout = 100; timeout--; ) { - ctrl = arswitch_readreg(dev, AR8X16_REG_MDIO_CTRL); + ctrl = arswitch_readreg(dev, a); if ((ctrl & AR8X16_MDIO_CTRL_BUSY) == 0) break; }