From owner-svn-src-all@freebsd.org Sat Dec 26 17:22:03 2015 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 6DDA2A52C46; Sat, 26 Dec 2015 17:22:03 +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 44DC71DD0; Sat, 26 Dec 2015 17:22:03 +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 tBQHM2X2004734; Sat, 26 Dec 2015 17:22:02 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBQHM2ui004731; Sat, 26 Dec 2015 17:22:02 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201512261722.tBQHM2ui004731@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 26 Dec 2015 17:22:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r292750 - head/sys/dev/mdio 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.20 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, 26 Dec 2015 17:22:03 -0000 Author: adrian Date: Sat Dec 26 17:22:02 2015 New Revision: 292750 URL: https://svnweb.freebsd.org/changeset/base/292750 Log: [mdio] Add MDIO support for "extended" registers as defined by IEEE 802.3 Clause 45. IEEE 802.3 Clause 45 added backwards-compatible support for 2^16 PHY registers through the addition of an additional device address frame. Clause 45 addressing is used in 10Gbe PHYs, 802.3az EEE registers, etc. It may make sense to provide a similar extension to the miibus interface, but I've refrained from unilaterally doing so here. Submitted by: Landon Fuller Differential Revision: https://reviews.freebsd.org/D4607 Modified: head/sys/dev/mdio/mdio.c head/sys/dev/mdio/mdio.h head/sys/dev/mdio/mdio_if.m Modified: head/sys/dev/mdio/mdio.c ============================================================================== --- head/sys/dev/mdio/mdio.c Sat Dec 26 15:40:12 2015 (r292749) +++ head/sys/dev/mdio/mdio.c Sat Dec 26 17:22:02 2015 (r292750) @@ -83,6 +83,21 @@ mdio_writereg(device_t dev, int phy, int return (MDIO_WRITEREG(device_get_parent(dev), phy, reg, val)); } +static int +mdio_readextreg(device_t dev, int phy, int devad, int reg) +{ + + return (MDIO_READEXTREG(device_get_parent(dev), phy, devad, reg)); +} + +static int +mdio_writeextreg(device_t dev, int phy, int devad, int reg, + int val) +{ + + return (MDIO_WRITEEXTREG(device_get_parent(dev), phy, devad, reg, val)); +} + static void mdio_hinted_child(device_t dev, const char *name, int unit) { @@ -105,6 +120,8 @@ static device_method_t mdio_methods[] = /* MDIO access */ DEVMETHOD(mdio_readreg, mdio_readreg), DEVMETHOD(mdio_writereg, mdio_writereg), + DEVMETHOD(mdio_readextreg, mdio_readextreg), + DEVMETHOD(mdio_writeextreg, mdio_writeextreg), DEVMETHOD_END }; Modified: head/sys/dev/mdio/mdio.h ============================================================================== --- head/sys/dev/mdio/mdio.h Sat Dec 26 15:40:12 2015 (r292749) +++ head/sys/dev/mdio/mdio.h Sat Dec 26 17:22:02 2015 (r292750) @@ -32,4 +32,6 @@ extern driver_t mdio_driver; extern devclass_t mdio_devclass; +#define MDIO_DEVADDR_NONE -1 /**< Use clause 22 register access */ + #endif /* __DEV_MDIO_MDIO_H__ */ Modified: head/sys/dev/mdio/mdio_if.m ============================================================================== --- head/sys/dev/mdio/mdio_if.m Sat Dec 26 15:40:12 2015 (r292749) +++ head/sys/dev/mdio/mdio_if.m Sat Dec 26 17:22:02 2015 (r292750) @@ -4,21 +4,88 @@ INTERFACE mdio; -# -# Read register from device on MDIO bus -# +CODE { + #include + + static int + mdio_null_readextreg(device_t dev, int phy, int devad, int reg) + { + if (devad == MDIO_DEVADDR_NONE) + return (MDIO_READREG(dev, phy, reg)); + return (~0U); + } + + static int + mdio_null_writeextreg(device_t dev, int phy, int devad, int reg, + int val) + { + if (devad == MDIO_DEVADDR_NONE) + return (MDIO_WRITEREG(dev, phy, reg, val)); + + return (EINVAL); + } +} + +/** + * @brief Read register from device on MDIO bus. + * + * @param dev MDIO bus device. + * @param phy PHY address. + * @param reg The PHY register offset. + */ METHOD int readreg { device_t dev; int phy; int reg; }; -# -# Write register to device on MDIO bus -# +/** + * @brief Write register to device on MDIO bus. + * + * @param dev MDIO bus device. + * @param phy PHY address. + * @param reg The PHY register offset. + * @param val The value to write at offset @p reg. + */ METHOD int writereg { device_t dev; int phy; int reg; int val; }; + + +/** + * @brief Read extended register from device on MDIO bus. + * + * @param dev MDIO bus device. + * @param phy PHY address. + * @param devad The MDIO IEEE 802.3 Clause 45 device address, or + * MDIO_DEVADDR_NONE to request Clause 22 register addressing. + * @param reg The PHY register offset. + */ +METHOD int readextreg { + device_t dev; + int phy; + int devad; + int reg; +} DEFAULT mdio_null_readextreg; + + +/** + * @brief Write extended register to device on MDIO bus. + * + * @param dev MDIO bus device. + * @param phy PHY address. + * @param devad The MDIO IEEE 802.3 Clause 45 device address, or + * MDIO_DEVADDR_NONE to request Clause 22 register addressing. + * @param reg The PHY register offset. + * @param val The value to write at offset @p reg. + */ +METHOD int writeextreg { + device_t dev; + int phy; + int devad; + int reg; + int val; +} DEFAULT mdio_null_writeextreg;