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_read_phy_reg_mdi_22 - Read from a clause 22 PHY register without lock
340 * @hw: pointer to hardware structure
341 * @reg_addr: 32 bit address of PHY register to read
342 * @dev_type: always unused
343 * @phy_data: Pointer to read data from PHY register
345 STATIC s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
346 u32 dev_type, u16 *phy_data)
348 u32 i, data, command;
349 UNREFERENCED_1PARAMETER(dev_type);
351 /* Setup and write the read command */
352 command = (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
353 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
354 IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_READ_AUTOINC |
355 IXGBE_MSCA_MDI_COMMAND;
357 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
359 /* Check every 10 usec to see if the access completed.
360 * The MDI Command bit will clear when the operation is
363 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
366 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
367 if (!(command & IXGBE_MSCA_MDI_COMMAND))
371 if (command & IXGBE_MSCA_MDI_COMMAND) {
372 ERROR_REPORT1(IXGBE_ERROR_POLLING,
373 "PHY read command did not complete.\n");
374 return IXGBE_ERR_PHY;
377 /* Read operation is complete. Get the data from MSRWD */
378 data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
379 data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
380 *phy_data = (u16)data;
382 return IXGBE_SUCCESS;
386 * ixgbe_write_phy_reg_mdi_22 - Write to a clause 22 PHY register without lock
387 * @hw: pointer to hardware structure
388 * @reg_addr: 32 bit PHY register to write
389 * @dev_type: always unused
390 * @phy_data: Data to write to the PHY register
392 STATIC s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
393 u32 dev_type, u16 phy_data)
396 UNREFERENCED_1PARAMETER(dev_type);
398 /* Put the data in the MDI single read and write data register*/
399 IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
401 /* Setup and write the write command */
402 command = (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
403 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
404 IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_WRITE |
405 IXGBE_MSCA_MDI_COMMAND;
407 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
409 /* Check every 10 usec to see if the access completed.
410 * The MDI Command bit will clear when the operation is
413 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
416 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
417 if (!(command & IXGBE_MSCA_MDI_COMMAND))
421 if (command & IXGBE_MSCA_MDI_COMMAND) {
422 ERROR_REPORT1(IXGBE_ERROR_POLLING,
423 "PHY write cmd didn't complete\n");
424 return IXGBE_ERR_PHY;
427 return IXGBE_SUCCESS;
431 * ixgbe_identify_phy_x550em - Get PHY type based on device id
432 * @hw: pointer to hardware structure
436 STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
438 hw->mac.ops.set_lan_id(hw);
440 ixgbe_read_mng_if_sel_x550em(hw);
442 switch (hw->device_id) {
443 case IXGBE_DEV_ID_X550EM_A_SFP:
444 return ixgbe_identify_module_generic(hw);
445 case IXGBE_DEV_ID_X550EM_X_SFP:
446 /* set up for CS4227 usage */
447 ixgbe_setup_mux_ctl(hw);
448 ixgbe_check_cs4227(hw);
451 case IXGBE_DEV_ID_X550EM_A_SFP_N:
452 return ixgbe_identify_module_generic(hw);
454 case IXGBE_DEV_ID_X550EM_X_KX4:
455 hw->phy.type = ixgbe_phy_x550em_kx4;
457 case IXGBE_DEV_ID_X550EM_X_XFI:
458 hw->phy.type = ixgbe_phy_x550em_xfi;
460 case IXGBE_DEV_ID_X550EM_X_KR:
461 case IXGBE_DEV_ID_X550EM_A_KR:
462 case IXGBE_DEV_ID_X550EM_A_KR_L:
463 hw->phy.type = ixgbe_phy_x550em_kr;
465 case IXGBE_DEV_ID_X550EM_A_10G_T:
466 case IXGBE_DEV_ID_X550EM_X_10G_T:
467 return ixgbe_identify_phy_generic(hw);
468 case IXGBE_DEV_ID_X550EM_X_1G_T:
469 hw->phy.type = ixgbe_phy_ext_1g_t;
470 hw->phy.ops.read_reg = NULL;
471 hw->phy.ops.write_reg = NULL;
473 case IXGBE_DEV_ID_X550EM_A_1G_T:
474 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
475 hw->phy.type = ixgbe_phy_fw;
476 hw->phy.ops.read_reg = NULL;
477 hw->phy.ops.write_reg = NULL;
479 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
481 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
486 return IXGBE_SUCCESS;
490 * ixgbe_fw_phy_activity - Perform an activity on a PHY
491 * @hw: pointer to hardware structure
492 * @activity: activity to perform
493 * @data: Pointer to 4 32-bit words of data
495 s32 ixgbe_fw_phy_activity(struct ixgbe_hw *hw, u16 activity,
496 u32 (*data)[FW_PHY_ACT_DATA_COUNT])
499 struct ixgbe_hic_phy_activity_req cmd;
500 struct ixgbe_hic_phy_activity_resp rsp;
502 u16 retries = FW_PHY_ACT_RETRIES;
507 memset(&hic, 0, sizeof(hic));
508 hic.cmd.hdr.cmd = FW_PHY_ACT_REQ_CMD;
509 hic.cmd.hdr.buf_len = FW_PHY_ACT_REQ_LEN;
510 hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
511 hic.cmd.port_number = hw->bus.lan_id;
512 hic.cmd.activity_id = IXGBE_CPU_TO_LE16(activity);
513 for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
514 hic.cmd.data[i] = IXGBE_CPU_TO_BE32((*data)[i]);
516 rc = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
518 IXGBE_HI_COMMAND_TIMEOUT,
520 if (rc != IXGBE_SUCCESS)
522 if (hic.rsp.hdr.cmd_or_resp.ret_status ==
523 FW_CEM_RESP_STATUS_SUCCESS) {
524 for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
525 (*data)[i] = IXGBE_BE32_TO_CPU(hic.rsp.data[i]);
526 return IXGBE_SUCCESS;
530 } while (retries > 0);
532 return IXGBE_ERR_HOST_INTERFACE_COMMAND;
535 static const struct {
537 ixgbe_link_speed phy_speed;
539 { FW_PHY_ACT_LINK_SPEED_10, IXGBE_LINK_SPEED_10_FULL },
540 { FW_PHY_ACT_LINK_SPEED_100, IXGBE_LINK_SPEED_100_FULL },
541 { FW_PHY_ACT_LINK_SPEED_1G, IXGBE_LINK_SPEED_1GB_FULL },
542 { FW_PHY_ACT_LINK_SPEED_2_5G, IXGBE_LINK_SPEED_2_5GB_FULL },
543 { FW_PHY_ACT_LINK_SPEED_5G, IXGBE_LINK_SPEED_5GB_FULL },
544 { FW_PHY_ACT_LINK_SPEED_10G, IXGBE_LINK_SPEED_10GB_FULL },
548 * ixgbe_get_phy_id_fw - Get the phy ID via firmware command
549 * @hw: pointer to hardware structure
553 static s32 ixgbe_get_phy_id_fw(struct ixgbe_hw *hw)
555 u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
561 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_PHY_INFO, &info);
565 hw->phy.speeds_supported = 0;
566 phy_speeds = info[0] & FW_PHY_INFO_SPEED_MASK;
567 for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
568 if (phy_speeds & ixgbe_fw_map[i].fw_speed)
569 hw->phy.speeds_supported |= ixgbe_fw_map[i].phy_speed;
571 if (!hw->phy.autoneg_advertised)
572 hw->phy.autoneg_advertised = hw->phy.speeds_supported;
574 hw->phy.id = info[0] & FW_PHY_INFO_ID_HI_MASK;
575 phy_id_lo = info[1] & FW_PHY_INFO_ID_LO_MASK;
576 hw->phy.id |= phy_id_lo & IXGBE_PHY_REVISION_MASK;
577 hw->phy.revision = phy_id_lo & ~IXGBE_PHY_REVISION_MASK;
578 if (!hw->phy.id || hw->phy.id == IXGBE_PHY_REVISION_MASK)
579 return IXGBE_ERR_PHY_ADDR_INVALID;
580 return IXGBE_SUCCESS;
584 * ixgbe_identify_phy_fw - Get PHY type based on firmware command
585 * @hw: pointer to hardware structure
589 static s32 ixgbe_identify_phy_fw(struct ixgbe_hw *hw)
592 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
594 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
596 hw->phy.type = ixgbe_phy_fw;
597 hw->phy.ops.read_reg = NULL;
598 hw->phy.ops.write_reg = NULL;
599 return ixgbe_get_phy_id_fw(hw);
603 * ixgbe_shutdown_fw_phy - Shutdown a firmware-controlled PHY
604 * @hw: pointer to hardware structure
608 s32 ixgbe_shutdown_fw_phy(struct ixgbe_hw *hw)
610 u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
612 setup[0] = FW_PHY_ACT_FORCE_LINK_DOWN_OFF;
613 return ixgbe_fw_phy_activity(hw, FW_PHY_ACT_FORCE_LINK_DOWN, &setup);
616 STATIC s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
617 u32 device_type, u16 *phy_data)
619 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
620 return IXGBE_NOT_IMPLEMENTED;
623 STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
624 u32 device_type, u16 phy_data)
626 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
627 return IXGBE_NOT_IMPLEMENTED;
631 * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
632 * @hw: pointer to the hardware structure
633 * @addr: I2C bus address to read from
634 * @reg: I2C device register to read from
635 * @val: pointer to location to receive read value
637 * Returns an error code on error.
639 STATIC s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
642 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
646 * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
647 * @hw: pointer to the hardware structure
648 * @addr: I2C bus address to read from
649 * @reg: I2C device register to read from
650 * @val: pointer to location to receive read value
652 * Returns an error code on error.
655 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
658 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, false);
662 * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
663 * @hw: pointer to the hardware structure
664 * @addr: I2C bus address to write to
665 * @reg: I2C device register to write to
666 * @val: value to write
668 * Returns an error code on error.
670 STATIC s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
671 u8 addr, u16 reg, u16 val)
673 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
677 * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
678 * @hw: pointer to the hardware structure
679 * @addr: I2C bus address to write to
680 * @reg: I2C device register to write to
681 * @val: value to write
683 * Returns an error code on error.
686 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
687 u8 addr, u16 reg, u16 val)
689 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, false);
693 * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
694 * @hw: pointer to hardware structure
696 * Initialize the function pointers and for MAC type X550EM.
697 * Does not touch the hardware.
699 s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
701 struct ixgbe_mac_info *mac = &hw->mac;
702 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
703 struct ixgbe_phy_info *phy = &hw->phy;
706 DEBUGFUNC("ixgbe_init_ops_X550EM");
708 /* Similar to X550 so start there. */
709 ret_val = ixgbe_init_ops_X550(hw);
711 /* Since this function eventually calls
712 * ixgbe_init_ops_540 by design, we are setting
713 * the pointers to NULL explicitly here to overwrite
714 * the values being set in the x540 function.
716 /* Thermal sensor not supported in x550EM */
717 mac->ops.get_thermal_sensor_data = NULL;
718 mac->ops.init_thermal_sensor_thresh = NULL;
719 mac->thermal_sensor_enabled = false;
721 /* FCOE not supported in x550EM */
722 mac->ops.get_san_mac_addr = NULL;
723 mac->ops.set_san_mac_addr = NULL;
724 mac->ops.get_wwn_prefix = NULL;
725 mac->ops.get_fcoe_boot_status = NULL;
727 /* IPsec not supported in x550EM */
728 mac->ops.disable_sec_rx_path = NULL;
729 mac->ops.enable_sec_rx_path = NULL;
731 /* AUTOC register is not present in x550EM. */
732 mac->ops.prot_autoc_read = NULL;
733 mac->ops.prot_autoc_write = NULL;
735 /* X550EM bus type is internal*/
736 hw->bus.type = ixgbe_bus_type_internal;
737 mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
740 mac->ops.get_media_type = ixgbe_get_media_type_X550em;
741 mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
742 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
743 mac->ops.reset_hw = ixgbe_reset_hw_X550em;
744 mac->ops.get_supported_physical_layer =
745 ixgbe_get_supported_physical_layer_X550em;
747 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
748 mac->ops.setup_fc = ixgbe_setup_fc_generic;
750 mac->ops.setup_fc = ixgbe_setup_fc_X550em;
753 phy->ops.init = ixgbe_init_phy_ops_X550em;
754 switch (hw->device_id) {
755 case IXGBE_DEV_ID_X550EM_A_1G_T:
756 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
757 mac->ops.setup_fc = NULL;
758 phy->ops.identify = ixgbe_identify_phy_fw;
759 phy->ops.set_phy_power = NULL;
760 phy->ops.get_firmware_version = NULL;
762 case IXGBE_DEV_ID_X550EM_X_1G_T:
763 mac->ops.setup_fc = NULL;
764 phy->ops.identify = ixgbe_identify_phy_x550em;
765 phy->ops.set_phy_power = NULL;
768 phy->ops.identify = ixgbe_identify_phy_x550em;
771 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
772 phy->ops.set_phy_power = NULL;
776 eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
777 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
778 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
779 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
780 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
781 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
782 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
783 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
789 * ixgbe_setup_fw_link - Setup firmware-controlled PHYs
790 * @hw: pointer to hardware structure
792 static s32 ixgbe_setup_fw_link(struct ixgbe_hw *hw)
794 u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
798 if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
801 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
802 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
803 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
804 return IXGBE_ERR_INVALID_LINK_SETTINGS;
807 switch (hw->fc.requested_mode) {
809 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RXTX <<
810 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
812 case ixgbe_fc_rx_pause:
813 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RX <<
814 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
816 case ixgbe_fc_tx_pause:
817 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_TX <<
818 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
824 for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
825 if (hw->phy.autoneg_advertised & ixgbe_fw_map[i].phy_speed)
826 setup[0] |= ixgbe_fw_map[i].fw_speed;
828 setup[0] |= FW_PHY_ACT_SETUP_LINK_HP | FW_PHY_ACT_SETUP_LINK_AN;
830 if (hw->phy.eee_speeds_advertised)
831 setup[0] |= FW_PHY_ACT_SETUP_LINK_EEE;
833 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_SETUP_LINK, &setup);
836 if (setup[0] == FW_PHY_ACT_SETUP_LINK_RSP_DOWN)
837 return IXGBE_ERR_OVERTEMP;
838 return IXGBE_SUCCESS;
842 * ixgbe_fc_autoneg_fw _ Set up flow control for FW-controlled PHYs
843 * @hw: pointer to hardware structure
845 * Called at init time to set up flow control.
847 static s32 ixgbe_fc_autoneg_fw(struct ixgbe_hw *hw)
849 if (hw->fc.requested_mode == ixgbe_fc_default)
850 hw->fc.requested_mode = ixgbe_fc_full;
852 return ixgbe_setup_fw_link(hw);
856 * ixgbe_setup_eee_fw - Enable/disable EEE support
857 * @hw: pointer to the HW structure
858 * @enable_eee: boolean flag to enable EEE
860 * Enable/disable EEE based on enable_eee flag.
861 * This function controls EEE for firmware-based PHY implementations.
863 static s32 ixgbe_setup_eee_fw(struct ixgbe_hw *hw, bool enable_eee)
865 if (!!hw->phy.eee_speeds_advertised == enable_eee)
866 return IXGBE_SUCCESS;
868 hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
870 hw->phy.eee_speeds_advertised = 0;
871 return hw->phy.ops.setup_link(hw);
875 * ixgbe_init_ops_X550EM_a - Inits func ptrs and MAC type
876 * @hw: pointer to hardware structure
878 * Initialize the function pointers and for MAC type X550EM_a.
879 * Does not touch the hardware.
881 s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
883 struct ixgbe_mac_info *mac = &hw->mac;
886 DEBUGFUNC("ixgbe_init_ops_X550EM_a");
888 /* Start with generic X550EM init */
889 ret_val = ixgbe_init_ops_X550EM(hw);
891 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
892 hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L) {
893 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
894 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
896 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a;
897 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a;
899 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
900 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
902 switch (mac->ops.get_media_type(hw)) {
903 case ixgbe_media_type_fiber:
904 mac->ops.setup_fc = NULL;
905 mac->ops.fc_autoneg = ixgbe_fc_autoneg_fiber_x550em_a;
907 case ixgbe_media_type_backplane:
908 mac->ops.fc_autoneg = ixgbe_fc_autoneg_backplane_x550em_a;
909 mac->ops.setup_fc = ixgbe_setup_fc_backplane_x550em_a;
915 switch (hw->device_id) {
916 case IXGBE_DEV_ID_X550EM_A_1G_T:
917 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
918 mac->ops.fc_autoneg = ixgbe_fc_autoneg_sgmii_x550em_a;
919 mac->ops.setup_fc = ixgbe_fc_autoneg_fw;
920 mac->ops.setup_eee = ixgbe_setup_eee_fw;
921 hw->phy.eee_speeds_supported = IXGBE_LINK_SPEED_100_FULL |
922 IXGBE_LINK_SPEED_1GB_FULL;
923 hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
933 * ixgbe_init_ops_X550EM_x - Inits func ptrs and MAC type
934 * @hw: pointer to hardware structure
936 * Initialize the function pointers and for MAC type X550EM_x.
937 * Does not touch the hardware.
939 s32 ixgbe_init_ops_X550EM_x(struct ixgbe_hw *hw)
941 struct ixgbe_mac_info *mac = &hw->mac;
942 struct ixgbe_link_info *link = &hw->link;
945 DEBUGFUNC("ixgbe_init_ops_X550EM_x");
947 /* Start with generic X550EM init */
948 ret_val = ixgbe_init_ops_X550EM(hw);
950 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
951 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
952 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
953 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
954 link->ops.read_link = ixgbe_read_i2c_combined_generic;
955 link->ops.read_link_unlocked = ixgbe_read_i2c_combined_generic_unlocked;
956 link->ops.write_link = ixgbe_write_i2c_combined_generic;
957 link->ops.write_link_unlocked =
958 ixgbe_write_i2c_combined_generic_unlocked;
959 link->addr = IXGBE_CS4227;
961 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T) {
962 mac->ops.setup_fc = NULL;
963 mac->ops.setup_eee = NULL;
964 mac->ops.init_led_link_act = NULL;
971 * ixgbe_dmac_config_X550
972 * @hw: pointer to hardware structure
974 * Configure DMA coalescing. If enabling dmac, dmac is activated.
975 * When disabling dmac, dmac enable dmac bit is cleared.
977 s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
979 u32 reg, high_pri_tc;
981 DEBUGFUNC("ixgbe_dmac_config_X550");
983 /* Disable DMA coalescing before configuring */
984 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
985 reg &= ~IXGBE_DMACR_DMAC_EN;
986 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
988 /* Disable DMA Coalescing if the watchdog timer is 0 */
989 if (!hw->mac.dmac_config.watchdog_timer)
992 ixgbe_dmac_config_tcs_X550(hw);
994 /* Configure DMA Coalescing Control Register */
995 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
997 /* Set the watchdog timer in units of 40.96 usec */
998 reg &= ~IXGBE_DMACR_DMACWT_MASK;
999 reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
1001 reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
1002 /* If fcoe is enabled, set high priority traffic class */
1003 if (hw->mac.dmac_config.fcoe_en) {
1004 high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
1005 reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
1006 IXGBE_DMACR_HIGH_PRI_TC_MASK);
1008 reg |= IXGBE_DMACR_EN_MNG_IND;
1010 /* Enable DMA coalescing after configuration */
1011 reg |= IXGBE_DMACR_DMAC_EN;
1012 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
1015 return IXGBE_SUCCESS;
1019 * ixgbe_dmac_config_tcs_X550
1020 * @hw: pointer to hardware structure
1022 * Configure DMA coalescing threshold per TC. The dmac enable bit must
1023 * be cleared before configuring.
1025 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
1027 u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
1029 DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
1031 /* Configure DMA coalescing enabled */
1032 switch (hw->mac.dmac_config.link_speed) {
1033 case IXGBE_LINK_SPEED_10_FULL:
1034 case IXGBE_LINK_SPEED_100_FULL:
1035 pb_headroom = IXGBE_DMACRXT_100M;
1037 case IXGBE_LINK_SPEED_1GB_FULL:
1038 pb_headroom = IXGBE_DMACRXT_1G;
1041 pb_headroom = IXGBE_DMACRXT_10G;
1045 maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
1046 IXGBE_MHADD_MFS_SHIFT) / 1024);
1048 /* Set the per Rx packet buffer receive threshold */
1049 for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
1050 reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
1051 reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
1053 if (tc < hw->mac.dmac_config.num_tcs) {
1054 /* Get Rx PB size */
1055 rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
1056 rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
1057 IXGBE_RXPBSIZE_SHIFT;
1059 /* Calculate receive buffer threshold in kilobytes */
1060 if (rx_pb_size > pb_headroom)
1061 rx_pb_size = rx_pb_size - pb_headroom;
1065 /* Minimum of MFS shall be set for DMCTH */
1066 reg |= (rx_pb_size > maxframe_size_kb) ?
1067 rx_pb_size : maxframe_size_kb;
1069 IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
1071 return IXGBE_SUCCESS;
1075 * ixgbe_dmac_update_tcs_X550
1076 * @hw: pointer to hardware structure
1078 * Disables dmac, updates per TC settings, and then enables dmac.
1080 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
1084 DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
1086 /* Disable DMA coalescing before configuring */
1087 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
1088 reg &= ~IXGBE_DMACR_DMAC_EN;
1089 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
1091 ixgbe_dmac_config_tcs_X550(hw);
1093 /* Enable DMA coalescing after configuration */
1094 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
1095 reg |= IXGBE_DMACR_DMAC_EN;
1096 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
1098 return IXGBE_SUCCESS;
1102 * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
1103 * @hw: pointer to hardware structure
1105 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
1106 * ixgbe_hw struct in order to set up EEPROM access.
1108 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
1110 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
1114 DEBUGFUNC("ixgbe_init_eeprom_params_X550");
1116 if (eeprom->type == ixgbe_eeprom_uninitialized) {
1117 eeprom->semaphore_delay = 10;
1118 eeprom->type = ixgbe_flash;
1120 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
1121 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
1122 IXGBE_EEC_SIZE_SHIFT);
1123 eeprom->word_size = 1 << (eeprom_size +
1124 IXGBE_EEPROM_WORD_SIZE_SHIFT);
1126 DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
1127 eeprom->type, eeprom->word_size);
1130 return IXGBE_SUCCESS;
1134 * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
1135 * @hw: pointer to hardware structure
1136 * @enable: enable or disable source address pruning
1137 * @pool: Rx pool to set source address pruning for
1139 void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
1144 /* max rx pool is 63 */
1148 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
1149 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
1152 pfflp |= (1ULL << pool);
1154 pfflp &= ~(1ULL << pool);
1156 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
1157 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
1161 * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
1162 * @hw: pointer to hardware structure
1163 * @enable: enable or disable switch for Ethertype anti-spoofing
1164 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
1167 void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
1168 bool enable, int vf)
1170 int vf_target_reg = vf >> 3;
1171 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
1174 DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
1176 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
1178 pfvfspoof |= (1 << vf_target_shift);
1180 pfvfspoof &= ~(1 << vf_target_shift);
1182 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
1186 * ixgbe_iosf_wait - Wait for IOSF command completion
1187 * @hw: pointer to hardware structure
1188 * @ctrl: pointer to location to receive final IOSF control value
1190 * Returns failing status on timeout
1192 * Note: ctrl can be NULL if the IOSF control register value is not needed
1194 STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
1198 /* Check every 10 usec to see if the address cycle completed.
1199 * The SB IOSF BUSY bit will clear when the operation is
1202 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
1203 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
1204 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
1210 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
1211 ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
1212 return IXGBE_ERR_PHY;
1215 return IXGBE_SUCCESS;
1219 * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register
1220 * of the IOSF device
1221 * @hw: pointer to hardware structure
1222 * @reg_addr: 32 bit PHY register to write
1223 * @device_type: 3 bit device type
1224 * @data: Data to write to the register
1226 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1227 u32 device_type, u32 data)
1229 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1233 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1234 if (ret != IXGBE_SUCCESS)
1237 ret = ixgbe_iosf_wait(hw, NULL);
1238 if (ret != IXGBE_SUCCESS)
1241 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1242 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1244 /* Write IOSF control register */
1245 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1247 /* Write IOSF data register */
1248 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
1250 ret = ixgbe_iosf_wait(hw, &command);
1252 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1253 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1254 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1255 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1256 "Failed to write, error %x\n", error);
1257 ret = IXGBE_ERR_PHY;
1261 ixgbe_release_swfw_semaphore(hw, gssr);
1266 * ixgbe_read_iosf_sb_reg_x550 - Reads specified register of the IOSF device
1267 * @hw: pointer to hardware structure
1268 * @reg_addr: 32 bit PHY register to write
1269 * @device_type: 3 bit device type
1270 * @data: Pointer to read data from the register
1272 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1273 u32 device_type, u32 *data)
1275 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1279 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1280 if (ret != IXGBE_SUCCESS)
1283 ret = ixgbe_iosf_wait(hw, NULL);
1284 if (ret != IXGBE_SUCCESS)
1287 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1288 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1290 /* Write IOSF control register */
1291 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1293 ret = ixgbe_iosf_wait(hw, &command);
1295 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1296 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1297 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1298 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1299 "Failed to read, error %x\n", error);
1300 ret = IXGBE_ERR_PHY;
1303 if (ret == IXGBE_SUCCESS)
1304 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
1307 ixgbe_release_swfw_semaphore(hw, gssr);
1312 * ixgbe_get_phy_token - Get the token for shared phy access
1313 * @hw: Pointer to hardware structure
1316 s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
1318 struct ixgbe_hic_phy_token_req token_cmd;
1321 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1322 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1323 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1324 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1325 token_cmd.port_number = hw->bus.lan_id;
1326 token_cmd.command_type = FW_PHY_TOKEN_REQ;
1328 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1330 IXGBE_HI_COMMAND_TIMEOUT,
1333 DEBUGOUT1("Issuing host interface command failed with Status = %d\n",
1337 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1338 return IXGBE_SUCCESS;
1339 if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY) {
1340 DEBUGOUT1("Host interface command returned 0x%08x , returning IXGBE_ERR_FW_RESP_INVALID\n",
1341 token_cmd.hdr.cmd_or_resp.ret_status);
1342 return IXGBE_ERR_FW_RESP_INVALID;
1345 DEBUGOUT("Returning IXGBE_ERR_TOKEN_RETRY\n");
1346 return IXGBE_ERR_TOKEN_RETRY;
1350 * ixgbe_put_phy_token - Put the token for shared phy access
1351 * @hw: Pointer to hardware structure
1354 s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
1356 struct ixgbe_hic_phy_token_req token_cmd;
1359 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1360 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1361 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1362 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1363 token_cmd.port_number = hw->bus.lan_id;
1364 token_cmd.command_type = FW_PHY_TOKEN_REL;
1366 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1368 IXGBE_HI_COMMAND_TIMEOUT,
1372 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1373 return IXGBE_SUCCESS;
1375 DEBUGOUT("Put PHY Token host interface command failed");
1376 return IXGBE_ERR_FW_RESP_INVALID;
1380 * ixgbe_write_iosf_sb_reg_x550a - Writes a value to specified register
1381 * of the IOSF device
1382 * @hw: pointer to hardware structure
1383 * @reg_addr: 32 bit PHY register to write
1384 * @device_type: 3 bit device type
1385 * @data: Data to write to the register
1387 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1388 u32 device_type, u32 data)
1390 struct ixgbe_hic_internal_phy_req write_cmd;
1392 UNREFERENCED_1PARAMETER(device_type);
1394 memset(&write_cmd, 0, sizeof(write_cmd));
1395 write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1396 write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1397 write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1398 write_cmd.port_number = hw->bus.lan_id;
1399 write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
1400 write_cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
1401 write_cmd.write_data = IXGBE_CPU_TO_BE32(data);
1403 status = ixgbe_host_interface_command(hw, (u32 *)&write_cmd,
1405 IXGBE_HI_COMMAND_TIMEOUT, false);
1411 * ixgbe_read_iosf_sb_reg_x550a - Reads specified register of the IOSF device
1412 * @hw: pointer to hardware structure
1413 * @reg_addr: 32 bit PHY register to write
1414 * @device_type: 3 bit device type
1415 * @data: Pointer to read data from the register
1417 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1418 u32 device_type, u32 *data)
1421 struct ixgbe_hic_internal_phy_req cmd;
1422 struct ixgbe_hic_internal_phy_resp rsp;
1425 UNREFERENCED_1PARAMETER(device_type);
1427 memset(&hic, 0, sizeof(hic));
1428 hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1429 hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1430 hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1431 hic.cmd.port_number = hw->bus.lan_id;
1432 hic.cmd.command_type = FW_INT_PHY_REQ_READ;
1433 hic.cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
1435 status = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
1437 IXGBE_HI_COMMAND_TIMEOUT, true);
1439 /* Extract the register value from the response. */
1440 *data = IXGBE_BE32_TO_CPU(hic.rsp.read_data);
1446 * ixgbe_disable_mdd_X550
1447 * @hw: pointer to hardware structure
1449 * Disable malicious driver detection
1451 void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
1455 DEBUGFUNC("ixgbe_disable_mdd_X550");
1457 /* Disable MDD for TX DMA and interrupt */
1458 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1459 reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1460 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1462 /* Disable MDD for RX and interrupt */
1463 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1464 reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1465 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1469 * ixgbe_enable_mdd_X550
1470 * @hw: pointer to hardware structure
1472 * Enable malicious driver detection
1474 void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
1478 DEBUGFUNC("ixgbe_enable_mdd_X550");
1480 /* Enable MDD for TX DMA and interrupt */
1481 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1482 reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1483 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1485 /* Enable MDD for RX and interrupt */
1486 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1487 reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1488 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1492 * ixgbe_restore_mdd_vf_X550
1493 * @hw: pointer to hardware structure
1496 * Restore VF that was disabled during malicious driver detection event
1498 void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
1500 u32 idx, reg, num_qs, start_q, bitmask;
1502 DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
1504 /* Map VF to queues */
1505 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1506 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1507 case IXGBE_MRQC_VMDQRT8TCEN:
1508 num_qs = 8; /* 16 VFs / pools */
1509 bitmask = 0x000000FF;
1511 case IXGBE_MRQC_VMDQRSS32EN:
1512 case IXGBE_MRQC_VMDQRT4TCEN:
1513 num_qs = 4; /* 32 VFs / pools */
1514 bitmask = 0x0000000F;
1516 default: /* 64 VFs / pools */
1518 bitmask = 0x00000003;
1521 start_q = vf * num_qs;
1523 /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1526 reg |= (bitmask << (start_q % 32));
1527 IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1528 IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1532 * ixgbe_mdd_event_X550
1533 * @hw: pointer to hardware structure
1534 * @vf_bitmap: vf bitmap of malicious vfs
1536 * Handle malicious driver detection event.
1538 void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1541 u32 i, j, reg, q, shift, vf, idx;
1543 DEBUGFUNC("ixgbe_mdd_event_X550");
1545 /* figure out pool size for mapping to vf's */
1546 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1547 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1548 case IXGBE_MRQC_VMDQRT8TCEN:
1549 shift = 3; /* 16 VFs / pools */
1551 case IXGBE_MRQC_VMDQRSS32EN:
1552 case IXGBE_MRQC_VMDQRT4TCEN:
1553 shift = 2; /* 32 VFs / pools */
1556 shift = 1; /* 64 VFs / pools */
1560 /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1561 for (i = 0; i < 4; i++) {
1562 wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1563 wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1568 /* Get malicious queue */
1569 for (j = 0; j < 32 && wqbr; j++) {
1571 if (!(wqbr & (1 << j)))
1574 /* Get queue from bitmask */
1577 /* Map queue to vf */
1580 /* Set vf bit in vf_bitmap */
1582 vf_bitmap[idx] |= (1 << (vf % 32));
1589 * ixgbe_get_media_type_X550em - Get media type
1590 * @hw: pointer to hardware structure
1592 * Returns the media type (fiber, copper, backplane)
1594 enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1596 enum ixgbe_media_type media_type;
1598 DEBUGFUNC("ixgbe_get_media_type_X550em");
1600 /* Detect if there is a copper PHY attached. */
1601 switch (hw->device_id) {
1602 case IXGBE_DEV_ID_X550EM_X_KR:
1603 case IXGBE_DEV_ID_X550EM_X_KX4:
1604 case IXGBE_DEV_ID_X550EM_X_XFI:
1605 case IXGBE_DEV_ID_X550EM_A_KR:
1606 case IXGBE_DEV_ID_X550EM_A_KR_L:
1607 media_type = ixgbe_media_type_backplane;
1609 case IXGBE_DEV_ID_X550EM_X_SFP:
1610 case IXGBE_DEV_ID_X550EM_A_SFP:
1611 case IXGBE_DEV_ID_X550EM_A_SFP_N:
1612 case IXGBE_DEV_ID_X550EM_A_QSFP:
1613 case IXGBE_DEV_ID_X550EM_A_QSFP_N:
1614 media_type = ixgbe_media_type_fiber;
1616 case IXGBE_DEV_ID_X550EM_X_1G_T:
1617 case IXGBE_DEV_ID_X550EM_X_10G_T:
1618 case IXGBE_DEV_ID_X550EM_A_10G_T:
1619 media_type = ixgbe_media_type_copper;
1621 case IXGBE_DEV_ID_X550EM_A_SGMII:
1622 case IXGBE_DEV_ID_X550EM_A_SGMII_L:
1623 media_type = ixgbe_media_type_backplane;
1624 hw->phy.type = ixgbe_phy_sgmii;
1626 case IXGBE_DEV_ID_X550EM_A_1G_T:
1627 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
1628 media_type = ixgbe_media_type_copper;
1631 media_type = ixgbe_media_type_unknown;
1638 * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1639 * @hw: pointer to hardware structure
1640 * @linear: true if SFP module is linear
1642 STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1644 DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1646 switch (hw->phy.sfp_type) {
1647 case ixgbe_sfp_type_not_present:
1648 return IXGBE_ERR_SFP_NOT_PRESENT;
1649 case ixgbe_sfp_type_da_cu_core0:
1650 case ixgbe_sfp_type_da_cu_core1:
1653 case ixgbe_sfp_type_srlr_core0:
1654 case ixgbe_sfp_type_srlr_core1:
1655 case ixgbe_sfp_type_da_act_lmt_core0:
1656 case ixgbe_sfp_type_da_act_lmt_core1:
1657 case ixgbe_sfp_type_1g_sx_core0:
1658 case ixgbe_sfp_type_1g_sx_core1:
1659 case ixgbe_sfp_type_1g_lx_core0:
1660 case ixgbe_sfp_type_1g_lx_core1:
1663 case ixgbe_sfp_type_unknown:
1664 case ixgbe_sfp_type_1g_cu_core0:
1665 case ixgbe_sfp_type_1g_cu_core1:
1667 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1670 return IXGBE_SUCCESS;
1674 * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1675 * @hw: pointer to hardware structure
1677 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1679 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1684 DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1686 status = ixgbe_identify_module_generic(hw);
1688 if (status != IXGBE_SUCCESS)
1691 /* Check if SFP module is supported */
1692 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1698 * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1699 * @hw: pointer to hardware structure
1701 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1706 DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1708 /* Check if SFP module is supported */
1709 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1711 if (status != IXGBE_SUCCESS)
1714 ixgbe_init_mac_link_ops_X550em(hw);
1715 hw->phy.ops.reset = NULL;
1717 return IXGBE_SUCCESS;
1721 * ixgbe_restart_an_internal_phy_x550em - restart autonegotiation for the
1723 * @hw: pointer to hardware structure
1725 STATIC s32 ixgbe_restart_an_internal_phy_x550em(struct ixgbe_hw *hw)
1730 /* Restart auto-negotiation. */
1731 status = hw->mac.ops.read_iosf_sb_reg(hw,
1732 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1733 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_ctrl);
1736 DEBUGOUT("Auto-negotiation did not complete\n");
1740 link_ctrl |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1741 status = hw->mac.ops.write_iosf_sb_reg(hw,
1742 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1743 IXGBE_SB_IOSF_TARGET_KR_PHY, link_ctrl);
1745 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1748 /* Indicate to FW that AN restart has been asserted */
1749 status = hw->mac.ops.read_iosf_sb_reg(hw,
1750 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1751 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_mask_st20);
1754 DEBUGOUT("Auto-negotiation did not complete\n");
1758 flx_mask_st20 |= IXGBE_KRM_PMD_FLX_MASK_ST20_FW_AN_RESTART;
1759 status = hw->mac.ops.write_iosf_sb_reg(hw,
1760 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1761 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_mask_st20);
1768 * ixgbe_setup_sgmii - Set up link for sgmii
1769 * @hw: pointer to hardware structure
1771 STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
1774 struct ixgbe_mac_info *mac = &hw->mac;
1775 u32 lval, sval, flx_val;
1778 rc = mac->ops.read_iosf_sb_reg(hw,
1779 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1780 IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
1784 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1785 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1786 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
1787 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
1788 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1789 rc = mac->ops.write_iosf_sb_reg(hw,
1790 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1791 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1795 rc = mac->ops.read_iosf_sb_reg(hw,
1796 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1797 IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
1801 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
1802 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
1803 rc = mac->ops.write_iosf_sb_reg(hw,
1804 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1805 IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
1809 rc = mac->ops.read_iosf_sb_reg(hw,
1810 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1811 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
1815 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
1816 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
1817 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
1818 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
1819 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
1821 rc = mac->ops.write_iosf_sb_reg(hw,
1822 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1823 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
1827 rc = ixgbe_restart_an_internal_phy_x550em(hw);
1831 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
1835 * ixgbe_setup_sgmii_fw - Set up link for sgmii with firmware-controlled PHYs
1836 * @hw: pointer to hardware structure
1838 STATIC s32 ixgbe_setup_sgmii_fw(struct ixgbe_hw *hw, ixgbe_link_speed speed,
1841 struct ixgbe_mac_info *mac = &hw->mac;
1842 u32 lval, sval, flx_val;
1845 rc = mac->ops.read_iosf_sb_reg(hw,
1846 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1847 IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
1851 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1852 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1853 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
1854 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
1855 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1856 rc = mac->ops.write_iosf_sb_reg(hw,
1857 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1858 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1862 rc = mac->ops.read_iosf_sb_reg(hw,
1863 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1864 IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
1868 sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
1869 sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
1870 rc = mac->ops.write_iosf_sb_reg(hw,
1871 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1872 IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
1876 rc = mac->ops.write_iosf_sb_reg(hw,
1877 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1878 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1882 rc = mac->ops.read_iosf_sb_reg(hw,
1883 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1884 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
1888 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
1889 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
1890 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
1891 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
1892 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
1894 rc = mac->ops.write_iosf_sb_reg(hw,
1895 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1896 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
1900 rc = ixgbe_restart_an_internal_phy_x550em(hw);
1902 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
1906 * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1907 * @hw: pointer to hardware structure
1909 void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1911 struct ixgbe_mac_info *mac = &hw->mac;
1913 DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1915 switch (hw->mac.ops.get_media_type(hw)) {
1916 case ixgbe_media_type_fiber:
1917 /* CS4227 does not support autoneg, so disable the laser control
1918 * functions for SFP+ fiber
1920 mac->ops.disable_tx_laser = NULL;
1921 mac->ops.enable_tx_laser = NULL;
1922 mac->ops.flap_tx_laser = NULL;
1923 mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1924 mac->ops.set_rate_select_speed =
1925 ixgbe_set_soft_rate_select_speed;
1927 if ((hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) ||
1928 (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP))
1929 mac->ops.setup_mac_link =
1930 ixgbe_setup_mac_link_sfp_x550a;
1932 mac->ops.setup_mac_link =
1933 ixgbe_setup_mac_link_sfp_x550em;
1935 case ixgbe_media_type_copper:
1936 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T)
1938 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1939 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T ||
1940 hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) {
1941 mac->ops.setup_link = ixgbe_setup_sgmii_fw;
1942 mac->ops.check_link =
1943 ixgbe_check_mac_link_generic;
1945 mac->ops.setup_link =
1946 ixgbe_setup_mac_link_t_X550em;
1949 mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1950 mac->ops.check_link = ixgbe_check_link_t_X550em;
1953 case ixgbe_media_type_backplane:
1954 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
1955 hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
1956 mac->ops.setup_link = ixgbe_setup_sgmii;
1964 * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1965 * @hw: pointer to hardware structure
1966 * @speed: pointer to link speed
1967 * @autoneg: true when autoneg or autotry is enabled
1969 s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1970 ixgbe_link_speed *speed,
1973 DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1976 if (hw->phy.type == ixgbe_phy_fw) {
1978 *speed = hw->phy.speeds_supported;
1983 if (hw->phy.media_type == ixgbe_media_type_fiber) {
1985 /* CS4227 SFP must not enable auto-negotiation */
1988 /* Check if 1G SFP module. */
1989 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1990 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1991 || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1992 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1993 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1994 return IXGBE_SUCCESS;
1997 /* Link capabilities are based on SFP */
1998 if (hw->phy.multispeed_fiber)
1999 *speed = IXGBE_LINK_SPEED_10GB_FULL |
2000 IXGBE_LINK_SPEED_1GB_FULL;
2002 *speed = IXGBE_LINK_SPEED_10GB_FULL;
2004 switch (hw->phy.type) {
2005 case ixgbe_phy_ext_1g_t:
2006 case ixgbe_phy_sgmii:
2007 *speed = IXGBE_LINK_SPEED_1GB_FULL;
2009 case ixgbe_phy_x550em_kr:
2010 if (hw->mac.type == ixgbe_mac_X550EM_a) {
2011 /* check different backplane modes */
2012 if (hw->phy.nw_mng_if_sel &
2013 IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
2014 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
2016 } else if (hw->device_id ==
2017 IXGBE_DEV_ID_X550EM_A_KR_L) {
2018 *speed = IXGBE_LINK_SPEED_1GB_FULL;
2024 *speed = IXGBE_LINK_SPEED_10GB_FULL |
2025 IXGBE_LINK_SPEED_1GB_FULL;
2031 return IXGBE_SUCCESS;
2035 * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
2036 * @hw: pointer to hardware structure
2037 * @lsc: pointer to boolean flag which indicates whether external Base T
2038 * PHY interrupt is lsc
2040 * Determime if external Base T PHY interrupt cause is high temperature
2041 * failure alarm or link status change.
2043 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
2044 * failure alarm, else return PHY access status.
2046 STATIC s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
2053 /* Vendor alarm triggered */
2054 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
2055 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2058 if (status != IXGBE_SUCCESS ||
2059 !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
2062 /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
2063 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
2064 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2067 if (status != IXGBE_SUCCESS ||
2068 !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
2069 IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
2072 /* Global alarm triggered */
2073 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
2074 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2077 if (status != IXGBE_SUCCESS)
2080 /* If high temperature failure, then return over temp error and exit */
2081 if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
2082 /* power down the PHY in case the PHY FW didn't already */
2083 ixgbe_set_copper_phy_power(hw, false);
2084 return IXGBE_ERR_OVERTEMP;
2085 } else if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
2086 /* device fault alarm triggered */
2087 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
2088 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2091 if (status != IXGBE_SUCCESS)
2094 /* if device fault was due to high temp alarm handle and exit */
2095 if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
2096 /* power down the PHY in case the PHY FW didn't */
2097 ixgbe_set_copper_phy_power(hw, false);
2098 return IXGBE_ERR_OVERTEMP;
2102 /* Vendor alarm 2 triggered */
2103 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
2104 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2106 if (status != IXGBE_SUCCESS ||
2107 !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
2110 /* link connect/disconnect event occurred */
2111 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
2112 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2114 if (status != IXGBE_SUCCESS)
2118 if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
2121 return IXGBE_SUCCESS;
2125 * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
2126 * @hw: pointer to hardware structure
2128 * Enable link status change and temperature failure alarm for the external
2131 * Returns PHY access status
2133 STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
2139 /* Clear interrupt flags */
2140 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
2142 /* Enable link status change alarm */
2144 /* Enable the LASI interrupts on X552 devices to receive notifications
2145 * of the link configurations of the external PHY and correspondingly
2146 * support the configuration of the internal iXFI link, since iXFI does
2147 * not support auto-negotiation. This is not required for X553 devices
2148 * having KR support, which performs auto-negotiations and which is used
2149 * as the internal link to the external PHY. Hence adding a check here
2150 * to avoid enabling LASI interrupts for X553 devices.
2152 if (hw->mac.type != ixgbe_mac_X550EM_a) {
2153 status = hw->phy.ops.read_reg(hw,
2154 IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
2155 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2157 if (status != IXGBE_SUCCESS)
2160 reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
2162 status = hw->phy.ops.write_reg(hw,
2163 IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
2164 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
2166 if (status != IXGBE_SUCCESS)
2170 /* Enable high temperature failure and global fault alarms */
2171 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
2172 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2175 if (status != IXGBE_SUCCESS)
2178 reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
2179 IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
2181 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
2182 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2185 if (status != IXGBE_SUCCESS)
2188 /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
2189 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
2190 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2193 if (status != IXGBE_SUCCESS)
2196 reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
2197 IXGBE_MDIO_GLOBAL_ALARM_1_INT);
2199 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
2200 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2203 if (status != IXGBE_SUCCESS)
2206 /* Enable chip-wide vendor alarm */
2207 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
2208 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2211 if (status != IXGBE_SUCCESS)
2214 reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
2216 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
2217 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2224 * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
2225 * @hw: pointer to hardware structure
2226 * @speed: link speed
2228 * Configures the integrated KR PHY.
2230 STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
2231 ixgbe_link_speed speed)
2236 status = hw->mac.ops.read_iosf_sb_reg(hw,
2237 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2238 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2242 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2243 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
2244 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
2246 /* Advertise 10G support. */
2247 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
2248 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
2250 /* Advertise 1G support. */
2251 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
2252 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
2254 status = hw->mac.ops.write_iosf_sb_reg(hw,
2255 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2256 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2258 if (hw->mac.type == ixgbe_mac_X550EM_a) {
2259 /* Set lane mode to KR auto negotiation */
2260 status = hw->mac.ops.read_iosf_sb_reg(hw,
2261 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2262 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2267 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
2268 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
2269 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
2270 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
2271 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
2273 status = hw->mac.ops.write_iosf_sb_reg(hw,
2274 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2275 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2278 return ixgbe_restart_an_internal_phy_x550em(hw);
2282 * ixgbe_reset_phy_fw - Reset firmware-controlled PHYs
2283 * @hw: pointer to hardware structure
2285 static s32 ixgbe_reset_phy_fw(struct ixgbe_hw *hw)
2287 u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
2290 if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
2291 return IXGBE_SUCCESS;
2293 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_PHY_SW_RESET, &store);
2296 memset(store, 0, sizeof(store));
2298 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_INIT_PHY, &store);
2302 return ixgbe_setup_fw_link(hw);
2306 * ixgbe_check_overtemp_fw - Check firmware-controlled PHYs for overtemp
2307 * @hw: pointer to hardware structure
2309 static s32 ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
2311 u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
2314 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &store);
2318 if (store[0] & FW_PHY_ACT_GET_LINK_INFO_TEMP) {
2319 ixgbe_shutdown_fw_phy(hw);
2320 return IXGBE_ERR_OVERTEMP;
2322 return IXGBE_SUCCESS;
2326 * ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
2327 * @hw: pointer to hardware structure
2329 * Read NW_MNG_IF_SEL register and save field values, and check for valid field
2332 STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
2334 /* Save NW management interface connected on board. This is used
2335 * to determine internal PHY mode.
2337 hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
2339 /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
2340 * PHY address. This register field was has only been used for X552.
2342 if (hw->mac.type == ixgbe_mac_X550EM_a &&
2343 hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
2344 hw->phy.addr = (hw->phy.nw_mng_if_sel &
2345 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
2346 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
2349 return IXGBE_SUCCESS;
2353 * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
2354 * @hw: pointer to hardware structure
2356 * Initialize any function pointers that were not able to be
2357 * set during init_shared_code because the PHY/SFP type was
2358 * not known. Perform the SFP init if necessary.
2360 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
2362 struct ixgbe_phy_info *phy = &hw->phy;
2365 DEBUGFUNC("ixgbe_init_phy_ops_X550em");
2367 hw->mac.ops.set_lan_id(hw);
2368 ixgbe_read_mng_if_sel_x550em(hw);
2370 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
2371 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
2372 ixgbe_setup_mux_ctl(hw);
2373 phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
2376 switch (hw->device_id) {
2377 case IXGBE_DEV_ID_X550EM_A_1G_T:
2378 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
2379 phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi_22;
2380 phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi_22;
2381 hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
2382 hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
2383 phy->ops.check_overtemp = ixgbe_check_overtemp_fw;
2385 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
2387 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
2390 case IXGBE_DEV_ID_X550EM_A_10G_T:
2391 case IXGBE_DEV_ID_X550EM_A_SFP:
2392 hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
2393 hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
2395 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
2397 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
2399 case IXGBE_DEV_ID_X550EM_X_SFP:
2400 /* set up for CS4227 usage */
2401 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
2407 /* Identify the PHY or SFP module */
2408 ret_val = phy->ops.identify(hw);
2409 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED ||
2410 ret_val == IXGBE_ERR_PHY_ADDR_INVALID)
2413 /* Setup function pointers based on detected hardware */
2414 ixgbe_init_mac_link_ops_X550em(hw);
2415 if (phy->sfp_type != ixgbe_sfp_type_unknown)
2416 phy->ops.reset = NULL;
2418 /* Set functions pointers based on phy type */
2419 switch (hw->phy.type) {
2420 case ixgbe_phy_x550em_kx4:
2421 phy->ops.setup_link = NULL;
2422 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2423 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2425 case ixgbe_phy_x550em_kr:
2426 phy->ops.setup_link = ixgbe_setup_kr_x550em;
2427 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2428 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2430 case ixgbe_phy_ext_1g_t:
2431 /* link is managed by FW */
2432 phy->ops.setup_link = NULL;
2433 phy->ops.reset = NULL;
2435 case ixgbe_phy_x550em_xfi:
2436 /* link is managed by HW */
2437 phy->ops.setup_link = NULL;
2438 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2439 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2441 case ixgbe_phy_x550em_ext_t:
2442 /* If internal link mode is XFI, then setup iXFI internal link,
2443 * else setup KR now.
2445 phy->ops.setup_internal_link =
2446 ixgbe_setup_internal_phy_t_x550em;
2448 /* setup SW LPLU only for first revision of X550EM_x */
2449 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
2450 !(IXGBE_FUSES0_REV_MASK &
2451 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
2452 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
2454 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
2455 phy->ops.reset = ixgbe_reset_phy_t_X550em;
2457 case ixgbe_phy_sgmii:
2458 phy->ops.setup_link = NULL;
2461 phy->ops.setup_link = ixgbe_setup_fw_link;
2462 phy->ops.reset = ixgbe_reset_phy_fw;
2471 * ixgbe_set_mdio_speed - Set MDIO clock speed
2472 * @hw: pointer to hardware structure
2474 STATIC void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
2478 switch (hw->device_id) {
2479 case IXGBE_DEV_ID_X550EM_X_10G_T:
2480 case IXGBE_DEV_ID_X550EM_A_SGMII:
2481 case IXGBE_DEV_ID_X550EM_A_SGMII_L:
2482 case IXGBE_DEV_ID_X550EM_A_10G_T:
2483 case IXGBE_DEV_ID_X550EM_A_SFP:
2484 case IXGBE_DEV_ID_X550EM_A_QSFP:
2485 /* Config MDIO clock speed before the first MDIO PHY access */
2486 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
2487 hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
2488 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
2490 case IXGBE_DEV_ID_X550EM_A_1G_T:
2491 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
2492 /* Select fast MDIO clock speed for these devices */
2493 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
2494 hlreg0 |= IXGBE_HLREG0_MDCSPD;
2495 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
2503 * ixgbe_reset_hw_X550em - Perform hardware reset
2504 * @hw: pointer to hardware structure
2506 * Resets the hardware by resetting the transmit and receive units, masks
2507 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
2510 s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
2512 ixgbe_link_speed link_speed;
2516 bool link_up = false;
2517 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2519 DEBUGFUNC("ixgbe_reset_hw_X550em");
2521 /* Call adapter stop to disable Tx/Rx and clear interrupts */
2522 status = hw->mac.ops.stop_adapter(hw);
2523 if (status != IXGBE_SUCCESS) {
2524 DEBUGOUT1("Failed to stop adapter, STATUS = %d\n", status);
2527 /* flush pending Tx transactions */
2528 ixgbe_clear_tx_pending(hw);
2530 ixgbe_set_mdio_speed(hw);
2532 /* PHY ops must be identified and initialized prior to reset */
2533 status = hw->phy.ops.init(hw);
2536 DEBUGOUT1("Failed to initialize PHY ops, STATUS = %d\n",
2539 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED) {
2540 DEBUGOUT("Returning from reset HW due to PHY init failure\n");
2544 /* start the external PHY */
2545 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
2546 status = ixgbe_init_ext_t_x550em(hw);
2548 DEBUGOUT1("Failed to start the external PHY, STATUS = %d\n",
2554 /* Setup SFP module if there is one present. */
2555 if (hw->phy.sfp_setup_needed) {
2556 status = hw->mac.ops.setup_sfp(hw);
2557 hw->phy.sfp_setup_needed = false;
2560 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
2564 if (!hw->phy.reset_disable && hw->phy.ops.reset) {
2565 if (hw->phy.ops.reset(hw) == IXGBE_ERR_OVERTEMP)
2566 return IXGBE_ERR_OVERTEMP;
2570 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
2571 * If link reset is used when link is up, it might reset the PHY when
2572 * mng is using it. If link is down or the flag to force full link
2573 * reset is set, then perform link reset.
2575 ctrl = IXGBE_CTRL_LNK_RST;
2576 if (!hw->force_full_reset) {
2577 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
2579 ctrl = IXGBE_CTRL_RST;
2582 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
2583 if (status != IXGBE_SUCCESS) {
2584 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
2585 "semaphore failed with %d", status);
2586 return IXGBE_ERR_SWFW_SYNC;
2588 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
2589 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
2590 IXGBE_WRITE_FLUSH(hw);
2591 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2593 /* Poll for reset bit to self-clear meaning reset is complete */
2594 for (i = 0; i < 10; i++) {
2596 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
2597 if (!(ctrl & IXGBE_CTRL_RST_MASK))
2601 if (ctrl & IXGBE_CTRL_RST_MASK) {
2602 status = IXGBE_ERR_RESET_FAILED;
2603 DEBUGOUT("Reset polling failed to complete.\n");
2608 /* Double resets are required for recovery from certain error
2609 * conditions. Between resets, it is necessary to stall to
2610 * allow time for any pending HW events to complete.
2612 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
2613 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
2617 /* Store the permanent mac address */
2618 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
2620 /* Store MAC address from RAR0, clear receive address registers, and
2621 * clear the multicast table. Also reset num_rar_entries to 128,
2622 * since we modify this value when programming the SAN MAC address.
2624 hw->mac.num_rar_entries = 128;
2625 hw->mac.ops.init_rx_addrs(hw);
2627 ixgbe_set_mdio_speed(hw);
2629 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
2630 ixgbe_setup_mux_ctl(hw);
2632 if (status != IXGBE_SUCCESS)
2633 DEBUGOUT1("Reset HW failed, STATUS = %d\n", status);
2639 * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
2640 * @hw: pointer to hardware structure
2642 s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
2647 status = hw->phy.ops.read_reg(hw,
2648 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
2649 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2652 if (status != IXGBE_SUCCESS)
2655 /* If PHY FW reset completed bit is set then this is the first
2656 * SW instance after a power on so the PHY FW must be un-stalled.
2658 if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
2659 status = hw->phy.ops.read_reg(hw,
2660 IXGBE_MDIO_GLOBAL_RES_PR_10,
2661 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2664 if (status != IXGBE_SUCCESS)
2667 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
2669 status = hw->phy.ops.write_reg(hw,
2670 IXGBE_MDIO_GLOBAL_RES_PR_10,
2671 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2674 if (status != IXGBE_SUCCESS)
2682 * ixgbe_setup_kr_x550em - Configure the KR PHY.
2683 * @hw: pointer to hardware structure
2685 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
2687 /* leave link alone for 2.5G */
2688 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
2689 return IXGBE_SUCCESS;
2691 if (ixgbe_check_reset_blocked(hw))
2694 return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
2698 * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
2699 * @hw: pointer to hardware structure
2701 * Configure the external PHY and the integrated KR PHY for SFP support.
2703 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
2704 ixgbe_link_speed speed,
2705 bool autoneg_wait_to_complete)
2708 u16 reg_slice, reg_val;
2709 bool setup_linear = false;
2710 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2712 /* Check if SFP module is supported and linear */
2713 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2715 /* If no SFP module present, then return success. Return success since
2716 * there is no reason to configure CS4227 and SFP not present error is
2717 * not excepted in the setup MAC link flow.
2719 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2720 return IXGBE_SUCCESS;
2722 if (ret_val != IXGBE_SUCCESS)
2725 /* Configure internal PHY for KR/KX. */
2726 ixgbe_setup_kr_speed_x550em(hw, speed);
2728 /* Configure CS4227 LINE side to proper mode. */
2729 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
2730 (hw->bus.lan_id << 12);
2732 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2734 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2735 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2741 * ixgbe_setup_sfi_x550a - Configure the internal PHY for native SFI mode
2742 * @hw: pointer to hardware structure
2743 * @speed: the link speed to force
2745 * Configures the integrated PHY for native SFI mode. Used to connect the
2746 * internal PHY directly to an SFP cage, without autonegotiation.
2748 STATIC s32 ixgbe_setup_sfi_x550a(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2750 struct ixgbe_mac_info *mac = &hw->mac;
2754 /* Disable all AN and force speed to 10G Serial. */
2755 status = mac->ops.read_iosf_sb_reg(hw,
2756 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2757 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2758 if (status != IXGBE_SUCCESS)
2761 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
2762 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
2763 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
2764 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
2766 /* Select forced link speed for internal PHY. */
2768 case IXGBE_LINK_SPEED_10GB_FULL:
2769 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_10G;
2771 case IXGBE_LINK_SPEED_1GB_FULL:
2772 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
2775 /* Other link speeds are not supported by internal PHY. */
2776 return IXGBE_ERR_LINK_SETUP;
2779 status = mac->ops.write_iosf_sb_reg(hw,
2780 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2781 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2783 /* Toggle port SW reset by AN reset. */
2784 status = ixgbe_restart_an_internal_phy_x550em(hw);
2790 * ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
2791 * @hw: pointer to hardware structure
2793 * Configure the the integrated PHY for SFP support.
2795 s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
2796 ixgbe_link_speed speed,
2797 bool autoneg_wait_to_complete)
2801 bool setup_linear = false;
2802 u32 reg_slice, reg_phy_int, slice_offset;
2804 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2806 /* Check if SFP module is supported and linear */
2807 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2809 /* If no SFP module present, then return success. Return success since
2810 * SFP not present error is not excepted in the setup MAC link flow.
2812 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2813 return IXGBE_SUCCESS;
2815 if (ret_val != IXGBE_SUCCESS)
2818 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) {
2819 /* Configure internal PHY for native SFI based on module type */
2820 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
2821 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2822 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_phy_int);
2824 if (ret_val != IXGBE_SUCCESS)
2827 reg_phy_int &= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_DA;
2829 reg_phy_int |= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_SR;
2831 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
2832 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2833 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_phy_int);
2835 if (ret_val != IXGBE_SUCCESS)
2838 /* Setup SFI internal link. */
2839 ret_val = ixgbe_setup_sfi_x550a(hw, &speed);
2841 /* Configure internal PHY for KR/KX. */
2842 ixgbe_setup_kr_speed_x550em(hw, speed);
2844 if (hw->phy.addr == 0x0 || hw->phy.addr == 0xFFFF) {
2846 DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
2847 return IXGBE_ERR_PHY_ADDR_INVALID;
2850 /* Get external PHY SKU id */
2851 ret_val = hw->phy.ops.read_reg(hw, IXGBE_CS4227_EFUSE_PDF_SKU,
2852 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2854 if (ret_val != IXGBE_SUCCESS)
2857 /* When configuring quad port CS4223, the MAC instance is part
2858 * of the slice offset.
2860 if (reg_phy_ext == IXGBE_CS4223_SKU_ID)
2861 slice_offset = (hw->bus.lan_id +
2862 (hw->bus.instance_id << 1)) << 12;
2864 slice_offset = hw->bus.lan_id << 12;
2866 /* Configure CS4227/CS4223 LINE side to proper mode. */
2867 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
2869 ret_val = hw->phy.ops.read_reg(hw, reg_slice,
2870 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2872 if (ret_val != IXGBE_SUCCESS)
2875 reg_phy_ext &= ~((IXGBE_CS4227_EDC_MODE_CX1 << 1) |
2876 (IXGBE_CS4227_EDC_MODE_SR << 1));
2879 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2881 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2882 ret_val = hw->phy.ops.write_reg(hw, reg_slice,
2883 IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
2885 /* Flush previous write with a read */
2886 ret_val = hw->phy.ops.read_reg(hw, reg_slice,
2887 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2893 * ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
2894 * @hw: pointer to hardware structure
2896 * iXfI configuration needed for ixgbe_mac_X550EM_x devices.
2898 STATIC s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
2900 struct ixgbe_mac_info *mac = &hw->mac;
2904 /* Disable training protocol FSM. */
2905 status = mac->ops.read_iosf_sb_reg(hw,
2906 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2907 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2908 if (status != IXGBE_SUCCESS)
2910 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
2911 status = mac->ops.write_iosf_sb_reg(hw,
2912 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2913 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2914 if (status != IXGBE_SUCCESS)
2917 /* Disable Flex from training TXFFE. */
2918 status = mac->ops.read_iosf_sb_reg(hw,
2919 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2920 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2921 if (status != IXGBE_SUCCESS)
2923 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2924 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2925 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2926 status = mac->ops.write_iosf_sb_reg(hw,
2927 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2928 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2929 if (status != IXGBE_SUCCESS)
2931 status = mac->ops.read_iosf_sb_reg(hw,
2932 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2933 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2934 if (status != IXGBE_SUCCESS)
2936 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2937 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2938 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2939 status = mac->ops.write_iosf_sb_reg(hw,
2940 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2941 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2942 if (status != IXGBE_SUCCESS)
2945 /* Enable override for coefficients. */
2946 status = mac->ops.read_iosf_sb_reg(hw,
2947 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2948 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2949 if (status != IXGBE_SUCCESS)
2951 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
2952 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
2953 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
2954 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
2955 status = mac->ops.write_iosf_sb_reg(hw,
2956 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2957 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2962 * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
2963 * @hw: pointer to hardware structure
2964 * @speed: the link speed to force
2966 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
2967 * internal and external PHY at a specific speed, without autonegotiation.
2969 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2971 struct ixgbe_mac_info *mac = &hw->mac;
2975 /* iXFI is only supported with X552 */
2976 if (mac->type != ixgbe_mac_X550EM_x)
2977 return IXGBE_ERR_LINK_SETUP;
2979 /* Disable AN and force speed to 10G Serial. */
2980 status = mac->ops.read_iosf_sb_reg(hw,
2981 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2982 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2983 if (status != IXGBE_SUCCESS)
2986 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2987 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2989 /* Select forced link speed for internal PHY. */
2991 case IXGBE_LINK_SPEED_10GB_FULL:
2992 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2994 case IXGBE_LINK_SPEED_1GB_FULL:
2995 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
2998 /* Other link speeds are not supported by internal KR PHY. */
2999 return IXGBE_ERR_LINK_SETUP;
3002 status = mac->ops.write_iosf_sb_reg(hw,
3003 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
3004 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3005 if (status != IXGBE_SUCCESS)
3008 /* Additional configuration needed for x550em_x */
3009 if (hw->mac.type == ixgbe_mac_X550EM_x) {
3010 status = ixgbe_setup_ixfi_x550em_x(hw);
3011 if (status != IXGBE_SUCCESS)
3015 /* Toggle port SW reset by AN reset. */
3016 status = ixgbe_restart_an_internal_phy_x550em(hw);
3022 * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
3023 * @hw: address of hardware structure
3024 * @link_up: address of boolean to indicate link status
3026 * Returns error code if unable to get link status.
3028 STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
3035 /* read this twice back to back to indicate current status */
3036 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3037 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3039 if (ret != IXGBE_SUCCESS)
3042 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3043 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3045 if (ret != IXGBE_SUCCESS)
3048 *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
3050 return IXGBE_SUCCESS;
3054 * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
3055 * @hw: point to hardware structure
3057 * Configures the link between the integrated KR PHY and the external X557 PHY
3058 * The driver will call this function when it gets a link status change
3059 * interrupt from the X557 PHY. This function configures the link speed
3060 * between the PHYs to match the link speed of the BASE-T link.
3062 * A return of a non-zero value indicates an error, and the base driver should
3063 * not report link up.
3065 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
3067 ixgbe_link_speed force_speed;
3072 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
3073 return IXGBE_ERR_CONFIG;
3075 if (hw->mac.type == ixgbe_mac_X550EM_x &&
3076 !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
3077 /* If link is down, there is no setup necessary so return */
3078 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3079 if (status != IXGBE_SUCCESS)
3083 return IXGBE_SUCCESS;
3085 status = hw->phy.ops.read_reg(hw,
3086 IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
3087 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3089 if (status != IXGBE_SUCCESS)
3092 /* If link is still down - no setup is required so return */
3093 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3094 if (status != IXGBE_SUCCESS)
3097 return IXGBE_SUCCESS;
3099 /* clear everything but the speed and duplex bits */
3100 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
3103 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
3104 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
3106 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
3107 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
3110 /* Internal PHY does not support anything else */
3111 return IXGBE_ERR_INVALID_LINK_SETTINGS;
3114 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
3116 speed = IXGBE_LINK_SPEED_10GB_FULL |
3117 IXGBE_LINK_SPEED_1GB_FULL;
3118 return ixgbe_setup_kr_speed_x550em(hw, speed);
3123 * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
3124 * @hw: pointer to hardware structure
3126 * Configures the integrated KR PHY to use internal loopback mode.
3128 s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
3133 /* Disable AN and force speed to 10G Serial. */
3134 status = hw->mac.ops.read_iosf_sb_reg(hw,
3135 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
3136 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3137 if (status != IXGBE_SUCCESS)
3139 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
3140 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
3141 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
3142 status = hw->mac.ops.write_iosf_sb_reg(hw,
3143 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
3144 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3145 if (status != IXGBE_SUCCESS)
3148 /* Set near-end loopback clocks. */
3149 status = hw->mac.ops.read_iosf_sb_reg(hw,
3150 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
3151 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3152 if (status != IXGBE_SUCCESS)
3154 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
3155 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
3156 status = hw->mac.ops.write_iosf_sb_reg(hw,
3157 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
3158 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3159 if (status != IXGBE_SUCCESS)
3162 /* Set loopback enable. */
3163 status = hw->mac.ops.read_iosf_sb_reg(hw,
3164 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
3165 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3166 if (status != IXGBE_SUCCESS)
3168 reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
3169 status = hw->mac.ops.write_iosf_sb_reg(hw,
3170 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
3171 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3172 if (status != IXGBE_SUCCESS)
3175 /* Training bypass. */
3176 status = hw->mac.ops.read_iosf_sb_reg(hw,
3177 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
3178 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3179 if (status != IXGBE_SUCCESS)
3181 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
3182 status = hw->mac.ops.write_iosf_sb_reg(hw,
3183 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
3184 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3190 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
3191 * assuming that the semaphore is already obtained.
3192 * @hw: pointer to hardware structure
3193 * @offset: offset of word in the EEPROM to read
3194 * @data: word read from the EEPROM
3196 * Reads a 16 bit word from the EEPROM using the hostif.
3198 s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 *data)
3200 const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
3201 struct ixgbe_hic_read_shadow_ram buffer;
3204 DEBUGFUNC("ixgbe_read_ee_hostif_X550");
3205 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
3206 buffer.hdr.req.buf_lenh = 0;
3207 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
3208 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3210 /* convert offset from words to bytes */
3211 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
3213 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
3215 status = hw->mac.ops.acquire_swfw_sync(hw, mask);
3219 status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
3220 IXGBE_HI_COMMAND_TIMEOUT);
3222 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
3223 FW_NVM_DATA_OFFSET);
3226 hw->mac.ops.release_swfw_sync(hw, mask);
3231 * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
3232 * @hw: pointer to hardware structure
3233 * @offset: offset of word in the EEPROM to read
3234 * @words: number of words
3235 * @data: word(s) read from the EEPROM
3237 * Reads a 16 bit word(s) from the EEPROM using the hostif.
3239 s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
3240 u16 offset, u16 words, u16 *data)
3242 const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
3243 struct ixgbe_hic_read_shadow_ram buffer;
3244 u32 current_word = 0;
3249 DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
3251 /* Take semaphore for the entire operation. */
3252 status = hw->mac.ops.acquire_swfw_sync(hw, mask);
3254 DEBUGOUT("EEPROM read buffer - semaphore failed\n");
3259 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
3260 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
3262 words_to_read = words;
3264 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
3265 buffer.hdr.req.buf_lenh = 0;
3266 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
3267 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3269 /* convert offset from words to bytes */
3270 buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
3271 buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
3273 status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
3274 IXGBE_HI_COMMAND_TIMEOUT);
3277 DEBUGOUT("Host interface command failed\n");
3281 for (i = 0; i < words_to_read; i++) {
3282 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
3284 u32 value = IXGBE_READ_REG(hw, reg);
3286 data[current_word] = (u16)(value & 0xffff);
3289 if (i < words_to_read) {
3291 data[current_word] = (u16)(value & 0xffff);
3295 words -= words_to_read;
3299 hw->mac.ops.release_swfw_sync(hw, mask);
3304 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
3305 * @hw: pointer to hardware structure
3306 * @offset: offset of word in the EEPROM to write
3307 * @data: word write to the EEPROM
3309 * Write a 16 bit word to the EEPROM using the hostif.
3311 s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
3315 struct ixgbe_hic_write_shadow_ram buffer;
3317 DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
3319 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
3320 buffer.hdr.req.buf_lenh = 0;
3321 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
3322 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3325 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
3327 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
3329 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
3331 IXGBE_HI_COMMAND_TIMEOUT, false);
3337 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
3338 * @hw: pointer to hardware structure
3339 * @offset: offset of word in the EEPROM to write
3340 * @data: word write to the EEPROM
3342 * Write a 16 bit word to the EEPROM using the hostif.
3344 s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
3347 s32 status = IXGBE_SUCCESS;
3349 DEBUGFUNC("ixgbe_write_ee_hostif_X550");
3351 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
3353 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
3354 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3356 DEBUGOUT("write ee hostif failed to get semaphore");
3357 status = IXGBE_ERR_SWFW_SYNC;
3364 * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
3365 * @hw: pointer to hardware structure
3366 * @offset: offset of word in the EEPROM to write
3367 * @words: number of words
3368 * @data: word(s) write to the EEPROM
3370 * Write a 16 bit word(s) to the EEPROM using the hostif.
3372 s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
3373 u16 offset, u16 words, u16 *data)
3375 s32 status = IXGBE_SUCCESS;
3378 DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
3380 /* Take semaphore for the entire operation. */
3381 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3382 if (status != IXGBE_SUCCESS) {
3383 DEBUGOUT("EEPROM write buffer - semaphore failed\n");
3387 for (i = 0; i < words; i++) {
3388 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
3391 if (status != IXGBE_SUCCESS) {
3392 DEBUGOUT("Eeprom buffered write failed\n");
3397 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3404 * ixgbe_checksum_ptr_x550 - Checksum one pointer region
3405 * @hw: pointer to hardware structure
3406 * @ptr: pointer offset in eeprom
3407 * @size: size of section pointed by ptr, if 0 first word will be used as size
3408 * @csum: address of checksum to update
3410 * Returns error status for any failure
3412 STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
3413 u16 size, u16 *csum, u16 *buffer,
3418 u16 length, bufsz, i, start;
3421 bufsz = sizeof(buf) / sizeof(buf[0]);
3423 /* Read a chunk at the pointer location */
3425 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
3427 DEBUGOUT("Failed to read EEPROM image\n");
3432 if (buffer_size < ptr)
3433 return IXGBE_ERR_PARAM;
3434 local_buffer = &buffer[ptr];
3442 length = local_buffer[0];
3444 /* Skip pointer section if length is invalid. */
3445 if (length == 0xFFFF || length == 0 ||
3446 (ptr + length) >= hw->eeprom.word_size)
3447 return IXGBE_SUCCESS;
3450 if (buffer && ((u32)start + (u32)length > buffer_size))
3451 return IXGBE_ERR_PARAM;
3453 for (i = start; length; i++, length--) {
3454 if (i == bufsz && !buffer) {
3460 /* Read a chunk at the pointer location */
3461 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
3464 DEBUGOUT("Failed to read EEPROM image\n");
3468 *csum += local_buffer[i];
3470 return IXGBE_SUCCESS;
3474 * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
3475 * @hw: pointer to hardware structure
3476 * @buffer: pointer to buffer containing calculated checksum
3477 * @buffer_size: size of buffer
3479 * Returns a negative error code on error, or the 16-bit checksum
3481 s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
3483 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
3487 u16 pointer, i, size;
3489 DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
3491 hw->eeprom.ops.init_params(hw);
3494 /* Read pointer area */
3495 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
3496 IXGBE_EEPROM_LAST_WORD + 1,
3499 DEBUGOUT("Failed to read EEPROM image\n");
3502 local_buffer = eeprom_ptrs;
3504 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
3505 return IXGBE_ERR_PARAM;
3506 local_buffer = buffer;
3510 * For X550 hardware include 0x0-0x41 in the checksum, skip the
3511 * checksum word itself
3513 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
3514 if (i != IXGBE_EEPROM_CHECKSUM)
3515 checksum += local_buffer[i];
3518 * Include all data from pointers 0x3, 0x6-0xE. This excludes the
3519 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
3521 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
3522 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
3525 pointer = local_buffer[i];
3527 /* Skip pointer section if the pointer is invalid. */
3528 if (pointer == 0xFFFF || pointer == 0 ||
3529 pointer >= hw->eeprom.word_size)
3533 case IXGBE_PCIE_GENERAL_PTR:
3534 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
3536 case IXGBE_PCIE_CONFIG0_PTR:
3537 case IXGBE_PCIE_CONFIG1_PTR:
3538 size = IXGBE_PCIE_CONFIG_SIZE;
3545 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
3546 buffer, buffer_size);
3551 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
3553 return (s32)checksum;
3557 * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
3558 * @hw: pointer to hardware structure
3560 * Returns a negative error code on error, or the 16-bit checksum
3562 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
3564 return ixgbe_calc_checksum_X550(hw, NULL, 0);
3568 * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
3569 * @hw: pointer to hardware structure
3570 * @checksum_val: calculated checksum
3572 * Performs checksum calculation and validates the EEPROM checksum. If the
3573 * caller does not need checksum_val, the value can be NULL.
3575 s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
3579 u16 read_checksum = 0;
3581 DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
3583 /* Read the first word from the EEPROM. If this times out or fails, do
3584 * not continue or we could be in for a very long wait while every
3587 status = hw->eeprom.ops.read(hw, 0, &checksum);
3589 DEBUGOUT("EEPROM read failed\n");
3593 status = hw->eeprom.ops.calc_checksum(hw);
3597 checksum = (u16)(status & 0xffff);
3599 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3604 /* Verify read checksum from EEPROM is the same as
3605 * calculated checksum
3607 if (read_checksum != checksum) {
3608 status = IXGBE_ERR_EEPROM_CHECKSUM;
3609 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
3610 "Invalid EEPROM checksum");
3613 /* If the user cares, return the calculated checksum */
3615 *checksum_val = checksum;
3621 * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
3622 * @hw: pointer to hardware structure
3624 * After writing EEPROM to shadow RAM using EEWR register, software calculates
3625 * checksum and updates the EEPROM and instructs the hardware to update
3628 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
3633 DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
3635 /* Read the first word from the EEPROM. If this times out or fails, do
3636 * not continue or we could be in for a very long wait while every
3639 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
3641 DEBUGOUT("EEPROM read failed\n");
3645 status = ixgbe_calc_eeprom_checksum_X550(hw);
3649 checksum = (u16)(status & 0xffff);
3651 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3656 status = ixgbe_update_flash_X550(hw);
3662 * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
3663 * @hw: pointer to hardware structure
3665 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
3667 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
3669 s32 status = IXGBE_SUCCESS;
3670 union ixgbe_hic_hdr2 buffer;
3672 DEBUGFUNC("ixgbe_update_flash_X550");
3674 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
3675 buffer.req.buf_lenh = 0;
3676 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
3677 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
3679 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
3681 IXGBE_HI_COMMAND_TIMEOUT, false);
3687 * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
3688 * @hw: pointer to hardware structure
3690 * Determines physical layer capabilities of the current configuration.
3692 u64 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
3694 u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
3695 u16 ext_ability = 0;
3697 DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
3699 hw->phy.ops.identify(hw);
3701 switch (hw->phy.type) {
3702 case ixgbe_phy_x550em_kr:
3703 if (hw->mac.type == ixgbe_mac_X550EM_a) {
3704 if (hw->phy.nw_mng_if_sel &
3705 IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
3707 IXGBE_PHYSICAL_LAYER_2500BASE_KX;
3709 } else if (hw->device_id ==
3710 IXGBE_DEV_ID_X550EM_A_KR_L) {
3712 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3717 case ixgbe_phy_x550em_xfi:
3718 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
3719 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3721 case ixgbe_phy_x550em_kx4:
3722 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
3723 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3725 case ixgbe_phy_x550em_ext_t:
3726 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
3727 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
3729 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
3730 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
3731 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
3732 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3735 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_1GB_FULL)
3736 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3737 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_100_FULL)
3738 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
3739 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_10_FULL)
3740 physical_layer |= IXGBE_PHYSICAL_LAYER_10BASE_T;
3742 case ixgbe_phy_sgmii:
3743 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3745 case ixgbe_phy_ext_1g_t:
3746 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3752 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
3753 physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
3755 return physical_layer;
3759 * ixgbe_get_bus_info_x550em - Set PCI bus info
3760 * @hw: pointer to hardware structure
3762 * Sets bus link width and speed to unknown because X550em is
3765 s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
3768 DEBUGFUNC("ixgbe_get_bus_info_x550em");
3770 hw->bus.width = ixgbe_bus_width_unknown;
3771 hw->bus.speed = ixgbe_bus_speed_unknown;
3773 hw->mac.ops.set_lan_id(hw);
3775 return IXGBE_SUCCESS;
3779 * ixgbe_disable_rx_x550 - Disable RX unit
3781 * Enables the Rx DMA unit for x550
3783 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
3785 u32 rxctrl, pfdtxgswc;
3787 struct ixgbe_hic_disable_rxen fw_cmd;
3789 DEBUGFUNC("ixgbe_enable_rx_dma_x550");
3791 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3792 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3793 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
3794 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
3795 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
3796 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
3797 hw->mac.set_lben = true;
3799 hw->mac.set_lben = false;
3802 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
3803 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
3804 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
3805 fw_cmd.port_number = (u8)hw->bus.lan_id;
3807 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
3808 sizeof(struct ixgbe_hic_disable_rxen),
3809 IXGBE_HI_COMMAND_TIMEOUT, true);
3811 /* If we fail - disable RX using register write */
3813 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3814 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3815 rxctrl &= ~IXGBE_RXCTRL_RXEN;
3816 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
3823 * ixgbe_enter_lplu_x550em - Transition to low power states
3824 * @hw: pointer to hardware structure
3826 * Configures Low Power Link Up on transition to low power states
3827 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
3828 * X557 PHY immediately prior to entering LPLU.
3830 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
3832 u16 an_10g_cntl_reg, autoneg_reg, speed;
3834 ixgbe_link_speed lcd_speed;
3838 /* SW LPLU not required on later HW revisions. */
3839 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
3840 (IXGBE_FUSES0_REV_MASK &
3841 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
3842 return IXGBE_SUCCESS;
3844 /* If blocked by MNG FW, then don't restart AN */
3845 if (ixgbe_check_reset_blocked(hw))
3846 return IXGBE_SUCCESS;
3848 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3849 if (status != IXGBE_SUCCESS)
3852 status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
3854 if (status != IXGBE_SUCCESS)
3857 /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
3858 * disabled, then force link down by entering low power mode.
3860 if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
3861 !(hw->wol_enabled || ixgbe_mng_present(hw)))
3862 return ixgbe_set_copper_phy_power(hw, FALSE);
3865 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
3867 if (status != IXGBE_SUCCESS)
3870 /* If no valid LCD link speed, then force link down and exit. */
3871 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
3872 return ixgbe_set_copper_phy_power(hw, FALSE);
3874 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
3875 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3878 if (status != IXGBE_SUCCESS)
3881 /* If no link now, speed is invalid so take link down */
3882 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3883 if (status != IXGBE_SUCCESS)
3884 return ixgbe_set_copper_phy_power(hw, false);
3886 /* clear everything but the speed bits */
3887 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
3889 /* If current speed is already LCD, then exit. */
3890 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
3891 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
3892 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
3893 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
3896 /* Clear AN completed indication */
3897 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
3898 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3901 if (status != IXGBE_SUCCESS)
3904 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
3905 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3908 if (status != IXGBE_SUCCESS)
3911 status = hw->phy.ops.read_reg(hw,
3912 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
3913 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3916 if (status != IXGBE_SUCCESS)
3919 save_autoneg = hw->phy.autoneg_advertised;
3921 /* Setup link at least common link speed */
3922 status = hw->mac.ops.setup_link(hw, lcd_speed, false);
3924 /* restore autoneg from before setting lplu speed */
3925 hw->phy.autoneg_advertised = save_autoneg;
3931 * ixgbe_get_lcd_x550em - Determine lowest common denominator
3932 * @hw: pointer to hardware structure
3933 * @lcd_speed: pointer to lowest common link speed
3935 * Determine lowest common link speed with link partner.
3937 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
3941 u16 word = hw->eeprom.ctrl_word_3;
3943 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
3945 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
3946 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3949 if (status != IXGBE_SUCCESS)
3952 /* If link partner advertised 1G, return 1G */
3953 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
3954 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
3958 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
3959 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
3960 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
3963 /* Link partner not capable of lower speeds, return 10G */
3964 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
3969 * ixgbe_setup_fc_X550em - Set up flow control
3970 * @hw: pointer to hardware structure
3972 * Called at init time to set up flow control.
3974 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
3976 s32 ret_val = IXGBE_SUCCESS;
3977 u32 pause, asm_dir, reg_val;
3979 DEBUGFUNC("ixgbe_setup_fc_X550em");
3981 /* Validate the requested mode */
3982 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
3983 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
3984 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
3985 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3989 /* 10gig parts do not have a word in the EEPROM to determine the
3990 * default flow control setting, so we explicitly set it to full.
3992 if (hw->fc.requested_mode == ixgbe_fc_default)
3993 hw->fc.requested_mode = ixgbe_fc_full;
3995 /* Determine PAUSE and ASM_DIR bits. */
3996 switch (hw->fc.requested_mode) {
4001 case ixgbe_fc_tx_pause:
4005 case ixgbe_fc_rx_pause:
4006 /* Rx Flow control is enabled and Tx Flow control is
4007 * disabled by software override. Since there really
4008 * isn't a way to advertise that we are capable of RX
4009 * Pause ONLY, we will advertise that we support both
4010 * symmetric and asymmetric Rx PAUSE, as such we fall
4011 * through to the fc_full statement. Later, we will
4012 * disable the adapter's ability to send PAUSE frames.
4019 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
4020 "Flow control param set incorrectly\n");
4021 ret_val = IXGBE_ERR_CONFIG;
4025 switch (hw->device_id) {
4026 case IXGBE_DEV_ID_X550EM_X_KR:
4027 case IXGBE_DEV_ID_X550EM_A_KR:
4028 case IXGBE_DEV_ID_X550EM_A_KR_L:
4029 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
4030 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4031 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
4032 if (ret_val != IXGBE_SUCCESS)
4034 reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
4035 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
4037 reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
4039 reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4040 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
4041 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4042 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
4044 /* This device does not fully support AN. */
4045 hw->fc.disable_fc_autoneg = true;
4047 case IXGBE_DEV_ID_X550EM_X_XFI:
4048 hw->fc.disable_fc_autoneg = true;
4059 * ixgbe_fc_autoneg_backplane_x550em_a - Enable flow control IEEE clause 37
4060 * @hw: pointer to hardware structure
4062 * Enable flow control according to IEEE clause 37.
4064 void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *hw)
4066 u32 link_s1, lp_an_page_low, an_cntl_1;
4067 s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4068 ixgbe_link_speed speed;
4071 /* AN should have completed when the cable was plugged in.
4072 * Look for reasons to bail out. Bail out if:
4073 * - FC autoneg is disabled, or if
4076 if (hw->fc.disable_fc_autoneg) {
4077 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4078 "Flow control autoneg is disabled");
4082 hw->mac.ops.check_link(hw, &speed, &link_up, false);
4084 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
4088 /* Check at auto-negotiation has completed */
4089 status = hw->mac.ops.read_iosf_sb_reg(hw,
4090 IXGBE_KRM_LINK_S1(hw->bus.lan_id),
4091 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_s1);
4093 if (status != IXGBE_SUCCESS ||
4094 (link_s1 & IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE) == 0) {
4095 DEBUGOUT("Auto-Negotiation did not complete\n");
4096 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4100 /* Read the 10g AN autoc and LP ability registers and resolve
4101 * local flow control settings accordingly
4103 status = hw->mac.ops.read_iosf_sb_reg(hw,
4104 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4105 IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl_1);
4107 if (status != IXGBE_SUCCESS) {
4108 DEBUGOUT("Auto-Negotiation did not complete\n");
4112 status = hw->mac.ops.read_iosf_sb_reg(hw,
4113 IXGBE_KRM_LP_BASE_PAGE_HIGH(hw->bus.lan_id),
4114 IXGBE_SB_IOSF_TARGET_KR_PHY, &lp_an_page_low);
4116 if (status != IXGBE_SUCCESS) {
4117 DEBUGOUT("Auto-Negotiation did not complete\n");
4121 status = ixgbe_negotiate_fc(hw, an_cntl_1, lp_an_page_low,
4122 IXGBE_KRM_AN_CNTL_1_SYM_PAUSE,
4123 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE,
4124 IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE,
4125 IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE);
4128 if (status == IXGBE_SUCCESS) {
4129 hw->fc.fc_was_autonegged = true;
4131 hw->fc.fc_was_autonegged = false;
4132 hw->fc.current_mode = hw->fc.requested_mode;
4137 * ixgbe_fc_autoneg_fiber_x550em_a - passthrough FC settings
4138 * @hw: pointer to hardware structure
4141 void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *hw)
4143 hw->fc.fc_was_autonegged = false;
4144 hw->fc.current_mode = hw->fc.requested_mode;
4148 * ixgbe_fc_autoneg_sgmii_x550em_a - Enable flow control IEEE clause 37
4149 * @hw: pointer to hardware structure
4151 * Enable flow control according to IEEE clause 37.
4153 void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
4155 s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4156 u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
4157 ixgbe_link_speed speed;
4160 /* AN should have completed when the cable was plugged in.
4161 * Look for reasons to bail out. Bail out if:
4162 * - FC autoneg is disabled, or if
4165 if (hw->fc.disable_fc_autoneg) {
4166 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4167 "Flow control autoneg is disabled");
4171 hw->mac.ops.check_link(hw, &speed, &link_up, false);
4173 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
4177 /* Check if auto-negotiation has completed */
4178 status = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &info);
4179 if (status != IXGBE_SUCCESS ||
4180 !(info[0] & FW_PHY_ACT_GET_LINK_INFO_AN_COMPLETE)) {
4181 DEBUGOUT("Auto-Negotiation did not complete\n");
4182 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4186 /* Negotiate the flow control */
4187 status = ixgbe_negotiate_fc(hw, info[0], info[0],
4188 FW_PHY_ACT_GET_LINK_INFO_FC_RX,
4189 FW_PHY_ACT_GET_LINK_INFO_FC_TX,
4190 FW_PHY_ACT_GET_LINK_INFO_LP_FC_RX,
4191 FW_PHY_ACT_GET_LINK_INFO_LP_FC_TX);
4194 if (status == IXGBE_SUCCESS) {
4195 hw->fc.fc_was_autonegged = true;
4197 hw->fc.fc_was_autonegged = false;
4198 hw->fc.current_mode = hw->fc.requested_mode;
4203 * ixgbe_setup_fc_backplane_x550em_a - Set up flow control
4204 * @hw: pointer to hardware structure
4206 * Called at init time to set up flow control.
4208 s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *hw)
4210 s32 status = IXGBE_SUCCESS;
4213 DEBUGFUNC("ixgbe_setup_fc_backplane_x550em_a");
4215 /* Validate the requested mode */
4216 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
4217 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4218 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
4219 return IXGBE_ERR_INVALID_LINK_SETTINGS;
4222 if (hw->fc.requested_mode == ixgbe_fc_default)
4223 hw->fc.requested_mode = ixgbe_fc_full;
4225 /* Set up the 1G and 10G flow control advertisement registers so the
4226 * HW will be able to do FC autoneg once the cable is plugged in. If
4227 * we link at 10G, the 1G advertisement is harmless and vice versa.
4229 status = hw->mac.ops.read_iosf_sb_reg(hw,
4230 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4231 IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl);
4233 if (status != IXGBE_SUCCESS) {
4234 DEBUGOUT("Auto-Negotiation did not complete\n");
4238 /* The possible values of fc.requested_mode are:
4239 * 0: Flow control is completely disabled
4240 * 1: Rx flow control is enabled (we can receive pause frames,
4241 * but not send pause frames).
4242 * 2: Tx flow control is enabled (we can send pause frames but
4243 * we do not support receiving pause frames).
4244 * 3: Both Rx and Tx flow control (symmetric) are enabled.
4247 switch (hw->fc.requested_mode) {
4249 /* Flow control completely disabled by software override. */
4250 an_cntl &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
4251 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
4253 case ixgbe_fc_tx_pause:
4254 /* Tx Flow control is enabled, and Rx Flow control is
4255 * disabled by software override.
4257 an_cntl |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4258 an_cntl &= ~IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
4260 case ixgbe_fc_rx_pause:
4261 /* Rx Flow control is enabled and Tx Flow control is
4262 * disabled by software override. Since there really
4263 * isn't a way to advertise that we are capable of RX
4264 * Pause ONLY, we will advertise that we support both
4265 * symmetric and asymmetric Rx PAUSE, as such we fall
4266 * through to the fc_full statement. Later, we will
4267 * disable the adapter's ability to send PAUSE frames.
4270 /* Flow control (both Rx and Tx) is enabled by SW override. */
4271 an_cntl |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
4272 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4275 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
4276 "Flow control param set incorrectly\n");
4277 return IXGBE_ERR_CONFIG;
4280 status = hw->mac.ops.write_iosf_sb_reg(hw,
4281 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4282 IXGBE_SB_IOSF_TARGET_KR_PHY, an_cntl);
4284 /* Restart auto-negotiation. */
4285 status = ixgbe_restart_an_internal_phy_x550em(hw);
4291 * ixgbe_set_mux - Set mux for port 1 access with CS4227
4292 * @hw: pointer to hardware structure
4293 * @state: set mux if 1, clear if 0
4295 STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
4299 if (!hw->bus.lan_id)
4301 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
4303 esdp |= IXGBE_ESDP_SDP1;
4305 esdp &= ~IXGBE_ESDP_SDP1;
4306 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
4307 IXGBE_WRITE_FLUSH(hw);
4311 * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
4312 * @hw: pointer to hardware structure
4313 * @mask: Mask to specify which semaphore to acquire
4315 * Acquires the SWFW semaphore and sets the I2C MUX
4317 s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
4321 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
4323 status = ixgbe_acquire_swfw_sync_X540(hw, mask);
4327 if (mask & IXGBE_GSSR_I2C_MASK)
4328 ixgbe_set_mux(hw, 1);
4330 return IXGBE_SUCCESS;
4334 * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
4335 * @hw: pointer to hardware structure
4336 * @mask: Mask to specify which semaphore to release
4338 * Releases the SWFW semaphore and sets the I2C MUX
4340 void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
4342 DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
4344 if (mask & IXGBE_GSSR_I2C_MASK)
4345 ixgbe_set_mux(hw, 0);
4347 ixgbe_release_swfw_sync_X540(hw, mask);
4351 * ixgbe_acquire_swfw_sync_X550a - Acquire SWFW semaphore
4352 * @hw: pointer to hardware structure
4353 * @mask: Mask to specify which semaphore to acquire
4355 * Acquires the SWFW semaphore and get the shared phy token as needed
4357 STATIC s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
4359 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
4360 int retries = FW_PHY_TOKEN_RETRIES;
4361 s32 status = IXGBE_SUCCESS;
4363 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");
4366 status = IXGBE_SUCCESS;
4368 status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
4370 DEBUGOUT1("Could not acquire SWFW semaphore, Status = %d\n",
4374 if (!(mask & IXGBE_GSSR_TOKEN_SM))
4375 return IXGBE_SUCCESS;
4377 status = ixgbe_get_phy_token(hw);
4378 if (status == IXGBE_ERR_TOKEN_RETRY)
4379 DEBUGOUT1("Could not acquire PHY token, Status = %d\n",
4382 if (status == IXGBE_SUCCESS)
4383 return IXGBE_SUCCESS;
4386 ixgbe_release_swfw_sync_X540(hw, hmask);
4388 if (status != IXGBE_ERR_TOKEN_RETRY) {
4389 DEBUGOUT1("Unable to retry acquiring the PHY token, Status = %d\n",
4395 DEBUGOUT1("Semaphore acquisition retries failed!: PHY ID = 0x%08X\n",
4401 * ixgbe_release_swfw_sync_X550a - Release SWFW semaphore
4402 * @hw: pointer to hardware structure
4403 * @mask: Mask to specify which semaphore to release
4405 * Releases the SWFW semaphore and puts the shared phy token as needed
4407 STATIC void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
4409 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
4411 DEBUGFUNC("ixgbe_release_swfw_sync_X550a");
4413 if (mask & IXGBE_GSSR_TOKEN_SM)
4414 ixgbe_put_phy_token(hw);
4417 ixgbe_release_swfw_sync_X540(hw, hmask);
4421 * ixgbe_read_phy_reg_x550a - Reads specified PHY register
4422 * @hw: pointer to hardware structure
4423 * @reg_addr: 32 bit address of PHY register to read
4424 * @phy_data: Pointer to read data from PHY register
4426 * Reads a value from a specified PHY register using the SWFW lock and PHY
4427 * Token. The PHY Token is needed since the MDIO is shared between to MAC
4430 s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
4431 u32 device_type, u16 *phy_data)
4434 u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
4436 DEBUGFUNC("ixgbe_read_phy_reg_x550a");
4438 if (hw->mac.ops.acquire_swfw_sync(hw, mask))
4439 return IXGBE_ERR_SWFW_SYNC;
4441 status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
4443 hw->mac.ops.release_swfw_sync(hw, mask);
4449 * ixgbe_write_phy_reg_x550a - Writes specified PHY register
4450 * @hw: pointer to hardware structure
4451 * @reg_addr: 32 bit PHY register to write
4452 * @device_type: 5 bit device type
4453 * @phy_data: Data to write to the PHY register
4455 * Writes a value to specified PHY register using the SWFW lock and PHY Token.
4456 * The PHY Token is needed since the MDIO is shared between to MAC instances.
4458 s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
4459 u32 device_type, u16 phy_data)
4462 u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
4464 DEBUGFUNC("ixgbe_write_phy_reg_x550a");
4466 if (hw->mac.ops.acquire_swfw_sync(hw, mask) == IXGBE_SUCCESS) {
4467 status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
4469 hw->mac.ops.release_swfw_sync(hw, mask);
4471 status = IXGBE_ERR_SWFW_SYNC;
4478 * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
4479 * @hw: pointer to hardware structure
4481 * Handle external Base T PHY interrupt. If high temperature
4482 * failure alarm then return error, else if link status change
4483 * then setup internal/external PHY link
4485 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
4486 * failure alarm, else return PHY access status.
4488 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
4493 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
4495 if (status != IXGBE_SUCCESS)
4499 return ixgbe_setup_internal_phy(hw);
4501 return IXGBE_SUCCESS;
4505 * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
4506 * @hw: pointer to hardware structure
4507 * @speed: new link speed
4508 * @autoneg_wait_to_complete: true when waiting for completion is needed
4510 * Setup internal/external PHY link speed based on link speed, then set
4511 * external PHY auto advertised link speed.
4513 * Returns error status for any failure
4515 s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
4516 ixgbe_link_speed speed,
4517 bool autoneg_wait_to_complete)
4520 ixgbe_link_speed force_speed;
4522 DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
4524 /* Setup internal/external PHY link speed to iXFI (10G), unless
4525 * only 1G is auto advertised then setup KX link.
4527 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
4528 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
4530 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
4532 /* If X552 and internal link mode is XFI, then setup XFI internal link.
4534 if (hw->mac.type == ixgbe_mac_X550EM_x &&
4535 !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
4536 status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
4538 if (status != IXGBE_SUCCESS)
4542 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
4546 * ixgbe_check_link_t_X550em - Determine link and speed status
4547 * @hw: pointer to hardware structure
4548 * @speed: pointer to link speed
4549 * @link_up: true when link is up
4550 * @link_up_wait_to_complete: bool used to wait for link up or not
4552 * Check that both the MAC and X557 external PHY have link.
4554 s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
4555 bool *link_up, bool link_up_wait_to_complete)
4558 u16 i, autoneg_status = 0;
4560 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
4561 return IXGBE_ERR_CONFIG;
4563 status = ixgbe_check_mac_link_generic(hw, speed, link_up,
4564 link_up_wait_to_complete);
4566 /* If check link fails or MAC link is not up, then return */
4567 if (status != IXGBE_SUCCESS || !(*link_up))
4570 /* MAC link is up, so check external PHY link.
4571 * X557 PHY. Link status is latching low, and can only be used to detect
4572 * link drop, and not the current status of the link without performing
4573 * back-to-back reads.
4575 for (i = 0; i < 2; i++) {
4576 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
4577 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
4580 if (status != IXGBE_SUCCESS)
4584 /* If external PHY link is not up, then indicate link not up */
4585 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
4588 return IXGBE_SUCCESS;
4592 * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
4593 * @hw: pointer to hardware structure
4595 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
4599 status = ixgbe_reset_phy_generic(hw);
4601 if (status != IXGBE_SUCCESS)
4604 /* Configure Link Status Alarm and Temperature Threshold interrupts */
4605 return ixgbe_enable_lasi_ext_t_x550em(hw);
4609 * ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
4610 * @hw: pointer to hardware structure
4611 * @led_idx: led number to turn on
4613 s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
4617 DEBUGFUNC("ixgbe_led_on_t_X550em");
4619 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
4620 return IXGBE_ERR_PARAM;
4622 /* To turn on the LED, set mode to ON. */
4623 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4624 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
4625 phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
4626 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4627 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
4629 /* Some designs have the LEDs wired to the MAC */
4630 return ixgbe_led_on_generic(hw, led_idx);
4634 * ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
4635 * @hw: pointer to hardware structure
4636 * @led_idx: led number to turn off
4638 s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
4642 DEBUGFUNC("ixgbe_led_off_t_X550em");
4644 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
4645 return IXGBE_ERR_PARAM;
4647 /* To turn on the LED, set mode to ON. */
4648 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4649 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
4650 phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
4651 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4652 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
4654 /* Some designs have the LEDs wired to the MAC */
4655 return ixgbe_led_off_generic(hw, led_idx);
4659 * ixgbe_set_fw_drv_ver_x550 - Sends driver version to firmware
4660 * @hw: pointer to the HW structure
4661 * @maj: driver version major number
4662 * @min: driver version minor number
4663 * @build: driver version build number
4664 * @sub: driver version sub build number
4665 * @len: length of driver_ver string
4666 * @driver_ver: driver string
4668 * Sends driver version number to firmware through the manageability
4669 * block. On success return IXGBE_SUCCESS
4670 * else returns IXGBE_ERR_SWFW_SYNC when encountering an error acquiring
4671 * semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
4673 s32 ixgbe_set_fw_drv_ver_x550(struct ixgbe_hw *hw, u8 maj, u8 min,
4674 u8 build, u8 sub, u16 len, const char *driver_ver)
4676 struct ixgbe_hic_drv_info2 fw_cmd;
4677 s32 ret_val = IXGBE_SUCCESS;
4680 DEBUGFUNC("ixgbe_set_fw_drv_ver_x550");
4682 if ((len == 0) || (driver_ver == NULL) ||
4683 (len > sizeof(fw_cmd.driver_string)))
4684 return IXGBE_ERR_INVALID_ARGUMENT;
4686 fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
4687 fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN + len;
4688 fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
4689 fw_cmd.port_num = (u8)hw->bus.func;
4690 fw_cmd.ver_maj = maj;
4691 fw_cmd.ver_min = min;
4692 fw_cmd.ver_build = build;
4693 fw_cmd.ver_sub = sub;
4694 fw_cmd.hdr.checksum = 0;
4695 memcpy(fw_cmd.driver_string, driver_ver, len);
4696 fw_cmd.hdr.checksum = ixgbe_calculate_checksum((u8 *)&fw_cmd,
4697 (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));
4699 for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
4700 ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
4702 IXGBE_HI_COMMAND_TIMEOUT,
4704 if (ret_val != IXGBE_SUCCESS)
4707 if (fw_cmd.hdr.cmd_or_resp.ret_status ==
4708 FW_CEM_RESP_STATUS_SUCCESS)
4709 ret_val = IXGBE_SUCCESS;
4711 ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND;