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 Quality Semiconductor 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/mii.h>
34*9860Sgdamore@opensolaris.org #include <sys/miiregs.h>
35*9860Sgdamore@opensolaris.org #include "miipriv.h"
36*9860Sgdamore@opensolaris.org
37*9860Sgdamore@opensolaris.org #define QS_IMASK_REG 30
38*9860Sgdamore@opensolaris.org #define QS_BTXPC 31
39*9860Sgdamore@opensolaris.org #define QS_BTXPC_SCRAM_DIS 0x1
40*9860Sgdamore@opensolaris.org
41*9860Sgdamore@opensolaris.org static int
qs6612_reset(phy_handle_t * ph)42*9860Sgdamore@opensolaris.org qs6612_reset(phy_handle_t *ph)
43*9860Sgdamore@opensolaris.org {
44*9860Sgdamore@opensolaris.org /* Ordinary reset. */
45*9860Sgdamore@opensolaris.org if (phy_reset(ph) != DDI_SUCCESS) {
46*9860Sgdamore@opensolaris.org return (DDI_FAILURE);
47*9860Sgdamore@opensolaris.org }
48*9860Sgdamore@opensolaris.org
49*9860Sgdamore@opensolaris.org /* Disable QS6612 proprietary interrupts. */
50*9860Sgdamore@opensolaris.org phy_write(ph, QS_IMASK_REG, 0);
51*9860Sgdamore@opensolaris.org
52*9860Sgdamore@opensolaris.org return (DDI_SUCCESS);
53*9860Sgdamore@opensolaris.org }
54*9860Sgdamore@opensolaris.org
55*9860Sgdamore@opensolaris.org static int
qs6612_check(phy_handle_t * ph)56*9860Sgdamore@opensolaris.org qs6612_check(phy_handle_t *ph)
57*9860Sgdamore@opensolaris.org {
58*9860Sgdamore@opensolaris.org link_state_t link;
59*9860Sgdamore@opensolaris.org int rv;
60*9860Sgdamore@opensolaris.org
61*9860Sgdamore@opensolaris.org /*
62*9860Sgdamore@opensolaris.org * Apparently some *ancient* Synoptics 28115 firwmare has a bug that
63*9860Sgdamore@opensolaris.org * doesn't connect with certain devices. While I'm fairly sure we
64*9860Sgdamore@opensolaris.org * could probably remove this workaround (for another vendor's bug!)
65*9860Sgdamore@opensolaris.org * at this point, it might crop up as a regression.
66*9860Sgdamore@opensolaris.org *
67*9860Sgdamore@opensolaris.org * Apparently, the workaround is to disable the scrambler for a bit
68*9860Sgdamore@opensolaris.org * once 100 Mbps link is achieved, and then reactivate. This lets
69*9860Sgdamore@opensolaris.org * the busted switch work. We only do it when first bringing up
70*9860Sgdamore@opensolaris.org * the 100 Mbps link.
71*9860Sgdamore@opensolaris.org *
72*9860Sgdamore@opensolaris.org * Yes, I resent having to do this. But the code is carried over
73*9860Sgdamore@opensolaris.org * from old hme/qfe. See 4071199 for details.
74*9860Sgdamore@opensolaris.org */
75*9860Sgdamore@opensolaris.org link = ph->phy_link;
76*9860Sgdamore@opensolaris.org
77*9860Sgdamore@opensolaris.org rv = phy_check(ph);
78*9860Sgdamore@opensolaris.org
79*9860Sgdamore@opensolaris.org if ((ph->phy_link == LINK_STATE_UP) && (link != LINK_STATE_UP) &&
80*9860Sgdamore@opensolaris.org (ph->phy_speed == 100)) {
81*9860Sgdamore@opensolaris.org uint16_t val;
82*9860Sgdamore@opensolaris.org val = phy_read(ph, QS_BTXPC);
83*9860Sgdamore@opensolaris.org phy_write(ph, QS_BTXPC, val | QS_BTXPC_SCRAM_DIS);
84*9860Sgdamore@opensolaris.org drv_usecwait(20);
85*9860Sgdamore@opensolaris.org phy_write(ph, QS_BTXPC, val);
86*9860Sgdamore@opensolaris.org }
87*9860Sgdamore@opensolaris.org
88*9860Sgdamore@opensolaris.org return (rv);
89*9860Sgdamore@opensolaris.org }
90*9860Sgdamore@opensolaris.org
91*9860Sgdamore@opensolaris.org boolean_t
phy_qualsemi_probe(phy_handle_t * ph)92*9860Sgdamore@opensolaris.org phy_qualsemi_probe(phy_handle_t *ph)
93*9860Sgdamore@opensolaris.org {
94*9860Sgdamore@opensolaris.org if ((MII_PHY_MFG(ph->phy_id) == MII_OUI_QUALITY_SEMI) &&
95*9860Sgdamore@opensolaris.org (MII_PHY_MODEL(ph->phy_id) == MII_MODEL_QUALITY_SEMI_QS6612)) {
96*9860Sgdamore@opensolaris.org ph->phy_vendor = "Quality Semiconductor";
97*9860Sgdamore@opensolaris.org ph->phy_model = "QS6612";
98*9860Sgdamore@opensolaris.org ph->phy_reset = qs6612_reset;
99*9860Sgdamore@opensolaris.org ph->phy_check = qs6612_check;
100*9860Sgdamore@opensolaris.org return (B_TRUE);
101*9860Sgdamore@opensolaris.org }
102*9860Sgdamore@opensolaris.org return (B_FALSE);
103*9860Sgdamore@opensolaris.org }
104