summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/mii/amphy.c44
-rw-r--r--sys/dev/mii/brgphy.c64
-rw-r--r--sys/dev/mii/eephy.c47
3 files changed, 80 insertions, 75 deletions
diff --git a/sys/dev/mii/amphy.c b/sys/dev/mii/amphy.c
index f4ab4555723..ef573635e32 100644
--- a/sys/dev/mii/amphy.c
+++ b/sys/dev/mii/amphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: amphy.c,v 1.10 2005/01/28 18:27:55 brad Exp $ */
+/* $OpenBSD: amphy.c,v 1.11 2005/02/05 19:11:34 brad Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -74,25 +74,28 @@ const struct mii_phy_funcs amphy_funcs = {
amphy_service, amphy_status, mii_phy_reset,
};
+static const struct mii_phydesc amphys[] = {
+ { MII_OUI_xxAMD, MII_MODEL_xxAMD_79C873,
+ MII_STR_xxAMD_79C873 },
+ { MII_OUI_xxDAVICOM, MII_MODEL_xxDAVICOM_DM9101,
+ MII_STR_xxDAVICOM_DM9101 },
+ { MII_OUI_DAVICOM, MII_MODEL_DAVICOM_DM9102,
+ MII_STR_DAVICOM_DM9102 },
+ { MII_OUI_DAVICOM, MII_MODEL_DAVICOM_DM9601,
+ MII_STR_DAVICOM_DM9601 },
+ { MII_OUI_xxALTIMA, MII_MODEL_AMD_79C875phy,
+ MII_STR_AMD_79C875phy },
+
+ { 0, 0,
+ NULL },
+};
+
int
amphymatch(struct device *parent, void *match, void *aux)
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxAMD &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxAMD_79C873)
- return (10);
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxDAVICOM &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxDAVICOM_DM9101)
- return(10);
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_DAVICOM &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_DAVICOM_DM9102)
- return(10);
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_DAVICOM &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_DAVICOM_DM9601)
- return(10);
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxALTIMA && /*XXX*/
- MII_MODEL(ma->mii_id2) == MII_MODEL_AMD_79C875phy)
+ if(mii_phy_match(ma, amphys) != NULL)
return(10);
return(0);
@@ -104,15 +107,10 @@ amphyattach(struct device *parent, struct device *self, void *aux)
struct mii_softc *sc = (struct mii_softc *)self;
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
+ const struct mii_phydesc *mpd;
- if ((MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxALTIMA && /*XXX*/
- MII_MODEL(ma->mii_id2) == MII_MODEL_AMD_79C875phy)) {
- printf(": %s, rev. %d\n", MII_STR_AMD_79C875phy,
- MII_REV(ma->mii_id2));
- } else {
- printf(": %s, rev. %d\n", MII_STR_xxAMD_79C873,
- MII_REV(ma->mii_id2));
- }
+ mpd = mii_phy_match(ma, amphys);
+ printf(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
diff --git a/sys/dev/mii/brgphy.c b/sys/dev/mii/brgphy.c
index 0a8ba6a1758..f383548c5e3 100644
--- a/sys/dev/mii/brgphy.c
+++ b/sys/dev/mii/brgphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: brgphy.c,v 1.20 2005/01/24 02:27:12 brad Exp $ */
+/* $OpenBSD: brgphy.c,v 1.21 2005/02/05 19:11:34 brad Exp $ */
/*
* Copyright (c) 2000
@@ -89,21 +89,36 @@ const struct mii_phy_funcs brgphy_funcs = {
brgphy_service, brgphy_status, brgphy_reset,
};
+static const struct mii_phydesc brgphys[] = {
+ { MII_OUI_xxBROADCOM, MII_MODEL_xxBROADCOM_BCM5400,
+ MII_STR_xxBROADCOM_BCM5400 },
+ { MII_OUI_xxBROADCOM, MII_MODEL_xxBROADCOM_BCM5401,
+ MII_STR_xxBROADCOM_BCM5401 },
+ { MII_OUI_xxBROADCOM, MII_MODEL_xxBROADCOM_BCM5411,
+ MII_STR_xxBROADCOM_BCM5411 },
+ { MII_OUI_xxBROADCOM, MII_MODEL_xxBROADCOM_BCM5421S,
+ MII_STR_xxBROADCOM_BCM5421S },
+ { MII_OUI_xxBROADCOM, MII_MODEL_xxBROADCOM_BCM5701,
+ MII_STR_xxBROADCOM_BCM5701 },
+ { MII_OUI_xxBROADCOM, MII_MODEL_xxBROADCOM_BCM5703,
+ MII_STR_xxBROADCOM_BCM5703 },
+ { MII_OUI_xxBROADCOM, MII_MODEL_xxBROADCOM_BCM5704,
+ MII_STR_xxBROADCOM_BCM5704 },
+ { MII_OUI_xxBROADCOM, MII_MODEL_xxBROADCOM_BCM5705,
+ MII_STR_xxBROADCOM_BCM5705 },
+ { MII_OUI_xxBROADCOM, MII_MODEL_xxBROADCOM_BCM5750,
+ MII_STR_xxBROADCOM_BCM5750 },
+
+ { 0, 0,
+ NULL },
+};
+
int
brgphy_probe(struct device *parent, void *match, void *aux)
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxBROADCOM &&
- (MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5400 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5401 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5411 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5421S ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5701 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5703 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5704 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5705 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5750))
+ if(mii_phy_match(ma, brgphys) != NULL)
return(10);
return(0);
@@ -115,29 +130,10 @@ brgphy_attach(struct device *parent, struct device *self, void *aux)
struct mii_softc *sc = (struct mii_softc *)self;
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
- char *model;
-
- if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5400 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_BROADCOM_BCM5400)
- model = MII_STR_BROADCOM_BCM5400;
- if (MII_MODEL(ma->mii_id2) == MII_MODEL_BROADCOM_BCM5401)
- model = MII_STR_BROADCOM_BCM5401;
- if (MII_MODEL(ma->mii_id2) == MII_MODEL_BROADCOM_BCM5411)
- model = MII_STR_BROADCOM_BCM5411;
- if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5421S)
- model = MII_STR_xxBROADCOM_BCM5421S;
- if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5701)
- model = MII_STR_xxBROADCOM_BCM5701;
- if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5703)
- model = MII_STR_xxBROADCOM_BCM5703;
- if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5704)
- model = MII_STR_xxBROADCOM_BCM5704;
- if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5705)
- model = MII_STR_xxBROADCOM_BCM5705;
- if (MII_MODEL(ma->mii_id2) == MII_MODEL_xxBROADCOM_BCM5750)
- model = MII_STR_xxBROADCOM_BCM5750;
-
- printf(": %s, rev. %d\n", model, MII_REV(ma->mii_id2));
+ const struct mii_phydesc *mpd;
+
+ mpd = mii_phy_match(ma, brgphys);
+ printf(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
diff --git a/sys/dev/mii/eephy.c b/sys/dev/mii/eephy.c
index b5d0222bd3f..f2f936979ef 100644
--- a/sys/dev/mii/eephy.c
+++ b/sys/dev/mii/eephy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eephy.c,v 1.14 2005/01/28 18:27:55 brad Exp $ */
+/* $OpenBSD: eephy.c,v 1.15 2005/02/05 19:11:34 brad Exp $ */
/*
* Principal Author: Parag Patel
* Copyright (c) 2001
@@ -55,7 +55,6 @@
#include <dev/mii/eephyreg.h>
-
int eephy_service(struct mii_softc *, struct mii_data *, int);
void eephy_status(struct mii_softc *);
int eephymatch(struct device *, void *, void *);
@@ -79,24 +78,36 @@ const struct mii_phy_funcs eephy_funcs = {
eephy_service, eephy_status, eephy_reset,
};
+static const struct mii_phydesc eephys[] = {
+ { MII_OUI_xxMARVELL, MII_MODEL_xxMARVELL_E1000_3,
+ MII_STR_xxMARVELL_E1000_3 },
+ { MII_OUI_xxMARVELL, MII_MODEL_xxMARVELL_E1000_5,
+ MII_STR_xxMARVELL_E1000_5 },
+ { MII_OUI_MARVELL, MII_MODEL_MARVELL_E1000,
+ MII_STR_MARVELL_E1000 },
+ { MII_OUI_MARVELL, MII_MODEL_MARVELL_E1011,
+ MII_STR_MARVELL_E1011 },
+ { MII_OUI_MARVELL, MII_MODEL_MARVELL_E1000_3,
+ MII_STR_MARVELL_E1000_3 },
+ { MII_OUI_MARVELL, MII_MODEL_MARVELL_E1000_4,
+ MII_STR_MARVELL_E1000_4 },
+ { MII_OUI_MARVELL, MII_MODEL_MARVELL_E1000_5,
+ MII_STR_MARVELL_E1000_5 },
+ { MII_OUI_MARVELL, MII_MODEL_MARVELL_E1000_6,
+ MII_STR_MARVELL_E1000_6 },
+ { MII_OUI_MARVELL, MII_MODEL_MARVELL_E1000_7,
+ MII_STR_MARVELL_E1000_7 },
+
+ { 0, 0,
+ NULL },
+};
+
int
eephymatch(struct device *parent, void *match, void *aux)
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxMARVELL &&
- (MII_MODEL(ma->mii_id2) == MII_MODEL_xxMARVELL_E1000_3 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxMARVELL_E1000_5 ))
- return (10);
-
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_MARVELL &&
- (MII_MODEL(ma->mii_id2) == MII_MODEL_MARVELL_E1000 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_MARVELL_E1011 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_MARVELL_E1000_3 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_MARVELL_E1000_4 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_MARVELL_E1000_5 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_MARVELL_E1000_6 ||
- MII_MODEL(ma->mii_id2) == MII_MODEL_MARVELL_E1000_7))
+ if(mii_phy_match(ma, eephys) != NULL)
return (10);
return(0);
@@ -108,10 +119,10 @@ eephyattach(struct device *parent, struct device *self, void *aux)
struct mii_softc *sc = (struct mii_softc *)self;
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
- char *sep;
+ const struct mii_phydesc *mpd;
- sep = "";
- printf(": %s\n", MII_STR_MARVELL_E1000);
+ mpd = mii_phy_match(ma, eephys);
+ printf(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;