xref: /titanic_41/usr/src/uts/common/io/mii/mii_other.c (revision a799b1e741b6f59012a469e6b57c40cb8061127b)
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(INTEL, "Intel"),
55 	OUI(MARVELL, "Marvell Technology"),
56 	OUI(NATIONAL_SEMI, "National Semiconductor"),
57 	OUI(NATIONAL_SEMI_2, "National Semiconductor"),
58 	OUI(QUALITY_SEMI, "Quality Semiconductor"),
59 	OUI(QUALITY_SEMI_2, "Quality Semiconductor"),
60 	{ 0, NULL }
61 };
62 
63 #define	ID(MFG, MODEL, DESC)	\
64 	{ MII_OUI_##MFG, MII_MODEL_##MFG##_##MODEL, DESC }
65 #define	IDN(MFG, N, MODEL, DESC)					\
66 	{ MII_OUI_##MFG##_##N, MII_MODEL_##MFG##_##MODEL, DESC }
67 static const struct {
68 	uint32_t	oui;
69 	uint32_t	model;
70 	const char	*desc;
71 } other_phys[] = {
72 
73 	/*
74 	 * AMD phys are pretty much standard.
75 	 */
76 	ID(AMD, AM79C901, "Am79C901"),
77 	ID(AMD, AM79C972, "Am79C792"),
78 	ID(AMD, AM79C973, "Am79C793"),
79 	IDN(AMD, 2, AM79C901, "Am79C901"),
80 	IDN(AMD, 2, AM79C972, "Am79C792"),
81 	IDN(AMD, 2, AM79C973, "Am79C793"),
82 
83 	/*
84 	 * Davicom phys are standard compliant.
85 	 */
86 	ID(DAVICOM, DM9101, "DM9101"),
87 	ID(DAVICOM, DM9102, "DM9102"),
88 	ID(DAVICOM, DM9161, "DM9161"),
89 	IDN(DAVICOM, 2, DM9101, "DM9101"),
90 	IDN(DAVICOM, 2, DM9102, "DM9102"),
91 
92 	/*
93 	 * IC Plus phy is standard compliant.
94 	 */
95 	ID(ICPLUS, IP101, "IP101"),
96 
97 	/*
98 	 * ICS phys need double read (bits are latched), have some
99 	 * faster polling support, and support for automatic power down.
100 	 * The framework deals with the first, we don't need the second,
101 	 * and the third is set to default anyway, so we don't need to
102 	 * use any special handling.
103 	 */
104 	ID(ICS, ICS1889, "ICS1889"),
105 	ID(ICS, ICS1890, "ICS1890"),
106 	ID(ICS, ICS1892, "ICS1892"),
107 	ID(ICS, ICS1893, "ICS1893"),
108 
109 	{ 0, 0, NULL },
110 };
111 
112 boolean_t
113 phy_other_probe(phy_handle_t *ph)
114 {
115 	uint32_t vid = MII_PHY_MFG(ph->phy_id);
116 	uint32_t pid = MII_PHY_MODEL(ph->phy_id);
117 
118 	for (int i = 0; other_vendors[i].vendor; i++) {
119 		if (vid == other_vendors[i].oui) {
120 			ph->phy_vendor = other_vendors[i].vendor;
121 
122 			for (int j = 0; other_phys[j].desc; j++) {
123 				if (vid == other_phys[j].oui &&
124 				    pid == other_phys[j].model) {
125 					ph->phy_model = other_phys[j].desc;
126 					return (B_TRUE);
127 				}
128 			}
129 
130 			/* PHY from this vendor isn't known to us */
131 			return (B_FALSE);
132 		}
133 	}
134 	return (B_FALSE);
135 }
136