xref: /titanic_44/usr/src/uts/common/io/mii/mii_other.c (revision 726fad2a65f16c200a03969c29cb5c86c2d427db)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * MII overrides for other 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(ALTIMA, "Altima Communications"),
44 	OUI(AMD, "Advanced Micro Devices"),
45 	OUI(AMD_2, "Advanced Micro Devices"),
46 	OUI(ATTANSIC, "Atheros/Attansic"),
47 	OUI(BROADCOM, "Broadcom Corporation"),
48 	OUI(BROADCOM_2, "Broadcom Corporation"),
49 	OUI(CICADA, "Cicada Semiconductor"),
50 	OUI(CICADA_2, "Cicada Semiconductor"),
51 	OUI(DAVICOM, "Davicom Semiconductor"),
52 	OUI(DAVICOM_2, "Davicom Semiconductor"),
53 	OUI(ICPLUS, "IC Plus Corp."),
54 	OUI(ICS, "Integrated Circuit Systems"),
55 	OUI(LUCENT, "Lucent Technologies"),
56 	OUI(INTEL, "Intel"),
57 	OUI(MARVELL, "Marvell Technology"),
58 	OUI(NATIONAL_SEMI, "National Semiconductor"),
59 	OUI(NATIONAL_SEMI_2, "National Semiconductor"),
60 	OUI(QUALITY_SEMI, "Quality Semiconductor"),
61 	OUI(QUALITY_SEMI_2, "Quality Semiconductor"),
62 	{ 0, NULL }
63 };
64 
65 #define	ID(MFG, MODEL, DESC)	\
66 	{ MII_OUI_##MFG, MII_MODEL_##MFG##_##MODEL, DESC }
67 #define	IDN(MFG, N, MODEL, DESC)					\
68 	{ MII_OUI_##MFG##_##N, MII_MODEL_##MFG##_##MODEL, DESC }
69 static const struct {
70 	uint32_t	oui;
71 	uint32_t	model;
72 	const char	*desc;
73 } other_phys[] = {
74 
75 	/*
76 	 * Altima phys are standard compliant.
77 	 * AMD Am79C874 and Am79C875 phys are work-alikes.
78 	 */
79 	ID(ALTIMA, AC101, "AC101/Am79C874"),
80 	ID(ALTIMA, AC101L, "AC101L"),
81 	ID(ALTIMA, AM79C875, "Am79C875"),
82 
83 	/*
84 	 * AMD phys are pretty much standard.
85 	 */
86 	ID(AMD, AM79C901, "Am79C901"),
87 	ID(AMD, AM79C972, "Am79C792"),
88 	ID(AMD, AM79C973, "Am79C793"),
89 	IDN(AMD, 2, AM79C901, "Am79C901"),
90 	IDN(AMD, 2, AM79C972, "Am79C792"),
91 	IDN(AMD, 2, AM79C973, "Am79C793"),
92 
93 	/*
94 	 * Davicom phys are standard compliant.
95 	 */
96 	ID(DAVICOM, DM9101, "DM9101"),
97 	ID(DAVICOM, DM9102, "DM9102"),
98 	ID(DAVICOM, DM9161, "DM9161"),
99 	IDN(DAVICOM, 2, DM9101, "DM9101"),
100 	IDN(DAVICOM, 2, DM9102, "DM9102"),
101 
102 	/*
103 	 * IC Plus phy is standard compliant.
104 	 */
105 	ID(ICPLUS, IP101, "IP101"),
106 
107 	/*
108 	 * ICS phys need double read (bits are latched), have some
109 	 * faster polling support, and support for automatic power down.
110 	 * The framework deals with the first, we don't need the second,
111 	 * and the third is set to default anyway, so we don't need to
112 	 * use any special handling.
113 	 */
114 	ID(ICS, ICS1889, "ICS1889"),
115 	ID(ICS, ICS1890, "ICS1890"),
116 	ID(ICS, ICS1892, "ICS1892"),
117 	ID(ICS, ICS1893, "ICS1893"),
118 
119 	ID(LUCENT, LU6612, "LU6612"),
120 
121 	{ 0, 0, NULL },
122 };
123 
124 boolean_t
125 phy_other_probe(phy_handle_t *ph)
126 {
127 	uint32_t vid = MII_PHY_MFG(ph->phy_id);
128 	uint32_t pid = MII_PHY_MODEL(ph->phy_id);
129 
130 	if ((ph->phy_id == 0) || (ph->phy_id == 0xffffffffU)) {
131 		/*
132 		 * IDs are technically optional, but all discrete PHYs
133 		 * should have them.
134 		 */
135 		ph->phy_vendor = "Internal";
136 		ph->phy_model = "PHY";
137 	}
138 	for (int i = 0; other_vendors[i].vendor; i++) {
139 		if (vid == other_vendors[i].oui) {
140 			ph->phy_vendor = other_vendors[i].vendor;
141 
142 			for (int j = 0; other_phys[j].desc; j++) {
143 				if (vid == other_phys[j].oui &&
144 				    pid == other_phys[j].model) {
145 					ph->phy_model = other_phys[j].desc;
146 					return (B_TRUE);
147 				}
148 			}
149 
150 			/* PHY from this vendor isn't known to us */
151 			return (B_FALSE);
152 		}
153 	}
154 	return (B_FALSE);
155 }
156