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.
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.
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]
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 * Private MII header file.
35 #define PHY_SET(phy, reg, bit) \
36 phy_write(phy, reg, phy_read(phy, reg) | (bit))
37 #define PHY_CLR(phy, reg, bit) \
38 phy_write(phy, reg, phy_read(phy, reg) & ~(bit))
40 typedef struct phy_ops phy_ops_t
;
41 typedef struct phy_handle phy_handle_t
;
45 * Read only fields for PHY implementations, used internally by
49 boolean_t phy_present
;
55 * Scratch storage available for PHY implementations. While
56 * perhaps not as "clean" as other solutions with dynamic memory,
57 * this avoids having to deal with potential concerns regarding the
58 * lifetime of the storage. It will be zeroed each time the MII
61 uintptr_t phy_scratch
[8];
64 * These fields are intended to be overridden by PHY
65 * implementations. If left NULL, then default
66 * implementations will be supplied.
68 const char *phy_vendor
;
69 const char *phy_model
;
70 int (*phy_reset
)(phy_handle_t
*);
71 int (*phy_start
)(phy_handle_t
*);
72 int (*phy_stop
)(phy_handle_t
*);
73 int (*phy_check
)(phy_handle_t
*);
74 int (*phy_loop
)(phy_handle_t
*);
77 * Physical capabilities. PHY implementations may override
78 * the defaults if necessary.
80 boolean_t phy_cap_aneg
;
81 boolean_t phy_cap_10_hdx
;
82 boolean_t phy_cap_10_fdx
;
83 boolean_t phy_cap_100_t4
;
84 boolean_t phy_cap_100_hdx
;
85 boolean_t phy_cap_100_fdx
;
86 boolean_t phy_cap_1000_hdx
;
87 boolean_t phy_cap_1000_fdx
;
88 boolean_t phy_cap_pause
;
89 boolean_t phy_cap_asmpause
;
92 * Local configured settings. PHY implementations should
93 * these as read only. The MII common layer will limit
94 * settings to only those that are sensible per the actual
95 * capabilities of the device. These represent administrator
98 boolean_t phy_en_aneg
;
99 boolean_t phy_en_10_hdx
;
100 boolean_t phy_en_10_fdx
;
101 boolean_t phy_en_100_t4
;
102 boolean_t phy_en_100_hdx
;
103 boolean_t phy_en_100_fdx
;
104 boolean_t phy_en_1000_hdx
;
105 boolean_t phy_en_1000_fdx
;
106 boolean_t phy_en_pause
;
107 boolean_t phy_en_asmpause
;
108 link_flowctrl_t phy_en_flowctrl
;
111 * Settings exposed on the hardware. MII common layer will
112 * limit settings to only those that are sensible per the
113 * actual capabilities of the device.
115 boolean_t phy_adv_aneg
;
116 boolean_t phy_adv_10_hdx
;
117 boolean_t phy_adv_10_fdx
;
118 boolean_t phy_adv_100_t4
;
119 boolean_t phy_adv_100_hdx
;
120 boolean_t phy_adv_100_fdx
;
121 boolean_t phy_adv_1000_hdx
;
122 boolean_t phy_adv_1000_fdx
;
123 boolean_t phy_adv_pause
;
124 boolean_t phy_adv_asmpause
;
127 * Link partner settings. PHY implementations should
128 * fill these in during phy_check.
130 boolean_t phy_lp_aneg
;
131 boolean_t phy_lp_10_hdx
;
132 boolean_t phy_lp_10_fdx
;
133 boolean_t phy_lp_100_t4
;
134 boolean_t phy_lp_100_hdx
;
135 boolean_t phy_lp_100_fdx
;
136 boolean_t phy_lp_1000_hdx
;
137 boolean_t phy_lp_1000_fdx
;
138 boolean_t phy_lp_pause
;
139 boolean_t phy_lp_asmpause
;
142 * Loopback state. Loopback state overrides any other settings.
145 #define PHY_LB_NONE 0
146 #define PHY_LB_INT_PHY 1
147 #define PHY_LB_EXT_10 2
148 #define PHY_LB_EXT_100 3
149 #define PHY_LB_EXT_1000 4
152 * Resolved link status. PHY implementations should
153 * fill these during phy_check.
155 link_state_t phy_link
;
157 link_duplex_t phy_duplex
;
158 link_flowctrl_t phy_flowctrl
;
162 * Routines intended to be accessed by PHY specific implementation code.
163 * All of these routines assume that any relevant locks are held by the
164 * famework (which would be true for all of the PHY functions.
167 uint16_t phy_read(phy_handle_t
*, uint8_t);
168 void phy_write(phy_handle_t
*, uint8_t, uint16_t);
169 int phy_get_prop(phy_handle_t
*, char *, int);
170 const char *phy_get_name(phy_handle_t
*);
171 const char *phy_get_driver(phy_handle_t
*);
172 void phy_warn(phy_handle_t
*, const char *, ...);
175 * phy_reset is called when the PHY needs to be reset. The default
176 * implementation just resets the PHY by toggling the BMCR bit, but it
177 * also unisolates and powers up the PHY.
179 int phy_reset(phy_handle_t
*);
182 * phy_start is used to start services on the PHY. Typically this is
183 * called when autonegotiation should be started. phy_reset will
184 * already have been called.
186 int phy_start(phy_handle_t
*);
189 * phy_stop is used when the phy services should be stopped. This can
190 * be done, for example, when a different PHY will be used. The default
191 * implementation isolates the PHY, puts it into loopback, and then powers
194 int phy_stop(phy_handle_t
*);
197 * phy_check is called to check the current state of the link. It
198 * can be used from the implementations phy_check entry point.
200 int phy_check(phy_handle_t
*);
203 * phy_ isoop called to establish loopback mode. The PHY must
204 * examine the value of phy_loopback.
206 int phy_loop(phy_handle_t
*);
209 * The following probes are PHY specific, and located here so that
210 * the common PHY layer can find them.
212 boolean_t
phy_intel_probe(phy_handle_t
*);
213 boolean_t
phy_natsemi_probe(phy_handle_t
*);
214 boolean_t
phy_qualsemi_probe(phy_handle_t
*);
215 boolean_t
phy_cicada_probe(phy_handle_t
*);
216 boolean_t
phy_marvell_probe(phy_handle_t
*);
217 boolean_t
phy_realtek_probe(phy_handle_t
*);
218 boolean_t
phy_other_probe(phy_handle_t
*);
220 #endif /* _MIIPRIV_H */