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);
44 STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw);
47 * ixgbe_init_ops_X550 - Inits func ptrs and MAC type
48 * @hw: pointer to hardware structure
50 * Initialize the function pointers and assign the MAC type for X550.
51 * Does not touch the hardware.
53 s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
55 struct ixgbe_mac_info *mac = &hw->mac;
56 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
59 DEBUGFUNC("ixgbe_init_ops_X550");
61 ret_val = ixgbe_init_ops_X540(hw);
62 mac->ops.dmac_config = ixgbe_dmac_config_X550;
63 mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
64 mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
65 mac->ops.setup_eee = NULL;
66 mac->ops.set_source_address_pruning =
67 ixgbe_set_source_address_pruning_X550;
68 mac->ops.set_ethertype_anti_spoofing =
69 ixgbe_set_ethertype_anti_spoofing_X550;
71 mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
72 eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
73 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
74 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
75 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
76 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
77 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
78 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
79 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
81 mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
82 mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
83 mac->ops.mdd_event = ixgbe_mdd_event_X550;
84 mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
85 mac->ops.disable_rx = ixgbe_disable_rx_x550;
86 /* Manageability interface */
87 mac->ops.set_fw_drv_ver = ixgbe_set_fw_drv_ver_x550;
88 switch (hw->device_id) {
89 case IXGBE_DEV_ID_X550EM_X_1G_T:
90 hw->mac.ops.led_on = NULL;
91 hw->mac.ops.led_off = NULL;
93 case IXGBE_DEV_ID_X550EM_X_10G_T:
94 case IXGBE_DEV_ID_X550EM_A_10G_T:
95 hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
96 hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
105 * ixgbe_read_cs4227 - Read CS4227 register
106 * @hw: pointer to hardware structure
107 * @reg: register number to write
108 * @value: pointer to receive value read
110 * Returns status code
112 STATIC s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
114 return hw->link.ops.read_link_unlocked(hw, hw->link.addr, reg, value);
118 * ixgbe_write_cs4227 - Write CS4227 register
119 * @hw: pointer to hardware structure
120 * @reg: register number to write
121 * @value: value to write to register
123 * Returns status code
125 STATIC s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
127 return hw->link.ops.write_link_unlocked(hw, hw->link.addr, reg, value);
131 * ixgbe_read_pe - Read register from port expander
132 * @hw: pointer to hardware structure
133 * @reg: register number to read
134 * @value: pointer to receive read value
136 * Returns status code
138 STATIC s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
142 status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
143 if (status != IXGBE_SUCCESS)
144 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
145 "port expander access failed with %d\n", status);
150 * ixgbe_write_pe - Write register to port expander
151 * @hw: pointer to hardware structure
152 * @reg: register number to write
153 * @value: value to write
155 * Returns status code
157 STATIC s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
161 status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
162 if (status != IXGBE_SUCCESS)
163 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
164 "port expander access failed with %d\n", status);
169 * ixgbe_reset_cs4227 - Reset CS4227 using port expander
170 * @hw: pointer to hardware structure
172 * This function assumes that the caller has acquired the proper semaphore.
175 STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
182 /* Trigger hard reset. */
183 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
184 if (status != IXGBE_SUCCESS)
186 reg |= IXGBE_PE_BIT1;
187 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
188 if (status != IXGBE_SUCCESS)
191 status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, ®);
192 if (status != IXGBE_SUCCESS)
194 reg &= ~IXGBE_PE_BIT1;
195 status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
196 if (status != IXGBE_SUCCESS)
199 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
200 if (status != IXGBE_SUCCESS)
202 reg &= ~IXGBE_PE_BIT1;
203 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
204 if (status != IXGBE_SUCCESS)
207 usec_delay(IXGBE_CS4227_RESET_HOLD);
209 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
210 if (status != IXGBE_SUCCESS)
212 reg |= IXGBE_PE_BIT1;
213 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
214 if (status != IXGBE_SUCCESS)
217 /* Wait for the reset to complete. */
218 msec_delay(IXGBE_CS4227_RESET_DELAY);
219 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
220 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
222 if (status == IXGBE_SUCCESS &&
223 value == IXGBE_CS4227_EEPROM_LOAD_OK)
225 msec_delay(IXGBE_CS4227_CHECK_DELAY);
227 if (retry == IXGBE_CS4227_RETRIES) {
228 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
229 "CS4227 reset did not complete.");
230 return IXGBE_ERR_PHY;
233 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
234 if (status != IXGBE_SUCCESS ||
235 !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
236 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
237 "CS4227 EEPROM did not load successfully.");
238 return IXGBE_ERR_PHY;
241 return IXGBE_SUCCESS;
245 * ixgbe_check_cs4227 - Check CS4227 and reset as needed
246 * @hw: pointer to hardware structure
248 STATIC void ixgbe_check_cs4227(struct ixgbe_hw *hw)
250 s32 status = IXGBE_SUCCESS;
251 u32 swfw_mask = hw->phy.phy_semaphore_mask;
255 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
256 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
257 if (status != IXGBE_SUCCESS) {
258 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
259 "semaphore failed with %d", status);
260 msec_delay(IXGBE_CS4227_CHECK_DELAY);
264 /* Get status of reset flow. */
265 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
267 if (status == IXGBE_SUCCESS &&
268 value == IXGBE_CS4227_RESET_COMPLETE)
271 if (status != IXGBE_SUCCESS ||
272 value != IXGBE_CS4227_RESET_PENDING)
275 /* Reset is pending. Wait and check again. */
276 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
277 msec_delay(IXGBE_CS4227_CHECK_DELAY);
280 /* If still pending, assume other instance failed. */
281 if (retry == IXGBE_CS4227_RETRIES) {
282 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
283 if (status != IXGBE_SUCCESS) {
284 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
285 "semaphore failed with %d", status);
290 /* Reset the CS4227. */
291 status = ixgbe_reset_cs4227(hw);
292 if (status != IXGBE_SUCCESS) {
293 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
294 "CS4227 reset failed: %d", status);
298 /* Reset takes so long, temporarily release semaphore in case the
299 * other driver instance is waiting for the reset indication.
301 ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
302 IXGBE_CS4227_RESET_PENDING);
303 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
305 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
306 if (status != IXGBE_SUCCESS) {
307 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
308 "semaphore failed with %d", status);
312 /* Record completion for next time. */
313 status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
314 IXGBE_CS4227_RESET_COMPLETE);
317 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
318 msec_delay(hw->eeprom.semaphore_delay);
322 * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
323 * @hw: pointer to hardware structure
325 STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
327 u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
329 if (hw->bus.lan_id) {
330 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
331 esdp |= IXGBE_ESDP_SDP1_DIR;
333 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
334 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
335 IXGBE_WRITE_FLUSH(hw);
339 * ixgbe_identify_phy_x550em - Get PHY type based on device id
340 * @hw: pointer to hardware structure
344 STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
346 hw->mac.ops.set_lan_id(hw);
348 ixgbe_read_mng_if_sel_x550em(hw);
350 switch (hw->device_id) {
351 case IXGBE_DEV_ID_X550EM_A_SFP:
352 return ixgbe_identify_module_generic(hw);
353 case IXGBE_DEV_ID_X550EM_X_SFP:
354 /* set up for CS4227 usage */
355 ixgbe_setup_mux_ctl(hw);
356 ixgbe_check_cs4227(hw);
359 case IXGBE_DEV_ID_X550EM_A_SFP_N:
360 return ixgbe_identify_module_generic(hw);
362 case IXGBE_DEV_ID_X550EM_X_KX4:
363 hw->phy.type = ixgbe_phy_x550em_kx4;
365 case IXGBE_DEV_ID_X550EM_X_XFI:
366 hw->phy.type = ixgbe_phy_x550em_xfi;
368 case IXGBE_DEV_ID_X550EM_X_KR:
369 case IXGBE_DEV_ID_X550EM_A_KR:
370 case IXGBE_DEV_ID_X550EM_A_KR_L:
371 hw->phy.type = ixgbe_phy_x550em_kr;
373 case IXGBE_DEV_ID_X550EM_A_10G_T:
374 case IXGBE_DEV_ID_X550EM_X_10G_T:
375 return ixgbe_identify_phy_generic(hw);
376 case IXGBE_DEV_ID_X550EM_X_1G_T:
377 hw->phy.type = ixgbe_phy_ext_1g_t;
379 case IXGBE_DEV_ID_X550EM_A_1G_T:
380 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
381 hw->phy.type = ixgbe_phy_fw;
383 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
385 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
390 return IXGBE_SUCCESS;
394 * ixgbe_fw_phy_activity - Perform an activity on a PHY
395 * @hw: pointer to hardware structure
396 * @activity: activity to perform
397 * @data: Pointer to 4 32-bit words of data
399 s32 ixgbe_fw_phy_activity(struct ixgbe_hw *hw, u16 activity,
400 u32 (*data)[FW_PHY_ACT_DATA_COUNT])
403 struct ixgbe_hic_phy_activity_req cmd;
404 struct ixgbe_hic_phy_activity_resp rsp;
406 u16 retries = FW_PHY_ACT_RETRIES;
411 memset(&hic, 0, sizeof(hic));
412 hic.cmd.hdr.cmd = FW_PHY_ACT_REQ_CMD;
413 hic.cmd.hdr.buf_len = FW_PHY_ACT_REQ_LEN;
414 hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
415 hic.cmd.port_number = hw->bus.lan_id;
416 hic.cmd.activity_id = IXGBE_CPU_TO_LE16(activity);
417 for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
418 hic.cmd.data[i] = IXGBE_CPU_TO_BE32((*data)[i]);
420 rc = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
422 IXGBE_HI_COMMAND_TIMEOUT,
424 if (rc != IXGBE_SUCCESS)
426 if (hic.rsp.hdr.cmd_or_resp.ret_status ==
427 FW_CEM_RESP_STATUS_SUCCESS) {
428 for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
429 (*data)[i] = IXGBE_BE32_TO_CPU(hic.rsp.data[i]);
430 return IXGBE_SUCCESS;
434 } while (retries > 0);
436 return IXGBE_ERR_HOST_INTERFACE_COMMAND;
439 static const struct {
441 ixgbe_link_speed phy_speed;
443 { FW_PHY_ACT_LINK_SPEED_10, IXGBE_LINK_SPEED_10_FULL },
444 { FW_PHY_ACT_LINK_SPEED_100, IXGBE_LINK_SPEED_100_FULL },
445 { FW_PHY_ACT_LINK_SPEED_1G, IXGBE_LINK_SPEED_1GB_FULL },
446 { FW_PHY_ACT_LINK_SPEED_2_5G, IXGBE_LINK_SPEED_2_5GB_FULL },
447 { FW_PHY_ACT_LINK_SPEED_5G, IXGBE_LINK_SPEED_5GB_FULL },
448 { FW_PHY_ACT_LINK_SPEED_10G, IXGBE_LINK_SPEED_10GB_FULL },
452 * ixgbe_get_phy_id_fw - Get the phy ID via firmware command
453 * @hw: pointer to hardware structure
457 static s32 ixgbe_get_phy_id_fw(struct ixgbe_hw *hw)
459 u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
465 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_PHY_INFO, &info);
469 hw->phy.speeds_supported = 0;
470 phy_speeds = info[0] & FW_PHY_INFO_SPEED_MASK;
471 for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
472 if (phy_speeds & ixgbe_fw_map[i].fw_speed)
473 hw->phy.speeds_supported |= ixgbe_fw_map[i].phy_speed;
475 if (!hw->phy.autoneg_advertised)
476 hw->phy.autoneg_advertised = hw->phy.speeds_supported;
478 hw->phy.id = info[0] & FW_PHY_INFO_ID_HI_MASK;
479 phy_id_lo = info[1] & FW_PHY_INFO_ID_LO_MASK;
480 hw->phy.id |= phy_id_lo & IXGBE_PHY_REVISION_MASK;
481 hw->phy.revision = phy_id_lo & ~IXGBE_PHY_REVISION_MASK;
482 if (!hw->phy.id || hw->phy.id == IXGBE_PHY_REVISION_MASK)
483 return IXGBE_ERR_PHY_ADDR_INVALID;
484 return IXGBE_SUCCESS;
488 * ixgbe_identify_phy_fw - Get PHY type based on firmware command
489 * @hw: pointer to hardware structure
493 static s32 ixgbe_identify_phy_fw(struct ixgbe_hw *hw)
496 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
498 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
500 hw->phy.type = ixgbe_phy_fw;
501 hw->phy.ops.read_reg = NULL;
502 hw->phy.ops.write_reg = NULL;
503 return ixgbe_get_phy_id_fw(hw);
507 * ixgbe_shutdown_fw_phy - Shutdown a firmware-controlled PHY
508 * @hw: pointer to hardware structure
512 s32 ixgbe_shutdown_fw_phy(struct ixgbe_hw *hw)
514 u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
516 setup[0] = FW_PHY_ACT_FORCE_LINK_DOWN_OFF;
517 return ixgbe_fw_phy_activity(hw, FW_PHY_ACT_FORCE_LINK_DOWN, &setup);
520 STATIC s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
521 u32 device_type, u16 *phy_data)
523 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
524 return IXGBE_NOT_IMPLEMENTED;
527 STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
528 u32 device_type, u16 phy_data)
530 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
531 return IXGBE_NOT_IMPLEMENTED;
535 * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
536 * @hw: pointer to the hardware structure
537 * @addr: I2C bus address to read from
538 * @reg: I2C device register to read from
539 * @val: pointer to location to receive read value
541 * Returns an error code on error.
543 STATIC s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
546 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
550 * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
551 * @hw: pointer to the hardware structure
552 * @addr: I2C bus address to read from
553 * @reg: I2C device register to read from
554 * @val: pointer to location to receive read value
556 * Returns an error code on error.
559 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
562 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, false);
566 * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
567 * @hw: pointer to the hardware structure
568 * @addr: I2C bus address to write to
569 * @reg: I2C device register to write to
570 * @val: value to write
572 * Returns an error code on error.
574 STATIC s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
575 u8 addr, u16 reg, u16 val)
577 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
581 * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
582 * @hw: pointer to the hardware structure
583 * @addr: I2C bus address to write to
584 * @reg: I2C device register to write to
585 * @val: value to write
587 * Returns an error code on error.
590 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
591 u8 addr, u16 reg, u16 val)
593 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, false);
597 * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
598 * @hw: pointer to hardware structure
600 * Initialize the function pointers and for MAC type X550EM.
601 * Does not touch the hardware.
603 s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
605 struct ixgbe_mac_info *mac = &hw->mac;
606 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
607 struct ixgbe_phy_info *phy = &hw->phy;
610 DEBUGFUNC("ixgbe_init_ops_X550EM");
612 /* Similar to X550 so start there. */
613 ret_val = ixgbe_init_ops_X550(hw);
615 /* Since this function eventually calls
616 * ixgbe_init_ops_540 by design, we are setting
617 * the pointers to NULL explicitly here to overwrite
618 * the values being set in the x540 function.
620 /* Thermal sensor not supported in x550EM */
621 mac->ops.get_thermal_sensor_data = NULL;
622 mac->ops.init_thermal_sensor_thresh = NULL;
623 mac->thermal_sensor_enabled = false;
625 /* FCOE not supported in x550EM */
626 mac->ops.get_san_mac_addr = NULL;
627 mac->ops.set_san_mac_addr = NULL;
628 mac->ops.get_wwn_prefix = NULL;
629 mac->ops.get_fcoe_boot_status = NULL;
631 /* IPsec not supported in x550EM */
632 mac->ops.disable_sec_rx_path = NULL;
633 mac->ops.enable_sec_rx_path = NULL;
635 /* AUTOC register is not present in x550EM. */
636 mac->ops.prot_autoc_read = NULL;
637 mac->ops.prot_autoc_write = NULL;
639 /* X550EM bus type is internal*/
640 hw->bus.type = ixgbe_bus_type_internal;
641 mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
644 mac->ops.get_media_type = ixgbe_get_media_type_X550em;
645 mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
646 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
647 mac->ops.reset_hw = ixgbe_reset_hw_X550em;
648 mac->ops.get_supported_physical_layer =
649 ixgbe_get_supported_physical_layer_X550em;
651 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
652 mac->ops.setup_fc = ixgbe_setup_fc_generic;
654 mac->ops.setup_fc = ixgbe_setup_fc_X550em;
657 phy->ops.init = ixgbe_init_phy_ops_X550em;
658 switch (hw->device_id) {
659 case IXGBE_DEV_ID_X550EM_A_1G_T:
660 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
661 mac->ops.setup_fc = NULL;
662 phy->ops.identify = ixgbe_identify_phy_fw;
663 phy->ops.set_phy_power = NULL;
664 phy->ops.get_firmware_version = NULL;
666 case IXGBE_DEV_ID_X550EM_X_1G_T:
667 mac->ops.setup_fc = NULL;
668 phy->ops.identify = ixgbe_identify_phy_x550em;
669 phy->ops.set_phy_power = NULL;
672 phy->ops.identify = ixgbe_identify_phy_x550em;
675 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
676 phy->ops.set_phy_power = NULL;
680 eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
681 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
682 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
683 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
684 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
685 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
686 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
687 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
693 * ixgbe_setup_fw_link - Setup firmware-controlled PHYs
694 * @hw: pointer to hardware structure
696 static s32 ixgbe_setup_fw_link(struct ixgbe_hw *hw)
698 u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
702 if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
705 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
706 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
707 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
708 return IXGBE_ERR_INVALID_LINK_SETTINGS;
711 switch (hw->fc.requested_mode) {
713 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RXTX <<
714 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
716 case ixgbe_fc_rx_pause:
717 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RX <<
718 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
720 case ixgbe_fc_tx_pause:
721 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_TX <<
722 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
728 for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
729 if (hw->phy.autoneg_advertised & ixgbe_fw_map[i].phy_speed)
730 setup[0] |= ixgbe_fw_map[i].fw_speed;
732 setup[0] |= FW_PHY_ACT_SETUP_LINK_HP | FW_PHY_ACT_SETUP_LINK_AN;
734 if (hw->phy.eee_speeds_advertised)
735 setup[0] |= FW_PHY_ACT_SETUP_LINK_EEE;
737 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_SETUP_LINK, &setup);
740 if (setup[0] == FW_PHY_ACT_SETUP_LINK_RSP_DOWN)
741 return IXGBE_ERR_OVERTEMP;
742 return IXGBE_SUCCESS;
746 * ixgbe_fc_autoneg_fw _ Set up flow control for FW-controlled PHYs
747 * @hw: pointer to hardware structure
749 * Called at init time to set up flow control.
751 static s32 ixgbe_fc_autoneg_fw(struct ixgbe_hw *hw)
753 if (hw->fc.requested_mode == ixgbe_fc_default)
754 hw->fc.requested_mode = ixgbe_fc_full;
756 return ixgbe_setup_fw_link(hw);
760 * ixgbe_setup_eee_fw - Enable/disable EEE support
761 * @hw: pointer to the HW structure
762 * @enable_eee: boolean flag to enable EEE
764 * Enable/disable EEE based on enable_eee flag.
765 * This function controls EEE for firmware-based PHY implementations.
767 static s32 ixgbe_setup_eee_fw(struct ixgbe_hw *hw, bool enable_eee)
769 if (!!hw->phy.eee_speeds_advertised == enable_eee)
770 return IXGBE_SUCCESS;
772 hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
774 hw->phy.eee_speeds_advertised = 0;
775 return hw->phy.ops.setup_link(hw);
779 * ixgbe_init_ops_X550EM_a - Inits func ptrs and MAC type
780 * @hw: pointer to hardware structure
782 * Initialize the function pointers and for MAC type X550EM_a.
783 * Does not touch the hardware.
785 s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
787 struct ixgbe_mac_info *mac = &hw->mac;
790 DEBUGFUNC("ixgbe_init_ops_X550EM_a");
792 /* Start with generic X550EM init */
793 ret_val = ixgbe_init_ops_X550EM(hw);
795 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
796 hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L) {
797 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
798 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
800 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a;
801 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a;
803 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
804 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
806 switch (mac->ops.get_media_type(hw)) {
807 case ixgbe_media_type_fiber:
808 mac->ops.setup_fc = NULL;
809 mac->ops.fc_autoneg = ixgbe_fc_autoneg_fiber_x550em_a;
811 case ixgbe_media_type_backplane:
812 mac->ops.fc_autoneg = ixgbe_fc_autoneg_backplane_x550em_a;
813 mac->ops.setup_fc = ixgbe_setup_fc_backplane_x550em_a;
819 switch (hw->device_id) {
820 case IXGBE_DEV_ID_X550EM_A_1G_T:
821 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
822 mac->ops.fc_autoneg = ixgbe_fc_autoneg_sgmii_x550em_a;
823 mac->ops.setup_fc = ixgbe_fc_autoneg_fw;
824 mac->ops.setup_eee = ixgbe_setup_eee_fw;
825 hw->phy.eee_speeds_supported = IXGBE_LINK_SPEED_100_FULL |
826 IXGBE_LINK_SPEED_1GB_FULL;
827 hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
837 * ixgbe_init_ops_X550EM_x - Inits func ptrs and MAC type
838 * @hw: pointer to hardware structure
840 * Initialize the function pointers and for MAC type X550EM_x.
841 * Does not touch the hardware.
843 s32 ixgbe_init_ops_X550EM_x(struct ixgbe_hw *hw)
845 struct ixgbe_mac_info *mac = &hw->mac;
846 struct ixgbe_link_info *link = &hw->link;
849 DEBUGFUNC("ixgbe_init_ops_X550EM_x");
851 /* Start with generic X550EM init */
852 ret_val = ixgbe_init_ops_X550EM(hw);
854 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
855 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
856 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
857 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
858 link->ops.read_link = ixgbe_read_i2c_combined_generic;
859 link->ops.read_link_unlocked = ixgbe_read_i2c_combined_generic_unlocked;
860 link->ops.write_link = ixgbe_write_i2c_combined_generic;
861 link->ops.write_link_unlocked =
862 ixgbe_write_i2c_combined_generic_unlocked;
863 link->addr = IXGBE_CS4227;
865 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T) {
866 mac->ops.setup_fc = NULL;
867 mac->ops.setup_eee = NULL;
868 mac->ops.init_led_link_act = NULL;
875 * ixgbe_dmac_config_X550
876 * @hw: pointer to hardware structure
878 * Configure DMA coalescing. If enabling dmac, dmac is activated.
879 * When disabling dmac, dmac enable dmac bit is cleared.
881 s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
883 u32 reg, high_pri_tc;
885 DEBUGFUNC("ixgbe_dmac_config_X550");
887 /* Disable DMA coalescing before configuring */
888 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
889 reg &= ~IXGBE_DMACR_DMAC_EN;
890 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
892 /* Disable DMA Coalescing if the watchdog timer is 0 */
893 if (!hw->mac.dmac_config.watchdog_timer)
896 ixgbe_dmac_config_tcs_X550(hw);
898 /* Configure DMA Coalescing Control Register */
899 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
901 /* Set the watchdog timer in units of 40.96 usec */
902 reg &= ~IXGBE_DMACR_DMACWT_MASK;
903 reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
905 reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
906 /* If fcoe is enabled, set high priority traffic class */
907 if (hw->mac.dmac_config.fcoe_en) {
908 high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
909 reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
910 IXGBE_DMACR_HIGH_PRI_TC_MASK);
912 reg |= IXGBE_DMACR_EN_MNG_IND;
914 /* Enable DMA coalescing after configuration */
915 reg |= IXGBE_DMACR_DMAC_EN;
916 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
919 return IXGBE_SUCCESS;
923 * ixgbe_dmac_config_tcs_X550
924 * @hw: pointer to hardware structure
926 * Configure DMA coalescing threshold per TC. The dmac enable bit must
927 * be cleared before configuring.
929 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
931 u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
933 DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
935 /* Configure DMA coalescing enabled */
936 switch (hw->mac.dmac_config.link_speed) {
937 case IXGBE_LINK_SPEED_10_FULL:
938 case IXGBE_LINK_SPEED_100_FULL:
939 pb_headroom = IXGBE_DMACRXT_100M;
941 case IXGBE_LINK_SPEED_1GB_FULL:
942 pb_headroom = IXGBE_DMACRXT_1G;
945 pb_headroom = IXGBE_DMACRXT_10G;
949 maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
950 IXGBE_MHADD_MFS_SHIFT) / 1024);
952 /* Set the per Rx packet buffer receive threshold */
953 for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
954 reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
955 reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
957 if (tc < hw->mac.dmac_config.num_tcs) {
959 rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
960 rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
961 IXGBE_RXPBSIZE_SHIFT;
963 /* Calculate receive buffer threshold in kilobytes */
964 if (rx_pb_size > pb_headroom)
965 rx_pb_size = rx_pb_size - pb_headroom;
969 /* Minimum of MFS shall be set for DMCTH */
970 reg |= (rx_pb_size > maxframe_size_kb) ?
971 rx_pb_size : maxframe_size_kb;
973 IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
975 return IXGBE_SUCCESS;
979 * ixgbe_dmac_update_tcs_X550
980 * @hw: pointer to hardware structure
982 * Disables dmac, updates per TC settings, and then enables dmac.
984 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
988 DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
990 /* Disable DMA coalescing before configuring */
991 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
992 reg &= ~IXGBE_DMACR_DMAC_EN;
993 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
995 ixgbe_dmac_config_tcs_X550(hw);
997 /* Enable DMA coalescing after configuration */
998 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
999 reg |= IXGBE_DMACR_DMAC_EN;
1000 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
1002 return IXGBE_SUCCESS;
1006 * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
1007 * @hw: pointer to hardware structure
1009 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
1010 * ixgbe_hw struct in order to set up EEPROM access.
1012 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
1014 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
1018 DEBUGFUNC("ixgbe_init_eeprom_params_X550");
1020 if (eeprom->type == ixgbe_eeprom_uninitialized) {
1021 eeprom->semaphore_delay = 10;
1022 eeprom->type = ixgbe_flash;
1024 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
1025 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
1026 IXGBE_EEC_SIZE_SHIFT);
1027 eeprom->word_size = 1 << (eeprom_size +
1028 IXGBE_EEPROM_WORD_SIZE_SHIFT);
1030 DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
1031 eeprom->type, eeprom->word_size);
1034 return IXGBE_SUCCESS;
1038 * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
1039 * @hw: pointer to hardware structure
1040 * @enable: enable or disable source address pruning
1041 * @pool: Rx pool to set source address pruning for
1043 void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
1048 /* max rx pool is 63 */
1052 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
1053 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
1056 pfflp |= (1ULL << pool);
1058 pfflp &= ~(1ULL << pool);
1060 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
1061 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
1065 * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
1066 * @hw: pointer to hardware structure
1067 * @enable: enable or disable switch for Ethertype anti-spoofing
1068 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
1071 void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
1072 bool enable, int vf)
1074 int vf_target_reg = vf >> 3;
1075 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
1078 DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
1080 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
1082 pfvfspoof |= (1 << vf_target_shift);
1084 pfvfspoof &= ~(1 << vf_target_shift);
1086 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
1090 * ixgbe_iosf_wait - Wait for IOSF command completion
1091 * @hw: pointer to hardware structure
1092 * @ctrl: pointer to location to receive final IOSF control value
1094 * Returns failing status on timeout
1096 * Note: ctrl can be NULL if the IOSF control register value is not needed
1098 STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
1102 /* Check every 10 usec to see if the address cycle completed.
1103 * The SB IOSF BUSY bit will clear when the operation is
1106 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
1107 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
1108 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
1114 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
1115 ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
1116 return IXGBE_ERR_PHY;
1119 return IXGBE_SUCCESS;
1123 * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register
1124 * of the IOSF device
1125 * @hw: pointer to hardware structure
1126 * @reg_addr: 32 bit PHY register to write
1127 * @device_type: 3 bit device type
1128 * @data: Data to write to the register
1130 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1131 u32 device_type, u32 data)
1133 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1137 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1138 if (ret != IXGBE_SUCCESS)
1141 ret = ixgbe_iosf_wait(hw, NULL);
1142 if (ret != IXGBE_SUCCESS)
1145 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1146 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1148 /* Write IOSF control register */
1149 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1151 /* Write IOSF data register */
1152 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
1154 ret = ixgbe_iosf_wait(hw, &command);
1156 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1157 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1158 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1159 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1160 "Failed to write, error %x\n", error);
1161 ret = IXGBE_ERR_PHY;
1165 ixgbe_release_swfw_semaphore(hw, gssr);
1170 * ixgbe_read_iosf_sb_reg_x550 - Reads specified register of the IOSF device
1171 * @hw: pointer to hardware structure
1172 * @reg_addr: 32 bit PHY register to write
1173 * @device_type: 3 bit device type
1174 * @data: Pointer to read data from the register
1176 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1177 u32 device_type, u32 *data)
1179 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1183 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1184 if (ret != IXGBE_SUCCESS)
1187 ret = ixgbe_iosf_wait(hw, NULL);
1188 if (ret != IXGBE_SUCCESS)
1191 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1192 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1194 /* Write IOSF control register */
1195 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1197 ret = ixgbe_iosf_wait(hw, &command);
1199 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1200 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1201 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1202 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1203 "Failed to read, error %x\n", error);
1204 ret = IXGBE_ERR_PHY;
1207 if (ret == IXGBE_SUCCESS)
1208 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
1211 ixgbe_release_swfw_semaphore(hw, gssr);
1216 * ixgbe_get_phy_token - Get the token for shared phy access
1217 * @hw: Pointer to hardware structure
1220 s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
1222 struct ixgbe_hic_phy_token_req token_cmd;
1225 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1226 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1227 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1228 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1229 token_cmd.port_number = hw->bus.lan_id;
1230 token_cmd.command_type = FW_PHY_TOKEN_REQ;
1232 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1234 IXGBE_HI_COMMAND_TIMEOUT,
1237 DEBUGOUT1("Issuing host interface command failed with Status = %d\n",
1241 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1242 return IXGBE_SUCCESS;
1243 if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY) {
1244 DEBUGOUT1("Host interface command returned 0x%08x , returning IXGBE_ERR_FW_RESP_INVALID\n",
1245 token_cmd.hdr.cmd_or_resp.ret_status);
1246 return IXGBE_ERR_FW_RESP_INVALID;
1249 DEBUGOUT("Returning IXGBE_ERR_TOKEN_RETRY\n");
1250 return IXGBE_ERR_TOKEN_RETRY;
1254 * ixgbe_put_phy_token - Put the token for shared phy access
1255 * @hw: Pointer to hardware structure
1258 s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
1260 struct ixgbe_hic_phy_token_req token_cmd;
1263 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1264 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1265 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1266 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1267 token_cmd.port_number = hw->bus.lan_id;
1268 token_cmd.command_type = FW_PHY_TOKEN_REL;
1270 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1272 IXGBE_HI_COMMAND_TIMEOUT,
1276 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1277 return IXGBE_SUCCESS;
1279 DEBUGOUT("Put PHY Token host interface command failed");
1280 return IXGBE_ERR_FW_RESP_INVALID;
1284 * ixgbe_write_iosf_sb_reg_x550a - Writes a value to specified register
1285 * of the IOSF device
1286 * @hw: pointer to hardware structure
1287 * @reg_addr: 32 bit PHY register to write
1288 * @device_type: 3 bit device type
1289 * @data: Data to write to the register
1291 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1292 u32 device_type, u32 data)
1294 struct ixgbe_hic_internal_phy_req write_cmd;
1296 UNREFERENCED_1PARAMETER(device_type);
1298 memset(&write_cmd, 0, sizeof(write_cmd));
1299 write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1300 write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1301 write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1302 write_cmd.port_number = hw->bus.lan_id;
1303 write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
1304 write_cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
1305 write_cmd.write_data = IXGBE_CPU_TO_BE32(data);
1307 status = ixgbe_host_interface_command(hw, (u32 *)&write_cmd,
1309 IXGBE_HI_COMMAND_TIMEOUT, false);
1315 * ixgbe_read_iosf_sb_reg_x550a - Reads specified register of the IOSF device
1316 * @hw: pointer to hardware structure
1317 * @reg_addr: 32 bit PHY register to write
1318 * @device_type: 3 bit device type
1319 * @data: Pointer to read data from the register
1321 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1322 u32 device_type, u32 *data)
1325 struct ixgbe_hic_internal_phy_req cmd;
1326 struct ixgbe_hic_internal_phy_resp rsp;
1329 UNREFERENCED_1PARAMETER(device_type);
1331 memset(&hic, 0, sizeof(hic));
1332 hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1333 hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1334 hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1335 hic.cmd.port_number = hw->bus.lan_id;
1336 hic.cmd.command_type = FW_INT_PHY_REQ_READ;
1337 hic.cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
1339 status = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
1341 IXGBE_HI_COMMAND_TIMEOUT, true);
1343 /* Extract the register value from the response. */
1344 *data = IXGBE_BE32_TO_CPU(hic.rsp.read_data);
1350 * ixgbe_disable_mdd_X550
1351 * @hw: pointer to hardware structure
1353 * Disable malicious driver detection
1355 void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
1359 DEBUGFUNC("ixgbe_disable_mdd_X550");
1361 /* Disable MDD for TX DMA and interrupt */
1362 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1363 reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1364 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1366 /* Disable MDD for RX and interrupt */
1367 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1368 reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1369 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1373 * ixgbe_enable_mdd_X550
1374 * @hw: pointer to hardware structure
1376 * Enable malicious driver detection
1378 void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
1382 DEBUGFUNC("ixgbe_enable_mdd_X550");
1384 /* Enable MDD for TX DMA and interrupt */
1385 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1386 reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1387 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1389 /* Enable MDD for RX and interrupt */
1390 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1391 reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1392 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1396 * ixgbe_restore_mdd_vf_X550
1397 * @hw: pointer to hardware structure
1400 * Restore VF that was disabled during malicious driver detection event
1402 void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
1404 u32 idx, reg, num_qs, start_q, bitmask;
1406 DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
1408 /* Map VF to queues */
1409 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1410 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1411 case IXGBE_MRQC_VMDQRT8TCEN:
1412 num_qs = 8; /* 16 VFs / pools */
1413 bitmask = 0x000000FF;
1415 case IXGBE_MRQC_VMDQRSS32EN:
1416 case IXGBE_MRQC_VMDQRT4TCEN:
1417 num_qs = 4; /* 32 VFs / pools */
1418 bitmask = 0x0000000F;
1420 default: /* 64 VFs / pools */
1422 bitmask = 0x00000003;
1425 start_q = vf * num_qs;
1427 /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1430 reg |= (bitmask << (start_q % 32));
1431 IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1432 IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1436 * ixgbe_mdd_event_X550
1437 * @hw: pointer to hardware structure
1438 * @vf_bitmap: vf bitmap of malicious vfs
1440 * Handle malicious driver detection event.
1442 void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1445 u32 i, j, reg, q, shift, vf, idx;
1447 DEBUGFUNC("ixgbe_mdd_event_X550");
1449 /* figure out pool size for mapping to vf's */
1450 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1451 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1452 case IXGBE_MRQC_VMDQRT8TCEN:
1453 shift = 3; /* 16 VFs / pools */
1455 case IXGBE_MRQC_VMDQRSS32EN:
1456 case IXGBE_MRQC_VMDQRT4TCEN:
1457 shift = 2; /* 32 VFs / pools */
1460 shift = 1; /* 64 VFs / pools */
1464 /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1465 for (i = 0; i < 4; i++) {
1466 wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1467 wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1472 /* Get malicious queue */
1473 for (j = 0; j < 32 && wqbr; j++) {
1475 if (!(wqbr & (1 << j)))
1478 /* Get queue from bitmask */
1481 /* Map queue to vf */
1484 /* Set vf bit in vf_bitmap */
1486 vf_bitmap[idx] |= (1 << (vf % 32));
1493 * ixgbe_get_media_type_X550em - Get media type
1494 * @hw: pointer to hardware structure
1496 * Returns the media type (fiber, copper, backplane)
1498 enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1500 enum ixgbe_media_type media_type;
1502 DEBUGFUNC("ixgbe_get_media_type_X550em");
1504 /* Detect if there is a copper PHY attached. */
1505 switch (hw->device_id) {
1506 case IXGBE_DEV_ID_X550EM_X_KR:
1507 case IXGBE_DEV_ID_X550EM_X_KX4:
1508 case IXGBE_DEV_ID_X550EM_X_XFI:
1509 case IXGBE_DEV_ID_X550EM_A_KR:
1510 case IXGBE_DEV_ID_X550EM_A_KR_L:
1511 media_type = ixgbe_media_type_backplane;
1513 case IXGBE_DEV_ID_X550EM_X_SFP:
1514 case IXGBE_DEV_ID_X550EM_A_SFP:
1515 case IXGBE_DEV_ID_X550EM_A_SFP_N:
1516 case IXGBE_DEV_ID_X550EM_A_QSFP:
1517 case IXGBE_DEV_ID_X550EM_A_QSFP_N:
1518 media_type = ixgbe_media_type_fiber;
1520 case IXGBE_DEV_ID_X550EM_X_1G_T:
1521 case IXGBE_DEV_ID_X550EM_X_10G_T:
1522 case IXGBE_DEV_ID_X550EM_A_10G_T:
1523 media_type = ixgbe_media_type_copper;
1525 case IXGBE_DEV_ID_X550EM_A_SGMII:
1526 case IXGBE_DEV_ID_X550EM_A_SGMII_L:
1527 media_type = ixgbe_media_type_backplane;
1528 hw->phy.type = ixgbe_phy_sgmii;
1530 case IXGBE_DEV_ID_X550EM_A_1G_T:
1531 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
1532 media_type = ixgbe_media_type_copper;
1535 media_type = ixgbe_media_type_unknown;
1542 * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1543 * @hw: pointer to hardware structure
1544 * @linear: true if SFP module is linear
1546 STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1548 DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1550 switch (hw->phy.sfp_type) {
1551 case ixgbe_sfp_type_not_present:
1552 return IXGBE_ERR_SFP_NOT_PRESENT;
1553 case ixgbe_sfp_type_da_cu_core0:
1554 case ixgbe_sfp_type_da_cu_core1:
1557 case ixgbe_sfp_type_srlr_core0:
1558 case ixgbe_sfp_type_srlr_core1:
1559 case ixgbe_sfp_type_da_act_lmt_core0:
1560 case ixgbe_sfp_type_da_act_lmt_core1:
1561 case ixgbe_sfp_type_1g_sx_core0:
1562 case ixgbe_sfp_type_1g_sx_core1:
1563 case ixgbe_sfp_type_1g_lx_core0:
1564 case ixgbe_sfp_type_1g_lx_core1:
1567 case ixgbe_sfp_type_unknown:
1568 case ixgbe_sfp_type_1g_cu_core0:
1569 case ixgbe_sfp_type_1g_cu_core1:
1571 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1574 return IXGBE_SUCCESS;
1578 * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1579 * @hw: pointer to hardware structure
1581 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1583 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1588 DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1590 status = ixgbe_identify_module_generic(hw);
1592 if (status != IXGBE_SUCCESS)
1595 /* Check if SFP module is supported */
1596 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1602 * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1603 * @hw: pointer to hardware structure
1605 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1610 DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1612 /* Check if SFP module is supported */
1613 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1615 if (status != IXGBE_SUCCESS)
1618 ixgbe_init_mac_link_ops_X550em(hw);
1619 hw->phy.ops.reset = NULL;
1621 return IXGBE_SUCCESS;
1625 * ixgbe_restart_an_internal_phy_x550em - restart autonegotiation for the
1627 * @hw: pointer to hardware structure
1629 STATIC s32 ixgbe_restart_an_internal_phy_x550em(struct ixgbe_hw *hw)
1634 /* Restart auto-negotiation. */
1635 status = hw->mac.ops.read_iosf_sb_reg(hw,
1636 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1637 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_ctrl);
1640 DEBUGOUT("Auto-negotiation did not complete\n");
1644 link_ctrl |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1645 status = hw->mac.ops.write_iosf_sb_reg(hw,
1646 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1647 IXGBE_SB_IOSF_TARGET_KR_PHY, link_ctrl);
1649 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1652 /* Indicate to FW that AN restart has been asserted */
1653 status = hw->mac.ops.read_iosf_sb_reg(hw,
1654 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1655 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_mask_st20);
1658 DEBUGOUT("Auto-negotiation did not complete\n");
1662 flx_mask_st20 |= IXGBE_KRM_PMD_FLX_MASK_ST20_FW_AN_RESTART;
1663 status = hw->mac.ops.write_iosf_sb_reg(hw,
1664 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1665 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_mask_st20);
1671 #ifndef PREBOOT_SUPPORT
1673 * ixgbe_setup_sgmii - Set up link for sgmii
1674 * @hw: pointer to hardware structure
1675 * @speed: new link speed
1676 * @autoneg_wait: true when waiting for completion is needed
1678 STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
1681 struct ixgbe_mac_info *mac = &hw->mac;
1682 u32 lval, sval, flx_val;
1685 rc = mac->ops.read_iosf_sb_reg(hw,
1686 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1687 IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
1691 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1692 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1693 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
1694 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
1695 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1696 rc = mac->ops.write_iosf_sb_reg(hw,
1697 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1698 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1702 rc = mac->ops.read_iosf_sb_reg(hw,
1703 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1704 IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
1708 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
1709 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
1710 rc = mac->ops.write_iosf_sb_reg(hw,
1711 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1712 IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
1716 rc = mac->ops.read_iosf_sb_reg(hw,
1717 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1718 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
1722 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
1723 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
1724 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
1725 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
1726 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
1728 rc = mac->ops.write_iosf_sb_reg(hw,
1729 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1730 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
1734 rc = ixgbe_restart_an_internal_phy_x550em(hw);
1738 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
1741 #endif /* PREBOOT_SUPPORT */
1743 * ixgbe_setup_sgmii_fw - Set up link for internal PHY SGMII auto-negotiation
1744 * @hw: pointer to hardware structure
1745 * @speed: new link speed
1746 * @autoneg_wait: true when waiting for completion is needed
1748 STATIC s32 ixgbe_setup_sgmii_fw(struct ixgbe_hw *hw, ixgbe_link_speed speed,
1751 struct ixgbe_mac_info *mac = &hw->mac;
1752 u32 lval, sval, flx_val;
1755 rc = mac->ops.read_iosf_sb_reg(hw,
1756 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1757 IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
1761 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1762 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1763 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
1764 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
1765 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1766 rc = mac->ops.write_iosf_sb_reg(hw,
1767 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1768 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1772 rc = mac->ops.read_iosf_sb_reg(hw,
1773 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1774 IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
1778 sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
1779 sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
1780 rc = mac->ops.write_iosf_sb_reg(hw,
1781 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1782 IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
1786 rc = mac->ops.write_iosf_sb_reg(hw,
1787 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1788 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1792 rc = mac->ops.read_iosf_sb_reg(hw,
1793 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1794 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
1798 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
1799 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
1800 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
1801 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
1802 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
1804 rc = mac->ops.write_iosf_sb_reg(hw,
1805 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1806 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
1810 rc = ixgbe_restart_an_internal_phy_x550em(hw);
1812 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
1816 * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1817 * @hw: pointer to hardware structure
1819 void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1821 struct ixgbe_mac_info *mac = &hw->mac;
1823 DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1825 switch (hw->mac.ops.get_media_type(hw)) {
1826 case ixgbe_media_type_fiber:
1827 /* CS4227 does not support autoneg, so disable the laser control
1828 * functions for SFP+ fiber
1830 mac->ops.disable_tx_laser = NULL;
1831 mac->ops.enable_tx_laser = NULL;
1832 mac->ops.flap_tx_laser = NULL;
1833 mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1834 mac->ops.set_rate_select_speed =
1835 ixgbe_set_soft_rate_select_speed;
1837 if ((hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) ||
1838 (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP))
1839 mac->ops.setup_mac_link =
1840 ixgbe_setup_mac_link_sfp_x550a;
1842 mac->ops.setup_mac_link =
1843 ixgbe_setup_mac_link_sfp_x550em;
1845 case ixgbe_media_type_copper:
1846 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T)
1848 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1849 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T ||
1850 hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) {
1851 mac->ops.setup_link = ixgbe_setup_sgmii_fw;
1852 mac->ops.check_link =
1853 ixgbe_check_mac_link_generic;
1855 mac->ops.setup_link =
1856 ixgbe_setup_mac_link_t_X550em;
1859 mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1860 mac->ops.check_link = ixgbe_check_link_t_X550em;
1863 case ixgbe_media_type_backplane:
1864 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
1865 hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
1866 #ifdef PREBOOT_SUPPORT
1867 mac->ops.setup_link = ixgbe_setup_sgmii_fw;
1869 mac->ops.setup_link = ixgbe_setup_sgmii;
1870 #endif /* PREBOOT_SUPPORT */
1878 * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1879 * @hw: pointer to hardware structure
1880 * @speed: pointer to link speed
1881 * @autoneg: true when autoneg or autotry is enabled
1883 s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1884 ixgbe_link_speed *speed,
1887 DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1890 if (hw->phy.type == ixgbe_phy_fw) {
1892 *speed = hw->phy.speeds_supported;
1897 if (hw->phy.media_type == ixgbe_media_type_fiber) {
1899 /* CS4227 SFP must not enable auto-negotiation */
1902 /* Check if 1G SFP module. */
1903 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1904 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1905 || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1906 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1907 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1908 return IXGBE_SUCCESS;
1911 /* Link capabilities are based on SFP */
1912 if (hw->phy.multispeed_fiber)
1913 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1914 IXGBE_LINK_SPEED_1GB_FULL;
1916 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1918 switch (hw->phy.type) {
1919 case ixgbe_phy_ext_1g_t:
1920 #ifdef PREBOOT_SUPPORT
1921 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1923 #endif /* PREBOOT_SUPPORT */
1924 case ixgbe_phy_sgmii:
1925 #ifdef PREBOOT_SUPPORT
1926 *speed = IXGBE_LINK_SPEED_1GB_FULL |
1927 IXGBE_LINK_SPEED_100_FULL |
1928 IXGBE_LINK_SPEED_10_FULL;
1930 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1931 #endif /* PREBOOT_SUPPORT */
1933 case ixgbe_phy_x550em_kr:
1934 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1935 /* check different backplane modes */
1936 if (hw->phy.nw_mng_if_sel &
1937 IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
1938 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
1940 } else if (hw->device_id ==
1941 IXGBE_DEV_ID_X550EM_A_KR_L) {
1942 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1948 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1949 IXGBE_LINK_SPEED_1GB_FULL;
1955 return IXGBE_SUCCESS;
1959 * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
1960 * @hw: pointer to hardware structure
1961 * @lsc: pointer to boolean flag which indicates whether external Base T
1962 * PHY interrupt is lsc
1964 * Determime if external Base T PHY interrupt cause is high temperature
1965 * failure alarm or link status change.
1967 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
1968 * failure alarm, else return PHY access status.
1970 STATIC s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
1977 /* Vendor alarm triggered */
1978 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1979 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1982 if (status != IXGBE_SUCCESS ||
1983 !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
1986 /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
1987 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
1988 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1991 if (status != IXGBE_SUCCESS ||
1992 !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1993 IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
1996 /* Global alarm triggered */
1997 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
1998 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2001 if (status != IXGBE_SUCCESS)
2004 /* If high temperature failure, then return over temp error and exit */
2005 if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
2006 /* power down the PHY in case the PHY FW didn't already */
2007 ixgbe_set_copper_phy_power(hw, false);
2008 return IXGBE_ERR_OVERTEMP;
2009 } else if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
2010 /* device fault alarm triggered */
2011 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
2012 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2015 if (status != IXGBE_SUCCESS)
2018 /* if device fault was due to high temp alarm handle and exit */
2019 if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
2020 /* power down the PHY in case the PHY FW didn't */
2021 ixgbe_set_copper_phy_power(hw, false);
2022 return IXGBE_ERR_OVERTEMP;
2026 /* Vendor alarm 2 triggered */
2027 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
2028 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2030 if (status != IXGBE_SUCCESS ||
2031 !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
2034 /* link connect/disconnect event occurred */
2035 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
2036 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2038 if (status != IXGBE_SUCCESS)
2042 if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
2045 return IXGBE_SUCCESS;
2049 * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
2050 * @hw: pointer to hardware structure
2052 * Enable link status change and temperature failure alarm for the external
2055 * Returns PHY access status
2057 STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
2063 /* Clear interrupt flags */
2064 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
2066 /* Enable link status change alarm */
2068 /* Enable the LASI interrupts on X552 devices to receive notifications
2069 * of the link configurations of the external PHY and correspondingly
2070 * support the configuration of the internal iXFI link, since iXFI does
2071 * not support auto-negotiation. This is not required for X553 devices
2072 * having KR support, which performs auto-negotiations and which is used
2073 * as the internal link to the external PHY. Hence adding a check here
2074 * to avoid enabling LASI interrupts for X553 devices.
2076 if (hw->mac.type != ixgbe_mac_X550EM_a) {
2077 status = hw->phy.ops.read_reg(hw,
2078 IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
2079 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2081 if (status != IXGBE_SUCCESS)
2084 reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
2086 status = hw->phy.ops.write_reg(hw,
2087 IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
2088 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
2090 if (status != IXGBE_SUCCESS)
2094 /* Enable high temperature failure and global fault alarms */
2095 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
2096 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2099 if (status != IXGBE_SUCCESS)
2102 reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
2103 IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
2105 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
2106 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2109 if (status != IXGBE_SUCCESS)
2112 /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
2113 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
2114 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2117 if (status != IXGBE_SUCCESS)
2120 reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
2121 IXGBE_MDIO_GLOBAL_ALARM_1_INT);
2123 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
2124 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2127 if (status != IXGBE_SUCCESS)
2130 /* Enable chip-wide vendor alarm */
2131 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
2132 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2135 if (status != IXGBE_SUCCESS)
2138 reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
2140 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
2141 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2148 * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
2149 * @hw: pointer to hardware structure
2150 * @speed: link speed
2152 * Configures the integrated KR PHY.
2154 STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
2155 ixgbe_link_speed speed)
2160 status = hw->mac.ops.read_iosf_sb_reg(hw,
2161 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2162 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2166 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2167 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
2168 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
2170 /* Advertise 10G support. */
2171 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
2172 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
2174 /* Advertise 1G support. */
2175 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
2176 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
2178 status = hw->mac.ops.write_iosf_sb_reg(hw,
2179 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2180 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2182 if (hw->mac.type == ixgbe_mac_X550EM_a) {
2183 /* Set lane mode to KR auto negotiation */
2184 status = hw->mac.ops.read_iosf_sb_reg(hw,
2185 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2186 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2191 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
2192 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
2193 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
2194 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
2195 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
2197 status = hw->mac.ops.write_iosf_sb_reg(hw,
2198 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2199 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2202 return ixgbe_restart_an_internal_phy_x550em(hw);
2206 * ixgbe_reset_phy_fw - Reset firmware-controlled PHYs
2207 * @hw: pointer to hardware structure
2209 static s32 ixgbe_reset_phy_fw(struct ixgbe_hw *hw)
2211 u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
2214 if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
2215 return IXGBE_SUCCESS;
2217 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_PHY_SW_RESET, &store);
2220 memset(store, 0, sizeof(store));
2222 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_INIT_PHY, &store);
2226 return ixgbe_setup_fw_link(hw);
2230 * ixgbe_check_overtemp_fw - Check firmware-controlled PHYs for overtemp
2231 * @hw: pointer to hardware structure
2233 static s32 ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
2235 u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
2238 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &store);
2242 if (store[0] & FW_PHY_ACT_GET_LINK_INFO_TEMP) {
2243 ixgbe_shutdown_fw_phy(hw);
2244 return IXGBE_ERR_OVERTEMP;
2246 return IXGBE_SUCCESS;
2250 * ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
2251 * @hw: pointer to hardware structure
2253 * Read NW_MNG_IF_SEL register and save field values, and check for valid field
2256 STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
2258 /* Save NW management interface connected on board. This is used
2259 * to determine internal PHY mode.
2261 hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
2263 /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
2264 * PHY address. This register field was has only been used for X552.
2266 if (hw->mac.type == ixgbe_mac_X550EM_a &&
2267 hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
2268 hw->phy.addr = (hw->phy.nw_mng_if_sel &
2269 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
2270 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
2273 return IXGBE_SUCCESS;
2277 * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
2278 * @hw: pointer to hardware structure
2280 * Initialize any function pointers that were not able to be
2281 * set during init_shared_code because the PHY/SFP type was
2282 * not known. Perform the SFP init if necessary.
2284 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
2286 struct ixgbe_phy_info *phy = &hw->phy;
2289 DEBUGFUNC("ixgbe_init_phy_ops_X550em");
2291 hw->mac.ops.set_lan_id(hw);
2292 ixgbe_read_mng_if_sel_x550em(hw);
2294 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
2295 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
2296 ixgbe_setup_mux_ctl(hw);
2297 phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
2300 switch (hw->device_id) {
2301 case IXGBE_DEV_ID_X550EM_A_1G_T:
2302 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
2303 phy->ops.read_reg_mdi = NULL;
2304 phy->ops.write_reg_mdi = NULL;
2305 hw->phy.ops.read_reg = NULL;
2306 hw->phy.ops.write_reg = NULL;
2307 phy->ops.check_overtemp = ixgbe_check_overtemp_fw;
2309 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
2311 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
2314 case IXGBE_DEV_ID_X550EM_A_10G_T:
2315 case IXGBE_DEV_ID_X550EM_A_SFP:
2316 hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
2317 hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
2319 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
2321 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
2323 case IXGBE_DEV_ID_X550EM_X_SFP:
2324 /* set up for CS4227 usage */
2325 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
2327 case IXGBE_DEV_ID_X550EM_X_1G_T:
2328 phy->ops.read_reg_mdi = NULL;
2329 phy->ops.write_reg_mdi = NULL;
2334 /* Identify the PHY or SFP module */
2335 ret_val = phy->ops.identify(hw);
2336 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED ||
2337 ret_val == IXGBE_ERR_PHY_ADDR_INVALID)
2340 /* Setup function pointers based on detected hardware */
2341 ixgbe_init_mac_link_ops_X550em(hw);
2342 if (phy->sfp_type != ixgbe_sfp_type_unknown)
2343 phy->ops.reset = NULL;
2345 /* Set functions pointers based on phy type */
2346 switch (hw->phy.type) {
2347 case ixgbe_phy_x550em_kx4:
2348 phy->ops.setup_link = NULL;
2349 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2350 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2352 case ixgbe_phy_x550em_kr:
2353 phy->ops.setup_link = ixgbe_setup_kr_x550em;
2354 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2355 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2357 case ixgbe_phy_ext_1g_t:
2358 /* link is managed by FW */
2359 phy->ops.setup_link = NULL;
2360 phy->ops.reset = NULL;
2362 case ixgbe_phy_x550em_xfi:
2363 /* link is managed by HW */
2364 phy->ops.setup_link = NULL;
2365 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2366 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2368 case ixgbe_phy_x550em_ext_t:
2369 /* If internal link mode is XFI, then setup iXFI internal link,
2370 * else setup KR now.
2372 phy->ops.setup_internal_link =
2373 ixgbe_setup_internal_phy_t_x550em;
2375 /* setup SW LPLU only for first revision of X550EM_x */
2376 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
2377 !(IXGBE_FUSES0_REV_MASK &
2378 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
2379 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
2381 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
2382 phy->ops.reset = ixgbe_reset_phy_t_X550em;
2384 case ixgbe_phy_sgmii:
2385 phy->ops.setup_link = NULL;
2388 phy->ops.setup_link = ixgbe_setup_fw_link;
2389 phy->ops.reset = ixgbe_reset_phy_fw;
2398 * ixgbe_set_mdio_speed - Set MDIO clock speed
2399 * @hw: pointer to hardware structure
2401 STATIC void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
2405 switch (hw->device_id) {
2406 case IXGBE_DEV_ID_X550EM_X_10G_T:
2407 case IXGBE_DEV_ID_X550EM_A_SGMII:
2408 case IXGBE_DEV_ID_X550EM_A_SGMII_L:
2409 case IXGBE_DEV_ID_X550EM_A_10G_T:
2410 case IXGBE_DEV_ID_X550EM_A_SFP:
2411 case IXGBE_DEV_ID_X550EM_A_QSFP:
2412 /* Config MDIO clock speed before the first MDIO PHY access */
2413 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
2414 hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
2415 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
2417 case IXGBE_DEV_ID_X550EM_A_1G_T:
2418 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
2419 /* Select fast MDIO clock speed for these devices */
2420 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
2421 hlreg0 |= IXGBE_HLREG0_MDCSPD;
2422 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
2430 * ixgbe_reset_hw_X550em - Perform hardware reset
2431 * @hw: pointer to hardware structure
2433 * Resets the hardware by resetting the transmit and receive units, masks
2434 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
2437 s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
2439 ixgbe_link_speed link_speed;
2443 bool link_up = false;
2444 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2446 DEBUGFUNC("ixgbe_reset_hw_X550em");
2448 /* Call adapter stop to disable Tx/Rx and clear interrupts */
2449 status = hw->mac.ops.stop_adapter(hw);
2450 if (status != IXGBE_SUCCESS) {
2451 DEBUGOUT1("Failed to stop adapter, STATUS = %d\n", status);
2454 /* flush pending Tx transactions */
2455 ixgbe_clear_tx_pending(hw);
2457 ixgbe_set_mdio_speed(hw);
2459 /* PHY ops must be identified and initialized prior to reset */
2460 status = hw->phy.ops.init(hw);
2463 DEBUGOUT1("Failed to initialize PHY ops, STATUS = %d\n",
2466 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED ||
2467 status == IXGBE_ERR_PHY_ADDR_INVALID) {
2468 DEBUGOUT("Returning from reset HW due to PHY init failure\n");
2472 /* start the external PHY */
2473 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
2474 status = ixgbe_init_ext_t_x550em(hw);
2476 DEBUGOUT1("Failed to start the external PHY, STATUS = %d\n",
2482 /* Setup SFP module if there is one present. */
2483 if (hw->phy.sfp_setup_needed) {
2484 status = hw->mac.ops.setup_sfp(hw);
2485 hw->phy.sfp_setup_needed = false;
2488 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
2492 if (!hw->phy.reset_disable && hw->phy.ops.reset) {
2493 if (hw->phy.ops.reset(hw) == IXGBE_ERR_OVERTEMP)
2494 return IXGBE_ERR_OVERTEMP;
2498 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
2499 * If link reset is used when link is up, it might reset the PHY when
2500 * mng is using it. If link is down or the flag to force full link
2501 * reset is set, then perform link reset.
2503 ctrl = IXGBE_CTRL_LNK_RST;
2504 if (!hw->force_full_reset) {
2505 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
2507 ctrl = IXGBE_CTRL_RST;
2510 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
2511 if (status != IXGBE_SUCCESS) {
2512 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
2513 "semaphore failed with %d", status);
2514 return IXGBE_ERR_SWFW_SYNC;
2516 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
2517 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
2518 IXGBE_WRITE_FLUSH(hw);
2519 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2521 /* Poll for reset bit to self-clear meaning reset is complete */
2522 for (i = 0; i < 10; i++) {
2524 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
2525 if (!(ctrl & IXGBE_CTRL_RST_MASK))
2529 if (ctrl & IXGBE_CTRL_RST_MASK) {
2530 status = IXGBE_ERR_RESET_FAILED;
2531 DEBUGOUT("Reset polling failed to complete.\n");
2536 /* Double resets are required for recovery from certain error
2537 * conditions. Between resets, it is necessary to stall to
2538 * allow time for any pending HW events to complete.
2540 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
2541 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
2545 /* Store the permanent mac address */
2546 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
2548 /* Store MAC address from RAR0, clear receive address registers, and
2549 * clear the multicast table. Also reset num_rar_entries to 128,
2550 * since we modify this value when programming the SAN MAC address.
2552 hw->mac.num_rar_entries = 128;
2553 hw->mac.ops.init_rx_addrs(hw);
2555 ixgbe_set_mdio_speed(hw);
2557 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
2558 ixgbe_setup_mux_ctl(hw);
2560 if (status != IXGBE_SUCCESS)
2561 DEBUGOUT1("Reset HW failed, STATUS = %d\n", status);
2567 * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
2568 * @hw: pointer to hardware structure
2570 s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
2575 status = hw->phy.ops.read_reg(hw,
2576 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
2577 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2580 if (status != IXGBE_SUCCESS)
2583 /* If PHY FW reset completed bit is set then this is the first
2584 * SW instance after a power on so the PHY FW must be un-stalled.
2586 if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
2587 status = hw->phy.ops.read_reg(hw,
2588 IXGBE_MDIO_GLOBAL_RES_PR_10,
2589 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2592 if (status != IXGBE_SUCCESS)
2595 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
2597 status = hw->phy.ops.write_reg(hw,
2598 IXGBE_MDIO_GLOBAL_RES_PR_10,
2599 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2602 if (status != IXGBE_SUCCESS)
2610 * ixgbe_setup_kr_x550em - Configure the KR PHY.
2611 * @hw: pointer to hardware structure
2613 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
2615 /* leave link alone for 2.5G */
2616 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
2617 return IXGBE_SUCCESS;
2619 if (ixgbe_check_reset_blocked(hw))
2622 return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
2626 * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
2627 * @hw: pointer to hardware structure
2628 * @speed: new link speed
2629 * @autoneg_wait_to_complete: unused
2631 * Configure the external PHY and the integrated KR PHY for SFP support.
2633 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
2634 ixgbe_link_speed speed,
2635 bool autoneg_wait_to_complete)
2638 u16 reg_slice, reg_val;
2639 bool setup_linear = false;
2640 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2642 /* Check if SFP module is supported and linear */
2643 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2645 /* If no SFP module present, then return success. Return success since
2646 * there is no reason to configure CS4227 and SFP not present error is
2647 * not excepted in the setup MAC link flow.
2649 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2650 return IXGBE_SUCCESS;
2652 if (ret_val != IXGBE_SUCCESS)
2655 /* Configure internal PHY for KR/KX. */
2656 ixgbe_setup_kr_speed_x550em(hw, speed);
2658 /* Configure CS4227 LINE side to proper mode. */
2659 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
2660 (hw->bus.lan_id << 12);
2662 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2664 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2665 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2671 * ixgbe_setup_sfi_x550a - Configure the internal PHY for native SFI mode
2672 * @hw: pointer to hardware structure
2673 * @speed: the link speed to force
2675 * Configures the integrated PHY for native SFI mode. Used to connect the
2676 * internal PHY directly to an SFP cage, without autonegotiation.
2678 STATIC s32 ixgbe_setup_sfi_x550a(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2680 struct ixgbe_mac_info *mac = &hw->mac;
2684 /* Disable all AN and force speed to 10G Serial. */
2685 status = mac->ops.read_iosf_sb_reg(hw,
2686 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2687 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2688 if (status != IXGBE_SUCCESS)
2691 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
2692 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
2693 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
2694 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
2696 /* Select forced link speed for internal PHY. */
2698 case IXGBE_LINK_SPEED_10GB_FULL:
2699 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_10G;
2701 case IXGBE_LINK_SPEED_1GB_FULL:
2702 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
2705 /* Other link speeds are not supported by internal PHY. */
2706 return IXGBE_ERR_LINK_SETUP;
2709 status = mac->ops.write_iosf_sb_reg(hw,
2710 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2711 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2713 /* Toggle port SW reset by AN reset. */
2714 status = ixgbe_restart_an_internal_phy_x550em(hw);
2720 * ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
2721 * @hw: pointer to hardware structure
2722 * @speed: new link speed
2723 * @autoneg_wait_to_complete: unused
2725 * Configure the integrated PHY for SFP support.
2727 s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
2728 ixgbe_link_speed speed,
2729 bool autoneg_wait_to_complete)
2733 bool setup_linear = false;
2734 u32 reg_slice, reg_phy_int, slice_offset;
2736 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2738 /* Check if SFP module is supported and linear */
2739 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2741 /* If no SFP module present, then return success. Return success since
2742 * SFP not present error is not excepted in the setup MAC link flow.
2744 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2745 return IXGBE_SUCCESS;
2747 if (ret_val != IXGBE_SUCCESS)
2750 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) {
2751 /* Configure internal PHY for native SFI based on module type */
2752 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
2753 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2754 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_phy_int);
2756 if (ret_val != IXGBE_SUCCESS)
2759 reg_phy_int &= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_DA;
2761 reg_phy_int |= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_SR;
2763 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
2764 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2765 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_phy_int);
2767 if (ret_val != IXGBE_SUCCESS)
2770 /* Setup SFI internal link. */
2771 ret_val = ixgbe_setup_sfi_x550a(hw, &speed);
2773 /* Configure internal PHY for KR/KX. */
2774 ixgbe_setup_kr_speed_x550em(hw, speed);
2776 if (hw->phy.addr == 0x0 || hw->phy.addr == 0xFFFF) {
2778 DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
2779 return IXGBE_ERR_PHY_ADDR_INVALID;
2782 /* Get external PHY SKU id */
2783 ret_val = hw->phy.ops.read_reg(hw, IXGBE_CS4227_EFUSE_PDF_SKU,
2784 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2786 if (ret_val != IXGBE_SUCCESS)
2789 /* When configuring quad port CS4223, the MAC instance is part
2790 * of the slice offset.
2792 if (reg_phy_ext == IXGBE_CS4223_SKU_ID)
2793 slice_offset = (hw->bus.lan_id +
2794 (hw->bus.instance_id << 1)) << 12;
2796 slice_offset = hw->bus.lan_id << 12;
2798 /* Configure CS4227/CS4223 LINE side to proper mode. */
2799 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
2801 ret_val = hw->phy.ops.read_reg(hw, reg_slice,
2802 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2804 if (ret_val != IXGBE_SUCCESS)
2807 reg_phy_ext &= ~((IXGBE_CS4227_EDC_MODE_CX1 << 1) |
2808 (IXGBE_CS4227_EDC_MODE_SR << 1));
2811 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2813 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2814 ret_val = hw->phy.ops.write_reg(hw, reg_slice,
2815 IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
2817 /* Flush previous write with a read */
2818 ret_val = hw->phy.ops.read_reg(hw, reg_slice,
2819 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2825 * ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
2826 * @hw: pointer to hardware structure
2828 * iXfI configuration needed for ixgbe_mac_X550EM_x devices.
2830 STATIC s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
2832 struct ixgbe_mac_info *mac = &hw->mac;
2836 /* Disable training protocol FSM. */
2837 status = mac->ops.read_iosf_sb_reg(hw,
2838 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2839 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2840 if (status != IXGBE_SUCCESS)
2842 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
2843 status = mac->ops.write_iosf_sb_reg(hw,
2844 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2845 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2846 if (status != IXGBE_SUCCESS)
2849 /* Disable Flex from training TXFFE. */
2850 status = mac->ops.read_iosf_sb_reg(hw,
2851 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2852 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2853 if (status != IXGBE_SUCCESS)
2855 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2856 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2857 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2858 status = mac->ops.write_iosf_sb_reg(hw,
2859 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2860 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2861 if (status != IXGBE_SUCCESS)
2863 status = mac->ops.read_iosf_sb_reg(hw,
2864 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2865 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2866 if (status != IXGBE_SUCCESS)
2868 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2869 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2870 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2871 status = mac->ops.write_iosf_sb_reg(hw,
2872 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2873 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2874 if (status != IXGBE_SUCCESS)
2877 /* Enable override for coefficients. */
2878 status = mac->ops.read_iosf_sb_reg(hw,
2879 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2880 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2881 if (status != IXGBE_SUCCESS)
2883 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
2884 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
2885 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
2886 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
2887 status = mac->ops.write_iosf_sb_reg(hw,
2888 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2889 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2894 * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
2895 * @hw: pointer to hardware structure
2896 * @speed: the link speed to force
2898 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
2899 * internal and external PHY at a specific speed, without autonegotiation.
2901 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2903 struct ixgbe_mac_info *mac = &hw->mac;
2907 /* iXFI is only supported with X552 */
2908 if (mac->type != ixgbe_mac_X550EM_x)
2909 return IXGBE_ERR_LINK_SETUP;
2911 /* Disable AN and force speed to 10G Serial. */
2912 status = mac->ops.read_iosf_sb_reg(hw,
2913 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2914 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2915 if (status != IXGBE_SUCCESS)
2918 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2919 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2921 /* Select forced link speed for internal PHY. */
2923 case IXGBE_LINK_SPEED_10GB_FULL:
2924 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2926 case IXGBE_LINK_SPEED_1GB_FULL:
2927 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
2930 /* Other link speeds are not supported by internal KR PHY. */
2931 return IXGBE_ERR_LINK_SETUP;
2934 status = mac->ops.write_iosf_sb_reg(hw,
2935 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2936 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2937 if (status != IXGBE_SUCCESS)
2940 /* Additional configuration needed for x550em_x */
2941 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2942 status = ixgbe_setup_ixfi_x550em_x(hw);
2943 if (status != IXGBE_SUCCESS)
2947 /* Toggle port SW reset by AN reset. */
2948 status = ixgbe_restart_an_internal_phy_x550em(hw);
2954 * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
2955 * @hw: address of hardware structure
2956 * @link_up: address of boolean to indicate link status
2958 * Returns error code if unable to get link status.
2960 STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
2967 /* read this twice back to back to indicate current status */
2968 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
2969 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2971 if (ret != IXGBE_SUCCESS)
2974 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
2975 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2977 if (ret != IXGBE_SUCCESS)
2980 *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
2982 return IXGBE_SUCCESS;
2986 * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
2987 * @hw: point to hardware structure
2989 * Configures the link between the integrated KR PHY and the external X557 PHY
2990 * The driver will call this function when it gets a link status change
2991 * interrupt from the X557 PHY. This function configures the link speed
2992 * between the PHYs to match the link speed of the BASE-T link.
2994 * A return of a non-zero value indicates an error, and the base driver should
2995 * not report link up.
2997 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
2999 ixgbe_link_speed force_speed;
3004 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
3005 return IXGBE_ERR_CONFIG;
3007 if (hw->mac.type == ixgbe_mac_X550EM_x &&
3008 !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
3009 /* If link is down, there is no setup necessary so return */
3010 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3011 if (status != IXGBE_SUCCESS)
3015 return IXGBE_SUCCESS;
3017 status = hw->phy.ops.read_reg(hw,
3018 IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
3019 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3021 if (status != IXGBE_SUCCESS)
3024 /* If link is still down - no setup is required so return */
3025 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3026 if (status != IXGBE_SUCCESS)
3029 return IXGBE_SUCCESS;
3031 /* clear everything but the speed and duplex bits */
3032 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
3035 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
3036 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
3038 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
3039 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
3042 /* Internal PHY does not support anything else */
3043 return IXGBE_ERR_INVALID_LINK_SETTINGS;
3046 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
3048 speed = IXGBE_LINK_SPEED_10GB_FULL |
3049 IXGBE_LINK_SPEED_1GB_FULL;
3050 return ixgbe_setup_kr_speed_x550em(hw, speed);
3055 * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
3056 * @hw: pointer to hardware structure
3058 * Configures the integrated KR PHY to use internal loopback mode.
3060 s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
3065 /* Disable AN and force speed to 10G Serial. */
3066 status = hw->mac.ops.read_iosf_sb_reg(hw,
3067 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
3068 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3069 if (status != IXGBE_SUCCESS)
3071 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
3072 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
3073 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
3074 status = hw->mac.ops.write_iosf_sb_reg(hw,
3075 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
3076 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3077 if (status != IXGBE_SUCCESS)
3080 /* Set near-end loopback clocks. */
3081 status = hw->mac.ops.read_iosf_sb_reg(hw,
3082 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
3083 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3084 if (status != IXGBE_SUCCESS)
3086 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
3087 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
3088 status = hw->mac.ops.write_iosf_sb_reg(hw,
3089 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
3090 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3091 if (status != IXGBE_SUCCESS)
3094 /* Set loopback enable. */
3095 status = hw->mac.ops.read_iosf_sb_reg(hw,
3096 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
3097 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3098 if (status != IXGBE_SUCCESS)
3100 reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
3101 status = hw->mac.ops.write_iosf_sb_reg(hw,
3102 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
3103 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3104 if (status != IXGBE_SUCCESS)
3107 /* Training bypass. */
3108 status = hw->mac.ops.read_iosf_sb_reg(hw,
3109 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
3110 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3111 if (status != IXGBE_SUCCESS)
3113 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
3114 status = hw->mac.ops.write_iosf_sb_reg(hw,
3115 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
3116 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3122 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
3123 * assuming that the semaphore is already obtained.
3124 * @hw: pointer to hardware structure
3125 * @offset: offset of word in the EEPROM to read
3126 * @data: word read from the EEPROM
3128 * Reads a 16 bit word from the EEPROM using the hostif.
3130 s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 *data)
3132 const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
3133 struct ixgbe_hic_read_shadow_ram buffer;
3136 DEBUGFUNC("ixgbe_read_ee_hostif_X550");
3137 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
3138 buffer.hdr.req.buf_lenh = 0;
3139 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
3140 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3142 /* convert offset from words to bytes */
3143 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
3145 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
3149 status = hw->mac.ops.acquire_swfw_sync(hw, mask);
3153 status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
3154 IXGBE_HI_COMMAND_TIMEOUT);
3156 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
3157 FW_NVM_DATA_OFFSET);
3160 hw->mac.ops.release_swfw_sync(hw, mask);
3165 * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
3166 * @hw: pointer to hardware structure
3167 * @offset: offset of word in the EEPROM to read
3168 * @words: number of words
3169 * @data: word(s) read from the EEPROM
3171 * Reads a 16 bit word(s) from the EEPROM using the hostif.
3173 s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
3174 u16 offset, u16 words, u16 *data)
3176 const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
3177 struct ixgbe_hic_read_shadow_ram buffer;
3178 u32 current_word = 0;
3183 DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
3185 /* Take semaphore for the entire operation. */
3186 status = hw->mac.ops.acquire_swfw_sync(hw, mask);
3188 DEBUGOUT("EEPROM read buffer - semaphore failed\n");
3193 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
3194 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
3196 words_to_read = words;
3198 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
3199 buffer.hdr.req.buf_lenh = 0;
3200 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
3201 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3203 /* convert offset from words to bytes */
3204 buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
3205 buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
3209 status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
3210 IXGBE_HI_COMMAND_TIMEOUT);
3213 DEBUGOUT("Host interface command failed\n");
3217 for (i = 0; i < words_to_read; i++) {
3218 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
3220 u32 value = IXGBE_READ_REG(hw, reg);
3222 data[current_word] = (u16)(value & 0xffff);
3225 if (i < words_to_read) {
3227 data[current_word] = (u16)(value & 0xffff);
3231 words -= words_to_read;
3235 hw->mac.ops.release_swfw_sync(hw, mask);
3240 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
3241 * @hw: pointer to hardware structure
3242 * @offset: offset of word in the EEPROM to write
3243 * @data: word write to the EEPROM
3245 * Write a 16 bit word to the EEPROM using the hostif.
3247 s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
3251 struct ixgbe_hic_write_shadow_ram buffer;
3253 DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
3255 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
3256 buffer.hdr.req.buf_lenh = 0;
3257 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
3258 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3261 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
3263 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
3265 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
3267 IXGBE_HI_COMMAND_TIMEOUT, false);
3273 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
3274 * @hw: pointer to hardware structure
3275 * @offset: offset of word in the EEPROM to write
3276 * @data: word write to the EEPROM
3278 * Write a 16 bit word to the EEPROM using the hostif.
3280 s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
3283 s32 status = IXGBE_SUCCESS;
3285 DEBUGFUNC("ixgbe_write_ee_hostif_X550");
3287 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
3289 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
3290 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3292 DEBUGOUT("write ee hostif failed to get semaphore");
3293 status = IXGBE_ERR_SWFW_SYNC;
3300 * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
3301 * @hw: pointer to hardware structure
3302 * @offset: offset of word in the EEPROM to write
3303 * @words: number of words
3304 * @data: word(s) write to the EEPROM
3306 * Write a 16 bit word(s) to the EEPROM using the hostif.
3308 s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
3309 u16 offset, u16 words, u16 *data)
3311 s32 status = IXGBE_SUCCESS;
3314 DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
3316 /* Take semaphore for the entire operation. */
3317 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3318 if (status != IXGBE_SUCCESS) {
3319 DEBUGOUT("EEPROM write buffer - semaphore failed\n");
3323 for (i = 0; i < words; i++) {
3324 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
3327 if (status != IXGBE_SUCCESS) {
3328 DEBUGOUT("Eeprom buffered write failed\n");
3333 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3340 * ixgbe_checksum_ptr_x550 - Checksum one pointer region
3341 * @hw: pointer to hardware structure
3342 * @ptr: pointer offset in eeprom
3343 * @size: size of section pointed by ptr, if 0 first word will be used as size
3344 * @csum: address of checksum to update
3345 * @buffer: pointer to buffer containing calculated checksum
3346 * @buffer_size: size of buffer
3348 * Returns error status for any failure
3350 STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
3351 u16 size, u16 *csum, u16 *buffer,
3356 u16 length, bufsz, i, start;
3359 bufsz = sizeof(buf) / sizeof(buf[0]);
3361 /* Read a chunk at the pointer location */
3363 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
3365 DEBUGOUT("Failed to read EEPROM image\n");
3370 if (buffer_size < ptr)
3371 return IXGBE_ERR_PARAM;
3372 local_buffer = &buffer[ptr];
3380 length = local_buffer[0];
3382 /* Skip pointer section if length is invalid. */
3383 if (length == 0xFFFF || length == 0 ||
3384 (ptr + length) >= hw->eeprom.word_size)
3385 return IXGBE_SUCCESS;
3388 if (buffer && ((u32)start + (u32)length > buffer_size))
3389 return IXGBE_ERR_PARAM;
3391 for (i = start; length; i++, length--) {
3392 if (i == bufsz && !buffer) {
3398 /* Read a chunk at the pointer location */
3399 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
3402 DEBUGOUT("Failed to read EEPROM image\n");
3406 *csum += local_buffer[i];
3408 return IXGBE_SUCCESS;
3412 * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
3413 * @hw: pointer to hardware structure
3414 * @buffer: pointer to buffer containing calculated checksum
3415 * @buffer_size: size of buffer
3417 * Returns a negative error code on error, or the 16-bit checksum
3419 s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
3421 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
3425 u16 pointer, i, size;
3427 DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
3429 hw->eeprom.ops.init_params(hw);
3432 /* Read pointer area */
3433 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
3434 IXGBE_EEPROM_LAST_WORD + 1,
3437 DEBUGOUT("Failed to read EEPROM image\n");
3440 local_buffer = eeprom_ptrs;
3442 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
3443 return IXGBE_ERR_PARAM;
3444 local_buffer = buffer;
3448 * For X550 hardware include 0x0-0x41 in the checksum, skip the
3449 * checksum word itself
3451 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
3452 if (i != IXGBE_EEPROM_CHECKSUM)
3453 checksum += local_buffer[i];
3456 * Include all data from pointers 0x3, 0x6-0xE. This excludes the
3457 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
3459 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
3460 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
3463 pointer = local_buffer[i];
3465 /* Skip pointer section if the pointer is invalid. */
3466 if (pointer == 0xFFFF || pointer == 0 ||
3467 pointer >= hw->eeprom.word_size)
3471 case IXGBE_PCIE_GENERAL_PTR:
3472 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
3474 case IXGBE_PCIE_CONFIG0_PTR:
3475 case IXGBE_PCIE_CONFIG1_PTR:
3476 size = IXGBE_PCIE_CONFIG_SIZE;
3483 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
3484 buffer, buffer_size);
3489 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
3491 return (s32)checksum;
3495 * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
3496 * @hw: pointer to hardware structure
3498 * Returns a negative error code on error, or the 16-bit checksum
3500 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
3502 return ixgbe_calc_checksum_X550(hw, NULL, 0);
3506 * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
3507 * @hw: pointer to hardware structure
3508 * @checksum_val: calculated checksum
3510 * Performs checksum calculation and validates the EEPROM checksum. If the
3511 * caller does not need checksum_val, the value can be NULL.
3513 s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
3517 u16 read_checksum = 0;
3519 DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
3521 /* Read the first word from the EEPROM. If this times out or fails, do
3522 * not continue or we could be in for a very long wait while every
3525 status = hw->eeprom.ops.read(hw, 0, &checksum);
3527 DEBUGOUT("EEPROM read failed\n");
3531 status = hw->eeprom.ops.calc_checksum(hw);
3535 checksum = (u16)(status & 0xffff);
3537 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3542 /* Verify read checksum from EEPROM is the same as
3543 * calculated checksum
3545 if (read_checksum != checksum) {
3546 status = IXGBE_ERR_EEPROM_CHECKSUM;
3547 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
3548 "Invalid EEPROM checksum");
3551 /* If the user cares, return the calculated checksum */
3553 *checksum_val = checksum;
3559 * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
3560 * @hw: pointer to hardware structure
3562 * After writing EEPROM to shadow RAM using EEWR register, software calculates
3563 * checksum and updates the EEPROM and instructs the hardware to update
3566 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
3571 DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
3573 /* Read the first word from the EEPROM. If this times out or fails, do
3574 * not continue or we could be in for a very long wait while every
3577 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
3579 DEBUGOUT("EEPROM read failed\n");
3583 status = ixgbe_calc_eeprom_checksum_X550(hw);
3587 checksum = (u16)(status & 0xffff);
3589 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3594 status = ixgbe_update_flash_X550(hw);
3600 * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
3601 * @hw: pointer to hardware structure
3603 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
3605 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
3607 s32 status = IXGBE_SUCCESS;
3608 union ixgbe_hic_hdr2 buffer;
3610 DEBUGFUNC("ixgbe_update_flash_X550");
3612 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
3613 buffer.req.buf_lenh = 0;
3614 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
3615 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
3617 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
3619 IXGBE_HI_COMMAND_TIMEOUT, false);
3625 * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
3626 * @hw: pointer to hardware structure
3628 * Determines physical layer capabilities of the current configuration.
3630 u64 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
3632 u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
3633 u16 ext_ability = 0;
3635 DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
3637 hw->phy.ops.identify(hw);
3639 switch (hw->phy.type) {
3640 case ixgbe_phy_x550em_kr:
3641 if (hw->mac.type == ixgbe_mac_X550EM_a) {
3642 if (hw->phy.nw_mng_if_sel &
3643 IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
3645 IXGBE_PHYSICAL_LAYER_2500BASE_KX;
3647 } else if (hw->device_id ==
3648 IXGBE_DEV_ID_X550EM_A_KR_L) {
3650 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3655 case ixgbe_phy_x550em_xfi:
3656 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
3657 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3659 case ixgbe_phy_x550em_kx4:
3660 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
3661 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3663 case ixgbe_phy_x550em_ext_t:
3664 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
3665 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
3667 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
3668 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
3669 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
3670 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3673 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_1GB_FULL)
3674 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3675 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_100_FULL)
3676 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
3677 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_10_FULL)
3678 physical_layer |= IXGBE_PHYSICAL_LAYER_10BASE_T;
3680 case ixgbe_phy_sgmii:
3681 #ifdef PREBOOT_SUPPORT
3682 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX |
3683 IXGBE_PHYSICAL_LAYER_100BASE_TX |
3684 IXGBE_PHYSICAL_LAYER_10BASE_T;
3686 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3687 #endif /* PREBOOT_SUPPORT */
3689 case ixgbe_phy_ext_1g_t:
3690 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3696 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
3697 physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
3699 return physical_layer;
3703 * ixgbe_get_bus_info_x550em - Set PCI bus info
3704 * @hw: pointer to hardware structure
3706 * Sets bus link width and speed to unknown because X550em is
3709 s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
3712 DEBUGFUNC("ixgbe_get_bus_info_x550em");
3714 hw->bus.width = ixgbe_bus_width_unknown;
3715 hw->bus.speed = ixgbe_bus_speed_unknown;
3717 hw->mac.ops.set_lan_id(hw);
3719 return IXGBE_SUCCESS;
3723 * ixgbe_disable_rx_x550 - Disable RX unit
3724 * @hw: pointer to hardware structure
3726 * Enables the Rx DMA unit for x550
3728 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
3730 u32 rxctrl, pfdtxgswc;
3732 struct ixgbe_hic_disable_rxen fw_cmd;
3734 DEBUGFUNC("ixgbe_enable_rx_dma_x550");
3736 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3737 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3738 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
3739 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
3740 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
3741 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
3742 hw->mac.set_lben = true;
3744 hw->mac.set_lben = false;
3747 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
3748 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
3749 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
3750 fw_cmd.port_number = (u8)hw->bus.lan_id;
3752 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
3753 sizeof(struct ixgbe_hic_disable_rxen),
3754 IXGBE_HI_COMMAND_TIMEOUT, true);
3756 /* If we fail - disable RX using register write */
3758 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3759 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3760 rxctrl &= ~IXGBE_RXCTRL_RXEN;
3761 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
3768 * ixgbe_enter_lplu_x550em - Transition to low power states
3769 * @hw: pointer to hardware structure
3771 * Configures Low Power Link Up on transition to low power states
3772 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
3773 * X557 PHY immediately prior to entering LPLU.
3775 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
3777 u16 an_10g_cntl_reg, autoneg_reg, speed;
3779 ixgbe_link_speed lcd_speed;
3783 /* SW LPLU not required on later HW revisions. */
3784 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
3785 (IXGBE_FUSES0_REV_MASK &
3786 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
3787 return IXGBE_SUCCESS;
3789 /* If blocked by MNG FW, then don't restart AN */
3790 if (ixgbe_check_reset_blocked(hw))
3791 return IXGBE_SUCCESS;
3793 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3794 if (status != IXGBE_SUCCESS)
3797 status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
3799 if (status != IXGBE_SUCCESS)
3802 /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
3803 * disabled, then force link down by entering low power mode.
3805 if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
3806 !(hw->wol_enabled || ixgbe_mng_present(hw)))
3807 return ixgbe_set_copper_phy_power(hw, FALSE);
3810 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
3812 if (status != IXGBE_SUCCESS)
3815 /* If no valid LCD link speed, then force link down and exit. */
3816 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
3817 return ixgbe_set_copper_phy_power(hw, FALSE);
3819 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
3820 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3823 if (status != IXGBE_SUCCESS)
3826 /* If no link now, speed is invalid so take link down */
3827 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3828 if (status != IXGBE_SUCCESS)
3829 return ixgbe_set_copper_phy_power(hw, false);
3831 /* clear everything but the speed bits */
3832 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
3834 /* If current speed is already LCD, then exit. */
3835 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
3836 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
3837 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
3838 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
3841 /* Clear AN completed indication */
3842 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
3843 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3846 if (status != IXGBE_SUCCESS)
3849 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
3850 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3853 if (status != IXGBE_SUCCESS)
3856 status = hw->phy.ops.read_reg(hw,
3857 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
3858 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3861 if (status != IXGBE_SUCCESS)
3864 save_autoneg = hw->phy.autoneg_advertised;
3866 /* Setup link at least common link speed */
3867 status = hw->mac.ops.setup_link(hw, lcd_speed, false);
3869 /* restore autoneg from before setting lplu speed */
3870 hw->phy.autoneg_advertised = save_autoneg;
3876 * ixgbe_get_lcd_x550em - Determine lowest common denominator
3877 * @hw: pointer to hardware structure
3878 * @lcd_speed: pointer to lowest common link speed
3880 * Determine lowest common link speed with link partner.
3882 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
3886 u16 word = hw->eeprom.ctrl_word_3;
3888 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
3890 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
3891 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3894 if (status != IXGBE_SUCCESS)
3897 /* If link partner advertised 1G, return 1G */
3898 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
3899 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
3903 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
3904 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
3905 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
3908 /* Link partner not capable of lower speeds, return 10G */
3909 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
3914 * ixgbe_setup_fc_X550em - Set up flow control
3915 * @hw: pointer to hardware structure
3917 * Called at init time to set up flow control.
3919 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
3921 s32 ret_val = IXGBE_SUCCESS;
3922 u32 pause, asm_dir, reg_val;
3924 DEBUGFUNC("ixgbe_setup_fc_X550em");
3926 /* Validate the requested mode */
3927 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
3928 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
3929 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
3930 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3934 /* 10gig parts do not have a word in the EEPROM to determine the
3935 * default flow control setting, so we explicitly set it to full.
3937 if (hw->fc.requested_mode == ixgbe_fc_default)
3938 hw->fc.requested_mode = ixgbe_fc_full;
3940 /* Determine PAUSE and ASM_DIR bits. */
3941 switch (hw->fc.requested_mode) {
3946 case ixgbe_fc_tx_pause:
3950 case ixgbe_fc_rx_pause:
3951 /* Rx Flow control is enabled and Tx Flow control is
3952 * disabled by software override. Since there really
3953 * isn't a way to advertise that we are capable of RX
3954 * Pause ONLY, we will advertise that we support both
3955 * symmetric and asymmetric Rx PAUSE, as such we fall
3956 * through to the fc_full statement. Later, we will
3957 * disable the adapter's ability to send PAUSE frames.
3964 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
3965 "Flow control param set incorrectly\n");
3966 ret_val = IXGBE_ERR_CONFIG;
3970 switch (hw->device_id) {
3971 case IXGBE_DEV_ID_X550EM_X_KR:
3972 case IXGBE_DEV_ID_X550EM_A_KR:
3973 case IXGBE_DEV_ID_X550EM_A_KR_L:
3974 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
3975 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
3976 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3977 if (ret_val != IXGBE_SUCCESS)
3979 reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
3980 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
3982 reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
3984 reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
3985 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
3986 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
3987 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3989 /* This device does not fully support AN. */
3990 hw->fc.disable_fc_autoneg = true;
3992 case IXGBE_DEV_ID_X550EM_X_XFI:
3993 hw->fc.disable_fc_autoneg = true;
4004 * ixgbe_fc_autoneg_backplane_x550em_a - Enable flow control IEEE clause 37
4005 * @hw: pointer to hardware structure
4007 * Enable flow control according to IEEE clause 37.
4009 void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *hw)
4011 u32 link_s1, lp_an_page_low, an_cntl_1;
4012 s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4013 ixgbe_link_speed speed;
4016 /* AN should have completed when the cable was plugged in.
4017 * Look for reasons to bail out. Bail out if:
4018 * - FC autoneg is disabled, or if
4021 if (hw->fc.disable_fc_autoneg) {
4022 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4023 "Flow control autoneg is disabled");
4027 hw->mac.ops.check_link(hw, &speed, &link_up, false);
4029 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
4033 /* Check at auto-negotiation has completed */
4034 status = hw->mac.ops.read_iosf_sb_reg(hw,
4035 IXGBE_KRM_LINK_S1(hw->bus.lan_id),
4036 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_s1);
4038 if (status != IXGBE_SUCCESS ||
4039 (link_s1 & IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE) == 0) {
4040 DEBUGOUT("Auto-Negotiation did not complete\n");
4041 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4045 /* Read the 10g AN autoc and LP ability registers and resolve
4046 * local flow control settings accordingly
4048 status = hw->mac.ops.read_iosf_sb_reg(hw,
4049 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4050 IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl_1);
4052 if (status != IXGBE_SUCCESS) {
4053 DEBUGOUT("Auto-Negotiation did not complete\n");
4057 status = hw->mac.ops.read_iosf_sb_reg(hw,
4058 IXGBE_KRM_LP_BASE_PAGE_HIGH(hw->bus.lan_id),
4059 IXGBE_SB_IOSF_TARGET_KR_PHY, &lp_an_page_low);
4061 if (status != IXGBE_SUCCESS) {
4062 DEBUGOUT("Auto-Negotiation did not complete\n");
4066 status = ixgbe_negotiate_fc(hw, an_cntl_1, lp_an_page_low,
4067 IXGBE_KRM_AN_CNTL_1_SYM_PAUSE,
4068 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE,
4069 IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE,
4070 IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE);
4073 if (status == IXGBE_SUCCESS) {
4074 hw->fc.fc_was_autonegged = true;
4076 hw->fc.fc_was_autonegged = false;
4077 hw->fc.current_mode = hw->fc.requested_mode;
4082 * ixgbe_fc_autoneg_fiber_x550em_a - passthrough FC settings
4083 * @hw: pointer to hardware structure
4086 void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *hw)
4088 hw->fc.fc_was_autonegged = false;
4089 hw->fc.current_mode = hw->fc.requested_mode;
4093 * ixgbe_fc_autoneg_sgmii_x550em_a - Enable flow control IEEE clause 37
4094 * @hw: pointer to hardware structure
4096 * Enable flow control according to IEEE clause 37.
4098 void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
4100 s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4101 u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
4102 ixgbe_link_speed speed;
4105 /* AN should have completed when the cable was plugged in.
4106 * Look for reasons to bail out. Bail out if:
4107 * - FC autoneg is disabled, or if
4110 if (hw->fc.disable_fc_autoneg) {
4111 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4112 "Flow control autoneg is disabled");
4116 hw->mac.ops.check_link(hw, &speed, &link_up, false);
4118 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
4122 /* Check if auto-negotiation has completed */
4123 status = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &info);
4124 if (status != IXGBE_SUCCESS ||
4125 !(info[0] & FW_PHY_ACT_GET_LINK_INFO_AN_COMPLETE)) {
4126 DEBUGOUT("Auto-Negotiation did not complete\n");
4127 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4131 /* Negotiate the flow control */
4132 status = ixgbe_negotiate_fc(hw, info[0], info[0],
4133 FW_PHY_ACT_GET_LINK_INFO_FC_RX,
4134 FW_PHY_ACT_GET_LINK_INFO_FC_TX,
4135 FW_PHY_ACT_GET_LINK_INFO_LP_FC_RX,
4136 FW_PHY_ACT_GET_LINK_INFO_LP_FC_TX);
4139 if (status == IXGBE_SUCCESS) {
4140 hw->fc.fc_was_autonegged = true;
4142 hw->fc.fc_was_autonegged = false;
4143 hw->fc.current_mode = hw->fc.requested_mode;
4148 * ixgbe_setup_fc_backplane_x550em_a - Set up flow control
4149 * @hw: pointer to hardware structure
4151 * Called at init time to set up flow control.
4153 s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *hw)
4155 s32 status = IXGBE_SUCCESS;
4158 DEBUGFUNC("ixgbe_setup_fc_backplane_x550em_a");
4160 /* Validate the requested mode */
4161 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
4162 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4163 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
4164 return IXGBE_ERR_INVALID_LINK_SETTINGS;
4167 if (hw->fc.requested_mode == ixgbe_fc_default)
4168 hw->fc.requested_mode = ixgbe_fc_full;
4170 /* Set up the 1G and 10G flow control advertisement registers so the
4171 * HW will be able to do FC autoneg once the cable is plugged in. If
4172 * we link at 10G, the 1G advertisement is harmless and vice versa.
4174 status = hw->mac.ops.read_iosf_sb_reg(hw,
4175 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4176 IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl);
4178 if (status != IXGBE_SUCCESS) {
4179 DEBUGOUT("Auto-Negotiation did not complete\n");
4183 /* The possible values of fc.requested_mode are:
4184 * 0: Flow control is completely disabled
4185 * 1: Rx flow control is enabled (we can receive pause frames,
4186 * but not send pause frames).
4187 * 2: Tx flow control is enabled (we can send pause frames but
4188 * we do not support receiving pause frames).
4189 * 3: Both Rx and Tx flow control (symmetric) are enabled.
4192 switch (hw->fc.requested_mode) {
4194 /* Flow control completely disabled by software override. */
4195 an_cntl &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
4196 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
4198 case ixgbe_fc_tx_pause:
4199 /* Tx Flow control is enabled, and Rx Flow control is
4200 * disabled by software override.
4202 an_cntl |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4203 an_cntl &= ~IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
4205 case ixgbe_fc_rx_pause:
4206 /* Rx Flow control is enabled and Tx Flow control is
4207 * disabled by software override. Since there really
4208 * isn't a way to advertise that we are capable of RX
4209 * Pause ONLY, we will advertise that we support both
4210 * symmetric and asymmetric Rx PAUSE, as such we fall
4211 * through to the fc_full statement. Later, we will
4212 * disable the adapter's ability to send PAUSE frames.
4215 /* Flow control (both Rx and Tx) is enabled by SW override. */
4216 an_cntl |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
4217 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4220 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
4221 "Flow control param set incorrectly\n");
4222 return IXGBE_ERR_CONFIG;
4225 status = hw->mac.ops.write_iosf_sb_reg(hw,
4226 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4227 IXGBE_SB_IOSF_TARGET_KR_PHY, an_cntl);
4229 /* Restart auto-negotiation. */
4230 status = ixgbe_restart_an_internal_phy_x550em(hw);
4236 * ixgbe_set_mux - Set mux for port 1 access with CS4227
4237 * @hw: pointer to hardware structure
4238 * @state: set mux if 1, clear if 0
4240 STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
4244 if (!hw->bus.lan_id)
4246 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
4248 esdp |= IXGBE_ESDP_SDP1;
4250 esdp &= ~IXGBE_ESDP_SDP1;
4251 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
4252 IXGBE_WRITE_FLUSH(hw);
4256 * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
4257 * @hw: pointer to hardware structure
4258 * @mask: Mask to specify which semaphore to acquire
4260 * Acquires the SWFW semaphore and sets the I2C MUX
4262 s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
4266 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
4268 status = ixgbe_acquire_swfw_sync_X540(hw, mask);
4272 if (mask & IXGBE_GSSR_I2C_MASK)
4273 ixgbe_set_mux(hw, 1);
4275 return IXGBE_SUCCESS;
4279 * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
4280 * @hw: pointer to hardware structure
4281 * @mask: Mask to specify which semaphore to release
4283 * Releases the SWFW semaphore and sets the I2C MUX
4285 void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
4287 DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
4289 if (mask & IXGBE_GSSR_I2C_MASK)
4290 ixgbe_set_mux(hw, 0);
4292 ixgbe_release_swfw_sync_X540(hw, mask);
4296 * ixgbe_acquire_swfw_sync_X550a - Acquire SWFW semaphore
4297 * @hw: pointer to hardware structure
4298 * @mask: Mask to specify which semaphore to acquire
4300 * Acquires the SWFW semaphore and get the shared phy token as needed
4302 STATIC s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
4304 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
4305 int retries = FW_PHY_TOKEN_RETRIES;
4306 s32 status = IXGBE_SUCCESS;
4308 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");
4311 status = IXGBE_SUCCESS;
4313 status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
4315 DEBUGOUT1("Could not acquire SWFW semaphore, Status = %d\n",
4319 if (!(mask & IXGBE_GSSR_TOKEN_SM))
4320 return IXGBE_SUCCESS;
4322 status = ixgbe_get_phy_token(hw);
4323 if (status == IXGBE_ERR_TOKEN_RETRY)
4324 DEBUGOUT1("Could not acquire PHY token, Status = %d\n",
4327 if (status == IXGBE_SUCCESS)
4328 return IXGBE_SUCCESS;
4331 ixgbe_release_swfw_sync_X540(hw, hmask);
4333 if (status != IXGBE_ERR_TOKEN_RETRY) {
4334 DEBUGOUT1("Unable to retry acquiring the PHY token, Status = %d\n",
4340 DEBUGOUT1("Semaphore acquisition retries failed!: PHY ID = 0x%08X\n",
4346 * ixgbe_release_swfw_sync_X550a - Release SWFW semaphore
4347 * @hw: pointer to hardware structure
4348 * @mask: Mask to specify which semaphore to release
4350 * Releases the SWFW semaphore and puts the shared phy token as needed
4352 STATIC void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
4354 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
4356 DEBUGFUNC("ixgbe_release_swfw_sync_X550a");
4358 if (mask & IXGBE_GSSR_TOKEN_SM)
4359 ixgbe_put_phy_token(hw);
4362 ixgbe_release_swfw_sync_X540(hw, hmask);
4366 * ixgbe_read_phy_reg_x550a - Reads specified PHY register
4367 * @hw: pointer to hardware structure
4368 * @reg_addr: 32 bit address of PHY register to read
4369 * @device_type: 5 bit device type
4370 * @phy_data: Pointer to read data from PHY register
4372 * Reads a value from a specified PHY register using the SWFW lock and PHY
4373 * Token. The PHY Token is needed since the MDIO is shared between to MAC
4376 s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
4377 u32 device_type, u16 *phy_data)
4380 u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
4382 DEBUGFUNC("ixgbe_read_phy_reg_x550a");
4384 if (hw->mac.ops.acquire_swfw_sync(hw, mask))
4385 return IXGBE_ERR_SWFW_SYNC;
4387 status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
4389 hw->mac.ops.release_swfw_sync(hw, mask);
4395 * ixgbe_write_phy_reg_x550a - Writes specified PHY register
4396 * @hw: pointer to hardware structure
4397 * @reg_addr: 32 bit PHY register to write
4398 * @device_type: 5 bit device type
4399 * @phy_data: Data to write to the PHY register
4401 * Writes a value to specified PHY register using the SWFW lock and PHY Token.
4402 * The PHY Token is needed since the MDIO is shared between to MAC instances.
4404 s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
4405 u32 device_type, u16 phy_data)
4408 u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
4410 DEBUGFUNC("ixgbe_write_phy_reg_x550a");
4412 if (hw->mac.ops.acquire_swfw_sync(hw, mask) == IXGBE_SUCCESS) {
4413 status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
4415 hw->mac.ops.release_swfw_sync(hw, mask);
4417 status = IXGBE_ERR_SWFW_SYNC;
4424 * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
4425 * @hw: pointer to hardware structure
4427 * Handle external Base T PHY interrupt. If high temperature
4428 * failure alarm then return error, else if link status change
4429 * then setup internal/external PHY link
4431 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
4432 * failure alarm, else return PHY access status.
4434 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
4439 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
4441 if (status != IXGBE_SUCCESS)
4445 return ixgbe_setup_internal_phy(hw);
4447 return IXGBE_SUCCESS;
4451 * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
4452 * @hw: pointer to hardware structure
4453 * @speed: new link speed
4454 * @autoneg_wait_to_complete: true when waiting for completion is needed
4456 * Setup internal/external PHY link speed based on link speed, then set
4457 * external PHY auto advertised link speed.
4459 * Returns error status for any failure
4461 s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
4462 ixgbe_link_speed speed,
4463 bool autoneg_wait_to_complete)
4466 ixgbe_link_speed force_speed;
4468 DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
4470 /* Setup internal/external PHY link speed to iXFI (10G), unless
4471 * only 1G is auto advertised then setup KX link.
4473 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
4474 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
4476 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
4478 /* If X552 and internal link mode is XFI, then setup XFI internal link.
4480 if (hw->mac.type == ixgbe_mac_X550EM_x &&
4481 !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
4482 status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
4484 if (status != IXGBE_SUCCESS)
4488 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
4492 * ixgbe_check_link_t_X550em - Determine link and speed status
4493 * @hw: pointer to hardware structure
4494 * @speed: pointer to link speed
4495 * @link_up: true when link is up
4496 * @link_up_wait_to_complete: bool used to wait for link up or not
4498 * Check that both the MAC and X557 external PHY have link.
4500 s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
4501 bool *link_up, bool link_up_wait_to_complete)
4504 u16 i, autoneg_status = 0;
4506 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
4507 return IXGBE_ERR_CONFIG;
4509 status = ixgbe_check_mac_link_generic(hw, speed, link_up,
4510 link_up_wait_to_complete);
4512 /* If check link fails or MAC link is not up, then return */
4513 if (status != IXGBE_SUCCESS || !(*link_up))
4516 /* MAC link is up, so check external PHY link.
4517 * X557 PHY. Link status is latching low, and can only be used to detect
4518 * link drop, and not the current status of the link without performing
4519 * back-to-back reads.
4521 for (i = 0; i < 2; i++) {
4522 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
4523 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
4526 if (status != IXGBE_SUCCESS)
4530 /* If external PHY link is not up, then indicate link not up */
4531 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
4534 return IXGBE_SUCCESS;
4538 * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
4539 * @hw: pointer to hardware structure
4541 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
4545 status = ixgbe_reset_phy_generic(hw);
4547 if (status != IXGBE_SUCCESS)
4550 /* Configure Link Status Alarm and Temperature Threshold interrupts */
4551 return ixgbe_enable_lasi_ext_t_x550em(hw);
4555 * ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
4556 * @hw: pointer to hardware structure
4557 * @led_idx: led number to turn on
4559 s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
4563 DEBUGFUNC("ixgbe_led_on_t_X550em");
4565 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
4566 return IXGBE_ERR_PARAM;
4568 /* To turn on the LED, set mode to ON. */
4569 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4570 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
4571 phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
4572 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4573 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
4575 /* Some designs have the LEDs wired to the MAC */
4576 return ixgbe_led_on_generic(hw, led_idx);
4580 * ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
4581 * @hw: pointer to hardware structure
4582 * @led_idx: led number to turn off
4584 s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
4588 DEBUGFUNC("ixgbe_led_off_t_X550em");
4590 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
4591 return IXGBE_ERR_PARAM;
4593 /* To turn on the LED, set mode to ON. */
4594 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4595 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
4596 phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
4597 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4598 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
4600 /* Some designs have the LEDs wired to the MAC */
4601 return ixgbe_led_off_generic(hw, led_idx);
4605 * ixgbe_set_fw_drv_ver_x550 - Sends driver version to firmware
4606 * @hw: pointer to the HW structure
4607 * @maj: driver version major number
4608 * @min: driver version minor number
4609 * @build: driver version build number
4610 * @sub: driver version sub build number
4611 * @len: length of driver_ver string
4612 * @driver_ver: driver string
4614 * Sends driver version number to firmware through the manageability
4615 * block. On success return IXGBE_SUCCESS
4616 * else returns IXGBE_ERR_SWFW_SYNC when encountering an error acquiring
4617 * semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
4619 s32 ixgbe_set_fw_drv_ver_x550(struct ixgbe_hw *hw, u8 maj, u8 min,
4620 u8 build, u8 sub, u16 len, const char *driver_ver)
4622 struct ixgbe_hic_drv_info2 fw_cmd;
4623 s32 ret_val = IXGBE_SUCCESS;
4626 DEBUGFUNC("ixgbe_set_fw_drv_ver_x550");
4628 if ((len == 0) || (driver_ver == NULL) ||
4629 (len > sizeof(fw_cmd.driver_string)))
4630 return IXGBE_ERR_INVALID_ARGUMENT;
4632 fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
4633 fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN + len;
4634 fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
4635 fw_cmd.port_num = (u8)hw->bus.func;
4636 fw_cmd.ver_maj = maj;
4637 fw_cmd.ver_min = min;
4638 fw_cmd.ver_build = build;
4639 fw_cmd.ver_sub = sub;
4640 fw_cmd.hdr.checksum = 0;
4641 memcpy(fw_cmd.driver_string, driver_ver, len);
4642 fw_cmd.hdr.checksum = ixgbe_calculate_checksum((u8 *)&fw_cmd,
4643 (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));
4645 for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
4646 ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
4648 IXGBE_HI_COMMAND_TIMEOUT,
4650 if (ret_val != IXGBE_SUCCESS)
4653 if (fw_cmd.hdr.cmd_or_resp.ret_status ==
4654 FW_CEM_RESP_STATUS_SUCCESS)
4655 ret_val = IXGBE_SUCCESS;
4657 ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND;