Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Mar 2012 02:40:54 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r233485 - in stable/9/sys: dev/mii i386/conf modules/mii
Message-ID:  <201203260240.q2Q2esNC010294@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203260240.q2Q2esNC010294>