1*9860Sgdamore@opensolaris.org /*
2*9860Sgdamore@opensolaris.org * CDDL HEADER START
3*9860Sgdamore@opensolaris.org *
4*9860Sgdamore@opensolaris.org * The contents of this file are subject to the terms of the
5*9860Sgdamore@opensolaris.org * Common Development and Distribution License (the "License").
6*9860Sgdamore@opensolaris.org * You may not use this file except in compliance with the License.
7*9860Sgdamore@opensolaris.org *
8*9860Sgdamore@opensolaris.org * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*9860Sgdamore@opensolaris.org * or http://www.opensolaris.org/os/licensing.
10*9860Sgdamore@opensolaris.org * See the License for the specific language governing permissions
11*9860Sgdamore@opensolaris.org * and limitations under the License.
12*9860Sgdamore@opensolaris.org *
13*9860Sgdamore@opensolaris.org * When distributing Covered Code, include this CDDL HEADER in each
14*9860Sgdamore@opensolaris.org * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*9860Sgdamore@opensolaris.org * If applicable, add the following below this CDDL HEADER, with the
16*9860Sgdamore@opensolaris.org * fields enclosed by brackets "[]" replaced with your own identifying
17*9860Sgdamore@opensolaris.org * information: Portions Copyright [yyyy] [name of copyright owner]
18*9860Sgdamore@opensolaris.org *
19*9860Sgdamore@opensolaris.org * CDDL HEADER END
20*9860Sgdamore@opensolaris.org */
21*9860Sgdamore@opensolaris.org /*
22*9860Sgdamore@opensolaris.org * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23*9860Sgdamore@opensolaris.org * Use is subject to license terms.
24*9860Sgdamore@opensolaris.org */
25*9860Sgdamore@opensolaris.org
26*9860Sgdamore@opensolaris.org /*
27*9860Sgdamore@opensolaris.org * MII overrides for Intel PHYs.
28*9860Sgdamore@opensolaris.org */
29*9860Sgdamore@opensolaris.org
30*9860Sgdamore@opensolaris.org #include <sys/types.h>
31*9860Sgdamore@opensolaris.org #include <sys/ddi.h>
32*9860Sgdamore@opensolaris.org #include <sys/sunddi.h>
33*9860Sgdamore@opensolaris.org #include <sys/cmn_err.h>
34*9860Sgdamore@opensolaris.org #include <sys/note.h>
35*9860Sgdamore@opensolaris.org #include <sys/mii.h>
36*9860Sgdamore@opensolaris.org #include <sys/miiregs.h>
37*9860Sgdamore@opensolaris.org #include "miipriv.h"
38*9860Sgdamore@opensolaris.org
39*9860Sgdamore@opensolaris.org #define MII_82555_SPCL_CONTROL MII_VENDOR(1)
40*9860Sgdamore@opensolaris.org #define I82555_AUTOPOL_DIS (1<<4)
41*9860Sgdamore@opensolaris.org
42*9860Sgdamore@opensolaris.org /*
43*9860Sgdamore@opensolaris.org * The older 82555 code in iprb had a bunch of workarounds to deal
44*9860Sgdamore@opensolaris.org * with chip errata surrounding (I believe) autonegotiation problems
45*9860Sgdamore@opensolaris.org * with the 82555 and long cables.
46*9860Sgdamore@opensolaris.org *
47*9860Sgdamore@opensolaris.org * I can't find any evidence in current Linux, NetBSD, or FreeBSD
48*9860Sgdamore@opensolaris.org * sources for the same kinds of workarounds for this PHY, so I'm
49*9860Sgdamore@opensolaris.org * going to operate on the belief that these workarounds are simply
50*9860Sgdamore@opensolaris.org * not necessary. Without access to the errata for these parts, as
51*9860Sgdamore@opensolaris.org * well as parts that exhibit the problems, I can't be certain that
52*9860Sgdamore@opensolaris.org * such workarounds will work properly. So I'm leaving them out for
53*9860Sgdamore@opensolaris.org * now. I believe that the errata were mostly problems for 10 Mbps
54*9860Sgdamore@opensolaris.org * links which are very hard to find anymore, anyway.
55*9860Sgdamore@opensolaris.org */
56*9860Sgdamore@opensolaris.org
57*9860Sgdamore@opensolaris.org static int
i82555_start(phy_handle_t * ph)58*9860Sgdamore@opensolaris.org i82555_start(phy_handle_t *ph)
59*9860Sgdamore@opensolaris.org {
60*9860Sgdamore@opensolaris.org int rv;
61*9860Sgdamore@opensolaris.org
62*9860Sgdamore@opensolaris.org if ((rv = phy_start(ph)) != DDI_SUCCESS) {
63*9860Sgdamore@opensolaris.org return (rv);
64*9860Sgdamore@opensolaris.org }
65*9860Sgdamore@opensolaris.org
66*9860Sgdamore@opensolaris.org /*
67*9860Sgdamore@opensolaris.org * Apparently some devices have problem with 10 Mbps polarity and
68*9860Sgdamore@opensolaris.org * short cable lengths. However, these days everyone should be using
69*9860Sgdamore@opensolaris.org * 100 Mbps, and rather than retain the extra legacy complexity
70*9860Sgdamore@opensolaris.org * here, I'm going to simply offer the choice to disable auto polarity.
71*9860Sgdamore@opensolaris.org *
72*9860Sgdamore@opensolaris.org * If autopolarity doesn't work for you, you have several choices:
73*9860Sgdamore@opensolaris.org *
74*9860Sgdamore@opensolaris.org * 1) Find a longer cable.
75*9860Sgdamore@opensolaris.org * 2) Upgrade to 100Mbps.
76*9860Sgdamore@opensolaris.org * 3) Disable the polarity check by setting AutoPolarity to 0.
77*9860Sgdamore@opensolaris.org *
78*9860Sgdamore@opensolaris.org * We also believe that 10BASE-T autopolarity may be harmful (because
79*9860Sgdamore@opensolaris.org * when used it can prevent use of a superior 100Mbps mode), so we
80*9860Sgdamore@opensolaris.org * disable autopolarity by default.
81*9860Sgdamore@opensolaris.org */
82*9860Sgdamore@opensolaris.org if (phy_get_prop(ph, "AutoPolarity", 0) == 0) {
83*9860Sgdamore@opensolaris.org /* disable autopolarity */
84*9860Sgdamore@opensolaris.org PHY_SET(ph, MII_82555_SPCL_CONTROL, I82555_AUTOPOL_DIS);
85*9860Sgdamore@opensolaris.org } else {
86*9860Sgdamore@opensolaris.org /* enable basic autopolarity */
87*9860Sgdamore@opensolaris.org PHY_CLR(ph, MII_82555_SPCL_CONTROL, I82555_AUTOPOL_DIS);
88*9860Sgdamore@opensolaris.org }
89*9860Sgdamore@opensolaris.org
90*9860Sgdamore@opensolaris.org return (rv);
91*9860Sgdamore@opensolaris.org }
92*9860Sgdamore@opensolaris.org
93*9860Sgdamore@opensolaris.org boolean_t
phy_intel_probe(phy_handle_t * ph)94*9860Sgdamore@opensolaris.org phy_intel_probe(phy_handle_t *ph)
95*9860Sgdamore@opensolaris.org {
96*9860Sgdamore@opensolaris.org const char *model;
97*9860Sgdamore@opensolaris.org
98*9860Sgdamore@opensolaris.org if (MII_PHY_MFG(ph->phy_id) != MII_OUI_INTEL) {
99*9860Sgdamore@opensolaris.org return (B_FALSE);
100*9860Sgdamore@opensolaris.org }
101*9860Sgdamore@opensolaris.org
102*9860Sgdamore@opensolaris.org switch (MII_PHY_MODEL(ph->phy_id)) {
103*9860Sgdamore@opensolaris.org case MII_MODEL_INTEL_82553_CSTEP:
104*9860Sgdamore@opensolaris.org model = "82553 C-step";
105*9860Sgdamore@opensolaris.org break;
106*9860Sgdamore@opensolaris.org case MII_MODEL_INTEL_82555:
107*9860Sgdamore@opensolaris.org ph->phy_start = i82555_start;
108*9860Sgdamore@opensolaris.org model = "82555";
109*9860Sgdamore@opensolaris.org break;
110*9860Sgdamore@opensolaris.org case MII_MODEL_INTEL_82562_EH:
111*9860Sgdamore@opensolaris.org model = "Intel 82562 EH";
112*9860Sgdamore@opensolaris.org break;
113*9860Sgdamore@opensolaris.org case MII_MODEL_INTEL_82562_ET:
114*9860Sgdamore@opensolaris.org model = "Intel 82562 ET";
115*9860Sgdamore@opensolaris.org break;
116*9860Sgdamore@opensolaris.org case MII_MODEL_INTEL_82562_EM:
117*9860Sgdamore@opensolaris.org model = "Intel 82562 EM";
118*9860Sgdamore@opensolaris.org break;
119*9860Sgdamore@opensolaris.org default:
120*9860Sgdamore@opensolaris.org return (B_FALSE);
121*9860Sgdamore@opensolaris.org }
122*9860Sgdamore@opensolaris.org
123*9860Sgdamore@opensolaris.org ph->phy_vendor = "Intel";
124*9860Sgdamore@opensolaris.org ph->phy_model = model;
125*9860Sgdamore@opensolaris.org
126*9860Sgdamore@opensolaris.org return (B_TRUE);
127*9860Sgdamore@opensolaris.org }
128