Add code to recognize and set media on GMII (Gigabit MII) PHYs.

802.3 doens't specify ANAR or ANLPAR bits for GMII.  Need to
use PHY-specific registers for this, for now, which means we
need specific drivers for the Gigabit-capable PHYs (I think the
most common is the BCM5400).
This commit is contained in:
thorpej 2001-04-30 19:49:08 +00:00
parent 99d1259e7f
commit d3a64bd0d8
4 changed files with 48 additions and 23 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mii.h,v 1.5 2001/04/30 19:21:03 thorpej Exp $ */
/* $NetBSD: mii.h,v 1.6 2001/04/30 19:49:08 thorpej Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer. All rights reserved.
@ -157,4 +157,7 @@
#define EXTSR_1000TFDX 0x2000 /* 1000T full-duplex capable */
#define EXTSR_1000THDX 0x1000 /* 1000T half-duplex capable */
#define EXTSR_MEDIAMASK (EXTSR_1000XFDX|EXTSR_1000XHDX| \
EXTSR_1000TFDX|EXTSR_1000THDX)
#endif /* _DEV_MII_MII_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mii_physubr.c,v 1.20 2001/04/13 23:30:09 thorpej Exp $ */
/* $NetBSD: mii_physubr.c,v 1.21 2001/04/30 19:49:08 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@ -58,14 +58,17 @@
/*
* Media to register setting conversion table. Order matters.
* XXX 802.3 doesn't specify ANAR or ANLPAR bits for 1000base.
*/
const struct mii_media mii_media_table[] = {
{ BMCR_ISO, ANAR_CSMA }, /* None */
{ 0, ANAR_CSMA|ANAR_10 }, /* 10baseT */
{ BMCR_FDX, ANAR_CSMA|ANAR_10_FD }, /* 10baseT-FDX */
{ BMCR_S10, ANAR_CSMA|ANAR_10 }, /* 10baseT */
{ BMCR_S10|BMCR_FDX, ANAR_CSMA|ANAR_10_FD }, /* 10baseT-FDX */
{ BMCR_S100, ANAR_CSMA|ANAR_T4 }, /* 100baseT4 */
{ BMCR_S100, ANAR_CSMA|ANAR_TX }, /* 100baseTX */
{ BMCR_S100|BMCR_FDX, ANAR_CSMA|ANAR_TX_FD }, /* 100baseTX-FDX */
{ BMCR_S1000, ANAR_CSMA }, /* 1000base */
{ BMCR_S1000|BMCR_FDX, ANAR_CSMA }, /* 1000base-FDX */
};
void mii_phy_auto_timeout __P((void *));
@ -339,11 +342,6 @@ mii_phy_add_media(sc)
if (sc->mii_capabilities & BMSR_10THDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, sc->mii_inst),
MII_MEDIA_10_T);
#if 0
if ((sc->mii_flags & MIIF_NOLOOP) == 0)
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_10_T, IFM_LOOP,
sc->mii_inst), MII_MEDIA_10_T);
#endif
PRINT("10baseT");
}
if (sc->mii_capabilities & BMSR_10TFDX) {
@ -354,11 +352,6 @@ mii_phy_add_media(sc)
if (sc->mii_capabilities & BMSR_100TXHDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, 0, sc->mii_inst),
MII_MEDIA_100_TX);
#if 0
if ((sc->mii_flags & MIIF_NOLOOP) == 0)
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP,
sc->mii_inst), MII_MEDIA_100_TX);
#endif
PRINT("100baseTX");
}
if (sc->mii_capabilities & BMSR_100TXFDX) {
@ -369,13 +362,36 @@ mii_phy_add_media(sc)
if (sc->mii_capabilities & BMSR_100T4) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_T4, 0, sc->mii_inst),
MII_MEDIA_100_T4);
#if 0
if ((sc->mii_flags & MIIF_NOLOOP) == 0)
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_T4, IFM_LOOP,
sc->mii_inst), MII_MEDIA_100_T4);
#endif
PRINT("100baseT4");
}
if (sc->mii_extcapabilities & EXTSR_MEDIAMASK) {
/*
* XXX Right now only handle 1000SX and 1000TX. Need
* XXX to hnalde 1000LX and 1000CX some how.
*/
if (sc->mii_extcapabilities & EXTSR_1000XHDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, 0,
sc->mii_inst), MII_MEDIA_1000);
PRINT("1000baseSX");
}
if (sc->mii_extcapabilities & EXTSR_1000XFDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_SX, IFM_FDX,
sc->mii_inst), MII_MEDIA_1000_FDX);
PRINT("1000baseSX-FDX");
}
if (sc->mii_extcapabilities & EXTSR_1000THDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_TX, 0,
sc->mii_inst), MII_MEDIA_1000);
PRINT("1000baseTX");
}
if (sc->mii_extcapabilities & EXTSR_1000TFDX) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_1000_TX, IFM_FDX,
sc->mii_inst), MII_MEDIA_1000_FDX);
PRINT("1000baseTX-FDX");
}
}
if (sc->mii_capabilities & BMSR_ANEG) {
ADD(IFM_MAKEWORD(IFM_ETHER, IFM_AUTO, 0, sc->mii_inst),
MII_NMEDIA); /* intentionally invalid index */

View File

@ -1,4 +1,4 @@
/* $NetBSD: miivar.h,v 1.22 2001/04/13 11:14:55 augustss Exp $ */
/* $NetBSD: miivar.h,v 1.23 2001/04/30 19:49:08 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@ -128,6 +128,7 @@ struct mii_softc {
int mii_flags; /* misc. flags; see below */
int mii_capabilities; /* capabilities from BMSR */
int mii_extcapabilities; /* extended capabilities */
int mii_ticks; /* MII_TICK counter */
struct callout mii_nway_ch; /* NWAY callout */
@ -183,7 +184,9 @@ struct mii_media {
#define MII_MEDIA_100_T4 3
#define MII_MEDIA_100_TX 4
#define MII_MEDIA_100_TX_FDX 5
#define MII_NMEDIA 6
#define MII_MEDIA_1000 6
#define MII_MEDIA_1000_FDX 7
#define MII_NMEDIA 8
#ifdef _KERNEL
#include "locators.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: ukphy.c,v 1.13 2000/07/04 03:29:00 thorpej Exp $ */
/* $NetBSD: ukphy.c,v 1.14 2001/04/30 19:49:08 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@ -168,8 +168,11 @@ ukphyattach(parent, self, aux)
sc->mii_capabilities =
PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
if (sc->mii_capabilities & BMSR_EXTSTAT)
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
printf("%s: ", sc->mii_dev.dv_xname);
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 &&
(sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0)
printf("no media present");
else
mii_phy_add_media(sc);