Subject: kern/29705: ciphy do not attach Cicada PHYs
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <tharada@oucrc.org>
List: netbsd-bugs
Date: 03/16/2005 06:02:01
>Number: 29705
>Category: kern
>Synopsis: ciphy do not attach Cicada PHYs
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Mar 16 06:02:00 +0000 2005
>Originator: Tomokazu HARADA
>Release: NetBSD 2.99.16
>Organization:
>Environment:
System: NetBSD cotton.ope.iri-com.co.jp 2.99.16 NetBSD 2.99.16 (COTTON) #4: Wed Mar 16 13:58:56 JST 2005 harada@cotton.ope.iri-com.co.jp:/var/tmp/obj/sys/arch/i386/compile/COTTON i386
Architecture: i386
Machine: i386
>Description:
Cicada PHYs are attached as ukphy. Return value of ciphy_match()
should be >1 when matching succeeded.
>How-To-Repeat:
(re)boot
>Fix:
Apply following patch. The patch also includes some other changes:
- aprint_{naive,normal} during attach
- add extra oui; my VT6122's integrated phy has oui 0x00c08f
Index: ciphy.c
===================================================================
RCS file: /netbsdroot/src/sys/dev/mii/ciphy.c,v
retrieving revision 1.2
diff -u -r1.2 ciphy.c
--- ciphy.c 27 Feb 2005 00:27:31 -0000 1.2
+++ ciphy.c 16 Mar 2005 04:58:46 -0000
@@ -57,11 +57,11 @@
#include <dev/mii/ciphyreg.h>
-static int ciphy_match(struct device *, struct cfdata *, void *);
-static void ciphy_attach(struct device *, struct device *, void *);
+static int ciphymatch(struct device *, struct cfdata *, void *);
+static void ciphyattach(struct device *, struct device *, void *);
CFATTACH_DECL(ciphy, sizeof(struct mii_softc),
- ciphy_match, ciphy_attach, mii_phy_detach, mii_phy_activate);
+ ciphymatch, ciphyattach, mii_phy_detach, mii_phy_activate);
static int ciphy_service(struct mii_softc *, struct mii_data *, int);
static void ciphy_status(struct mii_softc *);
@@ -72,35 +72,45 @@
ciphy_service, ciphy_status, mii_phy_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 },
+
+ { MII_OUI_xxCICADA, MII_MODEL_xxCICADA_CS8201B,
+ MII_STR_xxCICADA_CS8201B },
+
+ { 0, 0,
+ NULL },
+};
+
static int
-ciphy_match(struct device *parent, struct cfdata *match, void *aux)
+ciphymatch(struct device *parent, struct cfdata *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(1);
- }
+ 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_CS8201A) {
- return(1);
- }
-
- if (MII_OUI(ma->mii_id1, ma->mii_id2) == MII_OUI_CICADA &&
- MII_MODEL(ma->mii_id2) == MII_MODEL_CICADA_CS8201B) {
- return(1);
- }
-
- return(0);
+ return (0);
}
static void
-ciphy_attach(struct device *parent, struct device *self, void *aux)
+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;
+ const struct mii_phydesc *mpd;
+
+ mpd = mii_phy_match(ma, ciphys);
+ aprint_naive(": Media interface\n");
+ aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2));
sc->mii_inst = mii->mii_instance;
sc->mii_phy = ma->mii_phyno;
Index: miidevs
===================================================================
RCS file: /netbsdroot/src/sys/dev/mii/miidevs,v
retrieving revision 1.57
diff -u -r1.57 miidevs
--- miidevs 20 Feb 2005 16:35:56 -0000 1.57
+++ miidevs 16 Mar 2005 04:54:49 -0000
@@ -76,6 +76,9 @@
/* Some Intel 82553's use an alternative OUI. */
oui xxINTEL 0x001f00 Intel
+/* Some VIA 6122's use an alternative OUI. */
+oui xxCICADA 0x00c08f Cicada Semiconductor
+
/* bad bitorder (bits "g" and "h" (= MSBs byte 1) lost) */
oui yyAMD 0x000058 Advanced Micro Devices
oui xxBROADCOM 0x000818 Broadcom Corporation
@@ -139,6 +142,7 @@
model CICADA CS8201 0x0001 Cicada CS8201 10/100/1000TX PHY
model CICADA CS8201A 0x0020 Cicada CS8201 10/100/1000TX PHY
model CICADA CS8201B 0x0021 Cicada CS8201 10/100/1000TX PHY
+model xxCICADA CS8201B 0x0021 Cicada CS8201 10/100/1000TX PHY
/* Davicom Semiconductor PHYs */
/* AMD Am79C873 seems to be a relabeled DM9101 */