ixgbe_x550.c revision 1.1 1 1.1 msaitoh /******************************************************************************
2 1.1 msaitoh
3 1.1 msaitoh Copyright (c) 2001-2015, Intel Corporation
4 1.1 msaitoh All rights reserved.
5 1.1 msaitoh
6 1.1 msaitoh Redistribution and use in source and binary forms, with or without
7 1.1 msaitoh modification, are permitted provided that the following conditions are met:
8 1.1 msaitoh
9 1.1 msaitoh 1. Redistributions of source code must retain the above copyright notice,
10 1.1 msaitoh this list of conditions and the following disclaimer.
11 1.1 msaitoh
12 1.1 msaitoh 2. Redistributions in binary form must reproduce the above copyright
13 1.1 msaitoh notice, this list of conditions and the following disclaimer in the
14 1.1 msaitoh documentation and/or other materials provided with the distribution.
15 1.1 msaitoh
16 1.1 msaitoh 3. Neither the name of the Intel Corporation nor the names of its
17 1.1 msaitoh contributors may be used to endorse or promote products derived from
18 1.1 msaitoh this software without specific prior written permission.
19 1.1 msaitoh
20 1.1 msaitoh THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 1.1 msaitoh AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 1.1 msaitoh IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 1.1 msaitoh ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 1.1 msaitoh LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 1.1 msaitoh CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 1.1 msaitoh SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 1.1 msaitoh INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 1.1 msaitoh CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 1.1 msaitoh ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 1.1 msaitoh POSSIBILITY OF SUCH DAMAGE.
31 1.1 msaitoh
32 1.1 msaitoh ******************************************************************************/
33 1.1 msaitoh /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x550.c 282289 2015-04-30 22:53:27Z erj $*/
34 1.1 msaitoh
35 1.1 msaitoh #include "ixgbe_x550.h"
36 1.1 msaitoh #include "ixgbe_x540.h"
37 1.1 msaitoh #include "ixgbe_type.h"
38 1.1 msaitoh #include "ixgbe_api.h"
39 1.1 msaitoh #include "ixgbe_common.h"
40 1.1 msaitoh #include "ixgbe_phy.h"
41 1.1 msaitoh
42 1.1 msaitoh static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed);
43 1.1 msaitoh
44 1.1 msaitoh /**
45 1.1 msaitoh * ixgbe_init_ops_X550 - Inits func ptrs and MAC type
46 1.1 msaitoh * @hw: pointer to hardware structure
47 1.1 msaitoh *
48 1.1 msaitoh * Initialize the function pointers and assign the MAC type for X550.
49 1.1 msaitoh * Does not touch the hardware.
50 1.1 msaitoh **/
51 1.1 msaitoh s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
52 1.1 msaitoh {
53 1.1 msaitoh struct ixgbe_mac_info *mac = &hw->mac;
54 1.1 msaitoh struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
55 1.1 msaitoh s32 ret_val;
56 1.1 msaitoh
57 1.1 msaitoh DEBUGFUNC("ixgbe_init_ops_X550");
58 1.1 msaitoh
59 1.1 msaitoh ret_val = ixgbe_init_ops_X540(hw);
60 1.1 msaitoh mac->ops.dmac_config = ixgbe_dmac_config_X550;
61 1.1 msaitoh mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
62 1.1 msaitoh mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
63 1.1 msaitoh mac->ops.setup_eee = ixgbe_setup_eee_X550;
64 1.1 msaitoh mac->ops.set_source_address_pruning =
65 1.1 msaitoh ixgbe_set_source_address_pruning_X550;
66 1.1 msaitoh mac->ops.set_ethertype_anti_spoofing =
67 1.1 msaitoh ixgbe_set_ethertype_anti_spoofing_X550;
68 1.1 msaitoh
69 1.1 msaitoh mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
70 1.1 msaitoh eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
71 1.1 msaitoh eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
72 1.1 msaitoh eeprom->ops.read = ixgbe_read_ee_hostif_X550;
73 1.1 msaitoh eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
74 1.1 msaitoh eeprom->ops.write = ixgbe_write_ee_hostif_X550;
75 1.1 msaitoh eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
76 1.1 msaitoh eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
77 1.1 msaitoh eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
78 1.1 msaitoh
79 1.1 msaitoh mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
80 1.1 msaitoh mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
81 1.1 msaitoh mac->ops.mdd_event = ixgbe_mdd_event_X550;
82 1.1 msaitoh mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
83 1.1 msaitoh mac->ops.disable_rx = ixgbe_disable_rx_x550;
84 1.1 msaitoh if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
85 1.1 msaitoh hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
86 1.1 msaitoh hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
87 1.1 msaitoh }
88 1.1 msaitoh return ret_val;
89 1.1 msaitoh }
90 1.1 msaitoh
91 1.1 msaitoh /**
92 1.1 msaitoh * ixgbe_read_cs4227 - Read CS4227 register
93 1.1 msaitoh * @hw: pointer to hardware structure
94 1.1 msaitoh * @reg: register number to write
95 1.1 msaitoh * @value: pointer to receive value read
96 1.1 msaitoh *
97 1.1 msaitoh * Returns status code
98 1.1 msaitoh **/
99 1.1 msaitoh static s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
100 1.1 msaitoh {
101 1.1 msaitoh return ixgbe_read_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
102 1.1 msaitoh }
103 1.1 msaitoh
104 1.1 msaitoh /**
105 1.1 msaitoh * ixgbe_write_cs4227 - Write CS4227 register
106 1.1 msaitoh * @hw: pointer to hardware structure
107 1.1 msaitoh * @reg: register number to write
108 1.1 msaitoh * @value: value to write to register
109 1.1 msaitoh *
110 1.1 msaitoh * Returns status code
111 1.1 msaitoh **/
112 1.1 msaitoh static s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
113 1.1 msaitoh {
114 1.1 msaitoh return ixgbe_write_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
115 1.1 msaitoh }
116 1.1 msaitoh
117 1.1 msaitoh /**
118 1.1 msaitoh * ixgbe_get_cs4227_status - Return CS4227 status
119 1.1 msaitoh * @hw: pointer to hardware structure
120 1.1 msaitoh *
121 1.1 msaitoh * Returns error if CS4227 not successfully initialized
122 1.1 msaitoh **/
123 1.1 msaitoh static s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
124 1.1 msaitoh {
125 1.1 msaitoh s32 status;
126 1.1 msaitoh u16 value = 0;
127 1.1 msaitoh u16 reg_slice, reg_val;
128 1.1 msaitoh u8 retry;
129 1.1 msaitoh
130 1.1 msaitoh for (retry = 0; retry < IXGBE_CS4227_RETRIES; ++retry) {
131 1.1 msaitoh status = ixgbe_read_cs4227(hw, IXGBE_CS4227_GLOBAL_ID_LSB,
132 1.1 msaitoh &value);
133 1.1 msaitoh if (status != IXGBE_SUCCESS)
134 1.1 msaitoh return status;
135 1.1 msaitoh if (value == IXGBE_CS4227_GLOBAL_ID_VALUE)
136 1.1 msaitoh break;
137 1.1 msaitoh msec_delay(IXGBE_CS4227_CHECK_DELAY);
138 1.1 msaitoh }
139 1.1 msaitoh if (value != IXGBE_CS4227_GLOBAL_ID_VALUE)
140 1.1 msaitoh return IXGBE_ERR_PHY;
141 1.1 msaitoh
142 1.1 msaitoh status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
143 1.1 msaitoh if (status != IXGBE_SUCCESS)
144 1.1 msaitoh return status;
145 1.1 msaitoh
146 1.1 msaitoh /* If this is the first time after power-on, check the ucode.
147 1.1 msaitoh * Otherwise, this will disrupt link on all ports. Because we
148 1.1 msaitoh * can only do this the first time, we must check all ports,
149 1.1 msaitoh * not just our own.
150 1.1 msaitoh */
151 1.1 msaitoh if (value != IXGBE_CS4227_SCRATCH_VALUE) {
152 1.1 msaitoh reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
153 1.1 msaitoh reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
154 1.1 msaitoh status = ixgbe_write_cs4227(hw, reg_slice,
155 1.1 msaitoh reg_val);
156 1.1 msaitoh if (status != IXGBE_SUCCESS)
157 1.1 msaitoh return status;
158 1.1 msaitoh
159 1.1 msaitoh reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
160 1.1 msaitoh reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
161 1.1 msaitoh status = ixgbe_write_cs4227(hw, reg_slice,
162 1.1 msaitoh reg_val);
163 1.1 msaitoh if (status != IXGBE_SUCCESS)
164 1.1 msaitoh return status;
165 1.1 msaitoh
166 1.1 msaitoh reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
167 1.1 msaitoh reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
168 1.1 msaitoh status = ixgbe_write_cs4227(hw, reg_slice,
169 1.1 msaitoh reg_val);
170 1.1 msaitoh if (status != IXGBE_SUCCESS)
171 1.1 msaitoh return status;
172 1.1 msaitoh
173 1.1 msaitoh reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
174 1.1 msaitoh reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
175 1.1 msaitoh status = ixgbe_write_cs4227(hw, reg_slice,
176 1.1 msaitoh reg_val);
177 1.1 msaitoh if (status != IXGBE_SUCCESS)
178 1.1 msaitoh return status;
179 1.1 msaitoh
180 1.1 msaitoh msec_delay(10);
181 1.1 msaitoh }
182 1.1 msaitoh
183 1.1 msaitoh /* Verify that the ucode is operational on all ports. */
184 1.1 msaitoh reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
185 1.1 msaitoh reg_val = 0xFFFF;
186 1.1 msaitoh status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
187 1.1 msaitoh if (status != IXGBE_SUCCESS)
188 1.1 msaitoh return status;
189 1.1 msaitoh if (reg_val != 0)
190 1.1 msaitoh return IXGBE_ERR_PHY;
191 1.1 msaitoh
192 1.1 msaitoh reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
193 1.1 msaitoh reg_val = 0xFFFF;
194 1.1 msaitoh status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
195 1.1 msaitoh if (status != IXGBE_SUCCESS)
196 1.1 msaitoh return status;
197 1.1 msaitoh if (reg_val != 0)
198 1.1 msaitoh return IXGBE_ERR_PHY;
199 1.1 msaitoh
200 1.1 msaitoh reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
201 1.1 msaitoh reg_val = 0xFFFF;
202 1.1 msaitoh status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
203 1.1 msaitoh if (status != IXGBE_SUCCESS)
204 1.1 msaitoh return status;
205 1.1 msaitoh if (reg_val != 0)
206 1.1 msaitoh return IXGBE_ERR_PHY;
207 1.1 msaitoh
208 1.1 msaitoh reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
209 1.1 msaitoh reg_val = 0xFFFF;
210 1.1 msaitoh status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
211 1.1 msaitoh if (status != IXGBE_SUCCESS)
212 1.1 msaitoh return status;
213 1.1 msaitoh if (reg_val != 0)
214 1.1 msaitoh return IXGBE_ERR_PHY;
215 1.1 msaitoh
216 1.1 msaitoh /* Set scratch for next time. */
217 1.1 msaitoh status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
218 1.1 msaitoh IXGBE_CS4227_SCRATCH_VALUE);
219 1.1 msaitoh if (status != IXGBE_SUCCESS)
220 1.1 msaitoh return status;
221 1.1 msaitoh status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
222 1.1 msaitoh if (status != IXGBE_SUCCESS)
223 1.1 msaitoh return status;
224 1.1 msaitoh if (value != IXGBE_CS4227_SCRATCH_VALUE)
225 1.1 msaitoh return IXGBE_ERR_PHY;
226 1.1 msaitoh
227 1.1 msaitoh return IXGBE_SUCCESS;
228 1.1 msaitoh }
229 1.1 msaitoh
230 1.1 msaitoh /**
231 1.1 msaitoh * ixgbe_read_pe - Read register from port expander
232 1.1 msaitoh * @hw: pointer to hardware structure
233 1.1 msaitoh * @reg: register number to read
234 1.1 msaitoh * @value: pointer to receive read value
235 1.1 msaitoh *
236 1.1 msaitoh * Returns status code
237 1.1 msaitoh **/
238 1.1 msaitoh static s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
239 1.1 msaitoh {
240 1.1 msaitoh s32 status;
241 1.1 msaitoh
242 1.1 msaitoh status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
243 1.1 msaitoh if (status != IXGBE_SUCCESS)
244 1.1 msaitoh ERROR_REPORT2(IXGBE_ERROR_CAUTION,
245 1.1 msaitoh "port expander access failed with %d\n", status);
246 1.1 msaitoh return status;
247 1.1 msaitoh }
248 1.1 msaitoh
249 1.1 msaitoh /**
250 1.1 msaitoh * ixgbe_write_pe - Write register to port expander
251 1.1 msaitoh * @hw: pointer to hardware structure
252 1.1 msaitoh * @reg: register number to write
253 1.1 msaitoh * @value: value to write
254 1.1 msaitoh *
255 1.1 msaitoh * Returns status code
256 1.1 msaitoh **/
257 1.1 msaitoh static s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
258 1.1 msaitoh {
259 1.1 msaitoh s32 status;
260 1.1 msaitoh
261 1.1 msaitoh status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
262 1.1 msaitoh if (status != IXGBE_SUCCESS)
263 1.1 msaitoh ERROR_REPORT2(IXGBE_ERROR_CAUTION,
264 1.1 msaitoh "port expander access failed with %d\n", status);
265 1.1 msaitoh return status;
266 1.1 msaitoh }
267 1.1 msaitoh
268 1.1 msaitoh /**
269 1.1 msaitoh * ixgbe_reset_cs4227 - Reset CS4227 using port expander
270 1.1 msaitoh * @hw: pointer to hardware structure
271 1.1 msaitoh *
272 1.1 msaitoh * Returns error code
273 1.1 msaitoh **/
274 1.1 msaitoh static s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
275 1.1 msaitoh {
276 1.1 msaitoh s32 status;
277 1.1 msaitoh u8 reg;
278 1.1 msaitoh
279 1.1 msaitoh status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
280 1.1 msaitoh if (status != IXGBE_SUCCESS)
281 1.1 msaitoh return status;
282 1.1 msaitoh reg |= IXGBE_PE_BIT1;
283 1.1 msaitoh status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
284 1.1 msaitoh if (status != IXGBE_SUCCESS)
285 1.1 msaitoh return status;
286 1.1 msaitoh
287 1.1 msaitoh status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, ®);
288 1.1 msaitoh if (status != IXGBE_SUCCESS)
289 1.1 msaitoh return status;
290 1.1 msaitoh reg &= ~IXGBE_PE_BIT1;
291 1.1 msaitoh status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
292 1.1 msaitoh if (status != IXGBE_SUCCESS)
293 1.1 msaitoh return status;
294 1.1 msaitoh
295 1.1 msaitoh status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
296 1.1 msaitoh if (status != IXGBE_SUCCESS)
297 1.1 msaitoh return status;
298 1.1 msaitoh reg &= ~IXGBE_PE_BIT1;
299 1.1 msaitoh status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
300 1.1 msaitoh if (status != IXGBE_SUCCESS)
301 1.1 msaitoh return status;
302 1.1 msaitoh
303 1.1 msaitoh usec_delay(IXGBE_CS4227_RESET_HOLD);
304 1.1 msaitoh
305 1.1 msaitoh status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
306 1.1 msaitoh if (status != IXGBE_SUCCESS)
307 1.1 msaitoh return status;
308 1.1 msaitoh reg |= IXGBE_PE_BIT1;
309 1.1 msaitoh status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
310 1.1 msaitoh if (status != IXGBE_SUCCESS)
311 1.1 msaitoh return status;
312 1.1 msaitoh
313 1.1 msaitoh msec_delay(IXGBE_CS4227_RESET_DELAY);
314 1.1 msaitoh
315 1.1 msaitoh return IXGBE_SUCCESS;
316 1.1 msaitoh }
317 1.1 msaitoh
318 1.1 msaitoh /**
319 1.1 msaitoh * ixgbe_check_cs4227 - Check CS4227 and reset as needed
320 1.1 msaitoh * @hw: pointer to hardware structure
321 1.1 msaitoh **/
322 1.1 msaitoh static void ixgbe_check_cs4227(struct ixgbe_hw *hw)
323 1.1 msaitoh {
324 1.1 msaitoh u32 swfw_mask = hw->phy.phy_semaphore_mask;
325 1.1 msaitoh s32 status;
326 1.1 msaitoh u8 retry;
327 1.1 msaitoh
328 1.1 msaitoh for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
329 1.1 msaitoh status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
330 1.1 msaitoh if (status != IXGBE_SUCCESS) {
331 1.1 msaitoh ERROR_REPORT2(IXGBE_ERROR_CAUTION,
332 1.1 msaitoh "semaphore failed with %d\n", status);
333 1.1 msaitoh return;
334 1.1 msaitoh }
335 1.1 msaitoh status = ixgbe_get_cs4227_status(hw);
336 1.1 msaitoh if (status == IXGBE_SUCCESS) {
337 1.1 msaitoh hw->mac.ops.release_swfw_sync(hw, swfw_mask);
338 1.1 msaitoh msec_delay(hw->eeprom.semaphore_delay);
339 1.1 msaitoh return;
340 1.1 msaitoh }
341 1.1 msaitoh ixgbe_reset_cs4227(hw);
342 1.1 msaitoh hw->mac.ops.release_swfw_sync(hw, swfw_mask);
343 1.1 msaitoh msec_delay(hw->eeprom.semaphore_delay);
344 1.1 msaitoh }
345 1.1 msaitoh ERROR_REPORT2(IXGBE_ERROR_CAUTION,
346 1.1 msaitoh "Unable to initialize CS4227, err=%d\n", status);
347 1.1 msaitoh }
348 1.1 msaitoh
349 1.1 msaitoh /**
350 1.1 msaitoh * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
351 1.1 msaitoh * @hw: pointer to hardware structure
352 1.1 msaitoh **/
353 1.1 msaitoh static void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
354 1.1 msaitoh {
355 1.1 msaitoh u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
356 1.1 msaitoh
357 1.1 msaitoh if (hw->bus.lan_id) {
358 1.1 msaitoh esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
359 1.1 msaitoh esdp |= IXGBE_ESDP_SDP1_DIR;
360 1.1 msaitoh }
361 1.1 msaitoh esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
362 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
363 1.1 msaitoh IXGBE_WRITE_FLUSH(hw);
364 1.1 msaitoh }
365 1.1 msaitoh
366 1.1 msaitoh /**
367 1.1 msaitoh * ixgbe_identify_phy_x550em - Get PHY type based on device id
368 1.1 msaitoh * @hw: pointer to hardware structure
369 1.1 msaitoh *
370 1.1 msaitoh * Returns error code
371 1.1 msaitoh */
372 1.1 msaitoh static s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
373 1.1 msaitoh {
374 1.1 msaitoh switch (hw->device_id) {
375 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_SFP:
376 1.1 msaitoh /* set up for CS4227 usage */
377 1.1 msaitoh hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
378 1.1 msaitoh ixgbe_setup_mux_ctl(hw);
379 1.1 msaitoh ixgbe_check_cs4227(hw);
380 1.1 msaitoh
381 1.1 msaitoh return ixgbe_identify_module_generic(hw);
382 1.1 msaitoh break;
383 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_KX4:
384 1.1 msaitoh hw->phy.type = ixgbe_phy_x550em_kx4;
385 1.1 msaitoh break;
386 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_KR:
387 1.1 msaitoh hw->phy.type = ixgbe_phy_x550em_kr;
388 1.1 msaitoh break;
389 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_1G_T:
390 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_10G_T:
391 1.1 msaitoh return ixgbe_identify_phy_generic(hw);
392 1.1 msaitoh default:
393 1.1 msaitoh break;
394 1.1 msaitoh }
395 1.1 msaitoh return IXGBE_SUCCESS;
396 1.1 msaitoh }
397 1.1 msaitoh
398 1.1 msaitoh static s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
399 1.1 msaitoh u32 device_type, u16 *phy_data)
400 1.1 msaitoh {
401 1.1 msaitoh UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
402 1.1 msaitoh return IXGBE_NOT_IMPLEMENTED;
403 1.1 msaitoh }
404 1.1 msaitoh
405 1.1 msaitoh static s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
406 1.1 msaitoh u32 device_type, u16 phy_data)
407 1.1 msaitoh {
408 1.1 msaitoh UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
409 1.1 msaitoh return IXGBE_NOT_IMPLEMENTED;
410 1.1 msaitoh }
411 1.1 msaitoh
412 1.1 msaitoh /**
413 1.1 msaitoh * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
414 1.1 msaitoh * @hw: pointer to hardware structure
415 1.1 msaitoh *
416 1.1 msaitoh * Initialize the function pointers and for MAC type X550EM.
417 1.1 msaitoh * Does not touch the hardware.
418 1.1 msaitoh **/
419 1.1 msaitoh s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
420 1.1 msaitoh {
421 1.1 msaitoh struct ixgbe_mac_info *mac = &hw->mac;
422 1.1 msaitoh struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
423 1.1 msaitoh struct ixgbe_phy_info *phy = &hw->phy;
424 1.1 msaitoh s32 ret_val;
425 1.1 msaitoh
426 1.1 msaitoh DEBUGFUNC("ixgbe_init_ops_X550EM");
427 1.1 msaitoh
428 1.1 msaitoh /* Similar to X550 so start there. */
429 1.1 msaitoh ret_val = ixgbe_init_ops_X550(hw);
430 1.1 msaitoh
431 1.1 msaitoh /* Since this function eventually calls
432 1.1 msaitoh * ixgbe_init_ops_540 by design, we are setting
433 1.1 msaitoh * the pointers to NULL explicitly here to overwrite
434 1.1 msaitoh * the values being set in the x540 function.
435 1.1 msaitoh */
436 1.1 msaitoh
437 1.1 msaitoh /* FCOE not supported in x550EM */
438 1.1 msaitoh mac->ops.get_san_mac_addr = NULL;
439 1.1 msaitoh mac->ops.set_san_mac_addr = NULL;
440 1.1 msaitoh mac->ops.get_wwn_prefix = NULL;
441 1.1 msaitoh mac->ops.get_fcoe_boot_status = NULL;
442 1.1 msaitoh
443 1.1 msaitoh /* IPsec not supported in x550EM */
444 1.1 msaitoh mac->ops.disable_sec_rx_path = NULL;
445 1.1 msaitoh mac->ops.enable_sec_rx_path = NULL;
446 1.1 msaitoh
447 1.1 msaitoh /* AUTOC register is not present in x550EM. */
448 1.1 msaitoh mac->ops.prot_autoc_read = NULL;
449 1.1 msaitoh mac->ops.prot_autoc_write = NULL;
450 1.1 msaitoh
451 1.1 msaitoh /* X550EM bus type is internal*/
452 1.1 msaitoh hw->bus.type = ixgbe_bus_type_internal;
453 1.1 msaitoh mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
454 1.1 msaitoh
455 1.1 msaitoh mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
456 1.1 msaitoh mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
457 1.1 msaitoh mac->ops.get_media_type = ixgbe_get_media_type_X550em;
458 1.1 msaitoh mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
459 1.1 msaitoh mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
460 1.1 msaitoh mac->ops.reset_hw = ixgbe_reset_hw_X550em;
461 1.1 msaitoh mac->ops.get_supported_physical_layer =
462 1.1 msaitoh ixgbe_get_supported_physical_layer_X550em;
463 1.1 msaitoh
464 1.1 msaitoh if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
465 1.1 msaitoh mac->ops.setup_fc = ixgbe_setup_fc_generic;
466 1.1 msaitoh else
467 1.1 msaitoh mac->ops.setup_fc = ixgbe_setup_fc_X550em;
468 1.1 msaitoh
469 1.1 msaitoh mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
470 1.1 msaitoh mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
471 1.1 msaitoh
472 1.1 msaitoh if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
473 1.1 msaitoh mac->ops.setup_eee = NULL;
474 1.1 msaitoh
475 1.1 msaitoh /* PHY */
476 1.1 msaitoh phy->ops.init = ixgbe_init_phy_ops_X550em;
477 1.1 msaitoh phy->ops.identify = ixgbe_identify_phy_x550em;
478 1.1 msaitoh if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
479 1.1 msaitoh phy->ops.set_phy_power = NULL;
480 1.1 msaitoh
481 1.1 msaitoh
482 1.1 msaitoh /* EEPROM */
483 1.1 msaitoh eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
484 1.1 msaitoh eeprom->ops.read = ixgbe_read_ee_hostif_X550;
485 1.1 msaitoh eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
486 1.1 msaitoh eeprom->ops.write = ixgbe_write_ee_hostif_X550;
487 1.1 msaitoh eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
488 1.1 msaitoh eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
489 1.1 msaitoh eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
490 1.1 msaitoh eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
491 1.1 msaitoh
492 1.1 msaitoh return ret_val;
493 1.1 msaitoh }
494 1.1 msaitoh
495 1.1 msaitoh /**
496 1.1 msaitoh * ixgbe_dmac_config_X550
497 1.1 msaitoh * @hw: pointer to hardware structure
498 1.1 msaitoh *
499 1.1 msaitoh * Configure DMA coalescing. If enabling dmac, dmac is activated.
500 1.1 msaitoh * When disabling dmac, dmac enable dmac bit is cleared.
501 1.1 msaitoh **/
502 1.1 msaitoh s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
503 1.1 msaitoh {
504 1.1 msaitoh u32 reg, high_pri_tc;
505 1.1 msaitoh
506 1.1 msaitoh DEBUGFUNC("ixgbe_dmac_config_X550");
507 1.1 msaitoh
508 1.1 msaitoh /* Disable DMA coalescing before configuring */
509 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
510 1.1 msaitoh reg &= ~IXGBE_DMACR_DMAC_EN;
511 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
512 1.1 msaitoh
513 1.1 msaitoh /* Disable DMA Coalescing if the watchdog timer is 0 */
514 1.1 msaitoh if (!hw->mac.dmac_config.watchdog_timer)
515 1.1 msaitoh goto out;
516 1.1 msaitoh
517 1.1 msaitoh ixgbe_dmac_config_tcs_X550(hw);
518 1.1 msaitoh
519 1.1 msaitoh /* Configure DMA Coalescing Control Register */
520 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
521 1.1 msaitoh
522 1.1 msaitoh /* Set the watchdog timer in units of 40.96 usec */
523 1.1 msaitoh reg &= ~IXGBE_DMACR_DMACWT_MASK;
524 1.1 msaitoh reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
525 1.1 msaitoh
526 1.1 msaitoh reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
527 1.1 msaitoh /* If fcoe is enabled, set high priority traffic class */
528 1.1 msaitoh if (hw->mac.dmac_config.fcoe_en) {
529 1.1 msaitoh high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
530 1.1 msaitoh reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
531 1.1 msaitoh IXGBE_DMACR_HIGH_PRI_TC_MASK);
532 1.1 msaitoh }
533 1.1 msaitoh reg |= IXGBE_DMACR_EN_MNG_IND;
534 1.1 msaitoh
535 1.1 msaitoh /* Enable DMA coalescing after configuration */
536 1.1 msaitoh reg |= IXGBE_DMACR_DMAC_EN;
537 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
538 1.1 msaitoh
539 1.1 msaitoh out:
540 1.1 msaitoh return IXGBE_SUCCESS;
541 1.1 msaitoh }
542 1.1 msaitoh
543 1.1 msaitoh /**
544 1.1 msaitoh * ixgbe_dmac_config_tcs_X550
545 1.1 msaitoh * @hw: pointer to hardware structure
546 1.1 msaitoh *
547 1.1 msaitoh * Configure DMA coalescing threshold per TC. The dmac enable bit must
548 1.1 msaitoh * be cleared before configuring.
549 1.1 msaitoh **/
550 1.1 msaitoh s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
551 1.1 msaitoh {
552 1.1 msaitoh u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
553 1.1 msaitoh
554 1.1 msaitoh DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
555 1.1 msaitoh
556 1.1 msaitoh /* Configure DMA coalescing enabled */
557 1.1 msaitoh switch (hw->mac.dmac_config.link_speed) {
558 1.1 msaitoh case IXGBE_LINK_SPEED_100_FULL:
559 1.1 msaitoh pb_headroom = IXGBE_DMACRXT_100M;
560 1.1 msaitoh break;
561 1.1 msaitoh case IXGBE_LINK_SPEED_1GB_FULL:
562 1.1 msaitoh pb_headroom = IXGBE_DMACRXT_1G;
563 1.1 msaitoh break;
564 1.1 msaitoh default:
565 1.1 msaitoh pb_headroom = IXGBE_DMACRXT_10G;
566 1.1 msaitoh break;
567 1.1 msaitoh }
568 1.1 msaitoh
569 1.1 msaitoh maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
570 1.1 msaitoh IXGBE_MHADD_MFS_SHIFT) / 1024);
571 1.1 msaitoh
572 1.1 msaitoh /* Set the per Rx packet buffer receive threshold */
573 1.1 msaitoh for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
574 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
575 1.1 msaitoh reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
576 1.1 msaitoh
577 1.1 msaitoh if (tc < hw->mac.dmac_config.num_tcs) {
578 1.1 msaitoh /* Get Rx PB size */
579 1.1 msaitoh rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
580 1.1 msaitoh rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
581 1.1 msaitoh IXGBE_RXPBSIZE_SHIFT;
582 1.1 msaitoh
583 1.1 msaitoh /* Calculate receive buffer threshold in kilobytes */
584 1.1 msaitoh if (rx_pb_size > pb_headroom)
585 1.1 msaitoh rx_pb_size = rx_pb_size - pb_headroom;
586 1.1 msaitoh else
587 1.1 msaitoh rx_pb_size = 0;
588 1.1 msaitoh
589 1.1 msaitoh /* Minimum of MFS shall be set for DMCTH */
590 1.1 msaitoh reg |= (rx_pb_size > maxframe_size_kb) ?
591 1.1 msaitoh rx_pb_size : maxframe_size_kb;
592 1.1 msaitoh }
593 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
594 1.1 msaitoh }
595 1.1 msaitoh return IXGBE_SUCCESS;
596 1.1 msaitoh }
597 1.1 msaitoh
598 1.1 msaitoh /**
599 1.1 msaitoh * ixgbe_dmac_update_tcs_X550
600 1.1 msaitoh * @hw: pointer to hardware structure
601 1.1 msaitoh *
602 1.1 msaitoh * Disables dmac, updates per TC settings, and then enables dmac.
603 1.1 msaitoh **/
604 1.1 msaitoh s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
605 1.1 msaitoh {
606 1.1 msaitoh u32 reg;
607 1.1 msaitoh
608 1.1 msaitoh DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
609 1.1 msaitoh
610 1.1 msaitoh /* Disable DMA coalescing before configuring */
611 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
612 1.1 msaitoh reg &= ~IXGBE_DMACR_DMAC_EN;
613 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
614 1.1 msaitoh
615 1.1 msaitoh ixgbe_dmac_config_tcs_X550(hw);
616 1.1 msaitoh
617 1.1 msaitoh /* Enable DMA coalescing after configuration */
618 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
619 1.1 msaitoh reg |= IXGBE_DMACR_DMAC_EN;
620 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
621 1.1 msaitoh
622 1.1 msaitoh return IXGBE_SUCCESS;
623 1.1 msaitoh }
624 1.1 msaitoh
625 1.1 msaitoh /**
626 1.1 msaitoh * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
627 1.1 msaitoh * @hw: pointer to hardware structure
628 1.1 msaitoh *
629 1.1 msaitoh * Initializes the EEPROM parameters ixgbe_eeprom_info within the
630 1.1 msaitoh * ixgbe_hw struct in order to set up EEPROM access.
631 1.1 msaitoh **/
632 1.1 msaitoh s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
633 1.1 msaitoh {
634 1.1 msaitoh struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
635 1.1 msaitoh u32 eec;
636 1.1 msaitoh u16 eeprom_size;
637 1.1 msaitoh
638 1.1 msaitoh DEBUGFUNC("ixgbe_init_eeprom_params_X550");
639 1.1 msaitoh
640 1.1 msaitoh if (eeprom->type == ixgbe_eeprom_uninitialized) {
641 1.1 msaitoh eeprom->semaphore_delay = 10;
642 1.1 msaitoh eeprom->type = ixgbe_flash;
643 1.1 msaitoh
644 1.1 msaitoh eec = IXGBE_READ_REG(hw, IXGBE_EEC);
645 1.1 msaitoh eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
646 1.1 msaitoh IXGBE_EEC_SIZE_SHIFT);
647 1.1 msaitoh eeprom->word_size = 1 << (eeprom_size +
648 1.1 msaitoh IXGBE_EEPROM_WORD_SIZE_SHIFT);
649 1.1 msaitoh
650 1.1 msaitoh DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
651 1.1 msaitoh eeprom->type, eeprom->word_size);
652 1.1 msaitoh }
653 1.1 msaitoh
654 1.1 msaitoh return IXGBE_SUCCESS;
655 1.1 msaitoh }
656 1.1 msaitoh
657 1.1 msaitoh /**
658 1.1 msaitoh * ixgbe_setup_eee_X550 - Enable/disable EEE support
659 1.1 msaitoh * @hw: pointer to the HW structure
660 1.1 msaitoh * @enable_eee: boolean flag to enable EEE
661 1.1 msaitoh *
662 1.1 msaitoh * Enable/disable EEE based on enable_eee flag.
663 1.1 msaitoh * Auto-negotiation must be started after BASE-T EEE bits in PHY register 7.3C
664 1.1 msaitoh * are modified.
665 1.1 msaitoh *
666 1.1 msaitoh **/
667 1.1 msaitoh s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
668 1.1 msaitoh {
669 1.1 msaitoh u32 eeer;
670 1.1 msaitoh u16 autoneg_eee_reg;
671 1.1 msaitoh u32 link_reg;
672 1.1 msaitoh s32 status;
673 1.1 msaitoh u32 fuse;
674 1.1 msaitoh
675 1.1 msaitoh DEBUGFUNC("ixgbe_setup_eee_X550");
676 1.1 msaitoh
677 1.1 msaitoh eeer = IXGBE_READ_REG(hw, IXGBE_EEER);
678 1.1 msaitoh /* Enable or disable EEE per flag */
679 1.1 msaitoh if (enable_eee) {
680 1.1 msaitoh eeer |= (IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
681 1.1 msaitoh
682 1.1 msaitoh if (hw->device_id == IXGBE_DEV_ID_X550T) {
683 1.1 msaitoh /* Advertise EEE capability */
684 1.1 msaitoh hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
685 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
686 1.1 msaitoh
687 1.1 msaitoh autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
688 1.1 msaitoh IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
689 1.1 msaitoh IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
690 1.1 msaitoh
691 1.1 msaitoh hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
692 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
693 1.1 msaitoh } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
694 1.1 msaitoh /* Not supported on first revision. */
695 1.1 msaitoh fuse = IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0));
696 1.1 msaitoh if (!(fuse & IXGBE_FUSES0_REV1))
697 1.1 msaitoh return IXGBE_SUCCESS;
698 1.1 msaitoh
699 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
700 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
701 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
702 1.1 msaitoh if (status != IXGBE_SUCCESS)
703 1.1 msaitoh return status;
704 1.1 msaitoh
705 1.1 msaitoh link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
706 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
707 1.1 msaitoh
708 1.1 msaitoh /* Don't advertise FEC capability when EEE enabled. */
709 1.1 msaitoh link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
710 1.1 msaitoh
711 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
712 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
713 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
714 1.1 msaitoh if (status != IXGBE_SUCCESS)
715 1.1 msaitoh return status;
716 1.1 msaitoh }
717 1.1 msaitoh } else {
718 1.1 msaitoh eeer &= ~(IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
719 1.1 msaitoh
720 1.1 msaitoh if (hw->device_id == IXGBE_DEV_ID_X550T) {
721 1.1 msaitoh /* Disable advertised EEE capability */
722 1.1 msaitoh hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
723 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
724 1.1 msaitoh
725 1.1 msaitoh autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
726 1.1 msaitoh IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
727 1.1 msaitoh IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
728 1.1 msaitoh
729 1.1 msaitoh hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
730 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
731 1.1 msaitoh } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
732 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
733 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
734 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
735 1.1 msaitoh if (status != IXGBE_SUCCESS)
736 1.1 msaitoh return status;
737 1.1 msaitoh
738 1.1 msaitoh link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
739 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);
740 1.1 msaitoh
741 1.1 msaitoh /* Advertise FEC capability when EEE is disabled. */
742 1.1 msaitoh link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
743 1.1 msaitoh
744 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
745 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
746 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
747 1.1 msaitoh if (status != IXGBE_SUCCESS)
748 1.1 msaitoh return status;
749 1.1 msaitoh }
750 1.1 msaitoh }
751 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_EEER, eeer);
752 1.1 msaitoh
753 1.1 msaitoh return IXGBE_SUCCESS;
754 1.1 msaitoh }
755 1.1 msaitoh
756 1.1 msaitoh /**
757 1.1 msaitoh * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
758 1.1 msaitoh * @hw: pointer to hardware structure
759 1.1 msaitoh * @enable: enable or disable source address pruning
760 1.1 msaitoh * @pool: Rx pool to set source address pruning for
761 1.1 msaitoh **/
762 1.1 msaitoh void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
763 1.1 msaitoh unsigned int pool)
764 1.1 msaitoh {
765 1.1 msaitoh u64 pfflp;
766 1.1 msaitoh
767 1.1 msaitoh /* max rx pool is 63 */
768 1.1 msaitoh if (pool > 63)
769 1.1 msaitoh return;
770 1.1 msaitoh
771 1.1 msaitoh pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
772 1.1 msaitoh pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
773 1.1 msaitoh
774 1.1 msaitoh if (enable)
775 1.1 msaitoh pfflp |= (1ULL << pool);
776 1.1 msaitoh else
777 1.1 msaitoh pfflp &= ~(1ULL << pool);
778 1.1 msaitoh
779 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
780 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
781 1.1 msaitoh }
782 1.1 msaitoh
783 1.1 msaitoh /**
784 1.1 msaitoh * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
785 1.1 msaitoh * @hw: pointer to hardware structure
786 1.1 msaitoh * @enable: enable or disable switch for Ethertype anti-spoofing
787 1.1 msaitoh * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
788 1.1 msaitoh *
789 1.1 msaitoh **/
790 1.1 msaitoh void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
791 1.1 msaitoh bool enable, int vf)
792 1.1 msaitoh {
793 1.1 msaitoh int vf_target_reg = vf >> 3;
794 1.1 msaitoh int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
795 1.1 msaitoh u32 pfvfspoof;
796 1.1 msaitoh
797 1.1 msaitoh DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
798 1.1 msaitoh
799 1.1 msaitoh pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
800 1.1 msaitoh if (enable)
801 1.1 msaitoh pfvfspoof |= (1 << vf_target_shift);
802 1.1 msaitoh else
803 1.1 msaitoh pfvfspoof &= ~(1 << vf_target_shift);
804 1.1 msaitoh
805 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
806 1.1 msaitoh }
807 1.1 msaitoh
808 1.1 msaitoh /**
809 1.1 msaitoh * ixgbe_iosf_wait - Wait for IOSF command completion
810 1.1 msaitoh * @hw: pointer to hardware structure
811 1.1 msaitoh * @ctrl: pointer to location to receive final IOSF control value
812 1.1 msaitoh *
813 1.1 msaitoh * Returns failing status on timeout
814 1.1 msaitoh *
815 1.1 msaitoh * Note: ctrl can be NULL if the IOSF control register value is not needed
816 1.1 msaitoh **/
817 1.1 msaitoh static s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
818 1.1 msaitoh {
819 1.1 msaitoh u32 i, command = 0;
820 1.1 msaitoh
821 1.1 msaitoh /* Check every 10 usec to see if the address cycle completed.
822 1.1 msaitoh * The SB IOSF BUSY bit will clear when the operation is
823 1.1 msaitoh * complete
824 1.1 msaitoh */
825 1.1 msaitoh for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
826 1.1 msaitoh command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
827 1.1 msaitoh if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
828 1.1 msaitoh break;
829 1.1 msaitoh usec_delay(10);
830 1.1 msaitoh }
831 1.1 msaitoh if (ctrl)
832 1.1 msaitoh *ctrl = command;
833 1.1 msaitoh if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
834 1.1 msaitoh ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
835 1.1 msaitoh return IXGBE_ERR_PHY;
836 1.1 msaitoh }
837 1.1 msaitoh
838 1.1 msaitoh return IXGBE_SUCCESS;
839 1.1 msaitoh }
840 1.1 msaitoh
841 1.1 msaitoh /**
842 1.1 msaitoh * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
843 1.1 msaitoh * device
844 1.1 msaitoh * @hw: pointer to hardware structure
845 1.1 msaitoh * @reg_addr: 32 bit PHY register to write
846 1.1 msaitoh * @device_type: 3 bit device type
847 1.1 msaitoh * @data: Data to write to the register
848 1.1 msaitoh **/
849 1.1 msaitoh s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
850 1.1 msaitoh u32 device_type, u32 data)
851 1.1 msaitoh {
852 1.1 msaitoh u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
853 1.1 msaitoh u32 command, error __unused;
854 1.1 msaitoh s32 ret;
855 1.1 msaitoh
856 1.1 msaitoh ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
857 1.1 msaitoh if (ret != IXGBE_SUCCESS)
858 1.1 msaitoh return ret;
859 1.1 msaitoh
860 1.1 msaitoh ret = ixgbe_iosf_wait(hw, NULL);
861 1.1 msaitoh if (ret != IXGBE_SUCCESS)
862 1.1 msaitoh goto out;
863 1.1 msaitoh
864 1.1 msaitoh command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
865 1.1 msaitoh (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
866 1.1 msaitoh
867 1.1 msaitoh /* Write IOSF control register */
868 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
869 1.1 msaitoh
870 1.1 msaitoh /* Write IOSF data register */
871 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
872 1.1 msaitoh
873 1.1 msaitoh ret = ixgbe_iosf_wait(hw, &command);
874 1.1 msaitoh
875 1.1 msaitoh if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
876 1.1 msaitoh error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
877 1.1 msaitoh IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
878 1.1 msaitoh ERROR_REPORT2(IXGBE_ERROR_POLLING,
879 1.1 msaitoh "Failed to write, error %x\n", error);
880 1.1 msaitoh ret = IXGBE_ERR_PHY;
881 1.1 msaitoh }
882 1.1 msaitoh
883 1.1 msaitoh out:
884 1.1 msaitoh ixgbe_release_swfw_semaphore(hw, gssr);
885 1.1 msaitoh return ret;
886 1.1 msaitoh }
887 1.1 msaitoh
888 1.1 msaitoh /**
889 1.1 msaitoh * ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
890 1.1 msaitoh * device
891 1.1 msaitoh * @hw: pointer to hardware structure
892 1.1 msaitoh * @reg_addr: 32 bit PHY register to write
893 1.1 msaitoh * @device_type: 3 bit device type
894 1.1 msaitoh * @phy_data: Pointer to read data from the register
895 1.1 msaitoh **/
896 1.1 msaitoh s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
897 1.1 msaitoh u32 device_type, u32 *data)
898 1.1 msaitoh {
899 1.1 msaitoh u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
900 1.1 msaitoh u32 command, error __unused;
901 1.1 msaitoh s32 ret;
902 1.1 msaitoh
903 1.1 msaitoh ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
904 1.1 msaitoh if (ret != IXGBE_SUCCESS)
905 1.1 msaitoh return ret;
906 1.1 msaitoh
907 1.1 msaitoh ret = ixgbe_iosf_wait(hw, NULL);
908 1.1 msaitoh if (ret != IXGBE_SUCCESS)
909 1.1 msaitoh goto out;
910 1.1 msaitoh
911 1.1 msaitoh command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
912 1.1 msaitoh (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
913 1.1 msaitoh
914 1.1 msaitoh /* Write IOSF control register */
915 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
916 1.1 msaitoh
917 1.1 msaitoh ret = ixgbe_iosf_wait(hw, &command);
918 1.1 msaitoh
919 1.1 msaitoh if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
920 1.1 msaitoh error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
921 1.1 msaitoh IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
922 1.1 msaitoh ERROR_REPORT2(IXGBE_ERROR_POLLING,
923 1.1 msaitoh "Failed to read, error %x\n", error);
924 1.1 msaitoh ret = IXGBE_ERR_PHY;
925 1.1 msaitoh }
926 1.1 msaitoh
927 1.1 msaitoh if (ret == IXGBE_SUCCESS)
928 1.1 msaitoh *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
929 1.1 msaitoh
930 1.1 msaitoh out:
931 1.1 msaitoh ixgbe_release_swfw_semaphore(hw, gssr);
932 1.1 msaitoh return ret;
933 1.1 msaitoh }
934 1.1 msaitoh
935 1.1 msaitoh /**
936 1.1 msaitoh * ixgbe_disable_mdd_X550
937 1.1 msaitoh * @hw: pointer to hardware structure
938 1.1 msaitoh *
939 1.1 msaitoh * Disable malicious driver detection
940 1.1 msaitoh **/
941 1.1 msaitoh void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
942 1.1 msaitoh {
943 1.1 msaitoh u32 reg;
944 1.1 msaitoh
945 1.1 msaitoh DEBUGFUNC("ixgbe_disable_mdd_X550");
946 1.1 msaitoh
947 1.1 msaitoh /* Disable MDD for TX DMA and interrupt */
948 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
949 1.1 msaitoh reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
950 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
951 1.1 msaitoh
952 1.1 msaitoh /* Disable MDD for RX and interrupt */
953 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
954 1.1 msaitoh reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
955 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
956 1.1 msaitoh }
957 1.1 msaitoh
958 1.1 msaitoh /**
959 1.1 msaitoh * ixgbe_enable_mdd_X550
960 1.1 msaitoh * @hw: pointer to hardware structure
961 1.1 msaitoh *
962 1.1 msaitoh * Enable malicious driver detection
963 1.1 msaitoh **/
964 1.1 msaitoh void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
965 1.1 msaitoh {
966 1.1 msaitoh u32 reg;
967 1.1 msaitoh
968 1.1 msaitoh DEBUGFUNC("ixgbe_enable_mdd_X550");
969 1.1 msaitoh
970 1.1 msaitoh /* Enable MDD for TX DMA and interrupt */
971 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
972 1.1 msaitoh reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
973 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
974 1.1 msaitoh
975 1.1 msaitoh /* Enable MDD for RX and interrupt */
976 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
977 1.1 msaitoh reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
978 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
979 1.1 msaitoh }
980 1.1 msaitoh
981 1.1 msaitoh /**
982 1.1 msaitoh * ixgbe_restore_mdd_vf_X550
983 1.1 msaitoh * @hw: pointer to hardware structure
984 1.1 msaitoh * @vf: vf index
985 1.1 msaitoh *
986 1.1 msaitoh * Restore VF that was disabled during malicious driver detection event
987 1.1 msaitoh **/
988 1.1 msaitoh void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
989 1.1 msaitoh {
990 1.1 msaitoh u32 idx, reg, num_qs, start_q, bitmask;
991 1.1 msaitoh
992 1.1 msaitoh DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
993 1.1 msaitoh
994 1.1 msaitoh /* Map VF to queues */
995 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
996 1.1 msaitoh switch (reg & IXGBE_MRQC_MRQE_MASK) {
997 1.1 msaitoh case IXGBE_MRQC_VMDQRT8TCEN:
998 1.1 msaitoh num_qs = 8; /* 16 VFs / pools */
999 1.1 msaitoh bitmask = 0x000000FF;
1000 1.1 msaitoh break;
1001 1.1 msaitoh case IXGBE_MRQC_VMDQRSS32EN:
1002 1.1 msaitoh case IXGBE_MRQC_VMDQRT4TCEN:
1003 1.1 msaitoh num_qs = 4; /* 32 VFs / pools */
1004 1.1 msaitoh bitmask = 0x0000000F;
1005 1.1 msaitoh break;
1006 1.1 msaitoh default: /* 64 VFs / pools */
1007 1.1 msaitoh num_qs = 2;
1008 1.1 msaitoh bitmask = 0x00000003;
1009 1.1 msaitoh break;
1010 1.1 msaitoh }
1011 1.1 msaitoh start_q = vf * num_qs;
1012 1.1 msaitoh
1013 1.1 msaitoh /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1014 1.1 msaitoh idx = start_q / 32;
1015 1.1 msaitoh reg = 0;
1016 1.1 msaitoh reg |= (bitmask << (start_q % 32));
1017 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1018 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1019 1.1 msaitoh }
1020 1.1 msaitoh
1021 1.1 msaitoh /**
1022 1.1 msaitoh * ixgbe_mdd_event_X550
1023 1.1 msaitoh * @hw: pointer to hardware structure
1024 1.1 msaitoh * @vf_bitmap: vf bitmap of malicious vfs
1025 1.1 msaitoh *
1026 1.1 msaitoh * Handle malicious driver detection event.
1027 1.1 msaitoh **/
1028 1.1 msaitoh void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1029 1.1 msaitoh {
1030 1.1 msaitoh u32 wqbr;
1031 1.1 msaitoh u32 i, j, reg, q, shift, vf, idx;
1032 1.1 msaitoh
1033 1.1 msaitoh DEBUGFUNC("ixgbe_mdd_event_X550");
1034 1.1 msaitoh
1035 1.1 msaitoh /* figure out pool size for mapping to vf's */
1036 1.1 msaitoh reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1037 1.1 msaitoh switch (reg & IXGBE_MRQC_MRQE_MASK) {
1038 1.1 msaitoh case IXGBE_MRQC_VMDQRT8TCEN:
1039 1.1 msaitoh shift = 3; /* 16 VFs / pools */
1040 1.1 msaitoh break;
1041 1.1 msaitoh case IXGBE_MRQC_VMDQRSS32EN:
1042 1.1 msaitoh case IXGBE_MRQC_VMDQRT4TCEN:
1043 1.1 msaitoh shift = 2; /* 32 VFs / pools */
1044 1.1 msaitoh break;
1045 1.1 msaitoh default:
1046 1.1 msaitoh shift = 1; /* 64 VFs / pools */
1047 1.1 msaitoh break;
1048 1.1 msaitoh }
1049 1.1 msaitoh
1050 1.1 msaitoh /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1051 1.1 msaitoh for (i = 0; i < 4; i++) {
1052 1.1 msaitoh wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1053 1.1 msaitoh wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1054 1.1 msaitoh
1055 1.1 msaitoh if (!wqbr)
1056 1.1 msaitoh continue;
1057 1.1 msaitoh
1058 1.1 msaitoh /* Get malicious queue */
1059 1.1 msaitoh for (j = 0; j < 32 && wqbr; j++) {
1060 1.1 msaitoh
1061 1.1 msaitoh if (!(wqbr & (1 << j)))
1062 1.1 msaitoh continue;
1063 1.1 msaitoh
1064 1.1 msaitoh /* Get queue from bitmask */
1065 1.1 msaitoh q = j + (i * 32);
1066 1.1 msaitoh
1067 1.1 msaitoh /* Map queue to vf */
1068 1.1 msaitoh vf = (q >> shift);
1069 1.1 msaitoh
1070 1.1 msaitoh /* Set vf bit in vf_bitmap */
1071 1.1 msaitoh idx = vf / 32;
1072 1.1 msaitoh vf_bitmap[idx] |= (1 << (vf % 32));
1073 1.1 msaitoh wqbr &= ~(1 << j);
1074 1.1 msaitoh }
1075 1.1 msaitoh }
1076 1.1 msaitoh }
1077 1.1 msaitoh
1078 1.1 msaitoh /**
1079 1.1 msaitoh * ixgbe_get_media_type_X550em - Get media type
1080 1.1 msaitoh * @hw: pointer to hardware structure
1081 1.1 msaitoh *
1082 1.1 msaitoh * Returns the media type (fiber, copper, backplane)
1083 1.1 msaitoh */
1084 1.1 msaitoh enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1085 1.1 msaitoh {
1086 1.1 msaitoh enum ixgbe_media_type media_type;
1087 1.1 msaitoh
1088 1.1 msaitoh DEBUGFUNC("ixgbe_get_media_type_X550em");
1089 1.1 msaitoh
1090 1.1 msaitoh /* Detect if there is a copper PHY attached. */
1091 1.1 msaitoh switch (hw->device_id) {
1092 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_KR:
1093 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_KX4:
1094 1.1 msaitoh media_type = ixgbe_media_type_backplane;
1095 1.1 msaitoh break;
1096 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_SFP:
1097 1.1 msaitoh media_type = ixgbe_media_type_fiber;
1098 1.1 msaitoh break;
1099 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_1G_T:
1100 1.1 msaitoh case IXGBE_DEV_ID_X550EM_X_10G_T:
1101 1.1 msaitoh media_type = ixgbe_media_type_copper;
1102 1.1 msaitoh break;
1103 1.1 msaitoh default:
1104 1.1 msaitoh media_type = ixgbe_media_type_unknown;
1105 1.1 msaitoh break;
1106 1.1 msaitoh }
1107 1.1 msaitoh return media_type;
1108 1.1 msaitoh }
1109 1.1 msaitoh
1110 1.1 msaitoh /**
1111 1.1 msaitoh * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1112 1.1 msaitoh * @hw: pointer to hardware structure
1113 1.1 msaitoh * @linear: TRUE if SFP module is linear
1114 1.1 msaitoh */
1115 1.1 msaitoh static s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1116 1.1 msaitoh {
1117 1.1 msaitoh DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1118 1.1 msaitoh
1119 1.1 msaitoh switch (hw->phy.sfp_type) {
1120 1.1 msaitoh case ixgbe_sfp_type_not_present:
1121 1.1 msaitoh return IXGBE_ERR_SFP_NOT_PRESENT;
1122 1.1 msaitoh case ixgbe_sfp_type_da_cu_core0:
1123 1.1 msaitoh case ixgbe_sfp_type_da_cu_core1:
1124 1.1 msaitoh *linear = TRUE;
1125 1.1 msaitoh break;
1126 1.1 msaitoh case ixgbe_sfp_type_srlr_core0:
1127 1.1 msaitoh case ixgbe_sfp_type_srlr_core1:
1128 1.1 msaitoh case ixgbe_sfp_type_da_act_lmt_core0:
1129 1.1 msaitoh case ixgbe_sfp_type_da_act_lmt_core1:
1130 1.1 msaitoh case ixgbe_sfp_type_1g_sx_core0:
1131 1.1 msaitoh case ixgbe_sfp_type_1g_sx_core1:
1132 1.1 msaitoh case ixgbe_sfp_type_1g_lx_core0:
1133 1.1 msaitoh case ixgbe_sfp_type_1g_lx_core1:
1134 1.1 msaitoh *linear = FALSE;
1135 1.1 msaitoh break;
1136 1.1 msaitoh case ixgbe_sfp_type_unknown:
1137 1.1 msaitoh case ixgbe_sfp_type_1g_cu_core0:
1138 1.1 msaitoh case ixgbe_sfp_type_1g_cu_core1:
1139 1.1 msaitoh default:
1140 1.1 msaitoh return IXGBE_ERR_SFP_NOT_SUPPORTED;
1141 1.1 msaitoh }
1142 1.1 msaitoh
1143 1.1 msaitoh return IXGBE_SUCCESS;
1144 1.1 msaitoh }
1145 1.1 msaitoh
1146 1.1 msaitoh /**
1147 1.1 msaitoh * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1148 1.1 msaitoh * @hw: pointer to hardware structure
1149 1.1 msaitoh *
1150 1.1 msaitoh * Searches for and identifies the SFP module and assigns appropriate PHY type.
1151 1.1 msaitoh **/
1152 1.1 msaitoh s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1153 1.1 msaitoh {
1154 1.1 msaitoh s32 status;
1155 1.1 msaitoh bool linear;
1156 1.1 msaitoh
1157 1.1 msaitoh DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1158 1.1 msaitoh
1159 1.1 msaitoh status = ixgbe_identify_module_generic(hw);
1160 1.1 msaitoh
1161 1.1 msaitoh if (status != IXGBE_SUCCESS)
1162 1.1 msaitoh return status;
1163 1.1 msaitoh
1164 1.1 msaitoh /* Check if SFP module is supported */
1165 1.1 msaitoh status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1166 1.1 msaitoh
1167 1.1 msaitoh return status;
1168 1.1 msaitoh }
1169 1.1 msaitoh
1170 1.1 msaitoh /**
1171 1.1 msaitoh * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1172 1.1 msaitoh * @hw: pointer to hardware structure
1173 1.1 msaitoh */
1174 1.1 msaitoh s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1175 1.1 msaitoh {
1176 1.1 msaitoh s32 status;
1177 1.1 msaitoh bool linear;
1178 1.1 msaitoh
1179 1.1 msaitoh DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1180 1.1 msaitoh
1181 1.1 msaitoh /* Check if SFP module is supported */
1182 1.1 msaitoh status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1183 1.1 msaitoh
1184 1.1 msaitoh if (status != IXGBE_SUCCESS)
1185 1.1 msaitoh return status;
1186 1.1 msaitoh
1187 1.1 msaitoh ixgbe_init_mac_link_ops_X550em(hw);
1188 1.1 msaitoh hw->phy.ops.reset = NULL;
1189 1.1 msaitoh
1190 1.1 msaitoh return IXGBE_SUCCESS;
1191 1.1 msaitoh }
1192 1.1 msaitoh
1193 1.1 msaitoh /**
1194 1.1 msaitoh * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1195 1.1 msaitoh * @hw: pointer to hardware structure
1196 1.1 msaitoh */
1197 1.1 msaitoh void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1198 1.1 msaitoh {
1199 1.1 msaitoh struct ixgbe_mac_info *mac = &hw->mac;
1200 1.1 msaitoh
1201 1.1 msaitoh DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1202 1.1 msaitoh
1203 1.1 msaitoh switch (hw->mac.ops.get_media_type(hw)) {
1204 1.1 msaitoh case ixgbe_media_type_fiber:
1205 1.1 msaitoh /* CS4227 does not support autoneg, so disable the laser control
1206 1.1 msaitoh * functions for SFP+ fiber
1207 1.1 msaitoh */
1208 1.1 msaitoh mac->ops.disable_tx_laser = NULL;
1209 1.1 msaitoh mac->ops.enable_tx_laser = NULL;
1210 1.1 msaitoh mac->ops.flap_tx_laser = NULL;
1211 1.1 msaitoh mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1212 1.1 msaitoh mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_x550em;
1213 1.1 msaitoh mac->ops.set_rate_select_speed =
1214 1.1 msaitoh ixgbe_set_soft_rate_select_speed;
1215 1.1 msaitoh break;
1216 1.1 msaitoh case ixgbe_media_type_copper:
1217 1.1 msaitoh mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1218 1.1 msaitoh mac->ops.check_link = ixgbe_check_link_t_X550em;
1219 1.1 msaitoh break;
1220 1.1 msaitoh default:
1221 1.1 msaitoh break;
1222 1.1 msaitoh }
1223 1.1 msaitoh }
1224 1.1 msaitoh
1225 1.1 msaitoh /**
1226 1.1 msaitoh * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1227 1.1 msaitoh * @hw: pointer to hardware structure
1228 1.1 msaitoh * @speed: pointer to link speed
1229 1.1 msaitoh * @autoneg: TRUE when autoneg or autotry is enabled
1230 1.1 msaitoh */
1231 1.1 msaitoh s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1232 1.1 msaitoh ixgbe_link_speed *speed,
1233 1.1 msaitoh bool *autoneg)
1234 1.1 msaitoh {
1235 1.1 msaitoh DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1236 1.1 msaitoh
1237 1.1 msaitoh /* SFP */
1238 1.1 msaitoh if (hw->phy.media_type == ixgbe_media_type_fiber) {
1239 1.1 msaitoh
1240 1.1 msaitoh /* CS4227 SFP must not enable auto-negotiation */
1241 1.1 msaitoh *autoneg = FALSE;
1242 1.1 msaitoh
1243 1.1 msaitoh /* Check if 1G SFP module. */
1244 1.1 msaitoh if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1245 1.1 msaitoh hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1246 1.1 msaitoh || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1247 1.1 msaitoh hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1248 1.1 msaitoh *speed = IXGBE_LINK_SPEED_1GB_FULL;
1249 1.1 msaitoh return IXGBE_SUCCESS;
1250 1.1 msaitoh }
1251 1.1 msaitoh
1252 1.1 msaitoh /* Link capabilities are based on SFP */
1253 1.1 msaitoh if (hw->phy.multispeed_fiber)
1254 1.1 msaitoh *speed = IXGBE_LINK_SPEED_10GB_FULL |
1255 1.1 msaitoh IXGBE_LINK_SPEED_1GB_FULL;
1256 1.1 msaitoh else
1257 1.1 msaitoh *speed = IXGBE_LINK_SPEED_10GB_FULL;
1258 1.1 msaitoh } else {
1259 1.1 msaitoh *speed = IXGBE_LINK_SPEED_10GB_FULL |
1260 1.1 msaitoh IXGBE_LINK_SPEED_1GB_FULL;
1261 1.1 msaitoh *autoneg = TRUE;
1262 1.1 msaitoh }
1263 1.1 msaitoh
1264 1.1 msaitoh return IXGBE_SUCCESS;
1265 1.1 msaitoh }
1266 1.1 msaitoh
1267 1.1 msaitoh /**
1268 1.1 msaitoh * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
1269 1.1 msaitoh * @hw: pointer to hardware structure
1270 1.1 msaitoh * @lsc: pointer to boolean flag which indicates whether external Base T
1271 1.1 msaitoh * PHY interrupt is lsc
1272 1.1 msaitoh *
1273 1.1 msaitoh * Determime if external Base T PHY interrupt cause is high temperature
1274 1.1 msaitoh * failure alarm or link status change.
1275 1.1 msaitoh *
1276 1.1 msaitoh * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
1277 1.1 msaitoh * failure alarm, else return PHY access status.
1278 1.1 msaitoh */
1279 1.1 msaitoh static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
1280 1.1 msaitoh {
1281 1.1 msaitoh u32 status;
1282 1.1 msaitoh u16 reg;
1283 1.1 msaitoh
1284 1.1 msaitoh *lsc = FALSE;
1285 1.1 msaitoh
1286 1.1 msaitoh /* Vendor alarm triggered */
1287 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1288 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1289 1.1 msaitoh ®);
1290 1.1 msaitoh
1291 1.1 msaitoh if (status != IXGBE_SUCCESS ||
1292 1.1 msaitoh !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
1293 1.1 msaitoh return status;
1294 1.1 msaitoh
1295 1.1 msaitoh /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
1296 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
1297 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1298 1.1 msaitoh ®);
1299 1.1 msaitoh
1300 1.1 msaitoh if (status != IXGBE_SUCCESS ||
1301 1.1 msaitoh !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1302 1.1 msaitoh IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
1303 1.1 msaitoh return status;
1304 1.1 msaitoh
1305 1.1 msaitoh /* High temperature failure alarm triggered */
1306 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
1307 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1308 1.1 msaitoh ®);
1309 1.1 msaitoh
1310 1.1 msaitoh if (status != IXGBE_SUCCESS)
1311 1.1 msaitoh return status;
1312 1.1 msaitoh
1313 1.1 msaitoh /* If high temperature failure, then return over temp error and exit */
1314 1.1 msaitoh if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
1315 1.1 msaitoh /* power down the PHY in case the PHY FW didn't already */
1316 1.1 msaitoh ixgbe_set_copper_phy_power(hw, FALSE);
1317 1.1 msaitoh return IXGBE_ERR_OVERTEMP;
1318 1.1 msaitoh }
1319 1.1 msaitoh
1320 1.1 msaitoh /* Vendor alarm 2 triggered */
1321 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1322 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1323 1.1 msaitoh
1324 1.1 msaitoh if (status != IXGBE_SUCCESS ||
1325 1.1 msaitoh !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
1326 1.1 msaitoh return status;
1327 1.1 msaitoh
1328 1.1 msaitoh /* link connect/disconnect event occurred */
1329 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
1330 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1331 1.1 msaitoh
1332 1.1 msaitoh if (status != IXGBE_SUCCESS)
1333 1.1 msaitoh return status;
1334 1.1 msaitoh
1335 1.1 msaitoh /* Indicate LSC */
1336 1.1 msaitoh if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
1337 1.1 msaitoh *lsc = TRUE;
1338 1.1 msaitoh
1339 1.1 msaitoh return IXGBE_SUCCESS;
1340 1.1 msaitoh }
1341 1.1 msaitoh
1342 1.1 msaitoh /**
1343 1.1 msaitoh * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
1344 1.1 msaitoh * @hw: pointer to hardware structure
1345 1.1 msaitoh *
1346 1.1 msaitoh * Enable link status change and temperature failure alarm for the external
1347 1.1 msaitoh * Base T PHY
1348 1.1 msaitoh *
1349 1.1 msaitoh * Returns PHY access status
1350 1.1 msaitoh */
1351 1.1 msaitoh static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
1352 1.1 msaitoh {
1353 1.1 msaitoh u32 status;
1354 1.1 msaitoh u16 reg;
1355 1.1 msaitoh bool lsc;
1356 1.1 msaitoh
1357 1.1 msaitoh /* Clear interrupt flags */
1358 1.1 msaitoh status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
1359 1.1 msaitoh
1360 1.1 msaitoh /* Enable link status change alarm */
1361 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1362 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1363 1.1 msaitoh
1364 1.1 msaitoh if (status != IXGBE_SUCCESS)
1365 1.1 msaitoh return status;
1366 1.1 msaitoh
1367 1.1 msaitoh reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
1368 1.1 msaitoh
1369 1.1 msaitoh status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1370 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
1371 1.1 msaitoh
1372 1.1 msaitoh if (status != IXGBE_SUCCESS)
1373 1.1 msaitoh return status;
1374 1.1 msaitoh
1375 1.1 msaitoh /* Enables high temperature failure alarm */
1376 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1377 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1378 1.1 msaitoh ®);
1379 1.1 msaitoh
1380 1.1 msaitoh if (status != IXGBE_SUCCESS)
1381 1.1 msaitoh return status;
1382 1.1 msaitoh
1383 1.1 msaitoh reg |= IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN;
1384 1.1 msaitoh
1385 1.1 msaitoh status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1386 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1387 1.1 msaitoh reg);
1388 1.1 msaitoh
1389 1.1 msaitoh if (status != IXGBE_SUCCESS)
1390 1.1 msaitoh return status;
1391 1.1 msaitoh
1392 1.1 msaitoh /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
1393 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1394 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1395 1.1 msaitoh ®);
1396 1.1 msaitoh
1397 1.1 msaitoh if (status != IXGBE_SUCCESS)
1398 1.1 msaitoh return status;
1399 1.1 msaitoh
1400 1.1 msaitoh reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1401 1.1 msaitoh IXGBE_MDIO_GLOBAL_ALARM_1_INT);
1402 1.1 msaitoh
1403 1.1 msaitoh status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1404 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1405 1.1 msaitoh reg);
1406 1.1 msaitoh
1407 1.1 msaitoh if (status != IXGBE_SUCCESS)
1408 1.1 msaitoh return status;
1409 1.1 msaitoh
1410 1.1 msaitoh /* Enable chip-wide vendor alarm */
1411 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1412 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1413 1.1 msaitoh ®);
1414 1.1 msaitoh
1415 1.1 msaitoh if (status != IXGBE_SUCCESS)
1416 1.1 msaitoh return status;
1417 1.1 msaitoh
1418 1.1 msaitoh reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
1419 1.1 msaitoh
1420 1.1 msaitoh status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1421 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1422 1.1 msaitoh reg);
1423 1.1 msaitoh
1424 1.1 msaitoh return status;
1425 1.1 msaitoh }
1426 1.1 msaitoh
1427 1.1 msaitoh /**
1428 1.1 msaitoh * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
1429 1.1 msaitoh * @hw: pointer to hardware structure
1430 1.1 msaitoh * @speed: link speed
1431 1.1 msaitoh *
1432 1.1 msaitoh * Configures the integrated KR PHY.
1433 1.1 msaitoh **/
1434 1.1 msaitoh static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
1435 1.1 msaitoh ixgbe_link_speed speed)
1436 1.1 msaitoh {
1437 1.1 msaitoh s32 status;
1438 1.1 msaitoh u32 reg_val;
1439 1.1 msaitoh
1440 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
1441 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1442 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1443 1.1 msaitoh if (status)
1444 1.1 msaitoh return status;
1445 1.1 msaitoh
1446 1.1 msaitoh reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1447 1.1 msaitoh reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ |
1448 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC);
1449 1.1 msaitoh reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
1450 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
1451 1.1 msaitoh
1452 1.1 msaitoh /* Advertise 10G support. */
1453 1.1 msaitoh if (speed & IXGBE_LINK_SPEED_10GB_FULL)
1454 1.1 msaitoh reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
1455 1.1 msaitoh
1456 1.1 msaitoh /* Advertise 1G support. */
1457 1.1 msaitoh if (speed & IXGBE_LINK_SPEED_1GB_FULL)
1458 1.1 msaitoh reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
1459 1.1 msaitoh
1460 1.1 msaitoh /* Restart auto-negotiation. */
1461 1.1 msaitoh reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1462 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
1463 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1464 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1465 1.1 msaitoh
1466 1.1 msaitoh return status;
1467 1.1 msaitoh }
1468 1.1 msaitoh
1469 1.1 msaitoh /**
1470 1.1 msaitoh * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
1471 1.1 msaitoh * @hw: pointer to hardware structure
1472 1.1 msaitoh *
1473 1.1 msaitoh * Initialize any function pointers that were not able to be
1474 1.1 msaitoh * set during init_shared_code because the PHY/SFP type was
1475 1.1 msaitoh * not known. Perform the SFP init if necessary.
1476 1.1 msaitoh */
1477 1.1 msaitoh s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
1478 1.1 msaitoh {
1479 1.1 msaitoh struct ixgbe_phy_info *phy = &hw->phy;
1480 1.1 msaitoh ixgbe_link_speed speed;
1481 1.1 msaitoh s32 ret_val;
1482 1.1 msaitoh
1483 1.1 msaitoh DEBUGFUNC("ixgbe_init_phy_ops_X550em");
1484 1.1 msaitoh
1485 1.1 msaitoh hw->mac.ops.set_lan_id(hw);
1486 1.1 msaitoh
1487 1.1 msaitoh if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
1488 1.1 msaitoh phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
1489 1.1 msaitoh ixgbe_setup_mux_ctl(hw);
1490 1.1 msaitoh
1491 1.1 msaitoh /* Save NW management interface connected on board. This is used
1492 1.1 msaitoh * to determine internal PHY mode.
1493 1.1 msaitoh */
1494 1.1 msaitoh phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
1495 1.1 msaitoh
1496 1.1 msaitoh /* If internal PHY mode is KR, then initialize KR link */
1497 1.1 msaitoh if (phy->nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE) {
1498 1.1 msaitoh speed = IXGBE_LINK_SPEED_10GB_FULL |
1499 1.1 msaitoh IXGBE_LINK_SPEED_1GB_FULL;
1500 1.1 msaitoh ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
1501 1.1 msaitoh }
1502 1.1 msaitoh
1503 1.1 msaitoh phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
1504 1.1 msaitoh }
1505 1.1 msaitoh
1506 1.1 msaitoh /* Identify the PHY or SFP module */
1507 1.1 msaitoh ret_val = phy->ops.identify(hw);
1508 1.1 msaitoh if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
1509 1.1 msaitoh return ret_val;
1510 1.1 msaitoh
1511 1.1 msaitoh /* Setup function pointers based on detected hardware */
1512 1.1 msaitoh ixgbe_init_mac_link_ops_X550em(hw);
1513 1.1 msaitoh if (phy->sfp_type != ixgbe_sfp_type_unknown)
1514 1.1 msaitoh phy->ops.reset = NULL;
1515 1.1 msaitoh
1516 1.1 msaitoh /* Set functions pointers based on phy type */
1517 1.1 msaitoh switch (hw->phy.type) {
1518 1.1 msaitoh case ixgbe_phy_x550em_kx4:
1519 1.1 msaitoh phy->ops.setup_link = ixgbe_setup_kx4_x550em;
1520 1.1 msaitoh phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1521 1.1 msaitoh phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1522 1.1 msaitoh break;
1523 1.1 msaitoh case ixgbe_phy_x550em_kr:
1524 1.1 msaitoh phy->ops.setup_link = ixgbe_setup_kr_x550em;
1525 1.1 msaitoh phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1526 1.1 msaitoh phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1527 1.1 msaitoh break;
1528 1.1 msaitoh case ixgbe_phy_x550em_ext_t:
1529 1.1 msaitoh /* Save NW management interface connected on board. This is used
1530 1.1 msaitoh * to determine internal PHY mode
1531 1.1 msaitoh */
1532 1.1 msaitoh phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
1533 1.1 msaitoh
1534 1.1 msaitoh /* If internal link mode is XFI, then setup iXFI internal link,
1535 1.1 msaitoh * else setup KR now.
1536 1.1 msaitoh */
1537 1.1 msaitoh if (!(phy->nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
1538 1.1 msaitoh phy->ops.setup_internal_link =
1539 1.1 msaitoh ixgbe_setup_internal_phy_t_x550em;
1540 1.1 msaitoh } else {
1541 1.1 msaitoh speed = IXGBE_LINK_SPEED_10GB_FULL |
1542 1.1 msaitoh IXGBE_LINK_SPEED_1GB_FULL;
1543 1.1 msaitoh ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
1544 1.1 msaitoh }
1545 1.1 msaitoh
1546 1.1 msaitoh phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
1547 1.1 msaitoh phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
1548 1.1 msaitoh phy->ops.reset = ixgbe_reset_phy_t_X550em;
1549 1.1 msaitoh break;
1550 1.1 msaitoh default:
1551 1.1 msaitoh break;
1552 1.1 msaitoh }
1553 1.1 msaitoh return ret_val;
1554 1.1 msaitoh }
1555 1.1 msaitoh
1556 1.1 msaitoh /**
1557 1.1 msaitoh * ixgbe_reset_hw_X550em - Perform hardware reset
1558 1.1 msaitoh * @hw: pointer to hardware structure
1559 1.1 msaitoh *
1560 1.1 msaitoh * Resets the hardware by resetting the transmit and receive units, masks
1561 1.1 msaitoh * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
1562 1.1 msaitoh * reset.
1563 1.1 msaitoh */
1564 1.1 msaitoh s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
1565 1.1 msaitoh {
1566 1.1 msaitoh ixgbe_link_speed link_speed;
1567 1.1 msaitoh s32 status;
1568 1.1 msaitoh u32 ctrl = 0;
1569 1.1 msaitoh u32 i;
1570 1.1 msaitoh u32 hlreg0;
1571 1.1 msaitoh bool link_up = FALSE;
1572 1.1 msaitoh
1573 1.1 msaitoh DEBUGFUNC("ixgbe_reset_hw_X550em");
1574 1.1 msaitoh
1575 1.1 msaitoh /* Call adapter stop to disable Tx/Rx and clear interrupts */
1576 1.1 msaitoh status = hw->mac.ops.stop_adapter(hw);
1577 1.1 msaitoh if (status != IXGBE_SUCCESS)
1578 1.1 msaitoh return status;
1579 1.1 msaitoh
1580 1.1 msaitoh /* flush pending Tx transactions */
1581 1.1 msaitoh ixgbe_clear_tx_pending(hw);
1582 1.1 msaitoh
1583 1.1 msaitoh /* PHY ops must be identified and initialized prior to reset */
1584 1.1 msaitoh
1585 1.1 msaitoh /* Identify PHY and related function pointers */
1586 1.1 msaitoh status = hw->phy.ops.init(hw);
1587 1.1 msaitoh
1588 1.1 msaitoh if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1589 1.1 msaitoh return status;
1590 1.1 msaitoh
1591 1.1 msaitoh /* start the external PHY */
1592 1.1 msaitoh if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
1593 1.1 msaitoh status = ixgbe_init_ext_t_x550em(hw);
1594 1.1 msaitoh if (status)
1595 1.1 msaitoh return status;
1596 1.1 msaitoh }
1597 1.1 msaitoh
1598 1.1 msaitoh /* Setup SFP module if there is one present. */
1599 1.1 msaitoh if (hw->phy.sfp_setup_needed) {
1600 1.1 msaitoh status = hw->mac.ops.setup_sfp(hw);
1601 1.1 msaitoh hw->phy.sfp_setup_needed = FALSE;
1602 1.1 msaitoh }
1603 1.1 msaitoh
1604 1.1 msaitoh if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1605 1.1 msaitoh return status;
1606 1.1 msaitoh
1607 1.1 msaitoh /* Reset PHY */
1608 1.1 msaitoh if (!hw->phy.reset_disable && hw->phy.ops.reset)
1609 1.1 msaitoh hw->phy.ops.reset(hw);
1610 1.1 msaitoh
1611 1.1 msaitoh mac_reset_top:
1612 1.1 msaitoh /* Issue global reset to the MAC. Needs to be SW reset if link is up.
1613 1.1 msaitoh * If link reset is used when link is up, it might reset the PHY when
1614 1.1 msaitoh * mng is using it. If link is down or the flag to force full link
1615 1.1 msaitoh * reset is set, then perform link reset.
1616 1.1 msaitoh */
1617 1.1 msaitoh ctrl = IXGBE_CTRL_LNK_RST;
1618 1.1 msaitoh if (!hw->force_full_reset) {
1619 1.1 msaitoh hw->mac.ops.check_link(hw, &link_speed, &link_up, FALSE);
1620 1.1 msaitoh if (link_up)
1621 1.1 msaitoh ctrl = IXGBE_CTRL_RST;
1622 1.1 msaitoh }
1623 1.1 msaitoh
1624 1.1 msaitoh ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
1625 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
1626 1.1 msaitoh IXGBE_WRITE_FLUSH(hw);
1627 1.1 msaitoh
1628 1.1 msaitoh /* Poll for reset bit to self-clear meaning reset is complete */
1629 1.1 msaitoh for (i = 0; i < 10; i++) {
1630 1.1 msaitoh usec_delay(1);
1631 1.1 msaitoh ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
1632 1.1 msaitoh if (!(ctrl & IXGBE_CTRL_RST_MASK))
1633 1.1 msaitoh break;
1634 1.1 msaitoh }
1635 1.1 msaitoh
1636 1.1 msaitoh if (ctrl & IXGBE_CTRL_RST_MASK) {
1637 1.1 msaitoh status = IXGBE_ERR_RESET_FAILED;
1638 1.1 msaitoh DEBUGOUT("Reset polling failed to complete.\n");
1639 1.1 msaitoh }
1640 1.1 msaitoh
1641 1.1 msaitoh msec_delay(50);
1642 1.1 msaitoh
1643 1.1 msaitoh /* Double resets are required for recovery from certain error
1644 1.1 msaitoh * conditions. Between resets, it is necessary to stall to
1645 1.1 msaitoh * allow time for any pending HW events to complete.
1646 1.1 msaitoh */
1647 1.1 msaitoh if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
1648 1.1 msaitoh hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
1649 1.1 msaitoh goto mac_reset_top;
1650 1.1 msaitoh }
1651 1.1 msaitoh
1652 1.1 msaitoh /* Store the permanent mac address */
1653 1.1 msaitoh hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
1654 1.1 msaitoh
1655 1.1 msaitoh /* Store MAC address from RAR0, clear receive address registers, and
1656 1.1 msaitoh * clear the multicast table. Also reset num_rar_entries to 128,
1657 1.1 msaitoh * since we modify this value when programming the SAN MAC address.
1658 1.1 msaitoh */
1659 1.1 msaitoh hw->mac.num_rar_entries = 128;
1660 1.1 msaitoh hw->mac.ops.init_rx_addrs(hw);
1661 1.1 msaitoh
1662 1.1 msaitoh if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
1663 1.1 msaitoh /* Config MDIO clock speed. */
1664 1.1 msaitoh hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
1665 1.1 msaitoh hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
1666 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
1667 1.1 msaitoh }
1668 1.1 msaitoh
1669 1.1 msaitoh if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
1670 1.1 msaitoh ixgbe_setup_mux_ctl(hw);
1671 1.1 msaitoh
1672 1.1 msaitoh return status;
1673 1.1 msaitoh }
1674 1.1 msaitoh
1675 1.1 msaitoh /**
1676 1.1 msaitoh * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
1677 1.1 msaitoh * @hw: pointer to hardware structure
1678 1.1 msaitoh */
1679 1.1 msaitoh s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
1680 1.1 msaitoh {
1681 1.1 msaitoh u32 status;
1682 1.1 msaitoh u16 reg;
1683 1.1 msaitoh
1684 1.1 msaitoh status = hw->phy.ops.read_reg(hw,
1685 1.1 msaitoh IXGBE_MDIO_TX_VENDOR_ALARMS_3,
1686 1.1 msaitoh IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1687 1.1 msaitoh ®);
1688 1.1 msaitoh
1689 1.1 msaitoh if (status != IXGBE_SUCCESS)
1690 1.1 msaitoh return status;
1691 1.1 msaitoh
1692 1.1 msaitoh /* If PHY FW reset completed bit is set then this is the first
1693 1.1 msaitoh * SW instance after a power on so the PHY FW must be un-stalled.
1694 1.1 msaitoh */
1695 1.1 msaitoh if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
1696 1.1 msaitoh status = hw->phy.ops.read_reg(hw,
1697 1.1 msaitoh IXGBE_MDIO_GLOBAL_RES_PR_10,
1698 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1699 1.1 msaitoh ®);
1700 1.1 msaitoh
1701 1.1 msaitoh if (status != IXGBE_SUCCESS)
1702 1.1 msaitoh return status;
1703 1.1 msaitoh
1704 1.1 msaitoh reg &= ~IXGBE_MDIO_POWER_UP_STALL;
1705 1.1 msaitoh
1706 1.1 msaitoh status = hw->phy.ops.write_reg(hw,
1707 1.1 msaitoh IXGBE_MDIO_GLOBAL_RES_PR_10,
1708 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1709 1.1 msaitoh reg);
1710 1.1 msaitoh
1711 1.1 msaitoh if (status != IXGBE_SUCCESS)
1712 1.1 msaitoh return status;
1713 1.1 msaitoh }
1714 1.1 msaitoh
1715 1.1 msaitoh return status;
1716 1.1 msaitoh }
1717 1.1 msaitoh
1718 1.1 msaitoh /**
1719 1.1 msaitoh * ixgbe_setup_kr_x550em - Configure the KR PHY.
1720 1.1 msaitoh * @hw: pointer to hardware structure
1721 1.1 msaitoh *
1722 1.1 msaitoh * Configures the integrated KR PHY.
1723 1.1 msaitoh **/
1724 1.1 msaitoh s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
1725 1.1 msaitoh {
1726 1.1 msaitoh return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
1727 1.1 msaitoh }
1728 1.1 msaitoh
1729 1.1 msaitoh /**
1730 1.1 msaitoh * ixgbe_setup_kx4_x550em - Configure the KX4 PHY.
1731 1.1 msaitoh * @hw: pointer to hardware structure
1732 1.1 msaitoh *
1733 1.1 msaitoh * Configures the integrated KX4 PHY.
1734 1.1 msaitoh **/
1735 1.1 msaitoh s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
1736 1.1 msaitoh {
1737 1.1 msaitoh s32 status;
1738 1.1 msaitoh u32 reg_val;
1739 1.1 msaitoh
1740 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
1741 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KX4_PCS, ®_val);
1742 1.1 msaitoh if (status)
1743 1.1 msaitoh return status;
1744 1.1 msaitoh
1745 1.1 msaitoh reg_val &= ~(IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4 |
1746 1.1 msaitoh IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX);
1747 1.1 msaitoh
1748 1.1 msaitoh reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE;
1749 1.1 msaitoh
1750 1.1 msaitoh /* Advertise 10G support. */
1751 1.1 msaitoh if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1752 1.1 msaitoh reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4;
1753 1.1 msaitoh
1754 1.1 msaitoh /* Advertise 1G support. */
1755 1.1 msaitoh if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1756 1.1 msaitoh reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX;
1757 1.1 msaitoh
1758 1.1 msaitoh /* Restart auto-negotiation. */
1759 1.1 msaitoh reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART;
1760 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
1761 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KX4_PCS, reg_val);
1762 1.1 msaitoh
1763 1.1 msaitoh return status;
1764 1.1 msaitoh }
1765 1.1 msaitoh
1766 1.1 msaitoh /**
1767 1.1 msaitoh * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
1768 1.1 msaitoh * @hw: pointer to hardware structure
1769 1.1 msaitoh *
1770 1.1 msaitoh * Configure the external PHY and the integrated KR PHY for SFP support.
1771 1.1 msaitoh **/
1772 1.1 msaitoh s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
1773 1.1 msaitoh ixgbe_link_speed speed,
1774 1.1 msaitoh bool autoneg_wait_to_complete)
1775 1.1 msaitoh {
1776 1.1 msaitoh s32 ret_val;
1777 1.1 msaitoh u16 reg_slice, reg_val;
1778 1.1 msaitoh bool setup_linear = FALSE;
1779 1.1 msaitoh UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
1780 1.1 msaitoh
1781 1.1 msaitoh /* Check if SFP module is supported and linear */
1782 1.1 msaitoh ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
1783 1.1 msaitoh
1784 1.1 msaitoh /* If no SFP module present, then return success. Return success since
1785 1.1 msaitoh * there is no reason to configure CS4227 and SFP not present error is
1786 1.1 msaitoh * not excepted in the setup MAC link flow.
1787 1.1 msaitoh */
1788 1.1 msaitoh if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
1789 1.1 msaitoh return IXGBE_SUCCESS;
1790 1.1 msaitoh
1791 1.1 msaitoh if (ret_val != IXGBE_SUCCESS)
1792 1.1 msaitoh return ret_val;
1793 1.1 msaitoh
1794 1.1 msaitoh /* Configure CS4227 for LINE connection rate then type. */
1795 1.1 msaitoh reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB + (hw->bus.lan_id << 12);
1796 1.1 msaitoh reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
1797 1.1 msaitoh ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1798 1.1 msaitoh reg_val);
1799 1.1 msaitoh
1800 1.1 msaitoh reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
1801 1.1 msaitoh if (setup_linear)
1802 1.1 msaitoh reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1803 1.1 msaitoh else
1804 1.1 msaitoh reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1805 1.1 msaitoh ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1806 1.1 msaitoh reg_val);
1807 1.1 msaitoh
1808 1.1 msaitoh /* Configure CS4227 for HOST connection rate then type. */
1809 1.1 msaitoh reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB + (hw->bus.lan_id << 12);
1810 1.1 msaitoh reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
1811 1.1 msaitoh ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1812 1.1 msaitoh reg_val);
1813 1.1 msaitoh
1814 1.1 msaitoh reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (hw->bus.lan_id << 12);
1815 1.1 msaitoh if (setup_linear)
1816 1.1 msaitoh reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1817 1.1 msaitoh else
1818 1.1 msaitoh reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1819 1.1 msaitoh ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1820 1.1 msaitoh reg_val);
1821 1.1 msaitoh
1822 1.1 msaitoh /* If internal link mode is XFI, then setup XFI internal link. */
1823 1.1 msaitoh if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE))
1824 1.1 msaitoh ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
1825 1.1 msaitoh
1826 1.1 msaitoh return ret_val;
1827 1.1 msaitoh }
1828 1.1 msaitoh
1829 1.1 msaitoh /**
1830 1.1 msaitoh * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
1831 1.1 msaitoh * @hw: pointer to hardware structure
1832 1.1 msaitoh * @speed: the link speed to force
1833 1.1 msaitoh *
1834 1.1 msaitoh * Configures the integrated KR PHY to use iXFI mode. Used to connect an
1835 1.1 msaitoh * internal and external PHY at a specific speed, without autonegotiation.
1836 1.1 msaitoh **/
1837 1.1 msaitoh static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
1838 1.1 msaitoh {
1839 1.1 msaitoh s32 status;
1840 1.1 msaitoh u32 reg_val;
1841 1.1 msaitoh
1842 1.1 msaitoh /* Disable AN and force speed to 10G Serial. */
1843 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
1844 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1845 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1846 1.1 msaitoh if (status != IXGBE_SUCCESS)
1847 1.1 msaitoh return status;
1848 1.1 msaitoh
1849 1.1 msaitoh reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1850 1.1 msaitoh reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1851 1.1 msaitoh
1852 1.1 msaitoh /* Select forced link speed for internal PHY. */
1853 1.1 msaitoh switch (*speed) {
1854 1.1 msaitoh case IXGBE_LINK_SPEED_10GB_FULL:
1855 1.1 msaitoh reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
1856 1.1 msaitoh break;
1857 1.1 msaitoh case IXGBE_LINK_SPEED_1GB_FULL:
1858 1.1 msaitoh reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1859 1.1 msaitoh break;
1860 1.1 msaitoh default:
1861 1.1 msaitoh /* Other link speeds are not supported by internal KR PHY. */
1862 1.1 msaitoh return IXGBE_ERR_LINK_SETUP;
1863 1.1 msaitoh }
1864 1.1 msaitoh
1865 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
1866 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1867 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1868 1.1 msaitoh if (status != IXGBE_SUCCESS)
1869 1.1 msaitoh return status;
1870 1.1 msaitoh
1871 1.1 msaitoh /* Disable training protocol FSM. */
1872 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
1873 1.1 msaitoh IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1874 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1875 1.1 msaitoh if (status != IXGBE_SUCCESS)
1876 1.1 msaitoh return status;
1877 1.1 msaitoh reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
1878 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
1879 1.1 msaitoh IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1880 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1881 1.1 msaitoh if (status != IXGBE_SUCCESS)
1882 1.1 msaitoh return status;
1883 1.1 msaitoh
1884 1.1 msaitoh /* Disable Flex from training TXFFE. */
1885 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
1886 1.1 msaitoh IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1887 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1888 1.1 msaitoh if (status != IXGBE_SUCCESS)
1889 1.1 msaitoh return status;
1890 1.1 msaitoh reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1891 1.1 msaitoh reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1892 1.1 msaitoh reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1893 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
1894 1.1 msaitoh IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1895 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1896 1.1 msaitoh if (status != IXGBE_SUCCESS)
1897 1.1 msaitoh return status;
1898 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
1899 1.1 msaitoh IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1900 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1901 1.1 msaitoh if (status != IXGBE_SUCCESS)
1902 1.1 msaitoh return status;
1903 1.1 msaitoh reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1904 1.1 msaitoh reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1905 1.1 msaitoh reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1906 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
1907 1.1 msaitoh IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1908 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1909 1.1 msaitoh if (status != IXGBE_SUCCESS)
1910 1.1 msaitoh return status;
1911 1.1 msaitoh
1912 1.1 msaitoh /* Enable override for coefficients. */
1913 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
1914 1.1 msaitoh IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
1915 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1916 1.1 msaitoh if (status != IXGBE_SUCCESS)
1917 1.1 msaitoh return status;
1918 1.1 msaitoh reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
1919 1.1 msaitoh reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
1920 1.1 msaitoh reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
1921 1.1 msaitoh reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
1922 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
1923 1.1 msaitoh IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
1924 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1925 1.1 msaitoh if (status != IXGBE_SUCCESS)
1926 1.1 msaitoh return status;
1927 1.1 msaitoh
1928 1.1 msaitoh /* Toggle port SW reset by AN reset. */
1929 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
1930 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1931 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1932 1.1 msaitoh if (status != IXGBE_SUCCESS)
1933 1.1 msaitoh return status;
1934 1.1 msaitoh reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1935 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
1936 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1937 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1938 1.1 msaitoh
1939 1.1 msaitoh return status;
1940 1.1 msaitoh }
1941 1.1 msaitoh
1942 1.1 msaitoh /**
1943 1.1 msaitoh * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
1944 1.1 msaitoh * @hw: address of hardware structure
1945 1.1 msaitoh * @link_up: address of boolean to indicate link status
1946 1.1 msaitoh *
1947 1.1 msaitoh * Returns error code if unable to get link status.
1948 1.1 msaitoh */
1949 1.1 msaitoh static s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
1950 1.1 msaitoh {
1951 1.1 msaitoh u32 ret;
1952 1.1 msaitoh u16 autoneg_status;
1953 1.1 msaitoh
1954 1.1 msaitoh *link_up = FALSE;
1955 1.1 msaitoh
1956 1.1 msaitoh /* read this twice back to back to indicate current status */
1957 1.1 msaitoh ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1958 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1959 1.1 msaitoh &autoneg_status);
1960 1.1 msaitoh if (ret != IXGBE_SUCCESS)
1961 1.1 msaitoh return ret;
1962 1.1 msaitoh
1963 1.1 msaitoh ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1964 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1965 1.1 msaitoh &autoneg_status);
1966 1.1 msaitoh if (ret != IXGBE_SUCCESS)
1967 1.1 msaitoh return ret;
1968 1.1 msaitoh
1969 1.1 msaitoh *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
1970 1.1 msaitoh
1971 1.1 msaitoh return IXGBE_SUCCESS;
1972 1.1 msaitoh }
1973 1.1 msaitoh
1974 1.1 msaitoh /**
1975 1.1 msaitoh * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
1976 1.1 msaitoh * @hw: point to hardware structure
1977 1.1 msaitoh *
1978 1.1 msaitoh * Configures the link between the integrated KR PHY and the external X557 PHY
1979 1.1 msaitoh * The driver will call this function when it gets a link status change
1980 1.1 msaitoh * interrupt from the X557 PHY. This function configures the link speed
1981 1.1 msaitoh * between the PHYs to match the link speed of the BASE-T link.
1982 1.1 msaitoh *
1983 1.1 msaitoh * A return of a non-zero value indicates an error, and the base driver should
1984 1.1 msaitoh * not report link up.
1985 1.1 msaitoh */
1986 1.1 msaitoh s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
1987 1.1 msaitoh {
1988 1.1 msaitoh ixgbe_link_speed force_speed;
1989 1.1 msaitoh bool link_up;
1990 1.1 msaitoh u32 status;
1991 1.1 msaitoh u16 speed;
1992 1.1 msaitoh
1993 1.1 msaitoh if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
1994 1.1 msaitoh return IXGBE_ERR_CONFIG;
1995 1.1 msaitoh
1996 1.1 msaitoh /* If link is not up, then there is no setup necessary so return */
1997 1.1 msaitoh status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
1998 1.1 msaitoh if (status != IXGBE_SUCCESS)
1999 1.1 msaitoh return status;
2000 1.1 msaitoh
2001 1.1 msaitoh if (!link_up)
2002 1.1 msaitoh return IXGBE_SUCCESS;
2003 1.1 msaitoh
2004 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
2005 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2006 1.1 msaitoh &speed);
2007 1.1 msaitoh if (status != IXGBE_SUCCESS)
2008 1.1 msaitoh return status;
2009 1.1 msaitoh
2010 1.1 msaitoh /* If link is not still up, then no setup is necessary so return */
2011 1.1 msaitoh status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2012 1.1 msaitoh if (status != IXGBE_SUCCESS)
2013 1.1 msaitoh return status;
2014 1.1 msaitoh if (!link_up)
2015 1.1 msaitoh return IXGBE_SUCCESS;
2016 1.1 msaitoh
2017 1.1 msaitoh /* clear everything but the speed and duplex bits */
2018 1.1 msaitoh speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
2019 1.1 msaitoh
2020 1.1 msaitoh switch (speed) {
2021 1.1 msaitoh case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
2022 1.1 msaitoh force_speed = IXGBE_LINK_SPEED_10GB_FULL;
2023 1.1 msaitoh break;
2024 1.1 msaitoh case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
2025 1.1 msaitoh force_speed = IXGBE_LINK_SPEED_1GB_FULL;
2026 1.1 msaitoh break;
2027 1.1 msaitoh default:
2028 1.1 msaitoh /* Internal PHY does not support anything else */
2029 1.1 msaitoh return IXGBE_ERR_INVALID_LINK_SETTINGS;
2030 1.1 msaitoh }
2031 1.1 msaitoh
2032 1.1 msaitoh return ixgbe_setup_ixfi_x550em(hw, &force_speed);
2033 1.1 msaitoh }
2034 1.1 msaitoh
2035 1.1 msaitoh /**
2036 1.1 msaitoh * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
2037 1.1 msaitoh * @hw: pointer to hardware structure
2038 1.1 msaitoh *
2039 1.1 msaitoh * Configures the integrated KR PHY to use internal loopback mode.
2040 1.1 msaitoh **/
2041 1.1 msaitoh s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
2042 1.1 msaitoh {
2043 1.1 msaitoh s32 status;
2044 1.1 msaitoh u32 reg_val;
2045 1.1 msaitoh
2046 1.1 msaitoh /* Disable AN and force speed to 10G Serial. */
2047 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
2048 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2049 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2050 1.1 msaitoh if (status != IXGBE_SUCCESS)
2051 1.1 msaitoh return status;
2052 1.1 msaitoh reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2053 1.1 msaitoh reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2054 1.1 msaitoh reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2055 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
2056 1.1 msaitoh IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2057 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2058 1.1 msaitoh if (status != IXGBE_SUCCESS)
2059 1.1 msaitoh return status;
2060 1.1 msaitoh
2061 1.1 msaitoh /* Set near-end loopback clocks. */
2062 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
2063 1.1 msaitoh IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2064 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2065 1.1 msaitoh if (status != IXGBE_SUCCESS)
2066 1.1 msaitoh return status;
2067 1.1 msaitoh reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
2068 1.1 msaitoh reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
2069 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
2070 1.1 msaitoh IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2071 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2072 1.1 msaitoh if (status != IXGBE_SUCCESS)
2073 1.1 msaitoh return status;
2074 1.1 msaitoh
2075 1.1 msaitoh /* Set loopback enable. */
2076 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
2077 1.1 msaitoh IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2078 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2079 1.1 msaitoh if (status != IXGBE_SUCCESS)
2080 1.1 msaitoh return status;
2081 1.1 msaitoh reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
2082 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
2083 1.1 msaitoh IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2084 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2085 1.1 msaitoh if (status != IXGBE_SUCCESS)
2086 1.1 msaitoh return status;
2087 1.1 msaitoh
2088 1.1 msaitoh /* Training bypass. */
2089 1.1 msaitoh status = ixgbe_read_iosf_sb_reg_x550(hw,
2090 1.1 msaitoh IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2091 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2092 1.1 msaitoh if (status != IXGBE_SUCCESS)
2093 1.1 msaitoh return status;
2094 1.1 msaitoh reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
2095 1.1 msaitoh status = ixgbe_write_iosf_sb_reg_x550(hw,
2096 1.1 msaitoh IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2097 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2098 1.1 msaitoh
2099 1.1 msaitoh return status;
2100 1.1 msaitoh }
2101 1.1 msaitoh
2102 1.1 msaitoh /**
2103 1.1 msaitoh * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2104 1.1 msaitoh * assuming that the semaphore is already obtained.
2105 1.1 msaitoh * @hw: pointer to hardware structure
2106 1.1 msaitoh * @offset: offset of word in the EEPROM to read
2107 1.1 msaitoh * @data: word read from the EEPROM
2108 1.1 msaitoh *
2109 1.1 msaitoh * Reads a 16 bit word from the EEPROM using the hostif.
2110 1.1 msaitoh **/
2111 1.1 msaitoh s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2112 1.1 msaitoh u16 *data)
2113 1.1 msaitoh {
2114 1.1 msaitoh s32 status;
2115 1.1 msaitoh struct ixgbe_hic_read_shadow_ram buffer;
2116 1.1 msaitoh
2117 1.1 msaitoh DEBUGFUNC("ixgbe_read_ee_hostif_data_X550");
2118 1.1 msaitoh buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2119 1.1 msaitoh buffer.hdr.req.buf_lenh = 0;
2120 1.1 msaitoh buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2121 1.1 msaitoh buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2122 1.1 msaitoh
2123 1.1 msaitoh /* convert offset from words to bytes */
2124 1.1 msaitoh buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2125 1.1 msaitoh /* one word */
2126 1.1 msaitoh buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2127 1.1 msaitoh
2128 1.1 msaitoh status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2129 1.1 msaitoh sizeof(buffer),
2130 1.1 msaitoh IXGBE_HI_COMMAND_TIMEOUT, FALSE);
2131 1.1 msaitoh
2132 1.1 msaitoh if (status)
2133 1.1 msaitoh return status;
2134 1.1 msaitoh
2135 1.1 msaitoh *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
2136 1.1 msaitoh FW_NVM_DATA_OFFSET);
2137 1.1 msaitoh
2138 1.1 msaitoh return 0;
2139 1.1 msaitoh }
2140 1.1 msaitoh
2141 1.1 msaitoh /**
2142 1.1 msaitoh * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2143 1.1 msaitoh * @hw: pointer to hardware structure
2144 1.1 msaitoh * @offset: offset of word in the EEPROM to read
2145 1.1 msaitoh * @data: word read from the EEPROM
2146 1.1 msaitoh *
2147 1.1 msaitoh * Reads a 16 bit word from the EEPROM using the hostif.
2148 1.1 msaitoh **/
2149 1.1 msaitoh s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2150 1.1 msaitoh u16 *data)
2151 1.1 msaitoh {
2152 1.1 msaitoh s32 status = IXGBE_SUCCESS;
2153 1.1 msaitoh
2154 1.1 msaitoh DEBUGFUNC("ixgbe_read_ee_hostif_X550");
2155 1.1 msaitoh
2156 1.1 msaitoh if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2157 1.1 msaitoh IXGBE_SUCCESS) {
2158 1.1 msaitoh status = ixgbe_read_ee_hostif_data_X550(hw, offset, data);
2159 1.1 msaitoh hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2160 1.1 msaitoh } else {
2161 1.1 msaitoh status = IXGBE_ERR_SWFW_SYNC;
2162 1.1 msaitoh }
2163 1.1 msaitoh
2164 1.1 msaitoh return status;
2165 1.1 msaitoh }
2166 1.1 msaitoh
2167 1.1 msaitoh /**
2168 1.1 msaitoh * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
2169 1.1 msaitoh * @hw: pointer to hardware structure
2170 1.1 msaitoh * @offset: offset of word in the EEPROM to read
2171 1.1 msaitoh * @words: number of words
2172 1.1 msaitoh * @data: word(s) read from the EEPROM
2173 1.1 msaitoh *
2174 1.1 msaitoh * Reads a 16 bit word(s) from the EEPROM using the hostif.
2175 1.1 msaitoh **/
2176 1.1 msaitoh s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2177 1.1 msaitoh u16 offset, u16 words, u16 *data)
2178 1.1 msaitoh {
2179 1.1 msaitoh struct ixgbe_hic_read_shadow_ram buffer;
2180 1.1 msaitoh u32 current_word = 0;
2181 1.1 msaitoh u16 words_to_read;
2182 1.1 msaitoh s32 status;
2183 1.1 msaitoh u32 i;
2184 1.1 msaitoh
2185 1.1 msaitoh DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
2186 1.1 msaitoh
2187 1.1 msaitoh /* Take semaphore for the entire operation. */
2188 1.1 msaitoh status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2189 1.1 msaitoh if (status) {
2190 1.1 msaitoh DEBUGOUT("EEPROM read buffer - semaphore failed\n");
2191 1.1 msaitoh return status;
2192 1.1 msaitoh }
2193 1.1 msaitoh while (words) {
2194 1.1 msaitoh if (words > FW_MAX_READ_BUFFER_SIZE / 2)
2195 1.1 msaitoh words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
2196 1.1 msaitoh else
2197 1.1 msaitoh words_to_read = words;
2198 1.1 msaitoh
2199 1.1 msaitoh buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2200 1.1 msaitoh buffer.hdr.req.buf_lenh = 0;
2201 1.1 msaitoh buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2202 1.1 msaitoh buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2203 1.1 msaitoh
2204 1.1 msaitoh /* convert offset from words to bytes */
2205 1.1 msaitoh buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
2206 1.1 msaitoh buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
2207 1.1 msaitoh
2208 1.1 msaitoh status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2209 1.1 msaitoh sizeof(buffer),
2210 1.1 msaitoh IXGBE_HI_COMMAND_TIMEOUT,
2211 1.1 msaitoh FALSE);
2212 1.1 msaitoh
2213 1.1 msaitoh if (status) {
2214 1.1 msaitoh DEBUGOUT("Host interface command failed\n");
2215 1.1 msaitoh goto out;
2216 1.1 msaitoh }
2217 1.1 msaitoh
2218 1.1 msaitoh for (i = 0; i < words_to_read; i++) {
2219 1.1 msaitoh u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
2220 1.1 msaitoh 2 * i;
2221 1.1 msaitoh u32 value = IXGBE_READ_REG(hw, reg);
2222 1.1 msaitoh
2223 1.1 msaitoh data[current_word] = (u16)(value & 0xffff);
2224 1.1 msaitoh current_word++;
2225 1.1 msaitoh i++;
2226 1.1 msaitoh if (i < words_to_read) {
2227 1.1 msaitoh value >>= 16;
2228 1.1 msaitoh data[current_word] = (u16)(value & 0xffff);
2229 1.1 msaitoh current_word++;
2230 1.1 msaitoh }
2231 1.1 msaitoh }
2232 1.1 msaitoh words -= words_to_read;
2233 1.1 msaitoh }
2234 1.1 msaitoh
2235 1.1 msaitoh out:
2236 1.1 msaitoh hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2237 1.1 msaitoh return status;
2238 1.1 msaitoh }
2239 1.1 msaitoh
2240 1.1 msaitoh /**
2241 1.1 msaitoh * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2242 1.1 msaitoh * @hw: pointer to hardware structure
2243 1.1 msaitoh * @offset: offset of word in the EEPROM to write
2244 1.1 msaitoh * @data: word write to the EEPROM
2245 1.1 msaitoh *
2246 1.1 msaitoh * Write a 16 bit word to the EEPROM using the hostif.
2247 1.1 msaitoh **/
2248 1.1 msaitoh s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2249 1.1 msaitoh u16 data)
2250 1.1 msaitoh {
2251 1.1 msaitoh s32 status;
2252 1.1 msaitoh struct ixgbe_hic_write_shadow_ram buffer;
2253 1.1 msaitoh
2254 1.1 msaitoh DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
2255 1.1 msaitoh
2256 1.1 msaitoh buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
2257 1.1 msaitoh buffer.hdr.req.buf_lenh = 0;
2258 1.1 msaitoh buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
2259 1.1 msaitoh buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2260 1.1 msaitoh
2261 1.1 msaitoh /* one word */
2262 1.1 msaitoh buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2263 1.1 msaitoh buffer.data = data;
2264 1.1 msaitoh buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2265 1.1 msaitoh
2266 1.1 msaitoh status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2267 1.1 msaitoh sizeof(buffer),
2268 1.1 msaitoh IXGBE_HI_COMMAND_TIMEOUT, FALSE);
2269 1.1 msaitoh
2270 1.1 msaitoh return status;
2271 1.1 msaitoh }
2272 1.1 msaitoh
2273 1.1 msaitoh /**
2274 1.1 msaitoh * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2275 1.1 msaitoh * @hw: pointer to hardware structure
2276 1.1 msaitoh * @offset: offset of word in the EEPROM to write
2277 1.1 msaitoh * @data: word write to the EEPROM
2278 1.1 msaitoh *
2279 1.1 msaitoh * Write a 16 bit word to the EEPROM using the hostif.
2280 1.1 msaitoh **/
2281 1.1 msaitoh s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2282 1.1 msaitoh u16 data)
2283 1.1 msaitoh {
2284 1.1 msaitoh s32 status = IXGBE_SUCCESS;
2285 1.1 msaitoh
2286 1.1 msaitoh DEBUGFUNC("ixgbe_write_ee_hostif_X550");
2287 1.1 msaitoh
2288 1.1 msaitoh if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2289 1.1 msaitoh IXGBE_SUCCESS) {
2290 1.1 msaitoh status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
2291 1.1 msaitoh hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2292 1.1 msaitoh } else {
2293 1.1 msaitoh DEBUGOUT("write ee hostif failed to get semaphore");
2294 1.1 msaitoh status = IXGBE_ERR_SWFW_SYNC;
2295 1.1 msaitoh }
2296 1.1 msaitoh
2297 1.1 msaitoh return status;
2298 1.1 msaitoh }
2299 1.1 msaitoh
2300 1.1 msaitoh /**
2301 1.1 msaitoh * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
2302 1.1 msaitoh * @hw: pointer to hardware structure
2303 1.1 msaitoh * @offset: offset of word in the EEPROM to write
2304 1.1 msaitoh * @words: number of words
2305 1.1 msaitoh * @data: word(s) write to the EEPROM
2306 1.1 msaitoh *
2307 1.1 msaitoh * Write a 16 bit word(s) to the EEPROM using the hostif.
2308 1.1 msaitoh **/
2309 1.1 msaitoh s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2310 1.1 msaitoh u16 offset, u16 words, u16 *data)
2311 1.1 msaitoh {
2312 1.1 msaitoh s32 status = IXGBE_SUCCESS;
2313 1.1 msaitoh u32 i = 0;
2314 1.1 msaitoh
2315 1.1 msaitoh DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
2316 1.1 msaitoh
2317 1.1 msaitoh /* Take semaphore for the entire operation. */
2318 1.1 msaitoh status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2319 1.1 msaitoh if (status != IXGBE_SUCCESS) {
2320 1.1 msaitoh DEBUGOUT("EEPROM write buffer - semaphore failed\n");
2321 1.1 msaitoh goto out;
2322 1.1 msaitoh }
2323 1.1 msaitoh
2324 1.1 msaitoh for (i = 0; i < words; i++) {
2325 1.1 msaitoh status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
2326 1.1 msaitoh data[i]);
2327 1.1 msaitoh
2328 1.1 msaitoh if (status != IXGBE_SUCCESS) {
2329 1.1 msaitoh DEBUGOUT("Eeprom buffered write failed\n");
2330 1.1 msaitoh break;
2331 1.1 msaitoh }
2332 1.1 msaitoh }
2333 1.1 msaitoh
2334 1.1 msaitoh hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2335 1.1 msaitoh out:
2336 1.1 msaitoh
2337 1.1 msaitoh return status;
2338 1.1 msaitoh }
2339 1.1 msaitoh
2340 1.1 msaitoh /**
2341 1.1 msaitoh * ixgbe_checksum_ptr_x550 - Checksum one pointer region
2342 1.1 msaitoh * @hw: pointer to hardware structure
2343 1.1 msaitoh * @ptr: pointer offset in eeprom
2344 1.1 msaitoh * @size: size of section pointed by ptr, if 0 first word will be used as size
2345 1.1 msaitoh * @csum: address of checksum to update
2346 1.1 msaitoh *
2347 1.1 msaitoh * Returns error status for any failure
2348 1.1 msaitoh */
2349 1.1 msaitoh static s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
2350 1.1 msaitoh u16 size, u16 *csum, u16 *buffer,
2351 1.1 msaitoh u32 buffer_size)
2352 1.1 msaitoh {
2353 1.1 msaitoh u16 buf[256];
2354 1.1 msaitoh s32 status;
2355 1.1 msaitoh u16 length, bufsz, i, start;
2356 1.1 msaitoh u16 *local_buffer;
2357 1.1 msaitoh
2358 1.1 msaitoh bufsz = sizeof(buf) / sizeof(buf[0]);
2359 1.1 msaitoh
2360 1.1 msaitoh /* Read a chunk at the pointer location */
2361 1.1 msaitoh if (!buffer) {
2362 1.1 msaitoh status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
2363 1.1 msaitoh if (status) {
2364 1.1 msaitoh DEBUGOUT("Failed to read EEPROM image\n");
2365 1.1 msaitoh return status;
2366 1.1 msaitoh }
2367 1.1 msaitoh local_buffer = buf;
2368 1.1 msaitoh } else {
2369 1.1 msaitoh if (buffer_size < ptr)
2370 1.1 msaitoh return IXGBE_ERR_PARAM;
2371 1.1 msaitoh local_buffer = &buffer[ptr];
2372 1.1 msaitoh }
2373 1.1 msaitoh
2374 1.1 msaitoh if (size) {
2375 1.1 msaitoh start = 0;
2376 1.1 msaitoh length = size;
2377 1.1 msaitoh } else {
2378 1.1 msaitoh start = 1;
2379 1.1 msaitoh length = local_buffer[0];
2380 1.1 msaitoh
2381 1.1 msaitoh /* Skip pointer section if length is invalid. */
2382 1.1 msaitoh if (length == 0xFFFF || length == 0 ||
2383 1.1 msaitoh (ptr + length) >= hw->eeprom.word_size)
2384 1.1 msaitoh return IXGBE_SUCCESS;
2385 1.1 msaitoh }
2386 1.1 msaitoh
2387 1.1 msaitoh if (buffer && ((u32)start + (u32)length > buffer_size))
2388 1.1 msaitoh return IXGBE_ERR_PARAM;
2389 1.1 msaitoh
2390 1.1 msaitoh for (i = start; length; i++, length--) {
2391 1.1 msaitoh if (i == bufsz && !buffer) {
2392 1.1 msaitoh ptr += bufsz;
2393 1.1 msaitoh i = 0;
2394 1.1 msaitoh if (length < bufsz)
2395 1.1 msaitoh bufsz = length;
2396 1.1 msaitoh
2397 1.1 msaitoh /* Read a chunk at the pointer location */
2398 1.1 msaitoh status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
2399 1.1 msaitoh bufsz, buf);
2400 1.1 msaitoh if (status) {
2401 1.1 msaitoh DEBUGOUT("Failed to read EEPROM image\n");
2402 1.1 msaitoh return status;
2403 1.1 msaitoh }
2404 1.1 msaitoh }
2405 1.1 msaitoh *csum += local_buffer[i];
2406 1.1 msaitoh }
2407 1.1 msaitoh return IXGBE_SUCCESS;
2408 1.1 msaitoh }
2409 1.1 msaitoh
2410 1.1 msaitoh /**
2411 1.1 msaitoh * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
2412 1.1 msaitoh * @hw: pointer to hardware structure
2413 1.1 msaitoh * @buffer: pointer to buffer containing calculated checksum
2414 1.1 msaitoh * @buffer_size: size of buffer
2415 1.1 msaitoh *
2416 1.1 msaitoh * Returns a negative error code on error, or the 16-bit checksum
2417 1.1 msaitoh **/
2418 1.1 msaitoh s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
2419 1.1 msaitoh {
2420 1.1 msaitoh u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
2421 1.1 msaitoh u16 *local_buffer;
2422 1.1 msaitoh s32 status;
2423 1.1 msaitoh u16 checksum = 0;
2424 1.1 msaitoh u16 pointer, i, size;
2425 1.1 msaitoh
2426 1.1 msaitoh DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
2427 1.1 msaitoh
2428 1.1 msaitoh hw->eeprom.ops.init_params(hw);
2429 1.1 msaitoh
2430 1.1 msaitoh if (!buffer) {
2431 1.1 msaitoh /* Read pointer area */
2432 1.1 msaitoh status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
2433 1.1 msaitoh IXGBE_EEPROM_LAST_WORD + 1,
2434 1.1 msaitoh eeprom_ptrs);
2435 1.1 msaitoh if (status) {
2436 1.1 msaitoh DEBUGOUT("Failed to read EEPROM image\n");
2437 1.1 msaitoh return status;
2438 1.1 msaitoh }
2439 1.1 msaitoh local_buffer = eeprom_ptrs;
2440 1.1 msaitoh } else {
2441 1.1 msaitoh if (buffer_size < IXGBE_EEPROM_LAST_WORD)
2442 1.1 msaitoh return IXGBE_ERR_PARAM;
2443 1.1 msaitoh local_buffer = buffer;
2444 1.1 msaitoh }
2445 1.1 msaitoh
2446 1.1 msaitoh /*
2447 1.1 msaitoh * For X550 hardware include 0x0-0x41 in the checksum, skip the
2448 1.1 msaitoh * checksum word itself
2449 1.1 msaitoh */
2450 1.1 msaitoh for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
2451 1.1 msaitoh if (i != IXGBE_EEPROM_CHECKSUM)
2452 1.1 msaitoh checksum += local_buffer[i];
2453 1.1 msaitoh
2454 1.1 msaitoh /*
2455 1.1 msaitoh * Include all data from pointers 0x3, 0x6-0xE. This excludes the
2456 1.1 msaitoh * FW, PHY module, and PCIe Expansion/Option ROM pointers.
2457 1.1 msaitoh */
2458 1.1 msaitoh for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
2459 1.1 msaitoh if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
2460 1.1 msaitoh continue;
2461 1.1 msaitoh
2462 1.1 msaitoh pointer = local_buffer[i];
2463 1.1 msaitoh
2464 1.1 msaitoh /* Skip pointer section if the pointer is invalid. */
2465 1.1 msaitoh if (pointer == 0xFFFF || pointer == 0 ||
2466 1.1 msaitoh pointer >= hw->eeprom.word_size)
2467 1.1 msaitoh continue;
2468 1.1 msaitoh
2469 1.1 msaitoh switch (i) {
2470 1.1 msaitoh case IXGBE_PCIE_GENERAL_PTR:
2471 1.1 msaitoh size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
2472 1.1 msaitoh break;
2473 1.1 msaitoh case IXGBE_PCIE_CONFIG0_PTR:
2474 1.1 msaitoh case IXGBE_PCIE_CONFIG1_PTR:
2475 1.1 msaitoh size = IXGBE_PCIE_CONFIG_SIZE;
2476 1.1 msaitoh break;
2477 1.1 msaitoh default:
2478 1.1 msaitoh size = 0;
2479 1.1 msaitoh break;
2480 1.1 msaitoh }
2481 1.1 msaitoh
2482 1.1 msaitoh status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
2483 1.1 msaitoh buffer, buffer_size);
2484 1.1 msaitoh if (status)
2485 1.1 msaitoh return status;
2486 1.1 msaitoh }
2487 1.1 msaitoh
2488 1.1 msaitoh checksum = (u16)IXGBE_EEPROM_SUM - checksum;
2489 1.1 msaitoh
2490 1.1 msaitoh return (s32)checksum;
2491 1.1 msaitoh }
2492 1.1 msaitoh
2493 1.1 msaitoh /**
2494 1.1 msaitoh * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
2495 1.1 msaitoh * @hw: pointer to hardware structure
2496 1.1 msaitoh *
2497 1.1 msaitoh * Returns a negative error code on error, or the 16-bit checksum
2498 1.1 msaitoh **/
2499 1.1 msaitoh s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
2500 1.1 msaitoh {
2501 1.1 msaitoh return ixgbe_calc_checksum_X550(hw, NULL, 0);
2502 1.1 msaitoh }
2503 1.1 msaitoh
2504 1.1 msaitoh /**
2505 1.1 msaitoh * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
2506 1.1 msaitoh * @hw: pointer to hardware structure
2507 1.1 msaitoh * @checksum_val: calculated checksum
2508 1.1 msaitoh *
2509 1.1 msaitoh * Performs checksum calculation and validates the EEPROM checksum. If the
2510 1.1 msaitoh * caller does not need checksum_val, the value can be NULL.
2511 1.1 msaitoh **/
2512 1.1 msaitoh s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
2513 1.1 msaitoh {
2514 1.1 msaitoh s32 status;
2515 1.1 msaitoh u16 checksum;
2516 1.1 msaitoh u16 read_checksum = 0;
2517 1.1 msaitoh
2518 1.1 msaitoh DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
2519 1.1 msaitoh
2520 1.1 msaitoh /* Read the first word from the EEPROM. If this times out or fails, do
2521 1.1 msaitoh * not continue or we could be in for a very long wait while every
2522 1.1 msaitoh * EEPROM read fails
2523 1.1 msaitoh */
2524 1.1 msaitoh status = hw->eeprom.ops.read(hw, 0, &checksum);
2525 1.1 msaitoh if (status) {
2526 1.1 msaitoh DEBUGOUT("EEPROM read failed\n");
2527 1.1 msaitoh return status;
2528 1.1 msaitoh }
2529 1.1 msaitoh
2530 1.1 msaitoh status = hw->eeprom.ops.calc_checksum(hw);
2531 1.1 msaitoh if (status < 0)
2532 1.1 msaitoh return status;
2533 1.1 msaitoh
2534 1.1 msaitoh checksum = (u16)(status & 0xffff);
2535 1.1 msaitoh
2536 1.1 msaitoh status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2537 1.1 msaitoh &read_checksum);
2538 1.1 msaitoh if (status)
2539 1.1 msaitoh return status;
2540 1.1 msaitoh
2541 1.1 msaitoh /* Verify read checksum from EEPROM is the same as
2542 1.1 msaitoh * calculated checksum
2543 1.1 msaitoh */
2544 1.1 msaitoh if (read_checksum != checksum) {
2545 1.1 msaitoh status = IXGBE_ERR_EEPROM_CHECKSUM;
2546 1.1 msaitoh ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
2547 1.1 msaitoh "Invalid EEPROM checksum");
2548 1.1 msaitoh }
2549 1.1 msaitoh
2550 1.1 msaitoh /* If the user cares, return the calculated checksum */
2551 1.1 msaitoh if (checksum_val)
2552 1.1 msaitoh *checksum_val = checksum;
2553 1.1 msaitoh
2554 1.1 msaitoh return status;
2555 1.1 msaitoh }
2556 1.1 msaitoh
2557 1.1 msaitoh /**
2558 1.1 msaitoh * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
2559 1.1 msaitoh * @hw: pointer to hardware structure
2560 1.1 msaitoh *
2561 1.1 msaitoh * After writing EEPROM to shadow RAM using EEWR register, software calculates
2562 1.1 msaitoh * checksum and updates the EEPROM and instructs the hardware to update
2563 1.1 msaitoh * the flash.
2564 1.1 msaitoh **/
2565 1.1 msaitoh s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
2566 1.1 msaitoh {
2567 1.1 msaitoh s32 status;
2568 1.1 msaitoh u16 checksum = 0;
2569 1.1 msaitoh
2570 1.1 msaitoh DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
2571 1.1 msaitoh
2572 1.1 msaitoh /* Read the first word from the EEPROM. If this times out or fails, do
2573 1.1 msaitoh * not continue or we could be in for a very long wait while every
2574 1.1 msaitoh * EEPROM read fails
2575 1.1 msaitoh */
2576 1.1 msaitoh status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
2577 1.1 msaitoh if (status) {
2578 1.1 msaitoh DEBUGOUT("EEPROM read failed\n");
2579 1.1 msaitoh return status;
2580 1.1 msaitoh }
2581 1.1 msaitoh
2582 1.1 msaitoh status = ixgbe_calc_eeprom_checksum_X550(hw);
2583 1.1 msaitoh if (status < 0)
2584 1.1 msaitoh return status;
2585 1.1 msaitoh
2586 1.1 msaitoh checksum = (u16)(status & 0xffff);
2587 1.1 msaitoh
2588 1.1 msaitoh status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2589 1.1 msaitoh checksum);
2590 1.1 msaitoh if (status)
2591 1.1 msaitoh return status;
2592 1.1 msaitoh
2593 1.1 msaitoh status = ixgbe_update_flash_X550(hw);
2594 1.1 msaitoh
2595 1.1 msaitoh return status;
2596 1.1 msaitoh }
2597 1.1 msaitoh
2598 1.1 msaitoh /**
2599 1.1 msaitoh * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
2600 1.1 msaitoh * @hw: pointer to hardware structure
2601 1.1 msaitoh *
2602 1.1 msaitoh * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
2603 1.1 msaitoh **/
2604 1.1 msaitoh s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
2605 1.1 msaitoh {
2606 1.1 msaitoh s32 status = IXGBE_SUCCESS;
2607 1.1 msaitoh union ixgbe_hic_hdr2 buffer;
2608 1.1 msaitoh
2609 1.1 msaitoh DEBUGFUNC("ixgbe_update_flash_X550");
2610 1.1 msaitoh
2611 1.1 msaitoh buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
2612 1.1 msaitoh buffer.req.buf_lenh = 0;
2613 1.1 msaitoh buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
2614 1.1 msaitoh buffer.req.checksum = FW_DEFAULT_CHECKSUM;
2615 1.1 msaitoh
2616 1.1 msaitoh status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2617 1.1 msaitoh sizeof(buffer),
2618 1.1 msaitoh IXGBE_HI_COMMAND_TIMEOUT, FALSE);
2619 1.1 msaitoh
2620 1.1 msaitoh return status;
2621 1.1 msaitoh }
2622 1.1 msaitoh
2623 1.1 msaitoh /**
2624 1.1 msaitoh * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
2625 1.1 msaitoh * @hw: pointer to hardware structure
2626 1.1 msaitoh *
2627 1.1 msaitoh * Determines physical layer capabilities of the current configuration.
2628 1.1 msaitoh **/
2629 1.1 msaitoh u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
2630 1.1 msaitoh {
2631 1.1 msaitoh u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
2632 1.1 msaitoh u16 ext_ability = 0;
2633 1.1 msaitoh
2634 1.1 msaitoh DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
2635 1.1 msaitoh
2636 1.1 msaitoh hw->phy.ops.identify(hw);
2637 1.1 msaitoh
2638 1.1 msaitoh switch (hw->phy.type) {
2639 1.1 msaitoh case ixgbe_phy_x550em_kr:
2640 1.1 msaitoh physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
2641 1.1 msaitoh IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2642 1.1 msaitoh break;
2643 1.1 msaitoh case ixgbe_phy_x550em_kx4:
2644 1.1 msaitoh physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
2645 1.1 msaitoh IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2646 1.1 msaitoh break;
2647 1.1 msaitoh case ixgbe_phy_x550em_ext_t:
2648 1.1 msaitoh hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
2649 1.1 msaitoh IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2650 1.1 msaitoh &ext_ability);
2651 1.1 msaitoh if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
2652 1.1 msaitoh physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
2653 1.1 msaitoh if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
2654 1.1 msaitoh physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
2655 1.1 msaitoh break;
2656 1.1 msaitoh default:
2657 1.1 msaitoh break;
2658 1.1 msaitoh }
2659 1.1 msaitoh
2660 1.1 msaitoh if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
2661 1.1 msaitoh physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
2662 1.1 msaitoh
2663 1.1 msaitoh return physical_layer;
2664 1.1 msaitoh }
2665 1.1 msaitoh
2666 1.1 msaitoh /**
2667 1.1 msaitoh * ixgbe_get_bus_info_x550em - Set PCI bus info
2668 1.1 msaitoh * @hw: pointer to hardware structure
2669 1.1 msaitoh *
2670 1.1 msaitoh * Sets bus link width and speed to unknown because X550em is
2671 1.1 msaitoh * not a PCI device.
2672 1.1 msaitoh **/
2673 1.1 msaitoh s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
2674 1.1 msaitoh {
2675 1.1 msaitoh
2676 1.1 msaitoh DEBUGFUNC("ixgbe_get_bus_info_x550em");
2677 1.1 msaitoh
2678 1.1 msaitoh hw->bus.width = ixgbe_bus_width_unknown;
2679 1.1 msaitoh hw->bus.speed = ixgbe_bus_speed_unknown;
2680 1.1 msaitoh
2681 1.1 msaitoh hw->mac.ops.set_lan_id(hw);
2682 1.1 msaitoh
2683 1.1 msaitoh return IXGBE_SUCCESS;
2684 1.1 msaitoh }
2685 1.1 msaitoh
2686 1.1 msaitoh /**
2687 1.1 msaitoh * ixgbe_disable_rx_x550 - Disable RX unit
2688 1.1 msaitoh *
2689 1.1 msaitoh * Enables the Rx DMA unit for x550
2690 1.1 msaitoh **/
2691 1.1 msaitoh void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
2692 1.1 msaitoh {
2693 1.1 msaitoh u32 rxctrl, pfdtxgswc;
2694 1.1 msaitoh s32 status;
2695 1.1 msaitoh struct ixgbe_hic_disable_rxen fw_cmd;
2696 1.1 msaitoh
2697 1.1 msaitoh DEBUGFUNC("ixgbe_enable_rx_dma_x550");
2698 1.1 msaitoh
2699 1.1 msaitoh rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2700 1.1 msaitoh if (rxctrl & IXGBE_RXCTRL_RXEN) {
2701 1.1 msaitoh pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
2702 1.1 msaitoh if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
2703 1.1 msaitoh pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
2704 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
2705 1.1 msaitoh hw->mac.set_lben = TRUE;
2706 1.1 msaitoh } else {
2707 1.1 msaitoh hw->mac.set_lben = FALSE;
2708 1.1 msaitoh }
2709 1.1 msaitoh
2710 1.1 msaitoh fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
2711 1.1 msaitoh fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
2712 1.1 msaitoh fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
2713 1.1 msaitoh fw_cmd.port_number = (u8)hw->bus.lan_id;
2714 1.1 msaitoh
2715 1.1 msaitoh status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
2716 1.1 msaitoh sizeof(struct ixgbe_hic_disable_rxen),
2717 1.1 msaitoh IXGBE_HI_COMMAND_TIMEOUT, TRUE);
2718 1.1 msaitoh
2719 1.1 msaitoh /* If we fail - disable RX using register write */
2720 1.1 msaitoh if (status) {
2721 1.1 msaitoh rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2722 1.1 msaitoh if (rxctrl & IXGBE_RXCTRL_RXEN) {
2723 1.1 msaitoh rxctrl &= ~IXGBE_RXCTRL_RXEN;
2724 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
2725 1.1 msaitoh }
2726 1.1 msaitoh }
2727 1.1 msaitoh }
2728 1.1 msaitoh }
2729 1.1 msaitoh
2730 1.1 msaitoh /**
2731 1.1 msaitoh * ixgbe_enter_lplu_x550em - Transition to low power states
2732 1.1 msaitoh * @hw: pointer to hardware structure
2733 1.1 msaitoh *
2734 1.1 msaitoh * Configures Low Power Link Up on transition to low power states
2735 1.1 msaitoh * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
2736 1.1 msaitoh * X557 PHY immediately prior to entering LPLU.
2737 1.1 msaitoh **/
2738 1.1 msaitoh s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
2739 1.1 msaitoh {
2740 1.1 msaitoh u16 an_10g_cntl_reg, autoneg_reg, speed;
2741 1.1 msaitoh s32 status;
2742 1.1 msaitoh ixgbe_link_speed lcd_speed;
2743 1.1 msaitoh u32 save_autoneg;
2744 1.1 msaitoh bool link_up;
2745 1.1 msaitoh
2746 1.1 msaitoh /* If blocked by MNG FW, then don't restart AN */
2747 1.1 msaitoh if (ixgbe_check_reset_blocked(hw))
2748 1.1 msaitoh return IXGBE_SUCCESS;
2749 1.1 msaitoh
2750 1.1 msaitoh status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2751 1.1 msaitoh if (status != IXGBE_SUCCESS)
2752 1.1 msaitoh return status;
2753 1.1 msaitoh
2754 1.1 msaitoh status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
2755 1.1 msaitoh
2756 1.1 msaitoh if (status != IXGBE_SUCCESS)
2757 1.1 msaitoh return status;
2758 1.1 msaitoh
2759 1.1 msaitoh /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
2760 1.1 msaitoh * disabled, then force link down by entering low power mode.
2761 1.1 msaitoh */
2762 1.1 msaitoh if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
2763 1.1 msaitoh !(hw->wol_enabled || ixgbe_mng_present(hw)))
2764 1.1 msaitoh return ixgbe_set_copper_phy_power(hw, FALSE);
2765 1.1 msaitoh
2766 1.1 msaitoh /* Determine LCD */
2767 1.1 msaitoh status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
2768 1.1 msaitoh
2769 1.1 msaitoh if (status != IXGBE_SUCCESS)
2770 1.1 msaitoh return status;
2771 1.1 msaitoh
2772 1.1 msaitoh /* If no valid LCD link speed, then force link down and exit. */
2773 1.1 msaitoh if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
2774 1.1 msaitoh return ixgbe_set_copper_phy_power(hw, FALSE);
2775 1.1 msaitoh
2776 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
2777 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2778 1.1 msaitoh &speed);
2779 1.1 msaitoh
2780 1.1 msaitoh if (status != IXGBE_SUCCESS)
2781 1.1 msaitoh return status;
2782 1.1 msaitoh
2783 1.1 msaitoh /* If no link now, speed is invalid so take link down */
2784 1.1 msaitoh status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2785 1.1 msaitoh if (status != IXGBE_SUCCESS)
2786 1.1 msaitoh return ixgbe_set_copper_phy_power(hw, FALSE);
2787 1.1 msaitoh
2788 1.1 msaitoh /* clear everything but the speed bits */
2789 1.1 msaitoh speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
2790 1.1 msaitoh
2791 1.1 msaitoh /* If current speed is already LCD, then exit. */
2792 1.1 msaitoh if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
2793 1.1 msaitoh (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
2794 1.1 msaitoh ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
2795 1.1 msaitoh (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
2796 1.1 msaitoh return status;
2797 1.1 msaitoh
2798 1.1 msaitoh /* Clear AN completed indication */
2799 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
2800 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2801 1.1 msaitoh &autoneg_reg);
2802 1.1 msaitoh
2803 1.1 msaitoh if (status != IXGBE_SUCCESS)
2804 1.1 msaitoh return status;
2805 1.1 msaitoh
2806 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
2807 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2808 1.1 msaitoh &an_10g_cntl_reg);
2809 1.1 msaitoh
2810 1.1 msaitoh if (status != IXGBE_SUCCESS)
2811 1.1 msaitoh return status;
2812 1.1 msaitoh
2813 1.1 msaitoh status = hw->phy.ops.read_reg(hw,
2814 1.1 msaitoh IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
2815 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2816 1.1 msaitoh &autoneg_reg);
2817 1.1 msaitoh
2818 1.1 msaitoh if (status != IXGBE_SUCCESS)
2819 1.1 msaitoh return status;
2820 1.1 msaitoh
2821 1.1 msaitoh save_autoneg = hw->phy.autoneg_advertised;
2822 1.1 msaitoh
2823 1.1 msaitoh /* Setup link at least common link speed */
2824 1.1 msaitoh status = hw->mac.ops.setup_link(hw, lcd_speed, FALSE);
2825 1.1 msaitoh
2826 1.1 msaitoh /* restore autoneg from before setting lplu speed */
2827 1.1 msaitoh hw->phy.autoneg_advertised = save_autoneg;
2828 1.1 msaitoh
2829 1.1 msaitoh return status;
2830 1.1 msaitoh }
2831 1.1 msaitoh
2832 1.1 msaitoh /**
2833 1.1 msaitoh * ixgbe_get_lcd_x550em - Determine lowest common denominator
2834 1.1 msaitoh * @hw: pointer to hardware structure
2835 1.1 msaitoh * @lcd_speed: pointer to lowest common link speed
2836 1.1 msaitoh *
2837 1.1 msaitoh * Determine lowest common link speed with link partner.
2838 1.1 msaitoh **/
2839 1.1 msaitoh s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
2840 1.1 msaitoh {
2841 1.1 msaitoh u16 an_lp_status;
2842 1.1 msaitoh s32 status;
2843 1.1 msaitoh u16 word = hw->eeprom.ctrl_word_3;
2844 1.1 msaitoh
2845 1.1 msaitoh *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
2846 1.1 msaitoh
2847 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
2848 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2849 1.1 msaitoh &an_lp_status);
2850 1.1 msaitoh
2851 1.1 msaitoh if (status != IXGBE_SUCCESS)
2852 1.1 msaitoh return status;
2853 1.1 msaitoh
2854 1.1 msaitoh /* If link partner advertised 1G, return 1G */
2855 1.1 msaitoh if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
2856 1.1 msaitoh *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
2857 1.1 msaitoh return status;
2858 1.1 msaitoh }
2859 1.1 msaitoh
2860 1.1 msaitoh /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
2861 1.1 msaitoh if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
2862 1.1 msaitoh (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
2863 1.1 msaitoh return status;
2864 1.1 msaitoh
2865 1.1 msaitoh /* Link partner not capable of lower speeds, return 10G */
2866 1.1 msaitoh *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
2867 1.1 msaitoh return status;
2868 1.1 msaitoh }
2869 1.1 msaitoh
2870 1.1 msaitoh /**
2871 1.1 msaitoh * ixgbe_setup_fc_X550em - Set up flow control
2872 1.1 msaitoh * @hw: pointer to hardware structure
2873 1.1 msaitoh *
2874 1.1 msaitoh * Called at init time to set up flow control.
2875 1.1 msaitoh **/
2876 1.1 msaitoh s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
2877 1.1 msaitoh {
2878 1.1 msaitoh s32 ret_val = IXGBE_SUCCESS;
2879 1.1 msaitoh u32 pause, asm_dir, reg_val;
2880 1.1 msaitoh
2881 1.1 msaitoh DEBUGFUNC("ixgbe_setup_fc_X550em");
2882 1.1 msaitoh
2883 1.1 msaitoh /* Validate the requested mode */
2884 1.1 msaitoh if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
2885 1.1 msaitoh ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
2886 1.1 msaitoh "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
2887 1.1 msaitoh ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
2888 1.1 msaitoh goto out;
2889 1.1 msaitoh }
2890 1.1 msaitoh
2891 1.1 msaitoh /* 10gig parts do not have a word in the EEPROM to determine the
2892 1.1 msaitoh * default flow control setting, so we explicitly set it to full.
2893 1.1 msaitoh */
2894 1.1 msaitoh if (hw->fc.requested_mode == ixgbe_fc_default)
2895 1.1 msaitoh hw->fc.requested_mode = ixgbe_fc_full;
2896 1.1 msaitoh
2897 1.1 msaitoh /* Determine PAUSE and ASM_DIR bits. */
2898 1.1 msaitoh switch (hw->fc.requested_mode) {
2899 1.1 msaitoh case ixgbe_fc_none:
2900 1.1 msaitoh pause = 0;
2901 1.1 msaitoh asm_dir = 0;
2902 1.1 msaitoh break;
2903 1.1 msaitoh case ixgbe_fc_tx_pause:
2904 1.1 msaitoh pause = 0;
2905 1.1 msaitoh asm_dir = 1;
2906 1.1 msaitoh break;
2907 1.1 msaitoh case ixgbe_fc_rx_pause:
2908 1.1 msaitoh /* Rx Flow control is enabled and Tx Flow control is
2909 1.1 msaitoh * disabled by software override. Since there really
2910 1.1 msaitoh * isn't a way to advertise that we are capable of RX
2911 1.1 msaitoh * Pause ONLY, we will advertise that we support both
2912 1.1 msaitoh * symmetric and asymmetric Rx PAUSE, as such we fall
2913 1.1 msaitoh * through to the fc_full statement. Later, we will
2914 1.1 msaitoh * disable the adapter's ability to send PAUSE frames.
2915 1.1 msaitoh */
2916 1.1 msaitoh case ixgbe_fc_full:
2917 1.1 msaitoh pause = 1;
2918 1.1 msaitoh asm_dir = 1;
2919 1.1 msaitoh break;
2920 1.1 msaitoh default:
2921 1.1 msaitoh ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
2922 1.1 msaitoh "Flow control param set incorrectly\n");
2923 1.1 msaitoh ret_val = IXGBE_ERR_CONFIG;
2924 1.1 msaitoh goto out;
2925 1.1 msaitoh }
2926 1.1 msaitoh
2927 1.1 msaitoh if (hw->phy.media_type == ixgbe_media_type_backplane) {
2928 1.1 msaitoh ret_val = ixgbe_read_iosf_sb_reg_x550(hw,
2929 1.1 msaitoh IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
2930 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2931 1.1 msaitoh if (ret_val != IXGBE_SUCCESS)
2932 1.1 msaitoh goto out;
2933 1.1 msaitoh reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
2934 1.1 msaitoh IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
2935 1.1 msaitoh if (pause)
2936 1.1 msaitoh reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
2937 1.1 msaitoh if (asm_dir)
2938 1.1 msaitoh reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
2939 1.1 msaitoh ret_val = ixgbe_write_iosf_sb_reg_x550(hw,
2940 1.1 msaitoh IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
2941 1.1 msaitoh IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2942 1.1 msaitoh
2943 1.1 msaitoh /* Not all devices fully support AN. */
2944 1.1 msaitoh if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR)
2945 1.1 msaitoh hw->fc.disable_fc_autoneg = TRUE;
2946 1.1 msaitoh }
2947 1.1 msaitoh
2948 1.1 msaitoh out:
2949 1.1 msaitoh return ret_val;
2950 1.1 msaitoh }
2951 1.1 msaitoh
2952 1.1 msaitoh /**
2953 1.1 msaitoh * ixgbe_set_mux - Set mux for port 1 access with CS4227
2954 1.1 msaitoh * @hw: pointer to hardware structure
2955 1.1 msaitoh * @state: set mux if 1, clear if 0
2956 1.1 msaitoh */
2957 1.1 msaitoh static void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
2958 1.1 msaitoh {
2959 1.1 msaitoh u32 esdp;
2960 1.1 msaitoh
2961 1.1 msaitoh if (!hw->bus.lan_id)
2962 1.1 msaitoh return;
2963 1.1 msaitoh esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
2964 1.1 msaitoh if (state)
2965 1.1 msaitoh esdp |= IXGBE_ESDP_SDP1;
2966 1.1 msaitoh else
2967 1.1 msaitoh esdp &= ~IXGBE_ESDP_SDP1;
2968 1.1 msaitoh IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
2969 1.1 msaitoh IXGBE_WRITE_FLUSH(hw);
2970 1.1 msaitoh }
2971 1.1 msaitoh
2972 1.1 msaitoh /**
2973 1.1 msaitoh * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
2974 1.1 msaitoh * @hw: pointer to hardware structure
2975 1.1 msaitoh * @mask: Mask to specify which semaphore to acquire
2976 1.1 msaitoh *
2977 1.1 msaitoh * Acquires the SWFW semaphore and sets the I2C MUX
2978 1.1 msaitoh **/
2979 1.1 msaitoh s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
2980 1.1 msaitoh {
2981 1.1 msaitoh s32 status;
2982 1.1 msaitoh
2983 1.1 msaitoh DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
2984 1.1 msaitoh
2985 1.1 msaitoh status = ixgbe_acquire_swfw_sync_X540(hw, mask);
2986 1.1 msaitoh if (status)
2987 1.1 msaitoh return status;
2988 1.1 msaitoh
2989 1.1 msaitoh if (mask & IXGBE_GSSR_I2C_MASK)
2990 1.1 msaitoh ixgbe_set_mux(hw, 1);
2991 1.1 msaitoh
2992 1.1 msaitoh return IXGBE_SUCCESS;
2993 1.1 msaitoh }
2994 1.1 msaitoh
2995 1.1 msaitoh /**
2996 1.1 msaitoh * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
2997 1.1 msaitoh * @hw: pointer to hardware structure
2998 1.1 msaitoh * @mask: Mask to specify which semaphore to release
2999 1.1 msaitoh *
3000 1.1 msaitoh * Releases the SWFW semaphore and sets the I2C MUX
3001 1.1 msaitoh **/
3002 1.1 msaitoh void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
3003 1.1 msaitoh {
3004 1.1 msaitoh DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
3005 1.1 msaitoh
3006 1.1 msaitoh if (mask & IXGBE_GSSR_I2C_MASK)
3007 1.1 msaitoh ixgbe_set_mux(hw, 0);
3008 1.1 msaitoh
3009 1.1 msaitoh ixgbe_release_swfw_sync_X540(hw, mask);
3010 1.1 msaitoh }
3011 1.1 msaitoh
3012 1.1 msaitoh /**
3013 1.1 msaitoh * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
3014 1.1 msaitoh * @hw: pointer to hardware structure
3015 1.1 msaitoh *
3016 1.1 msaitoh * Handle external Base T PHY interrupt. If high temperature
3017 1.1 msaitoh * failure alarm then return error, else if link status change
3018 1.1 msaitoh * then setup internal/external PHY link
3019 1.1 msaitoh *
3020 1.1 msaitoh * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
3021 1.1 msaitoh * failure alarm, else return PHY access status.
3022 1.1 msaitoh */
3023 1.1 msaitoh s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
3024 1.1 msaitoh {
3025 1.1 msaitoh bool lsc;
3026 1.1 msaitoh u32 status;
3027 1.1 msaitoh
3028 1.1 msaitoh status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
3029 1.1 msaitoh
3030 1.1 msaitoh if (status != IXGBE_SUCCESS)
3031 1.1 msaitoh return status;
3032 1.1 msaitoh
3033 1.1 msaitoh if (lsc)
3034 1.1 msaitoh return ixgbe_setup_internal_phy(hw);
3035 1.1 msaitoh
3036 1.1 msaitoh return IXGBE_SUCCESS;
3037 1.1 msaitoh }
3038 1.1 msaitoh
3039 1.1 msaitoh /**
3040 1.1 msaitoh * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
3041 1.1 msaitoh * @hw: pointer to hardware structure
3042 1.1 msaitoh * @speed: new link speed
3043 1.1 msaitoh * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
3044 1.1 msaitoh *
3045 1.1 msaitoh * Setup internal/external PHY link speed based on link speed, then set
3046 1.1 msaitoh * external PHY auto advertised link speed.
3047 1.1 msaitoh *
3048 1.1 msaitoh * Returns error status for any failure
3049 1.1 msaitoh **/
3050 1.1 msaitoh s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
3051 1.1 msaitoh ixgbe_link_speed speed,
3052 1.1 msaitoh bool autoneg_wait_to_complete)
3053 1.1 msaitoh {
3054 1.1 msaitoh s32 status;
3055 1.1 msaitoh ixgbe_link_speed force_speed;
3056 1.1 msaitoh
3057 1.1 msaitoh DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
3058 1.1 msaitoh
3059 1.1 msaitoh /* Setup internal/external PHY link speed to iXFI (10G), unless
3060 1.1 msaitoh * only 1G is auto advertised then setup KX link.
3061 1.1 msaitoh */
3062 1.1 msaitoh if (speed & IXGBE_LINK_SPEED_10GB_FULL)
3063 1.1 msaitoh force_speed = IXGBE_LINK_SPEED_10GB_FULL;
3064 1.1 msaitoh else
3065 1.1 msaitoh force_speed = IXGBE_LINK_SPEED_1GB_FULL;
3066 1.1 msaitoh
3067 1.1 msaitoh /* If internal link mode is XFI, then setup XFI internal link. */
3068 1.1 msaitoh if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
3069 1.1 msaitoh status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
3070 1.1 msaitoh
3071 1.1 msaitoh if (status != IXGBE_SUCCESS)
3072 1.1 msaitoh return status;
3073 1.1 msaitoh }
3074 1.1 msaitoh
3075 1.1 msaitoh return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
3076 1.1 msaitoh }
3077 1.1 msaitoh
3078 1.1 msaitoh /**
3079 1.1 msaitoh * ixgbe_check_link_t_X550em - Determine link and speed status
3080 1.1 msaitoh * @hw: pointer to hardware structure
3081 1.1 msaitoh * @speed: pointer to link speed
3082 1.1 msaitoh * @link_up: TRUE when link is up
3083 1.1 msaitoh * @link_up_wait_to_complete: bool used to wait for link up or not
3084 1.1 msaitoh *
3085 1.1 msaitoh * Check that both the MAC and X557 external PHY have link.
3086 1.1 msaitoh **/
3087 1.1 msaitoh s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
3088 1.1 msaitoh bool *link_up, bool link_up_wait_to_complete)
3089 1.1 msaitoh {
3090 1.1 msaitoh u32 status;
3091 1.1 msaitoh u16 autoneg_status;
3092 1.1 msaitoh
3093 1.1 msaitoh if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
3094 1.1 msaitoh return IXGBE_ERR_CONFIG;
3095 1.1 msaitoh
3096 1.1 msaitoh status = ixgbe_check_mac_link_generic(hw, speed, link_up,
3097 1.1 msaitoh link_up_wait_to_complete);
3098 1.1 msaitoh
3099 1.1 msaitoh /* If check link fails or MAC link is not up, then return */
3100 1.1 msaitoh if (status != IXGBE_SUCCESS || !(*link_up))
3101 1.1 msaitoh return status;
3102 1.1 msaitoh
3103 1.1 msaitoh /* MAC link is up, so check external PHY link.
3104 1.1 msaitoh * Read this twice back to back to indicate current status.
3105 1.1 msaitoh */
3106 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3107 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3108 1.1 msaitoh &autoneg_status);
3109 1.1 msaitoh
3110 1.1 msaitoh if (status != IXGBE_SUCCESS)
3111 1.1 msaitoh return status;
3112 1.1 msaitoh
3113 1.1 msaitoh status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3114 1.1 msaitoh IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3115 1.1 msaitoh &autoneg_status);
3116 1.1 msaitoh
3117 1.1 msaitoh if (status != IXGBE_SUCCESS)
3118 1.1 msaitoh return status;
3119 1.1 msaitoh
3120 1.1 msaitoh /* If external PHY link is not up, then indicate link not up */
3121 1.1 msaitoh if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
3122 1.1 msaitoh *link_up = FALSE;
3123 1.1 msaitoh
3124 1.1 msaitoh return IXGBE_SUCCESS;
3125 1.1 msaitoh }
3126 1.1 msaitoh
3127 1.1 msaitoh /**
3128 1.1 msaitoh * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
3129 1.1 msaitoh * @hw: pointer to hardware structure
3130 1.1 msaitoh **/
3131 1.1 msaitoh s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
3132 1.1 msaitoh {
3133 1.1 msaitoh s32 status;
3134 1.1 msaitoh
3135 1.1 msaitoh status = ixgbe_reset_phy_generic(hw);
3136 1.1 msaitoh
3137 1.1 msaitoh if (status != IXGBE_SUCCESS)
3138 1.1 msaitoh return status;
3139 1.1 msaitoh
3140 1.1 msaitoh /* Configure Link Status Alarm and Temperature Threshold interrupts */
3141 1.1 msaitoh return ixgbe_enable_lasi_ext_t_x550em(hw);
3142 1.1 msaitoh }
3143 1.1 msaitoh
3144 1.1 msaitoh /**
3145 1.1 msaitoh * ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
3146 1.1 msaitoh * @hw: pointer to hardware structure
3147 1.1 msaitoh * @led_idx: led number to turn on
3148 1.1 msaitoh **/
3149 1.1 msaitoh s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
3150 1.1 msaitoh {
3151 1.1 msaitoh u16 phy_data;
3152 1.1 msaitoh
3153 1.1 msaitoh DEBUGFUNC("ixgbe_led_on_t_X550em");
3154 1.1 msaitoh
3155 1.1 msaitoh if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
3156 1.1 msaitoh return IXGBE_ERR_PARAM;
3157 1.1 msaitoh
3158 1.1 msaitoh /* To turn on the LED, set mode to ON. */
3159 1.1 msaitoh ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3160 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
3161 1.1 msaitoh phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
3162 1.1 msaitoh ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3163 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
3164 1.1 msaitoh
3165 1.1 msaitoh return IXGBE_SUCCESS;
3166 1.1 msaitoh }
3167 1.1 msaitoh
3168 1.1 msaitoh /**
3169 1.1 msaitoh * ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
3170 1.1 msaitoh * @hw: pointer to hardware structure
3171 1.1 msaitoh * @led_idx: led number to turn off
3172 1.1 msaitoh **/
3173 1.1 msaitoh s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
3174 1.1 msaitoh {
3175 1.1 msaitoh u16 phy_data;
3176 1.1 msaitoh
3177 1.1 msaitoh DEBUGFUNC("ixgbe_led_off_t_X550em");
3178 1.1 msaitoh
3179 1.1 msaitoh if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
3180 1.1 msaitoh return IXGBE_ERR_PARAM;
3181 1.1 msaitoh
3182 1.1 msaitoh /* To turn on the LED, set mode to ON. */
3183 1.1 msaitoh ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3184 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
3185 1.1 msaitoh phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
3186 1.1 msaitoh ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3187 1.1 msaitoh IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
3188 1.1 msaitoh
3189 1.1 msaitoh return IXGBE_SUCCESS;
3190 1.1 msaitoh }
3191 1.1 msaitoh
3192