Home | History | Annotate | Line # | Download | only in ixgbe
ixgbe_x540.c revision 1.18
      1   1.1  msaitoh /******************************************************************************
      2  1.12  msaitoh   SPDX-License-Identifier: BSD-3-Clause
      3   1.1  msaitoh 
      4  1.10  msaitoh   Copyright (c) 2001-2017, Intel Corporation
      5   1.1  msaitoh   All rights reserved.
      6  1.10  msaitoh 
      7  1.10  msaitoh   Redistribution and use in source and binary forms, with or without
      8   1.1  msaitoh   modification, are permitted provided that the following conditions are met:
      9  1.10  msaitoh 
     10  1.10  msaitoh    1. Redistributions of source code must retain the above copyright notice,
     11   1.1  msaitoh       this list of conditions and the following disclaimer.
     12  1.10  msaitoh 
     13  1.10  msaitoh    2. Redistributions in binary form must reproduce the above copyright
     14  1.10  msaitoh       notice, this list of conditions and the following disclaimer in the
     15   1.1  msaitoh       documentation and/or other materials provided with the distribution.
     16  1.10  msaitoh 
     17  1.10  msaitoh    3. Neither the name of the Intel Corporation nor the names of its
     18  1.10  msaitoh       contributors may be used to endorse or promote products derived from
     19   1.1  msaitoh       this software without specific prior written permission.
     20  1.10  msaitoh 
     21   1.1  msaitoh   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     22  1.10  msaitoh   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  1.10  msaitoh   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  1.10  msaitoh   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     25  1.10  msaitoh   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26  1.10  msaitoh   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27  1.10  msaitoh   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  1.10  msaitoh   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29  1.10  msaitoh   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30   1.1  msaitoh   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31   1.1  msaitoh   POSSIBILITY OF SUCH DAMAGE.
     32   1.1  msaitoh 
     33   1.1  msaitoh ******************************************************************************/
     34  1.15  msaitoh /*$FreeBSD: head/sys/dev/ixgbe/ixgbe_x540.c 331224 2018-03-19 20:55:05Z erj $*/
     35   1.1  msaitoh 
     36  1.18  msaitoh #include <sys/cdefs.h>
     37  1.18  msaitoh __KERNEL_RCSID(0, "$NetBSD: ixgbe_x540.c,v 1.18 2021/04/30 06:55:32 msaitoh Exp $");
     38  1.18  msaitoh 
     39   1.1  msaitoh #include "ixgbe_x540.h"
     40   1.1  msaitoh #include "ixgbe_type.h"
     41   1.1  msaitoh #include "ixgbe_api.h"
     42   1.1  msaitoh #include "ixgbe_common.h"
     43   1.1  msaitoh #include "ixgbe_phy.h"
     44   1.1  msaitoh 
     45   1.5  msaitoh #define IXGBE_X540_MAX_TX_QUEUES	128
     46   1.5  msaitoh #define IXGBE_X540_MAX_RX_QUEUES	128
     47   1.5  msaitoh #define IXGBE_X540_RAR_ENTRIES		128
     48   1.5  msaitoh #define IXGBE_X540_MC_TBL_SIZE		128
     49   1.5  msaitoh #define IXGBE_X540_VFT_TBL_SIZE		128
     50   1.5  msaitoh #define IXGBE_X540_RX_PB_SIZE		384
     51   1.5  msaitoh 
     52   1.1  msaitoh static s32 ixgbe_poll_flash_update_done_X540(struct ixgbe_hw *hw);
     53   1.1  msaitoh static s32 ixgbe_get_swfw_sync_semaphore(struct ixgbe_hw *hw);
     54   1.1  msaitoh static void ixgbe_release_swfw_sync_semaphore(struct ixgbe_hw *hw);
     55   1.1  msaitoh 
     56   1.1  msaitoh /**
     57   1.1  msaitoh  *  ixgbe_init_ops_X540 - Inits func ptrs and MAC type
     58   1.1  msaitoh  *  @hw: pointer to hardware structure
     59   1.1  msaitoh  *
     60   1.1  msaitoh  *  Initialize the function pointers and assign the MAC type for X540.
     61   1.1  msaitoh  *  Does not touch the hardware.
     62   1.1  msaitoh  **/
     63   1.1  msaitoh s32 ixgbe_init_ops_X540(struct ixgbe_hw *hw)
     64   1.1  msaitoh {
     65   1.1  msaitoh 	struct ixgbe_mac_info *mac = &hw->mac;
     66   1.1  msaitoh 	struct ixgbe_phy_info *phy = &hw->phy;
     67   1.1  msaitoh 	struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
     68   1.1  msaitoh 	s32 ret_val;
     69   1.1  msaitoh 
     70   1.1  msaitoh 	DEBUGFUNC("ixgbe_init_ops_X540");
     71   1.1  msaitoh 
     72   1.1  msaitoh 	ret_val = ixgbe_init_phy_ops_generic(hw);
     73   1.1  msaitoh 	ret_val = ixgbe_init_ops_generic(hw);
     74   1.1  msaitoh 
     75   1.1  msaitoh 
     76   1.1  msaitoh 	/* EEPROM */
     77   1.5  msaitoh 	eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
     78   1.5  msaitoh 	eeprom->ops.read = ixgbe_read_eerd_X540;
     79   1.5  msaitoh 	eeprom->ops.read_buffer = ixgbe_read_eerd_buffer_X540;
     80   1.5  msaitoh 	eeprom->ops.write = ixgbe_write_eewr_X540;
     81   1.5  msaitoh 	eeprom->ops.write_buffer = ixgbe_write_eewr_buffer_X540;
     82   1.5  msaitoh 	eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X540;
     83   1.5  msaitoh 	eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X540;
     84   1.5  msaitoh 	eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X540;
     85   1.1  msaitoh 
     86   1.1  msaitoh 	/* PHY */
     87   1.5  msaitoh 	phy->ops.init = ixgbe_init_phy_ops_generic;
     88   1.1  msaitoh 	phy->ops.reset = NULL;
     89   1.9  msaitoh 	phy->ops.set_phy_power = ixgbe_set_copper_phy_power;
     90   1.1  msaitoh 
     91   1.1  msaitoh 	/* MAC */
     92   1.5  msaitoh 	mac->ops.reset_hw = ixgbe_reset_hw_X540;
     93   1.5  msaitoh 	mac->ops.enable_relaxed_ordering = ixgbe_enable_relaxed_ordering_gen2;
     94   1.5  msaitoh 	mac->ops.get_media_type = ixgbe_get_media_type_X540;
     95   1.1  msaitoh 	mac->ops.get_supported_physical_layer =
     96   1.5  msaitoh 				    ixgbe_get_supported_physical_layer_X540;
     97   1.1  msaitoh 	mac->ops.read_analog_reg8 = NULL;
     98   1.1  msaitoh 	mac->ops.write_analog_reg8 = NULL;
     99   1.5  msaitoh 	mac->ops.start_hw = ixgbe_start_hw_X540;
    100   1.5  msaitoh 	mac->ops.get_san_mac_addr = ixgbe_get_san_mac_addr_generic;
    101   1.5  msaitoh 	mac->ops.set_san_mac_addr = ixgbe_set_san_mac_addr_generic;
    102   1.5  msaitoh 	mac->ops.get_device_caps = ixgbe_get_device_caps_generic;
    103   1.5  msaitoh 	mac->ops.get_wwn_prefix = ixgbe_get_wwn_prefix_generic;
    104   1.5  msaitoh 	mac->ops.get_fcoe_boot_status = ixgbe_get_fcoe_boot_status_generic;
    105   1.5  msaitoh 	mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X540;
    106   1.5  msaitoh 	mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X540;
    107  1.10  msaitoh 	mac->ops.init_swfw_sync = ixgbe_init_swfw_sync_X540;
    108   1.5  msaitoh 	mac->ops.disable_sec_rx_path = ixgbe_disable_sec_rx_path_generic;
    109   1.5  msaitoh 	mac->ops.enable_sec_rx_path = ixgbe_enable_sec_rx_path_generic;
    110   1.1  msaitoh 
    111   1.1  msaitoh 	/* RAR, Multicast, VLAN */
    112   1.5  msaitoh 	mac->ops.set_vmdq = ixgbe_set_vmdq_generic;
    113   1.5  msaitoh 	mac->ops.set_vmdq_san_mac = ixgbe_set_vmdq_san_mac_generic;
    114   1.5  msaitoh 	mac->ops.clear_vmdq = ixgbe_clear_vmdq_generic;
    115   1.5  msaitoh 	mac->ops.insert_mac_addr = ixgbe_insert_mac_addr_generic;
    116   1.1  msaitoh 	mac->rar_highwater = 1;
    117   1.5  msaitoh 	mac->ops.set_vfta = ixgbe_set_vfta_generic;
    118   1.5  msaitoh 	mac->ops.set_vlvf = ixgbe_set_vlvf_generic;
    119   1.5  msaitoh 	mac->ops.clear_vfta = ixgbe_clear_vfta_generic;
    120   1.5  msaitoh 	mac->ops.init_uta_tables = ixgbe_init_uta_tables_generic;
    121   1.5  msaitoh 	mac->ops.set_mac_anti_spoofing = ixgbe_set_mac_anti_spoofing;
    122   1.5  msaitoh 	mac->ops.set_vlan_anti_spoofing = ixgbe_set_vlan_anti_spoofing;
    123   1.1  msaitoh 
    124   1.1  msaitoh 	/* Link */
    125   1.1  msaitoh 	mac->ops.get_link_capabilities =
    126   1.5  msaitoh 				ixgbe_get_copper_link_capabilities_generic;
    127   1.5  msaitoh 	mac->ops.setup_link = ixgbe_setup_mac_link_X540;
    128   1.5  msaitoh 	mac->ops.setup_rxpba = ixgbe_set_rxpba_generic;
    129   1.5  msaitoh 	mac->ops.check_link = ixgbe_check_mac_link_generic;
    130  1.10  msaitoh 	mac->ops.bypass_rw = ixgbe_bypass_rw_generic;
    131  1.10  msaitoh 	mac->ops.bypass_valid_rd = ixgbe_bypass_valid_rd_generic;
    132  1.10  msaitoh 	mac->ops.bypass_set = ixgbe_bypass_set_generic;
    133  1.10  msaitoh 	mac->ops.bypass_rd_eep = ixgbe_bypass_rd_eep_generic;
    134   1.1  msaitoh 
    135   1.3  msaitoh 
    136   1.5  msaitoh 	mac->mcft_size		= IXGBE_X540_MC_TBL_SIZE;
    137   1.5  msaitoh 	mac->vft_size		= IXGBE_X540_VFT_TBL_SIZE;
    138   1.5  msaitoh 	mac->num_rar_entries	= IXGBE_X540_RAR_ENTRIES;
    139   1.5  msaitoh 	mac->rx_pb_size		= IXGBE_X540_RX_PB_SIZE;
    140   1.5  msaitoh 	mac->max_rx_queues	= IXGBE_X540_MAX_RX_QUEUES;
    141   1.5  msaitoh 	mac->max_tx_queues	= IXGBE_X540_MAX_TX_QUEUES;
    142   1.1  msaitoh 	mac->max_msix_vectors	= ixgbe_get_pcie_msix_count_generic(hw);
    143   1.1  msaitoh 
    144   1.1  msaitoh 	/*
    145   1.1  msaitoh 	 * FWSM register
    146   1.1  msaitoh 	 * ARC supported; valid only if manageability features are
    147   1.1  msaitoh 	 * enabled.
    148   1.1  msaitoh 	 */
    149   1.7  msaitoh 	mac->arc_subsystem_valid = !!(IXGBE_READ_REG(hw, IXGBE_FWSM_BY_MAC(hw))
    150   1.7  msaitoh 				     & IXGBE_FWSM_MODE_MASK);
    151   1.1  msaitoh 
    152   1.1  msaitoh 	hw->mbx.ops.init_params = ixgbe_init_mbx_params_pf;
    153   1.1  msaitoh 
    154   1.1  msaitoh 	/* LEDs */
    155   1.1  msaitoh 	mac->ops.blink_led_start = ixgbe_blink_led_start_X540;
    156   1.1  msaitoh 	mac->ops.blink_led_stop = ixgbe_blink_led_stop_X540;
    157   1.1  msaitoh 
    158   1.1  msaitoh 	/* Manageability interface */
    159   1.5  msaitoh 	mac->ops.set_fw_drv_ver = ixgbe_set_fw_drv_ver_generic;
    160   1.1  msaitoh 
    161   1.5  msaitoh 	mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
    162   1.4  msaitoh 
    163   1.1  msaitoh 	return ret_val;
    164   1.1  msaitoh }
    165   1.1  msaitoh 
    166   1.1  msaitoh /**
    167   1.1  msaitoh  *  ixgbe_get_link_capabilities_X540 - Determines link capabilities
    168   1.1  msaitoh  *  @hw: pointer to hardware structure
    169   1.1  msaitoh  *  @speed: pointer to link speed
    170   1.1  msaitoh  *  @autoneg: TRUE when autoneg or autotry is enabled
    171   1.1  msaitoh  *
    172   1.1  msaitoh  *  Determines the link capabilities by reading the AUTOC register.
    173   1.1  msaitoh  **/
    174   1.1  msaitoh s32 ixgbe_get_link_capabilities_X540(struct ixgbe_hw *hw,
    175   1.1  msaitoh 				     ixgbe_link_speed *speed,
    176   1.1  msaitoh 				     bool *autoneg)
    177   1.1  msaitoh {
    178   1.1  msaitoh 	ixgbe_get_copper_link_capabilities_generic(hw, speed, autoneg);
    179   1.1  msaitoh 
    180   1.1  msaitoh 	return IXGBE_SUCCESS;
    181   1.1  msaitoh }
    182   1.1  msaitoh 
    183   1.1  msaitoh /**
    184   1.1  msaitoh  *  ixgbe_get_media_type_X540 - Get media type
    185   1.1  msaitoh  *  @hw: pointer to hardware structure
    186   1.1  msaitoh  *
    187   1.1  msaitoh  *  Returns the media type (fiber, copper, backplane)
    188   1.1  msaitoh  **/
    189   1.1  msaitoh enum ixgbe_media_type ixgbe_get_media_type_X540(struct ixgbe_hw *hw)
    190   1.1  msaitoh {
    191   1.1  msaitoh 	UNREFERENCED_1PARAMETER(hw);
    192   1.1  msaitoh 	return ixgbe_media_type_copper;
    193   1.1  msaitoh }
    194   1.1  msaitoh 
    195   1.1  msaitoh /**
    196   1.1  msaitoh  *  ixgbe_setup_mac_link_X540 - Sets the auto advertised capabilities
    197   1.1  msaitoh  *  @hw: pointer to hardware structure
    198   1.1  msaitoh  *  @speed: new link speed
    199   1.1  msaitoh  *  @autoneg_wait_to_complete: TRUE when waiting for completion is needed
    200   1.1  msaitoh  **/
    201   1.1  msaitoh s32 ixgbe_setup_mac_link_X540(struct ixgbe_hw *hw,
    202   1.3  msaitoh 			      ixgbe_link_speed speed,
    203   1.1  msaitoh 			      bool autoneg_wait_to_complete)
    204   1.1  msaitoh {
    205   1.1  msaitoh 	DEBUGFUNC("ixgbe_setup_mac_link_X540");
    206   1.3  msaitoh 	return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
    207   1.1  msaitoh }
    208   1.1  msaitoh 
    209   1.1  msaitoh /**
    210   1.1  msaitoh  *  ixgbe_reset_hw_X540 - Perform hardware reset
    211   1.1  msaitoh  *  @hw: pointer to hardware structure
    212   1.1  msaitoh  *
    213   1.1  msaitoh  *  Resets the hardware by resetting the transmit and receive units, masks
    214   1.1  msaitoh  *  and clears all interrupts, and perform a reset.
    215   1.1  msaitoh  **/
    216   1.1  msaitoh s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw)
    217   1.1  msaitoh {
    218   1.1  msaitoh 	s32 status;
    219   1.1  msaitoh 	u32 ctrl, i;
    220  1.10  msaitoh 	u32 swfw_mask = hw->phy.phy_semaphore_mask;
    221   1.1  msaitoh 
    222   1.1  msaitoh 	DEBUGFUNC("ixgbe_reset_hw_X540");
    223   1.1  msaitoh 
    224   1.1  msaitoh 	/* Call adapter stop to disable tx/rx and clear interrupts */
    225   1.1  msaitoh 	status = hw->mac.ops.stop_adapter(hw);
    226   1.1  msaitoh 	if (status != IXGBE_SUCCESS)
    227   1.1  msaitoh 		goto reset_hw_out;
    228   1.1  msaitoh 
    229   1.1  msaitoh 	/* flush pending Tx transactions */
    230   1.1  msaitoh 	ixgbe_clear_tx_pending(hw);
    231   1.1  msaitoh 
    232   1.1  msaitoh mac_reset_top:
    233  1.10  msaitoh 	status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
    234  1.10  msaitoh 	if (status != IXGBE_SUCCESS) {
    235  1.10  msaitoh 		ERROR_REPORT2(IXGBE_ERROR_CAUTION,
    236  1.10  msaitoh 			"semaphore failed with %d", status);
    237  1.10  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    238  1.10  msaitoh 	}
    239   1.1  msaitoh 	ctrl = IXGBE_CTRL_RST;
    240   1.1  msaitoh 	ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
    241   1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
    242   1.1  msaitoh 	IXGBE_WRITE_FLUSH(hw);
    243  1.10  msaitoh 	hw->mac.ops.release_swfw_sync(hw, swfw_mask);
    244   1.1  msaitoh 
    245   1.1  msaitoh 	/* Poll for reset bit to self-clear indicating reset is complete */
    246   1.1  msaitoh 	for (i = 0; i < 10; i++) {
    247   1.1  msaitoh 		usec_delay(1);
    248   1.1  msaitoh 		ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
    249   1.1  msaitoh 		if (!(ctrl & IXGBE_CTRL_RST_MASK))
    250   1.1  msaitoh 			break;
    251   1.1  msaitoh 	}
    252   1.1  msaitoh 
    253   1.1  msaitoh 	if (ctrl & IXGBE_CTRL_RST_MASK) {
    254   1.1  msaitoh 		status = IXGBE_ERR_RESET_FAILED;
    255   1.4  msaitoh 		ERROR_REPORT1(IXGBE_ERROR_POLLING,
    256   1.4  msaitoh 			     "Reset polling failed to complete.\n");
    257   1.1  msaitoh 	}
    258   1.1  msaitoh 	msec_delay(100);
    259   1.1  msaitoh 
    260   1.1  msaitoh 	/*
    261   1.1  msaitoh 	 * Double resets are required for recovery from certain error
    262   1.1  msaitoh 	 * conditions.  Between resets, it is necessary to stall to allow time
    263   1.1  msaitoh 	 * for any pending HW events to complete.
    264   1.1  msaitoh 	 */
    265   1.1  msaitoh 	if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
    266   1.1  msaitoh 		hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
    267   1.1  msaitoh 		goto mac_reset_top;
    268   1.1  msaitoh 	}
    269   1.1  msaitoh 
    270   1.1  msaitoh 	/* Set the Rx packet buffer size. */
    271   1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(0), 384 << IXGBE_RXPBSIZE_SHIFT);
    272   1.1  msaitoh 
    273   1.1  msaitoh 	/* Store the permanent mac address */
    274   1.1  msaitoh 	hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
    275   1.1  msaitoh 
    276   1.1  msaitoh 	/*
    277   1.1  msaitoh 	 * Store MAC address from RAR0, clear receive address registers, and
    278   1.1  msaitoh 	 * clear the multicast table.  Also reset num_rar_entries to 128,
    279   1.1  msaitoh 	 * since we modify this value when programming the SAN MAC address.
    280   1.1  msaitoh 	 */
    281   1.1  msaitoh 	hw->mac.num_rar_entries = 128;
    282   1.1  msaitoh 	hw->mac.ops.init_rx_addrs(hw);
    283   1.1  msaitoh 
    284   1.1  msaitoh 	/* Store the permanent SAN mac address */
    285   1.1  msaitoh 	hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);
    286   1.1  msaitoh 
    287   1.1  msaitoh 	/* Add the SAN MAC address to the RAR only if it's a valid address */
    288   1.1  msaitoh 	if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
    289  1.10  msaitoh 		/* Save the SAN MAC RAR index */
    290  1.10  msaitoh 		hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;
    291  1.10  msaitoh 
    292  1.10  msaitoh 		hw->mac.ops.set_rar(hw, hw->mac.san_mac_rar_index,
    293   1.1  msaitoh 				    hw->mac.san_addr, 0, IXGBE_RAH_AV);
    294   1.1  msaitoh 
    295  1.10  msaitoh 		/* clear VMDq pool/queue selection for this RAR */
    296  1.10  msaitoh 		hw->mac.ops.clear_vmdq(hw, hw->mac.san_mac_rar_index,
    297  1.10  msaitoh 				       IXGBE_CLEAR_VMDQ_ALL);
    298   1.2  msaitoh 
    299   1.1  msaitoh 		/* Reserve the last RAR for the SAN MAC address */
    300   1.1  msaitoh 		hw->mac.num_rar_entries--;
    301   1.1  msaitoh 	}
    302   1.1  msaitoh 
    303   1.1  msaitoh 	/* Store the alternative WWNN/WWPN prefix */
    304   1.1  msaitoh 	hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
    305   1.1  msaitoh 				   &hw->mac.wwpn_prefix);
    306   1.1  msaitoh 
    307   1.1  msaitoh reset_hw_out:
    308   1.1  msaitoh 	return status;
    309   1.1  msaitoh }
    310   1.1  msaitoh 
    311   1.1  msaitoh /**
    312   1.1  msaitoh  *  ixgbe_start_hw_X540 - Prepare hardware for Tx/Rx
    313   1.1  msaitoh  *  @hw: pointer to hardware structure
    314   1.1  msaitoh  *
    315   1.1  msaitoh  *  Starts the hardware using the generic start_hw function
    316   1.1  msaitoh  *  and the generation start_hw function.
    317   1.1  msaitoh  *  Then performs revision-specific operations, if any.
    318   1.1  msaitoh  **/
    319   1.1  msaitoh s32 ixgbe_start_hw_X540(struct ixgbe_hw *hw)
    320   1.1  msaitoh {
    321   1.1  msaitoh 	s32 ret_val = IXGBE_SUCCESS;
    322   1.1  msaitoh 
    323   1.1  msaitoh 	DEBUGFUNC("ixgbe_start_hw_X540");
    324   1.1  msaitoh 
    325   1.1  msaitoh 	ret_val = ixgbe_start_hw_generic(hw);
    326   1.1  msaitoh 	if (ret_val != IXGBE_SUCCESS)
    327   1.1  msaitoh 		goto out;
    328   1.1  msaitoh 
    329   1.1  msaitoh 	ret_val = ixgbe_start_hw_gen2(hw);
    330   1.1  msaitoh 
    331   1.1  msaitoh out:
    332   1.1  msaitoh 	return ret_val;
    333   1.1  msaitoh }
    334   1.1  msaitoh 
    335   1.1  msaitoh /**
    336   1.1  msaitoh  *  ixgbe_get_supported_physical_layer_X540 - Returns physical layer type
    337   1.1  msaitoh  *  @hw: pointer to hardware structure
    338   1.1  msaitoh  *
    339   1.1  msaitoh  *  Determines physical layer capabilities of the current configuration.
    340   1.1  msaitoh  **/
    341  1.10  msaitoh u64 ixgbe_get_supported_physical_layer_X540(struct ixgbe_hw *hw)
    342   1.1  msaitoh {
    343  1.10  msaitoh 	u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
    344   1.1  msaitoh 	u16 ext_ability = 0;
    345   1.1  msaitoh 
    346   1.1  msaitoh 	DEBUGFUNC("ixgbe_get_supported_physical_layer_X540");
    347   1.1  msaitoh 
    348   1.1  msaitoh 	hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
    349   1.1  msaitoh 	IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability);
    350   1.1  msaitoh 	if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
    351   1.1  msaitoh 		physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
    352   1.1  msaitoh 	if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
    353   1.1  msaitoh 		physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
    354   1.1  msaitoh 	if (ext_ability & IXGBE_MDIO_PHY_100BASETX_ABILITY)
    355   1.1  msaitoh 		physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
    356   1.1  msaitoh 
    357  1.11  msaitoh 	if (hw->mac.type == ixgbe_mac_X550) {
    358  1.11  msaitoh 		physical_layer |= IXGBE_PHYSICAL_LAYER_2500BASE_T
    359  1.11  msaitoh 		    | IXGBE_PHYSICAL_LAYER_5GBASE_T;
    360  1.11  msaitoh 	}
    361  1.11  msaitoh 
    362   1.1  msaitoh 	return physical_layer;
    363   1.1  msaitoh }
    364   1.1  msaitoh 
    365   1.1  msaitoh /**
    366   1.1  msaitoh  *  ixgbe_init_eeprom_params_X540 - Initialize EEPROM params
    367   1.1  msaitoh  *  @hw: pointer to hardware structure
    368   1.1  msaitoh  *
    369   1.1  msaitoh  *  Initializes the EEPROM parameters ixgbe_eeprom_info within the
    370   1.1  msaitoh  *  ixgbe_hw struct in order to set up EEPROM access.
    371   1.1  msaitoh  **/
    372   1.1  msaitoh s32 ixgbe_init_eeprom_params_X540(struct ixgbe_hw *hw)
    373   1.1  msaitoh {
    374   1.1  msaitoh 	struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
    375   1.1  msaitoh 	u32 eec;
    376   1.1  msaitoh 	u16 eeprom_size;
    377   1.1  msaitoh 
    378   1.1  msaitoh 	DEBUGFUNC("ixgbe_init_eeprom_params_X540");
    379   1.1  msaitoh 
    380   1.1  msaitoh 	if (eeprom->type == ixgbe_eeprom_uninitialized) {
    381   1.1  msaitoh 		eeprom->semaphore_delay = 10;
    382   1.1  msaitoh 		eeprom->type = ixgbe_flash;
    383   1.1  msaitoh 
    384   1.7  msaitoh 		eec = IXGBE_READ_REG(hw, IXGBE_EEC_BY_MAC(hw));
    385   1.1  msaitoh 		eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
    386   1.1  msaitoh 				    IXGBE_EEC_SIZE_SHIFT);
    387   1.1  msaitoh 		eeprom->word_size = 1 << (eeprom_size +
    388   1.1  msaitoh 					  IXGBE_EEPROM_WORD_SIZE_SHIFT);
    389   1.1  msaitoh 
    390   1.1  msaitoh 		DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
    391   1.1  msaitoh 			  eeprom->type, eeprom->word_size);
    392   1.1  msaitoh 	}
    393   1.1  msaitoh 
    394   1.1  msaitoh 	return IXGBE_SUCCESS;
    395   1.1  msaitoh }
    396   1.1  msaitoh 
    397   1.1  msaitoh /**
    398   1.1  msaitoh  *  ixgbe_read_eerd_X540- Read EEPROM word using EERD
    399   1.1  msaitoh  *  @hw: pointer to hardware structure
    400   1.1  msaitoh  *  @offset: offset of  word in the EEPROM to read
    401   1.1  msaitoh  *  @data: word read from the EEPROM
    402   1.1  msaitoh  *
    403   1.1  msaitoh  *  Reads a 16 bit word from the EEPROM using the EERD register.
    404   1.1  msaitoh  **/
    405   1.1  msaitoh s32 ixgbe_read_eerd_X540(struct ixgbe_hw *hw, u16 offset, u16 *data)
    406   1.1  msaitoh {
    407   1.1  msaitoh 	s32 status = IXGBE_SUCCESS;
    408   1.1  msaitoh 
    409   1.1  msaitoh 	DEBUGFUNC("ixgbe_read_eerd_X540");
    410   1.1  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
    411   1.4  msaitoh 	    IXGBE_SUCCESS) {
    412   1.1  msaitoh 		status = ixgbe_read_eerd_generic(hw, offset, data);
    413   1.4  msaitoh 		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    414   1.4  msaitoh 	} else {
    415   1.1  msaitoh 		status = IXGBE_ERR_SWFW_SYNC;
    416   1.4  msaitoh 	}
    417   1.1  msaitoh 
    418   1.1  msaitoh 	return status;
    419   1.1  msaitoh }
    420   1.1  msaitoh 
    421   1.1  msaitoh /**
    422   1.1  msaitoh  *  ixgbe_read_eerd_buffer_X540- Read EEPROM word(s) using EERD
    423   1.1  msaitoh  *  @hw: pointer to hardware structure
    424   1.1  msaitoh  *  @offset: offset of  word in the EEPROM to read
    425   1.1  msaitoh  *  @words: number of words
    426   1.1  msaitoh  *  @data: word(s) read from the EEPROM
    427   1.1  msaitoh  *
    428   1.1  msaitoh  *  Reads a 16 bit word(s) from the EEPROM using the EERD register.
    429   1.1  msaitoh  **/
    430   1.1  msaitoh s32 ixgbe_read_eerd_buffer_X540(struct ixgbe_hw *hw,
    431   1.1  msaitoh 				u16 offset, u16 words, u16 *data)
    432   1.1  msaitoh {
    433   1.1  msaitoh 	s32 status = IXGBE_SUCCESS;
    434   1.1  msaitoh 
    435   1.1  msaitoh 	DEBUGFUNC("ixgbe_read_eerd_buffer_X540");
    436   1.1  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
    437   1.4  msaitoh 	    IXGBE_SUCCESS) {
    438   1.1  msaitoh 		status = ixgbe_read_eerd_buffer_generic(hw, offset,
    439   1.1  msaitoh 							words, data);
    440   1.4  msaitoh 		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    441   1.4  msaitoh 	} else {
    442   1.1  msaitoh 		status = IXGBE_ERR_SWFW_SYNC;
    443   1.4  msaitoh 	}
    444   1.1  msaitoh 
    445   1.1  msaitoh 	return status;
    446   1.1  msaitoh }
    447   1.1  msaitoh 
    448   1.1  msaitoh /**
    449   1.1  msaitoh  *  ixgbe_write_eewr_X540 - Write EEPROM word using EEWR
    450   1.1  msaitoh  *  @hw: pointer to hardware structure
    451   1.1  msaitoh  *  @offset: offset of  word in the EEPROM to write
    452   1.1  msaitoh  *  @data: word write to the EEPROM
    453   1.1  msaitoh  *
    454   1.1  msaitoh  *  Write a 16 bit word to the EEPROM using the EEWR register.
    455   1.1  msaitoh  **/
    456   1.1  msaitoh s32 ixgbe_write_eewr_X540(struct ixgbe_hw *hw, u16 offset, u16 data)
    457   1.1  msaitoh {
    458   1.1  msaitoh 	s32 status = IXGBE_SUCCESS;
    459   1.1  msaitoh 
    460   1.1  msaitoh 	DEBUGFUNC("ixgbe_write_eewr_X540");
    461   1.1  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
    462   1.4  msaitoh 	    IXGBE_SUCCESS) {
    463   1.1  msaitoh 		status = ixgbe_write_eewr_generic(hw, offset, data);
    464   1.4  msaitoh 		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    465   1.4  msaitoh 	} else {
    466   1.1  msaitoh 		status = IXGBE_ERR_SWFW_SYNC;
    467   1.4  msaitoh 	}
    468   1.1  msaitoh 
    469   1.1  msaitoh 	return status;
    470   1.1  msaitoh }
    471   1.1  msaitoh 
    472   1.1  msaitoh /**
    473   1.1  msaitoh  *  ixgbe_write_eewr_buffer_X540 - Write EEPROM word(s) using EEWR
    474   1.1  msaitoh  *  @hw: pointer to hardware structure
    475   1.1  msaitoh  *  @offset: offset of  word in the EEPROM to write
    476   1.1  msaitoh  *  @words: number of words
    477   1.1  msaitoh  *  @data: word(s) write to the EEPROM
    478   1.1  msaitoh  *
    479   1.1  msaitoh  *  Write a 16 bit word(s) to the EEPROM using the EEWR register.
    480   1.1  msaitoh  **/
    481   1.1  msaitoh s32 ixgbe_write_eewr_buffer_X540(struct ixgbe_hw *hw,
    482   1.1  msaitoh 				 u16 offset, u16 words, u16 *data)
    483   1.1  msaitoh {
    484   1.1  msaitoh 	s32 status = IXGBE_SUCCESS;
    485   1.1  msaitoh 
    486   1.1  msaitoh 	DEBUGFUNC("ixgbe_write_eewr_buffer_X540");
    487   1.1  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
    488   1.4  msaitoh 	    IXGBE_SUCCESS) {
    489   1.1  msaitoh 		status = ixgbe_write_eewr_buffer_generic(hw, offset,
    490   1.1  msaitoh 							 words, data);
    491   1.4  msaitoh 		hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    492   1.4  msaitoh 	} else {
    493   1.1  msaitoh 		status = IXGBE_ERR_SWFW_SYNC;
    494   1.4  msaitoh 	}
    495   1.1  msaitoh 
    496   1.1  msaitoh 	return status;
    497   1.1  msaitoh }
    498   1.1  msaitoh 
    499   1.1  msaitoh /**
    500   1.1  msaitoh  *  ixgbe_calc_eeprom_checksum_X540 - Calculates and returns the checksum
    501   1.1  msaitoh  *
    502   1.1  msaitoh  *  This function does not use synchronization for EERD and EEWR. It can
    503   1.1  msaitoh  *  be used internally by function which utilize ixgbe_acquire_swfw_sync_X540.
    504   1.1  msaitoh  *
    505   1.1  msaitoh  *  @hw: pointer to hardware structure
    506   1.5  msaitoh  *
    507   1.5  msaitoh  *  Returns a negative error code on error, or the 16-bit checksum
    508   1.1  msaitoh  **/
    509   1.5  msaitoh s32 ixgbe_calc_eeprom_checksum_X540(struct ixgbe_hw *hw)
    510   1.1  msaitoh {
    511   1.5  msaitoh 	u16 i, j;
    512   1.1  msaitoh 	u16 checksum = 0;
    513   1.1  msaitoh 	u16 length = 0;
    514   1.1  msaitoh 	u16 pointer = 0;
    515   1.1  msaitoh 	u16 word = 0;
    516   1.5  msaitoh 	u16 ptr_start = IXGBE_PCIE_ANALOG_PTR;
    517   1.1  msaitoh 
    518   1.5  msaitoh 	/* Do not use hw->eeprom.ops.read because we do not want to take
    519   1.1  msaitoh 	 * the synchronization semaphores here. Instead use
    520   1.1  msaitoh 	 * ixgbe_read_eerd_generic
    521   1.1  msaitoh 	 */
    522   1.1  msaitoh 
    523   1.1  msaitoh 	DEBUGFUNC("ixgbe_calc_eeprom_checksum_X540");
    524   1.1  msaitoh 
    525  1.10  msaitoh 	/* Include 0x0 up to IXGBE_EEPROM_CHECKSUM; do not include the
    526  1.10  msaitoh 	 * checksum itself
    527  1.10  msaitoh 	 */
    528  1.10  msaitoh 	for (i = 0; i < IXGBE_EEPROM_CHECKSUM; i++) {
    529   1.5  msaitoh 		if (ixgbe_read_eerd_generic(hw, i, &word)) {
    530   1.1  msaitoh 			DEBUGOUT("EEPROM read failed\n");
    531   1.5  msaitoh 			return IXGBE_ERR_EEPROM;
    532   1.1  msaitoh 		}
    533  1.10  msaitoh 		checksum += word;
    534   1.1  msaitoh 	}
    535   1.1  msaitoh 
    536   1.5  msaitoh 	/* Include all data from pointers 0x3, 0x6-0xE.  This excludes the
    537   1.1  msaitoh 	 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
    538   1.1  msaitoh 	 */
    539   1.5  msaitoh 	for (i = ptr_start; i < IXGBE_FW_PTR; i++) {
    540   1.1  msaitoh 		if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
    541   1.1  msaitoh 			continue;
    542   1.1  msaitoh 
    543   1.5  msaitoh 		if (ixgbe_read_eerd_generic(hw, i, &pointer)) {
    544   1.1  msaitoh 			DEBUGOUT("EEPROM read failed\n");
    545   1.5  msaitoh 			return IXGBE_ERR_EEPROM;
    546   1.1  msaitoh 		}
    547   1.1  msaitoh 
    548   1.1  msaitoh 		/* Skip pointer section if the pointer is invalid. */
    549   1.1  msaitoh 		if (pointer == 0xFFFF || pointer == 0 ||
    550   1.1  msaitoh 		    pointer >= hw->eeprom.word_size)
    551   1.1  msaitoh 			continue;
    552   1.1  msaitoh 
    553   1.5  msaitoh 		if (ixgbe_read_eerd_generic(hw, pointer, &length)) {
    554   1.1  msaitoh 			DEBUGOUT("EEPROM read failed\n");
    555   1.5  msaitoh 			return IXGBE_ERR_EEPROM;
    556   1.1  msaitoh 		}
    557   1.1  msaitoh 
    558   1.1  msaitoh 		/* Skip pointer section if length is invalid. */
    559   1.1  msaitoh 		if (length == 0xFFFF || length == 0 ||
    560   1.1  msaitoh 		    (pointer + length) >= hw->eeprom.word_size)
    561   1.1  msaitoh 			continue;
    562   1.1  msaitoh 
    563   1.5  msaitoh 		for (j = pointer + 1; j <= pointer + length; j++) {
    564   1.5  msaitoh 			if (ixgbe_read_eerd_generic(hw, j, &word)) {
    565   1.1  msaitoh 				DEBUGOUT("EEPROM read failed\n");
    566   1.5  msaitoh 				return IXGBE_ERR_EEPROM;
    567   1.1  msaitoh 			}
    568   1.1  msaitoh 			checksum += word;
    569   1.1  msaitoh 		}
    570   1.1  msaitoh 	}
    571   1.1  msaitoh 
    572   1.1  msaitoh 	checksum = (u16)IXGBE_EEPROM_SUM - checksum;
    573   1.1  msaitoh 
    574   1.5  msaitoh 	return (s32)checksum;
    575   1.1  msaitoh }
    576   1.1  msaitoh 
    577   1.1  msaitoh /**
    578   1.1  msaitoh  *  ixgbe_validate_eeprom_checksum_X540 - Validate EEPROM checksum
    579   1.1  msaitoh  *  @hw: pointer to hardware structure
    580   1.1  msaitoh  *  @checksum_val: calculated checksum
    581   1.1  msaitoh  *
    582   1.1  msaitoh  *  Performs checksum calculation and validates the EEPROM checksum.  If the
    583   1.1  msaitoh  *  caller does not need checksum_val, the value can be NULL.
    584   1.1  msaitoh  **/
    585   1.1  msaitoh s32 ixgbe_validate_eeprom_checksum_X540(struct ixgbe_hw *hw,
    586   1.1  msaitoh 					u16 *checksum_val)
    587   1.1  msaitoh {
    588   1.1  msaitoh 	s32 status;
    589   1.1  msaitoh 	u16 checksum;
    590   1.1  msaitoh 	u16 read_checksum = 0;
    591   1.1  msaitoh 
    592   1.1  msaitoh 	DEBUGFUNC("ixgbe_validate_eeprom_checksum_X540");
    593   1.1  msaitoh 
    594   1.5  msaitoh 	/* Read the first word from the EEPROM. If this times out or fails, do
    595   1.1  msaitoh 	 * not continue or we could be in for a very long wait while every
    596   1.1  msaitoh 	 * EEPROM read fails
    597   1.1  msaitoh 	 */
    598   1.1  msaitoh 	status = hw->eeprom.ops.read(hw, 0, &checksum);
    599   1.5  msaitoh 	if (status) {
    600   1.1  msaitoh 		DEBUGOUT("EEPROM read failed\n");
    601   1.5  msaitoh 		return status;
    602   1.1  msaitoh 	}
    603   1.1  msaitoh 
    604   1.5  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM))
    605   1.5  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    606   1.5  msaitoh 
    607   1.5  msaitoh 	status = hw->eeprom.ops.calc_checksum(hw);
    608   1.5  msaitoh 	if (status < 0)
    609   1.5  msaitoh 		goto out;
    610   1.1  msaitoh 
    611   1.5  msaitoh 	checksum = (u16)(status & 0xffff);
    612   1.1  msaitoh 
    613   1.5  msaitoh 	/* Do not use hw->eeprom.ops.read because we do not want to take
    614   1.5  msaitoh 	 * the synchronization semaphores twice here.
    615   1.5  msaitoh 	 */
    616   1.5  msaitoh 	status = ixgbe_read_eerd_generic(hw, IXGBE_EEPROM_CHECKSUM,
    617   1.5  msaitoh 					 &read_checksum);
    618   1.5  msaitoh 	if (status)
    619   1.5  msaitoh 		goto out;
    620   1.1  msaitoh 
    621   1.5  msaitoh 	/* Verify read checksum from EEPROM is the same as
    622   1.5  msaitoh 	 * calculated checksum
    623   1.5  msaitoh 	 */
    624   1.5  msaitoh 	if (read_checksum != checksum) {
    625   1.5  msaitoh 		ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
    626   1.5  msaitoh 			     "Invalid EEPROM checksum");
    627   1.5  msaitoh 		status = IXGBE_ERR_EEPROM_CHECKSUM;
    628   1.1  msaitoh 	}
    629   1.1  msaitoh 
    630   1.5  msaitoh 	/* If the user cares, return the calculated checksum */
    631   1.5  msaitoh 	if (checksum_val)
    632   1.5  msaitoh 		*checksum_val = checksum;
    633   1.5  msaitoh 
    634   1.1  msaitoh out:
    635   1.5  msaitoh 	hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    636   1.5  msaitoh 
    637   1.1  msaitoh 	return status;
    638   1.1  msaitoh }
    639   1.1  msaitoh 
    640   1.1  msaitoh /**
    641   1.1  msaitoh  * ixgbe_update_eeprom_checksum_X540 - Updates the EEPROM checksum and flash
    642   1.1  msaitoh  * @hw: pointer to hardware structure
    643   1.1  msaitoh  *
    644   1.1  msaitoh  * After writing EEPROM to shadow RAM using EEWR register, software calculates
    645   1.1  msaitoh  * checksum and updates the EEPROM and instructs the hardware to update
    646   1.1  msaitoh  * the flash.
    647   1.1  msaitoh  **/
    648   1.1  msaitoh s32 ixgbe_update_eeprom_checksum_X540(struct ixgbe_hw *hw)
    649   1.1  msaitoh {
    650   1.1  msaitoh 	s32 status;
    651   1.1  msaitoh 	u16 checksum;
    652   1.1  msaitoh 
    653   1.1  msaitoh 	DEBUGFUNC("ixgbe_update_eeprom_checksum_X540");
    654   1.1  msaitoh 
    655   1.5  msaitoh 	/* Read the first word from the EEPROM. If this times out or fails, do
    656   1.1  msaitoh 	 * not continue or we could be in for a very long wait while every
    657   1.1  msaitoh 	 * EEPROM read fails
    658   1.1  msaitoh 	 */
    659   1.1  msaitoh 	status = hw->eeprom.ops.read(hw, 0, &checksum);
    660   1.5  msaitoh 	if (status) {
    661   1.5  msaitoh 		DEBUGOUT("EEPROM read failed\n");
    662   1.5  msaitoh 		return status;
    663   1.5  msaitoh 	}
    664   1.5  msaitoh 
    665   1.5  msaitoh 	if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM))
    666   1.5  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    667   1.5  msaitoh 
    668   1.5  msaitoh 	status = hw->eeprom.ops.calc_checksum(hw);
    669   1.5  msaitoh 	if (status < 0)
    670   1.5  msaitoh 		goto out;
    671   1.1  msaitoh 
    672   1.5  msaitoh 	checksum = (u16)(status & 0xffff);
    673   1.1  msaitoh 
    674   1.5  msaitoh 	/* Do not use hw->eeprom.ops.write because we do not want to
    675   1.5  msaitoh 	 * take the synchronization semaphores twice here.
    676   1.5  msaitoh 	 */
    677   1.5  msaitoh 	status = ixgbe_write_eewr_generic(hw, IXGBE_EEPROM_CHECKSUM, checksum);
    678   1.5  msaitoh 	if (status)
    679   1.5  msaitoh 		goto out;
    680   1.1  msaitoh 
    681   1.5  msaitoh 	status = ixgbe_update_flash_X540(hw);
    682   1.1  msaitoh 
    683   1.5  msaitoh out:
    684   1.5  msaitoh 	hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
    685   1.1  msaitoh 
    686   1.1  msaitoh 	return status;
    687   1.1  msaitoh }
    688   1.1  msaitoh 
    689   1.1  msaitoh /**
    690   1.1  msaitoh  *  ixgbe_update_flash_X540 - Instruct HW to copy EEPROM to Flash device
    691   1.1  msaitoh  *  @hw: pointer to hardware structure
    692   1.1  msaitoh  *
    693   1.1  msaitoh  *  Set FLUP (bit 23) of the EEC register to instruct Hardware to copy
    694   1.1  msaitoh  *  EEPROM from shadow RAM to the flash device.
    695   1.1  msaitoh  **/
    696   1.4  msaitoh s32 ixgbe_update_flash_X540(struct ixgbe_hw *hw)
    697   1.1  msaitoh {
    698   1.1  msaitoh 	u32 flup;
    699   1.5  msaitoh 	s32 status;
    700   1.1  msaitoh 
    701   1.1  msaitoh 	DEBUGFUNC("ixgbe_update_flash_X540");
    702   1.1  msaitoh 
    703   1.1  msaitoh 	status = ixgbe_poll_flash_update_done_X540(hw);
    704   1.1  msaitoh 	if (status == IXGBE_ERR_EEPROM) {
    705   1.1  msaitoh 		DEBUGOUT("Flash update time out\n");
    706   1.1  msaitoh 		goto out;
    707   1.1  msaitoh 	}
    708   1.1  msaitoh 
    709   1.7  msaitoh 	flup = IXGBE_READ_REG(hw, IXGBE_EEC_BY_MAC(hw)) | IXGBE_EEC_FLUP;
    710   1.7  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_EEC_BY_MAC(hw), flup);
    711   1.1  msaitoh 
    712   1.1  msaitoh 	status = ixgbe_poll_flash_update_done_X540(hw);
    713   1.1  msaitoh 	if (status == IXGBE_SUCCESS)
    714   1.1  msaitoh 		DEBUGOUT("Flash update complete\n");
    715   1.1  msaitoh 	else
    716   1.1  msaitoh 		DEBUGOUT("Flash update time out\n");
    717   1.1  msaitoh 
    718   1.4  msaitoh 	if (hw->mac.type == ixgbe_mac_X540 && hw->revision_id == 0) {
    719   1.7  msaitoh 		flup = IXGBE_READ_REG(hw, IXGBE_EEC_BY_MAC(hw));
    720   1.1  msaitoh 
    721   1.1  msaitoh 		if (flup & IXGBE_EEC_SEC1VAL) {
    722   1.1  msaitoh 			flup |= IXGBE_EEC_FLUP;
    723   1.7  msaitoh 			IXGBE_WRITE_REG(hw, IXGBE_EEC_BY_MAC(hw), flup);
    724   1.1  msaitoh 		}
    725   1.1  msaitoh 
    726   1.1  msaitoh 		status = ixgbe_poll_flash_update_done_X540(hw);
    727   1.1  msaitoh 		if (status == IXGBE_SUCCESS)
    728   1.1  msaitoh 			DEBUGOUT("Flash update complete\n");
    729   1.1  msaitoh 		else
    730   1.1  msaitoh 			DEBUGOUT("Flash update time out\n");
    731   1.1  msaitoh 	}
    732   1.1  msaitoh out:
    733   1.1  msaitoh 	return status;
    734   1.1  msaitoh }
    735   1.1  msaitoh 
    736   1.1  msaitoh /**
    737   1.1  msaitoh  *  ixgbe_poll_flash_update_done_X540 - Poll flash update status
    738   1.1  msaitoh  *  @hw: pointer to hardware structure
    739   1.1  msaitoh  *
    740   1.1  msaitoh  *  Polls the FLUDONE (bit 26) of the EEC Register to determine when the
    741   1.1  msaitoh  *  flash update is done.
    742   1.1  msaitoh  **/
    743   1.1  msaitoh static s32 ixgbe_poll_flash_update_done_X540(struct ixgbe_hw *hw)
    744   1.1  msaitoh {
    745   1.1  msaitoh 	u32 i;
    746   1.1  msaitoh 	u32 reg;
    747   1.1  msaitoh 	s32 status = IXGBE_ERR_EEPROM;
    748   1.1  msaitoh 
    749   1.1  msaitoh 	DEBUGFUNC("ixgbe_poll_flash_update_done_X540");
    750   1.1  msaitoh 
    751   1.1  msaitoh 	for (i = 0; i < IXGBE_FLUDONE_ATTEMPTS; i++) {
    752   1.7  msaitoh 		reg = IXGBE_READ_REG(hw, IXGBE_EEC_BY_MAC(hw));
    753   1.1  msaitoh 		if (reg & IXGBE_EEC_FLUDONE) {
    754   1.1  msaitoh 			status = IXGBE_SUCCESS;
    755   1.1  msaitoh 			break;
    756   1.1  msaitoh 		}
    757   1.5  msaitoh 		msec_delay(5);
    758   1.1  msaitoh 	}
    759   1.4  msaitoh 
    760   1.4  msaitoh 	if (i == IXGBE_FLUDONE_ATTEMPTS)
    761   1.4  msaitoh 		ERROR_REPORT1(IXGBE_ERROR_POLLING,
    762   1.4  msaitoh 			     "Flash update status polling timed out");
    763   1.4  msaitoh 
    764   1.1  msaitoh 	return status;
    765   1.1  msaitoh }
    766   1.1  msaitoh 
    767   1.1  msaitoh /**
    768   1.1  msaitoh  *  ixgbe_acquire_swfw_sync_X540 - Acquire SWFW semaphore
    769   1.1  msaitoh  *  @hw: pointer to hardware structure
    770   1.1  msaitoh  *  @mask: Mask to specify which semaphore to acquire
    771   1.1  msaitoh  *
    772   1.1  msaitoh  *  Acquires the SWFW semaphore thought the SW_FW_SYNC register for
    773   1.1  msaitoh  *  the specified function (CSR, PHY0, PHY1, NVM, Flash)
    774   1.1  msaitoh  **/
    775   1.5  msaitoh s32 ixgbe_acquire_swfw_sync_X540(struct ixgbe_hw *hw, u32 mask)
    776   1.1  msaitoh {
    777   1.5  msaitoh 	u32 swmask = mask & IXGBE_GSSR_NVM_PHY_MASK;
    778   1.5  msaitoh 	u32 fwmask = swmask << 5;
    779   1.5  msaitoh 	u32 swi2c_mask = mask & IXGBE_GSSR_I2C_MASK;
    780   1.5  msaitoh 	u32 timeout = 200;
    781   1.5  msaitoh 	u32 hwmask = 0;
    782   1.1  msaitoh 	u32 swfw_sync;
    783   1.1  msaitoh 	u32 i;
    784   1.1  msaitoh 
    785   1.1  msaitoh 	DEBUGFUNC("ixgbe_acquire_swfw_sync_X540");
    786   1.1  msaitoh 
    787   1.5  msaitoh 	if (swmask & IXGBE_GSSR_EEP_SM)
    788   1.5  msaitoh 		hwmask |= IXGBE_GSSR_FLASH_SM;
    789   1.1  msaitoh 
    790   1.1  msaitoh 	/* SW only mask doesn't have FW bit pair */
    791   1.5  msaitoh 	if (mask & IXGBE_GSSR_SW_MNG_SM)
    792   1.5  msaitoh 		swmask |= IXGBE_GSSR_SW_MNG_SM;
    793   1.1  msaitoh 
    794   1.5  msaitoh 	swmask |= swi2c_mask;
    795   1.5  msaitoh 	fwmask |= swi2c_mask << 2;
    796  1.16  msaitoh 	if (hw->mac.type >= ixgbe_mac_X550)
    797  1.13  msaitoh 		timeout = 1000;
    798  1.13  msaitoh 
    799   1.1  msaitoh 	for (i = 0; i < timeout; i++) {
    800   1.5  msaitoh 		/* SW NVM semaphore bit is used for access to all
    801   1.1  msaitoh 		 * SW_FW_SYNC bits (not just NVM)
    802   1.1  msaitoh 		 */
    803  1.10  msaitoh 		if (ixgbe_get_swfw_sync_semaphore(hw)) {
    804  1.10  msaitoh 			DEBUGOUT("Failed to get NVM access and register semaphore, returning IXGBE_ERR_SWFW_SYNC\n");
    805   1.5  msaitoh 			return IXGBE_ERR_SWFW_SYNC;
    806  1.10  msaitoh 		}
    807   1.1  msaitoh 
    808   1.7  msaitoh 		swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    809   1.1  msaitoh 		if (!(swfw_sync & (fwmask | swmask | hwmask))) {
    810   1.1  msaitoh 			swfw_sync |= swmask;
    811   1.7  msaitoh 			IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw),
    812   1.7  msaitoh 					swfw_sync);
    813   1.1  msaitoh 			ixgbe_release_swfw_sync_semaphore(hw);
    814   1.5  msaitoh 			return IXGBE_SUCCESS;
    815   1.1  msaitoh 		}
    816   1.5  msaitoh 		/* Firmware currently using resource (fwmask), hardware
    817   1.5  msaitoh 		 * currently using resource (hwmask), or other software
    818   1.5  msaitoh 		 * thread currently using resource (swmask)
    819   1.5  msaitoh 		 */
    820   1.5  msaitoh 		ixgbe_release_swfw_sync_semaphore(hw);
    821   1.5  msaitoh 		msec_delay(5);
    822   1.1  msaitoh 	}
    823   1.1  msaitoh 
    824   1.1  msaitoh 	/* If the resource is not released by the FW/HW the SW can assume that
    825   1.4  msaitoh 	 * the FW/HW malfunctions. In that case the SW should set the SW bit(s)
    826   1.1  msaitoh 	 * of the requested resource(s) while ignoring the corresponding FW/HW
    827   1.1  msaitoh 	 * bits in the SW_FW_SYNC register.
    828   1.1  msaitoh 	 */
    829  1.10  msaitoh 	if (ixgbe_get_swfw_sync_semaphore(hw)) {
    830  1.17  msaitoh 		DEBUGOUT("Failed to get NVM semaphore and register semaphore while forcefully ignoring FW semaphore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n");
    831   1.5  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    832  1.10  msaitoh 	}
    833   1.7  msaitoh 	swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    834   1.1  msaitoh 	if (swfw_sync & (fwmask | hwmask)) {
    835   1.1  msaitoh 		swfw_sync |= swmask;
    836   1.7  msaitoh 		IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw), swfw_sync);
    837   1.1  msaitoh 		ixgbe_release_swfw_sync_semaphore(hw);
    838   1.1  msaitoh 		msec_delay(5);
    839   1.5  msaitoh 		return IXGBE_SUCCESS;
    840   1.1  msaitoh 	}
    841   1.4  msaitoh 	/* If the resource is not released by other SW the SW can assume that
    842   1.4  msaitoh 	 * the other SW malfunctions. In that case the SW should clear all SW
    843   1.4  msaitoh 	 * flags that it does not own and then repeat the whole process once
    844   1.4  msaitoh 	 * again.
    845   1.4  msaitoh 	 */
    846   1.5  msaitoh 	if (swfw_sync & swmask) {
    847   1.5  msaitoh 		u32 rmask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_PHY0_SM |
    848  1.10  msaitoh 			    IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_MAC_CSR_SM |
    849  1.10  msaitoh 			    IXGBE_GSSR_SW_MNG_SM;
    850   1.5  msaitoh 
    851   1.5  msaitoh 		if (swi2c_mask)
    852   1.5  msaitoh 			rmask |= IXGBE_GSSR_I2C_MASK;
    853   1.5  msaitoh 		ixgbe_release_swfw_sync_X540(hw, rmask);
    854   1.5  msaitoh 		ixgbe_release_swfw_sync_semaphore(hw);
    855  1.10  msaitoh 		DEBUGOUT("Resource not released by other SW, returning IXGBE_ERR_SWFW_SYNC\n");
    856   1.5  msaitoh 		return IXGBE_ERR_SWFW_SYNC;
    857   1.4  msaitoh 	}
    858   1.5  msaitoh 	ixgbe_release_swfw_sync_semaphore(hw);
    859  1.10  msaitoh 	DEBUGOUT("Returning error IXGBE_ERR_SWFW_SYNC\n");
    860   1.1  msaitoh 
    861   1.5  msaitoh 	return IXGBE_ERR_SWFW_SYNC;
    862   1.1  msaitoh }
    863   1.1  msaitoh 
    864   1.1  msaitoh /**
    865   1.1  msaitoh  *  ixgbe_release_swfw_sync_X540 - Release SWFW semaphore
    866   1.1  msaitoh  *  @hw: pointer to hardware structure
    867   1.1  msaitoh  *  @mask: Mask to specify which semaphore to release
    868   1.1  msaitoh  *
    869   1.2  msaitoh  *  Releases the SWFW semaphore through the SW_FW_SYNC register
    870   1.1  msaitoh  *  for the specified function (CSR, PHY0, PHY1, EVM, Flash)
    871   1.1  msaitoh  **/
    872   1.5  msaitoh void ixgbe_release_swfw_sync_X540(struct ixgbe_hw *hw, u32 mask)
    873   1.1  msaitoh {
    874   1.5  msaitoh 	u32 swmask = mask & (IXGBE_GSSR_NVM_PHY_MASK | IXGBE_GSSR_SW_MNG_SM);
    875   1.1  msaitoh 	u32 swfw_sync;
    876   1.1  msaitoh 
    877   1.1  msaitoh 	DEBUGFUNC("ixgbe_release_swfw_sync_X540");
    878   1.1  msaitoh 
    879   1.5  msaitoh 	if (mask & IXGBE_GSSR_I2C_MASK)
    880   1.5  msaitoh 		swmask |= mask & IXGBE_GSSR_I2C_MASK;
    881   1.1  msaitoh 	ixgbe_get_swfw_sync_semaphore(hw);
    882   1.1  msaitoh 
    883   1.7  msaitoh 	swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    884   1.1  msaitoh 	swfw_sync &= ~swmask;
    885   1.7  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw), swfw_sync);
    886   1.1  msaitoh 
    887   1.1  msaitoh 	ixgbe_release_swfw_sync_semaphore(hw);
    888  1.10  msaitoh 	msec_delay(2);
    889   1.1  msaitoh }
    890   1.1  msaitoh 
    891   1.1  msaitoh /**
    892   1.5  msaitoh  *  ixgbe_get_swfw_sync_semaphore - Get hardware semaphore
    893   1.1  msaitoh  *  @hw: pointer to hardware structure
    894   1.1  msaitoh  *
    895   1.1  msaitoh  *  Sets the hardware semaphores so SW/FW can gain control of shared resources
    896   1.1  msaitoh  **/
    897   1.1  msaitoh static s32 ixgbe_get_swfw_sync_semaphore(struct ixgbe_hw *hw)
    898   1.1  msaitoh {
    899   1.1  msaitoh 	s32 status = IXGBE_ERR_EEPROM;
    900   1.1  msaitoh 	u32 timeout = 2000;
    901   1.1  msaitoh 	u32 i;
    902   1.1  msaitoh 	u32 swsm;
    903   1.1  msaitoh 
    904   1.1  msaitoh 	DEBUGFUNC("ixgbe_get_swfw_sync_semaphore");
    905   1.1  msaitoh 
    906   1.1  msaitoh 	/* Get SMBI software semaphore between device drivers first */
    907   1.1  msaitoh 	for (i = 0; i < timeout; i++) {
    908   1.1  msaitoh 		/*
    909   1.1  msaitoh 		 * If the SMBI bit is 0 when we read it, then the bit will be
    910   1.1  msaitoh 		 * set and we have the semaphore
    911   1.1  msaitoh 		 */
    912   1.7  msaitoh 		swsm = IXGBE_READ_REG(hw, IXGBE_SWSM_BY_MAC(hw));
    913   1.1  msaitoh 		if (!(swsm & IXGBE_SWSM_SMBI)) {
    914   1.1  msaitoh 			status = IXGBE_SUCCESS;
    915   1.1  msaitoh 			break;
    916   1.1  msaitoh 		}
    917   1.1  msaitoh 		usec_delay(50);
    918   1.1  msaitoh 	}
    919   1.1  msaitoh 
    920   1.1  msaitoh 	/* Now get the semaphore between SW/FW through the REGSMP bit */
    921   1.1  msaitoh 	if (status == IXGBE_SUCCESS) {
    922   1.1  msaitoh 		for (i = 0; i < timeout; i++) {
    923   1.7  msaitoh 			swsm = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    924   1.1  msaitoh 			if (!(swsm & IXGBE_SWFW_REGSMP))
    925   1.1  msaitoh 				break;
    926   1.1  msaitoh 
    927   1.1  msaitoh 			usec_delay(50);
    928   1.1  msaitoh 		}
    929   1.1  msaitoh 
    930   1.1  msaitoh 		/*
    931   1.1  msaitoh 		 * Release semaphores and return error if SW NVM semaphore
    932   1.1  msaitoh 		 * was not granted because we don't have access to the EEPROM
    933   1.1  msaitoh 		 */
    934   1.1  msaitoh 		if (i >= timeout) {
    935   1.4  msaitoh 			ERROR_REPORT1(IXGBE_ERROR_POLLING,
    936   1.4  msaitoh 				"REGSMP Software NVM semaphore not granted.\n");
    937   1.1  msaitoh 			ixgbe_release_swfw_sync_semaphore(hw);
    938   1.1  msaitoh 			status = IXGBE_ERR_EEPROM;
    939   1.1  msaitoh 		}
    940   1.1  msaitoh 	} else {
    941   1.4  msaitoh 		ERROR_REPORT1(IXGBE_ERROR_POLLING,
    942   1.4  msaitoh 			     "Software semaphore SMBI between device drivers "
    943   1.4  msaitoh 			     "not granted.\n");
    944   1.1  msaitoh 	}
    945   1.1  msaitoh 
    946   1.1  msaitoh 	return status;
    947   1.1  msaitoh }
    948   1.1  msaitoh 
    949   1.1  msaitoh /**
    950   1.5  msaitoh  *  ixgbe_release_swfw_sync_semaphore - Release hardware semaphore
    951   1.1  msaitoh  *  @hw: pointer to hardware structure
    952   1.1  msaitoh  *
    953   1.1  msaitoh  *  This function clears hardware semaphore bits.
    954   1.1  msaitoh  **/
    955   1.1  msaitoh static void ixgbe_release_swfw_sync_semaphore(struct ixgbe_hw *hw)
    956   1.1  msaitoh {
    957   1.1  msaitoh 	u32 swsm;
    958   1.1  msaitoh 
    959   1.1  msaitoh 	DEBUGFUNC("ixgbe_release_swfw_sync_semaphore");
    960   1.1  msaitoh 
    961   1.1  msaitoh 	/* Release both semaphores by writing 0 to the bits REGSMP and SMBI */
    962   1.1  msaitoh 
    963   1.7  msaitoh 	swsm = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw));
    964   1.6  msaitoh 	swsm &= ~IXGBE_SWFW_REGSMP;
    965   1.7  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw), swsm);
    966   1.6  msaitoh 
    967   1.7  msaitoh 	swsm = IXGBE_READ_REG(hw, IXGBE_SWSM_BY_MAC(hw));
    968   1.1  msaitoh 	swsm &= ~IXGBE_SWSM_SMBI;
    969   1.7  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_SWSM_BY_MAC(hw), swsm);
    970   1.1  msaitoh 
    971   1.1  msaitoh 	IXGBE_WRITE_FLUSH(hw);
    972   1.1  msaitoh }
    973   1.1  msaitoh 
    974   1.1  msaitoh /**
    975  1.10  msaitoh  *  ixgbe_init_swfw_sync_X540 - Release hardware semaphore
    976  1.10  msaitoh  *  @hw: pointer to hardware structure
    977  1.10  msaitoh  *
    978  1.10  msaitoh  *  This function reset hardware semaphore bits for a semaphore that may
    979  1.10  msaitoh  *  have be left locked due to a catastrophic failure.
    980  1.10  msaitoh  **/
    981  1.10  msaitoh void ixgbe_init_swfw_sync_X540(struct ixgbe_hw *hw)
    982  1.10  msaitoh {
    983  1.10  msaitoh 	u32 rmask;
    984  1.10  msaitoh 
    985  1.10  msaitoh 	/* First try to grab the semaphore but we don't need to bother
    986  1.10  msaitoh 	 * looking to see whether we got the lock or not since we do
    987  1.10  msaitoh 	 * the same thing regardless of whether we got the lock or not.
    988  1.10  msaitoh 	 * We got the lock - we release it.
    989  1.10  msaitoh 	 * We timeout trying to get the lock - we force its release.
    990  1.10  msaitoh 	 */
    991  1.10  msaitoh 	ixgbe_get_swfw_sync_semaphore(hw);
    992  1.10  msaitoh 	ixgbe_release_swfw_sync_semaphore(hw);
    993  1.10  msaitoh 
    994  1.10  msaitoh 	/* Acquire and release all software resources. */
    995  1.10  msaitoh 	rmask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_PHY0_SM |
    996  1.10  msaitoh 		IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_MAC_CSR_SM |
    997  1.10  msaitoh 		IXGBE_GSSR_SW_MNG_SM;
    998  1.10  msaitoh 
    999  1.10  msaitoh 	rmask |= IXGBE_GSSR_I2C_MASK;
   1000  1.10  msaitoh 	ixgbe_acquire_swfw_sync_X540(hw, rmask);
   1001  1.10  msaitoh 	ixgbe_release_swfw_sync_X540(hw, rmask);
   1002  1.10  msaitoh }
   1003  1.10  msaitoh 
   1004  1.10  msaitoh /**
   1005   1.1  msaitoh  * ixgbe_blink_led_start_X540 - Blink LED based on index.
   1006   1.1  msaitoh  * @hw: pointer to hardware structure
   1007   1.1  msaitoh  * @index: led number to blink
   1008   1.1  msaitoh  *
   1009   1.1  msaitoh  * Devices that implement the version 2 interface:
   1010   1.1  msaitoh  *   X540
   1011   1.1  msaitoh  **/
   1012   1.1  msaitoh s32 ixgbe_blink_led_start_X540(struct ixgbe_hw *hw, u32 index)
   1013   1.1  msaitoh {
   1014   1.1  msaitoh 	u32 macc_reg;
   1015   1.1  msaitoh 	u32 ledctl_reg;
   1016   1.1  msaitoh 	ixgbe_link_speed speed;
   1017   1.1  msaitoh 	bool link_up;
   1018   1.1  msaitoh 
   1019   1.1  msaitoh 	DEBUGFUNC("ixgbe_blink_led_start_X540");
   1020   1.1  msaitoh 
   1021  1.10  msaitoh 	if (index > 3)
   1022  1.10  msaitoh 		return IXGBE_ERR_PARAM;
   1023  1.10  msaitoh 
   1024   1.1  msaitoh 	/*
   1025   1.1  msaitoh 	 * Link should be up in order for the blink bit in the LED control
   1026   1.1  msaitoh 	 * register to work. Force link and speed in the MAC if link is down.
   1027   1.1  msaitoh 	 * This will be reversed when we stop the blinking.
   1028   1.1  msaitoh 	 */
   1029   1.1  msaitoh 	hw->mac.ops.check_link(hw, &speed, &link_up, FALSE);
   1030   1.1  msaitoh 	if (link_up == FALSE) {
   1031   1.1  msaitoh 		macc_reg = IXGBE_READ_REG(hw, IXGBE_MACC);
   1032   1.1  msaitoh 		macc_reg |= IXGBE_MACC_FLU | IXGBE_MACC_FSV_10G | IXGBE_MACC_FS;
   1033   1.1  msaitoh 		IXGBE_WRITE_REG(hw, IXGBE_MACC, macc_reg);
   1034   1.1  msaitoh 	}
   1035   1.1  msaitoh 	/* Set the LED to LINK_UP + BLINK. */
   1036   1.1  msaitoh 	ledctl_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
   1037   1.1  msaitoh 	ledctl_reg &= ~IXGBE_LED_MODE_MASK(index);
   1038   1.1  msaitoh 	ledctl_reg |= IXGBE_LED_BLINK(index);
   1039   1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, ledctl_reg);
   1040   1.1  msaitoh 	IXGBE_WRITE_FLUSH(hw);
   1041   1.1  msaitoh 
   1042   1.1  msaitoh 	return IXGBE_SUCCESS;
   1043   1.1  msaitoh }
   1044   1.1  msaitoh 
   1045   1.1  msaitoh /**
   1046   1.1  msaitoh  * ixgbe_blink_led_stop_X540 - Stop blinking LED based on index.
   1047   1.1  msaitoh  * @hw: pointer to hardware structure
   1048   1.1  msaitoh  * @index: led number to stop blinking
   1049   1.1  msaitoh  *
   1050   1.1  msaitoh  * Devices that implement the version 2 interface:
   1051   1.1  msaitoh  *   X540
   1052   1.1  msaitoh  **/
   1053   1.1  msaitoh s32 ixgbe_blink_led_stop_X540(struct ixgbe_hw *hw, u32 index)
   1054   1.1  msaitoh {
   1055   1.1  msaitoh 	u32 macc_reg;
   1056   1.1  msaitoh 	u32 ledctl_reg;
   1057   1.1  msaitoh 
   1058  1.10  msaitoh 	if (index > 3)
   1059  1.10  msaitoh 		return IXGBE_ERR_PARAM;
   1060  1.10  msaitoh 
   1061   1.1  msaitoh 	DEBUGFUNC("ixgbe_blink_led_stop_X540");
   1062   1.1  msaitoh 
   1063   1.1  msaitoh 	/* Restore the LED to its default value. */
   1064   1.1  msaitoh 	ledctl_reg = IXGBE_READ_REG(hw, IXGBE_LEDCTL);
   1065   1.1  msaitoh 	ledctl_reg &= ~IXGBE_LED_MODE_MASK(index);
   1066   1.1  msaitoh 	ledctl_reg |= IXGBE_LED_LINK_ACTIVE << IXGBE_LED_MODE_SHIFT(index);
   1067   1.1  msaitoh 	ledctl_reg &= ~IXGBE_LED_BLINK(index);
   1068   1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_LEDCTL, ledctl_reg);
   1069   1.1  msaitoh 
   1070   1.1  msaitoh 	/* Unforce link and speed in the MAC. */
   1071   1.1  msaitoh 	macc_reg = IXGBE_READ_REG(hw, IXGBE_MACC);
   1072   1.1  msaitoh 	macc_reg &= ~(IXGBE_MACC_FLU | IXGBE_MACC_FSV_10G | IXGBE_MACC_FS);
   1073   1.1  msaitoh 	IXGBE_WRITE_REG(hw, IXGBE_MACC, macc_reg);
   1074   1.1  msaitoh 	IXGBE_WRITE_FLUSH(hw);
   1075   1.1  msaitoh 
   1076   1.1  msaitoh 	return IXGBE_SUCCESS;
   1077   1.1  msaitoh }
   1078