xref: /titanic_44/usr/src/uts/common/io/mii/mii_cicada.c (revision bdb9230ac765cb7af3fc1f4119caf2c5720dceb3)
1*bdb9230aSGarrett D'Amore /*
2*bdb9230aSGarrett D'Amore  * CDDL HEADER START
3*bdb9230aSGarrett D'Amore  *
4*bdb9230aSGarrett D'Amore  * The contents of this file are subject to the terms of the
5*bdb9230aSGarrett D'Amore  * Common Development and Distribution License (the "License").
6*bdb9230aSGarrett D'Amore  * You may not use this file except in compliance with the License.
7*bdb9230aSGarrett D'Amore  *
8*bdb9230aSGarrett D'Amore  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*bdb9230aSGarrett D'Amore  * or http://www.opensolaris.org/os/licensing.
10*bdb9230aSGarrett D'Amore  * See the License for the specific language governing permissions
11*bdb9230aSGarrett D'Amore  * and limitations under the License.
12*bdb9230aSGarrett D'Amore  *
13*bdb9230aSGarrett D'Amore  * When distributing Covered Code, include this CDDL HEADER in each
14*bdb9230aSGarrett D'Amore  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*bdb9230aSGarrett D'Amore  * If applicable, add the following below this CDDL HEADER, with the
16*bdb9230aSGarrett D'Amore  * fields enclosed by brackets "[]" replaced with your own identifying
17*bdb9230aSGarrett D'Amore  * information: Portions Copyright [yyyy] [name of copyright owner]
18*bdb9230aSGarrett D'Amore  *
19*bdb9230aSGarrett D'Amore  * CDDL HEADER END
20*bdb9230aSGarrett D'Amore  */
21*bdb9230aSGarrett D'Amore /*
22*bdb9230aSGarrett D'Amore  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*bdb9230aSGarrett D'Amore  * Use is subject to license terms.
24*bdb9230aSGarrett D'Amore  */
25*bdb9230aSGarrett D'Amore 
26*bdb9230aSGarrett D'Amore /*
27*bdb9230aSGarrett D'Amore  * MII overrides for Cicada (now Vitesse) PHYs.
28*bdb9230aSGarrett D'Amore  */
29*bdb9230aSGarrett D'Amore 
30*bdb9230aSGarrett D'Amore #include <sys/types.h>
31*bdb9230aSGarrett D'Amore #include <sys/ddi.h>
32*bdb9230aSGarrett D'Amore #include <sys/sunddi.h>
33*bdb9230aSGarrett D'Amore #include <sys/mii.h>
34*bdb9230aSGarrett D'Amore #include <sys/miiregs.h>
35*bdb9230aSGarrett D'Amore #include "miipriv.h"
36*bdb9230aSGarrett D'Amore 
37*bdb9230aSGarrett D'Amore #define	MII_CICADA_BYPASS_CONTROL	MII_VENDOR(2)
38*bdb9230aSGarrett D'Amore #define	CICADA_125MHZ_CLOCK_ENABLE	0x0001
39*bdb9230aSGarrett D'Amore 
40*bdb9230aSGarrett D'Amore #define	MII_CICADA_10BASET_CONTROL	MII_VENDOR(6)
41*bdb9230aSGarrett D'Amore #define	MII_CICADA_DISABLE_ECHO_MODE	0x2000
42*bdb9230aSGarrett D'Amore 
43*bdb9230aSGarrett D'Amore #define	MII_CICADA_EXT_CONTROL		MII_VENDOR(7)
44*bdb9230aSGarrett D'Amore #define	MII_CICADA_MODE_SELECT_BITS 	0xf000
45*bdb9230aSGarrett D'Amore #define	MII_CICADA_MODE_SELECT_RGMII	0x1000
46*bdb9230aSGarrett D'Amore #define	MII_CICADA_POWER_SUPPLY_BITS	0x0e00
47*bdb9230aSGarrett D'Amore #define	MII_CICADA_POWER_SUPPLY_3_3V	0x0000
48*bdb9230aSGarrett D'Amore #define	MII_CICADA_POWER_SUPPLY_2_5V	0x0200
49*bdb9230aSGarrett D'Amore 
50*bdb9230aSGarrett D'Amore #define	MII_CICADA_AUXCTRL_STATUS	MII_VENDOR(12)
51*bdb9230aSGarrett D'Amore #define	MII_CICADA_PIN_PRORITY_SETTING	0x0004
52*bdb9230aSGarrett D'Amore #define	MII_CICADA_PIN_PRORITY_DEFAULT	0x0000
53*bdb9230aSGarrett D'Amore 
54*bdb9230aSGarrett D'Amore /*
55*bdb9230aSGarrett D'Amore  * The nge driver seems to do some rather specialized programming of
56*bdb9230aSGarrett D'Amore  * this PHY.  Specifically, it appears that the PHY is programmed for
57*bdb9230aSGarrett D'Amore  * 2.5 RGMII operation and the PIN_PRIOITY_SETTING is set for RGMII
58*bdb9230aSGarrett D'Amore  * interfaces.  For MII interfaces, the echo mode is disabled and the
59*bdb9230aSGarrett D'Amore  * 125MHz clock is disabled.
60*bdb9230aSGarrett D'Amore  *
61*bdb9230aSGarrett D'Amore  * It isn't immediately clear to me how to cleanly do this.  One could
62*bdb9230aSGarrett D'Amore  * probably argue that this particular PHY would never ever be used in
63*bdb9230aSGarrett D'Amore  * a strict MII setting, but I hate to make an incorrect assumption.
64*bdb9230aSGarrett D'Amore  *
65*bdb9230aSGarrett D'Amore  * For now, absent data sheets on this part, we're going just leave
66*bdb9230aSGarrett D'Amore  * the code for this in nge.
67*bdb9230aSGarrett D'Amore  *
68*bdb9230aSGarrett D'Amore  * If someone has data sheets and can "prove" that the architecture
69*bdb9230aSGarrett D'Amore  * works portably across drivers, revisiting this logic and adding code
70*bdb9230aSGarrett D'Amore  * to handle these PHYs would be cleaner.
71*bdb9230aSGarrett D'Amore  */
72*bdb9230aSGarrett D'Amore boolean_t
phy_cicada_probe(phy_handle_t * ph)73*bdb9230aSGarrett D'Amore phy_cicada_probe(phy_handle_t *ph)
74*bdb9230aSGarrett D'Amore {
75*bdb9230aSGarrett D'Amore 	switch (MII_PHY_MFG(ph->phy_id)) {
76*bdb9230aSGarrett D'Amore 	case MII_OUI_CICADA:
77*bdb9230aSGarrett D'Amore 	case MII_OUI_CICADA_2:
78*bdb9230aSGarrett D'Amore 		switch (MII_PHY_MODEL(ph->phy_id)) {
79*bdb9230aSGarrett D'Amore 		case MII_MODEL_CICADA_CS8201:
80*bdb9230aSGarrett D'Amore 		case MII_MODEL_CICADA_CS8201A:
81*bdb9230aSGarrett D'Amore 		case MII_MODEL_CICADA_CS8201B:
82*bdb9230aSGarrett D'Amore 			ph->phy_vendor = "Cicada";
83*bdb9230aSGarrett D'Amore 			ph->phy_model = "CS8201";
84*bdb9230aSGarrett D'Amore 			return (B_TRUE);
85*bdb9230aSGarrett D'Amore 		default:
86*bdb9230aSGarrett D'Amore 			break;
87*bdb9230aSGarrett D'Amore 		}
88*bdb9230aSGarrett D'Amore 		break;
89*bdb9230aSGarrett D'Amore 
90*bdb9230aSGarrett D'Amore 	default:
91*bdb9230aSGarrett D'Amore 		break;
92*bdb9230aSGarrett D'Amore 	}
93*bdb9230aSGarrett D'Amore 
94*bdb9230aSGarrett D'Amore 	return (B_FALSE);
95*bdb9230aSGarrett D'Amore }
96