summaryrefslogtreecommitdiff
path: root/sys/dev/mii
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2005-02-05 22:20:43 +0000
committerBrad Smith <brad@cvs.openbsd.org>2005-02-05 22:20:43 +0000
commit07327fa3636b7451ac44f7675de60f241c008ed8 (patch)
tree3607e4a6d8a437abb56ed6a96e9b9f0b8d88c454 /sys/dev/mii
parent1a3645ca83813fc2e64c18e68bc05f090c935f93 (diff)
use mii_phy_match()
Diffstat (limited to 'sys/dev/mii')
-rw-r--r--sys/dev/mii/ciphy.c48
-rw-r--r--sys/dev/mii/icsphy.c44
-rw-r--r--sys/dev/mii/inphy.c42
-rw-r--r--sys/dev/mii/iophy.c25
-rw-r--r--sys/dev/mii/lxtphy.c27
-rw-r--r--sys/dev/mii/nsphyter.c29
6 files changed, 100 insertions, 115 deletions
diff --git a/sys/dev/mii/ciphy.c b/sys/dev/mii/ciphy.c
index 60e7a0c7f0e..32dee8f6cf8 100644
--- a/sys/dev/mii/ciphy.c
+++ b/sys/dev/mii/ciphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ciphy.c,v 1.2 2005/01/28 18:27:55 brad Exp $ */
+/* $OpenBSD: ciphy.c,v 1.3 2005/02/05 22:20:42 brad Exp $ */
/* $FreeBSD: ciphy.c,v 1.1 2004/09/10 20:57:45 wpaul Exp $ */
/*
* Copyright (c) 2004
@@ -85,25 +85,25 @@ const struct mii_phy_funcs ciphy_funcs = {
ciphy_service, ciphy_status, ciphy_reset,
};
+static const struct mii_phydesc ciphys[] = {
+ { MII_OUI_CICADA, MII_MODEL_CICADA_CS8201,
+ MII_STR_CICADA_CS8201 },
+ { MII_OUI_CICADA, MII_MODEL_CICADA_CS8201A,
+ MII_STR_CICADA_CS8201A },
+ { MII_OUI_CICADA, MII_MODEL_CICADA_CS8201B,
+ MII_STR_CICADA_CS8201B },
+
+ { 0, 0,
+ NULL },
+};
+
int
ciphymatch(struct device *parent, void *match, void *aux)
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201) {
- return (10);
- }
-
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201A) {
+ if (mii_phy_match(ma, ciphys) != NULL)
return (10);
- }
-
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201B) {
- return (10);
- }
return (0);
}
@@ -114,24 +114,10 @@ ciphyattach(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 *mstr;
-
- switch (MII_MODEL(ma->mii_id2)) {
- case MII_MODEL_CICADA_CS8201:
- mstr = MII_STR_CICADA_CS8201;
- break;
- case MII_MODEL_CICADA_CS8201A:
- mstr = MII_STR_CICADA_CS8201A;
- break;
- case MII_MODEL_CICADA_CS8201B:
- mstr = MII_STR_CICADA_CS8201B;
- break;
- default:
- mstr = "unknown ciphy";
- break;
- }
+ const struct mii_phydesc *mpd;
- printf(": %s, rev. %d\n", mstr, MII_REV(ma->mii_id2));
+ mpd = mii_phy_match(ma, ciphys);
+ 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/icsphy.c b/sys/dev/mii/icsphy.c
index be6f994e3d7..96c554914f2 100644
--- a/sys/dev/mii/icsphy.c
+++ b/sys/dev/mii/icsphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icsphy.c,v 1.15 2005/01/28 18:27:55 brad Exp $ */
+/* $OpenBSD: icsphy.c,v 1.16 2005/02/05 22:20:42 brad Exp $ */
/* $NetBSD: icsphy.c,v 1.17 2000/02/02 23:34:56 thorpej Exp $ */
/*-
@@ -108,21 +108,25 @@ const struct mii_phy_funcs icsphy_funcs = {
icsphy_service, icsphy_status, icsphy_reset,
};
+static const struct mii_phydesc icsphys[] = {
+ { MII_OUI_xxICS, MII_MODEL_xxICS_1890,
+ MII_STR_xxICS_1890 },
+ { MII_OUI_xxICS, MII_MODEL_xxICS_1892,
+ MII_STR_xxICS_1892 },
+ { MII_OUI_xxICS, MII_MODEL_xxICS_1893,
+ MII_STR_xxICS_1893 },
+
+ { 0, 0,
+ NULL },
+
+};
+
int
icsphymatch(struct device *parent, void *match, void *aux)
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxICS &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxICS_1890)
- return (10);
-
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxICS &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxICS_1892)
- return (10);
-
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxICS &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxICS_1893)
+ if (mii_phy_match(ma, icsphys) != NULL)
return (10);
return (0);
@@ -134,22 +138,10 @@ icsphyattach(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_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxICS)
- switch (MII_MODEL(ma->mii_id2)) {
- case MII_MODEL_xxICS_1890:
- model = MII_STR_xxICS_1890;
- break;
- case MII_MODEL_xxICS_1892:
- model = MII_STR_xxICS_1892;
- break;
- case MII_MODEL_xxICS_1893:
- model = MII_STR_xxICS_1893;
- break;
- }
+ const struct mii_phydesc *mpd;
- printf(": %s, rev. %d\n", model, MII_REV(ma->mii_id2));
+ mpd = mii_phy_match(ma, icsphys);
+ 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/inphy.c b/sys/dev/mii/inphy.c
index 4d5740f7708..2d2854b954b 100644
--- a/sys/dev/mii/inphy.c
+++ b/sys/dev/mii/inphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inphy.c,v 1.11 2005/01/28 18:27:55 brad Exp $ */
+/* $OpenBSD: inphy.c,v 1.12 2005/02/05 22:20:42 brad Exp $ */
/* $NetBSD: inphy.c,v 1.18 2000/02/02 23:34:56 thorpej Exp $ */
/*-
@@ -107,6 +107,17 @@ const struct mii_phy_funcs inphy_funcs = {
inphy_service, inphy_status, mii_phy_reset,
};
+static const struct mii_phydesc inphys[] = {
+ { MII_OUI_INTEL, MII_MODEL_INTEL_I82555,
+ MII_STR_INTEL_I82555 },
+ { MII_OUI_INTEL, MII_MODEL_INTEL_I82562EM,
+ MII_STR_INTEL_I82562EM },
+ { MII_OUI_INTEL, MII_MODEL_INTEL_I82562ET,
+ MII_STR_INTEL_I82562ET },
+ { 0, 0,
+ NULL },
+};
+
int
inphymatch(parent, match, aux)
struct device *parent;
@@ -115,14 +126,8 @@ inphymatch(parent, match, aux)
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_INTEL) {
- switch (MII_MODEL(ma->mii_id2)) {
- case MII_MODEL_INTEL_I82555:
- case MII_MODEL_INTEL_I82562EM:
- case MII_MODEL_INTEL_I82562ET:
- return (10);
- }
- }
+ if (mii_phy_match(ma, inphys) != NULL)
+ return (10);
return (0);
}
@@ -135,23 +140,10 @@ inphyattach(parent, self, aux)
struct mii_softc *sc = (struct mii_softc *)self;
struct mii_attach_args *ma = aux;
struct mii_data *mii = ma->mii_data;
- char *mstr;
+ const struct mii_phydesc *mpd;
- switch (MII_MODEL(ma->mii_id2)) {
- case MII_MODEL_INTEL_I82555:
- mstr = MII_STR_INTEL_I82555;
- break;
- case MII_MODEL_INTEL_I82562EM:
- mstr = MII_STR_INTEL_I82562EM;
- break;
- case MII_MODEL_INTEL_I82562ET:
- mstr = MII_STR_INTEL_I82562ET;
- break;
- default:
- mstr = "unknown inphy";
- break;
- }
- printf(": %s, rev. %d\n", mstr, MII_REV(ma->mii_id2));
+ mpd = mii_phy_match(ma, inphys);
+ 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/iophy.c b/sys/dev/mii/iophy.c
index e2da3e23df8..1af4174baa2 100644
--- a/sys/dev/mii/iophy.c
+++ b/sys/dev/mii/iophy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iophy.c,v 1.10 2005/01/28 18:27:55 brad Exp $ */
+/* $OpenBSD: iophy.c,v 1.11 2005/02/05 22:20:42 brad Exp $ */
/* $NetBSD: iophy.c,v 1.8 2000/02/02 23:34:56 thorpej Exp $ */
/*
@@ -105,6 +105,17 @@ const struct mii_phy_funcs iophy_funcs = {
iophy_service, iophy_status, mii_phy_reset,
};
+static const struct mii_phydesc iophys[] = {
+ { MII_OUI_xxINTEL, MII_MODEL_xxINTEL_I82553,
+ MII_STR_xxINTEL_I82553 },
+ { MII_OUI_INTEL, MII_MODEL_INTEL_I82553,
+ MII_STR_INTEL_I82553 },
+
+ { 0, 0,
+ NULL },
+
+};
+
int
iophymatch(parent, match, aux)
struct device *parent;
@@ -113,12 +124,7 @@ iophymatch(parent, match, aux)
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxINTEL &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxINTEL_I82553)
- return (10);
-
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_INTEL &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_INTEL_I82553)
+ if (mii_phy_match(ma, iophys) != NULL)
return (10);
return (0);
@@ -132,9 +138,10 @@ iophyattach(parent, self, 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;
- printf(": %s, rev. %d\n", MII_STR_INTEL_I82553,
- MII_REV(ma->mii_id2));
+ mpd = mii_phy_match(ma, iophys);
+ 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/lxtphy.c b/sys/dev/mii/lxtphy.c
index 8c9906ecaea..abb5719aa8e 100644
--- a/sys/dev/mii/lxtphy.c
+++ b/sys/dev/mii/lxtphy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lxtphy.c,v 1.12 2005/01/28 18:27:55 brad Exp $ */
+/* $OpenBSD: lxtphy.c,v 1.13 2005/02/05 22:20:42 brad Exp $ */
/* $NetBSD: lxtphy.c,v 1.19 2000/02/02 23:34:57 thorpej Exp $ */
/*-
@@ -112,6 +112,16 @@ const struct mii_phy_funcs lxtphy971_funcs = {
lxtphy_service, ukphy_status, lxtphy_reset,
};
+static const struct mii_phydesc lxtphys[] = {
+ { MII_OUI_xxLEVEL1, MII_MODEL_xxLEVEL1_LXT970,
+ MII_STR_xxLEVEL1_LXT970 },
+ { MII_OUI_xxLEVEL1a, MII_MODEL_xxLEVEL1a_LXT971,
+ MII_STR_xxLEVEL1a_LXT971 },
+
+ { 0, 0,
+ NULL },
+};
+
int
lxtphymatch(parent, match, aux)
struct device *parent;
@@ -120,12 +130,7 @@ lxtphymatch(parent, match, aux)
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxLEVEL1 &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1_LXT970)
- return (10);
-
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxLEVEL1a &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1a_LXT971)
+ if (mii_phy_match(ma, lxtphys) != NULL)
return (10);
return (0);
@@ -139,20 +144,20 @@ lxtphyattach(parent, self, 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_xxLEVEL1 &&
MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1_LXT970) {
- printf(": %s, rev. %d\n", MII_STR_xxLEVEL1_LXT970,
- MII_REV(ma->mii_id2));
sc->mii_funcs = &lxtphy_funcs;
}
if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_xxLEVEL1a &&
MII_MODEL(ma->mii_id2) == MII_MODEL_xxLEVEL1a_LXT971) {
- printf(": %s, rev. %d\n", MII_STR_xxLEVEL1a_LXT971,
- MII_REV(ma->mii_id2));
sc->mii_funcs = &lxtphy971_funcs;
}
+ mpd = mii_phy_match(ma, lxtphys);
+ 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;
sc->mii_pdata = mii;
diff --git a/sys/dev/mii/nsphyter.c b/sys/dev/mii/nsphyter.c
index e5cab70a76b..0eef321db5f 100644
--- a/sys/dev/mii/nsphyter.c
+++ b/sys/dev/mii/nsphyter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nsphyter.c,v 1.9 2005/01/28 18:27:55 brad Exp $ */
+/* $OpenBSD: nsphyter.c,v 1.10 2005/02/05 22:20:42 brad Exp $ */
/* $NetBSD: nsphyter.c,v 1.5 2000/02/02 23:34:57 thorpej Exp $ */
/*-
@@ -107,18 +107,23 @@ const struct mii_phy_funcs nsphyter_funcs = {
nsphyter_service, nsphyter_status, mii_phy_reset,
};
+static const struct mii_phydesc nsphyterphys[] = {
+ { MII_OUI_NATSEMI, MII_MODEL_NATSEMI_DP83843,
+ MII_STR_NATSEMI_DP83843 },
+ { MII_OUI_NATSEMI, MII_MODEL_NATSEMI_DP83815,
+ MII_STR_NATSEMI_DP83815 },
+
+ { 0, 0,
+ NULL },
+};
+
int
nsphytermatch(struct device *parent, void *match, void *aux)
{
struct mii_attach_args *ma = aux;
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_NATSEMI) {
- switch (MII_MODEL(ma->mii_id2)) {
- case MII_MODEL_NATSEMI_DP83843:
- case MII_MODEL_NATSEMI_DP83815:
- return (10);
- }
- }
+ if (mii_phy_match(ma, nsphyterphys) != NULL)
+ return (10);
return (0);
}
@@ -129,12 +134,10 @@ nsphyterattach(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_MODEL(ma->mii_id2) == MII_MODEL_NATSEMI_DP83815)
- printf(": %s", MII_STR_NATSEMI_DP83815);
- else
- printf(": %s", MII_STR_NATSEMI_DP83843);
- printf(", rev. %d\n", MII_REV(ma->mii_id2));
+ mpd = mii_phy_match(ma, nsphyterphys);
+ 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;