Home | History | Annotate | Line # | Download | only in ixgbe
ixgbe_x550.c revision 1.7.2.2
      1  1.7.2.2  jdolecek /******************************************************************************
      2  1.7.2.2  jdolecek 
      3  1.7.2.2  jdolecek   Copyright (c) 2001-2017, Intel Corporation
      4  1.7.2.2  jdolecek   All rights reserved.
      5  1.7.2.2  jdolecek 
      6  1.7.2.2  jdolecek   Redistribution and use in source and binary forms, with or without
      7  1.7.2.2  jdolecek   modification, are permitted provided that the following conditions are met:
      8  1.7.2.2  jdolecek 
      9  1.7.2.2  jdolecek    1. Redistributions of source code must retain the above copyright notice,
     10  1.7.2.2  jdolecek       this list of conditions and the following disclaimer.
     11  1.7.2.2  jdolecek 
     12  1.7.2.2  jdolecek    2. Redistributions in binary form must reproduce the above copyright
     13  1.7.2.2  jdolecek       notice, this list of conditions and the following disclaimer in the
     14  1.7.2.2  jdolecek       documentation and/or other materials provided with the distribution.
     15  1.7.2.2  jdolecek 
     16  1.7.2.2  jdolecek    3. Neither the name of the Intel Corporation nor the names of its
     17  1.7.2.2  jdolecek       contributors may be used to endorse or promote products derived from
     18  1.7.2.2  jdolecek       this software without specific prior written permission.
     19  1.7.2.2  jdolecek 
     20  1.7.2.2  jdolecek   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     21  1.7.2.2  jdolecek   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22  1.7.2.2  jdolecek   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23  1.7.2.2  jdolecek   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     24  1.7.2.2  jdolecek   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  1.7.2.2  jdolecek   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  1.7.2.2  jdolecek   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  1.7.2.2  jdolecek   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  1.7.2.2  jdolecek   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  1.7.2.2  jdolecek   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  1.7.2.2  jdolecek   POSSIBILITY OF SUCH DAMAGE.
     31  1.7.2.2  jdolecek 
     32  1.7.2.2  jdolecek ******************************************************************************/
     33  1.7.2.2  jdolecek /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x550.c 320688 2017-07-05 17:27:03Z erj $*/
     34  1.7.2.2  jdolecek 
     35  1.7.2.2  jdolecek #include "ixgbe_x550.h"
     36  1.7.2.2  jdolecek #include "ixgbe_x540.h"
     37  1.7.2.2  jdolecek #include "ixgbe_type.h"
     38  1.7.2.2  jdolecek #include "ixgbe_api.h"
     39  1.7.2.2  jdolecek #include "ixgbe_common.h"
     40  1.7.2.2  jdolecek #include "ixgbe_phy.h"
     41  1.7.2.2  jdolecek #include <dev/mii/mii.h>
     42  1.7.2.2  jdolecek 
     43  1.7.2.2  jdolecek static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed);
     44  1.7.2.2  jdolecek static s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
     45  1.7.2.2  jdolecek static void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
     46  1.7.2.2  jdolecek static s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw);
     47  1.7.2.2  jdolecek 
     48  1.7.2.2  jdolecek /**
     49  1.7.2.2  jdolecek  *  ixgbe_init_ops_X550 - Inits func ptrs and MAC type
     50  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
     51  1.7.2.2  jdolecek  *
     52  1.7.2.2  jdolecek  *  Initialize the function pointers and assign the MAC type for X550.
     53  1.7.2.2  jdolecek  *  Does not touch the hardware.
     54  1.7.2.2  jdolecek  **/
     55  1.7.2.2  jdolecek s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
     56  1.7.2.2  jdolecek {
     57  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
     58  1.7.2.2  jdolecek 	struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
     59  1.7.2.2  jdolecek 	s32 ret_val;
     60  1.7.2.2  jdolecek 
     61  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_init_ops_X550");
     62  1.7.2.2  jdolecek 
     63  1.7.2.2  jdolecek 	ret_val = ixgbe_init_ops_X540(hw);
     64  1.7.2.2  jdolecek 	mac->ops.dmac_config = ixgbe_dmac_config_X550;
     65  1.7.2.2  jdolecek 	mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
     66  1.7.2.2  jdolecek 	mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
     67  1.7.2.2  jdolecek 	mac->ops.setup_eee = NULL;
     68  1.7.2.2  jdolecek 	mac->ops.set_source_address_pruning =
     69  1.7.2.2  jdolecek 			ixgbe_set_source_address_pruning_X550;
     70  1.7.2.2  jdolecek 	mac->ops.set_ethertype_anti_spoofing =
     71  1.7.2.2  jdolecek 			ixgbe_set_ethertype_anti_spoofing_X550;
     72  1.7.2.2  jdolecek 
     73  1.7.2.2  jdolecek 	mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
     74  1.7.2.2  jdolecek 	eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
     75  1.7.2.2  jdolecek 	eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
     76  1.7.2.2  jdolecek 	eeprom->ops.read = ixgbe_read_ee_hostif_X550;
     77  1.7.2.2  jdolecek 	eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
     78  1.7.2.2  jdolecek 	eeprom->ops.write = ixgbe_write_ee_hostif_X550;
     79  1.7.2.2  jdolecek 	eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
     80  1.7.2.2  jdolecek 	eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
     81  1.7.2.2  jdolecek 	eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
     82  1.7.2.2  jdolecek 
     83  1.7.2.2  jdolecek 	mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
     84  1.7.2.2  jdolecek 	mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
     85  1.7.2.2  jdolecek 	mac->ops.mdd_event = ixgbe_mdd_event_X550;
     86  1.7.2.2  jdolecek 	mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
     87  1.7.2.2  jdolecek 	mac->ops.disable_rx = ixgbe_disable_rx_x550;
     88  1.7.2.2  jdolecek 	/* Manageability interface */
     89  1.7.2.2  jdolecek 	mac->ops.set_fw_drv_ver = ixgbe_set_fw_drv_ver_x550;
     90  1.7.2.2  jdolecek 	switch (hw->device_id) {
     91  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_1G_T:
     92  1.7.2.2  jdolecek 		hw->mac.ops.led_on = NULL;
     93  1.7.2.2  jdolecek 		hw->mac.ops.led_off = NULL;
     94  1.7.2.2  jdolecek 		break;
     95  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_10G_T:
     96  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_10G_T:
     97  1.7.2.2  jdolecek 		hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
     98  1.7.2.2  jdolecek 		hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
     99  1.7.2.2  jdolecek 		break;
    100  1.7.2.2  jdolecek 	default:
    101  1.7.2.2  jdolecek 		break;
    102  1.7.2.2  jdolecek 	}
    103  1.7.2.2  jdolecek 	return ret_val;
    104  1.7.2.2  jdolecek }
    105  1.7.2.2  jdolecek 
    106  1.7.2.2  jdolecek /**
    107  1.7.2.2  jdolecek  * ixgbe_read_cs4227 - Read CS4227 register
    108  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    109  1.7.2.2  jdolecek  * @reg: register number to write
    110  1.7.2.2  jdolecek  * @value: pointer to receive value read
    111  1.7.2.2  jdolecek  *
    112  1.7.2.2  jdolecek  * Returns status code
    113  1.7.2.2  jdolecek  **/
    114  1.7.2.2  jdolecek static s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
    115  1.7.2.2  jdolecek {
    116  1.7.2.2  jdolecek 	return hw->link.ops.read_link_unlocked(hw, hw->link.addr, reg, value);
    117  1.7.2.2  jdolecek }
    118  1.7.2.2  jdolecek 
    119  1.7.2.2  jdolecek /**
    120  1.7.2.2  jdolecek  * ixgbe_write_cs4227 - Write CS4227 register
    121  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    122  1.7.2.2  jdolecek  * @reg: register number to write
    123  1.7.2.2  jdolecek  * @value: value to write to register
    124  1.7.2.2  jdolecek  *
    125  1.7.2.2  jdolecek  * Returns status code
    126  1.7.2.2  jdolecek  **/
    127  1.7.2.2  jdolecek static s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
    128  1.7.2.2  jdolecek {
    129  1.7.2.2  jdolecek 	return hw->link.ops.write_link_unlocked(hw, hw->link.addr, reg, value);
    130  1.7.2.2  jdolecek }
    131  1.7.2.2  jdolecek 
    132  1.7.2.2  jdolecek /**
    133  1.7.2.2  jdolecek  * ixgbe_read_pe - Read register from port expander
    134  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    135  1.7.2.2  jdolecek  * @reg: register number to read
    136  1.7.2.2  jdolecek  * @value: pointer to receive read value
    137  1.7.2.2  jdolecek  *
    138  1.7.2.2  jdolecek  * Returns status code
    139  1.7.2.2  jdolecek  **/
    140  1.7.2.2  jdolecek static s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
    141  1.7.2.2  jdolecek {
    142  1.7.2.2  jdolecek 	s32 status;
    143  1.7.2.2  jdolecek 
    144  1.7.2.2  jdolecek 	status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
    145  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    146  1.7.2.2  jdolecek 		ERROR_REPORT2(IXGBE_ERROR_CAUTION,
    147  1.7.2.2  jdolecek 			      "port expander access failed with %d\n", status);
    148  1.7.2.2  jdolecek 	return status;
    149  1.7.2.2  jdolecek }
    150  1.7.2.2  jdolecek 
    151  1.7.2.2  jdolecek /**
    152  1.7.2.2  jdolecek  * ixgbe_write_pe - Write register to port expander
    153  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    154  1.7.2.2  jdolecek  * @reg: register number to write
    155  1.7.2.2  jdolecek  * @value: value to write
    156  1.7.2.2  jdolecek  *
    157  1.7.2.2  jdolecek  * Returns status code
    158  1.7.2.2  jdolecek  **/
    159  1.7.2.2  jdolecek static s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
    160  1.7.2.2  jdolecek {
    161  1.7.2.2  jdolecek 	s32 status;
    162  1.7.2.2  jdolecek 
    163  1.7.2.2  jdolecek 	status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
    164  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    165  1.7.2.2  jdolecek 		ERROR_REPORT2(IXGBE_ERROR_CAUTION,
    166  1.7.2.2  jdolecek 			      "port expander access failed with %d\n", status);
    167  1.7.2.2  jdolecek 	return status;
    168  1.7.2.2  jdolecek }
    169  1.7.2.2  jdolecek 
    170  1.7.2.2  jdolecek /**
    171  1.7.2.2  jdolecek  * ixgbe_reset_cs4227 - Reset CS4227 using port expander
    172  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    173  1.7.2.2  jdolecek  *
    174  1.7.2.2  jdolecek  * This function assumes that the caller has acquired the proper semaphore.
    175  1.7.2.2  jdolecek  * Returns error code
    176  1.7.2.2  jdolecek  **/
    177  1.7.2.2  jdolecek static s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
    178  1.7.2.2  jdolecek {
    179  1.7.2.2  jdolecek 	s32 status;
    180  1.7.2.2  jdolecek 	u32 retry;
    181  1.7.2.2  jdolecek 	u16 value;
    182  1.7.2.2  jdolecek 	u8 reg;
    183  1.7.2.2  jdolecek 
    184  1.7.2.2  jdolecek 	/* Trigger hard reset. */
    185  1.7.2.2  jdolecek 	status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
    186  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    187  1.7.2.2  jdolecek 		return status;
    188  1.7.2.2  jdolecek 	reg |= IXGBE_PE_BIT1;
    189  1.7.2.2  jdolecek 	status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
    190  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    191  1.7.2.2  jdolecek 		return status;
    192  1.7.2.2  jdolecek 
    193  1.7.2.2  jdolecek 	status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, &reg);
    194  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    195  1.7.2.2  jdolecek 		return status;
    196  1.7.2.2  jdolecek 	reg &= ~IXGBE_PE_BIT1;
    197  1.7.2.2  jdolecek 	status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
    198  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    199  1.7.2.2  jdolecek 		return status;
    200  1.7.2.2  jdolecek 
    201  1.7.2.2  jdolecek 	status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
    202  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    203  1.7.2.2  jdolecek 		return status;
    204  1.7.2.2  jdolecek 	reg &= ~IXGBE_PE_BIT1;
    205  1.7.2.2  jdolecek 	status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
    206  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    207  1.7.2.2  jdolecek 		return status;
    208  1.7.2.2  jdolecek 
    209  1.7.2.2  jdolecek 	usec_delay(IXGBE_CS4227_RESET_HOLD);
    210  1.7.2.2  jdolecek 
    211  1.7.2.2  jdolecek 	status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
    212  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    213  1.7.2.2  jdolecek 		return status;
    214  1.7.2.2  jdolecek 	reg |= IXGBE_PE_BIT1;
    215  1.7.2.2  jdolecek 	status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
    216  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
    217  1.7.2.2  jdolecek 		return status;
    218  1.7.2.2  jdolecek 
    219  1.7.2.2  jdolecek 	/* Wait for the reset to complete. */
    220  1.7.2.2  jdolecek 	msec_delay(IXGBE_CS4227_RESET_DELAY);
    221  1.7.2.2  jdolecek 	for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
    222  1.7.2.2  jdolecek 		status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
    223  1.7.2.2  jdolecek 					   &value);
    224  1.7.2.2  jdolecek 		if (status == IXGBE_SUCCESS &&
    225  1.7.2.2  jdolecek 		    value == IXGBE_CS4227_EEPROM_LOAD_OK)
    226  1.7.2.2  jdolecek 			break;
    227  1.7.2.2  jdolecek 		msec_delay(IXGBE_CS4227_CHECK_DELAY);
    228  1.7.2.2  jdolecek 	}
    229  1.7.2.2  jdolecek 	if (retry == IXGBE_CS4227_RETRIES) {
    230  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
    231  1.7.2.2  jdolecek 			"CS4227 reset did not complete.");
    232  1.7.2.2  jdolecek 		return IXGBE_ERR_PHY;
    233  1.7.2.2  jdolecek 	}
    234  1.7.2.2  jdolecek 
    235  1.7.2.2  jdolecek 	status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
    236  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS ||
    237  1.7.2.2  jdolecek 	    !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
    238  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
    239  1.7.2.2  jdolecek 			"CS4227 EEPROM did not load successfully.");
    240  1.7.2.2  jdolecek 		return IXGBE_ERR_PHY;
    241  1.7.2.2  jdolecek 	}
    242  1.7.2.2  jdolecek 
    243  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
    244  1.7.2.2  jdolecek }
    245  1.7.2.2  jdolecek 
    246  1.7.2.2  jdolecek /**
    247  1.7.2.2  jdolecek  * ixgbe_check_cs4227 - Check CS4227 and reset as needed
    248  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    249  1.7.2.2  jdolecek  **/
    250  1.7.2.2  jdolecek static void ixgbe_check_cs4227(struct ixgbe_hw *hw)
    251  1.7.2.2  jdolecek {
    252  1.7.2.2  jdolecek 	s32 status = IXGBE_SUCCESS;
    253  1.7.2.2  jdolecek 	u32 swfw_mask = hw->phy.phy_semaphore_mask;
    254  1.7.2.2  jdolecek 	u16 value = 0;
    255  1.7.2.2  jdolecek 	u8 retry;
    256  1.7.2.2  jdolecek 
    257  1.7.2.2  jdolecek 	for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
    258  1.7.2.2  jdolecek 		status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
    259  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS) {
    260  1.7.2.2  jdolecek 			ERROR_REPORT2(IXGBE_ERROR_CAUTION,
    261  1.7.2.2  jdolecek 				"semaphore failed with %d", status);
    262  1.7.2.2  jdolecek 			msec_delay(IXGBE_CS4227_CHECK_DELAY);
    263  1.7.2.2  jdolecek 			continue;
    264  1.7.2.2  jdolecek 		}
    265  1.7.2.2  jdolecek 
    266  1.7.2.2  jdolecek 		/* Get status of reset flow. */
    267  1.7.2.2  jdolecek 		status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
    268  1.7.2.2  jdolecek 
    269  1.7.2.2  jdolecek 		if (status == IXGBE_SUCCESS &&
    270  1.7.2.2  jdolecek 		    value == IXGBE_CS4227_RESET_COMPLETE)
    271  1.7.2.2  jdolecek 			goto out;
    272  1.7.2.2  jdolecek 
    273  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS ||
    274  1.7.2.2  jdolecek 		    value != IXGBE_CS4227_RESET_PENDING)
    275  1.7.2.2  jdolecek 			break;
    276  1.7.2.2  jdolecek 
    277  1.7.2.2  jdolecek 		/* Reset is pending. Wait and check again. */
    278  1.7.2.2  jdolecek 		hw->mac.ops.release_swfw_sync(hw, swfw_mask);
    279  1.7.2.2  jdolecek 		msec_delay(IXGBE_CS4227_CHECK_DELAY);
    280  1.7.2.2  jdolecek 	}
    281  1.7.2.2  jdolecek 
    282  1.7.2.2  jdolecek 	/* If still pending, assume other instance failed. */
    283  1.7.2.2  jdolecek 	if (retry == IXGBE_CS4227_RETRIES) {
    284  1.7.2.2  jdolecek 		status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
    285  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS) {
    286  1.7.2.2  jdolecek 			ERROR_REPORT2(IXGBE_ERROR_CAUTION,
    287  1.7.2.2  jdolecek 				      "semaphore failed with %d", status);
    288  1.7.2.2  jdolecek 			return;
    289  1.7.2.2  jdolecek 		}
    290  1.7.2.2  jdolecek 	}
    291  1.7.2.2  jdolecek 
    292  1.7.2.2  jdolecek 	/* Reset the CS4227. */
    293  1.7.2.2  jdolecek 	status = ixgbe_reset_cs4227(hw);
    294  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS) {
    295  1.7.2.2  jdolecek 		ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
    296  1.7.2.2  jdolecek 			"CS4227 reset failed: %d", status);
    297  1.7.2.2  jdolecek 		goto out;
    298  1.7.2.2  jdolecek 	}
    299  1.7.2.2  jdolecek 
    300  1.7.2.2  jdolecek 	/* Reset takes so long, temporarily release semaphore in case the
    301  1.7.2.2  jdolecek 	 * other driver instance is waiting for the reset indication.
    302  1.7.2.2  jdolecek 	 */
    303  1.7.2.2  jdolecek 	ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
    304  1.7.2.2  jdolecek 			   IXGBE_CS4227_RESET_PENDING);
    305  1.7.2.2  jdolecek 	hw->mac.ops.release_swfw_sync(hw, swfw_mask);
    306  1.7.2.2  jdolecek 	msec_delay(10);
    307  1.7.2.2  jdolecek 	status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
    308  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS) {
    309  1.7.2.2  jdolecek 		ERROR_REPORT2(IXGBE_ERROR_CAUTION,
    310  1.7.2.2  jdolecek 			"semaphore failed with %d", status);
    311  1.7.2.2  jdolecek 		return;
    312  1.7.2.2  jdolecek 	}
    313  1.7.2.2  jdolecek 
    314  1.7.2.2  jdolecek 	/* Record completion for next time. */
    315  1.7.2.2  jdolecek 	status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
    316  1.7.2.2  jdolecek 		IXGBE_CS4227_RESET_COMPLETE);
    317  1.7.2.2  jdolecek 
    318  1.7.2.2  jdolecek out:
    319  1.7.2.2  jdolecek 	hw->mac.ops.release_swfw_sync(hw, swfw_mask);
    320  1.7.2.2  jdolecek 	msec_delay(hw->eeprom.semaphore_delay);
    321  1.7.2.2  jdolecek }
    322  1.7.2.2  jdolecek 
    323  1.7.2.2  jdolecek /**
    324  1.7.2.2  jdolecek  * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
    325  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    326  1.7.2.2  jdolecek  **/
    327  1.7.2.2  jdolecek static void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
    328  1.7.2.2  jdolecek {
    329  1.7.2.2  jdolecek 	u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
    330  1.7.2.2  jdolecek 
    331  1.7.2.2  jdolecek 	if (hw->bus.lan_id) {
    332  1.7.2.2  jdolecek 		esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
    333  1.7.2.2  jdolecek 		esdp |= IXGBE_ESDP_SDP1_DIR;
    334  1.7.2.2  jdolecek 	}
    335  1.7.2.2  jdolecek 	esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
    336  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
    337  1.7.2.2  jdolecek 	IXGBE_WRITE_FLUSH(hw);
    338  1.7.2.2  jdolecek }
    339  1.7.2.2  jdolecek 
    340  1.7.2.2  jdolecek /**
    341  1.7.2.2  jdolecek  * ixgbe_read_phy_reg_mdi_22 - Read from a clause 22 PHY register without lock
    342  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    343  1.7.2.2  jdolecek  * @reg_addr: 32 bit address of PHY register to read
    344  1.7.2.2  jdolecek  * @dev_type: always unused
    345  1.7.2.2  jdolecek  * @phy_data: Pointer to read data from PHY register
    346  1.7.2.2  jdolecek  */
    347  1.7.2.2  jdolecek static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
    348  1.7.2.2  jdolecek 				     u32 dev_type, u16 *phy_data)
    349  1.7.2.2  jdolecek {
    350  1.7.2.2  jdolecek 	u32 i, data, command;
    351  1.7.2.2  jdolecek 	UNREFERENCED_1PARAMETER(dev_type);
    352  1.7.2.2  jdolecek 
    353  1.7.2.2  jdolecek 	/* Setup and write the read command */
    354  1.7.2.2  jdolecek 	command = (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
    355  1.7.2.2  jdolecek 		  (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
    356  1.7.2.2  jdolecek 		  IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_READ_AUTOINC |
    357  1.7.2.2  jdolecek 		  IXGBE_MSCA_MDI_COMMAND;
    358  1.7.2.2  jdolecek 
    359  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
    360  1.7.2.2  jdolecek 
    361  1.7.2.2  jdolecek 	/* Check every 10 usec to see if the access completed.
    362  1.7.2.2  jdolecek 	 * The MDI Command bit will clear when the operation is
    363  1.7.2.2  jdolecek 	 * complete
    364  1.7.2.2  jdolecek 	 */
    365  1.7.2.2  jdolecek 	for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
    366  1.7.2.2  jdolecek 		usec_delay(10);
    367  1.7.2.2  jdolecek 
    368  1.7.2.2  jdolecek 		command = IXGBE_READ_REG(hw, IXGBE_MSCA);
    369  1.7.2.2  jdolecek 		if (!(command & IXGBE_MSCA_MDI_COMMAND))
    370  1.7.2.2  jdolecek 			break;
    371  1.7.2.2  jdolecek 	}
    372  1.7.2.2  jdolecek 
    373  1.7.2.2  jdolecek 	if (command & IXGBE_MSCA_MDI_COMMAND) {
    374  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_POLLING,
    375  1.7.2.2  jdolecek 			      "PHY read command did not complete.\n");
    376  1.7.2.2  jdolecek 		return IXGBE_ERR_PHY;
    377  1.7.2.2  jdolecek 	}
    378  1.7.2.2  jdolecek 
    379  1.7.2.2  jdolecek 	/* Read operation is complete.  Get the data from MSRWD */
    380  1.7.2.2  jdolecek 	data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
    381  1.7.2.2  jdolecek 	data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
    382  1.7.2.2  jdolecek 	*phy_data = (u16)data;
    383  1.7.2.2  jdolecek 
    384  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
    385  1.7.2.2  jdolecek }
    386  1.7.2.2  jdolecek 
    387  1.7.2.2  jdolecek /**
    388  1.7.2.2  jdolecek  * ixgbe_write_phy_reg_mdi_22 - Write to a clause 22 PHY register without lock
    389  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    390  1.7.2.2  jdolecek  * @reg_addr: 32 bit PHY register to write
    391  1.7.2.2  jdolecek  * @dev_type: always unused
    392  1.7.2.2  jdolecek  * @phy_data: Data to write to the PHY register
    393  1.7.2.2  jdolecek  */
    394  1.7.2.2  jdolecek static s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
    395  1.7.2.2  jdolecek 				      u32 dev_type, u16 phy_data)
    396  1.7.2.2  jdolecek {
    397  1.7.2.2  jdolecek 	u32 i, command;
    398  1.7.2.2  jdolecek 	UNREFERENCED_1PARAMETER(dev_type);
    399  1.7.2.2  jdolecek 
    400  1.7.2.2  jdolecek 	/* Put the data in the MDI single read and write data register*/
    401  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
    402  1.7.2.2  jdolecek 
    403  1.7.2.2  jdolecek 	/* Setup and write the write command */
    404  1.7.2.2  jdolecek 	command = (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
    405  1.7.2.2  jdolecek 		  (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
    406  1.7.2.2  jdolecek 		  IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_WRITE |
    407  1.7.2.2  jdolecek 		  IXGBE_MSCA_MDI_COMMAND;
    408  1.7.2.2  jdolecek 
    409  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
    410  1.7.2.2  jdolecek 
    411  1.7.2.2  jdolecek 	/* Check every 10 usec to see if the access completed.
    412  1.7.2.2  jdolecek 	 * The MDI Command bit will clear when the operation is
    413  1.7.2.2  jdolecek 	 * complete
    414  1.7.2.2  jdolecek 	 */
    415  1.7.2.2  jdolecek 	for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
    416  1.7.2.2  jdolecek 		usec_delay(10);
    417  1.7.2.2  jdolecek 
    418  1.7.2.2  jdolecek 		command = IXGBE_READ_REG(hw, IXGBE_MSCA);
    419  1.7.2.2  jdolecek 		if (!(command & IXGBE_MSCA_MDI_COMMAND))
    420  1.7.2.2  jdolecek 			break;
    421  1.7.2.2  jdolecek 	}
    422  1.7.2.2  jdolecek 
    423  1.7.2.2  jdolecek 	if (command & IXGBE_MSCA_MDI_COMMAND) {
    424  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_POLLING,
    425  1.7.2.2  jdolecek 			      "PHY write cmd didn't complete\n");
    426  1.7.2.2  jdolecek 		return IXGBE_ERR_PHY;
    427  1.7.2.2  jdolecek 	}
    428  1.7.2.2  jdolecek 
    429  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
    430  1.7.2.2  jdolecek }
    431  1.7.2.2  jdolecek 
    432  1.7.2.2  jdolecek /**
    433  1.7.2.2  jdolecek  * ixgbe_identify_phy_x550em - Get PHY type based on device id
    434  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    435  1.7.2.2  jdolecek  *
    436  1.7.2.2  jdolecek  * Returns error code
    437  1.7.2.2  jdolecek  */
    438  1.7.2.2  jdolecek static s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
    439  1.7.2.2  jdolecek {
    440  1.7.2.2  jdolecek 	hw->mac.ops.set_lan_id(hw);
    441  1.7.2.2  jdolecek 
    442  1.7.2.2  jdolecek 	ixgbe_read_mng_if_sel_x550em(hw);
    443  1.7.2.2  jdolecek 
    444  1.7.2.2  jdolecek 	switch (hw->device_id) {
    445  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SFP:
    446  1.7.2.2  jdolecek 		return ixgbe_identify_module_generic(hw);
    447  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_SFP:
    448  1.7.2.2  jdolecek 		/* set up for CS4227 usage */
    449  1.7.2.2  jdolecek 		ixgbe_setup_mux_ctl(hw);
    450  1.7.2.2  jdolecek 		ixgbe_check_cs4227(hw);
    451  1.7.2.2  jdolecek 		/* Fallthrough */
    452  1.7.2.2  jdolecek 
    453  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SFP_N:
    454  1.7.2.2  jdolecek 		return ixgbe_identify_module_generic(hw);
    455  1.7.2.2  jdolecek 		break;
    456  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_KX4:
    457  1.7.2.2  jdolecek 		hw->phy.type = ixgbe_phy_x550em_kx4;
    458  1.7.2.2  jdolecek 		break;
    459  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_XFI:
    460  1.7.2.2  jdolecek 		hw->phy.type = ixgbe_phy_x550em_xfi;
    461  1.7.2.2  jdolecek 		break;
    462  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_KR:
    463  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_KR:
    464  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_KR_L:
    465  1.7.2.2  jdolecek 		hw->phy.type = ixgbe_phy_x550em_kr;
    466  1.7.2.2  jdolecek 		break;
    467  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_10G_T:
    468  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_10G_T:
    469  1.7.2.2  jdolecek 		return ixgbe_identify_phy_generic(hw);
    470  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_1G_T:
    471  1.7.2.2  jdolecek 		hw->phy.type = ixgbe_phy_ext_1g_t;
    472  1.7.2.2  jdolecek 		hw->phy.ops.read_reg = NULL;
    473  1.7.2.2  jdolecek 		hw->phy.ops.write_reg = NULL;
    474  1.7.2.2  jdolecek 		break;
    475  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T:
    476  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T_L:
    477  1.7.2.2  jdolecek 		hw->phy.type = ixgbe_phy_fw;
    478  1.7.2.2  jdolecek 		hw->phy.ops.read_reg = NULL;
    479  1.7.2.2  jdolecek 		hw->phy.ops.write_reg = NULL;
    480  1.7.2.2  jdolecek 		if (hw->bus.lan_id)
    481  1.7.2.2  jdolecek 			hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
    482  1.7.2.2  jdolecek 		else
    483  1.7.2.2  jdolecek 			hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
    484  1.7.2.2  jdolecek 		break;
    485  1.7.2.2  jdolecek 	default:
    486  1.7.2.2  jdolecek 		break;
    487  1.7.2.2  jdolecek 	}
    488  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
    489  1.7.2.2  jdolecek }
    490  1.7.2.2  jdolecek 
    491  1.7.2.2  jdolecek /**
    492  1.7.2.2  jdolecek  * ixgbe_fw_phy_activity - Perform an activity on a PHY
    493  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    494  1.7.2.2  jdolecek  * @activity: activity to perform
    495  1.7.2.2  jdolecek  * @data: Pointer to 4 32-bit words of data
    496  1.7.2.2  jdolecek  */
    497  1.7.2.2  jdolecek s32 ixgbe_fw_phy_activity(struct ixgbe_hw *hw, u16 activity,
    498  1.7.2.2  jdolecek 			  u32 (*data)[FW_PHY_ACT_DATA_COUNT])
    499  1.7.2.2  jdolecek {
    500  1.7.2.2  jdolecek 	union {
    501  1.7.2.2  jdolecek 		struct ixgbe_hic_phy_activity_req cmd;
    502  1.7.2.2  jdolecek 		struct ixgbe_hic_phy_activity_resp rsp;
    503  1.7.2.2  jdolecek 	} hic;
    504  1.7.2.2  jdolecek 	u16 retries = FW_PHY_ACT_RETRIES;
    505  1.7.2.2  jdolecek 	s32 rc;
    506  1.7.2.2  jdolecek 	u16 i;
    507  1.7.2.2  jdolecek 
    508  1.7.2.2  jdolecek 	do {
    509  1.7.2.2  jdolecek 		memset(&hic, 0, sizeof(hic));
    510  1.7.2.2  jdolecek 		hic.cmd.hdr.cmd = FW_PHY_ACT_REQ_CMD;
    511  1.7.2.2  jdolecek 		hic.cmd.hdr.buf_len = FW_PHY_ACT_REQ_LEN;
    512  1.7.2.2  jdolecek 		hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
    513  1.7.2.2  jdolecek 		hic.cmd.port_number = hw->bus.lan_id;
    514  1.7.2.2  jdolecek 		hic.cmd.activity_id = IXGBE_CPU_TO_LE16(activity);
    515  1.7.2.2  jdolecek 		for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
    516  1.7.2.2  jdolecek 			hic.cmd.data[i] = IXGBE_CPU_TO_BE32((*data)[i]);
    517  1.7.2.2  jdolecek 
    518  1.7.2.2  jdolecek 		rc = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
    519  1.7.2.2  jdolecek 						  sizeof(hic.cmd),
    520  1.7.2.2  jdolecek 						  IXGBE_HI_COMMAND_TIMEOUT,
    521  1.7.2.2  jdolecek 						  TRUE);
    522  1.7.2.2  jdolecek 		if (rc != IXGBE_SUCCESS)
    523  1.7.2.2  jdolecek 			return rc;
    524  1.7.2.2  jdolecek 		if (hic.rsp.hdr.cmd_or_resp.ret_status ==
    525  1.7.2.2  jdolecek 		    FW_CEM_RESP_STATUS_SUCCESS) {
    526  1.7.2.2  jdolecek 			for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
    527  1.7.2.2  jdolecek 				(*data)[i] = IXGBE_BE32_TO_CPU(hic.rsp.data[i]);
    528  1.7.2.2  jdolecek 			return IXGBE_SUCCESS;
    529  1.7.2.2  jdolecek 		}
    530  1.7.2.2  jdolecek 		usec_delay(20);
    531  1.7.2.2  jdolecek 		--retries;
    532  1.7.2.2  jdolecek 	} while (retries > 0);
    533  1.7.2.2  jdolecek 
    534  1.7.2.2  jdolecek 	return IXGBE_ERR_HOST_INTERFACE_COMMAND;
    535  1.7.2.2  jdolecek }
    536  1.7.2.2  jdolecek 
    537  1.7.2.2  jdolecek static const struct {
    538  1.7.2.2  jdolecek 	u16 fw_speed;
    539  1.7.2.2  jdolecek 	ixgbe_link_speed phy_speed;
    540  1.7.2.2  jdolecek } ixgbe_fw_map[] = {
    541  1.7.2.2  jdolecek 	{ FW_PHY_ACT_LINK_SPEED_10, IXGBE_LINK_SPEED_10_FULL },
    542  1.7.2.2  jdolecek 	{ FW_PHY_ACT_LINK_SPEED_100, IXGBE_LINK_SPEED_100_FULL },
    543  1.7.2.2  jdolecek 	{ FW_PHY_ACT_LINK_SPEED_1G, IXGBE_LINK_SPEED_1GB_FULL },
    544  1.7.2.2  jdolecek 	{ FW_PHY_ACT_LINK_SPEED_2_5G, IXGBE_LINK_SPEED_2_5GB_FULL },
    545  1.7.2.2  jdolecek 	{ FW_PHY_ACT_LINK_SPEED_5G, IXGBE_LINK_SPEED_5GB_FULL },
    546  1.7.2.2  jdolecek 	{ FW_PHY_ACT_LINK_SPEED_10G, IXGBE_LINK_SPEED_10GB_FULL },
    547  1.7.2.2  jdolecek };
    548  1.7.2.2  jdolecek 
    549  1.7.2.2  jdolecek /**
    550  1.7.2.2  jdolecek  * ixgbe_get_phy_id_fw - Get the phy ID via firmware command
    551  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    552  1.7.2.2  jdolecek  *
    553  1.7.2.2  jdolecek  * Returns error code
    554  1.7.2.2  jdolecek  */
    555  1.7.2.2  jdolecek static s32 ixgbe_get_phy_id_fw(struct ixgbe_hw *hw)
    556  1.7.2.2  jdolecek {
    557  1.7.2.2  jdolecek 	u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
    558  1.7.2.2  jdolecek 	u16 phy_speeds;
    559  1.7.2.2  jdolecek 	u16 phy_id_lo;
    560  1.7.2.2  jdolecek 	s32 rc;
    561  1.7.2.2  jdolecek 	u16 i;
    562  1.7.2.2  jdolecek 
    563  1.7.2.2  jdolecek 	rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_PHY_INFO, &info);
    564  1.7.2.2  jdolecek 	if (rc)
    565  1.7.2.2  jdolecek 		return rc;
    566  1.7.2.2  jdolecek 
    567  1.7.2.2  jdolecek 	hw->phy.speeds_supported = 0;
    568  1.7.2.2  jdolecek 	phy_speeds = info[0] & FW_PHY_INFO_SPEED_MASK;
    569  1.7.2.2  jdolecek 	for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
    570  1.7.2.2  jdolecek 		if (phy_speeds & ixgbe_fw_map[i].fw_speed)
    571  1.7.2.2  jdolecek 			hw->phy.speeds_supported |= ixgbe_fw_map[i].phy_speed;
    572  1.7.2.2  jdolecek 	}
    573  1.7.2.2  jdolecek 	if (!hw->phy.autoneg_advertised)
    574  1.7.2.2  jdolecek 		hw->phy.autoneg_advertised = hw->phy.speeds_supported;
    575  1.7.2.2  jdolecek 
    576  1.7.2.2  jdolecek 	hw->phy.id = info[0] & FW_PHY_INFO_ID_HI_MASK;
    577  1.7.2.2  jdolecek 	phy_id_lo = info[1] & FW_PHY_INFO_ID_LO_MASK;
    578  1.7.2.2  jdolecek 	hw->phy.id |= phy_id_lo & IXGBE_PHY_REVISION_MASK;
    579  1.7.2.2  jdolecek 	hw->phy.revision = phy_id_lo & ~IXGBE_PHY_REVISION_MASK;
    580  1.7.2.2  jdolecek 	if (!hw->phy.id || hw->phy.id == IXGBE_PHY_REVISION_MASK)
    581  1.7.2.2  jdolecek 		return IXGBE_ERR_PHY_ADDR_INVALID;
    582  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
    583  1.7.2.2  jdolecek }
    584  1.7.2.2  jdolecek 
    585  1.7.2.2  jdolecek /**
    586  1.7.2.2  jdolecek  * ixgbe_identify_phy_fw - Get PHY type based on firmware command
    587  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    588  1.7.2.2  jdolecek  *
    589  1.7.2.2  jdolecek  * Returns error code
    590  1.7.2.2  jdolecek  */
    591  1.7.2.2  jdolecek static s32 ixgbe_identify_phy_fw(struct ixgbe_hw *hw)
    592  1.7.2.2  jdolecek {
    593  1.7.2.2  jdolecek 	if (hw->bus.lan_id)
    594  1.7.2.2  jdolecek 		hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
    595  1.7.2.2  jdolecek 	else
    596  1.7.2.2  jdolecek 		hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
    597  1.7.2.2  jdolecek 
    598  1.7.2.2  jdolecek 	hw->phy.type = ixgbe_phy_fw;
    599  1.7.2.2  jdolecek 	hw->phy.ops.read_reg = NULL;
    600  1.7.2.2  jdolecek 	hw->phy.ops.write_reg = NULL;
    601  1.7.2.2  jdolecek 	return ixgbe_get_phy_id_fw(hw);
    602  1.7.2.2  jdolecek }
    603  1.7.2.2  jdolecek 
    604  1.7.2.2  jdolecek /**
    605  1.7.2.2  jdolecek  * ixgbe_shutdown_fw_phy - Shutdown a firmware-controlled PHY
    606  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    607  1.7.2.2  jdolecek  *
    608  1.7.2.2  jdolecek  * Returns error code
    609  1.7.2.2  jdolecek  */
    610  1.7.2.2  jdolecek s32 ixgbe_shutdown_fw_phy(struct ixgbe_hw *hw)
    611  1.7.2.2  jdolecek {
    612  1.7.2.2  jdolecek 	u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
    613  1.7.2.2  jdolecek 
    614  1.7.2.2  jdolecek 	setup[0] = FW_PHY_ACT_FORCE_LINK_DOWN_OFF;
    615  1.7.2.2  jdolecek 	return ixgbe_fw_phy_activity(hw, FW_PHY_ACT_FORCE_LINK_DOWN, &setup);
    616  1.7.2.2  jdolecek }
    617  1.7.2.2  jdolecek 
    618  1.7.2.2  jdolecek static s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
    619  1.7.2.2  jdolecek 				     u32 device_type, u16 *phy_data)
    620  1.7.2.2  jdolecek {
    621  1.7.2.2  jdolecek 	UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
    622  1.7.2.2  jdolecek 	return IXGBE_NOT_IMPLEMENTED;
    623  1.7.2.2  jdolecek }
    624  1.7.2.2  jdolecek 
    625  1.7.2.2  jdolecek static s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
    626  1.7.2.2  jdolecek 				      u32 device_type, u16 phy_data)
    627  1.7.2.2  jdolecek {
    628  1.7.2.2  jdolecek 	UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
    629  1.7.2.2  jdolecek 	return IXGBE_NOT_IMPLEMENTED;
    630  1.7.2.2  jdolecek }
    631  1.7.2.2  jdolecek 
    632  1.7.2.2  jdolecek /**
    633  1.7.2.2  jdolecek  * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
    634  1.7.2.2  jdolecek  * @hw: pointer to the hardware structure
    635  1.7.2.2  jdolecek  * @addr: I2C bus address to read from
    636  1.7.2.2  jdolecek  * @reg: I2C device register to read from
    637  1.7.2.2  jdolecek  * @val: pointer to location to receive read value
    638  1.7.2.2  jdolecek  *
    639  1.7.2.2  jdolecek  * Returns an error code on error.
    640  1.7.2.2  jdolecek  **/
    641  1.7.2.2  jdolecek static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
    642  1.7.2.2  jdolecek 					   u16 reg, u16 *val)
    643  1.7.2.2  jdolecek {
    644  1.7.2.2  jdolecek 	return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, TRUE);
    645  1.7.2.2  jdolecek }
    646  1.7.2.2  jdolecek 
    647  1.7.2.2  jdolecek /**
    648  1.7.2.2  jdolecek  * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
    649  1.7.2.2  jdolecek  * @hw: pointer to the hardware structure
    650  1.7.2.2  jdolecek  * @addr: I2C bus address to read from
    651  1.7.2.2  jdolecek  * @reg: I2C device register to read from
    652  1.7.2.2  jdolecek  * @val: pointer to location to receive read value
    653  1.7.2.2  jdolecek  *
    654  1.7.2.2  jdolecek  * Returns an error code on error.
    655  1.7.2.2  jdolecek  **/
    656  1.7.2.2  jdolecek static s32
    657  1.7.2.2  jdolecek ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
    658  1.7.2.2  jdolecek 					 u16 reg, u16 *val)
    659  1.7.2.2  jdolecek {
    660  1.7.2.2  jdolecek 	return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, FALSE);
    661  1.7.2.2  jdolecek }
    662  1.7.2.2  jdolecek 
    663  1.7.2.2  jdolecek /**
    664  1.7.2.2  jdolecek  * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
    665  1.7.2.2  jdolecek  * @hw: pointer to the hardware structure
    666  1.7.2.2  jdolecek  * @addr: I2C bus address to write to
    667  1.7.2.2  jdolecek  * @reg: I2C device register to write to
    668  1.7.2.2  jdolecek  * @val: value to write
    669  1.7.2.2  jdolecek  *
    670  1.7.2.2  jdolecek  * Returns an error code on error.
    671  1.7.2.2  jdolecek  **/
    672  1.7.2.2  jdolecek static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
    673  1.7.2.2  jdolecek 					    u8 addr, u16 reg, u16 val)
    674  1.7.2.2  jdolecek {
    675  1.7.2.2  jdolecek 	return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, TRUE);
    676  1.7.2.2  jdolecek }
    677  1.7.2.2  jdolecek 
    678  1.7.2.2  jdolecek /**
    679  1.7.2.2  jdolecek  * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
    680  1.7.2.2  jdolecek  * @hw: pointer to the hardware structure
    681  1.7.2.2  jdolecek  * @addr: I2C bus address to write to
    682  1.7.2.2  jdolecek  * @reg: I2C device register to write to
    683  1.7.2.2  jdolecek  * @val: value to write
    684  1.7.2.2  jdolecek  *
    685  1.7.2.2  jdolecek  * Returns an error code on error.
    686  1.7.2.2  jdolecek  **/
    687  1.7.2.2  jdolecek static s32
    688  1.7.2.2  jdolecek ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
    689  1.7.2.2  jdolecek 					  u8 addr, u16 reg, u16 val)
    690  1.7.2.2  jdolecek {
    691  1.7.2.2  jdolecek 	return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, FALSE);
    692  1.7.2.2  jdolecek }
    693  1.7.2.2  jdolecek 
    694  1.7.2.2  jdolecek /**
    695  1.7.2.2  jdolecek *  ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
    696  1.7.2.2  jdolecek *  @hw: pointer to hardware structure
    697  1.7.2.2  jdolecek *
    698  1.7.2.2  jdolecek *  Initialize the function pointers and for MAC type X550EM.
    699  1.7.2.2  jdolecek *  Does not touch the hardware.
    700  1.7.2.2  jdolecek **/
    701  1.7.2.2  jdolecek s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
    702  1.7.2.2  jdolecek {
    703  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
    704  1.7.2.2  jdolecek 	struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
    705  1.7.2.2  jdolecek 	struct ixgbe_phy_info *phy = &hw->phy;
    706  1.7.2.2  jdolecek 	s32 ret_val;
    707  1.7.2.2  jdolecek 
    708  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_init_ops_X550EM");
    709  1.7.2.2  jdolecek 
    710  1.7.2.2  jdolecek 	/* Similar to X550 so start there. */
    711  1.7.2.2  jdolecek 	ret_val = ixgbe_init_ops_X550(hw);
    712  1.7.2.2  jdolecek 
    713  1.7.2.2  jdolecek 	/* Since this function eventually calls
    714  1.7.2.2  jdolecek 	 * ixgbe_init_ops_540 by design, we are setting
    715  1.7.2.2  jdolecek 	 * the pointers to NULL explicitly here to overwrite
    716  1.7.2.2  jdolecek 	 * the values being set in the x540 function.
    717  1.7.2.2  jdolecek 	 */
    718  1.7.2.2  jdolecek 
    719  1.7.2.2  jdolecek 	/* Bypass not supported in x550EM */
    720  1.7.2.2  jdolecek 	mac->ops.bypass_rw = NULL;
    721  1.7.2.2  jdolecek 	mac->ops.bypass_valid_rd = NULL;
    722  1.7.2.2  jdolecek 	mac->ops.bypass_set = NULL;
    723  1.7.2.2  jdolecek 	mac->ops.bypass_rd_eep = NULL;
    724  1.7.2.2  jdolecek 
    725  1.7.2.2  jdolecek 	/* FCOE not supported in x550EM */
    726  1.7.2.2  jdolecek 	mac->ops.get_san_mac_addr = NULL;
    727  1.7.2.2  jdolecek 	mac->ops.set_san_mac_addr = NULL;
    728  1.7.2.2  jdolecek 	mac->ops.get_wwn_prefix = NULL;
    729  1.7.2.2  jdolecek 	mac->ops.get_fcoe_boot_status = NULL;
    730  1.7.2.2  jdolecek 
    731  1.7.2.2  jdolecek 	/* IPsec not supported in x550EM */
    732  1.7.2.2  jdolecek 	mac->ops.disable_sec_rx_path = NULL;
    733  1.7.2.2  jdolecek 	mac->ops.enable_sec_rx_path = NULL;
    734  1.7.2.2  jdolecek 
    735  1.7.2.2  jdolecek 	/* AUTOC register is not present in x550EM. */
    736  1.7.2.2  jdolecek 	mac->ops.prot_autoc_read = NULL;
    737  1.7.2.2  jdolecek 	mac->ops.prot_autoc_write = NULL;
    738  1.7.2.2  jdolecek 
    739  1.7.2.2  jdolecek 	/* X550EM bus type is internal*/
    740  1.7.2.2  jdolecek 	hw->bus.type = ixgbe_bus_type_internal;
    741  1.7.2.2  jdolecek 	mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
    742  1.7.2.2  jdolecek 
    743  1.7.2.2  jdolecek 
    744  1.7.2.2  jdolecek 	mac->ops.get_media_type = ixgbe_get_media_type_X550em;
    745  1.7.2.2  jdolecek 	mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
    746  1.7.2.2  jdolecek 	mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
    747  1.7.2.2  jdolecek 	mac->ops.reset_hw = ixgbe_reset_hw_X550em;
    748  1.7.2.2  jdolecek 	mac->ops.get_supported_physical_layer =
    749  1.7.2.2  jdolecek 				    ixgbe_get_supported_physical_layer_X550em;
    750  1.7.2.2  jdolecek 
    751  1.7.2.2  jdolecek 	if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
    752  1.7.2.2  jdolecek 		mac->ops.setup_fc = ixgbe_setup_fc_generic;
    753  1.7.2.2  jdolecek 	else
    754  1.7.2.2  jdolecek 		mac->ops.setup_fc = ixgbe_setup_fc_X550em;
    755  1.7.2.2  jdolecek 
    756  1.7.2.2  jdolecek 	/* PHY */
    757  1.7.2.2  jdolecek 	phy->ops.init = ixgbe_init_phy_ops_X550em;
    758  1.7.2.2  jdolecek 	switch (hw->device_id) {
    759  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T:
    760  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T_L:
    761  1.7.2.2  jdolecek 		mac->ops.setup_fc = NULL;
    762  1.7.2.2  jdolecek 		phy->ops.identify = ixgbe_identify_phy_fw;
    763  1.7.2.2  jdolecek 		phy->ops.set_phy_power = NULL;
    764  1.7.2.2  jdolecek 		phy->ops.get_firmware_version = NULL;
    765  1.7.2.2  jdolecek 		break;
    766  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_1G_T:
    767  1.7.2.2  jdolecek 		mac->ops.setup_fc = NULL;
    768  1.7.2.2  jdolecek 		phy->ops.identify = ixgbe_identify_phy_x550em;
    769  1.7.2.2  jdolecek 		phy->ops.set_phy_power = NULL;
    770  1.7.2.2  jdolecek 		break;
    771  1.7.2.2  jdolecek 	default:
    772  1.7.2.2  jdolecek 		phy->ops.identify = ixgbe_identify_phy_x550em;
    773  1.7.2.2  jdolecek 	}
    774  1.7.2.2  jdolecek 
    775  1.7.2.2  jdolecek 	if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
    776  1.7.2.2  jdolecek 		phy->ops.set_phy_power = NULL;
    777  1.7.2.2  jdolecek 
    778  1.7.2.2  jdolecek 
    779  1.7.2.2  jdolecek 	/* EEPROM */
    780  1.7.2.2  jdolecek 	eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
    781  1.7.2.2  jdolecek 	eeprom->ops.read = ixgbe_read_ee_hostif_X550;
    782  1.7.2.2  jdolecek 	eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
    783  1.7.2.2  jdolecek 	eeprom->ops.write = ixgbe_write_ee_hostif_X550;
    784  1.7.2.2  jdolecek 	eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
    785  1.7.2.2  jdolecek 	eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
    786  1.7.2.2  jdolecek 	eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
    787  1.7.2.2  jdolecek 	eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
    788  1.7.2.2  jdolecek 
    789  1.7.2.2  jdolecek 	return ret_val;
    790  1.7.2.2  jdolecek }
    791  1.7.2.2  jdolecek 
    792  1.7.2.2  jdolecek #define IXGBE_DENVERTON_WA 1
    793  1.7.2.2  jdolecek 
    794  1.7.2.2  jdolecek /**
    795  1.7.2.2  jdolecek  * ixgbe_setup_fw_link - Setup firmware-controlled PHYs
    796  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    797  1.7.2.2  jdolecek  */
    798  1.7.2.2  jdolecek static s32 ixgbe_setup_fw_link(struct ixgbe_hw *hw)
    799  1.7.2.2  jdolecek {
    800  1.7.2.2  jdolecek 	u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
    801  1.7.2.2  jdolecek 	s32 rc;
    802  1.7.2.2  jdolecek #ifdef IXGBE_DENVERTON_WA
    803  1.7.2.2  jdolecek 	s32 ret_val;
    804  1.7.2.2  jdolecek 	u16 phydata;
    805  1.7.2.2  jdolecek #endif
    806  1.7.2.2  jdolecek 	u16 i;
    807  1.7.2.2  jdolecek 
    808  1.7.2.2  jdolecek 	if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
    809  1.7.2.2  jdolecek 		return 0;
    810  1.7.2.2  jdolecek 
    811  1.7.2.2  jdolecek 	if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
    812  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
    813  1.7.2.2  jdolecek 			      "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
    814  1.7.2.2  jdolecek 		return IXGBE_ERR_INVALID_LINK_SETTINGS;
    815  1.7.2.2  jdolecek 	}
    816  1.7.2.2  jdolecek 
    817  1.7.2.2  jdolecek 	switch (hw->fc.requested_mode) {
    818  1.7.2.2  jdolecek 	case ixgbe_fc_full:
    819  1.7.2.2  jdolecek 		setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RXTX <<
    820  1.7.2.2  jdolecek 			    FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
    821  1.7.2.2  jdolecek 		break;
    822  1.7.2.2  jdolecek 	case ixgbe_fc_rx_pause:
    823  1.7.2.2  jdolecek 		setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RX <<
    824  1.7.2.2  jdolecek 			    FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
    825  1.7.2.2  jdolecek 		break;
    826  1.7.2.2  jdolecek 	case ixgbe_fc_tx_pause:
    827  1.7.2.2  jdolecek 		setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_TX <<
    828  1.7.2.2  jdolecek 			    FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
    829  1.7.2.2  jdolecek 		break;
    830  1.7.2.2  jdolecek 	default:
    831  1.7.2.2  jdolecek 		break;
    832  1.7.2.2  jdolecek 	}
    833  1.7.2.2  jdolecek 
    834  1.7.2.2  jdolecek 	for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
    835  1.7.2.2  jdolecek 		if (hw->phy.autoneg_advertised & ixgbe_fw_map[i].phy_speed)
    836  1.7.2.2  jdolecek 			setup[0] |= ixgbe_fw_map[i].fw_speed;
    837  1.7.2.2  jdolecek 	}
    838  1.7.2.2  jdolecek 	setup[0] |= FW_PHY_ACT_SETUP_LINK_HP | FW_PHY_ACT_SETUP_LINK_AN;
    839  1.7.2.2  jdolecek 
    840  1.7.2.2  jdolecek 	if (hw->phy.eee_speeds_advertised)
    841  1.7.2.2  jdolecek 		setup[0] |= FW_PHY_ACT_SETUP_LINK_EEE;
    842  1.7.2.2  jdolecek 
    843  1.7.2.2  jdolecek #ifdef IXGBE_DENVERTON_WA
    844  1.7.2.2  jdolecek 	/* Don't use auto-nego for 10/100Mbps */
    845  1.7.2.2  jdolecek 	if ((hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_100_FULL)
    846  1.7.2.2  jdolecek 	    || (hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_10_FULL)) {
    847  1.7.2.2  jdolecek 		setup[0] &= ~FW_PHY_ACT_SETUP_LINK_AN;
    848  1.7.2.2  jdolecek 		setup[0] &= ~FW_PHY_ACT_SETUP_LINK_EEE;
    849  1.7.2.2  jdolecek 		setup[0] &= ~(FW_PHY_ACT_SETUP_LINK_PAUSE_RXTX
    850  1.7.2.2  jdolecek 		    << FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT);
    851  1.7.2.2  jdolecek 	}
    852  1.7.2.2  jdolecek #endif
    853  1.7.2.2  jdolecek 
    854  1.7.2.2  jdolecek 	rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_SETUP_LINK, &setup);
    855  1.7.2.2  jdolecek 	if (rc)
    856  1.7.2.2  jdolecek 		return rc;
    857  1.7.2.2  jdolecek 
    858  1.7.2.2  jdolecek #ifdef IXGBE_DENVERTON_WA
    859  1.7.2.2  jdolecek 	ret_val = ixgbe_read_phy_reg_x550a(hw, MII_BMCR, 0, &phydata);
    860  1.7.2.2  jdolecek 	if (ret_val != 0)
    861  1.7.2.2  jdolecek 		goto out;
    862  1.7.2.2  jdolecek 
    863  1.7.2.2  jdolecek 	/*
    864  1.7.2.2  jdolecek 	 *  Broken firmware sets BMCR register incorrectly if
    865  1.7.2.2  jdolecek 	 * FW_PHY_ACT_SETUP_LINK_AN isn't set.
    866  1.7.2.2  jdolecek 	 * a) FDX may not be set.
    867  1.7.2.2  jdolecek 	 * b) BMCR_SPEED1 (bit 6) is always cleard.
    868  1.7.2.2  jdolecek 	 * + -------+------+-----------+-----+--------------------------+
    869  1.7.2.2  jdolecek 	 * |request | BMCR | BMCR spd | BMCR |                          |
    870  1.7.2.2  jdolecek 	 * |        | (HEX)| (in bits)|  FDX |                          |
    871  1.7.2.2  jdolecek 	 * +--------+------+----------+------+--------------------------+
    872  1.7.2.2  jdolecek 	 * |   10M  | 0000 |  10M(00) |    0 |                          |
    873  1.7.2.2  jdolecek 	 * |   10M  | 2000 | 100M(01) |    0 |(I've never observed this)|
    874  1.7.2.2  jdolecek 	 * |   10M  | 2100 | 100M(01) |    1 |                          |
    875  1.7.2.2  jdolecek 	 * |  100M  | 0000 |  10M(00) |    0 |                          |
    876  1.7.2.2  jdolecek 	 * |  100M  | 0100 |  10M(00) |    1 |                          |
    877  1.7.2.2  jdolecek 	 * +--------------------------+------+--------------------------+
    878  1.7.2.2  jdolecek 	 */
    879  1.7.2.2  jdolecek 	if (((hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_100_FULL)
    880  1.7.2.2  jdolecek 		&& (((phydata & BMCR_FDX) == 0) || (BMCR_SPEED(phydata) == 0)))
    881  1.7.2.2  jdolecek 	    || ((hw->phy.autoneg_advertised == IXGBE_LINK_SPEED_10_FULL)
    882  1.7.2.2  jdolecek 		&& (((phydata & BMCR_FDX) == 0)
    883  1.7.2.2  jdolecek 		    || (BMCR_SPEED(phydata) != BMCR_S10)))) {
    884  1.7.2.2  jdolecek 		phydata = BMCR_FDX;
    885  1.7.2.2  jdolecek 		switch (hw->phy.autoneg_advertised) {
    886  1.7.2.2  jdolecek 		case IXGBE_LINK_SPEED_10_FULL:
    887  1.7.2.2  jdolecek 			phydata |= BMCR_S10;
    888  1.7.2.2  jdolecek 			break;
    889  1.7.2.2  jdolecek 		case IXGBE_LINK_SPEED_100_FULL:
    890  1.7.2.2  jdolecek 			phydata |= BMCR_S100;
    891  1.7.2.2  jdolecek 			break;
    892  1.7.2.2  jdolecek 		case IXGBE_LINK_SPEED_1GB_FULL:
    893  1.7.2.2  jdolecek 			panic("%s: 1GB_FULL is set", __func__);
    894  1.7.2.2  jdolecek 			break;
    895  1.7.2.2  jdolecek 		default:
    896  1.7.2.2  jdolecek 			break;
    897  1.7.2.2  jdolecek 		}
    898  1.7.2.2  jdolecek 		ret_val = ixgbe_write_phy_reg_x550a(hw, MII_BMCR, 0, phydata);
    899  1.7.2.2  jdolecek 		if (ret_val != 0)
    900  1.7.2.2  jdolecek 			return ret_val;
    901  1.7.2.2  jdolecek 	}
    902  1.7.2.2  jdolecek out:
    903  1.7.2.2  jdolecek #endif
    904  1.7.2.2  jdolecek 	if (setup[0] == FW_PHY_ACT_SETUP_LINK_RSP_DOWN)
    905  1.7.2.2  jdolecek 		return IXGBE_ERR_OVERTEMP;
    906  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
    907  1.7.2.2  jdolecek }
    908  1.7.2.2  jdolecek 
    909  1.7.2.2  jdolecek /**
    910  1.7.2.2  jdolecek  * ixgbe_fc_autoneg_fw _ Set up flow control for FW-controlled PHYs
    911  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
    912  1.7.2.2  jdolecek  *
    913  1.7.2.2  jdolecek  *  Called at init time to set up flow control.
    914  1.7.2.2  jdolecek  */
    915  1.7.2.2  jdolecek static s32 ixgbe_fc_autoneg_fw(struct ixgbe_hw *hw)
    916  1.7.2.2  jdolecek {
    917  1.7.2.2  jdolecek 	if (hw->fc.requested_mode == ixgbe_fc_default)
    918  1.7.2.2  jdolecek 		hw->fc.requested_mode = ixgbe_fc_full;
    919  1.7.2.2  jdolecek 
    920  1.7.2.2  jdolecek 	return ixgbe_setup_fw_link(hw);
    921  1.7.2.2  jdolecek }
    922  1.7.2.2  jdolecek 
    923  1.7.2.2  jdolecek /**
    924  1.7.2.2  jdolecek  * ixgbe_setup_eee_fw - Enable/disable EEE support
    925  1.7.2.2  jdolecek  * @hw: pointer to the HW structure
    926  1.7.2.2  jdolecek  * @enable_eee: boolean flag to enable EEE
    927  1.7.2.2  jdolecek  *
    928  1.7.2.2  jdolecek  * Enable/disable EEE based on enable_eee flag.
    929  1.7.2.2  jdolecek  * This function controls EEE for firmware-based PHY implementations.
    930  1.7.2.2  jdolecek  */
    931  1.7.2.2  jdolecek static s32 ixgbe_setup_eee_fw(struct ixgbe_hw *hw, bool enable_eee)
    932  1.7.2.2  jdolecek {
    933  1.7.2.2  jdolecek 	if (!!hw->phy.eee_speeds_advertised == enable_eee)
    934  1.7.2.2  jdolecek 		return IXGBE_SUCCESS;
    935  1.7.2.2  jdolecek 	if (enable_eee)
    936  1.7.2.2  jdolecek 		hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
    937  1.7.2.2  jdolecek 	else
    938  1.7.2.2  jdolecek 		hw->phy.eee_speeds_advertised = 0;
    939  1.7.2.2  jdolecek 	return hw->phy.ops.setup_link(hw);
    940  1.7.2.2  jdolecek }
    941  1.7.2.2  jdolecek 
    942  1.7.2.2  jdolecek /**
    943  1.7.2.2  jdolecek *  ixgbe_init_ops_X550EM_a - Inits func ptrs and MAC type
    944  1.7.2.2  jdolecek *  @hw: pointer to hardware structure
    945  1.7.2.2  jdolecek *
    946  1.7.2.2  jdolecek *  Initialize the function pointers and for MAC type X550EM_a.
    947  1.7.2.2  jdolecek *  Does not touch the hardware.
    948  1.7.2.2  jdolecek **/
    949  1.7.2.2  jdolecek s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
    950  1.7.2.2  jdolecek {
    951  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
    952  1.7.2.2  jdolecek 	s32 ret_val;
    953  1.7.2.2  jdolecek 
    954  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_init_ops_X550EM_a");
    955  1.7.2.2  jdolecek 
    956  1.7.2.2  jdolecek 	/* Start with generic X550EM init */
    957  1.7.2.2  jdolecek 	ret_val = ixgbe_init_ops_X550EM(hw);
    958  1.7.2.2  jdolecek 
    959  1.7.2.2  jdolecek 	if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
    960  1.7.2.2  jdolecek 	    hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L) {
    961  1.7.2.2  jdolecek 		mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
    962  1.7.2.2  jdolecek 		mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
    963  1.7.2.2  jdolecek 	} else {
    964  1.7.2.2  jdolecek 		mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a;
    965  1.7.2.2  jdolecek 		mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a;
    966  1.7.2.2  jdolecek 	}
    967  1.7.2.2  jdolecek 	mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
    968  1.7.2.2  jdolecek 	mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
    969  1.7.2.2  jdolecek 
    970  1.7.2.2  jdolecek 	switch (mac->ops.get_media_type(hw)) {
    971  1.7.2.2  jdolecek 	case ixgbe_media_type_fiber:
    972  1.7.2.2  jdolecek 		mac->ops.setup_fc = NULL;
    973  1.7.2.2  jdolecek 		mac->ops.fc_autoneg = ixgbe_fc_autoneg_fiber_x550em_a;
    974  1.7.2.2  jdolecek 		break;
    975  1.7.2.2  jdolecek 	case ixgbe_media_type_backplane:
    976  1.7.2.2  jdolecek 		mac->ops.fc_autoneg = ixgbe_fc_autoneg_backplane_x550em_a;
    977  1.7.2.2  jdolecek 		mac->ops.setup_fc = ixgbe_setup_fc_backplane_x550em_a;
    978  1.7.2.2  jdolecek 		break;
    979  1.7.2.2  jdolecek 	default:
    980  1.7.2.2  jdolecek 		break;
    981  1.7.2.2  jdolecek 	}
    982  1.7.2.2  jdolecek 
    983  1.7.2.2  jdolecek 	switch (hw->device_id) {
    984  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T:
    985  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T_L:
    986  1.7.2.2  jdolecek 		mac->ops.fc_autoneg = ixgbe_fc_autoneg_sgmii_x550em_a;
    987  1.7.2.2  jdolecek 		mac->ops.setup_fc = ixgbe_fc_autoneg_fw;
    988  1.7.2.2  jdolecek 		mac->ops.setup_eee = ixgbe_setup_eee_fw;
    989  1.7.2.2  jdolecek 		hw->phy.eee_speeds_supported = IXGBE_LINK_SPEED_100_FULL |
    990  1.7.2.2  jdolecek 					       IXGBE_LINK_SPEED_1GB_FULL;
    991  1.7.2.2  jdolecek 		hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
    992  1.7.2.2  jdolecek 		break;
    993  1.7.2.2  jdolecek 	default:
    994  1.7.2.2  jdolecek 		break;
    995  1.7.2.2  jdolecek 	}
    996  1.7.2.2  jdolecek 
    997  1.7.2.2  jdolecek 	return ret_val;
    998  1.7.2.2  jdolecek }
    999  1.7.2.2  jdolecek 
   1000  1.7.2.2  jdolecek /**
   1001  1.7.2.2  jdolecek *  ixgbe_init_ops_X550EM_x - Inits func ptrs and MAC type
   1002  1.7.2.2  jdolecek *  @hw: pointer to hardware structure
   1003  1.7.2.2  jdolecek *
   1004  1.7.2.2  jdolecek *  Initialize the function pointers and for MAC type X550EM_x.
   1005  1.7.2.2  jdolecek *  Does not touch the hardware.
   1006  1.7.2.2  jdolecek **/
   1007  1.7.2.2  jdolecek s32 ixgbe_init_ops_X550EM_x(struct ixgbe_hw *hw)
   1008  1.7.2.2  jdolecek {
   1009  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
   1010  1.7.2.2  jdolecek 	struct ixgbe_link_info *link = &hw->link;
   1011  1.7.2.2  jdolecek 	s32 ret_val;
   1012  1.7.2.2  jdolecek 
   1013  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_init_ops_X550EM_x");
   1014  1.7.2.2  jdolecek 
   1015  1.7.2.2  jdolecek 	/* Start with generic X550EM init */
   1016  1.7.2.2  jdolecek 	ret_val = ixgbe_init_ops_X550EM(hw);
   1017  1.7.2.2  jdolecek 
   1018  1.7.2.2  jdolecek 	mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
   1019  1.7.2.2  jdolecek 	mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
   1020  1.7.2.2  jdolecek 	mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
   1021  1.7.2.2  jdolecek 	mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
   1022  1.7.2.2  jdolecek 	link->ops.read_link = ixgbe_read_i2c_combined_generic;
   1023  1.7.2.2  jdolecek 	link->ops.read_link_unlocked = ixgbe_read_i2c_combined_generic_unlocked;
   1024  1.7.2.2  jdolecek 	link->ops.write_link = ixgbe_write_i2c_combined_generic;
   1025  1.7.2.2  jdolecek 	link->ops.write_link_unlocked =
   1026  1.7.2.2  jdolecek 				      ixgbe_write_i2c_combined_generic_unlocked;
   1027  1.7.2.2  jdolecek 	link->addr = IXGBE_CS4227;
   1028  1.7.2.2  jdolecek 
   1029  1.7.2.2  jdolecek 	if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T) {
   1030  1.7.2.2  jdolecek 		mac->ops.setup_fc = NULL;
   1031  1.7.2.2  jdolecek 		mac->ops.setup_eee = NULL;
   1032  1.7.2.2  jdolecek 		mac->ops.init_led_link_act = NULL;
   1033  1.7.2.2  jdolecek 	}
   1034  1.7.2.2  jdolecek 
   1035  1.7.2.2  jdolecek 	return ret_val;
   1036  1.7.2.2  jdolecek }
   1037  1.7.2.2  jdolecek 
   1038  1.7.2.2  jdolecek /**
   1039  1.7.2.2  jdolecek  *  ixgbe_dmac_config_X550
   1040  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1041  1.7.2.2  jdolecek  *
   1042  1.7.2.2  jdolecek  *  Configure DMA coalescing. If enabling dmac, dmac is activated.
   1043  1.7.2.2  jdolecek  *  When disabling dmac, dmac enable dmac bit is cleared.
   1044  1.7.2.2  jdolecek  **/
   1045  1.7.2.2  jdolecek s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
   1046  1.7.2.2  jdolecek {
   1047  1.7.2.2  jdolecek 	u32 reg, high_pri_tc;
   1048  1.7.2.2  jdolecek 
   1049  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_dmac_config_X550");
   1050  1.7.2.2  jdolecek 
   1051  1.7.2.2  jdolecek 	/* Disable DMA coalescing before configuring */
   1052  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
   1053  1.7.2.2  jdolecek 	reg &= ~IXGBE_DMACR_DMAC_EN;
   1054  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
   1055  1.7.2.2  jdolecek 
   1056  1.7.2.2  jdolecek 	/* Disable DMA Coalescing if the watchdog timer is 0 */
   1057  1.7.2.2  jdolecek 	if (!hw->mac.dmac_config.watchdog_timer)
   1058  1.7.2.2  jdolecek 		goto out;
   1059  1.7.2.2  jdolecek 
   1060  1.7.2.2  jdolecek 	ixgbe_dmac_config_tcs_X550(hw);
   1061  1.7.2.2  jdolecek 
   1062  1.7.2.2  jdolecek 	/* Configure DMA Coalescing Control Register */
   1063  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
   1064  1.7.2.2  jdolecek 
   1065  1.7.2.2  jdolecek 	/* Set the watchdog timer in units of 40.96 usec */
   1066  1.7.2.2  jdolecek 	reg &= ~IXGBE_DMACR_DMACWT_MASK;
   1067  1.7.2.2  jdolecek 	reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
   1068  1.7.2.2  jdolecek 
   1069  1.7.2.2  jdolecek 	reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
   1070  1.7.2.2  jdolecek 	/* If fcoe is enabled, set high priority traffic class */
   1071  1.7.2.2  jdolecek 	if (hw->mac.dmac_config.fcoe_en) {
   1072  1.7.2.2  jdolecek 		high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
   1073  1.7.2.2  jdolecek 		reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
   1074  1.7.2.2  jdolecek 			IXGBE_DMACR_HIGH_PRI_TC_MASK);
   1075  1.7.2.2  jdolecek 	}
   1076  1.7.2.2  jdolecek 	reg |= IXGBE_DMACR_EN_MNG_IND;
   1077  1.7.2.2  jdolecek 
   1078  1.7.2.2  jdolecek 	/* Enable DMA coalescing after configuration */
   1079  1.7.2.2  jdolecek 	reg |= IXGBE_DMACR_DMAC_EN;
   1080  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
   1081  1.7.2.2  jdolecek 
   1082  1.7.2.2  jdolecek out:
   1083  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   1084  1.7.2.2  jdolecek }
   1085  1.7.2.2  jdolecek 
   1086  1.7.2.2  jdolecek /**
   1087  1.7.2.2  jdolecek  *  ixgbe_dmac_config_tcs_X550
   1088  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1089  1.7.2.2  jdolecek  *
   1090  1.7.2.2  jdolecek  *  Configure DMA coalescing threshold per TC. The dmac enable bit must
   1091  1.7.2.2  jdolecek  *  be cleared before configuring.
   1092  1.7.2.2  jdolecek  **/
   1093  1.7.2.2  jdolecek s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
   1094  1.7.2.2  jdolecek {
   1095  1.7.2.2  jdolecek 	u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
   1096  1.7.2.2  jdolecek 
   1097  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
   1098  1.7.2.2  jdolecek 
   1099  1.7.2.2  jdolecek 	/* Configure DMA coalescing enabled */
   1100  1.7.2.2  jdolecek 	switch (hw->mac.dmac_config.link_speed) {
   1101  1.7.2.2  jdolecek 	case IXGBE_LINK_SPEED_10_FULL:
   1102  1.7.2.2  jdolecek 	case IXGBE_LINK_SPEED_100_FULL:
   1103  1.7.2.2  jdolecek 		pb_headroom = IXGBE_DMACRXT_100M;
   1104  1.7.2.2  jdolecek 		break;
   1105  1.7.2.2  jdolecek 	case IXGBE_LINK_SPEED_1GB_FULL:
   1106  1.7.2.2  jdolecek 		pb_headroom = IXGBE_DMACRXT_1G;
   1107  1.7.2.2  jdolecek 		break;
   1108  1.7.2.2  jdolecek 	default:
   1109  1.7.2.2  jdolecek 		pb_headroom = IXGBE_DMACRXT_10G;
   1110  1.7.2.2  jdolecek 		break;
   1111  1.7.2.2  jdolecek 	}
   1112  1.7.2.2  jdolecek 
   1113  1.7.2.2  jdolecek 	maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
   1114  1.7.2.2  jdolecek 			     IXGBE_MHADD_MFS_SHIFT) / 1024);
   1115  1.7.2.2  jdolecek 
   1116  1.7.2.2  jdolecek 	/* Set the per Rx packet buffer receive threshold */
   1117  1.7.2.2  jdolecek 	for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
   1118  1.7.2.2  jdolecek 		reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
   1119  1.7.2.2  jdolecek 		reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
   1120  1.7.2.2  jdolecek 
   1121  1.7.2.2  jdolecek 		if (tc < hw->mac.dmac_config.num_tcs) {
   1122  1.7.2.2  jdolecek 			/* Get Rx PB size */
   1123  1.7.2.2  jdolecek 			rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
   1124  1.7.2.2  jdolecek 			rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
   1125  1.7.2.2  jdolecek 				IXGBE_RXPBSIZE_SHIFT;
   1126  1.7.2.2  jdolecek 
   1127  1.7.2.2  jdolecek 			/* Calculate receive buffer threshold in kilobytes */
   1128  1.7.2.2  jdolecek 			if (rx_pb_size > pb_headroom)
   1129  1.7.2.2  jdolecek 				rx_pb_size = rx_pb_size - pb_headroom;
   1130  1.7.2.2  jdolecek 			else
   1131  1.7.2.2  jdolecek 				rx_pb_size = 0;
   1132  1.7.2.2  jdolecek 
   1133  1.7.2.2  jdolecek 			/* Minimum of MFS shall be set for DMCTH */
   1134  1.7.2.2  jdolecek 			reg |= (rx_pb_size > maxframe_size_kb) ?
   1135  1.7.2.2  jdolecek 				rx_pb_size : maxframe_size_kb;
   1136  1.7.2.2  jdolecek 		}
   1137  1.7.2.2  jdolecek 		IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
   1138  1.7.2.2  jdolecek 	}
   1139  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   1140  1.7.2.2  jdolecek }
   1141  1.7.2.2  jdolecek 
   1142  1.7.2.2  jdolecek /**
   1143  1.7.2.2  jdolecek  *  ixgbe_dmac_update_tcs_X550
   1144  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1145  1.7.2.2  jdolecek  *
   1146  1.7.2.2  jdolecek  *  Disables dmac, updates per TC settings, and then enables dmac.
   1147  1.7.2.2  jdolecek  **/
   1148  1.7.2.2  jdolecek s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
   1149  1.7.2.2  jdolecek {
   1150  1.7.2.2  jdolecek 	u32 reg;
   1151  1.7.2.2  jdolecek 
   1152  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
   1153  1.7.2.2  jdolecek 
   1154  1.7.2.2  jdolecek 	/* Disable DMA coalescing before configuring */
   1155  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
   1156  1.7.2.2  jdolecek 	reg &= ~IXGBE_DMACR_DMAC_EN;
   1157  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
   1158  1.7.2.2  jdolecek 
   1159  1.7.2.2  jdolecek 	ixgbe_dmac_config_tcs_X550(hw);
   1160  1.7.2.2  jdolecek 
   1161  1.7.2.2  jdolecek 	/* Enable DMA coalescing after configuration */
   1162  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
   1163  1.7.2.2  jdolecek 	reg |= IXGBE_DMACR_DMAC_EN;
   1164  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
   1165  1.7.2.2  jdolecek 
   1166  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   1167  1.7.2.2  jdolecek }
   1168  1.7.2.2  jdolecek 
   1169  1.7.2.2  jdolecek /**
   1170  1.7.2.2  jdolecek  *  ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
   1171  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1172  1.7.2.2  jdolecek  *
   1173  1.7.2.2  jdolecek  *  Initializes the EEPROM parameters ixgbe_eeprom_info within the
   1174  1.7.2.2  jdolecek  *  ixgbe_hw struct in order to set up EEPROM access.
   1175  1.7.2.2  jdolecek  **/
   1176  1.7.2.2  jdolecek s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
   1177  1.7.2.2  jdolecek {
   1178  1.7.2.2  jdolecek 	struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
   1179  1.7.2.2  jdolecek 	u32 eec;
   1180  1.7.2.2  jdolecek 	u16 eeprom_size;
   1181  1.7.2.2  jdolecek 
   1182  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_init_eeprom_params_X550");
   1183  1.7.2.2  jdolecek 
   1184  1.7.2.2  jdolecek 	if (eeprom->type == ixgbe_eeprom_uninitialized) {
   1185  1.7.2.2  jdolecek 		eeprom->semaphore_delay = 10;
   1186  1.7.2.2  jdolecek 		eeprom->type = ixgbe_flash;
   1187  1.7.2.2  jdolecek 
   1188  1.7.2.2  jdolecek 		eec = IXGBE_READ_REG(hw, IXGBE_EEC);
   1189  1.7.2.2  jdolecek 		eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
   1190  1.7.2.2  jdolecek 				    IXGBE_EEC_SIZE_SHIFT);
   1191  1.7.2.2  jdolecek 		eeprom->word_size = 1 << (eeprom_size +
   1192  1.7.2.2  jdolecek 					  IXGBE_EEPROM_WORD_SIZE_SHIFT);
   1193  1.7.2.2  jdolecek 
   1194  1.7.2.2  jdolecek 		DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
   1195  1.7.2.2  jdolecek 			  eeprom->type, eeprom->word_size);
   1196  1.7.2.2  jdolecek 	}
   1197  1.7.2.2  jdolecek 
   1198  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   1199  1.7.2.2  jdolecek }
   1200  1.7.2.2  jdolecek 
   1201  1.7.2.2  jdolecek /**
   1202  1.7.2.2  jdolecek  * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
   1203  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   1204  1.7.2.2  jdolecek  * @enable: enable or disable source address pruning
   1205  1.7.2.2  jdolecek  * @pool: Rx pool to set source address pruning for
   1206  1.7.2.2  jdolecek  **/
   1207  1.7.2.2  jdolecek void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
   1208  1.7.2.2  jdolecek 					   unsigned int pool)
   1209  1.7.2.2  jdolecek {
   1210  1.7.2.2  jdolecek 	u64 pfflp;
   1211  1.7.2.2  jdolecek 
   1212  1.7.2.2  jdolecek 	/* max rx pool is 63 */
   1213  1.7.2.2  jdolecek 	if (pool > 63)
   1214  1.7.2.2  jdolecek 		return;
   1215  1.7.2.2  jdolecek 
   1216  1.7.2.2  jdolecek 	pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
   1217  1.7.2.2  jdolecek 	pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
   1218  1.7.2.2  jdolecek 
   1219  1.7.2.2  jdolecek 	if (enable)
   1220  1.7.2.2  jdolecek 		pfflp |= (1ULL << pool);
   1221  1.7.2.2  jdolecek 	else
   1222  1.7.2.2  jdolecek 		pfflp &= ~(1ULL << pool);
   1223  1.7.2.2  jdolecek 
   1224  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
   1225  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
   1226  1.7.2.2  jdolecek }
   1227  1.7.2.2  jdolecek 
   1228  1.7.2.2  jdolecek /**
   1229  1.7.2.2  jdolecek  *  ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
   1230  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1231  1.7.2.2  jdolecek  *  @enable: enable or disable switch for Ethertype anti-spoofing
   1232  1.7.2.2  jdolecek  *  @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
   1233  1.7.2.2  jdolecek  *
   1234  1.7.2.2  jdolecek  **/
   1235  1.7.2.2  jdolecek void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
   1236  1.7.2.2  jdolecek 		bool enable, int vf)
   1237  1.7.2.2  jdolecek {
   1238  1.7.2.2  jdolecek 	int vf_target_reg = vf >> 3;
   1239  1.7.2.2  jdolecek 	int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
   1240  1.7.2.2  jdolecek 	u32 pfvfspoof;
   1241  1.7.2.2  jdolecek 
   1242  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
   1243  1.7.2.2  jdolecek 
   1244  1.7.2.2  jdolecek 	pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
   1245  1.7.2.2  jdolecek 	if (enable)
   1246  1.7.2.2  jdolecek 		pfvfspoof |= (1 << vf_target_shift);
   1247  1.7.2.2  jdolecek 	else
   1248  1.7.2.2  jdolecek 		pfvfspoof &= ~(1 << vf_target_shift);
   1249  1.7.2.2  jdolecek 
   1250  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
   1251  1.7.2.2  jdolecek }
   1252  1.7.2.2  jdolecek 
   1253  1.7.2.2  jdolecek /**
   1254  1.7.2.2  jdolecek  * ixgbe_iosf_wait - Wait for IOSF command completion
   1255  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   1256  1.7.2.2  jdolecek  * @ctrl: pointer to location to receive final IOSF control value
   1257  1.7.2.2  jdolecek  *
   1258  1.7.2.2  jdolecek  * Returns failing status on timeout
   1259  1.7.2.2  jdolecek  *
   1260  1.7.2.2  jdolecek  * Note: ctrl can be NULL if the IOSF control register value is not needed
   1261  1.7.2.2  jdolecek  **/
   1262  1.7.2.2  jdolecek static s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
   1263  1.7.2.2  jdolecek {
   1264  1.7.2.2  jdolecek 	u32 i, command = 0;
   1265  1.7.2.2  jdolecek 
   1266  1.7.2.2  jdolecek 	/* Check every 10 usec to see if the address cycle completed.
   1267  1.7.2.2  jdolecek 	 * The SB IOSF BUSY bit will clear when the operation is
   1268  1.7.2.2  jdolecek 	 * complete
   1269  1.7.2.2  jdolecek 	 */
   1270  1.7.2.2  jdolecek 	for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
   1271  1.7.2.2  jdolecek 		command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
   1272  1.7.2.2  jdolecek 		if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
   1273  1.7.2.2  jdolecek 			break;
   1274  1.7.2.2  jdolecek 		usec_delay(10);
   1275  1.7.2.2  jdolecek 	}
   1276  1.7.2.2  jdolecek 	if (ctrl)
   1277  1.7.2.2  jdolecek 		*ctrl = command;
   1278  1.7.2.2  jdolecek 	if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
   1279  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
   1280  1.7.2.2  jdolecek 		return IXGBE_ERR_PHY;
   1281  1.7.2.2  jdolecek 	}
   1282  1.7.2.2  jdolecek 
   1283  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   1284  1.7.2.2  jdolecek }
   1285  1.7.2.2  jdolecek 
   1286  1.7.2.2  jdolecek /**
   1287  1.7.2.2  jdolecek  *  ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register
   1288  1.7.2.2  jdolecek  *  of the IOSF device
   1289  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1290  1.7.2.2  jdolecek  *  @reg_addr: 32 bit PHY register to write
   1291  1.7.2.2  jdolecek  *  @device_type: 3 bit device type
   1292  1.7.2.2  jdolecek  *  @data: Data to write to the register
   1293  1.7.2.2  jdolecek  **/
   1294  1.7.2.2  jdolecek s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
   1295  1.7.2.2  jdolecek 			    u32 device_type, u32 data)
   1296  1.7.2.2  jdolecek {
   1297  1.7.2.2  jdolecek 	u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
   1298  1.7.2.2  jdolecek 	u32 command, error __unused;
   1299  1.7.2.2  jdolecek 	s32 ret;
   1300  1.7.2.2  jdolecek 
   1301  1.7.2.2  jdolecek 	ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
   1302  1.7.2.2  jdolecek 	if (ret != IXGBE_SUCCESS)
   1303  1.7.2.2  jdolecek 		return ret;
   1304  1.7.2.2  jdolecek 
   1305  1.7.2.2  jdolecek 	ret = ixgbe_iosf_wait(hw, NULL);
   1306  1.7.2.2  jdolecek 	if (ret != IXGBE_SUCCESS)
   1307  1.7.2.2  jdolecek 		goto out;
   1308  1.7.2.2  jdolecek 
   1309  1.7.2.2  jdolecek 	command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
   1310  1.7.2.2  jdolecek 		   (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
   1311  1.7.2.2  jdolecek 
   1312  1.7.2.2  jdolecek 	/* Write IOSF control register */
   1313  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
   1314  1.7.2.2  jdolecek 
   1315  1.7.2.2  jdolecek 	/* Write IOSF data register */
   1316  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
   1317  1.7.2.2  jdolecek 
   1318  1.7.2.2  jdolecek 	ret = ixgbe_iosf_wait(hw, &command);
   1319  1.7.2.2  jdolecek 
   1320  1.7.2.2  jdolecek 	if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
   1321  1.7.2.2  jdolecek 		error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
   1322  1.7.2.2  jdolecek 			 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
   1323  1.7.2.2  jdolecek 		ERROR_REPORT2(IXGBE_ERROR_POLLING,
   1324  1.7.2.2  jdolecek 			      "Failed to write, error %x\n", error);
   1325  1.7.2.2  jdolecek 		ret = IXGBE_ERR_PHY;
   1326  1.7.2.2  jdolecek 	}
   1327  1.7.2.2  jdolecek 
   1328  1.7.2.2  jdolecek out:
   1329  1.7.2.2  jdolecek 	ixgbe_release_swfw_semaphore(hw, gssr);
   1330  1.7.2.2  jdolecek 	return ret;
   1331  1.7.2.2  jdolecek }
   1332  1.7.2.2  jdolecek 
   1333  1.7.2.2  jdolecek /**
   1334  1.7.2.2  jdolecek  *  ixgbe_read_iosf_sb_reg_x550 - Reads specified register of the IOSF device
   1335  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1336  1.7.2.2  jdolecek  *  @reg_addr: 32 bit PHY register to write
   1337  1.7.2.2  jdolecek  *  @device_type: 3 bit device type
   1338  1.7.2.2  jdolecek  *  @data: Pointer to read data from the register
   1339  1.7.2.2  jdolecek  **/
   1340  1.7.2.2  jdolecek s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
   1341  1.7.2.2  jdolecek 			   u32 device_type, u32 *data)
   1342  1.7.2.2  jdolecek {
   1343  1.7.2.2  jdolecek 	u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
   1344  1.7.2.2  jdolecek 	u32 command, error __unused;
   1345  1.7.2.2  jdolecek 	s32 ret;
   1346  1.7.2.2  jdolecek 
   1347  1.7.2.2  jdolecek 	ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
   1348  1.7.2.2  jdolecek 	if (ret != IXGBE_SUCCESS)
   1349  1.7.2.2  jdolecek 		return ret;
   1350  1.7.2.2  jdolecek 
   1351  1.7.2.2  jdolecek 	ret = ixgbe_iosf_wait(hw, NULL);
   1352  1.7.2.2  jdolecek 	if (ret != IXGBE_SUCCESS)
   1353  1.7.2.2  jdolecek 		goto out;
   1354  1.7.2.2  jdolecek 
   1355  1.7.2.2  jdolecek 	command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
   1356  1.7.2.2  jdolecek 		   (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
   1357  1.7.2.2  jdolecek 
   1358  1.7.2.2  jdolecek 	/* Write IOSF control register */
   1359  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
   1360  1.7.2.2  jdolecek 
   1361  1.7.2.2  jdolecek 	ret = ixgbe_iosf_wait(hw, &command);
   1362  1.7.2.2  jdolecek 
   1363  1.7.2.2  jdolecek 	if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
   1364  1.7.2.2  jdolecek 		error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
   1365  1.7.2.2  jdolecek 			 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
   1366  1.7.2.2  jdolecek 		ERROR_REPORT2(IXGBE_ERROR_POLLING,
   1367  1.7.2.2  jdolecek 				"Failed to read, error %x\n", error);
   1368  1.7.2.2  jdolecek 		ret = IXGBE_ERR_PHY;
   1369  1.7.2.2  jdolecek 	}
   1370  1.7.2.2  jdolecek 
   1371  1.7.2.2  jdolecek 	if (ret == IXGBE_SUCCESS)
   1372  1.7.2.2  jdolecek 		*data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
   1373  1.7.2.2  jdolecek 
   1374  1.7.2.2  jdolecek out:
   1375  1.7.2.2  jdolecek 	ixgbe_release_swfw_semaphore(hw, gssr);
   1376  1.7.2.2  jdolecek 	return ret;
   1377  1.7.2.2  jdolecek }
   1378  1.7.2.2  jdolecek 
   1379  1.7.2.2  jdolecek /**
   1380  1.7.2.2  jdolecek  * ixgbe_get_phy_token - Get the token for shared phy access
   1381  1.7.2.2  jdolecek  * @hw: Pointer to hardware structure
   1382  1.7.2.2  jdolecek  */
   1383  1.7.2.2  jdolecek 
   1384  1.7.2.2  jdolecek s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
   1385  1.7.2.2  jdolecek {
   1386  1.7.2.2  jdolecek 	struct ixgbe_hic_phy_token_req token_cmd;
   1387  1.7.2.2  jdolecek 	s32 status;
   1388  1.7.2.2  jdolecek 
   1389  1.7.2.2  jdolecek 	token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
   1390  1.7.2.2  jdolecek 	token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
   1391  1.7.2.2  jdolecek 	token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
   1392  1.7.2.2  jdolecek 	token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
   1393  1.7.2.2  jdolecek 	token_cmd.port_number = hw->bus.lan_id;
   1394  1.7.2.2  jdolecek 	token_cmd.command_type = FW_PHY_TOKEN_REQ;
   1395  1.7.2.2  jdolecek 	token_cmd.pad = 0;
   1396  1.7.2.2  jdolecek 	status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
   1397  1.7.2.2  jdolecek 					      sizeof(token_cmd),
   1398  1.7.2.2  jdolecek 					      IXGBE_HI_COMMAND_TIMEOUT,
   1399  1.7.2.2  jdolecek 					      TRUE);
   1400  1.7.2.2  jdolecek 	if (status) {
   1401  1.7.2.2  jdolecek 		DEBUGOUT1("Issuing host interface command failed with Status = %d\n",
   1402  1.7.2.2  jdolecek 			  status);
   1403  1.7.2.2  jdolecek 		return status;
   1404  1.7.2.2  jdolecek 	}
   1405  1.7.2.2  jdolecek 	if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
   1406  1.7.2.2  jdolecek 		return IXGBE_SUCCESS;
   1407  1.7.2.2  jdolecek 	if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY) {
   1408  1.7.2.2  jdolecek 		DEBUGOUT1("Host interface command returned 0x%08x , returning IXGBE_ERR_FW_RESP_INVALID\n",
   1409  1.7.2.2  jdolecek 			  token_cmd.hdr.cmd_or_resp.ret_status);
   1410  1.7.2.2  jdolecek 		return IXGBE_ERR_FW_RESP_INVALID;
   1411  1.7.2.2  jdolecek 	}
   1412  1.7.2.2  jdolecek 
   1413  1.7.2.2  jdolecek 	DEBUGOUT("Returning  IXGBE_ERR_TOKEN_RETRY\n");
   1414  1.7.2.2  jdolecek 	return IXGBE_ERR_TOKEN_RETRY;
   1415  1.7.2.2  jdolecek }
   1416  1.7.2.2  jdolecek 
   1417  1.7.2.2  jdolecek /**
   1418  1.7.2.2  jdolecek  * ixgbe_put_phy_token - Put the token for shared phy access
   1419  1.7.2.2  jdolecek  * @hw: Pointer to hardware structure
   1420  1.7.2.2  jdolecek  */
   1421  1.7.2.2  jdolecek 
   1422  1.7.2.2  jdolecek s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
   1423  1.7.2.2  jdolecek {
   1424  1.7.2.2  jdolecek 	struct ixgbe_hic_phy_token_req token_cmd;
   1425  1.7.2.2  jdolecek 	s32 status;
   1426  1.7.2.2  jdolecek 
   1427  1.7.2.2  jdolecek 	token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
   1428  1.7.2.2  jdolecek 	token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
   1429  1.7.2.2  jdolecek 	token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
   1430  1.7.2.2  jdolecek 	token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
   1431  1.7.2.2  jdolecek 	token_cmd.port_number = hw->bus.lan_id;
   1432  1.7.2.2  jdolecek 	token_cmd.command_type = FW_PHY_TOKEN_REL;
   1433  1.7.2.2  jdolecek 	token_cmd.pad = 0;
   1434  1.7.2.2  jdolecek 	status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
   1435  1.7.2.2  jdolecek 					      sizeof(token_cmd),
   1436  1.7.2.2  jdolecek 					      IXGBE_HI_COMMAND_TIMEOUT,
   1437  1.7.2.2  jdolecek 					      TRUE);
   1438  1.7.2.2  jdolecek 	if (status)
   1439  1.7.2.2  jdolecek 		return status;
   1440  1.7.2.2  jdolecek 	if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
   1441  1.7.2.2  jdolecek 		return IXGBE_SUCCESS;
   1442  1.7.2.2  jdolecek 
   1443  1.7.2.2  jdolecek 	DEBUGOUT("Put PHY Token host interface command failed");
   1444  1.7.2.2  jdolecek 	return IXGBE_ERR_FW_RESP_INVALID;
   1445  1.7.2.2  jdolecek }
   1446  1.7.2.2  jdolecek 
   1447  1.7.2.2  jdolecek /**
   1448  1.7.2.2  jdolecek  *  ixgbe_write_iosf_sb_reg_x550a - Writes a value to specified register
   1449  1.7.2.2  jdolecek  *  of the IOSF device
   1450  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1451  1.7.2.2  jdolecek  *  @reg_addr: 32 bit PHY register to write
   1452  1.7.2.2  jdolecek  *  @device_type: 3 bit device type
   1453  1.7.2.2  jdolecek  *  @data: Data to write to the register
   1454  1.7.2.2  jdolecek  **/
   1455  1.7.2.2  jdolecek s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
   1456  1.7.2.2  jdolecek 				  u32 device_type, u32 data)
   1457  1.7.2.2  jdolecek {
   1458  1.7.2.2  jdolecek 	struct ixgbe_hic_internal_phy_req write_cmd;
   1459  1.7.2.2  jdolecek 	s32 status;
   1460  1.7.2.2  jdolecek 	UNREFERENCED_1PARAMETER(device_type);
   1461  1.7.2.2  jdolecek 
   1462  1.7.2.2  jdolecek 	memset(&write_cmd, 0, sizeof(write_cmd));
   1463  1.7.2.2  jdolecek 	write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
   1464  1.7.2.2  jdolecek 	write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
   1465  1.7.2.2  jdolecek 	write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
   1466  1.7.2.2  jdolecek 	write_cmd.port_number = hw->bus.lan_id;
   1467  1.7.2.2  jdolecek 	write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
   1468  1.7.2.2  jdolecek 	write_cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
   1469  1.7.2.2  jdolecek 	write_cmd.write_data = IXGBE_CPU_TO_BE32(data);
   1470  1.7.2.2  jdolecek 
   1471  1.7.2.2  jdolecek 	status = ixgbe_host_interface_command(hw, (u32 *)&write_cmd,
   1472  1.7.2.2  jdolecek 					      sizeof(write_cmd),
   1473  1.7.2.2  jdolecek 					      IXGBE_HI_COMMAND_TIMEOUT, FALSE);
   1474  1.7.2.2  jdolecek 
   1475  1.7.2.2  jdolecek 	return status;
   1476  1.7.2.2  jdolecek }
   1477  1.7.2.2  jdolecek 
   1478  1.7.2.2  jdolecek /**
   1479  1.7.2.2  jdolecek  *  ixgbe_read_iosf_sb_reg_x550a - Reads specified register of the IOSF device
   1480  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1481  1.7.2.2  jdolecek  *  @reg_addr: 32 bit PHY register to write
   1482  1.7.2.2  jdolecek  *  @device_type: 3 bit device type
   1483  1.7.2.2  jdolecek  *  @data: Pointer to read data from the register
   1484  1.7.2.2  jdolecek  **/
   1485  1.7.2.2  jdolecek s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
   1486  1.7.2.2  jdolecek 				 u32 device_type, u32 *data)
   1487  1.7.2.2  jdolecek {
   1488  1.7.2.2  jdolecek 	union {
   1489  1.7.2.2  jdolecek 		struct ixgbe_hic_internal_phy_req cmd;
   1490  1.7.2.2  jdolecek 		struct ixgbe_hic_internal_phy_resp rsp;
   1491  1.7.2.2  jdolecek 	} hic;
   1492  1.7.2.2  jdolecek 	s32 status;
   1493  1.7.2.2  jdolecek 	UNREFERENCED_1PARAMETER(device_type);
   1494  1.7.2.2  jdolecek 
   1495  1.7.2.2  jdolecek 	memset(&hic, 0, sizeof(hic));
   1496  1.7.2.2  jdolecek 	hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
   1497  1.7.2.2  jdolecek 	hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
   1498  1.7.2.2  jdolecek 	hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
   1499  1.7.2.2  jdolecek 	hic.cmd.port_number = hw->bus.lan_id;
   1500  1.7.2.2  jdolecek 	hic.cmd.command_type = FW_INT_PHY_REQ_READ;
   1501  1.7.2.2  jdolecek 	hic.cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
   1502  1.7.2.2  jdolecek 
   1503  1.7.2.2  jdolecek 	status = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
   1504  1.7.2.2  jdolecek 					      sizeof(hic.cmd),
   1505  1.7.2.2  jdolecek 					      IXGBE_HI_COMMAND_TIMEOUT, TRUE);
   1506  1.7.2.2  jdolecek 
   1507  1.7.2.2  jdolecek 	/* Extract the register value from the response. */
   1508  1.7.2.2  jdolecek 	*data = IXGBE_BE32_TO_CPU(hic.rsp.read_data);
   1509  1.7.2.2  jdolecek 
   1510  1.7.2.2  jdolecek 	return status;
   1511  1.7.2.2  jdolecek }
   1512  1.7.2.2  jdolecek 
   1513  1.7.2.2  jdolecek /**
   1514  1.7.2.2  jdolecek  *  ixgbe_disable_mdd_X550
   1515  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1516  1.7.2.2  jdolecek  *
   1517  1.7.2.2  jdolecek  *  Disable malicious driver detection
   1518  1.7.2.2  jdolecek  **/
   1519  1.7.2.2  jdolecek void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
   1520  1.7.2.2  jdolecek {
   1521  1.7.2.2  jdolecek 	u32 reg;
   1522  1.7.2.2  jdolecek 
   1523  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_disable_mdd_X550");
   1524  1.7.2.2  jdolecek 
   1525  1.7.2.2  jdolecek 	/* Disable MDD for TX DMA and interrupt */
   1526  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
   1527  1.7.2.2  jdolecek 	reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
   1528  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
   1529  1.7.2.2  jdolecek 
   1530  1.7.2.2  jdolecek 	/* Disable MDD for RX and interrupt */
   1531  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
   1532  1.7.2.2  jdolecek 	reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
   1533  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
   1534  1.7.2.2  jdolecek }
   1535  1.7.2.2  jdolecek 
   1536  1.7.2.2  jdolecek /**
   1537  1.7.2.2  jdolecek  *  ixgbe_enable_mdd_X550
   1538  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1539  1.7.2.2  jdolecek  *
   1540  1.7.2.2  jdolecek  *  Enable malicious driver detection
   1541  1.7.2.2  jdolecek  **/
   1542  1.7.2.2  jdolecek void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
   1543  1.7.2.2  jdolecek {
   1544  1.7.2.2  jdolecek 	u32 reg;
   1545  1.7.2.2  jdolecek 
   1546  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_enable_mdd_X550");
   1547  1.7.2.2  jdolecek 
   1548  1.7.2.2  jdolecek 	/* Enable MDD for TX DMA and interrupt */
   1549  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
   1550  1.7.2.2  jdolecek 	reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
   1551  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
   1552  1.7.2.2  jdolecek 
   1553  1.7.2.2  jdolecek 	/* Enable MDD for RX and interrupt */
   1554  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
   1555  1.7.2.2  jdolecek 	reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
   1556  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
   1557  1.7.2.2  jdolecek }
   1558  1.7.2.2  jdolecek 
   1559  1.7.2.2  jdolecek /**
   1560  1.7.2.2  jdolecek  *  ixgbe_restore_mdd_vf_X550
   1561  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1562  1.7.2.2  jdolecek  *  @vf: vf index
   1563  1.7.2.2  jdolecek  *
   1564  1.7.2.2  jdolecek  *  Restore VF that was disabled during malicious driver detection event
   1565  1.7.2.2  jdolecek  **/
   1566  1.7.2.2  jdolecek void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
   1567  1.7.2.2  jdolecek {
   1568  1.7.2.2  jdolecek 	u32 idx, reg, num_qs, start_q, bitmask;
   1569  1.7.2.2  jdolecek 
   1570  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
   1571  1.7.2.2  jdolecek 
   1572  1.7.2.2  jdolecek 	/* Map VF to queues */
   1573  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
   1574  1.7.2.2  jdolecek 	switch (reg & IXGBE_MRQC_MRQE_MASK) {
   1575  1.7.2.2  jdolecek 	case IXGBE_MRQC_VMDQRT8TCEN:
   1576  1.7.2.2  jdolecek 		num_qs = 8;  /* 16 VFs / pools */
   1577  1.7.2.2  jdolecek 		bitmask = 0x000000FF;
   1578  1.7.2.2  jdolecek 		break;
   1579  1.7.2.2  jdolecek 	case IXGBE_MRQC_VMDQRSS32EN:
   1580  1.7.2.2  jdolecek 	case IXGBE_MRQC_VMDQRT4TCEN:
   1581  1.7.2.2  jdolecek 		num_qs = 4;  /* 32 VFs / pools */
   1582  1.7.2.2  jdolecek 		bitmask = 0x0000000F;
   1583  1.7.2.2  jdolecek 		break;
   1584  1.7.2.2  jdolecek 	default:            /* 64 VFs / pools */
   1585  1.7.2.2  jdolecek 		num_qs = 2;
   1586  1.7.2.2  jdolecek 		bitmask = 0x00000003;
   1587  1.7.2.2  jdolecek 		break;
   1588  1.7.2.2  jdolecek 	}
   1589  1.7.2.2  jdolecek 	start_q = vf * num_qs;
   1590  1.7.2.2  jdolecek 
   1591  1.7.2.2  jdolecek 	/* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
   1592  1.7.2.2  jdolecek 	idx = start_q / 32;
   1593  1.7.2.2  jdolecek 	reg = 0;
   1594  1.7.2.2  jdolecek 	reg |= (bitmask << (start_q % 32));
   1595  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
   1596  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
   1597  1.7.2.2  jdolecek }
   1598  1.7.2.2  jdolecek 
   1599  1.7.2.2  jdolecek /**
   1600  1.7.2.2  jdolecek  *  ixgbe_mdd_event_X550
   1601  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1602  1.7.2.2  jdolecek  *  @vf_bitmap: vf bitmap of malicious vfs
   1603  1.7.2.2  jdolecek  *
   1604  1.7.2.2  jdolecek  *  Handle malicious driver detection event.
   1605  1.7.2.2  jdolecek  **/
   1606  1.7.2.2  jdolecek void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
   1607  1.7.2.2  jdolecek {
   1608  1.7.2.2  jdolecek 	u32 wqbr;
   1609  1.7.2.2  jdolecek 	u32 i, j, reg, q, shift, vf, idx;
   1610  1.7.2.2  jdolecek 
   1611  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_mdd_event_X550");
   1612  1.7.2.2  jdolecek 
   1613  1.7.2.2  jdolecek 	/* figure out pool size for mapping to vf's */
   1614  1.7.2.2  jdolecek 	reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
   1615  1.7.2.2  jdolecek 	switch (reg & IXGBE_MRQC_MRQE_MASK) {
   1616  1.7.2.2  jdolecek 	case IXGBE_MRQC_VMDQRT8TCEN:
   1617  1.7.2.2  jdolecek 		shift = 3;  /* 16 VFs / pools */
   1618  1.7.2.2  jdolecek 		break;
   1619  1.7.2.2  jdolecek 	case IXGBE_MRQC_VMDQRSS32EN:
   1620  1.7.2.2  jdolecek 	case IXGBE_MRQC_VMDQRT4TCEN:
   1621  1.7.2.2  jdolecek 		shift = 2;  /* 32 VFs / pools */
   1622  1.7.2.2  jdolecek 		break;
   1623  1.7.2.2  jdolecek 	default:
   1624  1.7.2.2  jdolecek 		shift = 1;  /* 64 VFs / pools */
   1625  1.7.2.2  jdolecek 		break;
   1626  1.7.2.2  jdolecek 	}
   1627  1.7.2.2  jdolecek 
   1628  1.7.2.2  jdolecek 	/* Read WQBR_TX and WQBR_RX and check for malicious queues */
   1629  1.7.2.2  jdolecek 	for (i = 0; i < 4; i++) {
   1630  1.7.2.2  jdolecek 		wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
   1631  1.7.2.2  jdolecek 		wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
   1632  1.7.2.2  jdolecek 
   1633  1.7.2.2  jdolecek 		if (!wqbr)
   1634  1.7.2.2  jdolecek 			continue;
   1635  1.7.2.2  jdolecek 
   1636  1.7.2.2  jdolecek 		/* Get malicious queue */
   1637  1.7.2.2  jdolecek 		for (j = 0; j < 32 && wqbr; j++) {
   1638  1.7.2.2  jdolecek 
   1639  1.7.2.2  jdolecek 			if (!(wqbr & (1 << j)))
   1640  1.7.2.2  jdolecek 				continue;
   1641  1.7.2.2  jdolecek 
   1642  1.7.2.2  jdolecek 			/* Get queue from bitmask */
   1643  1.7.2.2  jdolecek 			q = j + (i * 32);
   1644  1.7.2.2  jdolecek 
   1645  1.7.2.2  jdolecek 			/* Map queue to vf */
   1646  1.7.2.2  jdolecek 			vf = (q >> shift);
   1647  1.7.2.2  jdolecek 
   1648  1.7.2.2  jdolecek 			/* Set vf bit in vf_bitmap */
   1649  1.7.2.2  jdolecek 			idx = vf / 32;
   1650  1.7.2.2  jdolecek 			vf_bitmap[idx] |= (1 << (vf % 32));
   1651  1.7.2.2  jdolecek 			wqbr &= ~(1 << j);
   1652  1.7.2.2  jdolecek 		}
   1653  1.7.2.2  jdolecek 	}
   1654  1.7.2.2  jdolecek }
   1655  1.7.2.2  jdolecek 
   1656  1.7.2.2  jdolecek /**
   1657  1.7.2.2  jdolecek  *  ixgbe_get_media_type_X550em - Get media type
   1658  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1659  1.7.2.2  jdolecek  *
   1660  1.7.2.2  jdolecek  *  Returns the media type (fiber, copper, backplane)
   1661  1.7.2.2  jdolecek  */
   1662  1.7.2.2  jdolecek enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
   1663  1.7.2.2  jdolecek {
   1664  1.7.2.2  jdolecek 	enum ixgbe_media_type media_type;
   1665  1.7.2.2  jdolecek 
   1666  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_get_media_type_X550em");
   1667  1.7.2.2  jdolecek 
   1668  1.7.2.2  jdolecek 	/* Detect if there is a copper PHY attached. */
   1669  1.7.2.2  jdolecek 	switch (hw->device_id) {
   1670  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_KR:
   1671  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_KX4:
   1672  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_XFI:
   1673  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_KR:
   1674  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_KR_L:
   1675  1.7.2.2  jdolecek 		media_type = ixgbe_media_type_backplane;
   1676  1.7.2.2  jdolecek 		break;
   1677  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_SFP:
   1678  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SFP:
   1679  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SFP_N:
   1680  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_QSFP:
   1681  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_QSFP_N:
   1682  1.7.2.2  jdolecek 		media_type = ixgbe_media_type_fiber;
   1683  1.7.2.2  jdolecek 		break;
   1684  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_1G_T:
   1685  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_10G_T:
   1686  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_10G_T:
   1687  1.7.2.2  jdolecek 		media_type = ixgbe_media_type_copper;
   1688  1.7.2.2  jdolecek 		break;
   1689  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SGMII:
   1690  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SGMII_L:
   1691  1.7.2.2  jdolecek 		media_type = ixgbe_media_type_backplane;
   1692  1.7.2.2  jdolecek 		hw->phy.type = ixgbe_phy_sgmii;
   1693  1.7.2.2  jdolecek 		break;
   1694  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T:
   1695  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T_L:
   1696  1.7.2.2  jdolecek 		media_type = ixgbe_media_type_copper;
   1697  1.7.2.2  jdolecek 		break;
   1698  1.7.2.2  jdolecek 	default:
   1699  1.7.2.2  jdolecek 		media_type = ixgbe_media_type_unknown;
   1700  1.7.2.2  jdolecek 		break;
   1701  1.7.2.2  jdolecek 	}
   1702  1.7.2.2  jdolecek 	return media_type;
   1703  1.7.2.2  jdolecek }
   1704  1.7.2.2  jdolecek 
   1705  1.7.2.2  jdolecek /**
   1706  1.7.2.2  jdolecek  *  ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
   1707  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1708  1.7.2.2  jdolecek  *  @linear: TRUE if SFP module is linear
   1709  1.7.2.2  jdolecek  */
   1710  1.7.2.2  jdolecek static s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
   1711  1.7.2.2  jdolecek {
   1712  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
   1713  1.7.2.2  jdolecek 
   1714  1.7.2.2  jdolecek 	switch (hw->phy.sfp_type) {
   1715  1.7.2.2  jdolecek 	case ixgbe_sfp_type_not_present:
   1716  1.7.2.2  jdolecek 		return IXGBE_ERR_SFP_NOT_PRESENT;
   1717  1.7.2.2  jdolecek 	case ixgbe_sfp_type_da_cu_core0:
   1718  1.7.2.2  jdolecek 	case ixgbe_sfp_type_da_cu_core1:
   1719  1.7.2.2  jdolecek 		*linear = TRUE;
   1720  1.7.2.2  jdolecek 		break;
   1721  1.7.2.2  jdolecek 	case ixgbe_sfp_type_srlr_core0:
   1722  1.7.2.2  jdolecek 	case ixgbe_sfp_type_srlr_core1:
   1723  1.7.2.2  jdolecek 	case ixgbe_sfp_type_da_act_lmt_core0:
   1724  1.7.2.2  jdolecek 	case ixgbe_sfp_type_da_act_lmt_core1:
   1725  1.7.2.2  jdolecek 	case ixgbe_sfp_type_1g_sx_core0:
   1726  1.7.2.2  jdolecek 	case ixgbe_sfp_type_1g_sx_core1:
   1727  1.7.2.2  jdolecek 	case ixgbe_sfp_type_1g_lx_core0:
   1728  1.7.2.2  jdolecek 	case ixgbe_sfp_type_1g_lx_core1:
   1729  1.7.2.2  jdolecek 		*linear = FALSE;
   1730  1.7.2.2  jdolecek 		break;
   1731  1.7.2.2  jdolecek 	case ixgbe_sfp_type_unknown:
   1732  1.7.2.2  jdolecek 	case ixgbe_sfp_type_1g_cu_core0:
   1733  1.7.2.2  jdolecek 	case ixgbe_sfp_type_1g_cu_core1:
   1734  1.7.2.2  jdolecek 	default:
   1735  1.7.2.2  jdolecek 		return IXGBE_ERR_SFP_NOT_SUPPORTED;
   1736  1.7.2.2  jdolecek 	}
   1737  1.7.2.2  jdolecek 
   1738  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   1739  1.7.2.2  jdolecek }
   1740  1.7.2.2  jdolecek 
   1741  1.7.2.2  jdolecek /**
   1742  1.7.2.2  jdolecek  *  ixgbe_identify_sfp_module_X550em - Identifies SFP modules
   1743  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1744  1.7.2.2  jdolecek  *
   1745  1.7.2.2  jdolecek  *  Searches for and identifies the SFP module and assigns appropriate PHY type.
   1746  1.7.2.2  jdolecek  **/
   1747  1.7.2.2  jdolecek s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
   1748  1.7.2.2  jdolecek {
   1749  1.7.2.2  jdolecek 	s32 status;
   1750  1.7.2.2  jdolecek 	bool linear;
   1751  1.7.2.2  jdolecek 
   1752  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
   1753  1.7.2.2  jdolecek 
   1754  1.7.2.2  jdolecek 	status = ixgbe_identify_module_generic(hw);
   1755  1.7.2.2  jdolecek 
   1756  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   1757  1.7.2.2  jdolecek 		return status;
   1758  1.7.2.2  jdolecek 
   1759  1.7.2.2  jdolecek 	/* Check if SFP module is supported */
   1760  1.7.2.2  jdolecek 	status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
   1761  1.7.2.2  jdolecek 
   1762  1.7.2.2  jdolecek 	return status;
   1763  1.7.2.2  jdolecek }
   1764  1.7.2.2  jdolecek 
   1765  1.7.2.2  jdolecek /**
   1766  1.7.2.2  jdolecek  *  ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
   1767  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1768  1.7.2.2  jdolecek  */
   1769  1.7.2.2  jdolecek s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
   1770  1.7.2.2  jdolecek {
   1771  1.7.2.2  jdolecek 	s32 status;
   1772  1.7.2.2  jdolecek 	bool linear;
   1773  1.7.2.2  jdolecek 
   1774  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
   1775  1.7.2.2  jdolecek 
   1776  1.7.2.2  jdolecek 	/* Check if SFP module is supported */
   1777  1.7.2.2  jdolecek 	status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
   1778  1.7.2.2  jdolecek 
   1779  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   1780  1.7.2.2  jdolecek 		return status;
   1781  1.7.2.2  jdolecek 
   1782  1.7.2.2  jdolecek 	ixgbe_init_mac_link_ops_X550em(hw);
   1783  1.7.2.2  jdolecek 	hw->phy.ops.reset = NULL;
   1784  1.7.2.2  jdolecek 
   1785  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   1786  1.7.2.2  jdolecek }
   1787  1.7.2.2  jdolecek 
   1788  1.7.2.2  jdolecek /**
   1789  1.7.2.2  jdolecek *  ixgbe_restart_an_internal_phy_x550em - restart autonegotiation for the
   1790  1.7.2.2  jdolecek *  internal PHY
   1791  1.7.2.2  jdolecek *  @hw: pointer to hardware structure
   1792  1.7.2.2  jdolecek **/
   1793  1.7.2.2  jdolecek static s32 ixgbe_restart_an_internal_phy_x550em(struct ixgbe_hw *hw)
   1794  1.7.2.2  jdolecek {
   1795  1.7.2.2  jdolecek 	s32 status;
   1796  1.7.2.2  jdolecek 	u32 link_ctrl;
   1797  1.7.2.2  jdolecek 
   1798  1.7.2.2  jdolecek 	/* Restart auto-negotiation. */
   1799  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   1800  1.7.2.2  jdolecek 				       IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   1801  1.7.2.2  jdolecek 				       IXGBE_SB_IOSF_TARGET_KR_PHY, &link_ctrl);
   1802  1.7.2.2  jdolecek 
   1803  1.7.2.2  jdolecek 	if (status) {
   1804  1.7.2.2  jdolecek 		DEBUGOUT("Auto-negotiation did not complete\n");
   1805  1.7.2.2  jdolecek 		return status;
   1806  1.7.2.2  jdolecek 	}
   1807  1.7.2.2  jdolecek 
   1808  1.7.2.2  jdolecek 	link_ctrl |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
   1809  1.7.2.2  jdolecek 	status = hw->mac.ops.write_iosf_sb_reg(hw,
   1810  1.7.2.2  jdolecek 					IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   1811  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, link_ctrl);
   1812  1.7.2.2  jdolecek 
   1813  1.7.2.2  jdolecek 	if (hw->mac.type == ixgbe_mac_X550EM_a) {
   1814  1.7.2.2  jdolecek 		u32 flx_mask_st20;
   1815  1.7.2.2  jdolecek 
   1816  1.7.2.2  jdolecek 		/* Indicate to FW that AN restart has been asserted */
   1817  1.7.2.2  jdolecek 		status = hw->mac.ops.read_iosf_sb_reg(hw,
   1818  1.7.2.2  jdolecek 				IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   1819  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_mask_st20);
   1820  1.7.2.2  jdolecek 
   1821  1.7.2.2  jdolecek 		if (status) {
   1822  1.7.2.2  jdolecek 			DEBUGOUT("Auto-negotiation did not complete\n");
   1823  1.7.2.2  jdolecek 			return status;
   1824  1.7.2.2  jdolecek 		}
   1825  1.7.2.2  jdolecek 
   1826  1.7.2.2  jdolecek 		flx_mask_st20 |= IXGBE_KRM_PMD_FLX_MASK_ST20_FW_AN_RESTART;
   1827  1.7.2.2  jdolecek 		status = hw->mac.ops.write_iosf_sb_reg(hw,
   1828  1.7.2.2  jdolecek 				IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   1829  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, flx_mask_st20);
   1830  1.7.2.2  jdolecek 	}
   1831  1.7.2.2  jdolecek 
   1832  1.7.2.2  jdolecek 	return status;
   1833  1.7.2.2  jdolecek }
   1834  1.7.2.2  jdolecek 
   1835  1.7.2.2  jdolecek /**
   1836  1.7.2.2  jdolecek  * ixgbe_setup_sgmii - Set up link for sgmii
   1837  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   1838  1.7.2.2  jdolecek  */
   1839  1.7.2.2  jdolecek static s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
   1840  1.7.2.2  jdolecek 			     bool autoneg_wait)
   1841  1.7.2.2  jdolecek {
   1842  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
   1843  1.7.2.2  jdolecek 	u32 lval, sval, flx_val;
   1844  1.7.2.2  jdolecek 	s32 rc;
   1845  1.7.2.2  jdolecek 
   1846  1.7.2.2  jdolecek 	rc = mac->ops.read_iosf_sb_reg(hw,
   1847  1.7.2.2  jdolecek 				       IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   1848  1.7.2.2  jdolecek 				       IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
   1849  1.7.2.2  jdolecek 	if (rc)
   1850  1.7.2.2  jdolecek 		return rc;
   1851  1.7.2.2  jdolecek 
   1852  1.7.2.2  jdolecek 	lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
   1853  1.7.2.2  jdolecek 	lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
   1854  1.7.2.2  jdolecek 	lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
   1855  1.7.2.2  jdolecek 	lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
   1856  1.7.2.2  jdolecek 	lval |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
   1857  1.7.2.2  jdolecek 	rc = mac->ops.write_iosf_sb_reg(hw,
   1858  1.7.2.2  jdolecek 					IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   1859  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
   1860  1.7.2.2  jdolecek 	if (rc)
   1861  1.7.2.2  jdolecek 		return rc;
   1862  1.7.2.2  jdolecek 
   1863  1.7.2.2  jdolecek 	rc = mac->ops.read_iosf_sb_reg(hw,
   1864  1.7.2.2  jdolecek 				       IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
   1865  1.7.2.2  jdolecek 				       IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
   1866  1.7.2.2  jdolecek 	if (rc)
   1867  1.7.2.2  jdolecek 		return rc;
   1868  1.7.2.2  jdolecek 
   1869  1.7.2.2  jdolecek 	sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
   1870  1.7.2.2  jdolecek 	sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
   1871  1.7.2.2  jdolecek 	rc = mac->ops.write_iosf_sb_reg(hw,
   1872  1.7.2.2  jdolecek 					IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
   1873  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
   1874  1.7.2.2  jdolecek 	if (rc)
   1875  1.7.2.2  jdolecek 		return rc;
   1876  1.7.2.2  jdolecek 
   1877  1.7.2.2  jdolecek 	rc = mac->ops.read_iosf_sb_reg(hw,
   1878  1.7.2.2  jdolecek 				    IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   1879  1.7.2.2  jdolecek 				    IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
   1880  1.7.2.2  jdolecek 	if (rc)
   1881  1.7.2.2  jdolecek 		return rc;
   1882  1.7.2.2  jdolecek 
   1883  1.7.2.2  jdolecek 	flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
   1884  1.7.2.2  jdolecek 	flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
   1885  1.7.2.2  jdolecek 	flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
   1886  1.7.2.2  jdolecek 	flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
   1887  1.7.2.2  jdolecek 	flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
   1888  1.7.2.2  jdolecek 
   1889  1.7.2.2  jdolecek 	rc = mac->ops.write_iosf_sb_reg(hw,
   1890  1.7.2.2  jdolecek 				    IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   1891  1.7.2.2  jdolecek 				    IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
   1892  1.7.2.2  jdolecek 	if (rc)
   1893  1.7.2.2  jdolecek 		return rc;
   1894  1.7.2.2  jdolecek 
   1895  1.7.2.2  jdolecek 	rc = ixgbe_restart_an_internal_phy_x550em(hw);
   1896  1.7.2.2  jdolecek 	if (rc)
   1897  1.7.2.2  jdolecek 		return rc;
   1898  1.7.2.2  jdolecek 
   1899  1.7.2.2  jdolecek 	return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
   1900  1.7.2.2  jdolecek }
   1901  1.7.2.2  jdolecek 
   1902  1.7.2.2  jdolecek /**
   1903  1.7.2.2  jdolecek  * ixgbe_setup_sgmii_fw - Set up link for sgmii with firmware-controlled PHYs
   1904  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   1905  1.7.2.2  jdolecek  */
   1906  1.7.2.2  jdolecek static s32 ixgbe_setup_sgmii_fw(struct ixgbe_hw *hw, ixgbe_link_speed speed,
   1907  1.7.2.2  jdolecek 				bool autoneg_wait)
   1908  1.7.2.2  jdolecek {
   1909  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
   1910  1.7.2.2  jdolecek 	u32 lval, sval, flx_val;
   1911  1.7.2.2  jdolecek 	s32 rc;
   1912  1.7.2.2  jdolecek 
   1913  1.7.2.2  jdolecek 	rc = mac->ops.read_iosf_sb_reg(hw,
   1914  1.7.2.2  jdolecek 				       IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   1915  1.7.2.2  jdolecek 				       IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
   1916  1.7.2.2  jdolecek 	if (rc)
   1917  1.7.2.2  jdolecek 		return rc;
   1918  1.7.2.2  jdolecek 
   1919  1.7.2.2  jdolecek 	lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
   1920  1.7.2.2  jdolecek 	lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
   1921  1.7.2.2  jdolecek 	lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
   1922  1.7.2.2  jdolecek 	lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
   1923  1.7.2.2  jdolecek 	lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
   1924  1.7.2.2  jdolecek 	rc = mac->ops.write_iosf_sb_reg(hw,
   1925  1.7.2.2  jdolecek 					IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   1926  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
   1927  1.7.2.2  jdolecek 	if (rc)
   1928  1.7.2.2  jdolecek 		return rc;
   1929  1.7.2.2  jdolecek 
   1930  1.7.2.2  jdolecek 	rc = mac->ops.read_iosf_sb_reg(hw,
   1931  1.7.2.2  jdolecek 				       IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
   1932  1.7.2.2  jdolecek 				       IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
   1933  1.7.2.2  jdolecek 	if (rc)
   1934  1.7.2.2  jdolecek 		return rc;
   1935  1.7.2.2  jdolecek 
   1936  1.7.2.2  jdolecek 	sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
   1937  1.7.2.2  jdolecek 	sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
   1938  1.7.2.2  jdolecek 	rc = mac->ops.write_iosf_sb_reg(hw,
   1939  1.7.2.2  jdolecek 					IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
   1940  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
   1941  1.7.2.2  jdolecek 	if (rc)
   1942  1.7.2.2  jdolecek 		return rc;
   1943  1.7.2.2  jdolecek 
   1944  1.7.2.2  jdolecek 	rc = mac->ops.write_iosf_sb_reg(hw,
   1945  1.7.2.2  jdolecek 					IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   1946  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
   1947  1.7.2.2  jdolecek 	if (rc)
   1948  1.7.2.2  jdolecek 		return rc;
   1949  1.7.2.2  jdolecek 
   1950  1.7.2.2  jdolecek 	rc = mac->ops.read_iosf_sb_reg(hw,
   1951  1.7.2.2  jdolecek 				    IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   1952  1.7.2.2  jdolecek 				    IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
   1953  1.7.2.2  jdolecek 	if (rc)
   1954  1.7.2.2  jdolecek 		return rc;
   1955  1.7.2.2  jdolecek 
   1956  1.7.2.2  jdolecek 	flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
   1957  1.7.2.2  jdolecek 	flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
   1958  1.7.2.2  jdolecek 	flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
   1959  1.7.2.2  jdolecek 	flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
   1960  1.7.2.2  jdolecek 	flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
   1961  1.7.2.2  jdolecek 
   1962  1.7.2.2  jdolecek 	rc = mac->ops.write_iosf_sb_reg(hw,
   1963  1.7.2.2  jdolecek 				    IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   1964  1.7.2.2  jdolecek 				    IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
   1965  1.7.2.2  jdolecek 	if (rc)
   1966  1.7.2.2  jdolecek 		return rc;
   1967  1.7.2.2  jdolecek 
   1968  1.7.2.2  jdolecek 	rc = ixgbe_restart_an_internal_phy_x550em(hw);
   1969  1.7.2.2  jdolecek 
   1970  1.7.2.2  jdolecek 	return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
   1971  1.7.2.2  jdolecek }
   1972  1.7.2.2  jdolecek 
   1973  1.7.2.2  jdolecek /**
   1974  1.7.2.2  jdolecek  *  ixgbe_init_mac_link_ops_X550em - init mac link function pointers
   1975  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   1976  1.7.2.2  jdolecek  */
   1977  1.7.2.2  jdolecek void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
   1978  1.7.2.2  jdolecek {
   1979  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
   1980  1.7.2.2  jdolecek 
   1981  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
   1982  1.7.2.2  jdolecek 
   1983  1.7.2.2  jdolecek 	switch (hw->mac.ops.get_media_type(hw)) {
   1984  1.7.2.2  jdolecek 	case ixgbe_media_type_fiber:
   1985  1.7.2.2  jdolecek 		/* CS4227 does not support autoneg, so disable the laser control
   1986  1.7.2.2  jdolecek 		 * functions for SFP+ fiber
   1987  1.7.2.2  jdolecek 		 */
   1988  1.7.2.2  jdolecek 		mac->ops.disable_tx_laser = NULL;
   1989  1.7.2.2  jdolecek 		mac->ops.enable_tx_laser = NULL;
   1990  1.7.2.2  jdolecek 		mac->ops.flap_tx_laser = NULL;
   1991  1.7.2.2  jdolecek 		mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
   1992  1.7.2.2  jdolecek 		mac->ops.set_rate_select_speed =
   1993  1.7.2.2  jdolecek 					ixgbe_set_soft_rate_select_speed;
   1994  1.7.2.2  jdolecek 
   1995  1.7.2.2  jdolecek 		if ((hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) ||
   1996  1.7.2.2  jdolecek 		    (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP))
   1997  1.7.2.2  jdolecek 			mac->ops.setup_mac_link =
   1998  1.7.2.2  jdolecek 						ixgbe_setup_mac_link_sfp_x550a;
   1999  1.7.2.2  jdolecek 		else
   2000  1.7.2.2  jdolecek 			mac->ops.setup_mac_link =
   2001  1.7.2.2  jdolecek 						ixgbe_setup_mac_link_sfp_x550em;
   2002  1.7.2.2  jdolecek 		break;
   2003  1.7.2.2  jdolecek 	case ixgbe_media_type_copper:
   2004  1.7.2.2  jdolecek 		if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T)
   2005  1.7.2.2  jdolecek 			break;
   2006  1.7.2.2  jdolecek 		if (hw->mac.type == ixgbe_mac_X550EM_a) {
   2007  1.7.2.2  jdolecek 			if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T ||
   2008  1.7.2.2  jdolecek 			    hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) {
   2009  1.7.2.2  jdolecek 				mac->ops.setup_link = ixgbe_setup_sgmii_fw;
   2010  1.7.2.2  jdolecek 				mac->ops.check_link =
   2011  1.7.2.2  jdolecek 						   ixgbe_check_mac_link_generic;
   2012  1.7.2.2  jdolecek 			} else {
   2013  1.7.2.2  jdolecek 				mac->ops.setup_link =
   2014  1.7.2.2  jdolecek 						  ixgbe_setup_mac_link_t_X550em;
   2015  1.7.2.2  jdolecek 			}
   2016  1.7.2.2  jdolecek 		} else {
   2017  1.7.2.2  jdolecek 			mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
   2018  1.7.2.2  jdolecek 			mac->ops.check_link = ixgbe_check_link_t_X550em;
   2019  1.7.2.2  jdolecek 		}
   2020  1.7.2.2  jdolecek 		break;
   2021  1.7.2.2  jdolecek 	case ixgbe_media_type_backplane:
   2022  1.7.2.2  jdolecek 		if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
   2023  1.7.2.2  jdolecek 		    hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
   2024  1.7.2.2  jdolecek 			mac->ops.setup_link = ixgbe_setup_sgmii;
   2025  1.7.2.2  jdolecek 		break;
   2026  1.7.2.2  jdolecek 	default:
   2027  1.7.2.2  jdolecek 		break;
   2028  1.7.2.2  jdolecek 	}
   2029  1.7.2.2  jdolecek }
   2030  1.7.2.2  jdolecek 
   2031  1.7.2.2  jdolecek /**
   2032  1.7.2.2  jdolecek  *  ixgbe_get_link_capabilities_x550em - Determines link capabilities
   2033  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2034  1.7.2.2  jdolecek  *  @speed: pointer to link speed
   2035  1.7.2.2  jdolecek  *  @autoneg: TRUE when autoneg or autotry is enabled
   2036  1.7.2.2  jdolecek  */
   2037  1.7.2.2  jdolecek s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
   2038  1.7.2.2  jdolecek 				       ixgbe_link_speed *speed,
   2039  1.7.2.2  jdolecek 				       bool *autoneg)
   2040  1.7.2.2  jdolecek {
   2041  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
   2042  1.7.2.2  jdolecek 
   2043  1.7.2.2  jdolecek 
   2044  1.7.2.2  jdolecek 	if (hw->phy.type == ixgbe_phy_fw) {
   2045  1.7.2.2  jdolecek 		*autoneg = TRUE;
   2046  1.7.2.2  jdolecek 		*speed = hw->phy.speeds_supported;
   2047  1.7.2.2  jdolecek 		return 0;
   2048  1.7.2.2  jdolecek 	}
   2049  1.7.2.2  jdolecek 
   2050  1.7.2.2  jdolecek 	/* SFP */
   2051  1.7.2.2  jdolecek 	if (hw->phy.media_type == ixgbe_media_type_fiber) {
   2052  1.7.2.2  jdolecek 
   2053  1.7.2.2  jdolecek 		/* CS4227 SFP must not enable auto-negotiation */
   2054  1.7.2.2  jdolecek 		*autoneg = FALSE;
   2055  1.7.2.2  jdolecek 
   2056  1.7.2.2  jdolecek 		/* Check if 1G SFP module. */
   2057  1.7.2.2  jdolecek 		if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
   2058  1.7.2.2  jdolecek 		    hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
   2059  1.7.2.2  jdolecek 		    || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
   2060  1.7.2.2  jdolecek 		    hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
   2061  1.7.2.2  jdolecek 			*speed = IXGBE_LINK_SPEED_1GB_FULL;
   2062  1.7.2.2  jdolecek 			return IXGBE_SUCCESS;
   2063  1.7.2.2  jdolecek 		}
   2064  1.7.2.2  jdolecek 
   2065  1.7.2.2  jdolecek 		/* Link capabilities are based on SFP */
   2066  1.7.2.2  jdolecek 		if (hw->phy.multispeed_fiber)
   2067  1.7.2.2  jdolecek 			*speed = IXGBE_LINK_SPEED_10GB_FULL |
   2068  1.7.2.2  jdolecek 				 IXGBE_LINK_SPEED_1GB_FULL;
   2069  1.7.2.2  jdolecek 		else
   2070  1.7.2.2  jdolecek 			*speed = IXGBE_LINK_SPEED_10GB_FULL;
   2071  1.7.2.2  jdolecek 	} else {
   2072  1.7.2.2  jdolecek 		switch (hw->phy.type) {
   2073  1.7.2.2  jdolecek 		case ixgbe_phy_ext_1g_t:
   2074  1.7.2.2  jdolecek 		case ixgbe_phy_sgmii:
   2075  1.7.2.2  jdolecek 			*speed = IXGBE_LINK_SPEED_1GB_FULL;
   2076  1.7.2.2  jdolecek 			break;
   2077  1.7.2.2  jdolecek 		case ixgbe_phy_x550em_kr:
   2078  1.7.2.2  jdolecek 			if (hw->mac.type == ixgbe_mac_X550EM_a) {
   2079  1.7.2.2  jdolecek 				/* check different backplane modes */
   2080  1.7.2.2  jdolecek 				if (hw->phy.nw_mng_if_sel &
   2081  1.7.2.2  jdolecek 					   IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
   2082  1.7.2.2  jdolecek 					*speed = IXGBE_LINK_SPEED_2_5GB_FULL;
   2083  1.7.2.2  jdolecek 					break;
   2084  1.7.2.2  jdolecek 				} else if (hw->device_id ==
   2085  1.7.2.2  jdolecek 						   IXGBE_DEV_ID_X550EM_A_KR_L) {
   2086  1.7.2.2  jdolecek 					*speed = IXGBE_LINK_SPEED_1GB_FULL;
   2087  1.7.2.2  jdolecek 					break;
   2088  1.7.2.2  jdolecek 				}
   2089  1.7.2.2  jdolecek 			}
   2090  1.7.2.2  jdolecek 			/* fall through */
   2091  1.7.2.2  jdolecek 		default:
   2092  1.7.2.2  jdolecek 			*speed = IXGBE_LINK_SPEED_10GB_FULL |
   2093  1.7.2.2  jdolecek 			    IXGBE_LINK_SPEED_1GB_FULL;
   2094  1.7.2.2  jdolecek 			break;
   2095  1.7.2.2  jdolecek 		}
   2096  1.7.2.2  jdolecek 		*autoneg = TRUE;
   2097  1.7.2.2  jdolecek 	}
   2098  1.7.2.2  jdolecek 
   2099  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   2100  1.7.2.2  jdolecek }
   2101  1.7.2.2  jdolecek 
   2102  1.7.2.2  jdolecek /**
   2103  1.7.2.2  jdolecek  * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
   2104  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   2105  1.7.2.2  jdolecek  * @lsc: pointer to boolean flag which indicates whether external Base T
   2106  1.7.2.2  jdolecek  *       PHY interrupt is lsc
   2107  1.7.2.2  jdolecek  *
   2108  1.7.2.2  jdolecek  * Determime if external Base T PHY interrupt cause is high temperature
   2109  1.7.2.2  jdolecek  * failure alarm or link status change.
   2110  1.7.2.2  jdolecek  *
   2111  1.7.2.2  jdolecek  * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
   2112  1.7.2.2  jdolecek  * failure alarm, else return PHY access status.
   2113  1.7.2.2  jdolecek  */
   2114  1.7.2.2  jdolecek static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
   2115  1.7.2.2  jdolecek {
   2116  1.7.2.2  jdolecek 	u32 status;
   2117  1.7.2.2  jdolecek 	u16 reg;
   2118  1.7.2.2  jdolecek 
   2119  1.7.2.2  jdolecek 	*lsc = FALSE;
   2120  1.7.2.2  jdolecek 
   2121  1.7.2.2  jdolecek 	/* Vendor alarm triggered */
   2122  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
   2123  1.7.2.2  jdolecek 				      IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2124  1.7.2.2  jdolecek 				      &reg);
   2125  1.7.2.2  jdolecek 
   2126  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS ||
   2127  1.7.2.2  jdolecek 	    !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
   2128  1.7.2.2  jdolecek 		return status;
   2129  1.7.2.2  jdolecek 
   2130  1.7.2.2  jdolecek 	/* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
   2131  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
   2132  1.7.2.2  jdolecek 				      IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2133  1.7.2.2  jdolecek 				      &reg);
   2134  1.7.2.2  jdolecek 
   2135  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS ||
   2136  1.7.2.2  jdolecek 	    !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
   2137  1.7.2.2  jdolecek 	    IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
   2138  1.7.2.2  jdolecek 		return status;
   2139  1.7.2.2  jdolecek 
   2140  1.7.2.2  jdolecek 	/* Global alarm triggered */
   2141  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
   2142  1.7.2.2  jdolecek 				      IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2143  1.7.2.2  jdolecek 				      &reg);
   2144  1.7.2.2  jdolecek 
   2145  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2146  1.7.2.2  jdolecek 		return status;
   2147  1.7.2.2  jdolecek 
   2148  1.7.2.2  jdolecek 	/* If high temperature failure, then return over temp error and exit */
   2149  1.7.2.2  jdolecek 	if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
   2150  1.7.2.2  jdolecek 		/* power down the PHY in case the PHY FW didn't already */
   2151  1.7.2.2  jdolecek 		ixgbe_set_copper_phy_power(hw, FALSE);
   2152  1.7.2.2  jdolecek 		return IXGBE_ERR_OVERTEMP;
   2153  1.7.2.2  jdolecek 	} else if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
   2154  1.7.2.2  jdolecek 		/*  device fault alarm triggered */
   2155  1.7.2.2  jdolecek 		status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
   2156  1.7.2.2  jdolecek 					  IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2157  1.7.2.2  jdolecek 					  &reg);
   2158  1.7.2.2  jdolecek 
   2159  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   2160  1.7.2.2  jdolecek 			return status;
   2161  1.7.2.2  jdolecek 
   2162  1.7.2.2  jdolecek 		/* if device fault was due to high temp alarm handle and exit */
   2163  1.7.2.2  jdolecek 		if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
   2164  1.7.2.2  jdolecek 			/* power down the PHY in case the PHY FW didn't */
   2165  1.7.2.2  jdolecek 			ixgbe_set_copper_phy_power(hw, FALSE);
   2166  1.7.2.2  jdolecek 			return IXGBE_ERR_OVERTEMP;
   2167  1.7.2.2  jdolecek 		}
   2168  1.7.2.2  jdolecek 	}
   2169  1.7.2.2  jdolecek 
   2170  1.7.2.2  jdolecek 	/* Vendor alarm 2 triggered */
   2171  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
   2172  1.7.2.2  jdolecek 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &reg);
   2173  1.7.2.2  jdolecek 
   2174  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS ||
   2175  1.7.2.2  jdolecek 	    !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
   2176  1.7.2.2  jdolecek 		return status;
   2177  1.7.2.2  jdolecek 
   2178  1.7.2.2  jdolecek 	/* link connect/disconnect event occurred */
   2179  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
   2180  1.7.2.2  jdolecek 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &reg);
   2181  1.7.2.2  jdolecek 
   2182  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2183  1.7.2.2  jdolecek 		return status;
   2184  1.7.2.2  jdolecek 
   2185  1.7.2.2  jdolecek 	/* Indicate LSC */
   2186  1.7.2.2  jdolecek 	if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
   2187  1.7.2.2  jdolecek 		*lsc = TRUE;
   2188  1.7.2.2  jdolecek 
   2189  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   2190  1.7.2.2  jdolecek }
   2191  1.7.2.2  jdolecek 
   2192  1.7.2.2  jdolecek /**
   2193  1.7.2.2  jdolecek  * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
   2194  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   2195  1.7.2.2  jdolecek  *
   2196  1.7.2.2  jdolecek  * Enable link status change and temperature failure alarm for the external
   2197  1.7.2.2  jdolecek  * Base T PHY
   2198  1.7.2.2  jdolecek  *
   2199  1.7.2.2  jdolecek  * Returns PHY access status
   2200  1.7.2.2  jdolecek  */
   2201  1.7.2.2  jdolecek static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
   2202  1.7.2.2  jdolecek {
   2203  1.7.2.2  jdolecek 	u32 status;
   2204  1.7.2.2  jdolecek 	u16 reg;
   2205  1.7.2.2  jdolecek 	bool lsc;
   2206  1.7.2.2  jdolecek 
   2207  1.7.2.2  jdolecek 	/* Clear interrupt flags */
   2208  1.7.2.2  jdolecek 	status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
   2209  1.7.2.2  jdolecek 
   2210  1.7.2.2  jdolecek 	/* Enable link status change alarm */
   2211  1.7.2.2  jdolecek 
   2212  1.7.2.2  jdolecek 	/* Enable the LASI interrupts on X552 devices to receive notifications
   2213  1.7.2.2  jdolecek 	 * of the link configurations of the external PHY and correspondingly
   2214  1.7.2.2  jdolecek 	 * support the configuration of the internal iXFI link, since iXFI does
   2215  1.7.2.2  jdolecek 	 * not support auto-negotiation. This is not required for X553 devices
   2216  1.7.2.2  jdolecek 	 * having KR support, which performs auto-negotiations and which is used
   2217  1.7.2.2  jdolecek 	 * as the internal link to the external PHY. Hence adding a check here
   2218  1.7.2.2  jdolecek 	 * to avoid enabling LASI interrupts for X553 devices.
   2219  1.7.2.2  jdolecek 	 */
   2220  1.7.2.2  jdolecek 	if (hw->mac.type != ixgbe_mac_X550EM_a) {
   2221  1.7.2.2  jdolecek 		status = hw->phy.ops.read_reg(hw,
   2222  1.7.2.2  jdolecek 					IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
   2223  1.7.2.2  jdolecek 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &reg);
   2224  1.7.2.2  jdolecek 
   2225  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   2226  1.7.2.2  jdolecek 			return status;
   2227  1.7.2.2  jdolecek 
   2228  1.7.2.2  jdolecek 		reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
   2229  1.7.2.2  jdolecek 
   2230  1.7.2.2  jdolecek 		status = hw->phy.ops.write_reg(hw,
   2231  1.7.2.2  jdolecek 					IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
   2232  1.7.2.2  jdolecek 				       IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
   2233  1.7.2.2  jdolecek 
   2234  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   2235  1.7.2.2  jdolecek 			return status;
   2236  1.7.2.2  jdolecek 	}
   2237  1.7.2.2  jdolecek 
   2238  1.7.2.2  jdolecek 	/* Enable high temperature failure and global fault alarms */
   2239  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
   2240  1.7.2.2  jdolecek 				      IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2241  1.7.2.2  jdolecek 				      &reg);
   2242  1.7.2.2  jdolecek 
   2243  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2244  1.7.2.2  jdolecek 		return status;
   2245  1.7.2.2  jdolecek 
   2246  1.7.2.2  jdolecek 	reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
   2247  1.7.2.2  jdolecek 		IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
   2248  1.7.2.2  jdolecek 
   2249  1.7.2.2  jdolecek 	status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
   2250  1.7.2.2  jdolecek 				       IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2251  1.7.2.2  jdolecek 				       reg);
   2252  1.7.2.2  jdolecek 
   2253  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2254  1.7.2.2  jdolecek 		return status;
   2255  1.7.2.2  jdolecek 
   2256  1.7.2.2  jdolecek 	/* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
   2257  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
   2258  1.7.2.2  jdolecek 				      IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2259  1.7.2.2  jdolecek 				      &reg);
   2260  1.7.2.2  jdolecek 
   2261  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2262  1.7.2.2  jdolecek 		return status;
   2263  1.7.2.2  jdolecek 
   2264  1.7.2.2  jdolecek 	reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
   2265  1.7.2.2  jdolecek 		IXGBE_MDIO_GLOBAL_ALARM_1_INT);
   2266  1.7.2.2  jdolecek 
   2267  1.7.2.2  jdolecek 	status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
   2268  1.7.2.2  jdolecek 				       IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2269  1.7.2.2  jdolecek 				       reg);
   2270  1.7.2.2  jdolecek 
   2271  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2272  1.7.2.2  jdolecek 		return status;
   2273  1.7.2.2  jdolecek 
   2274  1.7.2.2  jdolecek 	/* Enable chip-wide vendor alarm */
   2275  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
   2276  1.7.2.2  jdolecek 				      IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2277  1.7.2.2  jdolecek 				      &reg);
   2278  1.7.2.2  jdolecek 
   2279  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2280  1.7.2.2  jdolecek 		return status;
   2281  1.7.2.2  jdolecek 
   2282  1.7.2.2  jdolecek 	reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
   2283  1.7.2.2  jdolecek 
   2284  1.7.2.2  jdolecek 	status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
   2285  1.7.2.2  jdolecek 				       IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2286  1.7.2.2  jdolecek 				       reg);
   2287  1.7.2.2  jdolecek 
   2288  1.7.2.2  jdolecek 	return status;
   2289  1.7.2.2  jdolecek }
   2290  1.7.2.2  jdolecek 
   2291  1.7.2.2  jdolecek /**
   2292  1.7.2.2  jdolecek  *  ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
   2293  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2294  1.7.2.2  jdolecek  *  @speed: link speed
   2295  1.7.2.2  jdolecek  *
   2296  1.7.2.2  jdolecek  *  Configures the integrated KR PHY.
   2297  1.7.2.2  jdolecek  **/
   2298  1.7.2.2  jdolecek static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
   2299  1.7.2.2  jdolecek 				       ixgbe_link_speed speed)
   2300  1.7.2.2  jdolecek {
   2301  1.7.2.2  jdolecek 	s32 status;
   2302  1.7.2.2  jdolecek 	u32 reg_val;
   2303  1.7.2.2  jdolecek 
   2304  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   2305  1.7.2.2  jdolecek 		IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   2306  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   2307  1.7.2.2  jdolecek 	if (status)
   2308  1.7.2.2  jdolecek 		return status;
   2309  1.7.2.2  jdolecek 
   2310  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
   2311  1.7.2.2  jdolecek 	reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
   2312  1.7.2.2  jdolecek 		     IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
   2313  1.7.2.2  jdolecek 
   2314  1.7.2.2  jdolecek 	/* Advertise 10G support. */
   2315  1.7.2.2  jdolecek 	if (speed & IXGBE_LINK_SPEED_10GB_FULL)
   2316  1.7.2.2  jdolecek 		reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
   2317  1.7.2.2  jdolecek 
   2318  1.7.2.2  jdolecek 	/* Advertise 1G support. */
   2319  1.7.2.2  jdolecek 	if (speed & IXGBE_LINK_SPEED_1GB_FULL)
   2320  1.7.2.2  jdolecek 		reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
   2321  1.7.2.2  jdolecek 
   2322  1.7.2.2  jdolecek 	status = hw->mac.ops.write_iosf_sb_reg(hw,
   2323  1.7.2.2  jdolecek 		IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   2324  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   2325  1.7.2.2  jdolecek 
   2326  1.7.2.2  jdolecek 	if (hw->mac.type == ixgbe_mac_X550EM_a) {
   2327  1.7.2.2  jdolecek 		/* Set lane mode  to KR auto negotiation */
   2328  1.7.2.2  jdolecek 		status = hw->mac.ops.read_iosf_sb_reg(hw,
   2329  1.7.2.2  jdolecek 				    IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   2330  1.7.2.2  jdolecek 				    IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   2331  1.7.2.2  jdolecek 
   2332  1.7.2.2  jdolecek 		if (status)
   2333  1.7.2.2  jdolecek 			return status;
   2334  1.7.2.2  jdolecek 
   2335  1.7.2.2  jdolecek 		reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
   2336  1.7.2.2  jdolecek 		reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
   2337  1.7.2.2  jdolecek 		reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
   2338  1.7.2.2  jdolecek 		reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
   2339  1.7.2.2  jdolecek 		reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
   2340  1.7.2.2  jdolecek 
   2341  1.7.2.2  jdolecek 		status = hw->mac.ops.write_iosf_sb_reg(hw,
   2342  1.7.2.2  jdolecek 				    IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   2343  1.7.2.2  jdolecek 				    IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   2344  1.7.2.2  jdolecek 	}
   2345  1.7.2.2  jdolecek 
   2346  1.7.2.2  jdolecek 	return ixgbe_restart_an_internal_phy_x550em(hw);
   2347  1.7.2.2  jdolecek }
   2348  1.7.2.2  jdolecek 
   2349  1.7.2.2  jdolecek /**
   2350  1.7.2.2  jdolecek  * ixgbe_reset_phy_fw - Reset firmware-controlled PHYs
   2351  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   2352  1.7.2.2  jdolecek  */
   2353  1.7.2.2  jdolecek static s32 ixgbe_reset_phy_fw(struct ixgbe_hw *hw)
   2354  1.7.2.2  jdolecek {
   2355  1.7.2.2  jdolecek 	u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
   2356  1.7.2.2  jdolecek 	s32 rc;
   2357  1.7.2.2  jdolecek 
   2358  1.7.2.2  jdolecek 	if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
   2359  1.7.2.2  jdolecek 		return IXGBE_SUCCESS;
   2360  1.7.2.2  jdolecek 
   2361  1.7.2.2  jdolecek 	rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_PHY_SW_RESET, &store);
   2362  1.7.2.2  jdolecek 	if (rc)
   2363  1.7.2.2  jdolecek 		return rc;
   2364  1.7.2.2  jdolecek 	memset(store, 0, sizeof(store));
   2365  1.7.2.2  jdolecek 
   2366  1.7.2.2  jdolecek 	rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_INIT_PHY, &store);
   2367  1.7.2.2  jdolecek 	if (rc)
   2368  1.7.2.2  jdolecek 		return rc;
   2369  1.7.2.2  jdolecek 
   2370  1.7.2.2  jdolecek 	return ixgbe_setup_fw_link(hw);
   2371  1.7.2.2  jdolecek }
   2372  1.7.2.2  jdolecek 
   2373  1.7.2.2  jdolecek /**
   2374  1.7.2.2  jdolecek  * ixgbe_check_overtemp_fw - Check firmware-controlled PHYs for overtemp
   2375  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   2376  1.7.2.2  jdolecek  */
   2377  1.7.2.2  jdolecek static s32 ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
   2378  1.7.2.2  jdolecek {
   2379  1.7.2.2  jdolecek 	u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
   2380  1.7.2.2  jdolecek 	s32 rc;
   2381  1.7.2.2  jdolecek 
   2382  1.7.2.2  jdolecek 	rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &store);
   2383  1.7.2.2  jdolecek 	if (rc)
   2384  1.7.2.2  jdolecek 		return rc;
   2385  1.7.2.2  jdolecek 
   2386  1.7.2.2  jdolecek 	if (store[0] & FW_PHY_ACT_GET_LINK_INFO_TEMP) {
   2387  1.7.2.2  jdolecek 		ixgbe_shutdown_fw_phy(hw);
   2388  1.7.2.2  jdolecek 		return IXGBE_ERR_OVERTEMP;
   2389  1.7.2.2  jdolecek 	}
   2390  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   2391  1.7.2.2  jdolecek }
   2392  1.7.2.2  jdolecek 
   2393  1.7.2.2  jdolecek /**
   2394  1.7.2.2  jdolecek  *  ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
   2395  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2396  1.7.2.2  jdolecek  *
   2397  1.7.2.2  jdolecek  *  Read NW_MNG_IF_SEL register and save field values, and check for valid field
   2398  1.7.2.2  jdolecek  *  values.
   2399  1.7.2.2  jdolecek  **/
   2400  1.7.2.2  jdolecek static s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
   2401  1.7.2.2  jdolecek {
   2402  1.7.2.2  jdolecek 	/* Save NW management interface connected on board. This is used
   2403  1.7.2.2  jdolecek 	 * to determine internal PHY mode.
   2404  1.7.2.2  jdolecek 	 */
   2405  1.7.2.2  jdolecek 	hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
   2406  1.7.2.2  jdolecek 
   2407  1.7.2.2  jdolecek 	/* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
   2408  1.7.2.2  jdolecek 	 * PHY address. This register field was has only been used for X552.
   2409  1.7.2.2  jdolecek 	 */
   2410  1.7.2.2  jdolecek 	if (hw->mac.type == ixgbe_mac_X550EM_a &&
   2411  1.7.2.2  jdolecek 	    hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
   2412  1.7.2.2  jdolecek 		hw->phy.addr = (hw->phy.nw_mng_if_sel &
   2413  1.7.2.2  jdolecek 				IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
   2414  1.7.2.2  jdolecek 			       IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
   2415  1.7.2.2  jdolecek 	}
   2416  1.7.2.2  jdolecek 
   2417  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   2418  1.7.2.2  jdolecek }
   2419  1.7.2.2  jdolecek 
   2420  1.7.2.2  jdolecek /**
   2421  1.7.2.2  jdolecek  *  ixgbe_init_phy_ops_X550em - PHY/SFP specific init
   2422  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2423  1.7.2.2  jdolecek  *
   2424  1.7.2.2  jdolecek  *  Initialize any function pointers that were not able to be
   2425  1.7.2.2  jdolecek  *  set during init_shared_code because the PHY/SFP type was
   2426  1.7.2.2  jdolecek  *  not known.  Perform the SFP init if necessary.
   2427  1.7.2.2  jdolecek  */
   2428  1.7.2.2  jdolecek s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
   2429  1.7.2.2  jdolecek {
   2430  1.7.2.2  jdolecek 	struct ixgbe_phy_info *phy = &hw->phy;
   2431  1.7.2.2  jdolecek 	s32 ret_val;
   2432  1.7.2.2  jdolecek 
   2433  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_init_phy_ops_X550em");
   2434  1.7.2.2  jdolecek 
   2435  1.7.2.2  jdolecek 	hw->mac.ops.set_lan_id(hw);
   2436  1.7.2.2  jdolecek 	ixgbe_read_mng_if_sel_x550em(hw);
   2437  1.7.2.2  jdolecek 
   2438  1.7.2.2  jdolecek 	if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
   2439  1.7.2.2  jdolecek 		phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
   2440  1.7.2.2  jdolecek 		ixgbe_setup_mux_ctl(hw);
   2441  1.7.2.2  jdolecek 		phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
   2442  1.7.2.2  jdolecek 	}
   2443  1.7.2.2  jdolecek 
   2444  1.7.2.2  jdolecek 	switch (hw->device_id) {
   2445  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T:
   2446  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T_L:
   2447  1.7.2.2  jdolecek 		phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi_22;
   2448  1.7.2.2  jdolecek 		phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi_22;
   2449  1.7.2.2  jdolecek 		hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
   2450  1.7.2.2  jdolecek 		hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
   2451  1.7.2.2  jdolecek 		phy->ops.check_overtemp = ixgbe_check_overtemp_fw;
   2452  1.7.2.2  jdolecek 		if (hw->bus.lan_id)
   2453  1.7.2.2  jdolecek 			hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
   2454  1.7.2.2  jdolecek 		else
   2455  1.7.2.2  jdolecek 			hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
   2456  1.7.2.2  jdolecek 
   2457  1.7.2.2  jdolecek 		break;
   2458  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_10G_T:
   2459  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SFP:
   2460  1.7.2.2  jdolecek 		hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
   2461  1.7.2.2  jdolecek 		hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
   2462  1.7.2.2  jdolecek 		if (hw->bus.lan_id)
   2463  1.7.2.2  jdolecek 			hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
   2464  1.7.2.2  jdolecek 		else
   2465  1.7.2.2  jdolecek 			hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
   2466  1.7.2.2  jdolecek 		break;
   2467  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_SFP:
   2468  1.7.2.2  jdolecek 		/* set up for CS4227 usage */
   2469  1.7.2.2  jdolecek 		hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
   2470  1.7.2.2  jdolecek 		break;
   2471  1.7.2.2  jdolecek 	default:
   2472  1.7.2.2  jdolecek 		break;
   2473  1.7.2.2  jdolecek 	}
   2474  1.7.2.2  jdolecek 
   2475  1.7.2.2  jdolecek 	/* Identify the PHY or SFP module */
   2476  1.7.2.2  jdolecek 	ret_val = phy->ops.identify(hw);
   2477  1.7.2.2  jdolecek 	if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED ||
   2478  1.7.2.2  jdolecek 	    ret_val == IXGBE_ERR_PHY_ADDR_INVALID)
   2479  1.7.2.2  jdolecek 		return ret_val;
   2480  1.7.2.2  jdolecek 
   2481  1.7.2.2  jdolecek 	/* Setup function pointers based on detected hardware */
   2482  1.7.2.2  jdolecek 	ixgbe_init_mac_link_ops_X550em(hw);
   2483  1.7.2.2  jdolecek 	if (phy->sfp_type != ixgbe_sfp_type_unknown)
   2484  1.7.2.2  jdolecek 		phy->ops.reset = NULL;
   2485  1.7.2.2  jdolecek 
   2486  1.7.2.2  jdolecek 	/* Set functions pointers based on phy type */
   2487  1.7.2.2  jdolecek 	switch (hw->phy.type) {
   2488  1.7.2.2  jdolecek 	case ixgbe_phy_x550em_kx4:
   2489  1.7.2.2  jdolecek 		phy->ops.setup_link = NULL;
   2490  1.7.2.2  jdolecek 		phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
   2491  1.7.2.2  jdolecek 		phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
   2492  1.7.2.2  jdolecek 		break;
   2493  1.7.2.2  jdolecek 	case ixgbe_phy_x550em_kr:
   2494  1.7.2.2  jdolecek 		phy->ops.setup_link = ixgbe_setup_kr_x550em;
   2495  1.7.2.2  jdolecek 		phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
   2496  1.7.2.2  jdolecek 		phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
   2497  1.7.2.2  jdolecek 		break;
   2498  1.7.2.2  jdolecek 	case ixgbe_phy_ext_1g_t:
   2499  1.7.2.2  jdolecek 		/* link is managed by FW */
   2500  1.7.2.2  jdolecek 		phy->ops.setup_link = NULL;
   2501  1.7.2.2  jdolecek 		phy->ops.reset = NULL;
   2502  1.7.2.2  jdolecek 		break;
   2503  1.7.2.2  jdolecek 	case ixgbe_phy_x550em_xfi:
   2504  1.7.2.2  jdolecek 		/* link is managed by HW */
   2505  1.7.2.2  jdolecek 		phy->ops.setup_link = NULL;
   2506  1.7.2.2  jdolecek 		phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
   2507  1.7.2.2  jdolecek 		phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
   2508  1.7.2.2  jdolecek 		break;
   2509  1.7.2.2  jdolecek 	case ixgbe_phy_x550em_ext_t:
   2510  1.7.2.2  jdolecek 		/* If internal link mode is XFI, then setup iXFI internal link,
   2511  1.7.2.2  jdolecek 		 * else setup KR now.
   2512  1.7.2.2  jdolecek 		 */
   2513  1.7.2.2  jdolecek 		phy->ops.setup_internal_link =
   2514  1.7.2.2  jdolecek 					      ixgbe_setup_internal_phy_t_x550em;
   2515  1.7.2.2  jdolecek 
   2516  1.7.2.2  jdolecek 		/* setup SW LPLU only for first revision of X550EM_x */
   2517  1.7.2.2  jdolecek 		if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
   2518  1.7.2.2  jdolecek 		    !(IXGBE_FUSES0_REV_MASK &
   2519  1.7.2.2  jdolecek 		      IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
   2520  1.7.2.2  jdolecek 			phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
   2521  1.7.2.2  jdolecek 
   2522  1.7.2.2  jdolecek 		phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
   2523  1.7.2.2  jdolecek 		phy->ops.reset = ixgbe_reset_phy_t_X550em;
   2524  1.7.2.2  jdolecek 		break;
   2525  1.7.2.2  jdolecek 	case ixgbe_phy_sgmii:
   2526  1.7.2.2  jdolecek 		phy->ops.setup_link = NULL;
   2527  1.7.2.2  jdolecek 		break;
   2528  1.7.2.2  jdolecek 	case ixgbe_phy_fw:
   2529  1.7.2.2  jdolecek 		phy->ops.setup_link = ixgbe_setup_fw_link;
   2530  1.7.2.2  jdolecek 		phy->ops.reset = ixgbe_reset_phy_fw;
   2531  1.7.2.2  jdolecek 		break;
   2532  1.7.2.2  jdolecek 	default:
   2533  1.7.2.2  jdolecek 		break;
   2534  1.7.2.2  jdolecek 	}
   2535  1.7.2.2  jdolecek 	return ret_val;
   2536  1.7.2.2  jdolecek }
   2537  1.7.2.2  jdolecek 
   2538  1.7.2.2  jdolecek /**
   2539  1.7.2.2  jdolecek  * ixgbe_set_mdio_speed - Set MDIO clock speed
   2540  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2541  1.7.2.2  jdolecek  */
   2542  1.7.2.2  jdolecek static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
   2543  1.7.2.2  jdolecek {
   2544  1.7.2.2  jdolecek 	u32 hlreg0;
   2545  1.7.2.2  jdolecek 
   2546  1.7.2.2  jdolecek 	switch (hw->device_id) {
   2547  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_10G_T:
   2548  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SGMII:
   2549  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SGMII_L:
   2550  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_10G_T:
   2551  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_SFP:
   2552  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_QSFP:
   2553  1.7.2.2  jdolecek 		/* Config MDIO clock speed before the first MDIO PHY access */
   2554  1.7.2.2  jdolecek 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
   2555  1.7.2.2  jdolecek 		hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
   2556  1.7.2.2  jdolecek 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
   2557  1.7.2.2  jdolecek 		break;
   2558  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T:
   2559  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_1G_T_L:
   2560  1.7.2.2  jdolecek 		/* Select fast MDIO clock speed for these devices */
   2561  1.7.2.2  jdolecek 		hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
   2562  1.7.2.2  jdolecek 		hlreg0 |= IXGBE_HLREG0_MDCSPD;
   2563  1.7.2.2  jdolecek 		IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
   2564  1.7.2.2  jdolecek 		break;
   2565  1.7.2.2  jdolecek 	default:
   2566  1.7.2.2  jdolecek 		break;
   2567  1.7.2.2  jdolecek 	}
   2568  1.7.2.2  jdolecek }
   2569  1.7.2.2  jdolecek 
   2570  1.7.2.2  jdolecek /**
   2571  1.7.2.2  jdolecek  *  ixgbe_reset_hw_X550em - Perform hardware reset
   2572  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2573  1.7.2.2  jdolecek  *
   2574  1.7.2.2  jdolecek  *  Resets the hardware by resetting the transmit and receive units, masks
   2575  1.7.2.2  jdolecek  *  and clears all interrupts, perform a PHY reset, and perform a link (MAC)
   2576  1.7.2.2  jdolecek  *  reset.
   2577  1.7.2.2  jdolecek  */
   2578  1.7.2.2  jdolecek s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
   2579  1.7.2.2  jdolecek {
   2580  1.7.2.2  jdolecek 	ixgbe_link_speed link_speed;
   2581  1.7.2.2  jdolecek 	s32 status;
   2582  1.7.2.2  jdolecek 	u32 ctrl = 0;
   2583  1.7.2.2  jdolecek 	u32 i;
   2584  1.7.2.2  jdolecek 	bool link_up = FALSE;
   2585  1.7.2.2  jdolecek 	u32 swfw_mask = hw->phy.phy_semaphore_mask;
   2586  1.7.2.2  jdolecek 
   2587  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_reset_hw_X550em");
   2588  1.7.2.2  jdolecek 
   2589  1.7.2.2  jdolecek 	/* Call adapter stop to disable Tx/Rx and clear interrupts */
   2590  1.7.2.2  jdolecek 	status = hw->mac.ops.stop_adapter(hw);
   2591  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS) {
   2592  1.7.2.2  jdolecek 		DEBUGOUT1("Failed to stop adapter, STATUS = %d\n", status);
   2593  1.7.2.2  jdolecek 		return status;
   2594  1.7.2.2  jdolecek 	}
   2595  1.7.2.2  jdolecek 	/* flush pending Tx transactions */
   2596  1.7.2.2  jdolecek 	ixgbe_clear_tx_pending(hw);
   2597  1.7.2.2  jdolecek 
   2598  1.7.2.2  jdolecek 	ixgbe_set_mdio_speed(hw);
   2599  1.7.2.2  jdolecek 
   2600  1.7.2.2  jdolecek 	/* PHY ops must be identified and initialized prior to reset */
   2601  1.7.2.2  jdolecek 	status = hw->phy.ops.init(hw);
   2602  1.7.2.2  jdolecek 
   2603  1.7.2.2  jdolecek 	if (status)
   2604  1.7.2.2  jdolecek 		DEBUGOUT1("Failed to initialize PHY ops, STATUS = %d\n",
   2605  1.7.2.2  jdolecek 			  status);
   2606  1.7.2.2  jdolecek 
   2607  1.7.2.2  jdolecek 	if (status == IXGBE_ERR_SFP_NOT_SUPPORTED) {
   2608  1.7.2.2  jdolecek 		DEBUGOUT("Returning from reset HW due to PHY init failure\n");
   2609  1.7.2.2  jdolecek 		return status;
   2610  1.7.2.2  jdolecek 	}
   2611  1.7.2.2  jdolecek 
   2612  1.7.2.2  jdolecek 	/* start the external PHY */
   2613  1.7.2.2  jdolecek 	if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
   2614  1.7.2.2  jdolecek 		status = ixgbe_init_ext_t_x550em(hw);
   2615  1.7.2.2  jdolecek 		if (status) {
   2616  1.7.2.2  jdolecek 			DEBUGOUT1("Failed to start the external PHY, STATUS = %d\n",
   2617  1.7.2.2  jdolecek 				  status);
   2618  1.7.2.2  jdolecek 			return status;
   2619  1.7.2.2  jdolecek 		}
   2620  1.7.2.2  jdolecek 	}
   2621  1.7.2.2  jdolecek 
   2622  1.7.2.2  jdolecek 	/* Setup SFP module if there is one present. */
   2623  1.7.2.2  jdolecek 	if (hw->phy.sfp_setup_needed) {
   2624  1.7.2.2  jdolecek 		status = hw->mac.ops.setup_sfp(hw);
   2625  1.7.2.2  jdolecek 		hw->phy.sfp_setup_needed = FALSE;
   2626  1.7.2.2  jdolecek 	}
   2627  1.7.2.2  jdolecek 
   2628  1.7.2.2  jdolecek 	if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
   2629  1.7.2.2  jdolecek 		return status;
   2630  1.7.2.2  jdolecek 
   2631  1.7.2.2  jdolecek 	/* Reset PHY */
   2632  1.7.2.2  jdolecek 	if (!hw->phy.reset_disable && hw->phy.ops.reset) {
   2633  1.7.2.2  jdolecek 		if (hw->phy.ops.reset(hw) == IXGBE_ERR_OVERTEMP)
   2634  1.7.2.2  jdolecek 			return IXGBE_ERR_OVERTEMP;
   2635  1.7.2.2  jdolecek 	}
   2636  1.7.2.2  jdolecek 
   2637  1.7.2.2  jdolecek mac_reset_top:
   2638  1.7.2.2  jdolecek 	/* Issue global reset to the MAC.  Needs to be SW reset if link is up.
   2639  1.7.2.2  jdolecek 	 * If link reset is used when link is up, it might reset the PHY when
   2640  1.7.2.2  jdolecek 	 * mng is using it.  If link is down or the flag to force full link
   2641  1.7.2.2  jdolecek 	 * reset is set, then perform link reset.
   2642  1.7.2.2  jdolecek 	 */
   2643  1.7.2.2  jdolecek 	ctrl = IXGBE_CTRL_LNK_RST;
   2644  1.7.2.2  jdolecek 	if (!hw->force_full_reset) {
   2645  1.7.2.2  jdolecek 		hw->mac.ops.check_link(hw, &link_speed, &link_up, FALSE);
   2646  1.7.2.2  jdolecek 		if (link_up)
   2647  1.7.2.2  jdolecek 			ctrl = IXGBE_CTRL_RST;
   2648  1.7.2.2  jdolecek 	}
   2649  1.7.2.2  jdolecek 
   2650  1.7.2.2  jdolecek 	status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
   2651  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS) {
   2652  1.7.2.2  jdolecek 		ERROR_REPORT2(IXGBE_ERROR_CAUTION,
   2653  1.7.2.2  jdolecek 			"semaphore failed with %d", status);
   2654  1.7.2.2  jdolecek 		return IXGBE_ERR_SWFW_SYNC;
   2655  1.7.2.2  jdolecek 	}
   2656  1.7.2.2  jdolecek 	ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
   2657  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
   2658  1.7.2.2  jdolecek 	IXGBE_WRITE_FLUSH(hw);
   2659  1.7.2.2  jdolecek 	hw->mac.ops.release_swfw_sync(hw, swfw_mask);
   2660  1.7.2.2  jdolecek 
   2661  1.7.2.2  jdolecek 	/* Poll for reset bit to self-clear meaning reset is complete */
   2662  1.7.2.2  jdolecek 	for (i = 0; i < 10; i++) {
   2663  1.7.2.2  jdolecek 		usec_delay(1);
   2664  1.7.2.2  jdolecek 		ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
   2665  1.7.2.2  jdolecek 		if (!(ctrl & IXGBE_CTRL_RST_MASK))
   2666  1.7.2.2  jdolecek 			break;
   2667  1.7.2.2  jdolecek 	}
   2668  1.7.2.2  jdolecek 
   2669  1.7.2.2  jdolecek 	if (ctrl & IXGBE_CTRL_RST_MASK) {
   2670  1.7.2.2  jdolecek 		status = IXGBE_ERR_RESET_FAILED;
   2671  1.7.2.2  jdolecek 		DEBUGOUT("Reset polling failed to complete.\n");
   2672  1.7.2.2  jdolecek 	}
   2673  1.7.2.2  jdolecek 
   2674  1.7.2.2  jdolecek 	msec_delay(50);
   2675  1.7.2.2  jdolecek 
   2676  1.7.2.2  jdolecek 	/* Double resets are required for recovery from certain error
   2677  1.7.2.2  jdolecek 	 * conditions.  Between resets, it is necessary to stall to
   2678  1.7.2.2  jdolecek 	 * allow time for any pending HW events to complete.
   2679  1.7.2.2  jdolecek 	 */
   2680  1.7.2.2  jdolecek 	if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
   2681  1.7.2.2  jdolecek 		hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
   2682  1.7.2.2  jdolecek 		goto mac_reset_top;
   2683  1.7.2.2  jdolecek 	}
   2684  1.7.2.2  jdolecek 
   2685  1.7.2.2  jdolecek 	/* Store the permanent mac address */
   2686  1.7.2.2  jdolecek 	hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
   2687  1.7.2.2  jdolecek 
   2688  1.7.2.2  jdolecek 	/* Store MAC address from RAR0, clear receive address registers, and
   2689  1.7.2.2  jdolecek 	 * clear the multicast table.  Also reset num_rar_entries to 128,
   2690  1.7.2.2  jdolecek 	 * since we modify this value when programming the SAN MAC address.
   2691  1.7.2.2  jdolecek 	 */
   2692  1.7.2.2  jdolecek 	hw->mac.num_rar_entries = 128;
   2693  1.7.2.2  jdolecek 	hw->mac.ops.init_rx_addrs(hw);
   2694  1.7.2.2  jdolecek 
   2695  1.7.2.2  jdolecek 	ixgbe_set_mdio_speed(hw);
   2696  1.7.2.2  jdolecek 
   2697  1.7.2.2  jdolecek 	if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
   2698  1.7.2.2  jdolecek 		ixgbe_setup_mux_ctl(hw);
   2699  1.7.2.2  jdolecek 
   2700  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2701  1.7.2.2  jdolecek 		DEBUGOUT1("Reset HW failed, STATUS = %d\n", status);
   2702  1.7.2.2  jdolecek 
   2703  1.7.2.2  jdolecek 	return status;
   2704  1.7.2.2  jdolecek }
   2705  1.7.2.2  jdolecek 
   2706  1.7.2.2  jdolecek /**
   2707  1.7.2.2  jdolecek  * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
   2708  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   2709  1.7.2.2  jdolecek  */
   2710  1.7.2.2  jdolecek s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
   2711  1.7.2.2  jdolecek {
   2712  1.7.2.2  jdolecek 	u32 status;
   2713  1.7.2.2  jdolecek 	u16 reg;
   2714  1.7.2.2  jdolecek 
   2715  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw,
   2716  1.7.2.2  jdolecek 				      IXGBE_MDIO_TX_VENDOR_ALARMS_3,
   2717  1.7.2.2  jdolecek 				      IXGBE_MDIO_PMA_PMD_DEV_TYPE,
   2718  1.7.2.2  jdolecek 				      &reg);
   2719  1.7.2.2  jdolecek 
   2720  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2721  1.7.2.2  jdolecek 		return status;
   2722  1.7.2.2  jdolecek 
   2723  1.7.2.2  jdolecek 	/* If PHY FW reset completed bit is set then this is the first
   2724  1.7.2.2  jdolecek 	 * SW instance after a power on so the PHY FW must be un-stalled.
   2725  1.7.2.2  jdolecek 	 */
   2726  1.7.2.2  jdolecek 	if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
   2727  1.7.2.2  jdolecek 		status = hw->phy.ops.read_reg(hw,
   2728  1.7.2.2  jdolecek 					IXGBE_MDIO_GLOBAL_RES_PR_10,
   2729  1.7.2.2  jdolecek 					IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2730  1.7.2.2  jdolecek 					&reg);
   2731  1.7.2.2  jdolecek 
   2732  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   2733  1.7.2.2  jdolecek 			return status;
   2734  1.7.2.2  jdolecek 
   2735  1.7.2.2  jdolecek 		reg &= ~IXGBE_MDIO_POWER_UP_STALL;
   2736  1.7.2.2  jdolecek 
   2737  1.7.2.2  jdolecek 		status = hw->phy.ops.write_reg(hw,
   2738  1.7.2.2  jdolecek 					IXGBE_MDIO_GLOBAL_RES_PR_10,
   2739  1.7.2.2  jdolecek 					IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
   2740  1.7.2.2  jdolecek 					reg);
   2741  1.7.2.2  jdolecek 
   2742  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   2743  1.7.2.2  jdolecek 			return status;
   2744  1.7.2.2  jdolecek 	}
   2745  1.7.2.2  jdolecek 
   2746  1.7.2.2  jdolecek 	return status;
   2747  1.7.2.2  jdolecek }
   2748  1.7.2.2  jdolecek 
   2749  1.7.2.2  jdolecek /**
   2750  1.7.2.2  jdolecek  *  ixgbe_setup_kr_x550em - Configure the KR PHY.
   2751  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2752  1.7.2.2  jdolecek  **/
   2753  1.7.2.2  jdolecek s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
   2754  1.7.2.2  jdolecek {
   2755  1.7.2.2  jdolecek 	/* leave link alone for 2.5G */
   2756  1.7.2.2  jdolecek 	if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
   2757  1.7.2.2  jdolecek 		return IXGBE_SUCCESS;
   2758  1.7.2.2  jdolecek 
   2759  1.7.2.2  jdolecek 	if (ixgbe_check_reset_blocked(hw))
   2760  1.7.2.2  jdolecek 		return 0;
   2761  1.7.2.2  jdolecek 
   2762  1.7.2.2  jdolecek 	return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
   2763  1.7.2.2  jdolecek }
   2764  1.7.2.2  jdolecek 
   2765  1.7.2.2  jdolecek /**
   2766  1.7.2.2  jdolecek  *  ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
   2767  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2768  1.7.2.2  jdolecek  *
   2769  1.7.2.2  jdolecek  *  Configure the external PHY and the integrated KR PHY for SFP support.
   2770  1.7.2.2  jdolecek  **/
   2771  1.7.2.2  jdolecek s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
   2772  1.7.2.2  jdolecek 				    ixgbe_link_speed speed,
   2773  1.7.2.2  jdolecek 				    bool autoneg_wait_to_complete)
   2774  1.7.2.2  jdolecek {
   2775  1.7.2.2  jdolecek 	s32 ret_val;
   2776  1.7.2.2  jdolecek 	u16 reg_slice, reg_val;
   2777  1.7.2.2  jdolecek 	bool setup_linear = FALSE;
   2778  1.7.2.2  jdolecek 	UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
   2779  1.7.2.2  jdolecek 
   2780  1.7.2.2  jdolecek 	/* Check if SFP module is supported and linear */
   2781  1.7.2.2  jdolecek 	ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
   2782  1.7.2.2  jdolecek 
   2783  1.7.2.2  jdolecek 	/* If no SFP module present, then return success. Return success since
   2784  1.7.2.2  jdolecek 	 * there is no reason to configure CS4227 and SFP not present error is
   2785  1.7.2.2  jdolecek 	 * not excepted in the setup MAC link flow.
   2786  1.7.2.2  jdolecek 	 */
   2787  1.7.2.2  jdolecek 	if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
   2788  1.7.2.2  jdolecek 		return IXGBE_SUCCESS;
   2789  1.7.2.2  jdolecek 
   2790  1.7.2.2  jdolecek 	if (ret_val != IXGBE_SUCCESS)
   2791  1.7.2.2  jdolecek 		return ret_val;
   2792  1.7.2.2  jdolecek 
   2793  1.7.2.2  jdolecek 	/* Configure internal PHY for KR/KX. */
   2794  1.7.2.2  jdolecek 	ixgbe_setup_kr_speed_x550em(hw, speed);
   2795  1.7.2.2  jdolecek 
   2796  1.7.2.2  jdolecek 	/* Configure CS4227 LINE side to proper mode. */
   2797  1.7.2.2  jdolecek 	reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
   2798  1.7.2.2  jdolecek 		    (hw->bus.lan_id << 12);
   2799  1.7.2.2  jdolecek 	if (setup_linear)
   2800  1.7.2.2  jdolecek 		reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
   2801  1.7.2.2  jdolecek 	else
   2802  1.7.2.2  jdolecek 		reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
   2803  1.7.2.2  jdolecek 	ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
   2804  1.7.2.2  jdolecek 					  reg_val);
   2805  1.7.2.2  jdolecek 	return ret_val;
   2806  1.7.2.2  jdolecek }
   2807  1.7.2.2  jdolecek 
   2808  1.7.2.2  jdolecek /**
   2809  1.7.2.2  jdolecek  *  ixgbe_setup_sfi_x550a - Configure the internal PHY for native SFI mode
   2810  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2811  1.7.2.2  jdolecek  *  @speed: the link speed to force
   2812  1.7.2.2  jdolecek  *
   2813  1.7.2.2  jdolecek  *  Configures the integrated PHY for native SFI mode. Used to connect the
   2814  1.7.2.2  jdolecek  *  internal PHY directly to an SFP cage, without autonegotiation.
   2815  1.7.2.2  jdolecek  **/
   2816  1.7.2.2  jdolecek static s32 ixgbe_setup_sfi_x550a(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
   2817  1.7.2.2  jdolecek {
   2818  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
   2819  1.7.2.2  jdolecek 	s32 status;
   2820  1.7.2.2  jdolecek 	u32 reg_val;
   2821  1.7.2.2  jdolecek 
   2822  1.7.2.2  jdolecek 	/* Disable all AN and force speed to 10G Serial. */
   2823  1.7.2.2  jdolecek 	status = mac->ops.read_iosf_sb_reg(hw,
   2824  1.7.2.2  jdolecek 				IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   2825  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   2826  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2827  1.7.2.2  jdolecek 		return status;
   2828  1.7.2.2  jdolecek 
   2829  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
   2830  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
   2831  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
   2832  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
   2833  1.7.2.2  jdolecek 
   2834  1.7.2.2  jdolecek 	/* Select forced link speed for internal PHY. */
   2835  1.7.2.2  jdolecek 	switch (*speed) {
   2836  1.7.2.2  jdolecek 	case IXGBE_LINK_SPEED_10GB_FULL:
   2837  1.7.2.2  jdolecek 		reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_10G;
   2838  1.7.2.2  jdolecek 		break;
   2839  1.7.2.2  jdolecek 	case IXGBE_LINK_SPEED_1GB_FULL:
   2840  1.7.2.2  jdolecek 		reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
   2841  1.7.2.2  jdolecek 		break;
   2842  1.7.2.2  jdolecek 	default:
   2843  1.7.2.2  jdolecek 		/* Other link speeds are not supported by internal PHY. */
   2844  1.7.2.2  jdolecek 		return IXGBE_ERR_LINK_SETUP;
   2845  1.7.2.2  jdolecek 	}
   2846  1.7.2.2  jdolecek 
   2847  1.7.2.2  jdolecek 	status = mac->ops.write_iosf_sb_reg(hw,
   2848  1.7.2.2  jdolecek 				IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   2849  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   2850  1.7.2.2  jdolecek 
   2851  1.7.2.2  jdolecek 	/* Toggle port SW reset by AN reset. */
   2852  1.7.2.2  jdolecek 	status = ixgbe_restart_an_internal_phy_x550em(hw);
   2853  1.7.2.2  jdolecek 
   2854  1.7.2.2  jdolecek 	return status;
   2855  1.7.2.2  jdolecek }
   2856  1.7.2.2  jdolecek 
   2857  1.7.2.2  jdolecek /**
   2858  1.7.2.2  jdolecek  *  ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
   2859  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2860  1.7.2.2  jdolecek  *
   2861  1.7.2.2  jdolecek  *  Configure the the integrated PHY for SFP support.
   2862  1.7.2.2  jdolecek  **/
   2863  1.7.2.2  jdolecek s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
   2864  1.7.2.2  jdolecek 				    ixgbe_link_speed speed,
   2865  1.7.2.2  jdolecek 				    bool autoneg_wait_to_complete)
   2866  1.7.2.2  jdolecek {
   2867  1.7.2.2  jdolecek 	s32 ret_val;
   2868  1.7.2.2  jdolecek 	u16 reg_phy_ext;
   2869  1.7.2.2  jdolecek 	bool setup_linear = FALSE;
   2870  1.7.2.2  jdolecek 	u32 reg_slice, reg_phy_int, slice_offset;
   2871  1.7.2.2  jdolecek 
   2872  1.7.2.2  jdolecek 	UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
   2873  1.7.2.2  jdolecek 
   2874  1.7.2.2  jdolecek 	/* Check if SFP module is supported and linear */
   2875  1.7.2.2  jdolecek 	ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
   2876  1.7.2.2  jdolecek 
   2877  1.7.2.2  jdolecek 	/* If no SFP module present, then return success. Return success since
   2878  1.7.2.2  jdolecek 	 * SFP not present error is not excepted in the setup MAC link flow.
   2879  1.7.2.2  jdolecek 	 */
   2880  1.7.2.2  jdolecek 	if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
   2881  1.7.2.2  jdolecek 		return IXGBE_SUCCESS;
   2882  1.7.2.2  jdolecek 
   2883  1.7.2.2  jdolecek 	if (ret_val != IXGBE_SUCCESS)
   2884  1.7.2.2  jdolecek 		return ret_val;
   2885  1.7.2.2  jdolecek 
   2886  1.7.2.2  jdolecek 	if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) {
   2887  1.7.2.2  jdolecek 		/* Configure internal PHY for native SFI based on module type */
   2888  1.7.2.2  jdolecek 		ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
   2889  1.7.2.2  jdolecek 				   IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   2890  1.7.2.2  jdolecek 				   IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_phy_int);
   2891  1.7.2.2  jdolecek 
   2892  1.7.2.2  jdolecek 		if (ret_val != IXGBE_SUCCESS)
   2893  1.7.2.2  jdolecek 			return ret_val;
   2894  1.7.2.2  jdolecek 
   2895  1.7.2.2  jdolecek 		reg_phy_int &= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_DA;
   2896  1.7.2.2  jdolecek 		if (!setup_linear)
   2897  1.7.2.2  jdolecek 			reg_phy_int |= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_SR;
   2898  1.7.2.2  jdolecek 
   2899  1.7.2.2  jdolecek 		ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
   2900  1.7.2.2  jdolecek 				   IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
   2901  1.7.2.2  jdolecek 				   IXGBE_SB_IOSF_TARGET_KR_PHY, reg_phy_int);
   2902  1.7.2.2  jdolecek 
   2903  1.7.2.2  jdolecek 		if (ret_val != IXGBE_SUCCESS)
   2904  1.7.2.2  jdolecek 			return ret_val;
   2905  1.7.2.2  jdolecek 
   2906  1.7.2.2  jdolecek 		/* Setup SFI internal link. */
   2907  1.7.2.2  jdolecek 		ret_val = ixgbe_setup_sfi_x550a(hw, &speed);
   2908  1.7.2.2  jdolecek 	} else {
   2909  1.7.2.2  jdolecek 		/* Configure internal PHY for KR/KX. */
   2910  1.7.2.2  jdolecek 		ixgbe_setup_kr_speed_x550em(hw, speed);
   2911  1.7.2.2  jdolecek 
   2912  1.7.2.2  jdolecek 		if (hw->phy.addr == 0x0 || hw->phy.addr == 0xFFFF) {
   2913  1.7.2.2  jdolecek 			/* Find Address */
   2914  1.7.2.2  jdolecek 			DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
   2915  1.7.2.2  jdolecek 			return IXGBE_ERR_PHY_ADDR_INVALID;
   2916  1.7.2.2  jdolecek 		}
   2917  1.7.2.2  jdolecek 
   2918  1.7.2.2  jdolecek 		/* Get external PHY SKU id */
   2919  1.7.2.2  jdolecek 		ret_val = hw->phy.ops.read_reg(hw, IXGBE_CS4227_EFUSE_PDF_SKU,
   2920  1.7.2.2  jdolecek 					IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
   2921  1.7.2.2  jdolecek 
   2922  1.7.2.2  jdolecek 		if (ret_val != IXGBE_SUCCESS)
   2923  1.7.2.2  jdolecek 			return ret_val;
   2924  1.7.2.2  jdolecek 
   2925  1.7.2.2  jdolecek 		/* When configuring quad port CS4223, the MAC instance is part
   2926  1.7.2.2  jdolecek 		 * of the slice offset.
   2927  1.7.2.2  jdolecek 		 */
   2928  1.7.2.2  jdolecek 		if (reg_phy_ext == IXGBE_CS4223_SKU_ID)
   2929  1.7.2.2  jdolecek 			slice_offset = (hw->bus.lan_id +
   2930  1.7.2.2  jdolecek 					(hw->bus.instance_id << 1)) << 12;
   2931  1.7.2.2  jdolecek 		else
   2932  1.7.2.2  jdolecek 			slice_offset = hw->bus.lan_id << 12;
   2933  1.7.2.2  jdolecek 
   2934  1.7.2.2  jdolecek 		/* Configure CS4227/CS4223 LINE side to proper mode. */
   2935  1.7.2.2  jdolecek 		reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
   2936  1.7.2.2  jdolecek 
   2937  1.7.2.2  jdolecek 		ret_val = hw->phy.ops.read_reg(hw, reg_slice,
   2938  1.7.2.2  jdolecek 					IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
   2939  1.7.2.2  jdolecek 
   2940  1.7.2.2  jdolecek 		if (ret_val != IXGBE_SUCCESS)
   2941  1.7.2.2  jdolecek 			return ret_val;
   2942  1.7.2.2  jdolecek 
   2943  1.7.2.2  jdolecek 		reg_phy_ext &= ~((IXGBE_CS4227_EDC_MODE_CX1 << 1) |
   2944  1.7.2.2  jdolecek 				 (IXGBE_CS4227_EDC_MODE_SR << 1));
   2945  1.7.2.2  jdolecek 
   2946  1.7.2.2  jdolecek 		if (setup_linear)
   2947  1.7.2.2  jdolecek 			reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
   2948  1.7.2.2  jdolecek 		else
   2949  1.7.2.2  jdolecek 			reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
   2950  1.7.2.2  jdolecek 		ret_val = hw->phy.ops.write_reg(hw, reg_slice,
   2951  1.7.2.2  jdolecek 					 IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
   2952  1.7.2.2  jdolecek 
   2953  1.7.2.2  jdolecek 		/* Flush previous write with a read */
   2954  1.7.2.2  jdolecek 		ret_val = hw->phy.ops.read_reg(hw, reg_slice,
   2955  1.7.2.2  jdolecek 					IXGBE_MDIO_ZERO_DEV_TYPE, &reg_phy_ext);
   2956  1.7.2.2  jdolecek 	}
   2957  1.7.2.2  jdolecek 	return ret_val;
   2958  1.7.2.2  jdolecek }
   2959  1.7.2.2  jdolecek 
   2960  1.7.2.2  jdolecek /**
   2961  1.7.2.2  jdolecek  *  ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
   2962  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   2963  1.7.2.2  jdolecek  *
   2964  1.7.2.2  jdolecek  *  iXfI configuration needed for ixgbe_mac_X550EM_x devices.
   2965  1.7.2.2  jdolecek  **/
   2966  1.7.2.2  jdolecek static s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
   2967  1.7.2.2  jdolecek {
   2968  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
   2969  1.7.2.2  jdolecek 	s32 status;
   2970  1.7.2.2  jdolecek 	u32 reg_val;
   2971  1.7.2.2  jdolecek 
   2972  1.7.2.2  jdolecek 	/* Disable training protocol FSM. */
   2973  1.7.2.2  jdolecek 	status = mac->ops.read_iosf_sb_reg(hw,
   2974  1.7.2.2  jdolecek 				IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
   2975  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   2976  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2977  1.7.2.2  jdolecek 		return status;
   2978  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
   2979  1.7.2.2  jdolecek 	status = mac->ops.write_iosf_sb_reg(hw,
   2980  1.7.2.2  jdolecek 				IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
   2981  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   2982  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2983  1.7.2.2  jdolecek 		return status;
   2984  1.7.2.2  jdolecek 
   2985  1.7.2.2  jdolecek 	/* Disable Flex from training TXFFE. */
   2986  1.7.2.2  jdolecek 	status = mac->ops.read_iosf_sb_reg(hw,
   2987  1.7.2.2  jdolecek 				IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
   2988  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   2989  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2990  1.7.2.2  jdolecek 		return status;
   2991  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
   2992  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
   2993  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
   2994  1.7.2.2  jdolecek 	status = mac->ops.write_iosf_sb_reg(hw,
   2995  1.7.2.2  jdolecek 				IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
   2996  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   2997  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   2998  1.7.2.2  jdolecek 		return status;
   2999  1.7.2.2  jdolecek 	status = mac->ops.read_iosf_sb_reg(hw,
   3000  1.7.2.2  jdolecek 				IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
   3001  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   3002  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3003  1.7.2.2  jdolecek 		return status;
   3004  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
   3005  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
   3006  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
   3007  1.7.2.2  jdolecek 	status = mac->ops.write_iosf_sb_reg(hw,
   3008  1.7.2.2  jdolecek 				IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
   3009  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   3010  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3011  1.7.2.2  jdolecek 		return status;
   3012  1.7.2.2  jdolecek 
   3013  1.7.2.2  jdolecek 	/* Enable override for coefficients. */
   3014  1.7.2.2  jdolecek 	status = mac->ops.read_iosf_sb_reg(hw,
   3015  1.7.2.2  jdolecek 				IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
   3016  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   3017  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3018  1.7.2.2  jdolecek 		return status;
   3019  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
   3020  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
   3021  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
   3022  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
   3023  1.7.2.2  jdolecek 	status = mac->ops.write_iosf_sb_reg(hw,
   3024  1.7.2.2  jdolecek 				IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
   3025  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   3026  1.7.2.2  jdolecek 	return status;
   3027  1.7.2.2  jdolecek }
   3028  1.7.2.2  jdolecek 
   3029  1.7.2.2  jdolecek /**
   3030  1.7.2.2  jdolecek  *  ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
   3031  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3032  1.7.2.2  jdolecek  *  @speed: the link speed to force
   3033  1.7.2.2  jdolecek  *
   3034  1.7.2.2  jdolecek  *  Configures the integrated KR PHY to use iXFI mode. Used to connect an
   3035  1.7.2.2  jdolecek  *  internal and external PHY at a specific speed, without autonegotiation.
   3036  1.7.2.2  jdolecek  **/
   3037  1.7.2.2  jdolecek static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
   3038  1.7.2.2  jdolecek {
   3039  1.7.2.2  jdolecek 	struct ixgbe_mac_info *mac = &hw->mac;
   3040  1.7.2.2  jdolecek 	s32 status;
   3041  1.7.2.2  jdolecek 	u32 reg_val;
   3042  1.7.2.2  jdolecek 
   3043  1.7.2.2  jdolecek 	/* iXFI is only supported with X552 */
   3044  1.7.2.2  jdolecek 	if (mac->type != ixgbe_mac_X550EM_x)
   3045  1.7.2.2  jdolecek 		return IXGBE_ERR_LINK_SETUP;
   3046  1.7.2.2  jdolecek 
   3047  1.7.2.2  jdolecek 	/* Disable AN and force speed to 10G Serial. */
   3048  1.7.2.2  jdolecek 	status = mac->ops.read_iosf_sb_reg(hw,
   3049  1.7.2.2  jdolecek 					IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   3050  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   3051  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3052  1.7.2.2  jdolecek 		return status;
   3053  1.7.2.2  jdolecek 
   3054  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
   3055  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
   3056  1.7.2.2  jdolecek 
   3057  1.7.2.2  jdolecek 	/* Select forced link speed for internal PHY. */
   3058  1.7.2.2  jdolecek 	switch (*speed) {
   3059  1.7.2.2  jdolecek 	case IXGBE_LINK_SPEED_10GB_FULL:
   3060  1.7.2.2  jdolecek 		reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
   3061  1.7.2.2  jdolecek 		break;
   3062  1.7.2.2  jdolecek 	case IXGBE_LINK_SPEED_1GB_FULL:
   3063  1.7.2.2  jdolecek 		reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
   3064  1.7.2.2  jdolecek 		break;
   3065  1.7.2.2  jdolecek 	default:
   3066  1.7.2.2  jdolecek 		/* Other link speeds are not supported by internal KR PHY. */
   3067  1.7.2.2  jdolecek 		return IXGBE_ERR_LINK_SETUP;
   3068  1.7.2.2  jdolecek 	}
   3069  1.7.2.2  jdolecek 
   3070  1.7.2.2  jdolecek 	status = mac->ops.write_iosf_sb_reg(hw,
   3071  1.7.2.2  jdolecek 					IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   3072  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   3073  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3074  1.7.2.2  jdolecek 		return status;
   3075  1.7.2.2  jdolecek 
   3076  1.7.2.2  jdolecek 	/* Additional configuration needed for x550em_x */
   3077  1.7.2.2  jdolecek 	if (hw->mac.type == ixgbe_mac_X550EM_x) {
   3078  1.7.2.2  jdolecek 		status = ixgbe_setup_ixfi_x550em_x(hw);
   3079  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   3080  1.7.2.2  jdolecek 			return status;
   3081  1.7.2.2  jdolecek 	}
   3082  1.7.2.2  jdolecek 
   3083  1.7.2.2  jdolecek 	/* Toggle port SW reset by AN reset. */
   3084  1.7.2.2  jdolecek 	status = ixgbe_restart_an_internal_phy_x550em(hw);
   3085  1.7.2.2  jdolecek 
   3086  1.7.2.2  jdolecek 	return status;
   3087  1.7.2.2  jdolecek }
   3088  1.7.2.2  jdolecek 
   3089  1.7.2.2  jdolecek /**
   3090  1.7.2.2  jdolecek  * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
   3091  1.7.2.2  jdolecek  * @hw: address of hardware structure
   3092  1.7.2.2  jdolecek  * @link_up: address of boolean to indicate link status
   3093  1.7.2.2  jdolecek  *
   3094  1.7.2.2  jdolecek  * Returns error code if unable to get link status.
   3095  1.7.2.2  jdolecek  */
   3096  1.7.2.2  jdolecek static s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
   3097  1.7.2.2  jdolecek {
   3098  1.7.2.2  jdolecek 	u32 ret;
   3099  1.7.2.2  jdolecek 	u16 autoneg_status;
   3100  1.7.2.2  jdolecek 
   3101  1.7.2.2  jdolecek 	*link_up = FALSE;
   3102  1.7.2.2  jdolecek 
   3103  1.7.2.2  jdolecek 	/* read this twice back to back to indicate current status */
   3104  1.7.2.2  jdolecek 	ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
   3105  1.7.2.2  jdolecek 				   IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
   3106  1.7.2.2  jdolecek 				   &autoneg_status);
   3107  1.7.2.2  jdolecek 	if (ret != IXGBE_SUCCESS)
   3108  1.7.2.2  jdolecek 		return ret;
   3109  1.7.2.2  jdolecek 
   3110  1.7.2.2  jdolecek 	ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
   3111  1.7.2.2  jdolecek 				   IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
   3112  1.7.2.2  jdolecek 				   &autoneg_status);
   3113  1.7.2.2  jdolecek 	if (ret != IXGBE_SUCCESS)
   3114  1.7.2.2  jdolecek 		return ret;
   3115  1.7.2.2  jdolecek 
   3116  1.7.2.2  jdolecek 	*link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
   3117  1.7.2.2  jdolecek 
   3118  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   3119  1.7.2.2  jdolecek }
   3120  1.7.2.2  jdolecek 
   3121  1.7.2.2  jdolecek /**
   3122  1.7.2.2  jdolecek  * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
   3123  1.7.2.2  jdolecek  * @hw: point to hardware structure
   3124  1.7.2.2  jdolecek  *
   3125  1.7.2.2  jdolecek  * Configures the link between the integrated KR PHY and the external X557 PHY
   3126  1.7.2.2  jdolecek  * The driver will call this function when it gets a link status change
   3127  1.7.2.2  jdolecek  * interrupt from the X557 PHY. This function configures the link speed
   3128  1.7.2.2  jdolecek  * between the PHYs to match the link speed of the BASE-T link.
   3129  1.7.2.2  jdolecek  *
   3130  1.7.2.2  jdolecek  * A return of a non-zero value indicates an error, and the base driver should
   3131  1.7.2.2  jdolecek  * not report link up.
   3132  1.7.2.2  jdolecek  */
   3133  1.7.2.2  jdolecek s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
   3134  1.7.2.2  jdolecek {
   3135  1.7.2.2  jdolecek 	ixgbe_link_speed force_speed;
   3136  1.7.2.2  jdolecek 	bool link_up;
   3137  1.7.2.2  jdolecek 	u32 status;
   3138  1.7.2.2  jdolecek 	u16 speed;
   3139  1.7.2.2  jdolecek 
   3140  1.7.2.2  jdolecek 	if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
   3141  1.7.2.2  jdolecek 		return IXGBE_ERR_CONFIG;
   3142  1.7.2.2  jdolecek 
   3143  1.7.2.2  jdolecek 	if (hw->mac.type == ixgbe_mac_X550EM_x &&
   3144  1.7.2.2  jdolecek 	    !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
   3145  1.7.2.2  jdolecek 		/* If link is down, there is no setup necessary so return  */
   3146  1.7.2.2  jdolecek 		status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
   3147  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   3148  1.7.2.2  jdolecek 			return status;
   3149  1.7.2.2  jdolecek 
   3150  1.7.2.2  jdolecek 		if (!link_up)
   3151  1.7.2.2  jdolecek 			return IXGBE_SUCCESS;
   3152  1.7.2.2  jdolecek 
   3153  1.7.2.2  jdolecek 		status = hw->phy.ops.read_reg(hw,
   3154  1.7.2.2  jdolecek 					      IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
   3155  1.7.2.2  jdolecek 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
   3156  1.7.2.2  jdolecek 				      &speed);
   3157  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   3158  1.7.2.2  jdolecek 			return status;
   3159  1.7.2.2  jdolecek 
   3160  1.7.2.2  jdolecek 		/* If link is still down - no setup is required so return */
   3161  1.7.2.2  jdolecek 		status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
   3162  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   3163  1.7.2.2  jdolecek 			return status;
   3164  1.7.2.2  jdolecek 		if (!link_up)
   3165  1.7.2.2  jdolecek 			return IXGBE_SUCCESS;
   3166  1.7.2.2  jdolecek 
   3167  1.7.2.2  jdolecek 		/* clear everything but the speed and duplex bits */
   3168  1.7.2.2  jdolecek 		speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
   3169  1.7.2.2  jdolecek 
   3170  1.7.2.2  jdolecek 		switch (speed) {
   3171  1.7.2.2  jdolecek 		case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
   3172  1.7.2.2  jdolecek 			force_speed = IXGBE_LINK_SPEED_10GB_FULL;
   3173  1.7.2.2  jdolecek 			break;
   3174  1.7.2.2  jdolecek 		case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
   3175  1.7.2.2  jdolecek 			force_speed = IXGBE_LINK_SPEED_1GB_FULL;
   3176  1.7.2.2  jdolecek 			break;
   3177  1.7.2.2  jdolecek 		default:
   3178  1.7.2.2  jdolecek 			/* Internal PHY does not support anything else */
   3179  1.7.2.2  jdolecek 			return IXGBE_ERR_INVALID_LINK_SETTINGS;
   3180  1.7.2.2  jdolecek 		}
   3181  1.7.2.2  jdolecek 
   3182  1.7.2.2  jdolecek 		return ixgbe_setup_ixfi_x550em(hw, &force_speed);
   3183  1.7.2.2  jdolecek 	} else {
   3184  1.7.2.2  jdolecek 		speed = IXGBE_LINK_SPEED_10GB_FULL |
   3185  1.7.2.2  jdolecek 		    IXGBE_LINK_SPEED_1GB_FULL;
   3186  1.7.2.2  jdolecek 		return ixgbe_setup_kr_speed_x550em(hw, speed);
   3187  1.7.2.2  jdolecek 	}
   3188  1.7.2.2  jdolecek }
   3189  1.7.2.2  jdolecek 
   3190  1.7.2.2  jdolecek /**
   3191  1.7.2.2  jdolecek  *  ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
   3192  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3193  1.7.2.2  jdolecek  *
   3194  1.7.2.2  jdolecek  *  Configures the integrated KR PHY to use internal loopback mode.
   3195  1.7.2.2  jdolecek  **/
   3196  1.7.2.2  jdolecek s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
   3197  1.7.2.2  jdolecek {
   3198  1.7.2.2  jdolecek 	s32 status;
   3199  1.7.2.2  jdolecek 	u32 reg_val;
   3200  1.7.2.2  jdolecek 
   3201  1.7.2.2  jdolecek 	/* Disable AN and force speed to 10G Serial. */
   3202  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   3203  1.7.2.2  jdolecek 		IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   3204  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   3205  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3206  1.7.2.2  jdolecek 		return status;
   3207  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
   3208  1.7.2.2  jdolecek 	reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
   3209  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
   3210  1.7.2.2  jdolecek 	status = hw->mac.ops.write_iosf_sb_reg(hw,
   3211  1.7.2.2  jdolecek 		IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
   3212  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   3213  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3214  1.7.2.2  jdolecek 		return status;
   3215  1.7.2.2  jdolecek 
   3216  1.7.2.2  jdolecek 	/* Set near-end loopback clocks. */
   3217  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   3218  1.7.2.2  jdolecek 		IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
   3219  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   3220  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3221  1.7.2.2  jdolecek 		return status;
   3222  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
   3223  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
   3224  1.7.2.2  jdolecek 	status = hw->mac.ops.write_iosf_sb_reg(hw,
   3225  1.7.2.2  jdolecek 		IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
   3226  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   3227  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3228  1.7.2.2  jdolecek 		return status;
   3229  1.7.2.2  jdolecek 
   3230  1.7.2.2  jdolecek 	/* Set loopback enable. */
   3231  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   3232  1.7.2.2  jdolecek 		IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
   3233  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   3234  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3235  1.7.2.2  jdolecek 		return status;
   3236  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
   3237  1.7.2.2  jdolecek 	status = hw->mac.ops.write_iosf_sb_reg(hw,
   3238  1.7.2.2  jdolecek 		IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
   3239  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   3240  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3241  1.7.2.2  jdolecek 		return status;
   3242  1.7.2.2  jdolecek 
   3243  1.7.2.2  jdolecek 	/* Training bypass. */
   3244  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   3245  1.7.2.2  jdolecek 		IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
   3246  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   3247  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3248  1.7.2.2  jdolecek 		return status;
   3249  1.7.2.2  jdolecek 	reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
   3250  1.7.2.2  jdolecek 	status = hw->mac.ops.write_iosf_sb_reg(hw,
   3251  1.7.2.2  jdolecek 		IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
   3252  1.7.2.2  jdolecek 		IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   3253  1.7.2.2  jdolecek 
   3254  1.7.2.2  jdolecek 	return status;
   3255  1.7.2.2  jdolecek }
   3256  1.7.2.2  jdolecek 
   3257  1.7.2.2  jdolecek /**
   3258  1.7.2.2  jdolecek  *  ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
   3259  1.7.2.2  jdolecek  *  assuming that the semaphore is already obtained.
   3260  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3261  1.7.2.2  jdolecek  *  @offset: offset of  word in the EEPROM to read
   3262  1.7.2.2  jdolecek  *  @data: word read from the EEPROM
   3263  1.7.2.2  jdolecek  *
   3264  1.7.2.2  jdolecek  *  Reads a 16 bit word from the EEPROM using the hostif.
   3265  1.7.2.2  jdolecek  **/
   3266  1.7.2.2  jdolecek s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 *data)
   3267  1.7.2.2  jdolecek {
   3268  1.7.2.2  jdolecek 	const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
   3269  1.7.2.2  jdolecek 	struct ixgbe_hic_read_shadow_ram buffer;
   3270  1.7.2.2  jdolecek 	s32 status;
   3271  1.7.2.2  jdolecek 
   3272  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_read_ee_hostif_X550");
   3273  1.7.2.2  jdolecek 	buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
   3274  1.7.2.2  jdolecek 	buffer.hdr.req.buf_lenh = 0;
   3275  1.7.2.2  jdolecek 	buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
   3276  1.7.2.2  jdolecek 	buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
   3277  1.7.2.2  jdolecek 
   3278  1.7.2.2  jdolecek 	/* convert offset from words to bytes */
   3279  1.7.2.2  jdolecek 	buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
   3280  1.7.2.2  jdolecek 	/* one word */
   3281  1.7.2.2  jdolecek 	buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
   3282  1.7.2.2  jdolecek 
   3283  1.7.2.2  jdolecek 	status = hw->mac.ops.acquire_swfw_sync(hw, mask);
   3284  1.7.2.2  jdolecek 	if (status)
   3285  1.7.2.2  jdolecek 		return status;
   3286  1.7.2.2  jdolecek 
   3287  1.7.2.2  jdolecek 	status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
   3288  1.7.2.2  jdolecek 				    IXGBE_HI_COMMAND_TIMEOUT);
   3289  1.7.2.2  jdolecek 	if (!status) {
   3290  1.7.2.2  jdolecek 		*data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
   3291  1.7.2.2  jdolecek 						  FW_NVM_DATA_OFFSET);
   3292  1.7.2.2  jdolecek 	}
   3293  1.7.2.2  jdolecek 
   3294  1.7.2.2  jdolecek 	hw->mac.ops.release_swfw_sync(hw, mask);
   3295  1.7.2.2  jdolecek 	return status;
   3296  1.7.2.2  jdolecek }
   3297  1.7.2.2  jdolecek 
   3298  1.7.2.2  jdolecek /**
   3299  1.7.2.2  jdolecek  *  ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
   3300  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3301  1.7.2.2  jdolecek  *  @offset: offset of  word in the EEPROM to read
   3302  1.7.2.2  jdolecek  *  @words: number of words
   3303  1.7.2.2  jdolecek  *  @data: word(s) read from the EEPROM
   3304  1.7.2.2  jdolecek  *
   3305  1.7.2.2  jdolecek  *  Reads a 16 bit word(s) from the EEPROM using the hostif.
   3306  1.7.2.2  jdolecek  **/
   3307  1.7.2.2  jdolecek s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
   3308  1.7.2.2  jdolecek 				     u16 offset, u16 words, u16 *data)
   3309  1.7.2.2  jdolecek {
   3310  1.7.2.2  jdolecek 	const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
   3311  1.7.2.2  jdolecek 	struct ixgbe_hic_read_shadow_ram buffer;
   3312  1.7.2.2  jdolecek 	u32 current_word = 0;
   3313  1.7.2.2  jdolecek 	u16 words_to_read;
   3314  1.7.2.2  jdolecek 	s32 status;
   3315  1.7.2.2  jdolecek 	u32 i;
   3316  1.7.2.2  jdolecek 
   3317  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
   3318  1.7.2.2  jdolecek 
   3319  1.7.2.2  jdolecek 	/* Take semaphore for the entire operation. */
   3320  1.7.2.2  jdolecek 	status = hw->mac.ops.acquire_swfw_sync(hw, mask);
   3321  1.7.2.2  jdolecek 	if (status) {
   3322  1.7.2.2  jdolecek 		DEBUGOUT("EEPROM read buffer - semaphore failed\n");
   3323  1.7.2.2  jdolecek 		return status;
   3324  1.7.2.2  jdolecek 	}
   3325  1.7.2.2  jdolecek 
   3326  1.7.2.2  jdolecek 	while (words) {
   3327  1.7.2.2  jdolecek 		if (words > FW_MAX_READ_BUFFER_SIZE / 2)
   3328  1.7.2.2  jdolecek 			words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
   3329  1.7.2.2  jdolecek 		else
   3330  1.7.2.2  jdolecek 			words_to_read = words;
   3331  1.7.2.2  jdolecek 
   3332  1.7.2.2  jdolecek 		buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
   3333  1.7.2.2  jdolecek 		buffer.hdr.req.buf_lenh = 0;
   3334  1.7.2.2  jdolecek 		buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
   3335  1.7.2.2  jdolecek 		buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
   3336  1.7.2.2  jdolecek 
   3337  1.7.2.2  jdolecek 		/* convert offset from words to bytes */
   3338  1.7.2.2  jdolecek 		buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
   3339  1.7.2.2  jdolecek 		buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
   3340  1.7.2.2  jdolecek 
   3341  1.7.2.2  jdolecek 		status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
   3342  1.7.2.2  jdolecek 					    IXGBE_HI_COMMAND_TIMEOUT);
   3343  1.7.2.2  jdolecek 
   3344  1.7.2.2  jdolecek 		if (status) {
   3345  1.7.2.2  jdolecek 			DEBUGOUT("Host interface command failed\n");
   3346  1.7.2.2  jdolecek 			goto out;
   3347  1.7.2.2  jdolecek 		}
   3348  1.7.2.2  jdolecek 
   3349  1.7.2.2  jdolecek 		for (i = 0; i < words_to_read; i++) {
   3350  1.7.2.2  jdolecek 			u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
   3351  1.7.2.2  jdolecek 				  2 * i;
   3352  1.7.2.2  jdolecek 			u32 value = IXGBE_READ_REG(hw, reg);
   3353  1.7.2.2  jdolecek 
   3354  1.7.2.2  jdolecek 			data[current_word] = (u16)(value & 0xffff);
   3355  1.7.2.2  jdolecek 			current_word++;
   3356  1.7.2.2  jdolecek 			i++;
   3357  1.7.2.2  jdolecek 			if (i < words_to_read) {
   3358  1.7.2.2  jdolecek 				value >>= 16;
   3359  1.7.2.2  jdolecek 				data[current_word] = (u16)(value & 0xffff);
   3360  1.7.2.2  jdolecek 				current_word++;
   3361  1.7.2.2  jdolecek 			}
   3362  1.7.2.2  jdolecek 		}
   3363  1.7.2.2  jdolecek 		words -= words_to_read;
   3364  1.7.2.2  jdolecek 	}
   3365  1.7.2.2  jdolecek 
   3366  1.7.2.2  jdolecek out:
   3367  1.7.2.2  jdolecek 	hw->mac.ops.release_swfw_sync(hw, mask);
   3368  1.7.2.2  jdolecek 	return status;
   3369  1.7.2.2  jdolecek }
   3370  1.7.2.2  jdolecek 
   3371  1.7.2.2  jdolecek /**
   3372  1.7.2.2  jdolecek  *  ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
   3373  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3374  1.7.2.2  jdolecek  *  @offset: offset of  word in the EEPROM to write
   3375  1.7.2.2  jdolecek  *  @data: word write to the EEPROM
   3376  1.7.2.2  jdolecek  *
   3377  1.7.2.2  jdolecek  *  Write a 16 bit word to the EEPROM using the hostif.
   3378  1.7.2.2  jdolecek  **/
   3379  1.7.2.2  jdolecek s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
   3380  1.7.2.2  jdolecek 				    u16 data)
   3381  1.7.2.2  jdolecek {
   3382  1.7.2.2  jdolecek 	s32 status;
   3383  1.7.2.2  jdolecek 	struct ixgbe_hic_write_shadow_ram buffer;
   3384  1.7.2.2  jdolecek 
   3385  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
   3386  1.7.2.2  jdolecek 
   3387  1.7.2.2  jdolecek 	buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
   3388  1.7.2.2  jdolecek 	buffer.hdr.req.buf_lenh = 0;
   3389  1.7.2.2  jdolecek 	buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
   3390  1.7.2.2  jdolecek 	buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
   3391  1.7.2.2  jdolecek 
   3392  1.7.2.2  jdolecek 	 /* one word */
   3393  1.7.2.2  jdolecek 	buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
   3394  1.7.2.2  jdolecek 	buffer.data = data;
   3395  1.7.2.2  jdolecek 	buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
   3396  1.7.2.2  jdolecek 
   3397  1.7.2.2  jdolecek 	status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
   3398  1.7.2.2  jdolecek 					      sizeof(buffer),
   3399  1.7.2.2  jdolecek 					      IXGBE_HI_COMMAND_TIMEOUT, FALSE);
   3400  1.7.2.2  jdolecek 
   3401  1.7.2.2  jdolecek 	return status;
   3402  1.7.2.2  jdolecek }
   3403  1.7.2.2  jdolecek 
   3404  1.7.2.2  jdolecek /**
   3405  1.7.2.2  jdolecek  *  ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
   3406  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3407  1.7.2.2  jdolecek  *  @offset: offset of  word in the EEPROM to write
   3408  1.7.2.2  jdolecek  *  @data: word write to the EEPROM
   3409  1.7.2.2  jdolecek  *
   3410  1.7.2.2  jdolecek  *  Write a 16 bit word to the EEPROM using the hostif.
   3411  1.7.2.2  jdolecek  **/
   3412  1.7.2.2  jdolecek s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
   3413  1.7.2.2  jdolecek 			       u16 data)
   3414  1.7.2.2  jdolecek {
   3415  1.7.2.2  jdolecek 	s32 status = IXGBE_SUCCESS;
   3416  1.7.2.2  jdolecek 
   3417  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_write_ee_hostif_X550");
   3418  1.7.2.2  jdolecek 
   3419  1.7.2.2  jdolecek 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
   3420  1.7.2.2  jdolecek 	    IXGBE_SUCCESS) {
   3421  1.7.2.2  jdolecek 		status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
   3422  1.7.2.2  jdolecek 		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
   3423  1.7.2.2  jdolecek 	} else {
   3424  1.7.2.2  jdolecek 		DEBUGOUT("write ee hostif failed to get semaphore");
   3425  1.7.2.2  jdolecek 		status = IXGBE_ERR_SWFW_SYNC;
   3426  1.7.2.2  jdolecek 	}
   3427  1.7.2.2  jdolecek 
   3428  1.7.2.2  jdolecek 	return status;
   3429  1.7.2.2  jdolecek }
   3430  1.7.2.2  jdolecek 
   3431  1.7.2.2  jdolecek /**
   3432  1.7.2.2  jdolecek  *  ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
   3433  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3434  1.7.2.2  jdolecek  *  @offset: offset of  word in the EEPROM to write
   3435  1.7.2.2  jdolecek  *  @words: number of words
   3436  1.7.2.2  jdolecek  *  @data: word(s) write to the EEPROM
   3437  1.7.2.2  jdolecek  *
   3438  1.7.2.2  jdolecek  *  Write a 16 bit word(s) to the EEPROM using the hostif.
   3439  1.7.2.2  jdolecek  **/
   3440  1.7.2.2  jdolecek s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
   3441  1.7.2.2  jdolecek 				      u16 offset, u16 words, u16 *data)
   3442  1.7.2.2  jdolecek {
   3443  1.7.2.2  jdolecek 	s32 status = IXGBE_SUCCESS;
   3444  1.7.2.2  jdolecek 	u32 i = 0;
   3445  1.7.2.2  jdolecek 
   3446  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
   3447  1.7.2.2  jdolecek 
   3448  1.7.2.2  jdolecek 	/* Take semaphore for the entire operation. */
   3449  1.7.2.2  jdolecek 	status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
   3450  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS) {
   3451  1.7.2.2  jdolecek 		DEBUGOUT("EEPROM write buffer - semaphore failed\n");
   3452  1.7.2.2  jdolecek 		goto out;
   3453  1.7.2.2  jdolecek 	}
   3454  1.7.2.2  jdolecek 
   3455  1.7.2.2  jdolecek 	for (i = 0; i < words; i++) {
   3456  1.7.2.2  jdolecek 		status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
   3457  1.7.2.2  jdolecek 							 data[i]);
   3458  1.7.2.2  jdolecek 
   3459  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS) {
   3460  1.7.2.2  jdolecek 			DEBUGOUT("Eeprom buffered write failed\n");
   3461  1.7.2.2  jdolecek 			break;
   3462  1.7.2.2  jdolecek 		}
   3463  1.7.2.2  jdolecek 	}
   3464  1.7.2.2  jdolecek 
   3465  1.7.2.2  jdolecek 	hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
   3466  1.7.2.2  jdolecek out:
   3467  1.7.2.2  jdolecek 
   3468  1.7.2.2  jdolecek 	return status;
   3469  1.7.2.2  jdolecek }
   3470  1.7.2.2  jdolecek 
   3471  1.7.2.2  jdolecek /**
   3472  1.7.2.2  jdolecek  * ixgbe_checksum_ptr_x550 - Checksum one pointer region
   3473  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   3474  1.7.2.2  jdolecek  * @ptr: pointer offset in eeprom
   3475  1.7.2.2  jdolecek  * @size: size of section pointed by ptr, if 0 first word will be used as size
   3476  1.7.2.2  jdolecek  * @csum: address of checksum to update
   3477  1.7.2.2  jdolecek  *
   3478  1.7.2.2  jdolecek  * Returns error status for any failure
   3479  1.7.2.2  jdolecek  */
   3480  1.7.2.2  jdolecek static s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
   3481  1.7.2.2  jdolecek 				   u16 size, u16 *csum, u16 *buffer,
   3482  1.7.2.2  jdolecek 				   u32 buffer_size)
   3483  1.7.2.2  jdolecek {
   3484  1.7.2.2  jdolecek 	u16 buf[256];
   3485  1.7.2.2  jdolecek 	s32 status;
   3486  1.7.2.2  jdolecek 	u16 length, bufsz, i, start;
   3487  1.7.2.2  jdolecek 	u16 *local_buffer;
   3488  1.7.2.2  jdolecek 
   3489  1.7.2.2  jdolecek 	bufsz = sizeof(buf) / sizeof(buf[0]);
   3490  1.7.2.2  jdolecek 
   3491  1.7.2.2  jdolecek 	/* Read a chunk at the pointer location */
   3492  1.7.2.2  jdolecek 	if (!buffer) {
   3493  1.7.2.2  jdolecek 		status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
   3494  1.7.2.2  jdolecek 		if (status) {
   3495  1.7.2.2  jdolecek 			DEBUGOUT("Failed to read EEPROM image\n");
   3496  1.7.2.2  jdolecek 			return status;
   3497  1.7.2.2  jdolecek 		}
   3498  1.7.2.2  jdolecek 		local_buffer = buf;
   3499  1.7.2.2  jdolecek 	} else {
   3500  1.7.2.2  jdolecek 		if (buffer_size < ptr)
   3501  1.7.2.2  jdolecek 			return  IXGBE_ERR_PARAM;
   3502  1.7.2.2  jdolecek 		local_buffer = &buffer[ptr];
   3503  1.7.2.2  jdolecek 	}
   3504  1.7.2.2  jdolecek 
   3505  1.7.2.2  jdolecek 	if (size) {
   3506  1.7.2.2  jdolecek 		start = 0;
   3507  1.7.2.2  jdolecek 		length = size;
   3508  1.7.2.2  jdolecek 	} else {
   3509  1.7.2.2  jdolecek 		start = 1;
   3510  1.7.2.2  jdolecek 		length = local_buffer[0];
   3511  1.7.2.2  jdolecek 
   3512  1.7.2.2  jdolecek 		/* Skip pointer section if length is invalid. */
   3513  1.7.2.2  jdolecek 		if (length == 0xFFFF || length == 0 ||
   3514  1.7.2.2  jdolecek 		    (ptr + length) >= hw->eeprom.word_size)
   3515  1.7.2.2  jdolecek 			return IXGBE_SUCCESS;
   3516  1.7.2.2  jdolecek 	}
   3517  1.7.2.2  jdolecek 
   3518  1.7.2.2  jdolecek 	if (buffer && ((u32)start + (u32)length > buffer_size))
   3519  1.7.2.2  jdolecek 		return IXGBE_ERR_PARAM;
   3520  1.7.2.2  jdolecek 
   3521  1.7.2.2  jdolecek 	for (i = start; length; i++, length--) {
   3522  1.7.2.2  jdolecek 		if (i == bufsz && !buffer) {
   3523  1.7.2.2  jdolecek 			ptr += bufsz;
   3524  1.7.2.2  jdolecek 			i = 0;
   3525  1.7.2.2  jdolecek 			if (length < bufsz)
   3526  1.7.2.2  jdolecek 				bufsz = length;
   3527  1.7.2.2  jdolecek 
   3528  1.7.2.2  jdolecek 			/* Read a chunk at the pointer location */
   3529  1.7.2.2  jdolecek 			status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
   3530  1.7.2.2  jdolecek 								  bufsz, buf);
   3531  1.7.2.2  jdolecek 			if (status) {
   3532  1.7.2.2  jdolecek 				DEBUGOUT("Failed to read EEPROM image\n");
   3533  1.7.2.2  jdolecek 				return status;
   3534  1.7.2.2  jdolecek 			}
   3535  1.7.2.2  jdolecek 		}
   3536  1.7.2.2  jdolecek 		*csum += local_buffer[i];
   3537  1.7.2.2  jdolecek 	}
   3538  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   3539  1.7.2.2  jdolecek }
   3540  1.7.2.2  jdolecek 
   3541  1.7.2.2  jdolecek /**
   3542  1.7.2.2  jdolecek  *  ixgbe_calc_checksum_X550 - Calculates and returns the checksum
   3543  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3544  1.7.2.2  jdolecek  *  @buffer: pointer to buffer containing calculated checksum
   3545  1.7.2.2  jdolecek  *  @buffer_size: size of buffer
   3546  1.7.2.2  jdolecek  *
   3547  1.7.2.2  jdolecek  *  Returns a negative error code on error, or the 16-bit checksum
   3548  1.7.2.2  jdolecek  **/
   3549  1.7.2.2  jdolecek s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
   3550  1.7.2.2  jdolecek {
   3551  1.7.2.2  jdolecek 	u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
   3552  1.7.2.2  jdolecek 	u16 *local_buffer;
   3553  1.7.2.2  jdolecek 	s32 status;
   3554  1.7.2.2  jdolecek 	u16 checksum = 0;
   3555  1.7.2.2  jdolecek 	u16 pointer, i, size;
   3556  1.7.2.2  jdolecek 
   3557  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
   3558  1.7.2.2  jdolecek 
   3559  1.7.2.2  jdolecek 	hw->eeprom.ops.init_params(hw);
   3560  1.7.2.2  jdolecek 
   3561  1.7.2.2  jdolecek 	if (!buffer) {
   3562  1.7.2.2  jdolecek 		/* Read pointer area */
   3563  1.7.2.2  jdolecek 		status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
   3564  1.7.2.2  jdolecek 						     IXGBE_EEPROM_LAST_WORD + 1,
   3565  1.7.2.2  jdolecek 						     eeprom_ptrs);
   3566  1.7.2.2  jdolecek 		if (status) {
   3567  1.7.2.2  jdolecek 			DEBUGOUT("Failed to read EEPROM image\n");
   3568  1.7.2.2  jdolecek 			return status;
   3569  1.7.2.2  jdolecek 		}
   3570  1.7.2.2  jdolecek 		local_buffer = eeprom_ptrs;
   3571  1.7.2.2  jdolecek 	} else {
   3572  1.7.2.2  jdolecek 		if (buffer_size < IXGBE_EEPROM_LAST_WORD)
   3573  1.7.2.2  jdolecek 			return IXGBE_ERR_PARAM;
   3574  1.7.2.2  jdolecek 		local_buffer = buffer;
   3575  1.7.2.2  jdolecek 	}
   3576  1.7.2.2  jdolecek 
   3577  1.7.2.2  jdolecek 	/*
   3578  1.7.2.2  jdolecek 	 * For X550 hardware include 0x0-0x41 in the checksum, skip the
   3579  1.7.2.2  jdolecek 	 * checksum word itself
   3580  1.7.2.2  jdolecek 	 */
   3581  1.7.2.2  jdolecek 	for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
   3582  1.7.2.2  jdolecek 		if (i != IXGBE_EEPROM_CHECKSUM)
   3583  1.7.2.2  jdolecek 			checksum += local_buffer[i];
   3584  1.7.2.2  jdolecek 
   3585  1.7.2.2  jdolecek 	/*
   3586  1.7.2.2  jdolecek 	 * Include all data from pointers 0x3, 0x6-0xE.  This excludes the
   3587  1.7.2.2  jdolecek 	 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
   3588  1.7.2.2  jdolecek 	 */
   3589  1.7.2.2  jdolecek 	for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
   3590  1.7.2.2  jdolecek 		if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
   3591  1.7.2.2  jdolecek 			continue;
   3592  1.7.2.2  jdolecek 
   3593  1.7.2.2  jdolecek 		pointer = local_buffer[i];
   3594  1.7.2.2  jdolecek 
   3595  1.7.2.2  jdolecek 		/* Skip pointer section if the pointer is invalid. */
   3596  1.7.2.2  jdolecek 		if (pointer == 0xFFFF || pointer == 0 ||
   3597  1.7.2.2  jdolecek 		    pointer >= hw->eeprom.word_size)
   3598  1.7.2.2  jdolecek 			continue;
   3599  1.7.2.2  jdolecek 
   3600  1.7.2.2  jdolecek 		switch (i) {
   3601  1.7.2.2  jdolecek 		case IXGBE_PCIE_GENERAL_PTR:
   3602  1.7.2.2  jdolecek 			size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
   3603  1.7.2.2  jdolecek 			break;
   3604  1.7.2.2  jdolecek 		case IXGBE_PCIE_CONFIG0_PTR:
   3605  1.7.2.2  jdolecek 		case IXGBE_PCIE_CONFIG1_PTR:
   3606  1.7.2.2  jdolecek 			size = IXGBE_PCIE_CONFIG_SIZE;
   3607  1.7.2.2  jdolecek 			break;
   3608  1.7.2.2  jdolecek 		default:
   3609  1.7.2.2  jdolecek 			size = 0;
   3610  1.7.2.2  jdolecek 			break;
   3611  1.7.2.2  jdolecek 		}
   3612  1.7.2.2  jdolecek 
   3613  1.7.2.2  jdolecek 		status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
   3614  1.7.2.2  jdolecek 						buffer, buffer_size);
   3615  1.7.2.2  jdolecek 		if (status)
   3616  1.7.2.2  jdolecek 			return status;
   3617  1.7.2.2  jdolecek 	}
   3618  1.7.2.2  jdolecek 
   3619  1.7.2.2  jdolecek 	checksum = (u16)IXGBE_EEPROM_SUM - checksum;
   3620  1.7.2.2  jdolecek 
   3621  1.7.2.2  jdolecek 	return (s32)checksum;
   3622  1.7.2.2  jdolecek }
   3623  1.7.2.2  jdolecek 
   3624  1.7.2.2  jdolecek /**
   3625  1.7.2.2  jdolecek  *  ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
   3626  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3627  1.7.2.2  jdolecek  *
   3628  1.7.2.2  jdolecek  *  Returns a negative error code on error, or the 16-bit checksum
   3629  1.7.2.2  jdolecek  **/
   3630  1.7.2.2  jdolecek s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
   3631  1.7.2.2  jdolecek {
   3632  1.7.2.2  jdolecek 	return ixgbe_calc_checksum_X550(hw, NULL, 0);
   3633  1.7.2.2  jdolecek }
   3634  1.7.2.2  jdolecek 
   3635  1.7.2.2  jdolecek /**
   3636  1.7.2.2  jdolecek  *  ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
   3637  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3638  1.7.2.2  jdolecek  *  @checksum_val: calculated checksum
   3639  1.7.2.2  jdolecek  *
   3640  1.7.2.2  jdolecek  *  Performs checksum calculation and validates the EEPROM checksum.  If the
   3641  1.7.2.2  jdolecek  *  caller does not need checksum_val, the value can be NULL.
   3642  1.7.2.2  jdolecek  **/
   3643  1.7.2.2  jdolecek s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
   3644  1.7.2.2  jdolecek {
   3645  1.7.2.2  jdolecek 	s32 status;
   3646  1.7.2.2  jdolecek 	u16 checksum;
   3647  1.7.2.2  jdolecek 	u16 read_checksum = 0;
   3648  1.7.2.2  jdolecek 
   3649  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
   3650  1.7.2.2  jdolecek 
   3651  1.7.2.2  jdolecek 	/* Read the first word from the EEPROM. If this times out or fails, do
   3652  1.7.2.2  jdolecek 	 * not continue or we could be in for a very long wait while every
   3653  1.7.2.2  jdolecek 	 * EEPROM read fails
   3654  1.7.2.2  jdolecek 	 */
   3655  1.7.2.2  jdolecek 	status = hw->eeprom.ops.read(hw, 0, &checksum);
   3656  1.7.2.2  jdolecek 	if (status) {
   3657  1.7.2.2  jdolecek 		DEBUGOUT("EEPROM read failed\n");
   3658  1.7.2.2  jdolecek 		return status;
   3659  1.7.2.2  jdolecek 	}
   3660  1.7.2.2  jdolecek 
   3661  1.7.2.2  jdolecek 	status = hw->eeprom.ops.calc_checksum(hw);
   3662  1.7.2.2  jdolecek 	if (status < 0)
   3663  1.7.2.2  jdolecek 		return status;
   3664  1.7.2.2  jdolecek 
   3665  1.7.2.2  jdolecek 	checksum = (u16)(status & 0xffff);
   3666  1.7.2.2  jdolecek 
   3667  1.7.2.2  jdolecek 	status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
   3668  1.7.2.2  jdolecek 					   &read_checksum);
   3669  1.7.2.2  jdolecek 	if (status)
   3670  1.7.2.2  jdolecek 		return status;
   3671  1.7.2.2  jdolecek 
   3672  1.7.2.2  jdolecek 	/* Verify read checksum from EEPROM is the same as
   3673  1.7.2.2  jdolecek 	 * calculated checksum
   3674  1.7.2.2  jdolecek 	 */
   3675  1.7.2.2  jdolecek 	if (read_checksum != checksum) {
   3676  1.7.2.2  jdolecek 		status = IXGBE_ERR_EEPROM_CHECKSUM;
   3677  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
   3678  1.7.2.2  jdolecek 			     "Invalid EEPROM checksum");
   3679  1.7.2.2  jdolecek 	}
   3680  1.7.2.2  jdolecek 
   3681  1.7.2.2  jdolecek 	/* If the user cares, return the calculated checksum */
   3682  1.7.2.2  jdolecek 	if (checksum_val)
   3683  1.7.2.2  jdolecek 		*checksum_val = checksum;
   3684  1.7.2.2  jdolecek 
   3685  1.7.2.2  jdolecek 	return status;
   3686  1.7.2.2  jdolecek }
   3687  1.7.2.2  jdolecek 
   3688  1.7.2.2  jdolecek /**
   3689  1.7.2.2  jdolecek  * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
   3690  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   3691  1.7.2.2  jdolecek  *
   3692  1.7.2.2  jdolecek  * After writing EEPROM to shadow RAM using EEWR register, software calculates
   3693  1.7.2.2  jdolecek  * checksum and updates the EEPROM and instructs the hardware to update
   3694  1.7.2.2  jdolecek  * the flash.
   3695  1.7.2.2  jdolecek  **/
   3696  1.7.2.2  jdolecek s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
   3697  1.7.2.2  jdolecek {
   3698  1.7.2.2  jdolecek 	s32 status;
   3699  1.7.2.2  jdolecek 	u16 checksum = 0;
   3700  1.7.2.2  jdolecek 
   3701  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
   3702  1.7.2.2  jdolecek 
   3703  1.7.2.2  jdolecek 	/* Read the first word from the EEPROM. If this times out or fails, do
   3704  1.7.2.2  jdolecek 	 * not continue or we could be in for a very long wait while every
   3705  1.7.2.2  jdolecek 	 * EEPROM read fails
   3706  1.7.2.2  jdolecek 	 */
   3707  1.7.2.2  jdolecek 	status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
   3708  1.7.2.2  jdolecek 	if (status) {
   3709  1.7.2.2  jdolecek 		DEBUGOUT("EEPROM read failed\n");
   3710  1.7.2.2  jdolecek 		return status;
   3711  1.7.2.2  jdolecek 	}
   3712  1.7.2.2  jdolecek 
   3713  1.7.2.2  jdolecek 	status = ixgbe_calc_eeprom_checksum_X550(hw);
   3714  1.7.2.2  jdolecek 	if (status < 0)
   3715  1.7.2.2  jdolecek 		return status;
   3716  1.7.2.2  jdolecek 
   3717  1.7.2.2  jdolecek 	checksum = (u16)(status & 0xffff);
   3718  1.7.2.2  jdolecek 
   3719  1.7.2.2  jdolecek 	status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
   3720  1.7.2.2  jdolecek 					    checksum);
   3721  1.7.2.2  jdolecek 	if (status)
   3722  1.7.2.2  jdolecek 		return status;
   3723  1.7.2.2  jdolecek 
   3724  1.7.2.2  jdolecek 	status = ixgbe_update_flash_X550(hw);
   3725  1.7.2.2  jdolecek 
   3726  1.7.2.2  jdolecek 	return status;
   3727  1.7.2.2  jdolecek }
   3728  1.7.2.2  jdolecek 
   3729  1.7.2.2  jdolecek /**
   3730  1.7.2.2  jdolecek  *  ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
   3731  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3732  1.7.2.2  jdolecek  *
   3733  1.7.2.2  jdolecek  *  Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
   3734  1.7.2.2  jdolecek  **/
   3735  1.7.2.2  jdolecek s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
   3736  1.7.2.2  jdolecek {
   3737  1.7.2.2  jdolecek 	s32 status = IXGBE_SUCCESS;
   3738  1.7.2.2  jdolecek 	union ixgbe_hic_hdr2 buffer;
   3739  1.7.2.2  jdolecek 
   3740  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_update_flash_X550");
   3741  1.7.2.2  jdolecek 
   3742  1.7.2.2  jdolecek 	buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
   3743  1.7.2.2  jdolecek 	buffer.req.buf_lenh = 0;
   3744  1.7.2.2  jdolecek 	buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
   3745  1.7.2.2  jdolecek 	buffer.req.checksum = FW_DEFAULT_CHECKSUM;
   3746  1.7.2.2  jdolecek 
   3747  1.7.2.2  jdolecek 	status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
   3748  1.7.2.2  jdolecek 					      sizeof(buffer),
   3749  1.7.2.2  jdolecek 					      IXGBE_HI_COMMAND_TIMEOUT, FALSE);
   3750  1.7.2.2  jdolecek 
   3751  1.7.2.2  jdolecek 	return status;
   3752  1.7.2.2  jdolecek }
   3753  1.7.2.2  jdolecek 
   3754  1.7.2.2  jdolecek /**
   3755  1.7.2.2  jdolecek  *  ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
   3756  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3757  1.7.2.2  jdolecek  *
   3758  1.7.2.2  jdolecek  *  Determines physical layer capabilities of the current configuration.
   3759  1.7.2.2  jdolecek  **/
   3760  1.7.2.2  jdolecek u64 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
   3761  1.7.2.2  jdolecek {
   3762  1.7.2.2  jdolecek 	u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
   3763  1.7.2.2  jdolecek 	u16 ext_ability = 0;
   3764  1.7.2.2  jdolecek 
   3765  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
   3766  1.7.2.2  jdolecek 
   3767  1.7.2.2  jdolecek 	hw->phy.ops.identify(hw);
   3768  1.7.2.2  jdolecek 
   3769  1.7.2.2  jdolecek 	switch (hw->phy.type) {
   3770  1.7.2.2  jdolecek 	case ixgbe_phy_x550em_kr:
   3771  1.7.2.2  jdolecek 		if (hw->mac.type == ixgbe_mac_X550EM_a) {
   3772  1.7.2.2  jdolecek 			if (hw->phy.nw_mng_if_sel &
   3773  1.7.2.2  jdolecek 			    IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
   3774  1.7.2.2  jdolecek 				physical_layer =
   3775  1.7.2.2  jdolecek 					IXGBE_PHYSICAL_LAYER_2500BASE_KX;
   3776  1.7.2.2  jdolecek 				break;
   3777  1.7.2.2  jdolecek 			} else if (hw->device_id ==
   3778  1.7.2.2  jdolecek 				   IXGBE_DEV_ID_X550EM_A_KR_L) {
   3779  1.7.2.2  jdolecek 				physical_layer =
   3780  1.7.2.2  jdolecek 					IXGBE_PHYSICAL_LAYER_1000BASE_KX;
   3781  1.7.2.2  jdolecek 				break;
   3782  1.7.2.2  jdolecek 			}
   3783  1.7.2.2  jdolecek 		}
   3784  1.7.2.2  jdolecek 		/* fall through */
   3785  1.7.2.2  jdolecek 	case ixgbe_phy_x550em_xfi:
   3786  1.7.2.2  jdolecek 		physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
   3787  1.7.2.2  jdolecek 				 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
   3788  1.7.2.2  jdolecek 		break;
   3789  1.7.2.2  jdolecek 	case ixgbe_phy_x550em_kx4:
   3790  1.7.2.2  jdolecek 		physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
   3791  1.7.2.2  jdolecek 				 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
   3792  1.7.2.2  jdolecek 		break;
   3793  1.7.2.2  jdolecek 	case ixgbe_phy_x550em_ext_t:
   3794  1.7.2.2  jdolecek 		hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
   3795  1.7.2.2  jdolecek 				     IXGBE_MDIO_PMA_PMD_DEV_TYPE,
   3796  1.7.2.2  jdolecek 				     &ext_ability);
   3797  1.7.2.2  jdolecek 		if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
   3798  1.7.2.2  jdolecek 			physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
   3799  1.7.2.2  jdolecek 		if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
   3800  1.7.2.2  jdolecek 			physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
   3801  1.7.2.2  jdolecek 		break;
   3802  1.7.2.2  jdolecek 	case ixgbe_phy_fw:
   3803  1.7.2.2  jdolecek 		if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_1GB_FULL)
   3804  1.7.2.2  jdolecek 			physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
   3805  1.7.2.2  jdolecek 		if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_100_FULL)
   3806  1.7.2.2  jdolecek 			physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
   3807  1.7.2.2  jdolecek 		if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_10_FULL)
   3808  1.7.2.2  jdolecek 			physical_layer |= IXGBE_PHYSICAL_LAYER_10BASE_T;
   3809  1.7.2.2  jdolecek 		break;
   3810  1.7.2.2  jdolecek 	case ixgbe_phy_sgmii:
   3811  1.7.2.2  jdolecek 		physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
   3812  1.7.2.2  jdolecek 		break;
   3813  1.7.2.2  jdolecek 	case ixgbe_phy_ext_1g_t:
   3814  1.7.2.2  jdolecek 		physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
   3815  1.7.2.2  jdolecek 		break;
   3816  1.7.2.2  jdolecek 	default:
   3817  1.7.2.2  jdolecek 		break;
   3818  1.7.2.2  jdolecek 	}
   3819  1.7.2.2  jdolecek 
   3820  1.7.2.2  jdolecek 	if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
   3821  1.7.2.2  jdolecek 		physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
   3822  1.7.2.2  jdolecek 
   3823  1.7.2.2  jdolecek 	return physical_layer;
   3824  1.7.2.2  jdolecek }
   3825  1.7.2.2  jdolecek 
   3826  1.7.2.2  jdolecek /**
   3827  1.7.2.2  jdolecek  * ixgbe_get_bus_info_x550em - Set PCI bus info
   3828  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   3829  1.7.2.2  jdolecek  *
   3830  1.7.2.2  jdolecek  * Sets bus link width and speed to unknown because X550em is
   3831  1.7.2.2  jdolecek  * not a PCI device.
   3832  1.7.2.2  jdolecek  **/
   3833  1.7.2.2  jdolecek s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
   3834  1.7.2.2  jdolecek {
   3835  1.7.2.2  jdolecek 
   3836  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_get_bus_info_x550em");
   3837  1.7.2.2  jdolecek 
   3838  1.7.2.2  jdolecek 	hw->bus.width = ixgbe_bus_width_unknown;
   3839  1.7.2.2  jdolecek 	hw->bus.speed = ixgbe_bus_speed_unknown;
   3840  1.7.2.2  jdolecek 
   3841  1.7.2.2  jdolecek 	hw->mac.ops.set_lan_id(hw);
   3842  1.7.2.2  jdolecek 
   3843  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   3844  1.7.2.2  jdolecek }
   3845  1.7.2.2  jdolecek 
   3846  1.7.2.2  jdolecek /**
   3847  1.7.2.2  jdolecek  * ixgbe_disable_rx_x550 - Disable RX unit
   3848  1.7.2.2  jdolecek  *
   3849  1.7.2.2  jdolecek  * Enables the Rx DMA unit for x550
   3850  1.7.2.2  jdolecek  **/
   3851  1.7.2.2  jdolecek void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
   3852  1.7.2.2  jdolecek {
   3853  1.7.2.2  jdolecek 	u32 rxctrl, pfdtxgswc;
   3854  1.7.2.2  jdolecek 	s32 status;
   3855  1.7.2.2  jdolecek 	struct ixgbe_hic_disable_rxen fw_cmd;
   3856  1.7.2.2  jdolecek 
   3857  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_disable_rx_dma_x550");
   3858  1.7.2.2  jdolecek 
   3859  1.7.2.2  jdolecek 	rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
   3860  1.7.2.2  jdolecek 	if (rxctrl & IXGBE_RXCTRL_RXEN) {
   3861  1.7.2.2  jdolecek 		pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
   3862  1.7.2.2  jdolecek 		if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
   3863  1.7.2.2  jdolecek 			pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
   3864  1.7.2.2  jdolecek 			IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
   3865  1.7.2.2  jdolecek 			hw->mac.set_lben = TRUE;
   3866  1.7.2.2  jdolecek 		} else {
   3867  1.7.2.2  jdolecek 			hw->mac.set_lben = FALSE;
   3868  1.7.2.2  jdolecek 		}
   3869  1.7.2.2  jdolecek 
   3870  1.7.2.2  jdolecek 		fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
   3871  1.7.2.2  jdolecek 		fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
   3872  1.7.2.2  jdolecek 		fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
   3873  1.7.2.2  jdolecek 		fw_cmd.port_number = (u8)hw->bus.lan_id;
   3874  1.7.2.2  jdolecek 
   3875  1.7.2.2  jdolecek 		status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
   3876  1.7.2.2  jdolecek 					sizeof(struct ixgbe_hic_disable_rxen),
   3877  1.7.2.2  jdolecek 					IXGBE_HI_COMMAND_TIMEOUT, TRUE);
   3878  1.7.2.2  jdolecek 
   3879  1.7.2.2  jdolecek 		/* If we fail - disable RX using register write */
   3880  1.7.2.2  jdolecek 		if (status) {
   3881  1.7.2.2  jdolecek 			rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
   3882  1.7.2.2  jdolecek 			if (rxctrl & IXGBE_RXCTRL_RXEN) {
   3883  1.7.2.2  jdolecek 				rxctrl &= ~IXGBE_RXCTRL_RXEN;
   3884  1.7.2.2  jdolecek 				IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
   3885  1.7.2.2  jdolecek 			}
   3886  1.7.2.2  jdolecek 		}
   3887  1.7.2.2  jdolecek 	}
   3888  1.7.2.2  jdolecek }
   3889  1.7.2.2  jdolecek 
   3890  1.7.2.2  jdolecek /**
   3891  1.7.2.2  jdolecek  * ixgbe_enter_lplu_x550em - Transition to low power states
   3892  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   3893  1.7.2.2  jdolecek  *
   3894  1.7.2.2  jdolecek  * Configures Low Power Link Up on transition to low power states
   3895  1.7.2.2  jdolecek  * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
   3896  1.7.2.2  jdolecek  * X557 PHY immediately prior to entering LPLU.
   3897  1.7.2.2  jdolecek  **/
   3898  1.7.2.2  jdolecek s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
   3899  1.7.2.2  jdolecek {
   3900  1.7.2.2  jdolecek 	u16 an_10g_cntl_reg, autoneg_reg, speed;
   3901  1.7.2.2  jdolecek 	s32 status;
   3902  1.7.2.2  jdolecek 	ixgbe_link_speed lcd_speed;
   3903  1.7.2.2  jdolecek 	u32 save_autoneg;
   3904  1.7.2.2  jdolecek 	bool link_up;
   3905  1.7.2.2  jdolecek 
   3906  1.7.2.2  jdolecek 	/* SW LPLU not required on later HW revisions. */
   3907  1.7.2.2  jdolecek 	if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
   3908  1.7.2.2  jdolecek 	    (IXGBE_FUSES0_REV_MASK &
   3909  1.7.2.2  jdolecek 	     IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
   3910  1.7.2.2  jdolecek 		return IXGBE_SUCCESS;
   3911  1.7.2.2  jdolecek 
   3912  1.7.2.2  jdolecek 	/* If blocked by MNG FW, then don't restart AN */
   3913  1.7.2.2  jdolecek 	if (ixgbe_check_reset_blocked(hw))
   3914  1.7.2.2  jdolecek 		return IXGBE_SUCCESS;
   3915  1.7.2.2  jdolecek 
   3916  1.7.2.2  jdolecek 	status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
   3917  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3918  1.7.2.2  jdolecek 		return status;
   3919  1.7.2.2  jdolecek 
   3920  1.7.2.2  jdolecek 	status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
   3921  1.7.2.2  jdolecek 
   3922  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3923  1.7.2.2  jdolecek 		return status;
   3924  1.7.2.2  jdolecek 
   3925  1.7.2.2  jdolecek 	/* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
   3926  1.7.2.2  jdolecek 	 * disabled, then force link down by entering low power mode.
   3927  1.7.2.2  jdolecek 	 */
   3928  1.7.2.2  jdolecek 	if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
   3929  1.7.2.2  jdolecek 	    !(hw->wol_enabled || ixgbe_mng_present(hw)))
   3930  1.7.2.2  jdolecek 		return ixgbe_set_copper_phy_power(hw, FALSE);
   3931  1.7.2.2  jdolecek 
   3932  1.7.2.2  jdolecek 	/* Determine LCD */
   3933  1.7.2.2  jdolecek 	status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
   3934  1.7.2.2  jdolecek 
   3935  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3936  1.7.2.2  jdolecek 		return status;
   3937  1.7.2.2  jdolecek 
   3938  1.7.2.2  jdolecek 	/* If no valid LCD link speed, then force link down and exit. */
   3939  1.7.2.2  jdolecek 	if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
   3940  1.7.2.2  jdolecek 		return ixgbe_set_copper_phy_power(hw, FALSE);
   3941  1.7.2.2  jdolecek 
   3942  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
   3943  1.7.2.2  jdolecek 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
   3944  1.7.2.2  jdolecek 				      &speed);
   3945  1.7.2.2  jdolecek 
   3946  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3947  1.7.2.2  jdolecek 		return status;
   3948  1.7.2.2  jdolecek 
   3949  1.7.2.2  jdolecek 	/* If no link now, speed is invalid so take link down */
   3950  1.7.2.2  jdolecek 	status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
   3951  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3952  1.7.2.2  jdolecek 		return ixgbe_set_copper_phy_power(hw, FALSE);
   3953  1.7.2.2  jdolecek 
   3954  1.7.2.2  jdolecek 	/* clear everything but the speed bits */
   3955  1.7.2.2  jdolecek 	speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
   3956  1.7.2.2  jdolecek 
   3957  1.7.2.2  jdolecek 	/* If current speed is already LCD, then exit. */
   3958  1.7.2.2  jdolecek 	if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
   3959  1.7.2.2  jdolecek 	     (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
   3960  1.7.2.2  jdolecek 	    ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
   3961  1.7.2.2  jdolecek 	     (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
   3962  1.7.2.2  jdolecek 		return status;
   3963  1.7.2.2  jdolecek 
   3964  1.7.2.2  jdolecek 	/* Clear AN completed indication */
   3965  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
   3966  1.7.2.2  jdolecek 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
   3967  1.7.2.2  jdolecek 				      &autoneg_reg);
   3968  1.7.2.2  jdolecek 
   3969  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3970  1.7.2.2  jdolecek 		return status;
   3971  1.7.2.2  jdolecek 
   3972  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
   3973  1.7.2.2  jdolecek 			     IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
   3974  1.7.2.2  jdolecek 			     &an_10g_cntl_reg);
   3975  1.7.2.2  jdolecek 
   3976  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3977  1.7.2.2  jdolecek 		return status;
   3978  1.7.2.2  jdolecek 
   3979  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw,
   3980  1.7.2.2  jdolecek 			     IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
   3981  1.7.2.2  jdolecek 			     IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
   3982  1.7.2.2  jdolecek 			     &autoneg_reg);
   3983  1.7.2.2  jdolecek 
   3984  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   3985  1.7.2.2  jdolecek 		return status;
   3986  1.7.2.2  jdolecek 
   3987  1.7.2.2  jdolecek 	save_autoneg = hw->phy.autoneg_advertised;
   3988  1.7.2.2  jdolecek 
   3989  1.7.2.2  jdolecek 	/* Setup link at least common link speed */
   3990  1.7.2.2  jdolecek 	status = hw->mac.ops.setup_link(hw, lcd_speed, FALSE);
   3991  1.7.2.2  jdolecek 
   3992  1.7.2.2  jdolecek 	/* restore autoneg from before setting lplu speed */
   3993  1.7.2.2  jdolecek 	hw->phy.autoneg_advertised = save_autoneg;
   3994  1.7.2.2  jdolecek 
   3995  1.7.2.2  jdolecek 	return status;
   3996  1.7.2.2  jdolecek }
   3997  1.7.2.2  jdolecek 
   3998  1.7.2.2  jdolecek /**
   3999  1.7.2.2  jdolecek  * ixgbe_get_lcd_x550em - Determine lowest common denominator
   4000  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4001  1.7.2.2  jdolecek  *  @lcd_speed: pointer to lowest common link speed
   4002  1.7.2.2  jdolecek  *
   4003  1.7.2.2  jdolecek  * Determine lowest common link speed with link partner.
   4004  1.7.2.2  jdolecek  **/
   4005  1.7.2.2  jdolecek s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
   4006  1.7.2.2  jdolecek {
   4007  1.7.2.2  jdolecek 	u16 an_lp_status;
   4008  1.7.2.2  jdolecek 	s32 status;
   4009  1.7.2.2  jdolecek 	u16 word = hw->eeprom.ctrl_word_3;
   4010  1.7.2.2  jdolecek 
   4011  1.7.2.2  jdolecek 	*lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
   4012  1.7.2.2  jdolecek 
   4013  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
   4014  1.7.2.2  jdolecek 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
   4015  1.7.2.2  jdolecek 				      &an_lp_status);
   4016  1.7.2.2  jdolecek 
   4017  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   4018  1.7.2.2  jdolecek 		return status;
   4019  1.7.2.2  jdolecek 
   4020  1.7.2.2  jdolecek 	/* If link partner advertised 1G, return 1G */
   4021  1.7.2.2  jdolecek 	if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
   4022  1.7.2.2  jdolecek 		*lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
   4023  1.7.2.2  jdolecek 		return status;
   4024  1.7.2.2  jdolecek 	}
   4025  1.7.2.2  jdolecek 
   4026  1.7.2.2  jdolecek 	/* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
   4027  1.7.2.2  jdolecek 	if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
   4028  1.7.2.2  jdolecek 	    (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
   4029  1.7.2.2  jdolecek 		return status;
   4030  1.7.2.2  jdolecek 
   4031  1.7.2.2  jdolecek 	/* Link partner not capable of lower speeds, return 10G */
   4032  1.7.2.2  jdolecek 	*lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
   4033  1.7.2.2  jdolecek 	return status;
   4034  1.7.2.2  jdolecek }
   4035  1.7.2.2  jdolecek 
   4036  1.7.2.2  jdolecek /**
   4037  1.7.2.2  jdolecek  *  ixgbe_setup_fc_X550em - Set up flow control
   4038  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4039  1.7.2.2  jdolecek  *
   4040  1.7.2.2  jdolecek  *  Called at init time to set up flow control.
   4041  1.7.2.2  jdolecek  **/
   4042  1.7.2.2  jdolecek s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
   4043  1.7.2.2  jdolecek {
   4044  1.7.2.2  jdolecek 	s32 ret_val = IXGBE_SUCCESS;
   4045  1.7.2.2  jdolecek 	u32 pause, asm_dir, reg_val;
   4046  1.7.2.2  jdolecek 
   4047  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_setup_fc_X550em");
   4048  1.7.2.2  jdolecek 
   4049  1.7.2.2  jdolecek 	/* Validate the requested mode */
   4050  1.7.2.2  jdolecek 	if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
   4051  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
   4052  1.7.2.2  jdolecek 			"ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
   4053  1.7.2.2  jdolecek 		ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
   4054  1.7.2.2  jdolecek 		goto out;
   4055  1.7.2.2  jdolecek 	}
   4056  1.7.2.2  jdolecek 
   4057  1.7.2.2  jdolecek 	/* 10gig parts do not have a word in the EEPROM to determine the
   4058  1.7.2.2  jdolecek 	 * default flow control setting, so we explicitly set it to full.
   4059  1.7.2.2  jdolecek 	 */
   4060  1.7.2.2  jdolecek 	if (hw->fc.requested_mode == ixgbe_fc_default)
   4061  1.7.2.2  jdolecek 		hw->fc.requested_mode = ixgbe_fc_full;
   4062  1.7.2.2  jdolecek 
   4063  1.7.2.2  jdolecek 	/* Determine PAUSE and ASM_DIR bits. */
   4064  1.7.2.2  jdolecek 	switch (hw->fc.requested_mode) {
   4065  1.7.2.2  jdolecek 	case ixgbe_fc_none:
   4066  1.7.2.2  jdolecek 		pause = 0;
   4067  1.7.2.2  jdolecek 		asm_dir = 0;
   4068  1.7.2.2  jdolecek 		break;
   4069  1.7.2.2  jdolecek 	case ixgbe_fc_tx_pause:
   4070  1.7.2.2  jdolecek 		pause = 0;
   4071  1.7.2.2  jdolecek 		asm_dir = 1;
   4072  1.7.2.2  jdolecek 		break;
   4073  1.7.2.2  jdolecek 	case ixgbe_fc_rx_pause:
   4074  1.7.2.2  jdolecek 		/* Rx Flow control is enabled and Tx Flow control is
   4075  1.7.2.2  jdolecek 		 * disabled by software override. Since there really
   4076  1.7.2.2  jdolecek 		 * isn't a way to advertise that we are capable of RX
   4077  1.7.2.2  jdolecek 		 * Pause ONLY, we will advertise that we support both
   4078  1.7.2.2  jdolecek 		 * symmetric and asymmetric Rx PAUSE, as such we fall
   4079  1.7.2.2  jdolecek 		 * through to the fc_full statement.  Later, we will
   4080  1.7.2.2  jdolecek 		 * disable the adapter's ability to send PAUSE frames.
   4081  1.7.2.2  jdolecek 		 */
   4082  1.7.2.2  jdolecek 	case ixgbe_fc_full:
   4083  1.7.2.2  jdolecek 		pause = 1;
   4084  1.7.2.2  jdolecek 		asm_dir = 1;
   4085  1.7.2.2  jdolecek 		break;
   4086  1.7.2.2  jdolecek 	default:
   4087  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
   4088  1.7.2.2  jdolecek 			"Flow control param set incorrectly\n");
   4089  1.7.2.2  jdolecek 		ret_val = IXGBE_ERR_CONFIG;
   4090  1.7.2.2  jdolecek 		goto out;
   4091  1.7.2.2  jdolecek 	}
   4092  1.7.2.2  jdolecek 
   4093  1.7.2.2  jdolecek 	switch (hw->device_id) {
   4094  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_KR:
   4095  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_KR:
   4096  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_A_KR_L:
   4097  1.7.2.2  jdolecek 		ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
   4098  1.7.2.2  jdolecek 			IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
   4099  1.7.2.2  jdolecek 			IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
   4100  1.7.2.2  jdolecek 		if (ret_val != IXGBE_SUCCESS)
   4101  1.7.2.2  jdolecek 			goto out;
   4102  1.7.2.2  jdolecek 		reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
   4103  1.7.2.2  jdolecek 			IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
   4104  1.7.2.2  jdolecek 		if (pause)
   4105  1.7.2.2  jdolecek 			reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
   4106  1.7.2.2  jdolecek 		if (asm_dir)
   4107  1.7.2.2  jdolecek 			reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
   4108  1.7.2.2  jdolecek 		ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
   4109  1.7.2.2  jdolecek 			IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
   4110  1.7.2.2  jdolecek 			IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
   4111  1.7.2.2  jdolecek 
   4112  1.7.2.2  jdolecek 		/* This device does not fully support AN. */
   4113  1.7.2.2  jdolecek 		hw->fc.disable_fc_autoneg = TRUE;
   4114  1.7.2.2  jdolecek 		break;
   4115  1.7.2.2  jdolecek 	case IXGBE_DEV_ID_X550EM_X_XFI:
   4116  1.7.2.2  jdolecek 		hw->fc.disable_fc_autoneg = TRUE;
   4117  1.7.2.2  jdolecek 		break;
   4118  1.7.2.2  jdolecek 	default:
   4119  1.7.2.2  jdolecek 		break;
   4120  1.7.2.2  jdolecek 	}
   4121  1.7.2.2  jdolecek 
   4122  1.7.2.2  jdolecek out:
   4123  1.7.2.2  jdolecek 	return ret_val;
   4124  1.7.2.2  jdolecek }
   4125  1.7.2.2  jdolecek 
   4126  1.7.2.2  jdolecek /**
   4127  1.7.2.2  jdolecek  *  ixgbe_fc_autoneg_backplane_x550em_a - Enable flow control IEEE clause 37
   4128  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4129  1.7.2.2  jdolecek  *
   4130  1.7.2.2  jdolecek  *  Enable flow control according to IEEE clause 37.
   4131  1.7.2.2  jdolecek  **/
   4132  1.7.2.2  jdolecek void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *hw)
   4133  1.7.2.2  jdolecek {
   4134  1.7.2.2  jdolecek 	u32 link_s1, lp_an_page_low, an_cntl_1;
   4135  1.7.2.2  jdolecek 	s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
   4136  1.7.2.2  jdolecek 	ixgbe_link_speed speed;
   4137  1.7.2.2  jdolecek 	bool link_up;
   4138  1.7.2.2  jdolecek 
   4139  1.7.2.2  jdolecek 	/* AN should have completed when the cable was plugged in.
   4140  1.7.2.2  jdolecek 	 * Look for reasons to bail out.  Bail out if:
   4141  1.7.2.2  jdolecek 	 * - FC autoneg is disabled, or if
   4142  1.7.2.2  jdolecek 	 * - link is not up.
   4143  1.7.2.2  jdolecek 	 */
   4144  1.7.2.2  jdolecek 	if (hw->fc.disable_fc_autoneg) {
   4145  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
   4146  1.7.2.2  jdolecek 			     "Flow control autoneg is disabled");
   4147  1.7.2.2  jdolecek 		goto out;
   4148  1.7.2.2  jdolecek 	}
   4149  1.7.2.2  jdolecek 
   4150  1.7.2.2  jdolecek 	hw->mac.ops.check_link(hw, &speed, &link_up, FALSE);
   4151  1.7.2.2  jdolecek 	if (!link_up) {
   4152  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
   4153  1.7.2.2  jdolecek 		goto out;
   4154  1.7.2.2  jdolecek 	}
   4155  1.7.2.2  jdolecek 
   4156  1.7.2.2  jdolecek 	/* Check at auto-negotiation has completed */
   4157  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   4158  1.7.2.2  jdolecek 					IXGBE_KRM_LINK_S1(hw->bus.lan_id),
   4159  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, &link_s1);
   4160  1.7.2.2  jdolecek 
   4161  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS ||
   4162  1.7.2.2  jdolecek 	    (link_s1 & IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE) == 0) {
   4163  1.7.2.2  jdolecek 		DEBUGOUT("Auto-Negotiation did not complete\n");
   4164  1.7.2.2  jdolecek 		status = IXGBE_ERR_FC_NOT_NEGOTIATED;
   4165  1.7.2.2  jdolecek 		goto out;
   4166  1.7.2.2  jdolecek 	}
   4167  1.7.2.2  jdolecek 
   4168  1.7.2.2  jdolecek 	/* Read the 10g AN autoc and LP ability registers and resolve
   4169  1.7.2.2  jdolecek 	 * local flow control settings accordingly
   4170  1.7.2.2  jdolecek 	 */
   4171  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   4172  1.7.2.2  jdolecek 				IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
   4173  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl_1);
   4174  1.7.2.2  jdolecek 
   4175  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS) {
   4176  1.7.2.2  jdolecek 		DEBUGOUT("Auto-Negotiation did not complete\n");
   4177  1.7.2.2  jdolecek 		goto out;
   4178  1.7.2.2  jdolecek 	}
   4179  1.7.2.2  jdolecek 
   4180  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   4181  1.7.2.2  jdolecek 				IXGBE_KRM_LP_BASE_PAGE_HIGH(hw->bus.lan_id),
   4182  1.7.2.2  jdolecek 				IXGBE_SB_IOSF_TARGET_KR_PHY, &lp_an_page_low);
   4183  1.7.2.2  jdolecek 
   4184  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS) {
   4185  1.7.2.2  jdolecek 		DEBUGOUT("Auto-Negotiation did not complete\n");
   4186  1.7.2.2  jdolecek 		goto out;
   4187  1.7.2.2  jdolecek 	}
   4188  1.7.2.2  jdolecek 
   4189  1.7.2.2  jdolecek 	status = ixgbe_negotiate_fc(hw, an_cntl_1, lp_an_page_low,
   4190  1.7.2.2  jdolecek 				    IXGBE_KRM_AN_CNTL_1_SYM_PAUSE,
   4191  1.7.2.2  jdolecek 				    IXGBE_KRM_AN_CNTL_1_ASM_PAUSE,
   4192  1.7.2.2  jdolecek 				    IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE,
   4193  1.7.2.2  jdolecek 				    IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE);
   4194  1.7.2.2  jdolecek 
   4195  1.7.2.2  jdolecek out:
   4196  1.7.2.2  jdolecek 	if (status == IXGBE_SUCCESS) {
   4197  1.7.2.2  jdolecek 		hw->fc.fc_was_autonegged = TRUE;
   4198  1.7.2.2  jdolecek 	} else {
   4199  1.7.2.2  jdolecek 		hw->fc.fc_was_autonegged = FALSE;
   4200  1.7.2.2  jdolecek 		hw->fc.current_mode = hw->fc.requested_mode;
   4201  1.7.2.2  jdolecek 	}
   4202  1.7.2.2  jdolecek }
   4203  1.7.2.2  jdolecek 
   4204  1.7.2.2  jdolecek /**
   4205  1.7.2.2  jdolecek  *  ixgbe_fc_autoneg_fiber_x550em_a - passthrough FC settings
   4206  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4207  1.7.2.2  jdolecek  *
   4208  1.7.2.2  jdolecek  **/
   4209  1.7.2.2  jdolecek void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *hw)
   4210  1.7.2.2  jdolecek {
   4211  1.7.2.2  jdolecek 	hw->fc.fc_was_autonegged = FALSE;
   4212  1.7.2.2  jdolecek 	hw->fc.current_mode = hw->fc.requested_mode;
   4213  1.7.2.2  jdolecek }
   4214  1.7.2.2  jdolecek 
   4215  1.7.2.2  jdolecek /**
   4216  1.7.2.2  jdolecek  *  ixgbe_fc_autoneg_sgmii_x550em_a - Enable flow control IEEE clause 37
   4217  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4218  1.7.2.2  jdolecek  *
   4219  1.7.2.2  jdolecek  *  Enable flow control according to IEEE clause 37.
   4220  1.7.2.2  jdolecek  **/
   4221  1.7.2.2  jdolecek void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
   4222  1.7.2.2  jdolecek {
   4223  1.7.2.2  jdolecek 	s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
   4224  1.7.2.2  jdolecek 	u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
   4225  1.7.2.2  jdolecek 	ixgbe_link_speed speed;
   4226  1.7.2.2  jdolecek 	bool link_up;
   4227  1.7.2.2  jdolecek 
   4228  1.7.2.2  jdolecek 	/* AN should have completed when the cable was plugged in.
   4229  1.7.2.2  jdolecek 	 * Look for reasons to bail out.  Bail out if:
   4230  1.7.2.2  jdolecek 	 * - FC autoneg is disabled, or if
   4231  1.7.2.2  jdolecek 	 * - link is not up.
   4232  1.7.2.2  jdolecek 	 */
   4233  1.7.2.2  jdolecek 	if (hw->fc.disable_fc_autoneg) {
   4234  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
   4235  1.7.2.2  jdolecek 			     "Flow control autoneg is disabled");
   4236  1.7.2.2  jdolecek 		goto out;
   4237  1.7.2.2  jdolecek 	}
   4238  1.7.2.2  jdolecek 
   4239  1.7.2.2  jdolecek 	hw->mac.ops.check_link(hw, &speed, &link_up, FALSE);
   4240  1.7.2.2  jdolecek 	if (!link_up) {
   4241  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
   4242  1.7.2.2  jdolecek 		goto out;
   4243  1.7.2.2  jdolecek 	}
   4244  1.7.2.2  jdolecek 
   4245  1.7.2.2  jdolecek 	/* Check if auto-negotiation has completed */
   4246  1.7.2.2  jdolecek 	status = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &info);
   4247  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS ||
   4248  1.7.2.2  jdolecek 	    !(info[0] & FW_PHY_ACT_GET_LINK_INFO_AN_COMPLETE)) {
   4249  1.7.2.2  jdolecek 		DEBUGOUT("Auto-Negotiation did not complete\n");
   4250  1.7.2.2  jdolecek 		status = IXGBE_ERR_FC_NOT_NEGOTIATED;
   4251  1.7.2.2  jdolecek 		goto out;
   4252  1.7.2.2  jdolecek 	}
   4253  1.7.2.2  jdolecek 
   4254  1.7.2.2  jdolecek 	/* Negotiate the flow control */
   4255  1.7.2.2  jdolecek 	status = ixgbe_negotiate_fc(hw, info[0], info[0],
   4256  1.7.2.2  jdolecek 				    FW_PHY_ACT_GET_LINK_INFO_FC_RX,
   4257  1.7.2.2  jdolecek 				    FW_PHY_ACT_GET_LINK_INFO_FC_TX,
   4258  1.7.2.2  jdolecek 				    FW_PHY_ACT_GET_LINK_INFO_LP_FC_RX,
   4259  1.7.2.2  jdolecek 				    FW_PHY_ACT_GET_LINK_INFO_LP_FC_TX);
   4260  1.7.2.2  jdolecek 
   4261  1.7.2.2  jdolecek out:
   4262  1.7.2.2  jdolecek 	if (status == IXGBE_SUCCESS) {
   4263  1.7.2.2  jdolecek 		hw->fc.fc_was_autonegged = TRUE;
   4264  1.7.2.2  jdolecek 	} else {
   4265  1.7.2.2  jdolecek 		hw->fc.fc_was_autonegged = FALSE;
   4266  1.7.2.2  jdolecek 		hw->fc.current_mode = hw->fc.requested_mode;
   4267  1.7.2.2  jdolecek 	}
   4268  1.7.2.2  jdolecek }
   4269  1.7.2.2  jdolecek 
   4270  1.7.2.2  jdolecek /**
   4271  1.7.2.2  jdolecek  *  ixgbe_setup_fc_backplane_x550em_a - Set up flow control
   4272  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4273  1.7.2.2  jdolecek  *
   4274  1.7.2.2  jdolecek  *  Called at init time to set up flow control.
   4275  1.7.2.2  jdolecek  **/
   4276  1.7.2.2  jdolecek s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *hw)
   4277  1.7.2.2  jdolecek {
   4278  1.7.2.2  jdolecek 	s32 status = IXGBE_SUCCESS;
   4279  1.7.2.2  jdolecek 	u32 an_cntl = 0;
   4280  1.7.2.2  jdolecek 
   4281  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_setup_fc_backplane_x550em_a");
   4282  1.7.2.2  jdolecek 
   4283  1.7.2.2  jdolecek 	/* Validate the requested mode */
   4284  1.7.2.2  jdolecek 	if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
   4285  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
   4286  1.7.2.2  jdolecek 			      "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
   4287  1.7.2.2  jdolecek 		return IXGBE_ERR_INVALID_LINK_SETTINGS;
   4288  1.7.2.2  jdolecek 	}
   4289  1.7.2.2  jdolecek 
   4290  1.7.2.2  jdolecek 	if (hw->fc.requested_mode == ixgbe_fc_default)
   4291  1.7.2.2  jdolecek 		hw->fc.requested_mode = ixgbe_fc_full;
   4292  1.7.2.2  jdolecek 
   4293  1.7.2.2  jdolecek 	/* Set up the 1G and 10G flow control advertisement registers so the
   4294  1.7.2.2  jdolecek 	 * HW will be able to do FC autoneg once the cable is plugged in.  If
   4295  1.7.2.2  jdolecek 	 * we link at 10G, the 1G advertisement is harmless and vice versa.
   4296  1.7.2.2  jdolecek 	 */
   4297  1.7.2.2  jdolecek 	status = hw->mac.ops.read_iosf_sb_reg(hw,
   4298  1.7.2.2  jdolecek 					IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
   4299  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl);
   4300  1.7.2.2  jdolecek 
   4301  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS) {
   4302  1.7.2.2  jdolecek 		DEBUGOUT("Auto-Negotiation did not complete\n");
   4303  1.7.2.2  jdolecek 		return status;
   4304  1.7.2.2  jdolecek 	}
   4305  1.7.2.2  jdolecek 
   4306  1.7.2.2  jdolecek 	/* The possible values of fc.requested_mode are:
   4307  1.7.2.2  jdolecek 	 * 0: Flow control is completely disabled
   4308  1.7.2.2  jdolecek 	 * 1: Rx flow control is enabled (we can receive pause frames,
   4309  1.7.2.2  jdolecek 	 *    but not send pause frames).
   4310  1.7.2.2  jdolecek 	 * 2: Tx flow control is enabled (we can send pause frames but
   4311  1.7.2.2  jdolecek 	 *    we do not support receiving pause frames).
   4312  1.7.2.2  jdolecek 	 * 3: Both Rx and Tx flow control (symmetric) are enabled.
   4313  1.7.2.2  jdolecek 	 * other: Invalid.
   4314  1.7.2.2  jdolecek 	 */
   4315  1.7.2.2  jdolecek 	switch (hw->fc.requested_mode) {
   4316  1.7.2.2  jdolecek 	case ixgbe_fc_none:
   4317  1.7.2.2  jdolecek 		/* Flow control completely disabled by software override. */
   4318  1.7.2.2  jdolecek 		an_cntl &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
   4319  1.7.2.2  jdolecek 			     IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
   4320  1.7.2.2  jdolecek 		break;
   4321  1.7.2.2  jdolecek 	case ixgbe_fc_tx_pause:
   4322  1.7.2.2  jdolecek 		/* Tx Flow control is enabled, and Rx Flow control is
   4323  1.7.2.2  jdolecek 		 * disabled by software override.
   4324  1.7.2.2  jdolecek 		 */
   4325  1.7.2.2  jdolecek 		an_cntl |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
   4326  1.7.2.2  jdolecek 		an_cntl &= ~IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
   4327  1.7.2.2  jdolecek 		break;
   4328  1.7.2.2  jdolecek 	case ixgbe_fc_rx_pause:
   4329  1.7.2.2  jdolecek 		/* Rx Flow control is enabled and Tx Flow control is
   4330  1.7.2.2  jdolecek 		 * disabled by software override. Since there really
   4331  1.7.2.2  jdolecek 		 * isn't a way to advertise that we are capable of RX
   4332  1.7.2.2  jdolecek 		 * Pause ONLY, we will advertise that we support both
   4333  1.7.2.2  jdolecek 		 * symmetric and asymmetric Rx PAUSE, as such we fall
   4334  1.7.2.2  jdolecek 		 * through to the fc_full statement.  Later, we will
   4335  1.7.2.2  jdolecek 		 * disable the adapter's ability to send PAUSE frames.
   4336  1.7.2.2  jdolecek 		 */
   4337  1.7.2.2  jdolecek 	case ixgbe_fc_full:
   4338  1.7.2.2  jdolecek 		/* Flow control (both Rx and Tx) is enabled by SW override. */
   4339  1.7.2.2  jdolecek 		an_cntl |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
   4340  1.7.2.2  jdolecek 			   IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
   4341  1.7.2.2  jdolecek 		break;
   4342  1.7.2.2  jdolecek 	default:
   4343  1.7.2.2  jdolecek 		ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
   4344  1.7.2.2  jdolecek 			      "Flow control param set incorrectly\n");
   4345  1.7.2.2  jdolecek 		return IXGBE_ERR_CONFIG;
   4346  1.7.2.2  jdolecek 	}
   4347  1.7.2.2  jdolecek 
   4348  1.7.2.2  jdolecek 	status = hw->mac.ops.write_iosf_sb_reg(hw,
   4349  1.7.2.2  jdolecek 					IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
   4350  1.7.2.2  jdolecek 					IXGBE_SB_IOSF_TARGET_KR_PHY, an_cntl);
   4351  1.7.2.2  jdolecek 
   4352  1.7.2.2  jdolecek 	/* Restart auto-negotiation. */
   4353  1.7.2.2  jdolecek 	status = ixgbe_restart_an_internal_phy_x550em(hw);
   4354  1.7.2.2  jdolecek 
   4355  1.7.2.2  jdolecek 	return status;
   4356  1.7.2.2  jdolecek }
   4357  1.7.2.2  jdolecek 
   4358  1.7.2.2  jdolecek /**
   4359  1.7.2.2  jdolecek  * ixgbe_set_mux - Set mux for port 1 access with CS4227
   4360  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   4361  1.7.2.2  jdolecek  * @state: set mux if 1, clear if 0
   4362  1.7.2.2  jdolecek  */
   4363  1.7.2.2  jdolecek static void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
   4364  1.7.2.2  jdolecek {
   4365  1.7.2.2  jdolecek 	u32 esdp;
   4366  1.7.2.2  jdolecek 
   4367  1.7.2.2  jdolecek 	if (!hw->bus.lan_id)
   4368  1.7.2.2  jdolecek 		return;
   4369  1.7.2.2  jdolecek 	esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
   4370  1.7.2.2  jdolecek 	if (state)
   4371  1.7.2.2  jdolecek 		esdp |= IXGBE_ESDP_SDP1;
   4372  1.7.2.2  jdolecek 	else
   4373  1.7.2.2  jdolecek 		esdp &= ~IXGBE_ESDP_SDP1;
   4374  1.7.2.2  jdolecek 	IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
   4375  1.7.2.2  jdolecek 	IXGBE_WRITE_FLUSH(hw);
   4376  1.7.2.2  jdolecek }
   4377  1.7.2.2  jdolecek 
   4378  1.7.2.2  jdolecek /**
   4379  1.7.2.2  jdolecek  *  ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
   4380  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4381  1.7.2.2  jdolecek  *  @mask: Mask to specify which semaphore to acquire
   4382  1.7.2.2  jdolecek  *
   4383  1.7.2.2  jdolecek  *  Acquires the SWFW semaphore and sets the I2C MUX
   4384  1.7.2.2  jdolecek  **/
   4385  1.7.2.2  jdolecek s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
   4386  1.7.2.2  jdolecek {
   4387  1.7.2.2  jdolecek 	s32 status;
   4388  1.7.2.2  jdolecek 
   4389  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
   4390  1.7.2.2  jdolecek 
   4391  1.7.2.2  jdolecek 	status = ixgbe_acquire_swfw_sync_X540(hw, mask);
   4392  1.7.2.2  jdolecek 	if (status)
   4393  1.7.2.2  jdolecek 		return status;
   4394  1.7.2.2  jdolecek 
   4395  1.7.2.2  jdolecek 	if (mask & IXGBE_GSSR_I2C_MASK)
   4396  1.7.2.2  jdolecek 		ixgbe_set_mux(hw, 1);
   4397  1.7.2.2  jdolecek 
   4398  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   4399  1.7.2.2  jdolecek }
   4400  1.7.2.2  jdolecek 
   4401  1.7.2.2  jdolecek /**
   4402  1.7.2.2  jdolecek  *  ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
   4403  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4404  1.7.2.2  jdolecek  *  @mask: Mask to specify which semaphore to release
   4405  1.7.2.2  jdolecek  *
   4406  1.7.2.2  jdolecek  *  Releases the SWFW semaphore and sets the I2C MUX
   4407  1.7.2.2  jdolecek  **/
   4408  1.7.2.2  jdolecek void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
   4409  1.7.2.2  jdolecek {
   4410  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
   4411  1.7.2.2  jdolecek 
   4412  1.7.2.2  jdolecek 	if (mask & IXGBE_GSSR_I2C_MASK)
   4413  1.7.2.2  jdolecek 		ixgbe_set_mux(hw, 0);
   4414  1.7.2.2  jdolecek 
   4415  1.7.2.2  jdolecek 	ixgbe_release_swfw_sync_X540(hw, mask);
   4416  1.7.2.2  jdolecek }
   4417  1.7.2.2  jdolecek 
   4418  1.7.2.2  jdolecek /**
   4419  1.7.2.2  jdolecek  *  ixgbe_acquire_swfw_sync_X550a - Acquire SWFW semaphore
   4420  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4421  1.7.2.2  jdolecek  *  @mask: Mask to specify which semaphore to acquire
   4422  1.7.2.2  jdolecek  *
   4423  1.7.2.2  jdolecek  *  Acquires the SWFW semaphore and get the shared phy token as needed
   4424  1.7.2.2  jdolecek  */
   4425  1.7.2.2  jdolecek static s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
   4426  1.7.2.2  jdolecek {
   4427  1.7.2.2  jdolecek 	u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
   4428  1.7.2.2  jdolecek 	int retries = FW_PHY_TOKEN_RETRIES;
   4429  1.7.2.2  jdolecek 	s32 status = IXGBE_SUCCESS;
   4430  1.7.2.2  jdolecek 
   4431  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");
   4432  1.7.2.2  jdolecek 
   4433  1.7.2.2  jdolecek 	while (--retries) {
   4434  1.7.2.2  jdolecek 		status = IXGBE_SUCCESS;
   4435  1.7.2.2  jdolecek 		if (hmask)
   4436  1.7.2.2  jdolecek 			status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
   4437  1.7.2.2  jdolecek 		if (status) {
   4438  1.7.2.2  jdolecek 			DEBUGOUT1("Could not acquire SWFW semaphore, Status = %d\n",
   4439  1.7.2.2  jdolecek 				  status);
   4440  1.7.2.2  jdolecek 			return status;
   4441  1.7.2.2  jdolecek 		}
   4442  1.7.2.2  jdolecek 		if (!(mask & IXGBE_GSSR_TOKEN_SM))
   4443  1.7.2.2  jdolecek 			return IXGBE_SUCCESS;
   4444  1.7.2.2  jdolecek 
   4445  1.7.2.2  jdolecek 		status = ixgbe_get_phy_token(hw);
   4446  1.7.2.2  jdolecek 		if (status == IXGBE_ERR_TOKEN_RETRY)
   4447  1.7.2.2  jdolecek 			DEBUGOUT1("Could not acquire PHY token, Status = %d\n",
   4448  1.7.2.2  jdolecek 				  status);
   4449  1.7.2.2  jdolecek 
   4450  1.7.2.2  jdolecek 		if (status == IXGBE_SUCCESS)
   4451  1.7.2.2  jdolecek 			return IXGBE_SUCCESS;
   4452  1.7.2.2  jdolecek 
   4453  1.7.2.2  jdolecek 		if (hmask)
   4454  1.7.2.2  jdolecek 			ixgbe_release_swfw_sync_X540(hw, hmask);
   4455  1.7.2.2  jdolecek 
   4456  1.7.2.2  jdolecek 		if (status != IXGBE_ERR_TOKEN_RETRY) {
   4457  1.7.2.2  jdolecek 			DEBUGOUT1("Unable to retry acquiring the PHY token, Status = %d\n",
   4458  1.7.2.2  jdolecek 				  status);
   4459  1.7.2.2  jdolecek 			return status;
   4460  1.7.2.2  jdolecek 		}
   4461  1.7.2.2  jdolecek 	}
   4462  1.7.2.2  jdolecek 
   4463  1.7.2.2  jdolecek 	DEBUGOUT1("Semaphore acquisition retries failed!: PHY ID = 0x%08X\n",
   4464  1.7.2.2  jdolecek 		  hw->phy.id);
   4465  1.7.2.2  jdolecek 	return status;
   4466  1.7.2.2  jdolecek }
   4467  1.7.2.2  jdolecek 
   4468  1.7.2.2  jdolecek /**
   4469  1.7.2.2  jdolecek  *  ixgbe_release_swfw_sync_X550a - Release SWFW semaphore
   4470  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4471  1.7.2.2  jdolecek  *  @mask: Mask to specify which semaphore to release
   4472  1.7.2.2  jdolecek  *
   4473  1.7.2.2  jdolecek  *  Releases the SWFW semaphore and puts the shared phy token as needed
   4474  1.7.2.2  jdolecek  */
   4475  1.7.2.2  jdolecek static void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
   4476  1.7.2.2  jdolecek {
   4477  1.7.2.2  jdolecek 	u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
   4478  1.7.2.2  jdolecek 
   4479  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_release_swfw_sync_X550a");
   4480  1.7.2.2  jdolecek 
   4481  1.7.2.2  jdolecek 	if (mask & IXGBE_GSSR_TOKEN_SM)
   4482  1.7.2.2  jdolecek 		ixgbe_put_phy_token(hw);
   4483  1.7.2.2  jdolecek 
   4484  1.7.2.2  jdolecek 	if (hmask)
   4485  1.7.2.2  jdolecek 		ixgbe_release_swfw_sync_X540(hw, hmask);
   4486  1.7.2.2  jdolecek }
   4487  1.7.2.2  jdolecek 
   4488  1.7.2.2  jdolecek /**
   4489  1.7.2.2  jdolecek  *  ixgbe_read_phy_reg_x550a  - Reads specified PHY register
   4490  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4491  1.7.2.2  jdolecek  *  @reg_addr: 32 bit address of PHY register to read
   4492  1.7.2.2  jdolecek  *  @phy_data: Pointer to read data from PHY register
   4493  1.7.2.2  jdolecek  *
   4494  1.7.2.2  jdolecek  *  Reads a value from a specified PHY register using the SWFW lock and PHY
   4495  1.7.2.2  jdolecek  *  Token. The PHY Token is needed since the MDIO is shared between to MAC
   4496  1.7.2.2  jdolecek  *  instances.
   4497  1.7.2.2  jdolecek  **/
   4498  1.7.2.2  jdolecek s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
   4499  1.7.2.2  jdolecek 			       u32 device_type, u16 *phy_data)
   4500  1.7.2.2  jdolecek {
   4501  1.7.2.2  jdolecek 	s32 status;
   4502  1.7.2.2  jdolecek 	u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
   4503  1.7.2.2  jdolecek 
   4504  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_read_phy_reg_x550a");
   4505  1.7.2.2  jdolecek 
   4506  1.7.2.2  jdolecek 	if (hw->mac.ops.acquire_swfw_sync(hw, mask))
   4507  1.7.2.2  jdolecek 		return IXGBE_ERR_SWFW_SYNC;
   4508  1.7.2.2  jdolecek 
   4509  1.7.2.2  jdolecek 	status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
   4510  1.7.2.2  jdolecek 
   4511  1.7.2.2  jdolecek 	hw->mac.ops.release_swfw_sync(hw, mask);
   4512  1.7.2.2  jdolecek 
   4513  1.7.2.2  jdolecek 	return status;
   4514  1.7.2.2  jdolecek }
   4515  1.7.2.2  jdolecek 
   4516  1.7.2.2  jdolecek /**
   4517  1.7.2.2  jdolecek  *  ixgbe_write_phy_reg_x550a - Writes specified PHY register
   4518  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4519  1.7.2.2  jdolecek  *  @reg_addr: 32 bit PHY register to write
   4520  1.7.2.2  jdolecek  *  @device_type: 5 bit device type
   4521  1.7.2.2  jdolecek  *  @phy_data: Data to write to the PHY register
   4522  1.7.2.2  jdolecek  *
   4523  1.7.2.2  jdolecek  *  Writes a value to specified PHY register using the SWFW lock and PHY Token.
   4524  1.7.2.2  jdolecek  *  The PHY Token is needed since the MDIO is shared between to MAC instances.
   4525  1.7.2.2  jdolecek  **/
   4526  1.7.2.2  jdolecek s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
   4527  1.7.2.2  jdolecek 				u32 device_type, u16 phy_data)
   4528  1.7.2.2  jdolecek {
   4529  1.7.2.2  jdolecek 	s32 status;
   4530  1.7.2.2  jdolecek 	u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
   4531  1.7.2.2  jdolecek 
   4532  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_write_phy_reg_x550a");
   4533  1.7.2.2  jdolecek 
   4534  1.7.2.2  jdolecek 	if (hw->mac.ops.acquire_swfw_sync(hw, mask) == IXGBE_SUCCESS) {
   4535  1.7.2.2  jdolecek 		status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
   4536  1.7.2.2  jdolecek 						 phy_data);
   4537  1.7.2.2  jdolecek 		hw->mac.ops.release_swfw_sync(hw, mask);
   4538  1.7.2.2  jdolecek 	} else {
   4539  1.7.2.2  jdolecek 		status = IXGBE_ERR_SWFW_SYNC;
   4540  1.7.2.2  jdolecek 	}
   4541  1.7.2.2  jdolecek 
   4542  1.7.2.2  jdolecek 	return status;
   4543  1.7.2.2  jdolecek }
   4544  1.7.2.2  jdolecek 
   4545  1.7.2.2  jdolecek /**
   4546  1.7.2.2  jdolecek  * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
   4547  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   4548  1.7.2.2  jdolecek  *
   4549  1.7.2.2  jdolecek  * Handle external Base T PHY interrupt. If high temperature
   4550  1.7.2.2  jdolecek  * failure alarm then return error, else if link status change
   4551  1.7.2.2  jdolecek  * then setup internal/external PHY link
   4552  1.7.2.2  jdolecek  *
   4553  1.7.2.2  jdolecek  * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
   4554  1.7.2.2  jdolecek  * failure alarm, else return PHY access status.
   4555  1.7.2.2  jdolecek  */
   4556  1.7.2.2  jdolecek s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
   4557  1.7.2.2  jdolecek {
   4558  1.7.2.2  jdolecek 	bool lsc;
   4559  1.7.2.2  jdolecek 	u32 status;
   4560  1.7.2.2  jdolecek 
   4561  1.7.2.2  jdolecek 	status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
   4562  1.7.2.2  jdolecek 
   4563  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   4564  1.7.2.2  jdolecek 		return status;
   4565  1.7.2.2  jdolecek 
   4566  1.7.2.2  jdolecek 	if (lsc)
   4567  1.7.2.2  jdolecek 		return ixgbe_setup_internal_phy(hw);
   4568  1.7.2.2  jdolecek 
   4569  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   4570  1.7.2.2  jdolecek }
   4571  1.7.2.2  jdolecek 
   4572  1.7.2.2  jdolecek /**
   4573  1.7.2.2  jdolecek  * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
   4574  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   4575  1.7.2.2  jdolecek  * @speed: new link speed
   4576  1.7.2.2  jdolecek  * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
   4577  1.7.2.2  jdolecek  *
   4578  1.7.2.2  jdolecek  * Setup internal/external PHY link speed based on link speed, then set
   4579  1.7.2.2  jdolecek  * external PHY auto advertised link speed.
   4580  1.7.2.2  jdolecek  *
   4581  1.7.2.2  jdolecek  * Returns error status for any failure
   4582  1.7.2.2  jdolecek  **/
   4583  1.7.2.2  jdolecek s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
   4584  1.7.2.2  jdolecek 				  ixgbe_link_speed speed,
   4585  1.7.2.2  jdolecek 				  bool autoneg_wait_to_complete)
   4586  1.7.2.2  jdolecek {
   4587  1.7.2.2  jdolecek 	s32 status;
   4588  1.7.2.2  jdolecek 	ixgbe_link_speed force_speed;
   4589  1.7.2.2  jdolecek 
   4590  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
   4591  1.7.2.2  jdolecek 
   4592  1.7.2.2  jdolecek 	/* Setup internal/external PHY link speed to iXFI (10G), unless
   4593  1.7.2.2  jdolecek 	 * only 1G is auto advertised then setup KX link.
   4594  1.7.2.2  jdolecek 	 */
   4595  1.7.2.2  jdolecek 	if (speed & IXGBE_LINK_SPEED_10GB_FULL)
   4596  1.7.2.2  jdolecek 		force_speed = IXGBE_LINK_SPEED_10GB_FULL;
   4597  1.7.2.2  jdolecek 	else
   4598  1.7.2.2  jdolecek 		force_speed = IXGBE_LINK_SPEED_1GB_FULL;
   4599  1.7.2.2  jdolecek 
   4600  1.7.2.2  jdolecek 	/* If X552 and internal link mode is XFI, then setup XFI internal link.
   4601  1.7.2.2  jdolecek 	 */
   4602  1.7.2.2  jdolecek 	if (hw->mac.type == ixgbe_mac_X550EM_x &&
   4603  1.7.2.2  jdolecek 	    !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
   4604  1.7.2.2  jdolecek 		status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
   4605  1.7.2.2  jdolecek 
   4606  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   4607  1.7.2.2  jdolecek 			return status;
   4608  1.7.2.2  jdolecek 	}
   4609  1.7.2.2  jdolecek 
   4610  1.7.2.2  jdolecek 	return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
   4611  1.7.2.2  jdolecek }
   4612  1.7.2.2  jdolecek 
   4613  1.7.2.2  jdolecek /**
   4614  1.7.2.2  jdolecek  * ixgbe_check_link_t_X550em - Determine link and speed status
   4615  1.7.2.2  jdolecek  * @hw: pointer to hardware structure
   4616  1.7.2.2  jdolecek  * @speed: pointer to link speed
   4617  1.7.2.2  jdolecek  * @link_up: TRUE when link is up
   4618  1.7.2.2  jdolecek  * @link_up_wait_to_complete: bool used to wait for link up or not
   4619  1.7.2.2  jdolecek  *
   4620  1.7.2.2  jdolecek  * Check that both the MAC and X557 external PHY have link.
   4621  1.7.2.2  jdolecek  **/
   4622  1.7.2.2  jdolecek s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
   4623  1.7.2.2  jdolecek 			      bool *link_up, bool link_up_wait_to_complete)
   4624  1.7.2.2  jdolecek {
   4625  1.7.2.2  jdolecek 	u32 status;
   4626  1.7.2.2  jdolecek 	u16 i, autoneg_status = 0;
   4627  1.7.2.2  jdolecek 
   4628  1.7.2.2  jdolecek 	if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
   4629  1.7.2.2  jdolecek 		return IXGBE_ERR_CONFIG;
   4630  1.7.2.2  jdolecek 
   4631  1.7.2.2  jdolecek 	status = ixgbe_check_mac_link_generic(hw, speed, link_up,
   4632  1.7.2.2  jdolecek 					      link_up_wait_to_complete);
   4633  1.7.2.2  jdolecek 
   4634  1.7.2.2  jdolecek 	/* If check link fails or MAC link is not up, then return */
   4635  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS || !(*link_up))
   4636  1.7.2.2  jdolecek 		return status;
   4637  1.7.2.2  jdolecek 
   4638  1.7.2.2  jdolecek 	/* MAC link is up, so check external PHY link.
   4639  1.7.2.2  jdolecek 	 * X557 PHY. Link status is latching low, and can only be used to detect
   4640  1.7.2.2  jdolecek 	 * link drop, and not the current status of the link without performing
   4641  1.7.2.2  jdolecek 	 * back-to-back reads.
   4642  1.7.2.2  jdolecek 	 */
   4643  1.7.2.2  jdolecek 	for (i = 0; i < 2; i++) {
   4644  1.7.2.2  jdolecek 		status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
   4645  1.7.2.2  jdolecek 				      IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
   4646  1.7.2.2  jdolecek 				      &autoneg_status);
   4647  1.7.2.2  jdolecek 
   4648  1.7.2.2  jdolecek 		if (status != IXGBE_SUCCESS)
   4649  1.7.2.2  jdolecek 			return status;
   4650  1.7.2.2  jdolecek 	}
   4651  1.7.2.2  jdolecek 
   4652  1.7.2.2  jdolecek 	/* If external PHY link is not up, then indicate link not up */
   4653  1.7.2.2  jdolecek 	if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
   4654  1.7.2.2  jdolecek 		*link_up = FALSE;
   4655  1.7.2.2  jdolecek 
   4656  1.7.2.2  jdolecek 	return IXGBE_SUCCESS;
   4657  1.7.2.2  jdolecek }
   4658  1.7.2.2  jdolecek 
   4659  1.7.2.2  jdolecek /**
   4660  1.7.2.2  jdolecek  *  ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
   4661  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4662  1.7.2.2  jdolecek  **/
   4663  1.7.2.2  jdolecek s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
   4664  1.7.2.2  jdolecek {
   4665  1.7.2.2  jdolecek 	s32 status;
   4666  1.7.2.2  jdolecek 
   4667  1.7.2.2  jdolecek 	status = ixgbe_reset_phy_generic(hw);
   4668  1.7.2.2  jdolecek 
   4669  1.7.2.2  jdolecek 	if (status != IXGBE_SUCCESS)
   4670  1.7.2.2  jdolecek 		return status;
   4671  1.7.2.2  jdolecek 
   4672  1.7.2.2  jdolecek 	/* Configure Link Status Alarm and Temperature Threshold interrupts */
   4673  1.7.2.2  jdolecek 	return ixgbe_enable_lasi_ext_t_x550em(hw);
   4674  1.7.2.2  jdolecek }
   4675  1.7.2.2  jdolecek 
   4676  1.7.2.2  jdolecek /**
   4677  1.7.2.2  jdolecek  *  ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
   4678  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4679  1.7.2.2  jdolecek  *  @led_idx: led number to turn on
   4680  1.7.2.2  jdolecek  **/
   4681  1.7.2.2  jdolecek s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
   4682  1.7.2.2  jdolecek {
   4683  1.7.2.2  jdolecek 	u16 phy_data;
   4684  1.7.2.2  jdolecek 
   4685  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_led_on_t_X550em");
   4686  1.7.2.2  jdolecek 
   4687  1.7.2.2  jdolecek 	if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
   4688  1.7.2.2  jdolecek 		return IXGBE_ERR_PARAM;
   4689  1.7.2.2  jdolecek 
   4690  1.7.2.2  jdolecek 	/* To turn on the LED, set mode to ON. */
   4691  1.7.2.2  jdolecek 	ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
   4692  1.7.2.2  jdolecek 			   IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
   4693  1.7.2.2  jdolecek 	phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
   4694  1.7.2.2  jdolecek 	ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
   4695  1.7.2.2  jdolecek 			    IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
   4696  1.7.2.2  jdolecek 
   4697  1.7.2.2  jdolecek 	/* Some designs have the LEDs wired to the MAC */
   4698  1.7.2.2  jdolecek 	return ixgbe_led_on_generic(hw, led_idx);
   4699  1.7.2.2  jdolecek }
   4700  1.7.2.2  jdolecek 
   4701  1.7.2.2  jdolecek /**
   4702  1.7.2.2  jdolecek  *  ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
   4703  1.7.2.2  jdolecek  *  @hw: pointer to hardware structure
   4704  1.7.2.2  jdolecek  *  @led_idx: led number to turn off
   4705  1.7.2.2  jdolecek  **/
   4706  1.7.2.2  jdolecek s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
   4707  1.7.2.2  jdolecek {
   4708  1.7.2.2  jdolecek 	u16 phy_data;
   4709  1.7.2.2  jdolecek 
   4710  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_led_off_t_X550em");
   4711  1.7.2.2  jdolecek 
   4712  1.7.2.2  jdolecek 	if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
   4713  1.7.2.2  jdolecek 		return IXGBE_ERR_PARAM;
   4714  1.7.2.2  jdolecek 
   4715  1.7.2.2  jdolecek 	/* To turn on the LED, set mode to ON. */
   4716  1.7.2.2  jdolecek 	ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
   4717  1.7.2.2  jdolecek 			   IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
   4718  1.7.2.2  jdolecek 	phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
   4719  1.7.2.2  jdolecek 	ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
   4720  1.7.2.2  jdolecek 			    IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
   4721  1.7.2.2  jdolecek 
   4722  1.7.2.2  jdolecek 	/* Some designs have the LEDs wired to the MAC */
   4723  1.7.2.2  jdolecek 	return ixgbe_led_off_generic(hw, led_idx);
   4724  1.7.2.2  jdolecek }
   4725  1.7.2.2  jdolecek 
   4726  1.7.2.2  jdolecek /**
   4727  1.7.2.2  jdolecek  *  ixgbe_set_fw_drv_ver_x550 - Sends driver version to firmware
   4728  1.7.2.2  jdolecek  *  @hw: pointer to the HW structure
   4729  1.7.2.2  jdolecek  *  @maj: driver version major number
   4730  1.7.2.2  jdolecek  *  @min: driver version minor number
   4731  1.7.2.2  jdolecek  *  @build: driver version build number
   4732  1.7.2.2  jdolecek  *  @sub: driver version sub build number
   4733  1.7.2.2  jdolecek  *  @len: length of driver_ver string
   4734  1.7.2.2  jdolecek  *  @driver_ver: driver string
   4735  1.7.2.2  jdolecek  *
   4736  1.7.2.2  jdolecek  *  Sends driver version number to firmware through the manageability
   4737  1.7.2.2  jdolecek  *  block.  On success return IXGBE_SUCCESS
   4738  1.7.2.2  jdolecek  *  else returns IXGBE_ERR_SWFW_SYNC when encountering an error acquiring
   4739  1.7.2.2  jdolecek  *  semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
   4740  1.7.2.2  jdolecek  **/
   4741  1.7.2.2  jdolecek s32 ixgbe_set_fw_drv_ver_x550(struct ixgbe_hw *hw, u8 maj, u8 min,
   4742  1.7.2.2  jdolecek 			      u8 build, u8 sub, u16 len, const char *driver_ver)
   4743  1.7.2.2  jdolecek {
   4744  1.7.2.2  jdolecek 	struct ixgbe_hic_drv_info2 fw_cmd;
   4745  1.7.2.2  jdolecek 	s32 ret_val = IXGBE_SUCCESS;
   4746  1.7.2.2  jdolecek 	int i;
   4747  1.7.2.2  jdolecek 
   4748  1.7.2.2  jdolecek 	DEBUGFUNC("ixgbe_set_fw_drv_ver_x550");
   4749  1.7.2.2  jdolecek 
   4750  1.7.2.2  jdolecek 	if ((len == 0) || (driver_ver == NULL) ||
   4751  1.7.2.2  jdolecek 	   (len > sizeof(fw_cmd.driver_string)))
   4752  1.7.2.2  jdolecek 		return IXGBE_ERR_INVALID_ARGUMENT;
   4753  1.7.2.2  jdolecek 
   4754  1.7.2.2  jdolecek 	fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
   4755  1.7.2.2  jdolecek 	fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN + len;
   4756  1.7.2.2  jdolecek 	fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
   4757  1.7.2.2  jdolecek 	fw_cmd.port_num = (u8)hw->bus.func;
   4758  1.7.2.2  jdolecek 	fw_cmd.ver_maj = maj;
   4759  1.7.2.2  jdolecek 	fw_cmd.ver_min = min;
   4760  1.7.2.2  jdolecek 	fw_cmd.ver_build = build;
   4761  1.7.2.2  jdolecek 	fw_cmd.ver_sub = sub;
   4762  1.7.2.2  jdolecek 	fw_cmd.hdr.checksum = 0;
   4763  1.7.2.2  jdolecek 	memcpy(fw_cmd.driver_string, driver_ver, len);
   4764  1.7.2.2  jdolecek 	fw_cmd.hdr.checksum = ixgbe_calculate_checksum((u8 *)&fw_cmd,
   4765  1.7.2.2  jdolecek 				(FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));
   4766  1.7.2.2  jdolecek 
   4767  1.7.2.2  jdolecek 	for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
   4768  1.7.2.2  jdolecek 		ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
   4769  1.7.2.2  jdolecek 						       sizeof(fw_cmd),
   4770  1.7.2.2  jdolecek 						       IXGBE_HI_COMMAND_TIMEOUT,
   4771  1.7.2.2  jdolecek 						       TRUE);
   4772  1.7.2.2  jdolecek 		if (ret_val != IXGBE_SUCCESS)
   4773  1.7.2.2  jdolecek 			continue;
   4774  1.7.2.2  jdolecek 
   4775  1.7.2.2  jdolecek 		if (fw_cmd.hdr.cmd_or_resp.ret_status ==
   4776  1.7.2.2  jdolecek 		    FW_CEM_RESP_STATUS_SUCCESS)
   4777  1.7.2.2  jdolecek 			ret_val = IXGBE_SUCCESS;
   4778  1.7.2.2  jdolecek 		else
   4779  1.7.2.2  jdolecek 			ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND;
   4780  1.7.2.2  jdolecek 
   4781  1.7.2.2  jdolecek 		break;
   4782  1.7.2.2  jdolecek 	}
   4783  1.7.2.2  jdolecek 
   4784  1.7.2.2  jdolecek 	return ret_val;
   4785  1.7.2.2  jdolecek }
   4786