From owner-svn-src-stable@FreeBSD.ORG Mon Mar 26 02:40:55 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41255106566B; Mon, 26 Mar 2012 02:40:55 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 21A2E8FC1F; Mon, 26 Mar 2012 02:40:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2Q2esnD010297; Mon, 26 Mar 2012 02:40:54 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2Q2esNC010294; Mon, 26 Mar 2012 02:40:54 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201203260240.q2Q2esNC010294@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 26 Mar 2012 02:40:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233485 - in stable/9/sys: dev/mii i386/conf modules/mii X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2012 02:40:55 -0000 Author: yongari Date: Mon Mar 26 02:40:54 2012 New Revision: 233485 URL: http://svn.freebsd.org/changeset/base/233485 Log: MFC r232015-232016: r232015: Add Seeq Technology 80220 PHY support to smcphy(4). This PHY is found on Adaptec AIC-6915 Starfire ethernet controller. While here, use status register to know resolved speed/duplex. With this change, sf(4) correctly reports speed/duplex of established link. r232016: Connect smcphy(4) to mii module build. Modified: stable/9/sys/dev/mii/smcphy.c stable/9/sys/modules/mii/Makefile Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/i386/conf/XENHVM (props changed) Modified: stable/9/sys/dev/mii/smcphy.c ============================================================================== --- stable/9/sys/dev/mii/smcphy.c Mon Mar 26 01:26:33 2012 (r233484) +++ stable/9/sys/dev/mii/smcphy.c Mon Mar 26 02:40:54 2012 (r233485) @@ -55,6 +55,7 @@ static int smcphy_attach(device_t); static int smcphy_service(struct mii_softc *, struct mii_data *, int); static void smcphy_reset(struct mii_softc *); static void smcphy_auto(struct mii_softc *, int); +static void smcphy_status(struct mii_softc *); static device_method_t smcphy_methods[] = { /* device interface */ @@ -76,13 +77,20 @@ static driver_t smcphy_driver = { DRIVER_MODULE(smcphy, miibus, smcphy_driver, smcphy_devclass, 0, 0); static const struct mii_phydesc smcphys[] = { + MII_PHY_DESC(SEEQ, 80220), MII_PHY_DESC(SEEQ, 84220), MII_PHY_END }; +static const struct mii_phy_funcs smcphy80220_funcs = { + smcphy_service, + smcphy_status, + mii_phy_reset +}; + static const struct mii_phy_funcs smcphy_funcs = { smcphy_service, - ukphy_status, + smcphy_status, smcphy_reset }; @@ -97,11 +105,16 @@ static int smcphy_attach(device_t dev) { struct mii_softc *sc; + struct mii_attach_args *ma; + const struct mii_phy_funcs *mpf; sc = device_get_softc(dev); - - mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE, - &smcphy_funcs, 1); + ma = device_get_ivars(dev); + if (MII_MODEL(ma->mii_id2) == MII_MODEL_SEEQ_80220) + mpf = &smcphy80220_funcs; + else + mpf = &smcphy_funcs; + mii_phy_dev_attach(dev, MIIF_NOISOLATE | MIIF_NOMANPAUSE, mpf, 1); mii_phy_setmedia(sc); return (0); @@ -214,3 +227,46 @@ smcphy_auto(struct mii_softc *sc, int me anar = PHY_READ(sc, MII_ANAR); PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_STARTNEG); } + +static void +smcphy_status(struct mii_softc *sc) +{ + struct mii_data *mii; + uint32_t bmcr, bmsr, status; + + mii = sc->mii_pdata; + mii->mii_media_status = IFM_AVALID; + mii->mii_media_active = IFM_ETHER; + + bmsr = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); + if ((bmsr & BMSR_LINK) != 0) + mii->mii_media_status |= IFM_ACTIVE; + + bmcr = PHY_READ(sc, MII_BMCR); + if ((bmcr & BMCR_ISO) != 0) { + mii->mii_media_active |= IFM_NONE; + mii->mii_media_status = 0; + return; + } + + if ((bmcr & BMCR_LOOP) != 0) + mii->mii_media_active |= IFM_LOOP; + + if ((bmcr & BMCR_AUTOEN) != 0) { + if ((bmsr & BMSR_ACOMP) == 0) { + /* Erg, still trying, I guess... */ + mii->mii_media_active |= IFM_NONE; + return; + } + } + + status = PHY_READ(sc, 0x12); + if (status & 0x0080) + mii->mii_media_active |= IFM_100_TX; + else + mii->mii_media_active |= IFM_10_T; + if (status & 0x0040) + mii->mii_media_active |= IFM_FDX | mii_phy_flowstatus(sc); + else + mii->mii_media_active |= IFM_HDX; +} Modified: stable/9/sys/modules/mii/Makefile ============================================================================== --- stable/9/sys/modules/mii/Makefile Mon Mar 26 01:26:33 2012 (r233484) +++ stable/9/sys/modules/mii/Makefile Mon Mar 26 02:40:54 2012 (r233485) @@ -8,7 +8,7 @@ SRCS+= ciphy.c device_if.h SRCS+= e1000phy.c gentbi.c icsphy.c ip1000phy.c jmphy.c lxtphy.c SRCS+= miibus_if.c miibus_if.h mii.c miidevs.h mii_bitbang.c mii_physubr.c SRCS+= mlphy.c nsgphy.c nsphy.c nsphyter.c pci_if.h pnaphy.c qsphy.c -SRCS+= rdcphy.c rgephy.c rlphy.c tdkphy.c tlphy.c truephy.c +SRCS+= rdcphy.c rgephy.c rlphy.c smcphy.c tdkphy.c tlphy.c truephy.c SRCS+= ukphy.c ukphy_subr.c SRCS+= xmphy.c