Date: Wed, 19 Feb 2014 06:02:48 +0000 (UTC) From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262205 - head/sys/dev/etherswitch/arswitch Message-ID: <201402190602.s1J62mD6063961@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402190602.s1J62mD6063961>