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_10G_T:
90 case IXGBE_DEV_ID_X550EM_A_10G_T:
91 hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
92 hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
101 * ixgbe_read_cs4227 - Read CS4227 register
102 * @hw: pointer to hardware structure
103 * @reg: register number to write
104 * @value: pointer to receive value read
106 * Returns status code
108 STATIC s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
110 return hw->link.ops.read_link_unlocked(hw, hw->link.addr, reg, value);
114 * ixgbe_write_cs4227 - Write CS4227 register
115 * @hw: pointer to hardware structure
116 * @reg: register number to write
117 * @value: value to write to register
119 * Returns status code
121 STATIC s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
123 return hw->link.ops.write_link_unlocked(hw, hw->link.addr, reg, value);
127 * ixgbe_read_pe - Read register from port expander
128 * @hw: pointer to hardware structure
129 * @reg: register number to read
130 * @value: pointer to receive read value
132 * Returns status code
134 STATIC s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
138 status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
139 if (status != IXGBE_SUCCESS)
140 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
141 "port expander access failed with %d\n", status);
146 * ixgbe_write_pe - Write register to port expander
147 * @hw: pointer to hardware structure
148 * @reg: register number to write
149 * @value: value to write
151 * Returns status code
153 STATIC s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
157 status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
158 if (status != IXGBE_SUCCESS)
159 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
160 "port expander access failed with %d\n", status);
165 * ixgbe_reset_cs4227 - Reset CS4227 using port expander
166 * @hw: pointer to hardware structure
168 * This function assumes that the caller has acquired the proper semaphore.
171 STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
178 /* Trigger hard reset. */
179 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
180 if (status != IXGBE_SUCCESS)
182 reg |= IXGBE_PE_BIT1;
183 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
184 if (status != IXGBE_SUCCESS)
187 status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, ®);
188 if (status != IXGBE_SUCCESS)
190 reg &= ~IXGBE_PE_BIT1;
191 status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
192 if (status != IXGBE_SUCCESS)
195 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
196 if (status != IXGBE_SUCCESS)
198 reg &= ~IXGBE_PE_BIT1;
199 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
200 if (status != IXGBE_SUCCESS)
203 usec_delay(IXGBE_CS4227_RESET_HOLD);
205 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
206 if (status != IXGBE_SUCCESS)
208 reg |= IXGBE_PE_BIT1;
209 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
210 if (status != IXGBE_SUCCESS)
213 /* Wait for the reset to complete. */
214 msec_delay(IXGBE_CS4227_RESET_DELAY);
215 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
216 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
218 if (status == IXGBE_SUCCESS &&
219 value == IXGBE_CS4227_EEPROM_LOAD_OK)
221 msec_delay(IXGBE_CS4227_CHECK_DELAY);
223 if (retry == IXGBE_CS4227_RETRIES) {
224 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
225 "CS4227 reset did not complete.");
226 return IXGBE_ERR_PHY;
229 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
230 if (status != IXGBE_SUCCESS ||
231 !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
232 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
233 "CS4227 EEPROM did not load successfully.");
234 return IXGBE_ERR_PHY;
237 return IXGBE_SUCCESS;
241 * ixgbe_check_cs4227 - Check CS4227 and reset as needed
242 * @hw: pointer to hardware structure
244 STATIC void ixgbe_check_cs4227(struct ixgbe_hw *hw)
246 s32 status = IXGBE_SUCCESS;
247 u32 swfw_mask = hw->phy.phy_semaphore_mask;
251 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
252 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
253 if (status != IXGBE_SUCCESS) {
254 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
255 "semaphore failed with %d", status);
256 msec_delay(IXGBE_CS4227_CHECK_DELAY);
260 /* Get status of reset flow. */
261 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
263 if (status == IXGBE_SUCCESS &&
264 value == IXGBE_CS4227_RESET_COMPLETE)
267 if (status != IXGBE_SUCCESS ||
268 value != IXGBE_CS4227_RESET_PENDING)
271 /* Reset is pending. Wait and check again. */
272 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
273 msec_delay(IXGBE_CS4227_CHECK_DELAY);
276 /* If still pending, assume other instance failed. */
277 if (retry == IXGBE_CS4227_RETRIES) {
278 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
279 if (status != IXGBE_SUCCESS) {
280 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
281 "semaphore failed with %d", status);
286 /* Reset the CS4227. */
287 status = ixgbe_reset_cs4227(hw);
288 if (status != IXGBE_SUCCESS) {
289 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
290 "CS4227 reset failed: %d", status);
294 /* Reset takes so long, temporarily release semaphore in case the
295 * other driver instance is waiting for the reset indication.
297 ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
298 IXGBE_CS4227_RESET_PENDING);
299 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
301 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
302 if (status != IXGBE_SUCCESS) {
303 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
304 "semaphore failed with %d", status);
308 /* Record completion for next time. */
309 status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
310 IXGBE_CS4227_RESET_COMPLETE);
313 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
314 msec_delay(hw->eeprom.semaphore_delay);
318 * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
319 * @hw: pointer to hardware structure
321 STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
323 u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
325 if (hw->bus.lan_id) {
326 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
327 esdp |= IXGBE_ESDP_SDP1_DIR;
329 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
330 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
331 IXGBE_WRITE_FLUSH(hw);
335 * ixgbe_read_phy_reg_mdi_22 - Read from a clause 22 PHY register without lock
336 * @hw: pointer to hardware structure
337 * @reg_addr: 32 bit address of PHY register to read
338 * @dev_type: always unused
339 * @phy_data: Pointer to read data from PHY register
341 STATIC s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
342 u32 dev_type, u16 *phy_data)
344 u32 i, data, command;
345 UNREFERENCED_1PARAMETER(dev_type);
347 /* Setup and write the read command */
348 command = (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
349 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
350 IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_READ_AUTOINC |
351 IXGBE_MSCA_MDI_COMMAND;
353 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
355 /* Check every 10 usec to see if the access completed.
356 * The MDI Command bit will clear when the operation is
359 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
362 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
363 if (!(command & IXGBE_MSCA_MDI_COMMAND))
367 if (command & IXGBE_MSCA_MDI_COMMAND) {
368 ERROR_REPORT1(IXGBE_ERROR_POLLING,
369 "PHY read command did not complete.\n");
370 return IXGBE_ERR_PHY;
373 /* Read operation is complete. Get the data from MSRWD */
374 data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
375 data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
376 *phy_data = (u16)data;
378 return IXGBE_SUCCESS;
382 * ixgbe_write_phy_reg_mdi_22 - Write to a clause 22 PHY register without lock
383 * @hw: pointer to hardware structure
384 * @reg_addr: 32 bit PHY register to write
385 * @dev_type: always unused
386 * @phy_data: Data to write to the PHY register
388 STATIC s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
389 u32 dev_type, u16 phy_data)
392 UNREFERENCED_1PARAMETER(dev_type);
394 /* Put the data in the MDI single read and write data register*/
395 IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
397 /* Setup and write the write command */
398 command = (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
399 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
400 IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_WRITE |
401 IXGBE_MSCA_MDI_COMMAND;
403 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
405 /* Check every 10 usec to see if the access completed.
406 * The MDI Command bit will clear when the operation is
409 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
412 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
413 if (!(command & IXGBE_MSCA_MDI_COMMAND))
417 if (command & IXGBE_MSCA_MDI_COMMAND) {
418 ERROR_REPORT1(IXGBE_ERROR_POLLING,
419 "PHY write cmd didn't complete\n");
420 return IXGBE_ERR_PHY;
423 return IXGBE_SUCCESS;
427 * ixgbe_identify_phy_x550em - Get PHY type based on device id
428 * @hw: pointer to hardware structure
432 STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
434 hw->mac.ops.set_lan_id(hw);
436 ixgbe_read_mng_if_sel_x550em(hw);
438 switch (hw->device_id) {
439 case IXGBE_DEV_ID_X550EM_A_SFP:
440 return ixgbe_identify_module_generic(hw);
441 case IXGBE_DEV_ID_X550EM_X_SFP:
442 /* set up for CS4227 usage */
443 ixgbe_setup_mux_ctl(hw);
444 ixgbe_check_cs4227(hw);
447 case IXGBE_DEV_ID_X550EM_A_SFP_N:
448 return ixgbe_identify_module_generic(hw);
450 case IXGBE_DEV_ID_X550EM_X_KX4:
451 hw->phy.type = ixgbe_phy_x550em_kx4;
453 case IXGBE_DEV_ID_X550EM_X_XFI:
454 hw->phy.type = ixgbe_phy_x550em_xfi;
456 case IXGBE_DEV_ID_X550EM_X_KR:
457 case IXGBE_DEV_ID_X550EM_A_KR:
458 case IXGBE_DEV_ID_X550EM_A_KR_L:
459 hw->phy.type = ixgbe_phy_x550em_kr;
461 case IXGBE_DEV_ID_X550EM_A_10G_T:
462 case IXGBE_DEV_ID_X550EM_X_1G_T:
463 case IXGBE_DEV_ID_X550EM_X_10G_T:
464 return ixgbe_identify_phy_generic(hw);
465 case IXGBE_DEV_ID_X550EM_A_1G_T:
466 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
467 hw->phy.type = ixgbe_phy_fw;
468 hw->phy.ops.read_reg = NULL;
469 hw->phy.ops.write_reg = NULL;
471 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
473 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
478 return IXGBE_SUCCESS;
482 * ixgbe_fw_phy_activity - Perform an activity on a PHY
483 * @hw: pointer to hardware structure
484 * @activity: activity to perform
485 * @data: Pointer to 4 32-bit words of data
487 s32 ixgbe_fw_phy_activity(struct ixgbe_hw *hw, u16 activity,
488 u32 (*data)[FW_PHY_ACT_DATA_COUNT])
491 struct ixgbe_hic_phy_activity_req cmd;
492 struct ixgbe_hic_phy_activity_resp rsp;
494 u16 retries = FW_PHY_ACT_RETRIES;
499 memset(&hic, 0, sizeof(hic));
500 hic.cmd.hdr.cmd = FW_PHY_ACT_REQ_CMD;
501 hic.cmd.hdr.buf_len = FW_PHY_ACT_REQ_LEN;
502 hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
503 hic.cmd.port_number = hw->bus.lan_id;
504 hic.cmd.activity_id = IXGBE_CPU_TO_LE16(activity);
505 for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
506 hic.cmd.data[i] = IXGBE_CPU_TO_BE32((*data)[i]);
508 rc = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
510 IXGBE_HI_COMMAND_TIMEOUT,
512 if (rc != IXGBE_SUCCESS)
514 if (hic.rsp.hdr.cmd_or_resp.ret_status ==
515 FW_CEM_RESP_STATUS_SUCCESS) {
516 for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
517 (*data)[i] = IXGBE_BE32_TO_CPU(hic.rsp.data[i]);
518 return IXGBE_SUCCESS;
522 } while (retries > 0);
524 return IXGBE_ERR_HOST_INTERFACE_COMMAND;
527 static const struct {
529 ixgbe_link_speed phy_speed;
531 { FW_PHY_ACT_LINK_SPEED_10, IXGBE_LINK_SPEED_10_FULL },
532 { FW_PHY_ACT_LINK_SPEED_100, IXGBE_LINK_SPEED_100_FULL },
533 { FW_PHY_ACT_LINK_SPEED_1G, IXGBE_LINK_SPEED_1GB_FULL },
534 { FW_PHY_ACT_LINK_SPEED_2_5G, IXGBE_LINK_SPEED_2_5GB_FULL },
535 { FW_PHY_ACT_LINK_SPEED_5G, IXGBE_LINK_SPEED_5GB_FULL },
536 { FW_PHY_ACT_LINK_SPEED_10G, IXGBE_LINK_SPEED_10GB_FULL },
540 * ixgbe_get_phy_id_fw - Get the phy ID via firmware command
541 * @hw: pointer to hardware structure
545 static s32 ixgbe_get_phy_id_fw(struct ixgbe_hw *hw)
547 u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
553 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_PHY_INFO, &info);
557 hw->phy.speeds_supported = 0;
558 phy_speeds = info[0] & FW_PHY_INFO_SPEED_MASK;
559 for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
560 if (phy_speeds & ixgbe_fw_map[i].fw_speed)
561 hw->phy.speeds_supported |= ixgbe_fw_map[i].phy_speed;
563 if (!hw->phy.autoneg_advertised)
564 hw->phy.autoneg_advertised = hw->phy.speeds_supported;
566 hw->phy.id = info[0] & FW_PHY_INFO_ID_HI_MASK;
567 phy_id_lo = info[1] & FW_PHY_INFO_ID_LO_MASK;
568 hw->phy.id |= phy_id_lo & IXGBE_PHY_REVISION_MASK;
569 hw->phy.revision = phy_id_lo & ~IXGBE_PHY_REVISION_MASK;
570 if (!hw->phy.id || hw->phy.id == IXGBE_PHY_REVISION_MASK)
571 return IXGBE_ERR_PHY_ADDR_INVALID;
572 return IXGBE_SUCCESS;
576 * ixgbe_identify_phy_fw - Get PHY type based on firmware command
577 * @hw: pointer to hardware structure
581 static s32 ixgbe_identify_phy_fw(struct ixgbe_hw *hw)
584 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
586 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
588 hw->phy.type = ixgbe_phy_fw;
589 hw->phy.ops.read_reg = NULL;
590 hw->phy.ops.write_reg = NULL;
591 return ixgbe_get_phy_id_fw(hw);
595 * ixgbe_shutdown_fw_phy - Shutdown a firmware-controlled PHY
596 * @hw: pointer to hardware structure
600 s32 ixgbe_shutdown_fw_phy(struct ixgbe_hw *hw)
602 u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
604 setup[0] = FW_PHY_ACT_FORCE_LINK_DOWN_OFF;
605 return ixgbe_fw_phy_activity(hw, FW_PHY_ACT_FORCE_LINK_DOWN, &setup);
608 STATIC s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
609 u32 device_type, u16 *phy_data)
611 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
612 return IXGBE_NOT_IMPLEMENTED;
615 STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
616 u32 device_type, u16 phy_data)
618 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
619 return IXGBE_NOT_IMPLEMENTED;
623 * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
624 * @hw: pointer to the hardware structure
625 * @addr: I2C bus address to read from
626 * @reg: I2C device register to read from
627 * @val: pointer to location to receive read value
629 * Returns an error code on error.
631 STATIC s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
634 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
638 * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
639 * @hw: pointer to the hardware structure
640 * @addr: I2C bus address to read from
641 * @reg: I2C device register to read from
642 * @val: pointer to location to receive read value
644 * Returns an error code on error.
647 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
650 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, false);
654 * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
655 * @hw: pointer to the hardware structure
656 * @addr: I2C bus address to write to
657 * @reg: I2C device register to write to
658 * @val: value to write
660 * Returns an error code on error.
662 STATIC s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
663 u8 addr, u16 reg, u16 val)
665 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
669 * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
670 * @hw: pointer to the hardware structure
671 * @addr: I2C bus address to write to
672 * @reg: I2C device register to write to
673 * @val: value to write
675 * Returns an error code on error.
678 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
679 u8 addr, u16 reg, u16 val)
681 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, false);
685 * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
686 * @hw: pointer to hardware structure
688 * Initialize the function pointers and for MAC type X550EM.
689 * Does not touch the hardware.
691 s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
693 struct ixgbe_mac_info *mac = &hw->mac;
694 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
695 struct ixgbe_phy_info *phy = &hw->phy;
698 DEBUGFUNC("ixgbe_init_ops_X550EM");
700 /* Similar to X550 so start there. */
701 ret_val = ixgbe_init_ops_X550(hw);
703 /* Since this function eventually calls
704 * ixgbe_init_ops_540 by design, we are setting
705 * the pointers to NULL explicitly here to overwrite
706 * the values being set in the x540 function.
708 /* Thermal sensor not supported in x550EM */
709 mac->ops.get_thermal_sensor_data = NULL;
710 mac->ops.init_thermal_sensor_thresh = NULL;
711 mac->thermal_sensor_enabled = false;
713 /* FCOE not supported in x550EM */
714 mac->ops.get_san_mac_addr = NULL;
715 mac->ops.set_san_mac_addr = NULL;
716 mac->ops.get_wwn_prefix = NULL;
717 mac->ops.get_fcoe_boot_status = NULL;
719 /* IPsec not supported in x550EM */
720 mac->ops.disable_sec_rx_path = NULL;
721 mac->ops.enable_sec_rx_path = NULL;
723 /* AUTOC register is not present in x550EM. */
724 mac->ops.prot_autoc_read = NULL;
725 mac->ops.prot_autoc_write = NULL;
727 /* X550EM bus type is internal*/
728 hw->bus.type = ixgbe_bus_type_internal;
729 mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
732 mac->ops.get_media_type = ixgbe_get_media_type_X550em;
733 mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
734 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
735 mac->ops.reset_hw = ixgbe_reset_hw_X550em;
736 mac->ops.get_supported_physical_layer =
737 ixgbe_get_supported_physical_layer_X550em;
739 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
740 mac->ops.setup_fc = ixgbe_setup_fc_generic;
742 mac->ops.setup_fc = ixgbe_setup_fc_X550em;
745 phy->ops.init = ixgbe_init_phy_ops_X550em;
746 switch (hw->device_id) {
747 case IXGBE_DEV_ID_X550EM_A_1G_T:
748 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
749 mac->ops.setup_fc = NULL;
750 phy->ops.identify = ixgbe_identify_phy_fw;
751 phy->ops.set_phy_power = NULL;
752 phy->ops.get_firmware_version = NULL;
755 phy->ops.identify = ixgbe_identify_phy_x550em;
758 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
759 phy->ops.set_phy_power = NULL;
763 eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
764 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
765 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
766 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
767 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
768 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
769 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
770 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
776 * ixgbe_setup_fw_link - Setup firmware-controlled PHYs
777 * @hw: pointer to hardware structure
779 static s32 ixgbe_setup_fw_link(struct ixgbe_hw *hw)
781 u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
785 if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
788 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
789 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
790 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
791 return IXGBE_ERR_INVALID_LINK_SETTINGS;
794 switch (hw->fc.requested_mode) {
796 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RXTX <<
797 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
799 case ixgbe_fc_rx_pause:
800 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RX <<
801 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
803 case ixgbe_fc_tx_pause:
804 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_TX <<
805 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
811 for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
812 if (hw->phy.autoneg_advertised & ixgbe_fw_map[i].phy_speed)
813 setup[0] |= ixgbe_fw_map[i].fw_speed;
815 setup[0] |= FW_PHY_ACT_SETUP_LINK_HP | FW_PHY_ACT_SETUP_LINK_AN;
817 if (hw->phy.eee_speeds_advertised)
818 setup[0] |= FW_PHY_ACT_SETUP_LINK_EEE;
820 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_SETUP_LINK, &setup);
823 if (setup[0] == FW_PHY_ACT_SETUP_LINK_RSP_DOWN)
824 return IXGBE_ERR_OVERTEMP;
825 return IXGBE_SUCCESS;
829 * ixgbe_fc_autoneg_fw _ Set up flow control for FW-controlled PHYs
830 * @hw: pointer to hardware structure
832 * Called at init time to set up flow control.
834 static s32 ixgbe_fc_autoneg_fw(struct ixgbe_hw *hw)
836 if (hw->fc.requested_mode == ixgbe_fc_default)
837 hw->fc.requested_mode = ixgbe_fc_full;
839 return ixgbe_setup_fw_link(hw);
843 * ixgbe_setup_eee_fw - Enable/disable EEE support
844 * @hw: pointer to the HW structure
845 * @enable_eee: boolean flag to enable EEE
847 * Enable/disable EEE based on enable_eee flag.
848 * This function controls EEE for firmware-based PHY implementations.
850 static s32 ixgbe_setup_eee_fw(struct ixgbe_hw *hw, bool enable_eee)
852 if (!!hw->phy.eee_speeds_advertised == enable_eee)
853 return IXGBE_SUCCESS;
855 hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
857 hw->phy.eee_speeds_advertised = 0;
858 return hw->phy.ops.setup_link(hw);
862 * ixgbe_init_ops_X550EM_a - Inits func ptrs and MAC type
863 * @hw: pointer to hardware structure
865 * Initialize the function pointers and for MAC type X550EM_a.
866 * Does not touch the hardware.
868 s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
870 struct ixgbe_mac_info *mac = &hw->mac;
873 DEBUGFUNC("ixgbe_init_ops_X550EM_a");
875 /* Start with generic X550EM init */
876 ret_val = ixgbe_init_ops_X550EM(hw);
878 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
879 hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L) {
880 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
881 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
883 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a;
884 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a;
886 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
887 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
889 switch (mac->ops.get_media_type(hw)) {
890 case ixgbe_media_type_fiber:
891 mac->ops.setup_fc = NULL;
892 mac->ops.fc_autoneg = ixgbe_fc_autoneg_fiber_x550em_a;
894 case ixgbe_media_type_backplane:
895 mac->ops.fc_autoneg = ixgbe_fc_autoneg_backplane_x550em_a;
896 mac->ops.setup_fc = ixgbe_setup_fc_backplane_x550em_a;
902 switch (hw->device_id) {
903 case IXGBE_DEV_ID_X550EM_A_1G_T:
904 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
905 mac->ops.fc_autoneg = ixgbe_fc_autoneg_sgmii_x550em_a;
906 mac->ops.setup_fc = ixgbe_fc_autoneg_fw;
907 mac->ops.setup_eee = ixgbe_setup_eee_fw;
908 hw->phy.eee_speeds_supported = IXGBE_LINK_SPEED_100_FULL |
909 IXGBE_LINK_SPEED_1GB_FULL;
910 hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
920 * ixgbe_init_ops_X550EM_x - Inits func ptrs and MAC type
921 * @hw: pointer to hardware structure
923 * Initialize the function pointers and for MAC type X550EM_x.
924 * Does not touch the hardware.
926 s32 ixgbe_init_ops_X550EM_x(struct ixgbe_hw *hw)
928 struct ixgbe_mac_info *mac = &hw->mac;
929 struct ixgbe_link_info *link = &hw->link;
932 DEBUGFUNC("ixgbe_init_ops_X550EM_x");
934 /* Start with generic X550EM init */
935 ret_val = ixgbe_init_ops_X550EM(hw);
937 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
938 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
939 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
940 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
941 link->ops.read_link = ixgbe_read_i2c_combined_generic;
942 link->ops.read_link_unlocked = ixgbe_read_i2c_combined_generic_unlocked;
943 link->ops.write_link = ixgbe_write_i2c_combined_generic;
944 link->ops.write_link_unlocked =
945 ixgbe_write_i2c_combined_generic_unlocked;
946 link->addr = IXGBE_CS4227;
953 * ixgbe_dmac_config_X550
954 * @hw: pointer to hardware structure
956 * Configure DMA coalescing. If enabling dmac, dmac is activated.
957 * When disabling dmac, dmac enable dmac bit is cleared.
959 s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
961 u32 reg, high_pri_tc;
963 DEBUGFUNC("ixgbe_dmac_config_X550");
965 /* Disable DMA coalescing before configuring */
966 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
967 reg &= ~IXGBE_DMACR_DMAC_EN;
968 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
970 /* Disable DMA Coalescing if the watchdog timer is 0 */
971 if (!hw->mac.dmac_config.watchdog_timer)
974 ixgbe_dmac_config_tcs_X550(hw);
976 /* Configure DMA Coalescing Control Register */
977 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
979 /* Set the watchdog timer in units of 40.96 usec */
980 reg &= ~IXGBE_DMACR_DMACWT_MASK;
981 reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
983 reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
984 /* If fcoe is enabled, set high priority traffic class */
985 if (hw->mac.dmac_config.fcoe_en) {
986 high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
987 reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
988 IXGBE_DMACR_HIGH_PRI_TC_MASK);
990 reg |= IXGBE_DMACR_EN_MNG_IND;
992 /* Enable DMA coalescing after configuration */
993 reg |= IXGBE_DMACR_DMAC_EN;
994 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
997 return IXGBE_SUCCESS;
1001 * ixgbe_dmac_config_tcs_X550
1002 * @hw: pointer to hardware structure
1004 * Configure DMA coalescing threshold per TC. The dmac enable bit must
1005 * be cleared before configuring.
1007 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
1009 u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
1011 DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
1013 /* Configure DMA coalescing enabled */
1014 switch (hw->mac.dmac_config.link_speed) {
1015 case IXGBE_LINK_SPEED_10_FULL:
1016 case IXGBE_LINK_SPEED_100_FULL:
1017 pb_headroom = IXGBE_DMACRXT_100M;
1019 case IXGBE_LINK_SPEED_1GB_FULL:
1020 pb_headroom = IXGBE_DMACRXT_1G;
1023 pb_headroom = IXGBE_DMACRXT_10G;
1027 maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
1028 IXGBE_MHADD_MFS_SHIFT) / 1024);
1030 /* Set the per Rx packet buffer receive threshold */
1031 for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
1032 reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
1033 reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
1035 if (tc < hw->mac.dmac_config.num_tcs) {
1036 /* Get Rx PB size */
1037 rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
1038 rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
1039 IXGBE_RXPBSIZE_SHIFT;
1041 /* Calculate receive buffer threshold in kilobytes */
1042 if (rx_pb_size > pb_headroom)
1043 rx_pb_size = rx_pb_size - pb_headroom;
1047 /* Minimum of MFS shall be set for DMCTH */
1048 reg |= (rx_pb_size > maxframe_size_kb) ?
1049 rx_pb_size : maxframe_size_kb;
1051 IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
1053 return IXGBE_SUCCESS;
1057 * ixgbe_dmac_update_tcs_X550
1058 * @hw: pointer to hardware structure
1060 * Disables dmac, updates per TC settings, and then enables dmac.
1062 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
1066 DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
1068 /* Disable DMA coalescing before configuring */
1069 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
1070 reg &= ~IXGBE_DMACR_DMAC_EN;
1071 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
1073 ixgbe_dmac_config_tcs_X550(hw);
1075 /* Enable DMA coalescing after configuration */
1076 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
1077 reg |= IXGBE_DMACR_DMAC_EN;
1078 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
1080 return IXGBE_SUCCESS;
1084 * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
1085 * @hw: pointer to hardware structure
1087 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
1088 * ixgbe_hw struct in order to set up EEPROM access.
1090 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
1092 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
1096 DEBUGFUNC("ixgbe_init_eeprom_params_X550");
1098 if (eeprom->type == ixgbe_eeprom_uninitialized) {
1099 eeprom->semaphore_delay = 10;
1100 eeprom->type = ixgbe_flash;
1102 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
1103 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
1104 IXGBE_EEC_SIZE_SHIFT);
1105 eeprom->word_size = 1 << (eeprom_size +
1106 IXGBE_EEPROM_WORD_SIZE_SHIFT);
1108 DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
1109 eeprom->type, eeprom->word_size);
1112 return IXGBE_SUCCESS;
1116 * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
1117 * @hw: pointer to hardware structure
1118 * @enable: enable or disable source address pruning
1119 * @pool: Rx pool to set source address pruning for
1121 void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
1126 /* max rx pool is 63 */
1130 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
1131 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
1134 pfflp |= (1ULL << pool);
1136 pfflp &= ~(1ULL << pool);
1138 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
1139 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
1143 * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
1144 * @hw: pointer to hardware structure
1145 * @enable: enable or disable switch for Ethertype anti-spoofing
1146 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
1149 void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
1150 bool enable, int vf)
1152 int vf_target_reg = vf >> 3;
1153 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
1156 DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
1158 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
1160 pfvfspoof |= (1 << vf_target_shift);
1162 pfvfspoof &= ~(1 << vf_target_shift);
1164 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
1168 * ixgbe_iosf_wait - Wait for IOSF command completion
1169 * @hw: pointer to hardware structure
1170 * @ctrl: pointer to location to receive final IOSF control value
1172 * Returns failing status on timeout
1174 * Note: ctrl can be NULL if the IOSF control register value is not needed
1176 STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
1180 /* Check every 10 usec to see if the address cycle completed.
1181 * The SB IOSF BUSY bit will clear when the operation is
1184 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
1185 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
1186 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
1192 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
1193 ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
1194 return IXGBE_ERR_PHY;
1197 return IXGBE_SUCCESS;
1201 * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register
1202 * of the IOSF device
1203 * @hw: pointer to hardware structure
1204 * @reg_addr: 32 bit PHY register to write
1205 * @device_type: 3 bit device type
1206 * @data: Data to write to the register
1208 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1209 u32 device_type, u32 data)
1211 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1215 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1216 if (ret != IXGBE_SUCCESS)
1219 ret = ixgbe_iosf_wait(hw, NULL);
1220 if (ret != IXGBE_SUCCESS)
1223 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1224 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1226 /* Write IOSF control register */
1227 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1229 /* Write IOSF data register */
1230 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
1232 ret = ixgbe_iosf_wait(hw, &command);
1234 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1235 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1236 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1237 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1238 "Failed to write, error %x\n", error);
1239 ret = IXGBE_ERR_PHY;
1243 ixgbe_release_swfw_semaphore(hw, gssr);
1248 * ixgbe_read_iosf_sb_reg_x550 - Reads specified register of the IOSF device
1249 * @hw: pointer to hardware structure
1250 * @reg_addr: 32 bit PHY register to write
1251 * @device_type: 3 bit device type
1252 * @data: Pointer to read data from the register
1254 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1255 u32 device_type, u32 *data)
1257 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1261 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1262 if (ret != IXGBE_SUCCESS)
1265 ret = ixgbe_iosf_wait(hw, NULL);
1266 if (ret != IXGBE_SUCCESS)
1269 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1270 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1272 /* Write IOSF control register */
1273 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1275 ret = ixgbe_iosf_wait(hw, &command);
1277 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1278 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1279 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1280 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1281 "Failed to read, error %x\n", error);
1282 ret = IXGBE_ERR_PHY;
1285 if (ret == IXGBE_SUCCESS)
1286 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
1289 ixgbe_release_swfw_semaphore(hw, gssr);
1294 * ixgbe_get_phy_token - Get the token for shared phy access
1295 * @hw: Pointer to hardware structure
1298 s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
1300 struct ixgbe_hic_phy_token_req token_cmd;
1303 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1304 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1305 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1306 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1307 token_cmd.port_number = hw->bus.lan_id;
1308 token_cmd.command_type = FW_PHY_TOKEN_REQ;
1310 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1312 IXGBE_HI_COMMAND_TIMEOUT,
1316 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1317 return IXGBE_SUCCESS;
1318 if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY)
1319 return IXGBE_ERR_FW_RESP_INVALID;
1321 return IXGBE_ERR_TOKEN_RETRY;
1325 * ixgbe_put_phy_token - Put the token for shared phy access
1326 * @hw: Pointer to hardware structure
1329 s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
1331 struct ixgbe_hic_phy_token_req token_cmd;
1334 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1335 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1336 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1337 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1338 token_cmd.port_number = hw->bus.lan_id;
1339 token_cmd.command_type = FW_PHY_TOKEN_REL;
1341 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1343 IXGBE_HI_COMMAND_TIMEOUT,
1347 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1348 return IXGBE_SUCCESS;
1350 DEBUGOUT("Put PHY Token host interface command failed");
1351 return IXGBE_ERR_FW_RESP_INVALID;
1355 * ixgbe_write_iosf_sb_reg_x550a - Writes a value to specified register
1356 * of the IOSF device
1357 * @hw: pointer to hardware structure
1358 * @reg_addr: 32 bit PHY register to write
1359 * @device_type: 3 bit device type
1360 * @data: Data to write to the register
1362 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1363 u32 device_type, u32 data)
1365 struct ixgbe_hic_internal_phy_req write_cmd;
1367 UNREFERENCED_1PARAMETER(device_type);
1369 memset(&write_cmd, 0, sizeof(write_cmd));
1370 write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1371 write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1372 write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1373 write_cmd.port_number = hw->bus.lan_id;
1374 write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
1375 write_cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
1376 write_cmd.write_data = IXGBE_CPU_TO_BE32(data);
1378 status = ixgbe_host_interface_command(hw, (u32 *)&write_cmd,
1380 IXGBE_HI_COMMAND_TIMEOUT, false);
1386 * ixgbe_read_iosf_sb_reg_x550a - Reads specified register of the IOSF device
1387 * @hw: pointer to hardware structure
1388 * @reg_addr: 32 bit PHY register to write
1389 * @device_type: 3 bit device type
1390 * @data: Pointer to read data from the register
1392 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1393 u32 device_type, u32 *data)
1396 struct ixgbe_hic_internal_phy_req cmd;
1397 struct ixgbe_hic_internal_phy_resp rsp;
1400 UNREFERENCED_1PARAMETER(device_type);
1402 memset(&hic, 0, sizeof(hic));
1403 hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1404 hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1405 hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1406 hic.cmd.port_number = hw->bus.lan_id;
1407 hic.cmd.command_type = FW_INT_PHY_REQ_READ;
1408 hic.cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
1410 status = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
1412 IXGBE_HI_COMMAND_TIMEOUT, true);
1414 /* Extract the register value from the response. */
1415 *data = IXGBE_BE32_TO_CPU(hic.rsp.read_data);
1421 * ixgbe_disable_mdd_X550
1422 * @hw: pointer to hardware structure
1424 * Disable malicious driver detection
1426 void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
1430 DEBUGFUNC("ixgbe_disable_mdd_X550");
1432 /* Disable MDD for TX DMA and interrupt */
1433 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1434 reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1435 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1437 /* Disable MDD for RX and interrupt */
1438 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1439 reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1440 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1444 * ixgbe_enable_mdd_X550
1445 * @hw: pointer to hardware structure
1447 * Enable malicious driver detection
1449 void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
1453 DEBUGFUNC("ixgbe_enable_mdd_X550");
1455 /* Enable MDD for TX DMA and interrupt */
1456 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1457 reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1458 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1460 /* Enable MDD for RX and interrupt */
1461 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1462 reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1463 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1467 * ixgbe_restore_mdd_vf_X550
1468 * @hw: pointer to hardware structure
1471 * Restore VF that was disabled during malicious driver detection event
1473 void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
1475 u32 idx, reg, num_qs, start_q, bitmask;
1477 DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
1479 /* Map VF to queues */
1480 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1481 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1482 case IXGBE_MRQC_VMDQRT8TCEN:
1483 num_qs = 8; /* 16 VFs / pools */
1484 bitmask = 0x000000FF;
1486 case IXGBE_MRQC_VMDQRSS32EN:
1487 case IXGBE_MRQC_VMDQRT4TCEN:
1488 num_qs = 4; /* 32 VFs / pools */
1489 bitmask = 0x0000000F;
1491 default: /* 64 VFs / pools */
1493 bitmask = 0x00000003;
1496 start_q = vf * num_qs;
1498 /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1501 reg |= (bitmask << (start_q % 32));
1502 IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1503 IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1507 * ixgbe_mdd_event_X550
1508 * @hw: pointer to hardware structure
1509 * @vf_bitmap: vf bitmap of malicious vfs
1511 * Handle malicious driver detection event.
1513 void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1516 u32 i, j, reg, q, shift, vf, idx;
1518 DEBUGFUNC("ixgbe_mdd_event_X550");
1520 /* figure out pool size for mapping to vf's */
1521 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1522 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1523 case IXGBE_MRQC_VMDQRT8TCEN:
1524 shift = 3; /* 16 VFs / pools */
1526 case IXGBE_MRQC_VMDQRSS32EN:
1527 case IXGBE_MRQC_VMDQRT4TCEN:
1528 shift = 2; /* 32 VFs / pools */
1531 shift = 1; /* 64 VFs / pools */
1535 /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1536 for (i = 0; i < 4; i++) {
1537 wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1538 wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1543 /* Get malicious queue */
1544 for (j = 0; j < 32 && wqbr; j++) {
1546 if (!(wqbr & (1 << j)))
1549 /* Get queue from bitmask */
1552 /* Map queue to vf */
1555 /* Set vf bit in vf_bitmap */
1557 vf_bitmap[idx] |= (1 << (vf % 32));
1564 * ixgbe_get_media_type_X550em - Get media type
1565 * @hw: pointer to hardware structure
1567 * Returns the media type (fiber, copper, backplane)
1569 enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1571 enum ixgbe_media_type media_type;
1573 DEBUGFUNC("ixgbe_get_media_type_X550em");
1575 /* Detect if there is a copper PHY attached. */
1576 switch (hw->device_id) {
1577 case IXGBE_DEV_ID_X550EM_X_KR:
1578 case IXGBE_DEV_ID_X550EM_X_KX4:
1579 case IXGBE_DEV_ID_X550EM_X_XFI:
1580 case IXGBE_DEV_ID_X550EM_A_KR:
1581 case IXGBE_DEV_ID_X550EM_A_KR_L:
1582 media_type = ixgbe_media_type_backplane;
1584 case IXGBE_DEV_ID_X550EM_X_SFP:
1585 case IXGBE_DEV_ID_X550EM_A_SFP:
1586 case IXGBE_DEV_ID_X550EM_A_SFP_N:
1587 case IXGBE_DEV_ID_X550EM_A_QSFP:
1588 case IXGBE_DEV_ID_X550EM_A_QSFP_N:
1589 media_type = ixgbe_media_type_fiber;
1591 case IXGBE_DEV_ID_X550EM_X_1G_T:
1592 case IXGBE_DEV_ID_X550EM_X_10G_T:
1593 case IXGBE_DEV_ID_X550EM_A_10G_T:
1594 media_type = ixgbe_media_type_copper;
1596 case IXGBE_DEV_ID_X550EM_A_SGMII:
1597 case IXGBE_DEV_ID_X550EM_A_SGMII_L:
1598 media_type = ixgbe_media_type_backplane;
1599 hw->phy.type = ixgbe_phy_sgmii;
1601 case IXGBE_DEV_ID_X550EM_A_1G_T:
1602 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
1603 media_type = ixgbe_media_type_copper;
1606 media_type = ixgbe_media_type_unknown;
1613 * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1614 * @hw: pointer to hardware structure
1615 * @linear: true if SFP module is linear
1617 STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1619 DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1621 switch (hw->phy.sfp_type) {
1622 case ixgbe_sfp_type_not_present:
1623 return IXGBE_ERR_SFP_NOT_PRESENT;
1624 case ixgbe_sfp_type_da_cu_core0:
1625 case ixgbe_sfp_type_da_cu_core1:
1628 case ixgbe_sfp_type_srlr_core0:
1629 case ixgbe_sfp_type_srlr_core1:
1630 case ixgbe_sfp_type_da_act_lmt_core0:
1631 case ixgbe_sfp_type_da_act_lmt_core1:
1632 case ixgbe_sfp_type_1g_sx_core0:
1633 case ixgbe_sfp_type_1g_sx_core1:
1634 case ixgbe_sfp_type_1g_lx_core0:
1635 case ixgbe_sfp_type_1g_lx_core1:
1638 case ixgbe_sfp_type_unknown:
1639 case ixgbe_sfp_type_1g_cu_core0:
1640 case ixgbe_sfp_type_1g_cu_core1:
1642 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1645 return IXGBE_SUCCESS;
1649 * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1650 * @hw: pointer to hardware structure
1652 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1654 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1659 DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1661 status = ixgbe_identify_module_generic(hw);
1663 if (status != IXGBE_SUCCESS)
1666 /* Check if SFP module is supported */
1667 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1673 * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1674 * @hw: pointer to hardware structure
1676 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1681 DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1683 /* Check if SFP module is supported */
1684 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1686 if (status != IXGBE_SUCCESS)
1689 ixgbe_init_mac_link_ops_X550em(hw);
1690 hw->phy.ops.reset = NULL;
1692 return IXGBE_SUCCESS;
1696 * ixgbe_restart_an_internal_phy_x550em - restart autonegotiation for the
1698 * @hw: pointer to hardware structure
1700 STATIC s32 ixgbe_restart_an_internal_phy_x550em(struct ixgbe_hw *hw)
1705 /* Restart auto-negotiation. */
1706 status = hw->mac.ops.read_iosf_sb_reg(hw,
1707 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1708 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_ctrl);
1711 DEBUGOUT("Auto-negotiation did not complete\n");
1715 link_ctrl |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1716 status = hw->mac.ops.write_iosf_sb_reg(hw,
1717 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1718 IXGBE_SB_IOSF_TARGET_KR_PHY, link_ctrl);
1720 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1723 /* Indicate to FW that AN restart has been asserted */
1724 status = hw->mac.ops.read_iosf_sb_reg(hw,
1725 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1726 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_mask_st20);
1729 DEBUGOUT("Auto-negotiation did not complete\n");
1733 flx_mask_st20 |= IXGBE_KRM_PMD_FLX_MASK_ST20_FW_AN_RESTART;
1734 status = hw->mac.ops.write_iosf_sb_reg(hw,
1735 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1736 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_mask_st20);
1743 * ixgbe_setup_sgmii - Set up link for sgmii
1744 * @hw: pointer to hardware structure
1746 STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
1749 struct ixgbe_mac_info *mac = &hw->mac;
1750 u32 lval, sval, flx_val;
1753 rc = mac->ops.read_iosf_sb_reg(hw,
1754 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1755 IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
1759 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1760 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1761 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
1762 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
1763 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1764 rc = mac->ops.write_iosf_sb_reg(hw,
1765 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1766 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1770 rc = mac->ops.read_iosf_sb_reg(hw,
1771 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1772 IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
1776 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
1777 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
1778 rc = mac->ops.write_iosf_sb_reg(hw,
1779 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1780 IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
1784 rc = mac->ops.read_iosf_sb_reg(hw,
1785 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1786 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
1790 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
1791 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
1792 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
1793 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
1794 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
1796 rc = mac->ops.write_iosf_sb_reg(hw,
1797 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1798 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
1802 rc = ixgbe_restart_an_internal_phy_x550em(hw);
1806 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
1810 * ixgbe_setup_sgmii_fw - Set up link for sgmii with firmware-controlled PHYs
1811 * @hw: pointer to hardware structure
1813 STATIC s32 ixgbe_setup_sgmii_fw(struct ixgbe_hw *hw, ixgbe_link_speed speed,
1816 struct ixgbe_mac_info *mac = &hw->mac;
1817 u32 lval, sval, flx_val;
1820 rc = mac->ops.read_iosf_sb_reg(hw,
1821 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1822 IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
1826 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1827 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1828 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
1829 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
1830 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1831 rc = mac->ops.write_iosf_sb_reg(hw,
1832 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1833 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1837 rc = mac->ops.read_iosf_sb_reg(hw,
1838 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1839 IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
1843 sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
1844 sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
1845 rc = mac->ops.write_iosf_sb_reg(hw,
1846 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1847 IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
1851 rc = mac->ops.write_iosf_sb_reg(hw,
1852 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1853 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1857 rc = mac->ops.read_iosf_sb_reg(hw,
1858 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1859 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
1863 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
1864 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
1865 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
1866 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
1867 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
1869 rc = mac->ops.write_iosf_sb_reg(hw,
1870 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1871 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
1875 rc = ixgbe_restart_an_internal_phy_x550em(hw);
1877 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
1881 * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1882 * @hw: pointer to hardware structure
1884 void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1886 struct ixgbe_mac_info *mac = &hw->mac;
1888 DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1890 switch (hw->mac.ops.get_media_type(hw)) {
1891 case ixgbe_media_type_fiber:
1892 /* CS4227 does not support autoneg, so disable the laser control
1893 * functions for SFP+ fiber
1895 mac->ops.disable_tx_laser = NULL;
1896 mac->ops.enable_tx_laser = NULL;
1897 mac->ops.flap_tx_laser = NULL;
1898 mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1899 mac->ops.set_rate_select_speed =
1900 ixgbe_set_soft_rate_select_speed;
1902 if ((hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) ||
1903 (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP))
1904 mac->ops.setup_mac_link =
1905 ixgbe_setup_mac_link_sfp_x550a;
1907 mac->ops.setup_mac_link =
1908 ixgbe_setup_mac_link_sfp_x550em;
1910 case ixgbe_media_type_copper:
1911 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1912 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T ||
1913 hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) {
1914 mac->ops.setup_link = ixgbe_setup_sgmii_fw;
1915 mac->ops.check_link =
1916 ixgbe_check_mac_link_generic;
1918 mac->ops.setup_link =
1919 ixgbe_setup_mac_link_t_X550em;
1922 mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1923 mac->ops.check_link = ixgbe_check_link_t_X550em;
1926 case ixgbe_media_type_backplane:
1927 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
1928 hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
1929 mac->ops.setup_link = ixgbe_setup_sgmii;
1937 * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1938 * @hw: pointer to hardware structure
1939 * @speed: pointer to link speed
1940 * @autoneg: true when autoneg or autotry is enabled
1942 s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1943 ixgbe_link_speed *speed,
1946 DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1949 if (hw->phy.type == ixgbe_phy_fw) {
1951 *speed = hw->phy.speeds_supported;
1956 if (hw->phy.media_type == ixgbe_media_type_fiber) {
1958 /* CS4227 SFP must not enable auto-negotiation */
1961 /* Check if 1G SFP module. */
1962 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1963 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1964 || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1965 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1966 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1967 return IXGBE_SUCCESS;
1970 /* Link capabilities are based on SFP */
1971 if (hw->phy.multispeed_fiber)
1972 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1973 IXGBE_LINK_SPEED_1GB_FULL;
1975 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1977 switch (hw->phy.type) {
1978 case ixgbe_phy_sgmii:
1979 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1981 case ixgbe_phy_x550em_kr:
1982 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1983 /* check different backplane modes */
1984 if (hw->phy.nw_mng_if_sel &
1985 IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
1986 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
1988 } else if (hw->device_id ==
1989 IXGBE_DEV_ID_X550EM_A_KR_L) {
1990 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1996 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1997 IXGBE_LINK_SPEED_1GB_FULL;
2003 return IXGBE_SUCCESS;
2007 * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
2008 * @hw: pointer to hardware structure
2009 * @lsc: pointer to boolean flag which indicates whether external Base T
2010 * PHY interrupt is lsc
2012 * Determime if external Base T PHY interrupt cause is high temperature
2013 * failure alarm or link status change.
2015 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
2016 * failure alarm, else return PHY access status.
2018 STATIC s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
2025 /* Vendor alarm triggered */
2026 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
2027 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2030 if (status != IXGBE_SUCCESS ||
2031 !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
2034 /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
2035 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
2036 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2039 if (status != IXGBE_SUCCESS ||
2040 !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
2041 IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
2044 /* Global alarm triggered */
2045 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
2046 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2049 if (status != IXGBE_SUCCESS)
2052 /* If high temperature failure, then return over temp error and exit */
2053 if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
2054 /* power down the PHY in case the PHY FW didn't already */
2055 ixgbe_set_copper_phy_power(hw, false);
2056 return IXGBE_ERR_OVERTEMP;
2057 } else if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
2058 /* device fault alarm triggered */
2059 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
2060 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2063 if (status != IXGBE_SUCCESS)
2066 /* if device fault was due to high temp alarm handle and exit */
2067 if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
2068 /* power down the PHY in case the PHY FW didn't */
2069 ixgbe_set_copper_phy_power(hw, false);
2070 return IXGBE_ERR_OVERTEMP;
2074 /* Vendor alarm 2 triggered */
2075 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
2076 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2078 if (status != IXGBE_SUCCESS ||
2079 !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
2082 /* link connect/disconnect event occurred */
2083 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
2084 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2086 if (status != IXGBE_SUCCESS)
2090 if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
2093 return IXGBE_SUCCESS;
2097 * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
2098 * @hw: pointer to hardware structure
2100 * Enable link status change and temperature failure alarm for the external
2103 * Returns PHY access status
2105 STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
2111 /* Clear interrupt flags */
2112 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
2114 /* Enable link status change alarm */
2116 /* Enable the LASI interrupts on X552 devices to receive notifications
2117 * of the link configurations of the external PHY and correspondingly
2118 * support the configuration of the internal iXFI link, since iXFI does
2119 * not support auto-negotiation. This is not required for X553 devices
2120 * having KR support, which performs auto-negotiations and which is used
2121 * as the internal link to the external PHY. Hence adding a check here
2122 * to avoid enabling LASI interrupts for X553 devices.
2124 if (hw->mac.type != ixgbe_mac_X550EM_a) {
2125 status = hw->phy.ops.read_reg(hw,
2126 IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
2127 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2129 if (status != IXGBE_SUCCESS)
2132 reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
2134 status = hw->phy.ops.write_reg(hw,
2135 IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
2136 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
2138 if (status != IXGBE_SUCCESS)
2142 /* Enable high temperature failure and global fault alarms */
2143 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
2144 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2147 if (status != IXGBE_SUCCESS)
2150 reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
2151 IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
2153 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
2154 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2157 if (status != IXGBE_SUCCESS)
2160 /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
2161 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
2162 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2165 if (status != IXGBE_SUCCESS)
2168 reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
2169 IXGBE_MDIO_GLOBAL_ALARM_1_INT);
2171 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
2172 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2175 if (status != IXGBE_SUCCESS)
2178 /* Enable chip-wide vendor alarm */
2179 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
2180 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2183 if (status != IXGBE_SUCCESS)
2186 reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
2188 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
2189 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2196 * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
2197 * @hw: pointer to hardware structure
2198 * @speed: link speed
2200 * Configures the integrated KR PHY.
2202 STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
2203 ixgbe_link_speed speed)
2208 status = hw->mac.ops.read_iosf_sb_reg(hw,
2209 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2210 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2214 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2215 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
2216 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
2218 /* Advertise 10G support. */
2219 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
2220 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
2222 /* Advertise 1G support. */
2223 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
2224 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
2226 status = hw->mac.ops.write_iosf_sb_reg(hw,
2227 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2228 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2230 if (hw->mac.type == ixgbe_mac_X550EM_a) {
2231 /* Set lane mode to KR auto negotiation */
2232 status = hw->mac.ops.read_iosf_sb_reg(hw,
2233 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2234 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2239 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
2240 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
2241 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
2242 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
2243 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
2245 status = hw->mac.ops.write_iosf_sb_reg(hw,
2246 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2247 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2250 return ixgbe_restart_an_internal_phy_x550em(hw);
2254 * ixgbe_reset_phy_fw - Reset firmware-controlled PHYs
2255 * @hw: pointer to hardware structure
2257 static s32 ixgbe_reset_phy_fw(struct ixgbe_hw *hw)
2259 u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
2262 if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
2263 return IXGBE_SUCCESS;
2265 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_PHY_SW_RESET, &store);
2268 memset(store, 0, sizeof(store));
2270 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_INIT_PHY, &store);
2274 return ixgbe_setup_fw_link(hw);
2278 * ixgbe_check_overtemp_fw - Check firmware-controlled PHYs for overtemp
2279 * @hw: pointer to hardware structure
2281 static s32 ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
2283 u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
2286 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &store);
2290 if (store[0] & FW_PHY_ACT_GET_LINK_INFO_TEMP) {
2291 ixgbe_shutdown_fw_phy(hw);
2292 return IXGBE_ERR_OVERTEMP;
2294 return IXGBE_SUCCESS;
2298 * ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
2299 * @hw: pointer to hardware structure
2301 * Read NW_MNG_IF_SEL register and save field values, and check for valid field
2304 STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
2306 /* Save NW management interface connected on board. This is used
2307 * to determine internal PHY mode.
2309 hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
2311 /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
2312 * PHY address. This register field was has only been used for X552.
2314 if (hw->mac.type == ixgbe_mac_X550EM_a &&
2315 hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
2316 hw->phy.addr = (hw->phy.nw_mng_if_sel &
2317 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
2318 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
2321 return IXGBE_SUCCESS;
2325 * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
2326 * @hw: pointer to hardware structure
2328 * Initialize any function pointers that were not able to be
2329 * set during init_shared_code because the PHY/SFP type was
2330 * not known. Perform the SFP init if necessary.
2332 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
2334 struct ixgbe_phy_info *phy = &hw->phy;
2337 DEBUGFUNC("ixgbe_init_phy_ops_X550em");
2339 hw->mac.ops.set_lan_id(hw);
2340 ixgbe_read_mng_if_sel_x550em(hw);
2342 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
2343 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
2344 ixgbe_setup_mux_ctl(hw);
2345 phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
2348 switch (hw->device_id) {
2349 case IXGBE_DEV_ID_X550EM_A_1G_T:
2350 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
2351 phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi_22;
2352 phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi_22;
2353 hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
2354 hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
2355 phy->ops.check_overtemp = ixgbe_check_overtemp_fw;
2357 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
2359 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
2362 case IXGBE_DEV_ID_X550EM_A_10G_T:
2363 case IXGBE_DEV_ID_X550EM_A_SFP:
2364 hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
2365 hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
2367 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
2369 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
2371 case IXGBE_DEV_ID_X550EM_X_SFP:
2372 /* set up for CS4227 usage */
2373 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
2379 /* Identify the PHY or SFP module */
2380 ret_val = phy->ops.identify(hw);
2381 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED ||
2382 ret_val == IXGBE_ERR_PHY_ADDR_INVALID)
2385 /* Setup function pointers based on detected hardware */
2386 ixgbe_init_mac_link_ops_X550em(hw);
2387 if (phy->sfp_type != ixgbe_sfp_type_unknown)
2388 phy->ops.reset = NULL;
2390 /* Set functions pointers based on phy type */
2391 switch (hw->phy.type) {
2392 case ixgbe_phy_x550em_kx4:
2393 phy->ops.setup_link = NULL;
2394 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2395 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2397 case ixgbe_phy_x550em_kr:
2398 phy->ops.setup_link = ixgbe_setup_kr_x550em;
2399 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2400 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2402 case ixgbe_phy_x550em_xfi:
2403 /* link is managed by HW */
2404 phy->ops.setup_link = NULL;
2405 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2406 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2408 case ixgbe_phy_x550em_ext_t:
2409 /* If internal link mode is XFI, then setup iXFI internal link,
2410 * else setup KR now.
2412 phy->ops.setup_internal_link =
2413 ixgbe_setup_internal_phy_t_x550em;
2415 /* setup SW LPLU only for first revision of X550EM_x */
2416 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
2417 !(IXGBE_FUSES0_REV_MASK &
2418 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
2419 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
2421 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
2422 phy->ops.reset = ixgbe_reset_phy_t_X550em;
2424 case ixgbe_phy_sgmii:
2425 phy->ops.setup_link = NULL;
2428 phy->ops.setup_link = ixgbe_setup_fw_link;
2429 phy->ops.reset = ixgbe_reset_phy_fw;
2438 * ixgbe_set_mdio_speed - Set MDIO clock speed
2439 * @hw: pointer to hardware structure
2441 STATIC void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
2445 switch (hw->device_id) {
2446 case IXGBE_DEV_ID_X550EM_X_10G_T:
2447 case IXGBE_DEV_ID_X550EM_A_SGMII:
2448 case IXGBE_DEV_ID_X550EM_A_SGMII_L:
2449 case IXGBE_DEV_ID_X550EM_A_10G_T:
2450 case IXGBE_DEV_ID_X550EM_A_SFP:
2451 case IXGBE_DEV_ID_X550EM_A_QSFP:
2452 /* Config MDIO clock speed before the first MDIO PHY access */
2453 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
2454 hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
2455 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
2457 case IXGBE_DEV_ID_X550EM_A_1G_T:
2458 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
2459 /* Select fast MDIO clock speed for these devices */
2460 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
2461 hlreg0 |= IXGBE_HLREG0_MDCSPD;
2462 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
2470 * ixgbe_reset_hw_X550em - Perform hardware reset
2471 * @hw: pointer to hardware structure
2473 * Resets the hardware by resetting the transmit and receive units, masks
2474 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
2477 s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
2479 ixgbe_link_speed link_speed;
2483 bool link_up = false;
2485 DEBUGFUNC("ixgbe_reset_hw_X550em");
2487 /* Call adapter stop to disable Tx/Rx and clear interrupts */
2488 status = hw->mac.ops.stop_adapter(hw);
2489 if (status != IXGBE_SUCCESS)
2492 /* flush pending Tx transactions */
2493 ixgbe_clear_tx_pending(hw);
2495 ixgbe_set_mdio_speed(hw);
2497 /* PHY ops must be identified and initialized prior to reset */
2498 status = hw->phy.ops.init(hw);
2500 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
2503 /* start the external PHY */
2504 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
2505 status = ixgbe_init_ext_t_x550em(hw);
2510 /* Setup SFP module if there is one present. */
2511 if (hw->phy.sfp_setup_needed) {
2512 status = hw->mac.ops.setup_sfp(hw);
2513 hw->phy.sfp_setup_needed = false;
2516 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
2520 if (!hw->phy.reset_disable && hw->phy.ops.reset) {
2521 if (hw->phy.ops.reset(hw) == IXGBE_ERR_OVERTEMP)
2522 return IXGBE_ERR_OVERTEMP;
2526 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
2527 * If link reset is used when link is up, it might reset the PHY when
2528 * mng is using it. If link is down or the flag to force full link
2529 * reset is set, then perform link reset.
2531 ctrl = IXGBE_CTRL_LNK_RST;
2532 if (!hw->force_full_reset) {
2533 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
2535 ctrl = IXGBE_CTRL_RST;
2538 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
2539 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
2540 IXGBE_WRITE_FLUSH(hw);
2542 /* Poll for reset bit to self-clear meaning reset is complete */
2543 for (i = 0; i < 10; i++) {
2545 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
2546 if (!(ctrl & IXGBE_CTRL_RST_MASK))
2550 if (ctrl & IXGBE_CTRL_RST_MASK) {
2551 status = IXGBE_ERR_RESET_FAILED;
2552 DEBUGOUT("Reset polling failed to complete.\n");
2557 /* Double resets are required for recovery from certain error
2558 * conditions. Between resets, it is necessary to stall to
2559 * allow time for any pending HW events to complete.
2561 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
2562 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
2566 /* Store the permanent mac address */
2567 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
2569 /* Store MAC address from RAR0, clear receive address registers, and
2570 * clear the multicast table. Also reset num_rar_entries to 128,
2571 * since we modify this value when programming the SAN MAC address.
2573 hw->mac.num_rar_entries = 128;
2574 hw->mac.ops.init_rx_addrs(hw);
2576 ixgbe_set_mdio_speed(hw);
2578 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
2579 ixgbe_setup_mux_ctl(hw);
2585 * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
2586 * @hw: pointer to hardware structure
2588 s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
2593 status = hw->phy.ops.read_reg(hw,
2594 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
2595 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2598 if (status != IXGBE_SUCCESS)
2601 /* If PHY FW reset completed bit is set then this is the first
2602 * SW instance after a power on so the PHY FW must be un-stalled.
2604 if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
2605 status = hw->phy.ops.read_reg(hw,
2606 IXGBE_MDIO_GLOBAL_RES_PR_10,
2607 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2610 if (status != IXGBE_SUCCESS)
2613 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
2615 status = hw->phy.ops.write_reg(hw,
2616 IXGBE_MDIO_GLOBAL_RES_PR_10,
2617 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2620 if (status != IXGBE_SUCCESS)
2628 * ixgbe_setup_kr_x550em - Configure the KR PHY.
2629 * @hw: pointer to hardware structure
2631 * Configures the integrated KR PHY for X550EM_x.
2633 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
2635 if (hw->mac.type != ixgbe_mac_X550EM_x)
2636 return IXGBE_SUCCESS;
2638 return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
2642 * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
2643 * @hw: pointer to hardware structure
2645 * Configure the external PHY and the integrated KR PHY for SFP support.
2647 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
2648 ixgbe_link_speed speed,
2649 bool autoneg_wait_to_complete)
2652 u16 reg_slice, reg_val;
2653 bool setup_linear = false;
2654 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2656 /* Check if SFP module is supported and linear */
2657 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2659 /* If no SFP module present, then return success. Return success since
2660 * there is no reason to configure CS4227 and SFP not present error is
2661 * not excepted in the setup MAC link flow.
2663 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2664 return IXGBE_SUCCESS;
2666 if (ret_val != IXGBE_SUCCESS)
2669 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
2670 /* Configure CS4227 LINE side to 10G SR. */
2671 reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB +
2672 (hw->bus.lan_id << 12);
2673 reg_val = IXGBE_CS4227_SPEED_10G;
2674 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2677 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
2678 (hw->bus.lan_id << 12);
2679 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2680 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2683 /* Configure CS4227 for HOST connection rate then type. */
2684 reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB +
2685 (hw->bus.lan_id << 12);
2686 reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ?
2687 IXGBE_CS4227_SPEED_10G : IXGBE_CS4227_SPEED_1G;
2688 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2691 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB +
2692 (hw->bus.lan_id << 12);
2694 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2696 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2697 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2700 /* Setup XFI internal link. */
2701 ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
2703 /* Configure internal PHY for KR/KX. */
2704 ixgbe_setup_kr_speed_x550em(hw, speed);
2706 /* Configure CS4227 LINE side to proper mode. */
2707 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
2708 (hw->bus.lan_id << 12);
2710 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2712 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2713 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2720 * ixgbe_setup_sfi_x550a - Configure the internal PHY for native SFI mode
2721 * @hw: pointer to hardware structure
2722 * @speed: the link speed to force
2724 * Configures the integrated PHY for native SFI mode. Used to connect the
2725 * internal PHY directly to an SFP cage, without autonegotiation.
2727 STATIC s32 ixgbe_setup_sfi_x550a(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2729 struct ixgbe_mac_info *mac = &hw->mac;
2733 /* Disable all AN and force speed to 10G Serial. */
2734 status = mac->ops.read_iosf_sb_reg(hw,
2735 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2736 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2737 if (status != IXGBE_SUCCESS)
2740 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
2741 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
2742 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
2743 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
2745 /* Select forced link speed for internal PHY. */
2747 case IXGBE_LINK_SPEED_10GB_FULL:
2748 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_10G;
2750 case IXGBE_LINK_SPEED_1GB_FULL:
2751 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
2754 /* Other link speeds are not supported by internal PHY. */
2755 return IXGBE_ERR_LINK_SETUP;
2758 status = mac->ops.write_iosf_sb_reg(hw,
2759 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2760 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2762 /* Toggle port SW reset by AN reset. */
2763 status = ixgbe_restart_an_internal_phy_x550em(hw);
2769 * ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
2770 * @hw: pointer to hardware structure
2772 * Configure the the integrated PHY for SFP support.
2774 s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
2775 ixgbe_link_speed speed,
2776 bool autoneg_wait_to_complete)
2780 bool setup_linear = false;
2781 u32 reg_slice, reg_phy_int, slice_offset;
2783 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2785 /* Check if SFP module is supported and linear */
2786 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2788 /* If no SFP module present, then return success. Return success since
2789 * SFP not present error is not excepted in the setup MAC link flow.
2791 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2792 return IXGBE_SUCCESS;
2794 if (ret_val != IXGBE_SUCCESS)
2797 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) {
2798 /* Configure internal PHY for native SFI based on module type */
2799 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
2800 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2801 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_phy_int);
2803 if (ret_val != IXGBE_SUCCESS)
2806 reg_phy_int &= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_DA;
2808 reg_phy_int |= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_SR;
2810 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
2811 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2812 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_phy_int);
2814 if (ret_val != IXGBE_SUCCESS)
2817 /* Setup SFI internal link. */
2818 ret_val = ixgbe_setup_sfi_x550a(hw, &speed);
2820 /* Configure internal PHY for KR/KX. */
2821 ixgbe_setup_kr_speed_x550em(hw, speed);
2823 if (hw->phy.addr == 0x0 || hw->phy.addr == 0xFFFF) {
2825 DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
2826 return IXGBE_ERR_PHY_ADDR_INVALID;
2829 /* Get external PHY SKU id */
2830 ret_val = hw->phy.ops.read_reg(hw, IXGBE_CS4227_EFUSE_PDF_SKU,
2831 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2833 if (ret_val != IXGBE_SUCCESS)
2836 /* When configuring quad port CS4223, the MAC instance is part
2837 * of the slice offset.
2839 if (reg_phy_ext == IXGBE_CS4223_SKU_ID)
2840 slice_offset = (hw->bus.lan_id +
2841 (hw->bus.instance_id << 1)) << 12;
2843 slice_offset = hw->bus.lan_id << 12;
2845 /* Configure CS4227/CS4223 LINE side to proper mode. */
2846 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
2848 ret_val = hw->phy.ops.read_reg(hw, reg_slice,
2849 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2851 if (ret_val != IXGBE_SUCCESS)
2854 reg_phy_ext &= ~((IXGBE_CS4227_EDC_MODE_CX1 << 1) |
2855 (IXGBE_CS4227_EDC_MODE_SR << 1));
2858 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2860 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2861 ret_val = hw->phy.ops.write_reg(hw, reg_slice,
2862 IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
2864 /* Flush previous write with a read */
2865 ret_val = hw->phy.ops.read_reg(hw, reg_slice,
2866 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2872 * ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
2873 * @hw: pointer to hardware structure
2875 * iXfI configuration needed for ixgbe_mac_X550EM_x devices.
2877 STATIC s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
2879 struct ixgbe_mac_info *mac = &hw->mac;
2883 /* Disable training protocol FSM. */
2884 status = mac->ops.read_iosf_sb_reg(hw,
2885 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2886 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2887 if (status != IXGBE_SUCCESS)
2889 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
2890 status = mac->ops.write_iosf_sb_reg(hw,
2891 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2892 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2893 if (status != IXGBE_SUCCESS)
2896 /* Disable Flex from training TXFFE. */
2897 status = mac->ops.read_iosf_sb_reg(hw,
2898 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2899 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2900 if (status != IXGBE_SUCCESS)
2902 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2903 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2904 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2905 status = mac->ops.write_iosf_sb_reg(hw,
2906 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2907 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2908 if (status != IXGBE_SUCCESS)
2910 status = mac->ops.read_iosf_sb_reg(hw,
2911 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2912 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2913 if (status != IXGBE_SUCCESS)
2915 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2916 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2917 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2918 status = mac->ops.write_iosf_sb_reg(hw,
2919 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2920 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2921 if (status != IXGBE_SUCCESS)
2924 /* Enable override for coefficients. */
2925 status = mac->ops.read_iosf_sb_reg(hw,
2926 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2927 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2928 if (status != IXGBE_SUCCESS)
2930 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
2931 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
2932 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
2933 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
2934 status = mac->ops.write_iosf_sb_reg(hw,
2935 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2936 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2941 * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
2942 * @hw: pointer to hardware structure
2943 * @speed: the link speed to force
2945 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
2946 * internal and external PHY at a specific speed, without autonegotiation.
2948 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2950 struct ixgbe_mac_info *mac = &hw->mac;
2954 /* iXFI is only supported with X552 */
2955 if (mac->type != ixgbe_mac_X550EM_x)
2956 return IXGBE_ERR_LINK_SETUP;
2958 /* Disable AN and force speed to 10G Serial. */
2959 status = mac->ops.read_iosf_sb_reg(hw,
2960 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2961 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2962 if (status != IXGBE_SUCCESS)
2965 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2966 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2968 /* Select forced link speed for internal PHY. */
2970 case IXGBE_LINK_SPEED_10GB_FULL:
2971 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2973 case IXGBE_LINK_SPEED_1GB_FULL:
2974 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
2977 /* Other link speeds are not supported by internal KR PHY. */
2978 return IXGBE_ERR_LINK_SETUP;
2981 status = mac->ops.write_iosf_sb_reg(hw,
2982 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2983 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2984 if (status != IXGBE_SUCCESS)
2987 /* Additional configuration needed for x550em_x */
2988 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2989 status = ixgbe_setup_ixfi_x550em_x(hw);
2990 if (status != IXGBE_SUCCESS)
2994 /* Toggle port SW reset by AN reset. */
2995 status = ixgbe_restart_an_internal_phy_x550em(hw);
3001 * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
3002 * @hw: address of hardware structure
3003 * @link_up: address of boolean to indicate link status
3005 * Returns error code if unable to get link status.
3007 STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
3014 /* read this twice back to back to indicate current status */
3015 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3016 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3018 if (ret != IXGBE_SUCCESS)
3021 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3022 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3024 if (ret != IXGBE_SUCCESS)
3027 *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
3029 return IXGBE_SUCCESS;
3033 * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
3034 * @hw: point to hardware structure
3036 * Configures the link between the integrated KR PHY and the external X557 PHY
3037 * The driver will call this function when it gets a link status change
3038 * interrupt from the X557 PHY. This function configures the link speed
3039 * between the PHYs to match the link speed of the BASE-T link.
3041 * A return of a non-zero value indicates an error, and the base driver should
3042 * not report link up.
3044 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
3046 ixgbe_link_speed force_speed;
3051 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
3052 return IXGBE_ERR_CONFIG;
3054 if (hw->mac.type == ixgbe_mac_X550EM_x &&
3055 !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
3056 /* If link is down, there is no setup necessary so return */
3057 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3058 if (status != IXGBE_SUCCESS)
3062 return IXGBE_SUCCESS;
3064 status = hw->phy.ops.read_reg(hw,
3065 IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
3066 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3068 if (status != IXGBE_SUCCESS)
3071 /* If link is still down - no setup is required so return */
3072 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3073 if (status != IXGBE_SUCCESS)
3076 return IXGBE_SUCCESS;
3078 /* clear everything but the speed and duplex bits */
3079 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
3082 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
3083 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
3085 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
3086 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
3089 /* Internal PHY does not support anything else */
3090 return IXGBE_ERR_INVALID_LINK_SETTINGS;
3093 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
3095 speed = IXGBE_LINK_SPEED_10GB_FULL |
3096 IXGBE_LINK_SPEED_1GB_FULL;
3097 return ixgbe_setup_kr_speed_x550em(hw, speed);
3102 * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
3103 * @hw: pointer to hardware structure
3105 * Configures the integrated KR PHY to use internal loopback mode.
3107 s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
3112 /* Disable AN and force speed to 10G Serial. */
3113 status = hw->mac.ops.read_iosf_sb_reg(hw,
3114 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
3115 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3116 if (status != IXGBE_SUCCESS)
3118 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
3119 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
3120 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
3121 status = hw->mac.ops.write_iosf_sb_reg(hw,
3122 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
3123 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3124 if (status != IXGBE_SUCCESS)
3127 /* Set near-end loopback clocks. */
3128 status = hw->mac.ops.read_iosf_sb_reg(hw,
3129 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
3130 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3131 if (status != IXGBE_SUCCESS)
3133 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
3134 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
3135 status = hw->mac.ops.write_iosf_sb_reg(hw,
3136 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
3137 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3138 if (status != IXGBE_SUCCESS)
3141 /* Set loopback enable. */
3142 status = hw->mac.ops.read_iosf_sb_reg(hw,
3143 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
3144 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3145 if (status != IXGBE_SUCCESS)
3147 reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
3148 status = hw->mac.ops.write_iosf_sb_reg(hw,
3149 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
3150 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3151 if (status != IXGBE_SUCCESS)
3154 /* Training bypass. */
3155 status = hw->mac.ops.read_iosf_sb_reg(hw,
3156 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
3157 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3158 if (status != IXGBE_SUCCESS)
3160 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
3161 status = hw->mac.ops.write_iosf_sb_reg(hw,
3162 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
3163 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3169 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
3170 * assuming that the semaphore is already obtained.
3171 * @hw: pointer to hardware structure
3172 * @offset: offset of word in the EEPROM to read
3173 * @data: word read from the EEPROM
3175 * Reads a 16 bit word from the EEPROM using the hostif.
3177 s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 *data)
3179 const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
3180 struct ixgbe_hic_read_shadow_ram buffer;
3183 DEBUGFUNC("ixgbe_read_ee_hostif_X550");
3184 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
3185 buffer.hdr.req.buf_lenh = 0;
3186 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
3187 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3189 /* convert offset from words to bytes */
3190 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
3192 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
3194 status = hw->mac.ops.acquire_swfw_sync(hw, mask);
3198 status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
3199 IXGBE_HI_COMMAND_TIMEOUT);
3201 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
3202 FW_NVM_DATA_OFFSET);
3205 hw->mac.ops.release_swfw_sync(hw, mask);
3210 * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
3211 * @hw: pointer to hardware structure
3212 * @offset: offset of word in the EEPROM to read
3213 * @words: number of words
3214 * @data: word(s) read from the EEPROM
3216 * Reads a 16 bit word(s) from the EEPROM using the hostif.
3218 s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
3219 u16 offset, u16 words, u16 *data)
3221 const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
3222 struct ixgbe_hic_read_shadow_ram buffer;
3223 u32 current_word = 0;
3228 DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
3230 /* Take semaphore for the entire operation. */
3231 status = hw->mac.ops.acquire_swfw_sync(hw, mask);
3233 DEBUGOUT("EEPROM read buffer - semaphore failed\n");
3238 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
3239 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
3241 words_to_read = words;
3243 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
3244 buffer.hdr.req.buf_lenh = 0;
3245 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
3246 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3248 /* convert offset from words to bytes */
3249 buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
3250 buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
3252 status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
3253 IXGBE_HI_COMMAND_TIMEOUT);
3256 DEBUGOUT("Host interface command failed\n");
3260 for (i = 0; i < words_to_read; i++) {
3261 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
3263 u32 value = IXGBE_READ_REG(hw, reg);
3265 data[current_word] = (u16)(value & 0xffff);
3268 if (i < words_to_read) {
3270 data[current_word] = (u16)(value & 0xffff);
3274 words -= words_to_read;
3278 hw->mac.ops.release_swfw_sync(hw, mask);
3283 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
3284 * @hw: pointer to hardware structure
3285 * @offset: offset of word in the EEPROM to write
3286 * @data: word write to the EEPROM
3288 * Write a 16 bit word to the EEPROM using the hostif.
3290 s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
3294 struct ixgbe_hic_write_shadow_ram buffer;
3296 DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
3298 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
3299 buffer.hdr.req.buf_lenh = 0;
3300 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
3301 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3304 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
3306 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
3308 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
3310 IXGBE_HI_COMMAND_TIMEOUT, false);
3316 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
3317 * @hw: pointer to hardware structure
3318 * @offset: offset of word in the EEPROM to write
3319 * @data: word write to the EEPROM
3321 * Write a 16 bit word to the EEPROM using the hostif.
3323 s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
3326 s32 status = IXGBE_SUCCESS;
3328 DEBUGFUNC("ixgbe_write_ee_hostif_X550");
3330 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
3332 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
3333 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3335 DEBUGOUT("write ee hostif failed to get semaphore");
3336 status = IXGBE_ERR_SWFW_SYNC;
3343 * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
3344 * @hw: pointer to hardware structure
3345 * @offset: offset of word in the EEPROM to write
3346 * @words: number of words
3347 * @data: word(s) write to the EEPROM
3349 * Write a 16 bit word(s) to the EEPROM using the hostif.
3351 s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
3352 u16 offset, u16 words, u16 *data)
3354 s32 status = IXGBE_SUCCESS;
3357 DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
3359 /* Take semaphore for the entire operation. */
3360 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3361 if (status != IXGBE_SUCCESS) {
3362 DEBUGOUT("EEPROM write buffer - semaphore failed\n");
3366 for (i = 0; i < words; i++) {
3367 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
3370 if (status != IXGBE_SUCCESS) {
3371 DEBUGOUT("Eeprom buffered write failed\n");
3376 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3383 * ixgbe_checksum_ptr_x550 - Checksum one pointer region
3384 * @hw: pointer to hardware structure
3385 * @ptr: pointer offset in eeprom
3386 * @size: size of section pointed by ptr, if 0 first word will be used as size
3387 * @csum: address of checksum to update
3389 * Returns error status for any failure
3391 STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
3392 u16 size, u16 *csum, u16 *buffer,
3397 u16 length, bufsz, i, start;
3400 bufsz = sizeof(buf) / sizeof(buf[0]);
3402 /* Read a chunk at the pointer location */
3404 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
3406 DEBUGOUT("Failed to read EEPROM image\n");
3411 if (buffer_size < ptr)
3412 return IXGBE_ERR_PARAM;
3413 local_buffer = &buffer[ptr];
3421 length = local_buffer[0];
3423 /* Skip pointer section if length is invalid. */
3424 if (length == 0xFFFF || length == 0 ||
3425 (ptr + length) >= hw->eeprom.word_size)
3426 return IXGBE_SUCCESS;
3429 if (buffer && ((u32)start + (u32)length > buffer_size))
3430 return IXGBE_ERR_PARAM;
3432 for (i = start; length; i++, length--) {
3433 if (i == bufsz && !buffer) {
3439 /* Read a chunk at the pointer location */
3440 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
3443 DEBUGOUT("Failed to read EEPROM image\n");
3447 *csum += local_buffer[i];
3449 return IXGBE_SUCCESS;
3453 * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
3454 * @hw: pointer to hardware structure
3455 * @buffer: pointer to buffer containing calculated checksum
3456 * @buffer_size: size of buffer
3458 * Returns a negative error code on error, or the 16-bit checksum
3460 s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
3462 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
3466 u16 pointer, i, size;
3468 DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
3470 hw->eeprom.ops.init_params(hw);
3473 /* Read pointer area */
3474 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
3475 IXGBE_EEPROM_LAST_WORD + 1,
3478 DEBUGOUT("Failed to read EEPROM image\n");
3481 local_buffer = eeprom_ptrs;
3483 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
3484 return IXGBE_ERR_PARAM;
3485 local_buffer = buffer;
3489 * For X550 hardware include 0x0-0x41 in the checksum, skip the
3490 * checksum word itself
3492 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
3493 if (i != IXGBE_EEPROM_CHECKSUM)
3494 checksum += local_buffer[i];
3497 * Include all data from pointers 0x3, 0x6-0xE. This excludes the
3498 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
3500 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
3501 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
3504 pointer = local_buffer[i];
3506 /* Skip pointer section if the pointer is invalid. */
3507 if (pointer == 0xFFFF || pointer == 0 ||
3508 pointer >= hw->eeprom.word_size)
3512 case IXGBE_PCIE_GENERAL_PTR:
3513 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
3515 case IXGBE_PCIE_CONFIG0_PTR:
3516 case IXGBE_PCIE_CONFIG1_PTR:
3517 size = IXGBE_PCIE_CONFIG_SIZE;
3524 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
3525 buffer, buffer_size);
3530 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
3532 return (s32)checksum;
3536 * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
3537 * @hw: pointer to hardware structure
3539 * Returns a negative error code on error, or the 16-bit checksum
3541 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
3543 return ixgbe_calc_checksum_X550(hw, NULL, 0);
3547 * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
3548 * @hw: pointer to hardware structure
3549 * @checksum_val: calculated checksum
3551 * Performs checksum calculation and validates the EEPROM checksum. If the
3552 * caller does not need checksum_val, the value can be NULL.
3554 s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
3558 u16 read_checksum = 0;
3560 DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
3562 /* Read the first word from the EEPROM. If this times out or fails, do
3563 * not continue or we could be in for a very long wait while every
3566 status = hw->eeprom.ops.read(hw, 0, &checksum);
3568 DEBUGOUT("EEPROM read failed\n");
3572 status = hw->eeprom.ops.calc_checksum(hw);
3576 checksum = (u16)(status & 0xffff);
3578 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3583 /* Verify read checksum from EEPROM is the same as
3584 * calculated checksum
3586 if (read_checksum != checksum) {
3587 status = IXGBE_ERR_EEPROM_CHECKSUM;
3588 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
3589 "Invalid EEPROM checksum");
3592 /* If the user cares, return the calculated checksum */
3594 *checksum_val = checksum;
3600 * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
3601 * @hw: pointer to hardware structure
3603 * After writing EEPROM to shadow RAM using EEWR register, software calculates
3604 * checksum and updates the EEPROM and instructs the hardware to update
3607 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
3612 DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
3614 /* Read the first word from the EEPROM. If this times out or fails, do
3615 * not continue or we could be in for a very long wait while every
3618 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
3620 DEBUGOUT("EEPROM read failed\n");
3624 status = ixgbe_calc_eeprom_checksum_X550(hw);
3628 checksum = (u16)(status & 0xffff);
3630 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3635 status = ixgbe_update_flash_X550(hw);
3641 * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
3642 * @hw: pointer to hardware structure
3644 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
3646 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
3648 s32 status = IXGBE_SUCCESS;
3649 union ixgbe_hic_hdr2 buffer;
3651 DEBUGFUNC("ixgbe_update_flash_X550");
3653 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
3654 buffer.req.buf_lenh = 0;
3655 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
3656 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
3658 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
3660 IXGBE_HI_COMMAND_TIMEOUT, false);
3666 * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
3667 * @hw: pointer to hardware structure
3669 * Determines physical layer capabilities of the current configuration.
3671 u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
3673 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
3674 u16 ext_ability = 0;
3676 DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
3678 hw->phy.ops.identify(hw);
3680 switch (hw->phy.type) {
3681 case ixgbe_phy_x550em_kr:
3682 case ixgbe_phy_x550em_xfi:
3683 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
3684 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3686 case ixgbe_phy_x550em_kx4:
3687 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
3688 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3690 case ixgbe_phy_x550em_ext_t:
3691 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
3692 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
3694 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
3695 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
3696 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
3697 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3700 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_1GB_FULL)
3701 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3702 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_100_FULL)
3703 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
3704 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_10_FULL)
3705 physical_layer |= IXGBE_PHYSICAL_LAYER_10BASE_T;
3707 case ixgbe_phy_sgmii:
3708 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3714 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
3715 physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
3717 return physical_layer;
3721 * ixgbe_get_bus_info_x550em - Set PCI bus info
3722 * @hw: pointer to hardware structure
3724 * Sets bus link width and speed to unknown because X550em is
3727 s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
3730 DEBUGFUNC("ixgbe_get_bus_info_x550em");
3732 hw->bus.width = ixgbe_bus_width_unknown;
3733 hw->bus.speed = ixgbe_bus_speed_unknown;
3735 hw->mac.ops.set_lan_id(hw);
3737 return IXGBE_SUCCESS;
3741 * ixgbe_disable_rx_x550 - Disable RX unit
3743 * Enables the Rx DMA unit for x550
3745 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
3747 u32 rxctrl, pfdtxgswc;
3749 struct ixgbe_hic_disable_rxen fw_cmd;
3751 DEBUGFUNC("ixgbe_enable_rx_dma_x550");
3753 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3754 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3755 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
3756 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
3757 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
3758 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
3759 hw->mac.set_lben = true;
3761 hw->mac.set_lben = false;
3764 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
3765 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
3766 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
3767 fw_cmd.port_number = (u8)hw->bus.lan_id;
3769 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
3770 sizeof(struct ixgbe_hic_disable_rxen),
3771 IXGBE_HI_COMMAND_TIMEOUT, true);
3773 /* If we fail - disable RX using register write */
3775 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3776 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3777 rxctrl &= ~IXGBE_RXCTRL_RXEN;
3778 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
3785 * ixgbe_enter_lplu_x550em - Transition to low power states
3786 * @hw: pointer to hardware structure
3788 * Configures Low Power Link Up on transition to low power states
3789 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
3790 * X557 PHY immediately prior to entering LPLU.
3792 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
3794 u16 an_10g_cntl_reg, autoneg_reg, speed;
3796 ixgbe_link_speed lcd_speed;
3800 /* SW LPLU not required on later HW revisions. */
3801 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
3802 (IXGBE_FUSES0_REV_MASK &
3803 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
3804 return IXGBE_SUCCESS;
3806 /* If blocked by MNG FW, then don't restart AN */
3807 if (ixgbe_check_reset_blocked(hw))
3808 return IXGBE_SUCCESS;
3810 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3811 if (status != IXGBE_SUCCESS)
3814 status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
3816 if (status != IXGBE_SUCCESS)
3819 /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
3820 * disabled, then force link down by entering low power mode.
3822 if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
3823 !(hw->wol_enabled || ixgbe_mng_present(hw)))
3824 return ixgbe_set_copper_phy_power(hw, FALSE);
3827 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
3829 if (status != IXGBE_SUCCESS)
3832 /* If no valid LCD link speed, then force link down and exit. */
3833 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
3834 return ixgbe_set_copper_phy_power(hw, FALSE);
3836 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
3837 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3840 if (status != IXGBE_SUCCESS)
3843 /* If no link now, speed is invalid so take link down */
3844 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3845 if (status != IXGBE_SUCCESS)
3846 return ixgbe_set_copper_phy_power(hw, false);
3848 /* clear everything but the speed bits */
3849 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
3851 /* If current speed is already LCD, then exit. */
3852 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
3853 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
3854 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
3855 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
3858 /* Clear AN completed indication */
3859 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
3860 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3863 if (status != IXGBE_SUCCESS)
3866 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
3867 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3870 if (status != IXGBE_SUCCESS)
3873 status = hw->phy.ops.read_reg(hw,
3874 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
3875 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3878 if (status != IXGBE_SUCCESS)
3881 save_autoneg = hw->phy.autoneg_advertised;
3883 /* Setup link at least common link speed */
3884 status = hw->mac.ops.setup_link(hw, lcd_speed, false);
3886 /* restore autoneg from before setting lplu speed */
3887 hw->phy.autoneg_advertised = save_autoneg;
3893 * ixgbe_get_lcd_x550em - Determine lowest common denominator
3894 * @hw: pointer to hardware structure
3895 * @lcd_speed: pointer to lowest common link speed
3897 * Determine lowest common link speed with link partner.
3899 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
3903 u16 word = hw->eeprom.ctrl_word_3;
3905 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
3907 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
3908 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3911 if (status != IXGBE_SUCCESS)
3914 /* If link partner advertised 1G, return 1G */
3915 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
3916 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
3920 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
3921 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
3922 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
3925 /* Link partner not capable of lower speeds, return 10G */
3926 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
3931 * ixgbe_setup_fc_X550em - Set up flow control
3932 * @hw: pointer to hardware structure
3934 * Called at init time to set up flow control.
3936 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
3938 s32 ret_val = IXGBE_SUCCESS;
3939 u32 pause, asm_dir, reg_val;
3941 DEBUGFUNC("ixgbe_setup_fc_X550em");
3943 /* Validate the requested mode */
3944 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
3945 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
3946 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
3947 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3951 /* 10gig parts do not have a word in the EEPROM to determine the
3952 * default flow control setting, so we explicitly set it to full.
3954 if (hw->fc.requested_mode == ixgbe_fc_default)
3955 hw->fc.requested_mode = ixgbe_fc_full;
3957 /* Determine PAUSE and ASM_DIR bits. */
3958 switch (hw->fc.requested_mode) {
3963 case ixgbe_fc_tx_pause:
3967 case ixgbe_fc_rx_pause:
3968 /* Rx Flow control is enabled and Tx Flow control is
3969 * disabled by software override. Since there really
3970 * isn't a way to advertise that we are capable of RX
3971 * Pause ONLY, we will advertise that we support both
3972 * symmetric and asymmetric Rx PAUSE, as such we fall
3973 * through to the fc_full statement. Later, we will
3974 * disable the adapter's ability to send PAUSE frames.
3981 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
3982 "Flow control param set incorrectly\n");
3983 ret_val = IXGBE_ERR_CONFIG;
3987 switch (hw->device_id) {
3988 case IXGBE_DEV_ID_X550EM_X_KR:
3989 case IXGBE_DEV_ID_X550EM_A_KR:
3990 case IXGBE_DEV_ID_X550EM_A_KR_L:
3991 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
3992 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
3993 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3994 if (ret_val != IXGBE_SUCCESS)
3996 reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
3997 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
3999 reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
4001 reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4002 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
4003 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4004 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
4006 /* This device does not fully support AN. */
4007 hw->fc.disable_fc_autoneg = true;
4018 * ixgbe_fc_autoneg_backplane_x550em_a - Enable flow control IEEE clause 37
4019 * @hw: pointer to hardware structure
4021 * Enable flow control according to IEEE clause 37.
4023 void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *hw)
4025 u32 link_s1, lp_an_page_low, an_cntl_1;
4026 s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4027 ixgbe_link_speed speed;
4030 /* AN should have completed when the cable was plugged in.
4031 * Look for reasons to bail out. Bail out if:
4032 * - FC autoneg is disabled, or if
4035 if (hw->fc.disable_fc_autoneg) {
4036 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4037 "Flow control autoneg is disabled");
4041 hw->mac.ops.check_link(hw, &speed, &link_up, false);
4043 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
4047 /* Check at auto-negotiation has completed */
4048 status = hw->mac.ops.read_iosf_sb_reg(hw,
4049 IXGBE_KRM_LINK_S1(hw->bus.lan_id),
4050 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_s1);
4052 if (status != IXGBE_SUCCESS ||
4053 (link_s1 & IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE) == 0) {
4054 DEBUGOUT("Auto-Negotiation did not complete\n");
4055 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4059 /* Read the 10g AN autoc and LP ability registers and resolve
4060 * local flow control settings accordingly
4062 status = hw->mac.ops.read_iosf_sb_reg(hw,
4063 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4064 IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl_1);
4066 if (status != IXGBE_SUCCESS) {
4067 DEBUGOUT("Auto-Negotiation did not complete\n");
4071 status = hw->mac.ops.read_iosf_sb_reg(hw,
4072 IXGBE_KRM_LP_BASE_PAGE_HIGH(hw->bus.lan_id),
4073 IXGBE_SB_IOSF_TARGET_KR_PHY, &lp_an_page_low);
4075 if (status != IXGBE_SUCCESS) {
4076 DEBUGOUT("Auto-Negotiation did not complete\n");
4080 status = ixgbe_negotiate_fc(hw, an_cntl_1, lp_an_page_low,
4081 IXGBE_KRM_AN_CNTL_1_SYM_PAUSE,
4082 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE,
4083 IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE,
4084 IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE);
4087 if (status == IXGBE_SUCCESS) {
4088 hw->fc.fc_was_autonegged = true;
4090 hw->fc.fc_was_autonegged = false;
4091 hw->fc.current_mode = hw->fc.requested_mode;
4096 * ixgbe_fc_autoneg_fiber_x550em_a - passthrough FC settings
4097 * @hw: pointer to hardware structure
4100 void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *hw)
4102 hw->fc.fc_was_autonegged = false;
4103 hw->fc.current_mode = hw->fc.requested_mode;
4107 * ixgbe_fc_autoneg_sgmii_x550em_a - Enable flow control IEEE clause 37
4108 * @hw: pointer to hardware structure
4110 * Enable flow control according to IEEE clause 37.
4112 void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
4114 s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4115 u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
4116 ixgbe_link_speed speed;
4119 /* AN should have completed when the cable was plugged in.
4120 * Look for reasons to bail out. Bail out if:
4121 * - FC autoneg is disabled, or if
4124 if (hw->fc.disable_fc_autoneg) {
4125 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4126 "Flow control autoneg is disabled");
4130 hw->mac.ops.check_link(hw, &speed, &link_up, false);
4132 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
4136 /* Check if auto-negotiation has completed */
4137 status = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &info);
4138 if (status != IXGBE_SUCCESS ||
4139 !(info[0] & FW_PHY_ACT_GET_LINK_INFO_AN_COMPLETE)) {
4140 DEBUGOUT("Auto-Negotiation did not complete\n");
4141 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4145 /* Negotiate the flow control */
4146 status = ixgbe_negotiate_fc(hw, info[0], info[0],
4147 FW_PHY_ACT_GET_LINK_INFO_FC_RX,
4148 FW_PHY_ACT_GET_LINK_INFO_FC_TX,
4149 FW_PHY_ACT_GET_LINK_INFO_LP_FC_RX,
4150 FW_PHY_ACT_GET_LINK_INFO_LP_FC_TX);
4153 if (status == IXGBE_SUCCESS) {
4154 hw->fc.fc_was_autonegged = true;
4156 hw->fc.fc_was_autonegged = false;
4157 hw->fc.current_mode = hw->fc.requested_mode;
4162 * ixgbe_setup_fc_backplane_x550em_a - Set up flow control
4163 * @hw: pointer to hardware structure
4165 * Called at init time to set up flow control.
4167 s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *hw)
4169 s32 status = IXGBE_SUCCESS;
4172 DEBUGFUNC("ixgbe_setup_fc_backplane_x550em_a");
4174 /* Validate the requested mode */
4175 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
4176 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4177 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
4178 return IXGBE_ERR_INVALID_LINK_SETTINGS;
4181 if (hw->fc.requested_mode == ixgbe_fc_default)
4182 hw->fc.requested_mode = ixgbe_fc_full;
4184 /* Set up the 1G and 10G flow control advertisement registers so the
4185 * HW will be able to do FC autoneg once the cable is plugged in. If
4186 * we link at 10G, the 1G advertisement is harmless and vice versa.
4188 status = hw->mac.ops.read_iosf_sb_reg(hw,
4189 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4190 IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl);
4192 if (status != IXGBE_SUCCESS) {
4193 DEBUGOUT("Auto-Negotiation did not complete\n");
4197 /* The possible values of fc.requested_mode are:
4198 * 0: Flow control is completely disabled
4199 * 1: Rx flow control is enabled (we can receive pause frames,
4200 * but not send pause frames).
4201 * 2: Tx flow control is enabled (we can send pause frames but
4202 * we do not support receiving pause frames).
4203 * 3: Both Rx and Tx flow control (symmetric) are enabled.
4206 switch (hw->fc.requested_mode) {
4208 /* Flow control completely disabled by software override. */
4209 an_cntl &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
4210 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
4212 case ixgbe_fc_tx_pause:
4213 /* Tx Flow control is enabled, and Rx Flow control is
4214 * disabled by software override.
4216 an_cntl |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4217 an_cntl &= ~IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
4219 case ixgbe_fc_rx_pause:
4220 /* Rx Flow control is enabled and Tx Flow control is
4221 * disabled by software override. Since there really
4222 * isn't a way to advertise that we are capable of RX
4223 * Pause ONLY, we will advertise that we support both
4224 * symmetric and asymmetric Rx PAUSE, as such we fall
4225 * through to the fc_full statement. Later, we will
4226 * disable the adapter's ability to send PAUSE frames.
4229 /* Flow control (both Rx and Tx) is enabled by SW override. */
4230 an_cntl |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
4231 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4234 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
4235 "Flow control param set incorrectly\n");
4236 return IXGBE_ERR_CONFIG;
4239 status = hw->mac.ops.write_iosf_sb_reg(hw,
4240 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4241 IXGBE_SB_IOSF_TARGET_KR_PHY, an_cntl);
4243 /* Restart auto-negotiation. */
4244 status = ixgbe_restart_an_internal_phy_x550em(hw);
4250 * ixgbe_set_mux - Set mux for port 1 access with CS4227
4251 * @hw: pointer to hardware structure
4252 * @state: set mux if 1, clear if 0
4254 STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
4258 if (!hw->bus.lan_id)
4260 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
4262 esdp |= IXGBE_ESDP_SDP1;
4264 esdp &= ~IXGBE_ESDP_SDP1;
4265 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
4266 IXGBE_WRITE_FLUSH(hw);
4270 * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
4271 * @hw: pointer to hardware structure
4272 * @mask: Mask to specify which semaphore to acquire
4274 * Acquires the SWFW semaphore and sets the I2C MUX
4276 s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
4280 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
4282 status = ixgbe_acquire_swfw_sync_X540(hw, mask);
4286 if (mask & IXGBE_GSSR_I2C_MASK)
4287 ixgbe_set_mux(hw, 1);
4289 return IXGBE_SUCCESS;
4293 * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
4294 * @hw: pointer to hardware structure
4295 * @mask: Mask to specify which semaphore to release
4297 * Releases the SWFW semaphore and sets the I2C MUX
4299 void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
4301 DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
4303 if (mask & IXGBE_GSSR_I2C_MASK)
4304 ixgbe_set_mux(hw, 0);
4306 ixgbe_release_swfw_sync_X540(hw, mask);
4310 * ixgbe_acquire_swfw_sync_X550a - Acquire SWFW semaphore
4311 * @hw: pointer to hardware structure
4312 * @mask: Mask to specify which semaphore to acquire
4314 * Acquires the SWFW semaphore and get the shared phy token as needed
4316 STATIC s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
4318 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
4319 int retries = FW_PHY_TOKEN_RETRIES;
4320 s32 status = IXGBE_SUCCESS;
4322 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");
4325 status = IXGBE_SUCCESS;
4327 status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
4330 if (!(mask & IXGBE_GSSR_TOKEN_SM))
4331 return IXGBE_SUCCESS;
4333 status = ixgbe_get_phy_token(hw);
4334 if (status == IXGBE_SUCCESS)
4335 return IXGBE_SUCCESS;
4338 ixgbe_release_swfw_sync_X540(hw, hmask);
4339 if (status != IXGBE_ERR_TOKEN_RETRY)
4347 * ixgbe_release_swfw_sync_X550a - Release SWFW semaphore
4348 * @hw: pointer to hardware structure
4349 * @mask: Mask to specify which semaphore to release
4351 * Releases the SWFW semaphore and puts the shared phy token as needed
4353 STATIC void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
4355 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
4357 DEBUGFUNC("ixgbe_release_swfw_sync_X550a");
4359 if (mask & IXGBE_GSSR_TOKEN_SM)
4360 ixgbe_put_phy_token(hw);
4363 ixgbe_release_swfw_sync_X540(hw, hmask);
4367 * ixgbe_read_phy_reg_x550a - Reads specified PHY register
4368 * @hw: pointer to hardware structure
4369 * @reg_addr: 32 bit address of PHY register to read
4370 * @phy_data: Pointer to read data from PHY register
4372 * Reads a value from a specified PHY register using the SWFW lock and PHY
4373 * Token. The PHY Token is needed since the MDIO is shared between to MAC
4376 s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
4377 u32 device_type, u16 *phy_data)
4380 u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
4382 DEBUGFUNC("ixgbe_read_phy_reg_x550a");
4384 if (hw->mac.ops.acquire_swfw_sync(hw, mask))
4385 return IXGBE_ERR_SWFW_SYNC;
4387 status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
4389 hw->mac.ops.release_swfw_sync(hw, mask);
4395 * ixgbe_write_phy_reg_x550a - Writes specified PHY register
4396 * @hw: pointer to hardware structure
4397 * @reg_addr: 32 bit PHY register to write
4398 * @device_type: 5 bit device type
4399 * @phy_data: Data to write to the PHY register
4401 * Writes a value to specified PHY register using the SWFW lock and PHY Token.
4402 * The PHY Token is needed since the MDIO is shared between to MAC instances.
4404 s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
4405 u32 device_type, u16 phy_data)
4408 u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
4410 DEBUGFUNC("ixgbe_write_phy_reg_x550a");
4412 if (hw->mac.ops.acquire_swfw_sync(hw, mask) == IXGBE_SUCCESS) {
4413 status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
4415 hw->mac.ops.release_swfw_sync(hw, mask);
4417 status = IXGBE_ERR_SWFW_SYNC;
4424 * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
4425 * @hw: pointer to hardware structure
4427 * Handle external Base T PHY interrupt. If high temperature
4428 * failure alarm then return error, else if link status change
4429 * then setup internal/external PHY link
4431 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
4432 * failure alarm, else return PHY access status.
4434 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
4439 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
4441 if (status != IXGBE_SUCCESS)
4445 return ixgbe_setup_internal_phy(hw);
4447 return IXGBE_SUCCESS;
4451 * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
4452 * @hw: pointer to hardware structure
4453 * @speed: new link speed
4454 * @autoneg_wait_to_complete: true when waiting for completion is needed
4456 * Setup internal/external PHY link speed based on link speed, then set
4457 * external PHY auto advertised link speed.
4459 * Returns error status for any failure
4461 s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
4462 ixgbe_link_speed speed,
4463 bool autoneg_wait_to_complete)
4466 ixgbe_link_speed force_speed;
4468 DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
4470 /* Setup internal/external PHY link speed to iXFI (10G), unless
4471 * only 1G is auto advertised then setup KX link.
4473 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
4474 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
4476 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
4478 /* If X552 and internal link mode is XFI, then setup XFI internal link.
4480 if (hw->mac.type == ixgbe_mac_X550EM_x &&
4481 !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
4482 status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
4484 if (status != IXGBE_SUCCESS)
4488 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
4492 * ixgbe_check_link_t_X550em - Determine link and speed status
4493 * @hw: pointer to hardware structure
4494 * @speed: pointer to link speed
4495 * @link_up: true when link is up
4496 * @link_up_wait_to_complete: bool used to wait for link up or not
4498 * Check that both the MAC and X557 external PHY have link.
4500 s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
4501 bool *link_up, bool link_up_wait_to_complete)
4504 u16 i, autoneg_status = 0;
4506 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
4507 return IXGBE_ERR_CONFIG;
4509 status = ixgbe_check_mac_link_generic(hw, speed, link_up,
4510 link_up_wait_to_complete);
4512 /* If check link fails or MAC link is not up, then return */
4513 if (status != IXGBE_SUCCESS || !(*link_up))
4516 /* MAC link is up, so check external PHY link.
4517 * X557 PHY. Link status is latching low, and can only be used to detect
4518 * link drop, and not the current status of the link without performing
4519 * back-to-back reads.
4521 for (i = 0; i < 2; i++) {
4522 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
4523 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
4526 if (status != IXGBE_SUCCESS)
4530 /* If external PHY link is not up, then indicate link not up */
4531 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
4534 return IXGBE_SUCCESS;
4538 * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
4539 * @hw: pointer to hardware structure
4541 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
4545 status = ixgbe_reset_phy_generic(hw);
4547 if (status != IXGBE_SUCCESS)
4550 /* Configure Link Status Alarm and Temperature Threshold interrupts */
4551 return ixgbe_enable_lasi_ext_t_x550em(hw);
4555 * ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
4556 * @hw: pointer to hardware structure
4557 * @led_idx: led number to turn on
4559 s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
4563 DEBUGFUNC("ixgbe_led_on_t_X550em");
4565 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
4566 return IXGBE_ERR_PARAM;
4568 /* To turn on the LED, set mode to ON. */
4569 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4570 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
4571 phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
4572 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4573 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
4575 return IXGBE_SUCCESS;
4579 * ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
4580 * @hw: pointer to hardware structure
4581 * @led_idx: led number to turn off
4583 s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
4587 DEBUGFUNC("ixgbe_led_off_t_X550em");
4589 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
4590 return IXGBE_ERR_PARAM;
4592 /* To turn on the LED, set mode to ON. */
4593 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4594 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
4595 phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
4596 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4597 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
4599 return IXGBE_SUCCESS;
4603 * ixgbe_set_fw_drv_ver_x550 - Sends driver version to firmware
4604 * @hw: pointer to the HW structure
4605 * @maj: driver version major number
4606 * @min: driver version minor number
4607 * @build: driver version build number
4608 * @sub: driver version sub build number
4609 * @len: length of driver_ver string
4610 * @driver_ver: driver string
4612 * Sends driver version number to firmware through the manageability
4613 * block. On success return IXGBE_SUCCESS
4614 * else returns IXGBE_ERR_SWFW_SYNC when encountering an error acquiring
4615 * semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
4617 s32 ixgbe_set_fw_drv_ver_x550(struct ixgbe_hw *hw, u8 maj, u8 min,
4618 u8 build, u8 sub, u16 len, const char *driver_ver)
4620 struct ixgbe_hic_drv_info2 fw_cmd;
4621 s32 ret_val = IXGBE_SUCCESS;
4624 DEBUGFUNC("ixgbe_set_fw_drv_ver_x550");
4626 if ((len == 0) || (driver_ver == NULL) ||
4627 (len > sizeof(fw_cmd.driver_string)))
4628 return IXGBE_ERR_INVALID_ARGUMENT;
4630 fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
4631 fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN + len;
4632 fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
4633 fw_cmd.port_num = (u8)hw->bus.func;
4634 fw_cmd.ver_maj = maj;
4635 fw_cmd.ver_min = min;
4636 fw_cmd.ver_build = build;
4637 fw_cmd.ver_sub = sub;
4638 fw_cmd.hdr.checksum = 0;
4639 memcpy(fw_cmd.driver_string, driver_ver, len);
4640 fw_cmd.hdr.checksum = ixgbe_calculate_checksum((u8 *)&fw_cmd,
4641 (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));
4643 for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
4644 ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
4646 IXGBE_HI_COMMAND_TIMEOUT,
4648 if (ret_val != IXGBE_SUCCESS)
4651 if (fw_cmd.hdr.cmd_or_resp.ret_status ==
4652 FW_CEM_RESP_STATUS_SUCCESS)
4653 ret_val = IXGBE_SUCCESS;
4655 ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND;