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