1 /*******************************************************************************
3 Copyright (c) 2001-2015, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ***************************************************************************/
34 #include "ixgbe_x550.h"
35 #include "ixgbe_x540.h"
36 #include "ixgbe_type.h"
37 #include "ixgbe_api.h"
38 #include "ixgbe_common.h"
39 #include "ixgbe_phy.h"
41 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed);
42 static s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
43 static void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
46 * ixgbe_init_ops_X550 - Inits func ptrs and MAC type
47 * @hw: pointer to hardware structure
49 * Initialize the function pointers and assign the MAC type for X550.
50 * Does not touch the hardware.
52 s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
54 struct ixgbe_mac_info *mac = &hw->mac;
55 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
58 DEBUGFUNC("ixgbe_init_ops_X550");
60 ret_val = ixgbe_init_ops_X540(hw);
61 mac->ops.dmac_config = ixgbe_dmac_config_X550;
62 mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
63 mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
64 mac->ops.setup_eee = ixgbe_setup_eee_X550;
65 mac->ops.set_source_address_pruning =
66 ixgbe_set_source_address_pruning_X550;
67 mac->ops.set_ethertype_anti_spoofing =
68 ixgbe_set_ethertype_anti_spoofing_X550;
70 mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
71 eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
72 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
73 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
74 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
75 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
76 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
77 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
78 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
80 mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
81 mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
82 mac->ops.mdd_event = ixgbe_mdd_event_X550;
83 mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
84 mac->ops.disable_rx = ixgbe_disable_rx_x550;
85 switch (hw->device_id) {
86 case IXGBE_DEV_ID_X550EM_X_10G_T:
87 case IXGBE_DEV_ID_X550EM_A_10G_T:
88 hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
89 hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
98 * ixgbe_read_cs4227 - Read CS4227 register
99 * @hw: pointer to hardware structure
100 * @reg: register number to write
101 * @value: pointer to receive value read
103 * Returns status code
105 STATIC s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
107 return ixgbe_read_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
111 * ixgbe_write_cs4227 - Write CS4227 register
112 * @hw: pointer to hardware structure
113 * @reg: register number to write
114 * @value: value to write to register
116 * Returns status code
118 STATIC s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
120 return ixgbe_write_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
124 * ixgbe_read_pe - Read register from port expander
125 * @hw: pointer to hardware structure
126 * @reg: register number to read
127 * @value: pointer to receive read value
129 * Returns status code
131 STATIC s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
135 status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
136 if (status != IXGBE_SUCCESS)
137 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
138 "port expander access failed with %d\n", status);
143 * ixgbe_write_pe - Write register to port expander
144 * @hw: pointer to hardware structure
145 * @reg: register number to write
146 * @value: value to write
148 * Returns status code
150 STATIC s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
154 status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
155 if (status != IXGBE_SUCCESS)
156 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
157 "port expander access failed with %d\n", status);
162 * ixgbe_reset_cs4227 - Reset CS4227 using port expander
163 * @hw: pointer to hardware structure
165 * This function assumes that the caller has acquired the proper semaphore.
168 STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
175 /* Trigger hard reset. */
176 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
177 if (status != IXGBE_SUCCESS)
179 reg |= IXGBE_PE_BIT1;
180 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
181 if (status != IXGBE_SUCCESS)
184 status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, ®);
185 if (status != IXGBE_SUCCESS)
187 reg &= ~IXGBE_PE_BIT1;
188 status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
189 if (status != IXGBE_SUCCESS)
192 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
193 if (status != IXGBE_SUCCESS)
195 reg &= ~IXGBE_PE_BIT1;
196 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
197 if (status != IXGBE_SUCCESS)
200 usec_delay(IXGBE_CS4227_RESET_HOLD);
202 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
203 if (status != IXGBE_SUCCESS)
205 reg |= IXGBE_PE_BIT1;
206 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
207 if (status != IXGBE_SUCCESS)
210 /* Wait for the reset to complete. */
211 msec_delay(IXGBE_CS4227_RESET_DELAY);
212 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
213 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
215 if (status == IXGBE_SUCCESS &&
216 value == IXGBE_CS4227_EEPROM_LOAD_OK)
218 msec_delay(IXGBE_CS4227_CHECK_DELAY);
220 if (retry == IXGBE_CS4227_RETRIES) {
221 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
222 "CS4227 reset did not complete.");
223 return IXGBE_ERR_PHY;
226 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
227 if (status != IXGBE_SUCCESS ||
228 !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
229 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
230 "CS4227 EEPROM did not load successfully.");
231 return IXGBE_ERR_PHY;
234 return IXGBE_SUCCESS;
238 * ixgbe_check_cs4227 - Check CS4227 and reset as needed
239 * @hw: pointer to hardware structure
241 STATIC void ixgbe_check_cs4227(struct ixgbe_hw *hw)
243 s32 status = IXGBE_SUCCESS;
244 u32 swfw_mask = hw->phy.phy_semaphore_mask;
248 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
249 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
250 if (status != IXGBE_SUCCESS) {
251 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
252 "semaphore failed with %d", status);
253 msec_delay(IXGBE_CS4227_CHECK_DELAY);
257 /* Get status of reset flow. */
258 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
260 if (status == IXGBE_SUCCESS &&
261 value == IXGBE_CS4227_RESET_COMPLETE)
264 if (status != IXGBE_SUCCESS ||
265 value != IXGBE_CS4227_RESET_PENDING)
268 /* Reset is pending. Wait and check again. */
269 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
270 msec_delay(IXGBE_CS4227_CHECK_DELAY);
273 /* If still pending, assume other instance failed. */
274 if (retry == IXGBE_CS4227_RETRIES) {
275 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
276 if (status != IXGBE_SUCCESS) {
277 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
278 "semaphore failed with %d", status);
283 /* Reset the CS4227. */
284 status = ixgbe_reset_cs4227(hw);
285 if (status != IXGBE_SUCCESS) {
286 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
287 "CS4227 reset failed: %d", status);
291 /* Reset takes so long, temporarily release semaphore in case the
292 * other driver instance is waiting for the reset indication.
294 ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
295 IXGBE_CS4227_RESET_PENDING);
296 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
298 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
299 if (status != IXGBE_SUCCESS) {
300 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
301 "semaphore failed with %d", status);
305 /* Record completion for next time. */
306 status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
307 IXGBE_CS4227_RESET_COMPLETE);
310 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
311 msec_delay(hw->eeprom.semaphore_delay);
315 * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
316 * @hw: pointer to hardware structure
318 STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
320 u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
322 if (hw->bus.lan_id) {
323 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
324 esdp |= IXGBE_ESDP_SDP1_DIR;
326 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
327 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
328 IXGBE_WRITE_FLUSH(hw);
332 * ixgbe_identify_phy_x550em - Get PHY type based on device id
333 * @hw: pointer to hardware structure
337 STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
339 switch (hw->device_id) {
340 case IXGBE_DEV_ID_X550EM_A_SFP:
341 hw->phy.phy_semaphore_mask = IXGBE_GSSR_TOKEN_SM;
343 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
345 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
346 return ixgbe_identify_module_generic(hw);
347 case IXGBE_DEV_ID_X550EM_X_SFP:
348 /* set up for CS4227 usage */
349 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
350 ixgbe_setup_mux_ctl(hw);
351 ixgbe_check_cs4227(hw);
354 case IXGBE_DEV_ID_X550EM_A_SFP_N:
355 return ixgbe_identify_module_generic(hw);
357 case IXGBE_DEV_ID_X550EM_X_KX4:
358 hw->phy.type = ixgbe_phy_x550em_kx4;
360 case IXGBE_DEV_ID_X550EM_X_KR:
361 case IXGBE_DEV_ID_X550EM_A_KR:
362 case IXGBE_DEV_ID_X550EM_A_KR_L:
363 hw->phy.type = ixgbe_phy_x550em_kr;
365 case IXGBE_DEV_ID_X550EM_X_1G_T:
366 case IXGBE_DEV_ID_X550EM_X_10G_T:
367 case IXGBE_DEV_ID_X550EM_A_1G_T:
368 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
369 case IXGBE_DEV_ID_X550EM_A_10G_T:
370 return ixgbe_identify_phy_generic(hw);
374 return IXGBE_SUCCESS;
377 STATIC s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
378 u32 device_type, u16 *phy_data)
380 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
381 return IXGBE_NOT_IMPLEMENTED;
384 STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
385 u32 device_type, u16 phy_data)
387 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
388 return IXGBE_NOT_IMPLEMENTED;
392 * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
393 * @hw: pointer to hardware structure
395 * Initialize the function pointers and for MAC type X550EM.
396 * Does not touch the hardware.
398 s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
400 struct ixgbe_mac_info *mac = &hw->mac;
401 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
402 struct ixgbe_phy_info *phy = &hw->phy;
405 DEBUGFUNC("ixgbe_init_ops_X550EM");
407 /* Similar to X550 so start there. */
408 ret_val = ixgbe_init_ops_X550(hw);
410 /* Since this function eventually calls
411 * ixgbe_init_ops_540 by design, we are setting
412 * the pointers to NULL explicitly here to overwrite
413 * the values being set in the x540 function.
415 /* Thermal sensor not supported in x550EM */
416 mac->ops.get_thermal_sensor_data = NULL;
417 mac->ops.init_thermal_sensor_thresh = NULL;
418 mac->thermal_sensor_enabled = false;
420 /* FCOE not supported in x550EM */
421 mac->ops.get_san_mac_addr = NULL;
422 mac->ops.set_san_mac_addr = NULL;
423 mac->ops.get_wwn_prefix = NULL;
424 mac->ops.get_fcoe_boot_status = NULL;
426 /* IPsec not supported in x550EM */
427 mac->ops.disable_sec_rx_path = NULL;
428 mac->ops.enable_sec_rx_path = NULL;
430 /* AUTOC register is not present in x550EM. */
431 mac->ops.prot_autoc_read = NULL;
432 mac->ops.prot_autoc_write = NULL;
434 /* X550EM bus type is internal*/
435 hw->bus.type = ixgbe_bus_type_internal;
436 mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
438 if (hw->mac.type == ixgbe_mac_X550EM_x) {
439 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
440 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
441 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
442 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
444 if (hw->mac.type == ixgbe_mac_X550EM_a) {
445 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a;
446 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a;
447 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
448 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
451 mac->ops.get_media_type = ixgbe_get_media_type_X550em;
452 mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
453 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
454 mac->ops.reset_hw = ixgbe_reset_hw_X550em;
455 mac->ops.get_supported_physical_layer =
456 ixgbe_get_supported_physical_layer_X550em;
458 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
459 mac->ops.setup_fc = ixgbe_setup_fc_generic;
461 mac->ops.setup_fc = ixgbe_setup_fc_X550em;
464 if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
465 mac->ops.setup_eee = NULL;
468 phy->ops.init = ixgbe_init_phy_ops_X550em;
469 phy->ops.identify = ixgbe_identify_phy_x550em;
470 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
471 phy->ops.set_phy_power = NULL;
475 eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
476 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
477 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
478 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
479 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
480 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
481 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
482 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
488 * ixgbe_dmac_config_X550
489 * @hw: pointer to hardware structure
491 * Configure DMA coalescing. If enabling dmac, dmac is activated.
492 * When disabling dmac, dmac enable dmac bit is cleared.
494 s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
496 u32 reg, high_pri_tc;
498 DEBUGFUNC("ixgbe_dmac_config_X550");
500 /* Disable DMA coalescing before configuring */
501 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
502 reg &= ~IXGBE_DMACR_DMAC_EN;
503 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
505 /* Disable DMA Coalescing if the watchdog timer is 0 */
506 if (!hw->mac.dmac_config.watchdog_timer)
509 ixgbe_dmac_config_tcs_X550(hw);
511 /* Configure DMA Coalescing Control Register */
512 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
514 /* Set the watchdog timer in units of 40.96 usec */
515 reg &= ~IXGBE_DMACR_DMACWT_MASK;
516 reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
518 reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
519 /* If fcoe is enabled, set high priority traffic class */
520 if (hw->mac.dmac_config.fcoe_en) {
521 high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
522 reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
523 IXGBE_DMACR_HIGH_PRI_TC_MASK);
525 reg |= IXGBE_DMACR_EN_MNG_IND;
527 /* Enable DMA coalescing after configuration */
528 reg |= IXGBE_DMACR_DMAC_EN;
529 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
532 return IXGBE_SUCCESS;
536 * ixgbe_dmac_config_tcs_X550
537 * @hw: pointer to hardware structure
539 * Configure DMA coalescing threshold per TC. The dmac enable bit must
540 * be cleared before configuring.
542 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
544 u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
546 DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
548 /* Configure DMA coalescing enabled */
549 switch (hw->mac.dmac_config.link_speed) {
550 case IXGBE_LINK_SPEED_100_FULL:
551 pb_headroom = IXGBE_DMACRXT_100M;
553 case IXGBE_LINK_SPEED_1GB_FULL:
554 pb_headroom = IXGBE_DMACRXT_1G;
557 pb_headroom = IXGBE_DMACRXT_10G;
561 maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
562 IXGBE_MHADD_MFS_SHIFT) / 1024);
564 /* Set the per Rx packet buffer receive threshold */
565 for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
566 reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
567 reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
569 if (tc < hw->mac.dmac_config.num_tcs) {
571 rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
572 rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
573 IXGBE_RXPBSIZE_SHIFT;
575 /* Calculate receive buffer threshold in kilobytes */
576 if (rx_pb_size > pb_headroom)
577 rx_pb_size = rx_pb_size - pb_headroom;
581 /* Minimum of MFS shall be set for DMCTH */
582 reg |= (rx_pb_size > maxframe_size_kb) ?
583 rx_pb_size : maxframe_size_kb;
585 IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
587 return IXGBE_SUCCESS;
591 * ixgbe_dmac_update_tcs_X550
592 * @hw: pointer to hardware structure
594 * Disables dmac, updates per TC settings, and then enables dmac.
596 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
600 DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
602 /* Disable DMA coalescing before configuring */
603 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
604 reg &= ~IXGBE_DMACR_DMAC_EN;
605 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
607 ixgbe_dmac_config_tcs_X550(hw);
609 /* Enable DMA coalescing after configuration */
610 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
611 reg |= IXGBE_DMACR_DMAC_EN;
612 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
614 return IXGBE_SUCCESS;
618 * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
619 * @hw: pointer to hardware structure
621 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
622 * ixgbe_hw struct in order to set up EEPROM access.
624 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
626 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
630 DEBUGFUNC("ixgbe_init_eeprom_params_X550");
632 if (eeprom->type == ixgbe_eeprom_uninitialized) {
633 eeprom->semaphore_delay = 10;
634 eeprom->type = ixgbe_flash;
636 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
637 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
638 IXGBE_EEC_SIZE_SHIFT);
639 eeprom->word_size = 1 << (eeprom_size +
640 IXGBE_EEPROM_WORD_SIZE_SHIFT);
642 DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
643 eeprom->type, eeprom->word_size);
646 return IXGBE_SUCCESS;
650 * ixgbe_setup_eee_X550 - Enable/disable EEE support
651 * @hw: pointer to the HW structure
652 * @enable_eee: boolean flag to enable EEE
654 * Enable/disable EEE based on enable_eee flag.
655 * Auto-negotiation must be started after BASE-T EEE bits in PHY register 7.3C
659 s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
666 DEBUGFUNC("ixgbe_setup_eee_X550");
668 eeer = IXGBE_READ_REG(hw, IXGBE_EEER);
669 /* Enable or disable EEE per flag */
671 eeer |= (IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
673 if (hw->mac.type == ixgbe_mac_X550) {
674 /* Advertise EEE capability */
675 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
676 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
678 autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
679 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
680 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
682 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
683 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
684 } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
685 /* Not supported on first revision of X550EM_x. */
686 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
687 !(IXGBE_FUSES0_REV_MASK &
688 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
689 return IXGBE_SUCCESS;
691 status = ixgbe_read_iosf_sb_reg_x550(hw,
692 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
693 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
694 if (status != IXGBE_SUCCESS)
697 link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
698 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
700 /* Don't advertise FEC capability when EEE enabled. */
701 link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
703 status = ixgbe_write_iosf_sb_reg_x550(hw,
704 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
705 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
706 if (status != IXGBE_SUCCESS)
710 eeer &= ~(IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
712 if (hw->mac.type == ixgbe_mac_X550) {
713 /* Disable advertised EEE capability */
714 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
715 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
717 autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
718 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
719 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
721 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
722 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
723 } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
724 status = ixgbe_read_iosf_sb_reg_x550(hw,
725 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
726 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
727 if (status != IXGBE_SUCCESS)
730 link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
731 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);
733 /* Advertise FEC capability when EEE is disabled. */
734 link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
736 status = ixgbe_write_iosf_sb_reg_x550(hw,
737 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
738 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
739 if (status != IXGBE_SUCCESS)
743 IXGBE_WRITE_REG(hw, IXGBE_EEER, eeer);
745 return IXGBE_SUCCESS;
749 * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
750 * @hw: pointer to hardware structure
751 * @enable: enable or disable source address pruning
752 * @pool: Rx pool to set source address pruning for
754 void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
759 /* max rx pool is 63 */
763 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
764 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
767 pfflp |= (1ULL << pool);
769 pfflp &= ~(1ULL << pool);
771 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
772 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
776 * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
777 * @hw: pointer to hardware structure
778 * @enable: enable or disable switch for Ethertype anti-spoofing
779 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
782 void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
785 int vf_target_reg = vf >> 3;
786 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
789 DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
791 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
793 pfvfspoof |= (1 << vf_target_shift);
795 pfvfspoof &= ~(1 << vf_target_shift);
797 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
801 * ixgbe_iosf_wait - Wait for IOSF command completion
802 * @hw: pointer to hardware structure
803 * @ctrl: pointer to location to receive final IOSF control value
805 * Returns failing status on timeout
807 * Note: ctrl can be NULL if the IOSF control register value is not needed
809 STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
813 /* Check every 10 usec to see if the address cycle completed.
814 * The SB IOSF BUSY bit will clear when the operation is
817 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
818 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
819 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
825 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
826 ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
827 return IXGBE_ERR_PHY;
830 return IXGBE_SUCCESS;
834 * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
836 * @hw: pointer to hardware structure
837 * @reg_addr: 32 bit PHY register to write
838 * @device_type: 3 bit device type
839 * @data: Data to write to the register
841 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
842 u32 device_type, u32 data)
844 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
848 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
849 if (ret != IXGBE_SUCCESS)
852 ret = ixgbe_iosf_wait(hw, NULL);
853 if (ret != IXGBE_SUCCESS)
856 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
857 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
859 /* Write IOSF control register */
860 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
862 /* Write IOSF data register */
863 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
865 ret = ixgbe_iosf_wait(hw, &command);
867 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
868 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
869 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
870 ERROR_REPORT2(IXGBE_ERROR_POLLING,
871 "Failed to write, error %x\n", error);
876 ixgbe_release_swfw_semaphore(hw, gssr);
881 * ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
883 * @hw: pointer to hardware structure
884 * @reg_addr: 32 bit PHY register to write
885 * @device_type: 3 bit device type
886 * @phy_data: Pointer to read data from the register
888 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
889 u32 device_type, u32 *data)
891 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
895 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
896 if (ret != IXGBE_SUCCESS)
899 ret = ixgbe_iosf_wait(hw, NULL);
900 if (ret != IXGBE_SUCCESS)
903 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
904 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
906 /* Write IOSF control register */
907 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
909 ret = ixgbe_iosf_wait(hw, &command);
911 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
912 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
913 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
914 ERROR_REPORT2(IXGBE_ERROR_POLLING,
915 "Failed to read, error %x\n", error);
919 if (ret == IXGBE_SUCCESS)
920 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
923 ixgbe_release_swfw_semaphore(hw, gssr);
928 * ixgbe_get_phy_token - Get the token for shared phy access
929 * @hw: Pointer to hardware structure
932 s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
934 struct ixgbe_hic_phy_token_req token_cmd;
937 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
938 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
939 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
940 token_cmd.port_number = hw->bus.lan_id;
941 token_cmd.command_type = FW_PHY_TOKEN_REQ;
943 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
945 IXGBE_HI_COMMAND_TIMEOUT,
949 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
950 return IXGBE_SUCCESS;
951 if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY)
952 return IXGBE_ERR_FW_RESP_INVALID;
954 return IXGBE_ERR_TOKEN_RETRY;
958 * ixgbe_put_phy_token - Put the token for shared phy access
959 * @hw: Pointer to hardware structure
962 s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
964 struct ixgbe_hic_phy_token_req token_cmd;
967 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
968 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
969 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
970 token_cmd.port_number = hw->bus.lan_id;
971 token_cmd.command_type = FW_PHY_TOKEN_REL;
973 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
975 IXGBE_HI_COMMAND_TIMEOUT,
979 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
980 return IXGBE_SUCCESS;
981 return IXGBE_ERR_FW_RESP_INVALID;
985 * ixgbe_write_iosf_sb_reg_x550a - Writes a value to specified register
987 * @hw: pointer to hardware structure
988 * @reg_addr: 32 bit PHY register to write
989 * @device_type: 3 bit device type
990 * @data: Data to write to the register
992 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
993 u32 device_type, u32 data)
995 struct ixgbe_hic_internal_phy_req write_cmd;
997 UNREFERENCED_1PARAMETER(device_type);
999 write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1000 write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1001 write_cmd.port_number = hw->bus.lan_id;
1002 write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
1003 write_cmd.address = (u16)reg_addr;
1005 write_cmd.write_data = data;
1008 status = ixgbe_host_interface_command(hw, (u32 *)&write_cmd,
1009 sizeof(write_cmd), IXGBE_HI_COMMAND_TIMEOUT, false);
1015 * ixgbe_read_iosf_sb_reg_x550a - Writes a value to specified register
1016 * of the IOSF device.
1017 * @hw: pointer to hardware structure
1018 * @reg_addr: 32 bit PHY register to write
1019 * @device_type: 3 bit device type
1020 * @data: Pointer to read data from the register
1022 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1023 u32 device_type, u32 *data)
1025 struct ixgbe_hic_internal_phy_req read_cmd;
1027 UNREFERENCED_1PARAMETER(device_type);
1029 read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1030 read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1031 read_cmd.port_number = hw->bus.lan_id;
1032 read_cmd.command_type = FW_INT_PHY_REQ_READ;
1033 read_cmd.address = (u16)reg_addr;
1035 read_cmd.write_data = 0;
1038 status = ixgbe_host_interface_command(hw, (u32 *)&read_cmd,
1039 sizeof(read_cmd), IXGBE_HI_COMMAND_TIMEOUT, true);
1041 /* Extract the register value from the response. */
1042 *data = ((struct ixgbe_hic_internal_phy_resp *)&read_cmd)->read_data;
1048 * ixgbe_disable_mdd_X550
1049 * @hw: pointer to hardware structure
1051 * Disable malicious driver detection
1053 void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
1057 DEBUGFUNC("ixgbe_disable_mdd_X550");
1059 /* Disable MDD for TX DMA and interrupt */
1060 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1061 reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1062 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1064 /* Disable MDD for RX and interrupt */
1065 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1066 reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1067 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1071 * ixgbe_enable_mdd_X550
1072 * @hw: pointer to hardware structure
1074 * Enable malicious driver detection
1076 void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
1080 DEBUGFUNC("ixgbe_enable_mdd_X550");
1082 /* Enable MDD for TX DMA and interrupt */
1083 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1084 reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1085 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1087 /* Enable MDD for RX and interrupt */
1088 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1089 reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1090 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1094 * ixgbe_restore_mdd_vf_X550
1095 * @hw: pointer to hardware structure
1098 * Restore VF that was disabled during malicious driver detection event
1100 void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
1102 u32 idx, reg, num_qs, start_q, bitmask;
1104 DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
1106 /* Map VF to queues */
1107 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1108 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1109 case IXGBE_MRQC_VMDQRT8TCEN:
1110 num_qs = 8; /* 16 VFs / pools */
1111 bitmask = 0x000000FF;
1113 case IXGBE_MRQC_VMDQRSS32EN:
1114 case IXGBE_MRQC_VMDQRT4TCEN:
1115 num_qs = 4; /* 32 VFs / pools */
1116 bitmask = 0x0000000F;
1118 default: /* 64 VFs / pools */
1120 bitmask = 0x00000003;
1123 start_q = vf * num_qs;
1125 /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1128 reg |= (bitmask << (start_q % 32));
1129 IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1130 IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1134 * ixgbe_mdd_event_X550
1135 * @hw: pointer to hardware structure
1136 * @vf_bitmap: vf bitmap of malicious vfs
1138 * Handle malicious driver detection event.
1140 void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1143 u32 i, j, reg, q, shift, vf, idx;
1145 DEBUGFUNC("ixgbe_mdd_event_X550");
1147 /* figure out pool size for mapping to vf's */
1148 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1149 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1150 case IXGBE_MRQC_VMDQRT8TCEN:
1151 shift = 3; /* 16 VFs / pools */
1153 case IXGBE_MRQC_VMDQRSS32EN:
1154 case IXGBE_MRQC_VMDQRT4TCEN:
1155 shift = 2; /* 32 VFs / pools */
1158 shift = 1; /* 64 VFs / pools */
1162 /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1163 for (i = 0; i < 4; i++) {
1164 wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1165 wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1170 /* Get malicious queue */
1171 for (j = 0; j < 32 && wqbr; j++) {
1173 if (!(wqbr & (1 << j)))
1176 /* Get queue from bitmask */
1179 /* Map queue to vf */
1182 /* Set vf bit in vf_bitmap */
1184 vf_bitmap[idx] |= (1 << (vf % 32));
1191 * ixgbe_get_media_type_X550em - Get media type
1192 * @hw: pointer to hardware structure
1194 * Returns the media type (fiber, copper, backplane)
1196 enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1198 enum ixgbe_media_type media_type;
1200 DEBUGFUNC("ixgbe_get_media_type_X550em");
1202 /* Detect if there is a copper PHY attached. */
1203 switch (hw->device_id) {
1204 case IXGBE_DEV_ID_X550EM_X_KR:
1205 case IXGBE_DEV_ID_X550EM_X_KX4:
1206 case IXGBE_DEV_ID_X550EM_A_KR:
1207 case IXGBE_DEV_ID_X550EM_A_KR_L:
1208 media_type = ixgbe_media_type_backplane;
1210 case IXGBE_DEV_ID_X550EM_X_SFP:
1211 case IXGBE_DEV_ID_X550EM_A_SFP:
1212 case IXGBE_DEV_ID_X550EM_A_SFP_N:
1213 case IXGBE_DEV_ID_X550EM_A_QSFP:
1214 case IXGBE_DEV_ID_X550EM_A_QSFP_N:
1215 media_type = ixgbe_media_type_fiber;
1217 case IXGBE_DEV_ID_X550EM_X_1G_T:
1218 case IXGBE_DEV_ID_X550EM_X_10G_T:
1219 case IXGBE_DEV_ID_X550EM_A_1G_T:
1220 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
1221 case IXGBE_DEV_ID_X550EM_A_10G_T:
1222 media_type = ixgbe_media_type_copper;
1225 media_type = ixgbe_media_type_unknown;
1232 * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1233 * @hw: pointer to hardware structure
1234 * @linear: true if SFP module is linear
1236 STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1238 DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1240 switch (hw->phy.sfp_type) {
1241 case ixgbe_sfp_type_not_present:
1242 return IXGBE_ERR_SFP_NOT_PRESENT;
1243 case ixgbe_sfp_type_da_cu_core0:
1244 case ixgbe_sfp_type_da_cu_core1:
1247 case ixgbe_sfp_type_srlr_core0:
1248 case ixgbe_sfp_type_srlr_core1:
1249 case ixgbe_sfp_type_da_act_lmt_core0:
1250 case ixgbe_sfp_type_da_act_lmt_core1:
1251 case ixgbe_sfp_type_1g_sx_core0:
1252 case ixgbe_sfp_type_1g_sx_core1:
1253 case ixgbe_sfp_type_1g_lx_core0:
1254 case ixgbe_sfp_type_1g_lx_core1:
1257 case ixgbe_sfp_type_unknown:
1258 case ixgbe_sfp_type_1g_cu_core0:
1259 case ixgbe_sfp_type_1g_cu_core1:
1261 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1264 return IXGBE_SUCCESS;
1268 * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1269 * @hw: pointer to hardware structure
1271 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1273 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1278 DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1280 status = ixgbe_identify_module_generic(hw);
1282 if (status != IXGBE_SUCCESS)
1285 /* Check if SFP module is supported */
1286 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1292 * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1293 * @hw: pointer to hardware structure
1295 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1300 DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1302 /* Check if SFP module is supported */
1303 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1305 if (status != IXGBE_SUCCESS)
1308 ixgbe_init_mac_link_ops_X550em(hw);
1309 hw->phy.ops.reset = NULL;
1311 return IXGBE_SUCCESS;
1315 * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1316 * @hw: pointer to hardware structure
1318 void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1320 struct ixgbe_mac_info *mac = &hw->mac;
1322 DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1324 switch (hw->mac.ops.get_media_type(hw)) {
1325 case ixgbe_media_type_fiber:
1326 /* CS4227 does not support autoneg, so disable the laser control
1327 * functions for SFP+ fiber
1329 mac->ops.disable_tx_laser = NULL;
1330 mac->ops.enable_tx_laser = NULL;
1331 mac->ops.flap_tx_laser = NULL;
1332 mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1333 mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_x550em;
1334 mac->ops.set_rate_select_speed =
1335 ixgbe_set_soft_rate_select_speed;
1337 case ixgbe_media_type_copper:
1338 mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1339 mac->ops.check_link = ixgbe_check_link_t_X550em;
1347 * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1348 * @hw: pointer to hardware structure
1349 * @speed: pointer to link speed
1350 * @autoneg: true when autoneg or autotry is enabled
1352 s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1353 ixgbe_link_speed *speed,
1356 DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1359 if (hw->phy.media_type == ixgbe_media_type_fiber) {
1361 /* CS4227 SFP must not enable auto-negotiation */
1364 /* Check if 1G SFP module. */
1365 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1366 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1367 || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1368 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1369 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1370 return IXGBE_SUCCESS;
1373 /* Link capabilities are based on SFP */
1374 if (hw->phy.multispeed_fiber)
1375 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1376 IXGBE_LINK_SPEED_1GB_FULL;
1378 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1380 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1381 IXGBE_LINK_SPEED_1GB_FULL;
1385 return IXGBE_SUCCESS;
1389 * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
1390 * @hw: pointer to hardware structure
1391 * @lsc: pointer to boolean flag which indicates whether external Base T
1392 * PHY interrupt is lsc
1394 * Determime if external Base T PHY interrupt cause is high temperature
1395 * failure alarm or link status change.
1397 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
1398 * failure alarm, else return PHY access status.
1400 STATIC s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
1407 /* Vendor alarm triggered */
1408 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1409 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1412 if (status != IXGBE_SUCCESS ||
1413 !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
1416 /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
1417 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
1418 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1421 if (status != IXGBE_SUCCESS ||
1422 !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1423 IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
1426 /* Global alarm triggered */
1427 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
1428 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1431 if (status != IXGBE_SUCCESS)
1434 /* If high temperature failure, then return over temp error and exit */
1435 if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
1436 /* power down the PHY in case the PHY FW didn't already */
1437 ixgbe_set_copper_phy_power(hw, false);
1438 return IXGBE_ERR_OVERTEMP;
1439 } else if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
1440 /* device fault alarm triggered */
1441 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
1442 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1445 if (status != IXGBE_SUCCESS)
1448 /* if device fault was due to high temp alarm handle and exit */
1449 if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
1450 /* power down the PHY in case the PHY FW didn't */
1451 ixgbe_set_copper_phy_power(hw, false);
1452 return IXGBE_ERR_OVERTEMP;
1456 /* Vendor alarm 2 triggered */
1457 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1458 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1460 if (status != IXGBE_SUCCESS ||
1461 !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
1464 /* link connect/disconnect event occurred */
1465 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
1466 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1468 if (status != IXGBE_SUCCESS)
1472 if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
1475 return IXGBE_SUCCESS;
1479 * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
1480 * @hw: pointer to hardware structure
1482 * Enable link status change and temperature failure alarm for the external
1485 * Returns PHY access status
1487 STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
1493 /* Clear interrupt flags */
1494 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
1496 /* Enable link status change alarm */
1497 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1498 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1500 if (status != IXGBE_SUCCESS)
1503 reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
1505 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1506 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
1508 if (status != IXGBE_SUCCESS)
1511 /* Enable high temperature failure and global fault alarms */
1512 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1513 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1516 if (status != IXGBE_SUCCESS)
1519 reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
1520 IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
1522 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1523 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1526 if (status != IXGBE_SUCCESS)
1529 /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
1530 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1531 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1534 if (status != IXGBE_SUCCESS)
1537 reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1538 IXGBE_MDIO_GLOBAL_ALARM_1_INT);
1540 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1541 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1544 if (status != IXGBE_SUCCESS)
1547 /* Enable chip-wide vendor alarm */
1548 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1549 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1552 if (status != IXGBE_SUCCESS)
1555 reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
1557 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1558 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1565 * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
1566 * @hw: pointer to hardware structure
1567 * @speed: link speed
1569 * Configures the integrated KR PHY.
1571 STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
1572 ixgbe_link_speed speed)
1577 status = ixgbe_read_iosf_sb_reg_x550(hw,
1578 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1579 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1583 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1584 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
1585 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
1587 /* Advertise 10G support. */
1588 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
1589 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
1591 /* Advertise 1G support. */
1592 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
1593 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
1595 /* Restart auto-negotiation. */
1596 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1597 status = ixgbe_write_iosf_sb_reg_x550(hw,
1598 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1599 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1605 * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
1606 * @hw: pointer to hardware structure
1608 * Initialize any function pointers that were not able to be
1609 * set during init_shared_code because the PHY/SFP type was
1610 * not known. Perform the SFP init if necessary.
1612 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
1614 struct ixgbe_phy_info *phy = &hw->phy;
1617 DEBUGFUNC("ixgbe_init_phy_ops_X550em");
1619 hw->mac.ops.set_lan_id(hw);
1621 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
1622 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
1623 ixgbe_setup_mux_ctl(hw);
1625 /* Save NW management interface connected on board. This is used
1626 * to determine internal PHY mode.
1628 phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
1629 phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
1632 /* Identify the PHY or SFP module */
1633 ret_val = phy->ops.identify(hw);
1634 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
1637 /* Setup function pointers based on detected hardware */
1638 ixgbe_init_mac_link_ops_X550em(hw);
1639 if (phy->sfp_type != ixgbe_sfp_type_unknown)
1640 phy->ops.reset = NULL;
1642 /* Set functions pointers based on phy type */
1643 switch (hw->phy.type) {
1644 case ixgbe_phy_x550em_kx4:
1645 phy->ops.setup_link = NULL;
1646 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1647 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1649 case ixgbe_phy_x550em_kr:
1650 phy->ops.setup_link = ixgbe_setup_kr_x550em;
1651 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1652 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1654 case ixgbe_phy_x550em_ext_t:
1655 /* Save NW management interface connected on board. This is used
1656 * to determine internal PHY mode
1658 phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
1660 /* If internal link mode is XFI, then setup iXFI internal link,
1661 * else setup KR now.
1663 phy->ops.setup_internal_link =
1664 ixgbe_setup_internal_phy_t_x550em;
1666 /* setup SW LPLU only for first revision of X550EM_x */
1667 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
1668 !(IXGBE_FUSES0_REV_MASK &
1669 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
1670 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
1672 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
1673 phy->ops.reset = ixgbe_reset_phy_t_X550em;
1682 * ixgbe_set_mdio_speed - Set MDIO clock speed
1683 * @hw: pointer to hardware structure
1685 static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
1689 switch (hw->device_id) {
1690 case IXGBE_DEV_ID_X550EM_X_10G_T:
1691 case IXGBE_DEV_ID_X550EM_A_1G_T:
1692 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
1693 case IXGBE_DEV_ID_X550EM_A_10G_T:
1694 case IXGBE_DEV_ID_X550EM_A_SFP:
1695 case IXGBE_DEV_ID_X550EM_A_QSFP:
1696 /* Config MDIO clock speed before the first MDIO PHY access */
1697 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
1698 hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
1699 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
1707 * ixgbe_reset_hw_X550em - Perform hardware reset
1708 * @hw: pointer to hardware structure
1710 * Resets the hardware by resetting the transmit and receive units, masks
1711 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
1714 s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
1716 ixgbe_link_speed link_speed;
1720 bool link_up = false;
1722 DEBUGFUNC("ixgbe_reset_hw_X550em");
1724 /* Call adapter stop to disable Tx/Rx and clear interrupts */
1725 status = hw->mac.ops.stop_adapter(hw);
1726 if (status != IXGBE_SUCCESS)
1729 /* flush pending Tx transactions */
1730 ixgbe_clear_tx_pending(hw);
1732 ixgbe_set_mdio_speed(hw);
1734 /* PHY ops must be identified and initialized prior to reset */
1735 status = hw->phy.ops.init(hw);
1737 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1740 /* start the external PHY */
1741 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
1742 status = ixgbe_init_ext_t_x550em(hw);
1747 /* Setup SFP module if there is one present. */
1748 if (hw->phy.sfp_setup_needed) {
1749 status = hw->mac.ops.setup_sfp(hw);
1750 hw->phy.sfp_setup_needed = false;
1753 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1757 if (!hw->phy.reset_disable && hw->phy.ops.reset)
1758 hw->phy.ops.reset(hw);
1761 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
1762 * If link reset is used when link is up, it might reset the PHY when
1763 * mng is using it. If link is down or the flag to force full link
1764 * reset is set, then perform link reset.
1766 ctrl = IXGBE_CTRL_LNK_RST;
1767 if (!hw->force_full_reset) {
1768 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
1770 ctrl = IXGBE_CTRL_RST;
1773 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
1774 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
1775 IXGBE_WRITE_FLUSH(hw);
1777 /* Poll for reset bit to self-clear meaning reset is complete */
1778 for (i = 0; i < 10; i++) {
1780 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
1781 if (!(ctrl & IXGBE_CTRL_RST_MASK))
1785 if (ctrl & IXGBE_CTRL_RST_MASK) {
1786 status = IXGBE_ERR_RESET_FAILED;
1787 DEBUGOUT("Reset polling failed to complete.\n");
1792 /* Double resets are required for recovery from certain error
1793 * conditions. Between resets, it is necessary to stall to
1794 * allow time for any pending HW events to complete.
1796 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
1797 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
1801 /* Store the permanent mac address */
1802 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
1804 /* Store MAC address from RAR0, clear receive address registers, and
1805 * clear the multicast table. Also reset num_rar_entries to 128,
1806 * since we modify this value when programming the SAN MAC address.
1808 hw->mac.num_rar_entries = 128;
1809 hw->mac.ops.init_rx_addrs(hw);
1811 ixgbe_set_mdio_speed(hw);
1813 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
1814 ixgbe_setup_mux_ctl(hw);
1820 * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
1821 * @hw: pointer to hardware structure
1823 s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
1828 status = hw->phy.ops.read_reg(hw,
1829 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
1830 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1833 if (status != IXGBE_SUCCESS)
1836 /* If PHY FW reset completed bit is set then this is the first
1837 * SW instance after a power on so the PHY FW must be un-stalled.
1839 if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
1840 status = hw->phy.ops.read_reg(hw,
1841 IXGBE_MDIO_GLOBAL_RES_PR_10,
1842 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1845 if (status != IXGBE_SUCCESS)
1848 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
1850 status = hw->phy.ops.write_reg(hw,
1851 IXGBE_MDIO_GLOBAL_RES_PR_10,
1852 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1855 if (status != IXGBE_SUCCESS)
1863 * ixgbe_setup_kr_x550em - Configure the KR PHY.
1864 * @hw: pointer to hardware structure
1866 * Configures the integrated KR PHY.
1868 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
1870 return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
1874 * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
1875 * @hw: pointer to hardware structure
1877 * Configure the external PHY and the integrated KR PHY for SFP support.
1879 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
1880 ixgbe_link_speed speed,
1881 bool autoneg_wait_to_complete)
1884 u16 reg_slice, reg_val;
1885 bool setup_linear = false;
1886 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
1888 /* Check if SFP module is supported and linear */
1889 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
1891 /* If no SFP module present, then return success. Return success since
1892 * there is no reason to configure CS4227 and SFP not present error is
1893 * not excepted in the setup MAC link flow.
1895 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
1896 return IXGBE_SUCCESS;
1898 if (ret_val != IXGBE_SUCCESS)
1901 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
1902 /* Configure CS4227 LINE side to 10G SR. */
1903 reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB +
1904 (hw->bus.lan_id << 12);
1905 reg_val = IXGBE_CS4227_SPEED_10G;
1906 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1909 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
1910 (hw->bus.lan_id << 12);
1911 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1912 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1915 /* Configure CS4227 for HOST connection rate then type. */
1916 reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB +
1917 (hw->bus.lan_id << 12);
1918 reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ?
1919 IXGBE_CS4227_SPEED_10G : IXGBE_CS4227_SPEED_1G;
1920 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1923 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB +
1924 (hw->bus.lan_id << 12);
1926 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1928 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1929 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1932 /* Setup XFI internal link. */
1933 ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
1935 /* Configure internal PHY for KR/KX. */
1936 ixgbe_setup_kr_speed_x550em(hw, speed);
1938 /* Configure CS4227 LINE side to proper mode. */
1939 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
1940 (hw->bus.lan_id << 12);
1942 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1944 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1945 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1952 * ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
1953 * @hw: pointer to hardware structure
1955 * iXfI configuration needed for ixgbe_mac_X550EM_x devices.
1957 STATIC s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
1962 /* Disable training protocol FSM. */
1963 status = ixgbe_read_iosf_sb_reg_x550(hw,
1964 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1965 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1966 if (status != IXGBE_SUCCESS)
1968 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
1969 status = ixgbe_write_iosf_sb_reg_x550(hw,
1970 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1971 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1972 if (status != IXGBE_SUCCESS)
1975 /* Disable Flex from training TXFFE. */
1976 status = ixgbe_read_iosf_sb_reg_x550(hw,
1977 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1978 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1979 if (status != IXGBE_SUCCESS)
1981 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1982 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1983 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1984 status = ixgbe_write_iosf_sb_reg_x550(hw,
1985 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1986 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1987 if (status != IXGBE_SUCCESS)
1989 status = ixgbe_read_iosf_sb_reg_x550(hw,
1990 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1991 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1992 if (status != IXGBE_SUCCESS)
1994 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1995 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1996 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1997 status = ixgbe_write_iosf_sb_reg_x550(hw,
1998 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1999 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2000 if (status != IXGBE_SUCCESS)
2003 /* Enable override for coefficients. */
2004 status = ixgbe_read_iosf_sb_reg_x550(hw,
2005 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2006 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2007 if (status != IXGBE_SUCCESS)
2009 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
2010 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
2011 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
2012 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
2013 status = ixgbe_write_iosf_sb_reg_x550(hw,
2014 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2015 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2020 * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
2021 * @hw: pointer to hardware structure
2022 * @speed: the link speed to force
2024 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
2025 * internal and external PHY at a specific speed, without autonegotiation.
2027 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2032 /* Disable AN and force speed to 10G Serial. */
2033 status = ixgbe_read_iosf_sb_reg_x550(hw,
2034 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2035 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2036 if (status != IXGBE_SUCCESS)
2039 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2040 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2042 /* Select forced link speed for internal PHY. */
2044 case IXGBE_LINK_SPEED_10GB_FULL:
2045 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2047 case IXGBE_LINK_SPEED_1GB_FULL:
2048 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
2051 /* Other link speeds are not supported by internal KR PHY. */
2052 return IXGBE_ERR_LINK_SETUP;
2055 status = ixgbe_write_iosf_sb_reg_x550(hw,
2056 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2057 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2058 if (status != IXGBE_SUCCESS)
2061 /* Additional configuration needed for x550em_x */
2062 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2063 status = ixgbe_setup_ixfi_x550em_x(hw);
2064 if (status != IXGBE_SUCCESS)
2068 /* Toggle port SW reset by AN reset. */
2069 status = ixgbe_read_iosf_sb_reg_x550(hw,
2070 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2071 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2072 if (status != IXGBE_SUCCESS)
2074 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
2075 status = ixgbe_write_iosf_sb_reg_x550(hw,
2076 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2077 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2083 * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
2084 * @hw: address of hardware structure
2085 * @link_up: address of boolean to indicate link status
2087 * Returns error code if unable to get link status.
2089 STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
2096 /* read this twice back to back to indicate current status */
2097 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
2098 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2100 if (ret != IXGBE_SUCCESS)
2103 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
2104 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2106 if (ret != IXGBE_SUCCESS)
2109 *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
2111 return IXGBE_SUCCESS;
2115 * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
2116 * @hw: point to hardware structure
2118 * Configures the link between the integrated KR PHY and the external X557 PHY
2119 * The driver will call this function when it gets a link status change
2120 * interrupt from the X557 PHY. This function configures the link speed
2121 * between the PHYs to match the link speed of the BASE-T link.
2123 * A return of a non-zero value indicates an error, and the base driver should
2124 * not report link up.
2126 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
2128 ixgbe_link_speed force_speed;
2133 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
2134 return IXGBE_ERR_CONFIG;
2136 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
2137 /* If link is down, there is no setup necessary so return */
2138 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2139 if (status != IXGBE_SUCCESS)
2143 return IXGBE_SUCCESS;
2145 status = hw->phy.ops.read_reg(hw,
2146 IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
2147 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2149 if (status != IXGBE_SUCCESS)
2152 /* If link is still down - no setup is required so return */
2153 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2154 if (status != IXGBE_SUCCESS)
2157 return IXGBE_SUCCESS;
2159 /* clear everything but the speed and duplex bits */
2160 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
2163 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
2164 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
2166 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
2167 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
2170 /* Internal PHY does not support anything else */
2171 return IXGBE_ERR_INVALID_LINK_SETTINGS;
2174 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
2176 speed = IXGBE_LINK_SPEED_10GB_FULL |
2177 IXGBE_LINK_SPEED_1GB_FULL;
2178 return ixgbe_setup_kr_speed_x550em(hw, speed);
2183 * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
2184 * @hw: pointer to hardware structure
2186 * Configures the integrated KR PHY to use internal loopback mode.
2188 s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
2193 /* Disable AN and force speed to 10G Serial. */
2194 status = ixgbe_read_iosf_sb_reg_x550(hw,
2195 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2196 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2197 if (status != IXGBE_SUCCESS)
2199 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2200 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2201 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2202 status = ixgbe_write_iosf_sb_reg_x550(hw,
2203 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2204 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2205 if (status != IXGBE_SUCCESS)
2208 /* Set near-end loopback clocks. */
2209 status = ixgbe_read_iosf_sb_reg_x550(hw,
2210 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2211 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2212 if (status != IXGBE_SUCCESS)
2214 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
2215 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
2216 status = ixgbe_write_iosf_sb_reg_x550(hw,
2217 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2218 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2219 if (status != IXGBE_SUCCESS)
2222 /* Set loopback enable. */
2223 status = ixgbe_read_iosf_sb_reg_x550(hw,
2224 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2225 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2226 if (status != IXGBE_SUCCESS)
2228 reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
2229 status = ixgbe_write_iosf_sb_reg_x550(hw,
2230 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2231 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2232 if (status != IXGBE_SUCCESS)
2235 /* Training bypass. */
2236 status = ixgbe_read_iosf_sb_reg_x550(hw,
2237 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2238 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2239 if (status != IXGBE_SUCCESS)
2241 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
2242 status = ixgbe_write_iosf_sb_reg_x550(hw,
2243 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2244 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2250 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2251 * assuming that the semaphore is already obtained.
2252 * @hw: pointer to hardware structure
2253 * @offset: offset of word in the EEPROM to read
2254 * @data: word read from the EEPROM
2256 * Reads a 16 bit word from the EEPROM using the hostif.
2258 s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2262 struct ixgbe_hic_read_shadow_ram buffer;
2264 DEBUGFUNC("ixgbe_read_ee_hostif_data_X550");
2265 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2266 buffer.hdr.req.buf_lenh = 0;
2267 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2268 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2270 /* convert offset from words to bytes */
2271 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2273 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2275 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2277 IXGBE_HI_COMMAND_TIMEOUT, false);
2282 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
2283 FW_NVM_DATA_OFFSET);
2289 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2290 * @hw: pointer to hardware structure
2291 * @offset: offset of word in the EEPROM to read
2292 * @data: word read from the EEPROM
2294 * Reads a 16 bit word from the EEPROM using the hostif.
2296 s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2299 s32 status = IXGBE_SUCCESS;
2301 DEBUGFUNC("ixgbe_read_ee_hostif_X550");
2303 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2305 status = ixgbe_read_ee_hostif_data_X550(hw, offset, data);
2306 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2308 status = IXGBE_ERR_SWFW_SYNC;
2315 * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
2316 * @hw: pointer to hardware structure
2317 * @offset: offset of word in the EEPROM to read
2318 * @words: number of words
2319 * @data: word(s) read from the EEPROM
2321 * Reads a 16 bit word(s) from the EEPROM using the hostif.
2323 s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2324 u16 offset, u16 words, u16 *data)
2326 struct ixgbe_hic_read_shadow_ram buffer;
2327 u32 current_word = 0;
2332 DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
2334 /* Take semaphore for the entire operation. */
2335 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2337 DEBUGOUT("EEPROM read buffer - semaphore failed\n");
2341 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
2342 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
2344 words_to_read = words;
2346 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2347 buffer.hdr.req.buf_lenh = 0;
2348 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2349 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2351 /* convert offset from words to bytes */
2352 buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
2353 buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
2355 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2357 IXGBE_HI_COMMAND_TIMEOUT,
2361 DEBUGOUT("Host interface command failed\n");
2365 for (i = 0; i < words_to_read; i++) {
2366 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
2368 u32 value = IXGBE_READ_REG(hw, reg);
2370 data[current_word] = (u16)(value & 0xffff);
2373 if (i < words_to_read) {
2375 data[current_word] = (u16)(value & 0xffff);
2379 words -= words_to_read;
2383 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2388 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2389 * @hw: pointer to hardware structure
2390 * @offset: offset of word in the EEPROM to write
2391 * @data: word write to the EEPROM
2393 * Write a 16 bit word to the EEPROM using the hostif.
2395 s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2399 struct ixgbe_hic_write_shadow_ram buffer;
2401 DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
2403 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
2404 buffer.hdr.req.buf_lenh = 0;
2405 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
2406 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2409 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2411 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2413 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2415 IXGBE_HI_COMMAND_TIMEOUT, false);
2421 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2422 * @hw: pointer to hardware structure
2423 * @offset: offset of word in the EEPROM to write
2424 * @data: word write to the EEPROM
2426 * Write a 16 bit word to the EEPROM using the hostif.
2428 s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2431 s32 status = IXGBE_SUCCESS;
2433 DEBUGFUNC("ixgbe_write_ee_hostif_X550");
2435 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2437 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
2438 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2440 DEBUGOUT("write ee hostif failed to get semaphore");
2441 status = IXGBE_ERR_SWFW_SYNC;
2448 * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
2449 * @hw: pointer to hardware structure
2450 * @offset: offset of word in the EEPROM to write
2451 * @words: number of words
2452 * @data: word(s) write to the EEPROM
2454 * Write a 16 bit word(s) to the EEPROM using the hostif.
2456 s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2457 u16 offset, u16 words, u16 *data)
2459 s32 status = IXGBE_SUCCESS;
2462 DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
2464 /* Take semaphore for the entire operation. */
2465 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2466 if (status != IXGBE_SUCCESS) {
2467 DEBUGOUT("EEPROM write buffer - semaphore failed\n");
2471 for (i = 0; i < words; i++) {
2472 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
2475 if (status != IXGBE_SUCCESS) {
2476 DEBUGOUT("Eeprom buffered write failed\n");
2481 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2488 * ixgbe_checksum_ptr_x550 - Checksum one pointer region
2489 * @hw: pointer to hardware structure
2490 * @ptr: pointer offset in eeprom
2491 * @size: size of section pointed by ptr, if 0 first word will be used as size
2492 * @csum: address of checksum to update
2494 * Returns error status for any failure
2496 STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
2497 u16 size, u16 *csum, u16 *buffer,
2502 u16 length, bufsz, i, start;
2505 bufsz = sizeof(buf) / sizeof(buf[0]);
2507 /* Read a chunk at the pointer location */
2509 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
2511 DEBUGOUT("Failed to read EEPROM image\n");
2516 if (buffer_size < ptr)
2517 return IXGBE_ERR_PARAM;
2518 local_buffer = &buffer[ptr];
2526 length = local_buffer[0];
2528 /* Skip pointer section if length is invalid. */
2529 if (length == 0xFFFF || length == 0 ||
2530 (ptr + length) >= hw->eeprom.word_size)
2531 return IXGBE_SUCCESS;
2534 if (buffer && ((u32)start + (u32)length > buffer_size))
2535 return IXGBE_ERR_PARAM;
2537 for (i = start; length; i++, length--) {
2538 if (i == bufsz && !buffer) {
2544 /* Read a chunk at the pointer location */
2545 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
2548 DEBUGOUT("Failed to read EEPROM image\n");
2552 *csum += local_buffer[i];
2554 return IXGBE_SUCCESS;
2558 * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
2559 * @hw: pointer to hardware structure
2560 * @buffer: pointer to buffer containing calculated checksum
2561 * @buffer_size: size of buffer
2563 * Returns a negative error code on error, or the 16-bit checksum
2565 s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
2567 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
2571 u16 pointer, i, size;
2573 DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
2575 hw->eeprom.ops.init_params(hw);
2578 /* Read pointer area */
2579 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
2580 IXGBE_EEPROM_LAST_WORD + 1,
2583 DEBUGOUT("Failed to read EEPROM image\n");
2586 local_buffer = eeprom_ptrs;
2588 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
2589 return IXGBE_ERR_PARAM;
2590 local_buffer = buffer;
2594 * For X550 hardware include 0x0-0x41 in the checksum, skip the
2595 * checksum word itself
2597 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
2598 if (i != IXGBE_EEPROM_CHECKSUM)
2599 checksum += local_buffer[i];
2602 * Include all data from pointers 0x3, 0x6-0xE. This excludes the
2603 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
2605 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
2606 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
2609 pointer = local_buffer[i];
2611 /* Skip pointer section if the pointer is invalid. */
2612 if (pointer == 0xFFFF || pointer == 0 ||
2613 pointer >= hw->eeprom.word_size)
2617 case IXGBE_PCIE_GENERAL_PTR:
2618 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
2620 case IXGBE_PCIE_CONFIG0_PTR:
2621 case IXGBE_PCIE_CONFIG1_PTR:
2622 size = IXGBE_PCIE_CONFIG_SIZE;
2629 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
2630 buffer, buffer_size);
2635 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
2637 return (s32)checksum;
2641 * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
2642 * @hw: pointer to hardware structure
2644 * Returns a negative error code on error, or the 16-bit checksum
2646 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
2648 return ixgbe_calc_checksum_X550(hw, NULL, 0);
2652 * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
2653 * @hw: pointer to hardware structure
2654 * @checksum_val: calculated checksum
2656 * Performs checksum calculation and validates the EEPROM checksum. If the
2657 * caller does not need checksum_val, the value can be NULL.
2659 s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
2663 u16 read_checksum = 0;
2665 DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
2667 /* Read the first word from the EEPROM. If this times out or fails, do
2668 * not continue or we could be in for a very long wait while every
2671 status = hw->eeprom.ops.read(hw, 0, &checksum);
2673 DEBUGOUT("EEPROM read failed\n");
2677 status = hw->eeprom.ops.calc_checksum(hw);
2681 checksum = (u16)(status & 0xffff);
2683 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2688 /* Verify read checksum from EEPROM is the same as
2689 * calculated checksum
2691 if (read_checksum != checksum) {
2692 status = IXGBE_ERR_EEPROM_CHECKSUM;
2693 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
2694 "Invalid EEPROM checksum");
2697 /* If the user cares, return the calculated checksum */
2699 *checksum_val = checksum;
2705 * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
2706 * @hw: pointer to hardware structure
2708 * After writing EEPROM to shadow RAM using EEWR register, software calculates
2709 * checksum and updates the EEPROM and instructs the hardware to update
2712 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
2717 DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
2719 /* Read the first word from the EEPROM. If this times out or fails, do
2720 * not continue or we could be in for a very long wait while every
2723 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
2725 DEBUGOUT("EEPROM read failed\n");
2729 status = ixgbe_calc_eeprom_checksum_X550(hw);
2733 checksum = (u16)(status & 0xffff);
2735 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2740 status = ixgbe_update_flash_X550(hw);
2746 * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
2747 * @hw: pointer to hardware structure
2749 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
2751 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
2753 s32 status = IXGBE_SUCCESS;
2754 union ixgbe_hic_hdr2 buffer;
2756 DEBUGFUNC("ixgbe_update_flash_X550");
2758 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
2759 buffer.req.buf_lenh = 0;
2760 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
2761 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
2763 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2765 IXGBE_HI_COMMAND_TIMEOUT, false);
2771 * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
2772 * @hw: pointer to hardware structure
2774 * Determines physical layer capabilities of the current configuration.
2776 u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
2778 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
2779 u16 ext_ability = 0;
2781 DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
2783 hw->phy.ops.identify(hw);
2785 switch (hw->phy.type) {
2786 case ixgbe_phy_x550em_kr:
2787 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
2788 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2790 case ixgbe_phy_x550em_kx4:
2791 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
2792 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2794 case ixgbe_phy_x550em_ext_t:
2795 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
2796 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2798 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
2799 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
2800 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
2801 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
2807 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
2808 physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
2810 return physical_layer;
2814 * ixgbe_get_bus_info_x550em - Set PCI bus info
2815 * @hw: pointer to hardware structure
2817 * Sets bus link width and speed to unknown because X550em is
2820 s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
2823 DEBUGFUNC("ixgbe_get_bus_info_x550em");
2825 hw->bus.width = ixgbe_bus_width_unknown;
2826 hw->bus.speed = ixgbe_bus_speed_unknown;
2828 hw->mac.ops.set_lan_id(hw);
2830 return IXGBE_SUCCESS;
2834 * ixgbe_disable_rx_x550 - Disable RX unit
2836 * Enables the Rx DMA unit for x550
2838 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
2840 u32 rxctrl, pfdtxgswc;
2842 struct ixgbe_hic_disable_rxen fw_cmd;
2844 DEBUGFUNC("ixgbe_enable_rx_dma_x550");
2846 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2847 if (rxctrl & IXGBE_RXCTRL_RXEN) {
2848 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
2849 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
2850 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
2851 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
2852 hw->mac.set_lben = true;
2854 hw->mac.set_lben = false;
2857 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
2858 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
2859 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
2860 fw_cmd.port_number = (u8)hw->bus.lan_id;
2862 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
2863 sizeof(struct ixgbe_hic_disable_rxen),
2864 IXGBE_HI_COMMAND_TIMEOUT, true);
2866 /* If we fail - disable RX using register write */
2868 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2869 if (rxctrl & IXGBE_RXCTRL_RXEN) {
2870 rxctrl &= ~IXGBE_RXCTRL_RXEN;
2871 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
2878 * ixgbe_enter_lplu_x550em - Transition to low power states
2879 * @hw: pointer to hardware structure
2881 * Configures Low Power Link Up on transition to low power states
2882 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
2883 * X557 PHY immediately prior to entering LPLU.
2885 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
2887 u16 an_10g_cntl_reg, autoneg_reg, speed;
2889 ixgbe_link_speed lcd_speed;
2893 /* SW LPLU not required on later HW revisions. */
2894 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
2895 (IXGBE_FUSES0_REV_MASK &
2896 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
2897 return IXGBE_SUCCESS;
2899 /* If blocked by MNG FW, then don't restart AN */
2900 if (ixgbe_check_reset_blocked(hw))
2901 return IXGBE_SUCCESS;
2903 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2904 if (status != IXGBE_SUCCESS)
2907 status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
2909 if (status != IXGBE_SUCCESS)
2912 /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
2913 * disabled, then force link down by entering low power mode.
2915 if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
2916 !(hw->wol_enabled || ixgbe_mng_present(hw)))
2917 return ixgbe_set_copper_phy_power(hw, FALSE);
2920 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
2922 if (status != IXGBE_SUCCESS)
2925 /* If no valid LCD link speed, then force link down and exit. */
2926 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
2927 return ixgbe_set_copper_phy_power(hw, FALSE);
2929 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
2930 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2933 if (status != IXGBE_SUCCESS)
2936 /* If no link now, speed is invalid so take link down */
2937 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2938 if (status != IXGBE_SUCCESS)
2939 return ixgbe_set_copper_phy_power(hw, false);
2941 /* clear everything but the speed bits */
2942 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
2944 /* If current speed is already LCD, then exit. */
2945 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
2946 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
2947 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
2948 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
2951 /* Clear AN completed indication */
2952 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
2953 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2956 if (status != IXGBE_SUCCESS)
2959 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
2960 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2963 if (status != IXGBE_SUCCESS)
2966 status = hw->phy.ops.read_reg(hw,
2967 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
2968 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2971 if (status != IXGBE_SUCCESS)
2974 save_autoneg = hw->phy.autoneg_advertised;
2976 /* Setup link at least common link speed */
2977 status = hw->mac.ops.setup_link(hw, lcd_speed, false);
2979 /* restore autoneg from before setting lplu speed */
2980 hw->phy.autoneg_advertised = save_autoneg;
2986 * ixgbe_get_lcd_x550em - Determine lowest common denominator
2987 * @hw: pointer to hardware structure
2988 * @lcd_speed: pointer to lowest common link speed
2990 * Determine lowest common link speed with link partner.
2992 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
2996 u16 word = hw->eeprom.ctrl_word_3;
2998 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
3000 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
3001 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3004 if (status != IXGBE_SUCCESS)
3007 /* If link partner advertised 1G, return 1G */
3008 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
3009 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
3013 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
3014 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
3015 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
3018 /* Link partner not capable of lower speeds, return 10G */
3019 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
3024 * ixgbe_setup_fc_X550em - Set up flow control
3025 * @hw: pointer to hardware structure
3027 * Called at init time to set up flow control.
3029 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
3031 s32 ret_val = IXGBE_SUCCESS;
3032 u32 pause, asm_dir, reg_val;
3034 DEBUGFUNC("ixgbe_setup_fc_X550em");
3036 /* Validate the requested mode */
3037 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
3038 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
3039 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
3040 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3044 /* 10gig parts do not have a word in the EEPROM to determine the
3045 * default flow control setting, so we explicitly set it to full.
3047 if (hw->fc.requested_mode == ixgbe_fc_default)
3048 hw->fc.requested_mode = ixgbe_fc_full;
3050 /* Determine PAUSE and ASM_DIR bits. */
3051 switch (hw->fc.requested_mode) {
3056 case ixgbe_fc_tx_pause:
3060 case ixgbe_fc_rx_pause:
3061 /* Rx Flow control is enabled and Tx Flow control is
3062 * disabled by software override. Since there really
3063 * isn't a way to advertise that we are capable of RX
3064 * Pause ONLY, we will advertise that we support both
3065 * symmetric and asymmetric Rx PAUSE, as such we fall
3066 * through to the fc_full statement. Later, we will
3067 * disable the adapter's ability to send PAUSE frames.
3074 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
3075 "Flow control param set incorrectly\n");
3076 ret_val = IXGBE_ERR_CONFIG;
3080 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
3081 ret_val = ixgbe_read_iosf_sb_reg_x550(hw,
3082 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
3083 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3084 if (ret_val != IXGBE_SUCCESS)
3086 reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
3087 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
3089 reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
3091 reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
3092 ret_val = ixgbe_write_iosf_sb_reg_x550(hw,
3093 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
3094 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3096 /* This device does not fully support AN. */
3097 hw->fc.disable_fc_autoneg = true;
3105 * ixgbe_set_mux - Set mux for port 1 access with CS4227
3106 * @hw: pointer to hardware structure
3107 * @state: set mux if 1, clear if 0
3109 STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
3113 if (!hw->bus.lan_id)
3115 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
3117 esdp |= IXGBE_ESDP_SDP1;
3119 esdp &= ~IXGBE_ESDP_SDP1;
3120 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
3121 IXGBE_WRITE_FLUSH(hw);
3125 * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
3126 * @hw: pointer to hardware structure
3127 * @mask: Mask to specify which semaphore to acquire
3129 * Acquires the SWFW semaphore and sets the I2C MUX
3131 s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
3135 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
3137 status = ixgbe_acquire_swfw_sync_X540(hw, mask);
3141 if (mask & IXGBE_GSSR_I2C_MASK)
3142 ixgbe_set_mux(hw, 1);
3144 return IXGBE_SUCCESS;
3148 * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
3149 * @hw: pointer to hardware structure
3150 * @mask: Mask to specify which semaphore to release
3152 * Releases the SWFW semaphore and sets the I2C MUX
3154 void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
3156 DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
3158 if (mask & IXGBE_GSSR_I2C_MASK)
3159 ixgbe_set_mux(hw, 0);
3161 ixgbe_release_swfw_sync_X540(hw, mask);
3165 * ixgbe_acquire_swfw_sync_X550a - Acquire SWFW semaphore
3166 * @hw: pointer to hardware structure
3167 * @mask: Mask to specify which semaphore to acquire
3169 * Acquires the SWFW semaphore and get the shared phy token as needed
3171 static s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
3173 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
3174 int retries = FW_PHY_TOKEN_RETRIES;
3175 s32 status = IXGBE_SUCCESS;
3177 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");
3181 status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
3184 if (!(mask & IXGBE_GSSR_TOKEN_SM))
3186 status = ixgbe_get_phy_token(hw);
3187 if (status != IXGBE_ERR_TOKEN_RETRY)
3190 ixgbe_release_swfw_sync_X540(hw, hmask);
3191 msec_delay(FW_PHY_TOKEN_DELAY);
3198 * ixgbe_release_swfw_sync_X550a - Release SWFW semaphore
3199 * @hw: pointer to hardware structure
3200 * @mask: Mask to specify which semaphore to release
3202 * Releases the SWFW semaphore and puts the shared phy token as needed
3204 static void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
3206 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
3208 DEBUGFUNC("ixgbe_release_swfw_sync_X550a");
3210 if (mask & IXGBE_GSSR_TOKEN_SM)
3211 ixgbe_put_phy_token(hw);
3214 ixgbe_release_swfw_sync_X540(hw, hmask);
3218 * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
3219 * @hw: pointer to hardware structure
3221 * Handle external Base T PHY interrupt. If high temperature
3222 * failure alarm then return error, else if link status change
3223 * then setup internal/external PHY link
3225 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
3226 * failure alarm, else return PHY access status.
3228 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
3233 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
3235 if (status != IXGBE_SUCCESS)
3239 return ixgbe_setup_internal_phy(hw);
3241 return IXGBE_SUCCESS;
3245 * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
3246 * @hw: pointer to hardware structure
3247 * @speed: new link speed
3248 * @autoneg_wait_to_complete: true when waiting for completion is needed
3250 * Setup internal/external PHY link speed based on link speed, then set
3251 * external PHY auto advertised link speed.
3253 * Returns error status for any failure
3255 s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
3256 ixgbe_link_speed speed,
3257 bool autoneg_wait_to_complete)
3260 ixgbe_link_speed force_speed;
3262 DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
3264 /* Setup internal/external PHY link speed to iXFI (10G), unless
3265 * only 1G is auto advertised then setup KX link.
3267 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
3268 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
3270 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
3272 /* If internal link mode is XFI, then setup XFI internal link. */
3273 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
3274 status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
3276 if (status != IXGBE_SUCCESS)
3280 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
3284 * ixgbe_check_link_t_X550em - Determine link and speed status
3285 * @hw: pointer to hardware structure
3286 * @speed: pointer to link speed
3287 * @link_up: true when link is up
3288 * @link_up_wait_to_complete: bool used to wait for link up or not
3290 * Check that both the MAC and X557 external PHY have link.
3292 s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
3293 bool *link_up, bool link_up_wait_to_complete)
3298 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
3299 return IXGBE_ERR_CONFIG;
3301 status = ixgbe_check_mac_link_generic(hw, speed, link_up,
3302 link_up_wait_to_complete);
3304 /* If check link fails or MAC link is not up, then return */
3305 if (status != IXGBE_SUCCESS || !(*link_up))
3308 /* MAC link is up, so check external PHY link.
3309 * Read this twice back to back to indicate current status.
3311 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3312 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3315 if (status != IXGBE_SUCCESS)
3318 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3319 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3322 if (status != IXGBE_SUCCESS)
3325 /* If external PHY link is not up, then indicate link not up */
3326 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
3329 return IXGBE_SUCCESS;
3333 * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
3334 * @hw: pointer to hardware structure
3336 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
3340 status = ixgbe_reset_phy_generic(hw);
3342 if (status != IXGBE_SUCCESS)
3345 /* Configure Link Status Alarm and Temperature Threshold interrupts */
3346 return ixgbe_enable_lasi_ext_t_x550em(hw);
3350 * ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
3351 * @hw: pointer to hardware structure
3352 * @led_idx: led number to turn on
3354 s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
3358 DEBUGFUNC("ixgbe_led_on_t_X550em");
3360 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
3361 return IXGBE_ERR_PARAM;
3363 /* To turn on the LED, set mode to ON. */
3364 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3365 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
3366 phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
3367 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3368 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
3370 return IXGBE_SUCCESS;
3374 * ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
3375 * @hw: pointer to hardware structure
3376 * @led_idx: led number to turn off
3378 s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
3382 DEBUGFUNC("ixgbe_led_off_t_X550em");
3384 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
3385 return IXGBE_ERR_PARAM;
3387 /* To turn on the LED, set mode to ON. */
3388 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3389 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
3390 phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
3391 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3392 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
3394 return IXGBE_SUCCESS;