xref: /titanic_41/usr/src/uts/common/io/mii/mii_other.c (revision 02d09e03eb27f3a2dc299de704e45dae5173f43f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * MII overrides for Quality Semiconductor PHYs.
28  */
29 
30 #include <sys/types.h>
31 #include <sys/ddi.h>
32 #include <sys/sunddi.h>
33 #include <sys/mii.h>
34 #include <sys/miiregs.h>
35 #include "miipriv.h"
36 
37 #define	OUI(MFG, VEND)	{ MII_OUI_##MFG, VEND }
38 
39 static const struct {
40 	uint32_t	oui;
41 	const char	*vendor;
42 } other_vendors[] = {
43 	OUI(AMD, "Advanced Micro Devices"),
44 	OUI(AMD_2, "Advanced Micro Devices"),
45 	OUI(ATTANSIC, "Atheros/Attansic"),
46 	OUI(BROADCOM, "Broadcom Corporation"),
47 	OUI(BROADCOM_2, "Broadcom Corporation"),
48 	OUI(CICADA, "Cicada Semiconductor"),
49 	OUI(CICADA_2, "Cicada Semiconductor"),
50 	OUI(DAVICOM, "Davicom Semiconductor"),
51 	OUI(DAVICOM_2, "Davicom Semiconductor"),
52 	OUI(ICPLUS, "IC Plus Corp."),
53 	OUI(ICS, "Integrated Circuit Systems"),
54 	OUI(LUCENT, "Lucent Technologies"),
55 	OUI(INTEL, "Intel"),
56 	OUI(MARVELL, "Marvell Technology"),
57 	OUI(NATIONAL_SEMI, "National Semiconductor"),
58 	OUI(NATIONAL_SEMI_2, "National Semiconductor"),
59 	OUI(QUALITY_SEMI, "Quality Semiconductor"),
60 	OUI(QUALITY_SEMI_2, "Quality Semiconductor"),
61 	{ 0, NULL }
62 };
63 
64 #define	ID(MFG, MODEL, DESC)	\
65 	{ MII_OUI_##MFG, MII_MODEL_##MFG##_##MODEL, DESC }
66 #define	IDN(MFG, N, MODEL, DESC)					\
67 	{ MII_OUI_##MFG##_##N, MII_MODEL_##MFG##_##MODEL, DESC }
68 static const struct {
69 	uint32_t	oui;
70 	uint32_t	model;
71 	const char	*desc;
72 } other_phys[] = {
73 
74 	/*
75 	 * AMD phys are pretty much standard.
76 	 */
77 	ID(AMD, AM79C901, "Am79C901"),
78 	ID(AMD, AM79C972, "Am79C792"),
79 	ID(AMD, AM79C973, "Am79C793"),
80 	IDN(AMD, 2, AM79C901, "Am79C901"),
81 	IDN(AMD, 2, AM79C972, "Am79C792"),
82 	IDN(AMD, 2, AM79C973, "Am79C793"),
83 
84 	/*
85 	 * Davicom phys are standard compliant.
86 	 */
87 	ID(DAVICOM, DM9101, "DM9101"),
88 	ID(DAVICOM, DM9102, "DM9102"),
89 	ID(DAVICOM, DM9161, "DM9161"),
90 	IDN(DAVICOM, 2, DM9101, "DM9101"),
91 	IDN(DAVICOM, 2, DM9102, "DM9102"),
92 
93 	/*
94 	 * IC Plus phy is standard compliant.
95 	 */
96 	ID(ICPLUS, IP101, "IP101"),
97 
98 	/*
99 	 * ICS phys need double read (bits are latched), have some
100 	 * faster polling support, and support for automatic power down.
101 	 * The framework deals with the first, we don't need the second,
102 	 * and the third is set to default anyway, so we don't need to
103 	 * use any special handling.
104 	 */
105 	ID(ICS, ICS1889, "ICS1889"),
106 	ID(ICS, ICS1890, "ICS1890"),
107 	ID(ICS, ICS1892, "ICS1892"),
108 	ID(ICS, ICS1893, "ICS1893"),
109 
110 	ID(LUCENT, LU6612, "LU6612"),
111 
112 	{ 0, 0, NULL },
113 };
114 
115 boolean_t
116 phy_other_probe(phy_handle_t *ph)
117 {
118 	uint32_t vid = MII_PHY_MFG(ph->phy_id);
119 	uint32_t pid = MII_PHY_MODEL(ph->phy_id);
120 
121 	for (int i = 0; other_vendors[i].vendor; i++) {
122 		if (vid == other_vendors[i].oui) {
123 			ph->phy_vendor = other_vendors[i].vendor;
124 
125 			for (int j = 0; other_phys[j].desc; j++) {
126 				if (vid == other_phys[j].oui &&
127 				    pid == other_phys[j].model) {
128 					ph->phy_model = other_phys[j].desc;
129 					return (B_TRUE);
130 				}
131 			}
132 
133 			/* PHY from this vendor isn't known to us */
134 			return (B_FALSE);
135 		}
136 	}
137 	return (B_FALSE);
138 }
139