devices/e1000/e1000_hw-2.6.18-orig.c
author Gavin Lambert <gavinl@compacsort.com>
Tue, 14 Apr 2015 09:33:24 -0400
changeset 2618 3affe9cd0b66
parent 667 9feff35c9617
permissions -rw-r--r--
Ignore NXIO error otherwise this causes spam if network is empty or refclk not
selected yet, and syncing refclk time to master.
667
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2006 Intel Corporation. All rights reserved.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
  
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it 
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms of the GNU General Public License as published by the Free 
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  Software Foundation; either version 2 of the License, or (at your option) 
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
  any later version.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  This program is distributed in the hope that it will be useful, but WITHOUT 
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
  more details.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  You should have received a copy of the GNU General Public License along with
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  this program; if not, write to the Free Software Foundation, Inc., 59 
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
  Temple Place - Suite 330, Boston, MA  02111-1307, USA.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  The full GNU General Public License is included in this distribution in the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
  file called LICENSE.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Contact Information:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  Linux NICS <linux.nics@intel.com>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
*******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
/* e1000_hw.c
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 * Shared functions for accessing and configuring the MAC
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include "e1000_hw.h"
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
static int32_t e1000_set_phy_type(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
static void e1000_phy_init_script(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
static int32_t e1000_setup_copper_link(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
static int32_t e1000_setup_fiber_serdes_link(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
static int32_t e1000_adjust_serdes_amplitude(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
static int32_t e1000_phy_force_speed_duplex(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
static int32_t e1000_config_mac_to_phy(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
static void e1000_raise_mdi_clk(struct e1000_hw *hw, uint32_t *ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
static void e1000_lower_mdi_clk(struct e1000_hw *hw, uint32_t *ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
static void e1000_shift_out_mdi_bits(struct e1000_hw *hw, uint32_t data,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
                                     uint16_t count);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
static uint16_t e1000_shift_in_mdi_bits(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
static int32_t e1000_phy_reset_dsp(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
static int32_t e1000_write_eeprom_spi(struct e1000_hw *hw, uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
                                      uint16_t words, uint16_t *data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
static int32_t e1000_write_eeprom_microwire(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
                                            uint16_t offset, uint16_t words,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
                                            uint16_t *data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
static int32_t e1000_spi_eeprom_ready(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
static void e1000_raise_ee_clk(struct e1000_hw *hw, uint32_t *eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
static void e1000_lower_ee_clk(struct e1000_hw *hw, uint32_t *eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
static void e1000_shift_out_ee_bits(struct e1000_hw *hw, uint16_t data,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
                                    uint16_t count);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
static int32_t e1000_write_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
                                      uint16_t phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
static int32_t e1000_read_phy_reg_ex(struct e1000_hw *hw,uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
                                     uint16_t *phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
static uint16_t e1000_shift_in_ee_bits(struct e1000_hw *hw, uint16_t count);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
static int32_t e1000_acquire_eeprom(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
static void e1000_release_eeprom(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
static void e1000_standby_eeprom(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
static int32_t e1000_set_vco_speed(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
static int32_t e1000_polarity_reversal_workaround(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
static int32_t e1000_set_phy_mode(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
static int32_t e1000_host_if_read_cookie(struct e1000_hw *hw, uint8_t *buffer);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
static uint8_t e1000_calculate_mng_checksum(char *buffer, uint32_t length);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
static uint8_t e1000_arc_subsystem_valid(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
static int32_t e1000_check_downshift(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
static int32_t e1000_check_polarity(struct e1000_hw *hw, uint16_t *polarity);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
static void e1000_clear_hw_cntrs(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
static void e1000_clear_vfta(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
static int32_t e1000_commit_shadow_ram(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
static int32_t e1000_config_dsp_after_link_change(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
						  boolean_t link_up);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
static int32_t e1000_config_fc_after_link_up(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
static int32_t e1000_detect_gig_phy(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
static int32_t e1000_get_auto_rd_done(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
static int32_t e1000_get_cable_length(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
				      uint16_t *min_length,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
				      uint16_t *max_length);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
static int32_t e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
static int32_t e1000_get_phy_cfg_done(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
static int32_t e1000_id_led_init(struct e1000_hw * hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
static void e1000_init_rx_addrs(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
static boolean_t e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
static int32_t e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
static void e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
static int32_t e1000_read_eeprom_eerd(struct e1000_hw *hw, uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
				      uint16_t words, uint16_t *data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
static int32_t e1000_set_d0_lplu_state(struct e1000_hw *hw, boolean_t active);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
static int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
static int32_t e1000_wait_autoneg(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
static void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
			       uint32_t value);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
#define E1000_WRITE_REG_IO(a, reg, val) \
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
	    e1000_write_reg_io((a), E1000_##reg, val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
static int32_t e1000_configure_kmrn_for_10_100(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
                                               uint16_t duplex);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
static int32_t e1000_configure_kmrn_for_1000(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
static int32_t e1000_erase_ich8_4k_segment(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
					   uint32_t segment);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
static int32_t e1000_get_software_flag(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
static int32_t e1000_get_software_semaphore(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
static int32_t e1000_init_lcd_from_nvm(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
static int32_t e1000_kumeran_lock_loss_workaround(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
static int32_t e1000_read_eeprom_ich8(struct e1000_hw *hw, uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
				      uint16_t words, uint16_t *data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
static int32_t e1000_read_ich8_byte(struct e1000_hw *hw, uint32_t index,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
				    uint8_t* data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
static int32_t e1000_read_ich8_word(struct e1000_hw *hw, uint32_t index,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
				    uint16_t *data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
static int32_t e1000_read_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
				   uint16_t *data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
static void e1000_release_software_flag(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
static void e1000_release_software_semaphore(struct e1000_hw *hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
static int32_t e1000_set_pci_ex_no_snoop(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
					 uint32_t no_snoop);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
static int32_t e1000_verify_write_ich8_byte(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
					    uint32_t index, uint8_t byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
static int32_t e1000_write_eeprom_ich8(struct e1000_hw *hw, uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
				       uint16_t words, uint16_t *data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
static int32_t e1000_write_ich8_byte(struct e1000_hw *hw, uint32_t index,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
				     uint8_t data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
static int32_t e1000_write_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
				    uint16_t data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
/* IGP cable length table */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
static const
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
uint16_t e1000_igp_cable_length_table[IGP01E1000_AGC_LENGTH_TABLE_SIZE] =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
    { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
      5, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 25, 25, 25,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
      25, 25, 25, 25, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
      40, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
      60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 90, 90, 90,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
      90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
      100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
      110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120};
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
static const
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
uint16_t e1000_igp_2_cable_length_table[IGP02E1000_AGC_LENGTH_TABLE_SIZE] =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
    { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
      0, 0, 0, 3, 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
      6, 10, 14, 18, 22, 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
      21, 26, 31, 35, 40, 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
      40, 45, 51, 56, 61, 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
      60, 66, 72, 77, 82, 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
      83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
      104, 109, 114, 118, 121, 124};
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
 * Set the phy type member in the hw struct.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
e1000_set_phy_type(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
    DEBUGFUNC("e1000_set_phy_type");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
    if(hw->mac_type == e1000_undefined)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
        return -E1000_ERR_PHY_TYPE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
    switch(hw->phy_id) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
    case M88E1000_E_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
    case M88E1000_I_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
    case M88E1011_I_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
    case M88E1111_I_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
        hw->phy_type = e1000_phy_m88;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
    case IGP01E1000_I_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
        if(hw->mac_type == e1000_82541 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
           hw->mac_type == e1000_82541_rev_2 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
           hw->mac_type == e1000_82547 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
           hw->mac_type == e1000_82547_rev_2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
            hw->phy_type = e1000_phy_igp;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
    case IGP03E1000_E_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
        hw->phy_type = e1000_phy_igp_3;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
    case IFE_E_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
    case IFE_PLUS_E_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
    case IFE_C_E_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
        hw->phy_type = e1000_phy_ife;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
    case GG82563_E_PHY_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
        if (hw->mac_type == e1000_80003es2lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
            hw->phy_type = e1000_phy_gg82563;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
        /* Fall Through */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
        /* Should never have loaded on this device */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
        hw->phy_type = e1000_phy_undefined;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
        return -E1000_ERR_PHY_TYPE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
 * IGP phy init script - initializes the GbE PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
e1000_phy_init_script(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
    uint32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
    uint16_t phy_saved_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
    DEBUGFUNC("e1000_phy_init_script");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
    if(hw->phy_init_script) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
        msec_delay(20);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
        /* Save off the current value of register 0x2F5B to be restored at
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
         * the end of this routine. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
        ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
        /* Disabled the PHY transmitter */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
        e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
        msec_delay(20);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
        e1000_write_phy_reg(hw,0x0000,0x0140);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
        msec_delay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
        switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
        case e1000_82541:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
        case e1000_82547:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
            e1000_write_phy_reg(hw, 0x1F95, 0x0001);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
            e1000_write_phy_reg(hw, 0x1F71, 0xBD21);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
            e1000_write_phy_reg(hw, 0x1F79, 0x0018);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
            e1000_write_phy_reg(hw, 0x1F30, 0x1600);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
            e1000_write_phy_reg(hw, 0x1F31, 0x0014);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
            e1000_write_phy_reg(hw, 0x1F32, 0x161C);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
            e1000_write_phy_reg(hw, 0x1F94, 0x0003);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
            e1000_write_phy_reg(hw, 0x1F96, 0x003F);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
            e1000_write_phy_reg(hw, 0x2010, 0x0008);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
        case e1000_82541_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
        case e1000_82547_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
            e1000_write_phy_reg(hw, 0x1F73, 0x0099);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
        e1000_write_phy_reg(hw, 0x0000, 0x3300);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
        msec_delay(20);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
        /* Now enable the transmitter */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
        e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
        if(hw->mac_type == e1000_82547) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
            uint16_t fused, fine, coarse;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
            /* Move to analog registers page */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
            e1000_read_phy_reg(hw, IGP01E1000_ANALOG_SPARE_FUSE_STATUS, &fused);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
            if(!(fused & IGP01E1000_ANALOG_SPARE_FUSE_ENABLED)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
                e1000_read_phy_reg(hw, IGP01E1000_ANALOG_FUSE_STATUS, &fused);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
                fine = fused & IGP01E1000_ANALOG_FUSE_FINE_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
                coarse = fused & IGP01E1000_ANALOG_FUSE_COARSE_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
                if(coarse > IGP01E1000_ANALOG_FUSE_COARSE_THRESH) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
                    coarse -= IGP01E1000_ANALOG_FUSE_COARSE_10;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
                    fine -= IGP01E1000_ANALOG_FUSE_FINE_1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
                } else if(coarse == IGP01E1000_ANALOG_FUSE_COARSE_THRESH)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
                    fine -= IGP01E1000_ANALOG_FUSE_FINE_10;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
                fused = (fused & IGP01E1000_ANALOG_FUSE_POLY_MASK) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
                        (fine & IGP01E1000_ANALOG_FUSE_FINE_MASK) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
                        (coarse & IGP01E1000_ANALOG_FUSE_COARSE_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
                e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_CONTROL, fused);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
                e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_BYPASS,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
                                    IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
 * Set the mac type member in the hw struct.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
e1000_set_mac_type(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
    DEBUGFUNC("e1000_set_mac_type");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
    switch (hw->device_id) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
    case E1000_DEV_ID_82542:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
        switch (hw->revision_id) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
        case E1000_82542_2_0_REV_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
            hw->mac_type = e1000_82542_rev2_0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
        case E1000_82542_2_1_REV_ID:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
            hw->mac_type = e1000_82542_rev2_1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
            /* Invalid 82542 revision ID */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
            return -E1000_ERR_MAC_TYPE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
    case E1000_DEV_ID_82543GC_FIBER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
    case E1000_DEV_ID_82543GC_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
        hw->mac_type = e1000_82543;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
    case E1000_DEV_ID_82544EI_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
    case E1000_DEV_ID_82544EI_FIBER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
    case E1000_DEV_ID_82544GC_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
    case E1000_DEV_ID_82544GC_LOM:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
        hw->mac_type = e1000_82544;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
    case E1000_DEV_ID_82540EM:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
    case E1000_DEV_ID_82540EM_LOM:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
    case E1000_DEV_ID_82540EP:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
    case E1000_DEV_ID_82540EP_LOM:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
    case E1000_DEV_ID_82540EP_LP:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
        hw->mac_type = e1000_82540;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
    case E1000_DEV_ID_82545EM_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
    case E1000_DEV_ID_82545EM_FIBER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
        hw->mac_type = e1000_82545;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
    case E1000_DEV_ID_82545GM_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
    case E1000_DEV_ID_82545GM_FIBER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
    case E1000_DEV_ID_82545GM_SERDES:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
        hw->mac_type = e1000_82545_rev_3;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
    case E1000_DEV_ID_82546EB_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
    case E1000_DEV_ID_82546EB_FIBER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
    case E1000_DEV_ID_82546EB_QUAD_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
        hw->mac_type = e1000_82546;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
    case E1000_DEV_ID_82546GB_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
    case E1000_DEV_ID_82546GB_FIBER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
    case E1000_DEV_ID_82546GB_SERDES:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
    case E1000_DEV_ID_82546GB_PCIE:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
    case E1000_DEV_ID_82546GB_QUAD_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
    case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
        hw->mac_type = e1000_82546_rev_3;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
    case E1000_DEV_ID_82541EI:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
    case E1000_DEV_ID_82541EI_MOBILE:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
    case E1000_DEV_ID_82541ER_LOM:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
        hw->mac_type = e1000_82541;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
    case E1000_DEV_ID_82541ER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
    case E1000_DEV_ID_82541GI:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
    case E1000_DEV_ID_82541GI_LF:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
    case E1000_DEV_ID_82541GI_MOBILE:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
        hw->mac_type = e1000_82541_rev_2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
    case E1000_DEV_ID_82547EI:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
    case E1000_DEV_ID_82547EI_MOBILE:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
        hw->mac_type = e1000_82547;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
    case E1000_DEV_ID_82547GI:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
        hw->mac_type = e1000_82547_rev_2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
    case E1000_DEV_ID_82571EB_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
    case E1000_DEV_ID_82571EB_FIBER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
    case E1000_DEV_ID_82571EB_SERDES:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
            hw->mac_type = e1000_82571;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
    case E1000_DEV_ID_82572EI_COPPER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
    case E1000_DEV_ID_82572EI_FIBER:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
    case E1000_DEV_ID_82572EI_SERDES:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
    case E1000_DEV_ID_82572EI:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
        hw->mac_type = e1000_82572;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
    case E1000_DEV_ID_82573E:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
    case E1000_DEV_ID_82573E_IAMT:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
    case E1000_DEV_ID_82573L:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
        hw->mac_type = e1000_82573;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
    case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
    case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
    case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
    case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
        hw->mac_type = e1000_80003es2lan;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
    case E1000_DEV_ID_ICH8_IGP_M_AMT:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
    case E1000_DEV_ID_ICH8_IGP_AMT:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
    case E1000_DEV_ID_ICH8_IGP_C:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
    case E1000_DEV_ID_ICH8_IFE:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
    case E1000_DEV_ID_ICH8_IGP_M:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
        hw->mac_type = e1000_ich8lan;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
        /* Should never have loaded on this device */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
        return -E1000_ERR_MAC_TYPE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
    case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
        hw->swfwhw_semaphore_present = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
        hw->asf_firmware_present = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
        hw->swfw_sync_present = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
        /* fall through */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
    case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
    case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
        hw->eeprom_semaphore_present = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
        /* fall through */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
    case e1000_82541:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
    case e1000_82547:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
    case e1000_82541_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
    case e1000_82547_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
        hw->asf_firmware_present = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
 * Set media type and TBI compatibility.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
 * **************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
e1000_set_media_type(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
    uint32_t status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
    DEBUGFUNC("e1000_set_media_type");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
    if(hw->mac_type != e1000_82543) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
        /* tbi_compatibility is only valid on 82543 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
        hw->tbi_compatibility_en = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
    switch (hw->device_id) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
    case E1000_DEV_ID_82545GM_SERDES:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
    case E1000_DEV_ID_82546GB_SERDES:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
    case E1000_DEV_ID_82571EB_SERDES:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
    case E1000_DEV_ID_82572EI_SERDES:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
    case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
        hw->media_type = e1000_media_type_internal_serdes;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
        switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
        case e1000_82542_rev2_0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
        case e1000_82542_rev2_1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
            hw->media_type = e1000_media_type_fiber;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
        case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
        case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
            /* The STATUS_TBIMODE bit is reserved or reused for the this
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
             * device.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
            hw->media_type = e1000_media_type_copper;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
            status = E1000_READ_REG(hw, STATUS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
            if (status & E1000_STATUS_TBIMODE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
                hw->media_type = e1000_media_type_fiber;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
                /* tbi_compatibility not valid on fiber */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
                hw->tbi_compatibility_en = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
                hw->media_type = e1000_media_type_copper;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
 * Reset the transmit and receive units; mask and clear all interrupts.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
e1000_reset_hw(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
    uint32_t ctrl_ext;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
    uint32_t icr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
    uint32_t manc;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
    uint32_t led_ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
    uint32_t timeout;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
    uint32_t extcnf_ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
    DEBUGFUNC("e1000_reset_hw");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
    /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
    if(hw->mac_type == e1000_82542_rev2_0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
        DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
        e1000_pci_clear_mwi(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
    if(hw->bus_type == e1000_bus_type_pci_express) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
        /* Prevent the PCI-E bus from sticking if there is no TLP connection
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
         * on the last TLP read/write transaction when MAC is reset.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
        if(e1000_disable_pciex_master(hw) != E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
            DEBUGOUT("PCI-E Master disable polling has failed.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
    /* Clear interrupt mask to stop board from generating interrupts */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
    DEBUGOUT("Masking off all interrupts\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
    E1000_WRITE_REG(hw, IMC, 0xffffffff);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
    /* Disable the Transmit and Receive units.  Then delay to allow
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
     * any pending transactions to complete before we hit the MAC with
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
     * the global reset.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
    E1000_WRITE_REG(hw, RCTL, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
    E1000_WRITE_REG(hw, TCTL, E1000_TCTL_PSP);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
    /* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
    hw->tbi_compatibility_on = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
    /* Delay to allow any outstanding PCI transactions to complete before
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
     * resetting the device
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
    msec_delay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
    /* Must reset the PHY before resetting the MAC */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
    if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
        E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_PHY_RST));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
        msec_delay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
    /* Must acquire the MDIO ownership before MAC reset.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
     * Ownership defaults to firmware after a reset. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
    if(hw->mac_type == e1000_82573) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
        timeout = 10;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
        extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
        extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
        do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
            E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
            extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
            if(extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
            else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
                extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
            msec_delay(2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
            timeout--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
        } while(timeout);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
    /* Workaround for ICH8 bit corruption issue in FIFO memory */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
    if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
        /* Set Tx and Rx buffer allocation to 8k apiece. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
        E1000_WRITE_REG(hw, PBA, E1000_PBA_8K);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
        /* Set Packet Buffer Size to 16k. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
        E1000_WRITE_REG(hw, PBS, E1000_PBS_16K);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
    /* Issue a global reset to the MAC.  This will reset the chip's
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
     * transmit, receive, DMA, and link units.  It will not effect
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
     * the current PCI configuration.  The global reset bit is self-
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
     * clearing, and should clear within a microsecond.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
    DEBUGOUT("Issuing a global reset to MAC\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
        case e1000_82544:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
        case e1000_82540:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
        case e1000_82545:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
        case e1000_82546:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
        case e1000_82541:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
        case e1000_82541_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
            /* These controllers can't ack the 64-bit write when issuing the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
             * reset, so use IO-mapping as a workaround to issue the reset */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
            E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_RST));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
        case e1000_82545_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
        case e1000_82546_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
            /* Reset is performed on a shadow of the control register */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
            E1000_WRITE_REG(hw, CTRL_DUP, (ctrl | E1000_CTRL_RST));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
        case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
            if (!hw->phy_reset_disable &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
                e1000_check_phy_reset_block(hw) == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
                /* e1000_ich8lan PHY HW reset requires MAC CORE reset
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
                 * at the same time to make sure the interface between
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
                 * MAC and the external PHY is reset.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
                 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
                ctrl |= E1000_CTRL_PHY_RST;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
            e1000_get_software_flag(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
            E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
            msec_delay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
            E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
    /* After MAC reset, force reload of EEPROM to restore power-on settings to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
     * device.  Later controllers reload the EEPROM automatically, so just wait
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
     * for reload to complete.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
        case e1000_82542_rev2_0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
        case e1000_82542_rev2_1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
        case e1000_82543:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
        case e1000_82544:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
            /* Wait for reset to complete */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
            udelay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
            ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
            ctrl_ext |= E1000_CTRL_EXT_EE_RST;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
            E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
            E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
            /* Wait for EEPROM reload */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
            msec_delay(2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
        case e1000_82541:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
        case e1000_82541_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
        case e1000_82547:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
        case e1000_82547_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
            /* Wait for EEPROM reload */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
            msec_delay(20);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
        case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
            if (e1000_is_onboard_nvm_eeprom(hw) == FALSE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
                udelay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
                ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
                ctrl_ext |= E1000_CTRL_EXT_EE_RST;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
                E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
                E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
            /* fall through */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
        case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
        case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
        case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
        case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
            ret_val = e1000_get_auto_rd_done(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
                /* We don't want to continue accessing MAC registers. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
            /* Wait for EEPROM reload (it happens automatically) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
            msec_delay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
    /* Disable HW ARPs on ASF enabled adapters */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
    if(hw->mac_type >= e1000_82540 && hw->mac_type <= e1000_82547_rev_2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
        manc = E1000_READ_REG(hw, MANC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
        manc &= ~(E1000_MANC_ARP_EN);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
        E1000_WRITE_REG(hw, MANC, manc);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
    if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
        e1000_phy_init_script(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
        /* Configure activity LED after PHY reset */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
        led_ctrl = E1000_READ_REG(hw, LEDCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
        led_ctrl &= IGP_ACTIVITY_LED_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
        led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
        E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
    /* Clear interrupt mask to stop board from generating interrupts */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
    DEBUGOUT("Masking off all interrupts\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
    E1000_WRITE_REG(hw, IMC, 0xffffffff);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
    /* Clear any pending interrupt events. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
    icr = E1000_READ_REG(hw, ICR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
    /* If MWI was previously enabled, reenable it. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
    if(hw->mac_type == e1000_82542_rev2_0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
        if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
            e1000_pci_set_mwi(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
    if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
        uint32_t kab = E1000_READ_REG(hw, KABGTXD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
        kab |= E1000_KABGTXD_BGSQLBIAS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
        E1000_WRITE_REG(hw, KABGTXD, kab);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
 * Performs basic configuration of the adapter.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
 * Assumes that the controller has previously been reset and is in a
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
 * post-reset uninitialized state. Initializes the receive address registers,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
 * multicast table, and VLAN filter table. Calls routines to setup link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
 * configuration and flow control settings. Clears all on-chip counters. Leaves
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
 * the transmit and receive units disabled and uninitialized.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
e1000_init_hw(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
    uint32_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
    uint16_t pcix_cmd_word;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
    uint16_t pcix_stat_hi_word;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
    uint16_t cmd_mmrbc;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
    uint16_t stat_mmrbc;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
    uint32_t mta_size;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
    uint32_t reg_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
    uint32_t ctrl_ext;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
    DEBUGFUNC("e1000_init_hw");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
    /* Initialize Identification LED */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
    ret_val = e1000_id_led_init(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
    if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
        DEBUGOUT("Error Initializing Identification LED\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
    /* Set the media type and TBI compatibility */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
    e1000_set_media_type(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
    /* Disabling VLAN filtering. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
    DEBUGOUT("Initializing the IEEE VLAN\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
    /* VET hardcoded to standard value and VFTA removed in ICH8 LAN */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
    if (hw->mac_type != e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
        if (hw->mac_type < e1000_82545_rev_3)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
            E1000_WRITE_REG(hw, VET, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
        e1000_clear_vfta(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
    /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
    if(hw->mac_type == e1000_82542_rev2_0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
        DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
        e1000_pci_clear_mwi(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
        E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
        msec_delay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
    /* Setup the receive address. This involves initializing all of the Receive
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
     * Address Registers (RARs 0 - 15).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
    e1000_init_rx_addrs(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
    /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
    if(hw->mac_type == e1000_82542_rev2_0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
        E1000_WRITE_REG(hw, RCTL, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
        msec_delay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
        if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
            e1000_pci_set_mwi(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
    /* Zero out the Multicast HASH table */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
    DEBUGOUT("Zeroing the MTA\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
    mta_size = E1000_MC_TBL_SIZE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
        mta_size = E1000_MC_TBL_SIZE_ICH8LAN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
    for(i = 0; i < mta_size; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
        E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
        /* use write flush to prevent Memory Write Block (MWB) from
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
         * occuring when accessing our register space */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
    /* Set the PCI priority bit correctly in the CTRL register.  This
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
     * determines if the adapter gives priority to receives, or if it
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
     * gives equal priority to transmits and receives.  Valid only on
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
     * 82542 and 82543 silicon.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
    if(hw->dma_fairness && hw->mac_type <= e1000_82543) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
        ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
        E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
    case e1000_82545_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
    case e1000_82546_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
        /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
        if(hw->bus_type == e1000_bus_type_pcix) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
            e1000_read_pci_cfg(hw, PCIX_COMMAND_REGISTER, &pcix_cmd_word);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
            e1000_read_pci_cfg(hw, PCIX_STATUS_REGISTER_HI,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
                &pcix_stat_hi_word);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
            cmd_mmrbc = (pcix_cmd_word & PCIX_COMMAND_MMRBC_MASK) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
                PCIX_COMMAND_MMRBC_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
            stat_mmrbc = (pcix_stat_hi_word & PCIX_STATUS_HI_MMRBC_MASK) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
                PCIX_STATUS_HI_MMRBC_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
            if(stat_mmrbc == PCIX_STATUS_HI_MMRBC_4K)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
                stat_mmrbc = PCIX_STATUS_HI_MMRBC_2K;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
            if(cmd_mmrbc > stat_mmrbc) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
                pcix_cmd_word &= ~PCIX_COMMAND_MMRBC_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
                pcix_cmd_word |= stat_mmrbc << PCIX_COMMAND_MMRBC_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
                e1000_write_pci_cfg(hw, PCIX_COMMAND_REGISTER,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
                    &pcix_cmd_word);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
    /* More time needed for PHY to initialize */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
        msec_delay(15);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
    /* Call a subroutine to configure the link and setup flow control. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
    ret_val = e1000_setup_link(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
    /* Set the transmit descriptor write-back policy */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
    if(hw->mac_type > e1000_82544) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
        ctrl = E1000_READ_REG(hw, TXDCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
        ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
        switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
        case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
        case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
        case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
        case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
        case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
            ctrl |= E1000_TXDCTL_COUNT_DESC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
        E1000_WRITE_REG(hw, TXDCTL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
    if (hw->mac_type == e1000_82573) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
        e1000_enable_tx_pkt_filtering(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
        /* Enable retransmit on late collisions */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
        reg_data = E1000_READ_REG(hw, TCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
        reg_data |= E1000_TCTL_RTLC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
        E1000_WRITE_REG(hw, TCTL, reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
        /* Configure Gigabit Carry Extend Padding */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
        reg_data = E1000_READ_REG(hw, TCTL_EXT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
        reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
        reg_data |= DEFAULT_80003ES2LAN_TCTL_EXT_GCEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
        E1000_WRITE_REG(hw, TCTL_EXT, reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
        /* Configure Transmit Inter-Packet Gap */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
        reg_data = E1000_READ_REG(hw, TIPG);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
        reg_data &= ~E1000_TIPG_IPGT_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
        reg_data |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
        E1000_WRITE_REG(hw, TIPG, reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
        reg_data = E1000_READ_REG_ARRAY(hw, FFLT, 0x0001);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
        reg_data &= ~0x00100000;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
        E1000_WRITE_REG_ARRAY(hw, FFLT, 0x0001, reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
        /* Fall through */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
    case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
    case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
        ctrl = E1000_READ_REG(hw, TXDCTL1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
        ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
        if(hw->mac_type >= e1000_82571)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
            ctrl |= E1000_TXDCTL_COUNT_DESC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
        E1000_WRITE_REG(hw, TXDCTL1, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
    if (hw->mac_type == e1000_82573) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
        uint32_t gcr = E1000_READ_REG(hw, GCR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
        gcr |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
        E1000_WRITE_REG(hw, GCR, gcr);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
    /* Clear all of the statistics registers (clear on read).  It is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
     * important that we do this after we have tried to establish link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
     * because the symbol error count will increment wildly if there
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
     * is no link.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
    e1000_clear_hw_cntrs(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
    /* ICH8 No-snoop bits are opposite polarity.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
     * Set to snoop by default after reset. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
        e1000_set_pci_ex_no_snoop(hw, PCI_EX_82566_SNOOP_ALL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
    if (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
        hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
        ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
        /* Relaxed ordering must be disabled to avoid a parity
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
         * error crash in a PCI slot. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
        ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
 * Adjust SERDES output amplitude based on EEPROM setting.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
 * hw - Struct containing variables accessed by shared code.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
e1000_adjust_serdes_amplitude(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
    uint16_t eeprom_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
    int32_t  ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
    DEBUGFUNC("e1000_adjust_serdes_amplitude");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
    if(hw->media_type != e1000_media_type_internal_serdes)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
    case e1000_82545_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
    case e1000_82546_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
    ret_val = e1000_read_eeprom(hw, EEPROM_SERDES_AMPLITUDE, 1, &eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
    if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
    if(eeprom_data != EEPROM_RESERVED_WORD) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
        /* Adjust SERDES output amplitude only. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
        eeprom_data &= EEPROM_SERDES_AMPLITUDE_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
        ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_EXT_CTRL, eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
 * Configures flow control and link settings.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
 * Determines which flow control settings to use. Calls the apropriate media-
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
 * specific link configuration function. Configures the flow control settings.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
 * Assuming the adapter has a valid link partner, a valid link should be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
 * established. Assumes the hardware has previously been reset and the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
 * transmitter and receiver are not enabled.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
e1000_setup_link(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
    uint32_t ctrl_ext;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
    uint16_t eeprom_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
    DEBUGFUNC("e1000_setup_link");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
    /* In the case of the phy reset being blocked, we already have a link.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
     * We do not have to set it up again. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
    if (e1000_check_phy_reset_block(hw))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
    /* Read and store word 0x0F of the EEPROM. This word contains bits
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
     * that determine the hardware's default PAUSE (flow control) mode,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
     * a bit that determines whether the HW defaults to enabling or
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
     * disabling auto-negotiation, and the direction of the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
     * SW defined pins. If there is no SW over-ride of the flow
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
     * control setting, then the variable hw->fc will
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
     * be initialized based on a value in the EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
    if (hw->fc == e1000_fc_default) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
        switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
        case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
        case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
            hw->fc = e1000_fc_full;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
            ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
                                        1, &eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
            if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
                DEBUGOUT("EEPROM Read Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
                return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
            if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
                hw->fc = e1000_fc_none;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
            else if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
                    EEPROM_WORD0F_ASM_DIR)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
                hw->fc = e1000_fc_tx_pause;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
            else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
                hw->fc = e1000_fc_full;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
    /* We want to save off the original Flow Control configuration just
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
     * in case we get disconnected and then reconnected into a different
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
     * hub or switch with different Flow Control capabilities.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
    if(hw->mac_type == e1000_82542_rev2_0)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
        hw->fc &= (~e1000_fc_tx_pause);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
    if((hw->mac_type < e1000_82543) && (hw->report_tx_early == 1))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
        hw->fc &= (~e1000_fc_rx_pause);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
    hw->original_fc = hw->fc;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
    DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
    /* Take the 4 bits from EEPROM word 0x0F that determine the initial
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
     * polarity value for the SW controlled pins, and setup the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
     * Extended Device Control reg with that info.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
     * This is needed because one of the SW controlled pins is used for
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
     * signal detection.  So this should be done before e1000_setup_pcs_link()
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
     * or e1000_phy_setup() is called.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
    if (hw->mac_type == e1000_82543) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
		ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
									1, &eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
		if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
			DEBUGOUT("EEPROM Read Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
			return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
		}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
        ctrl_ext = ((eeprom_data & EEPROM_WORD0F_SWPDIO_EXT) <<
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
                    SWDPIO__EXT_SHIFT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
    /* Call the necessary subroutine to configure the link. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
    ret_val = (hw->media_type == e1000_media_type_copper) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
              e1000_setup_copper_link(hw) :
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
              e1000_setup_fiber_serdes_link(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
    /* Initialize the flow control address, type, and PAUSE timer
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
     * registers to their default values.  This is done even if flow
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
     * control is disabled, because it does not hurt anything to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
     * initialize these registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
    DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
    /* FCAL/H and FCT are hardcoded to standard values in e1000_ich8lan. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
    if (hw->mac_type != e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
        E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
        E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
        E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
    E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
    /* Set the flow control receive threshold registers.  Normally,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
     * these registers will be set to a default threshold that may be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
     * adjusted later by the driver's runtime code.  However, if the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
     * ability to transmit pause frames in not enabled, then these
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
     * registers will be set to 0.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
    if(!(hw->fc & e1000_fc_tx_pause)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
        E1000_WRITE_REG(hw, FCRTL, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
        E1000_WRITE_REG(hw, FCRTH, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
        /* We need to set up the Receive Threshold high and low water marks
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
         * as well as (optionally) enabling the transmission of XON frames.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
        if(hw->fc_send_xon) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
            E1000_WRITE_REG(hw, FCRTL, (hw->fc_low_water | E1000_FCRTL_XONE));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
            E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
            E1000_WRITE_REG(hw, FCRTL, hw->fc_low_water);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
            E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
 * Sets up link for a fiber based or serdes based adapter
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
 * Manipulates Physical Coding Sublayer functions in order to configure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
 * link. Assumes the hardware has been previously reset and the transmitter
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
 * and receiver are not enabled.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
    uint32_t status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
    uint32_t txcw = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
    uint32_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
    uint32_t signal = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
    DEBUGFUNC("e1000_setup_fiber_serdes_link");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
    /* On 82571 and 82572 Fiber connections, SerDes loopback mode persists
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
     * until explicitly turned off or a power cycle is performed.  A read to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
     * the register does not indicate its status.  Therefore, we ensure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
     * loopback mode is disabled during initialization.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
    if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
        E1000_WRITE_REG(hw, SCTL, E1000_DISABLE_SERDES_LOOPBACK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
    /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
     * set when the optics detect a signal. On older adapters, it will be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
     * cleared when there is a signal.  This applies to fiber media only.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
     * If we're on serdes media, adjust the output amplitude to value set in
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
     * the EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
    if(hw->media_type == e1000_media_type_fiber)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
        signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
    ret_val = e1000_adjust_serdes_amplitude(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
    /* Take the link out of reset */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
    ctrl &= ~(E1000_CTRL_LRST);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
    /* Adjust VCO speed to improve BER performance */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
    ret_val = e1000_set_vco_speed(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
    e1000_config_collision_dist(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
    /* Check for a software override of the flow control settings, and setup
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
     * the device accordingly.  If auto-negotiation is enabled, then software
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
     * will have to set the "PAUSE" bits to the correct value in the Tranmsit
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
     * Config Word Register (TXCW) and re-start auto-negotiation.  However, if
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
     * auto-negotiation is disabled, then software will have to manually
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
     * configure the two flow control enable bits in the CTRL register.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
     *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
     * The possible values of the "fc" parameter are:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
     *      0:  Flow control is completely disabled
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
     *      1:  Rx flow control is enabled (we can receive pause frames, but
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
     *          not send pause frames).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
     *      2:  Tx flow control is enabled (we can send pause frames but we do
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
     *          not support receiving pause frames).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
     *      3:  Both Rx and TX flow control (symmetric) are enabled.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
    switch (hw->fc) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
    case e1000_fc_none:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
        /* Flow control is completely disabled by a software over-ride. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
        txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
    case e1000_fc_rx_pause:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
        /* RX Flow control is enabled and TX Flow control is disabled by a
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
         * software over-ride. Since there really isn't a way to advertise
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
         * that we are capable of RX Pause ONLY, we will advertise that we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
         * support both symmetric and asymmetric RX PAUSE. Later, we will
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
         *  disable the adapter's ability to send PAUSE frames.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
        txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
    case e1000_fc_tx_pause:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
        /* TX Flow control is enabled, and RX Flow control is disabled, by a
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
         * software over-ride.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
        txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
    case e1000_fc_full:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
        /* Flow control (both RX and TX) is enabled by a software over-ride. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
        txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
        DEBUGOUT("Flow control param set incorrectly\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
        return -E1000_ERR_CONFIG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
    /* Since auto-negotiation is enabled, take the link out of reset (the link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
     * will be in reset, because we previously reset the chip). This will
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
     * restart auto-negotiation.  If auto-neogtiation is successful then the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
     * link-up status bit will be set and the flow control enable bits (RFCE
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
     * and TFCE) will be set according to their negotiated value.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
    DEBUGOUT("Auto-negotiation enabled\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
    E1000_WRITE_REG(hw, TXCW, txcw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
    E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
    hw->txcw = txcw;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
    msec_delay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
    /* If we have a signal (the cable is plugged in) then poll for a "Link-Up"
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
     * indication in the Device Status Register.  Time-out if a link isn't
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
     * seen in 500 milliseconds seconds (Auto-negotiation should complete in
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
     * less than 500 milliseconds even if the other end is doing it in SW).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
     * For internal serdes, we just assume a signal is present, then poll.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
    if(hw->media_type == e1000_media_type_internal_serdes ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
       (E1000_READ_REG(hw, CTRL) & E1000_CTRL_SWDPIN1) == signal) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
        DEBUGOUT("Looking for Link\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
        for(i = 0; i < (LINK_UP_TIMEOUT / 10); i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
            msec_delay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
            status = E1000_READ_REG(hw, STATUS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
            if(status & E1000_STATUS_LU) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
        if(i == (LINK_UP_TIMEOUT / 10)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
            DEBUGOUT("Never got a valid link from auto-neg!!!\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
            hw->autoneg_failed = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
            /* AutoNeg failed to achieve a link, so we'll call
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
             * e1000_check_for_link. This routine will force the link up if
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
             * we detect a signal. This will allow us to communicate with
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
             * non-autonegotiating link partners.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
            ret_val = e1000_check_for_link(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
            if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
                DEBUGOUT("Error while checking for link\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
            hw->autoneg_failed = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
            hw->autoneg_failed = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
            DEBUGOUT("Valid Link Found\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
        DEBUGOUT("No Signal Detected\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
* Make sure we have a valid PHY and change PHY mode before link setup.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
e1000_copper_link_preconfig(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
    DEBUGFUNC("e1000_copper_link_preconfig");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
    /* With 82543, we need to force speed and duplex on the MAC equal to what
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
     * the PHY speed and duplex configuration is. In addition, we need to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
     * perform a hardware reset on the PHY to take it out of reset.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
    if(hw->mac_type > e1000_82543) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
        ctrl |= E1000_CTRL_SLU;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
        ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
        E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
        ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
        E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
        ret_val = e1000_phy_hw_reset(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
    /* Make sure we have a valid PHY */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
    ret_val = e1000_detect_gig_phy(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
    if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
        DEBUGOUT("Error, did not detect valid phy.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
    DEBUGOUT1("Phy ID = %x \n", hw->phy_id);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
    /* Set PHY to class A mode (if necessary) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
    ret_val = e1000_set_phy_mode(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
    if((hw->mac_type == e1000_82545_rev_3) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
       (hw->mac_type == e1000_82546_rev_3)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
        phy_data |= 0x00000008;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
        ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
    if(hw->mac_type <= e1000_82543 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
       hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
       hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
        hw->phy_reset_disable = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
   return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
/********************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
* Copper link setup for e1000_phy_igp series.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
*********************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
e1000_copper_link_igp_setup(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
    uint32_t led_ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
    DEBUGFUNC("e1000_copper_link_igp_setup");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
    if (hw->phy_reset_disable)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
    ret_val = e1000_phy_reset(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
    if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
        DEBUGOUT("Error Resetting the PHY\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
    /* Wait 10ms for MAC to configure PHY from eeprom settings */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
    msec_delay(15);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
    if (hw->mac_type != e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
    /* Configure activity LED after PHY reset */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
    led_ctrl = E1000_READ_REG(hw, LEDCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
    led_ctrl &= IGP_ACTIVITY_LED_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
    led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
    E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
    /* disable lplu d3 during driver init */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
    ret_val = e1000_set_d3_lplu_state(hw, FALSE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
    if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
        DEBUGOUT("Error Disabling LPLU D3\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
    /* disable lplu d0 during driver init */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
    ret_val = e1000_set_d0_lplu_state(hw, FALSE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
    if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
        DEBUGOUT("Error Disabling LPLU D0\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
    /* Configure mdi-mdix settings */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
    ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
    if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
        hw->dsp_config_state = e1000_dsp_config_disabled;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
        /* Force MDI for earlier revs of the IGP PHY */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
        phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX | IGP01E1000_PSCR_FORCE_MDI_MDIX);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
        hw->mdix = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
        hw->dsp_config_state = e1000_dsp_config_enabled;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
        phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
        switch (hw->mdix) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
        case 1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
            phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
        case 2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
            phy_data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
        case 0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
            phy_data |= IGP01E1000_PSCR_AUTO_MDIX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
    ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
    /* set auto-master slave resolution settings */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
    if(hw->autoneg) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
        e1000_ms_type phy_ms_setting = hw->master_slave;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
        if(hw->ffe_config_state == e1000_ffe_config_active)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
            hw->ffe_config_state = e1000_ffe_config_enabled;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
        if(hw->dsp_config_state == e1000_dsp_config_activated)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
            hw->dsp_config_state = e1000_dsp_config_enabled;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
        /* when autonegotiation advertisment is only 1000Mbps then we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
          * should disable SmartSpeed and enable Auto MasterSlave
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
          * resolution as hardware default. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
        if(hw->autoneg_advertised == ADVERTISE_1000_FULL) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
            /* Disable SmartSpeed */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
            phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
            ret_val = e1000_write_phy_reg(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
                                                  IGP01E1000_PHY_PORT_CONFIG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
                                                  phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
            /* Set auto Master/Slave resolution process */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
            ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
            phy_data &= ~CR_1000T_MS_ENABLE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
            ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
        ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
        /* load defaults for future use */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
        hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
                                        ((phy_data & CR_1000T_MS_VALUE) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
                                         e1000_ms_force_master :
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
                                         e1000_ms_force_slave) :
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
                                         e1000_ms_auto;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
        switch (phy_ms_setting) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
        case e1000_ms_force_master:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
            phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
        case e1000_ms_force_slave:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
            phy_data |= CR_1000T_MS_ENABLE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
            phy_data &= ~(CR_1000T_MS_VALUE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
        case e1000_ms_auto:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
            phy_data &= ~CR_1000T_MS_ENABLE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
            default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
        ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
/********************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
* Copper link setup for e1000_phy_gg82563 series.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
*********************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
e1000_copper_link_ggp_setup(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
    uint32_t reg_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
    DEBUGFUNC("e1000_copper_link_ggp_setup");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
    if(!hw->phy_reset_disable) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
        /* Enable CRS on TX for half-duplex operation. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
                                     &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
        phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
        /* Use 25MHz for both link down and 1000BASE-T for Tx clock */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
        phy_data |= GG82563_MSCR_TX_CLK_1000MBPS_25MHZ;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
                                      phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
        /* Options:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
         *   MDI/MDI-X = 0 (default)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
         *   0 - Auto for all speeds
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
         *   1 - MDI mode
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
         *   2 - MDI-X mode
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
         *   3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_SPEC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
        phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
        switch (hw->mdix) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
        case 1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
            phy_data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
        case 2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
            phy_data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
        case 0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
            phy_data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
        /* Options:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
         *   disable_polarity_correction = 0 (default)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
         *       Automatic Correction for Reversed Cable Polarity
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
         *   0 - Disabled
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
         *   1 - Enabled
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
        phy_data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
        if(hw->disable_polarity_correction == 1)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
            phy_data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_SPEC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
        /* SW Reset the PHY so all changes take effect */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
        ret_val = e1000_phy_reset(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
        if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
            DEBUGOUT("Error Resetting the PHY\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
    } /* phy_reset_disable */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
    if (hw->mac_type == e1000_80003es2lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
        /* Bypass RX and TX FIFO's */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
        ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_FIFO_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
                                       E1000_KUMCTRLSTA_FIFO_CTRL_RX_BYPASS |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
                                       E1000_KUMCTRLSTA_FIFO_CTRL_TX_BYPASS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_SPEC_CTRL_2, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
        phy_data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_SPEC_CTRL_2, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
        reg_data = E1000_READ_REG(hw, CTRL_EXT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
        reg_data &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
        E1000_WRITE_REG(hw, CTRL_EXT, reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_PWR_MGMT_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
                                          &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
        /* Do not init these registers when the HW is in IAMT mode, since the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
         * firmware will have already initialized them.  We only initialize
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
         * them if the HW is not in IAMT mode.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
        if (e1000_check_mng_mode(hw) == FALSE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
            /* Enable Electrical Idle on the PHY */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
            phy_data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
            ret_val = e1000_write_phy_reg(hw, GG82563_PHY_PWR_MGMT_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
                                          phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
            ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
                                         &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
            phy_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
            ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
                                          phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
        /* Workaround: Disable padding in Kumeran interface in the MAC
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
         * and in the PHY to avoid CRC errors.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_INBAND_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
                                     &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
        phy_data |= GG82563_ICR_DIS_PADDING;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_INBAND_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
                                      phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
/********************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
* Copper link setup for e1000_phy_m88 series.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
*********************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
e1000_copper_link_mgp_setup(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
    DEBUGFUNC("e1000_copper_link_mgp_setup");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
    if(hw->phy_reset_disable)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
    /* Enable CRS on TX. This must be set for half-duplex operation. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
    phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
    /* Options:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
     *   MDI/MDI-X = 0 (default)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
     *   0 - Auto for all speeds
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
     *   1 - MDI mode
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
     *   2 - MDI-X mode
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
     *   3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
    phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
    switch (hw->mdix) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
    case 1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
        phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
    case 2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
        phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
    case 3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
        phy_data |= M88E1000_PSCR_AUTO_X_1000T;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
    case 0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
        phy_data |= M88E1000_PSCR_AUTO_X_MODE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
    /* Options:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
     *   disable_polarity_correction = 0 (default)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
     *       Automatic Correction for Reversed Cable Polarity
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
     *   0 - Disabled
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
     *   1 - Enabled
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
    phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
    if(hw->disable_polarity_correction == 1)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
        phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
    if (hw->phy_revision < M88E1011_I_REV_4) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
        /* Force TX_CLK in the Extended PHY Specific Control Register
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
         * to 25MHz clock.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
        ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
        phy_data |= M88E1000_EPSCR_TX_CLK_25;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
        if ((hw->phy_revision == E1000_REVISION_2) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
            (hw->phy_id == M88E1111_I_PHY_ID)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
            /* Vidalia Phy, set the downshift counter to 5x */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
            phy_data &= ~(M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
            phy_data |= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
            ret_val = e1000_write_phy_reg(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
                                        M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
            /* Configure Master and Slave downshift values */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
            phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
                              M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
            phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
                             M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
            ret_val = e1000_write_phy_reg(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
                                        M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
               return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
    /* SW Reset the PHY so all changes take effect */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
    ret_val = e1000_phy_reset(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
    if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
        DEBUGOUT("Error Resetting the PHY\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
   return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
/********************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
* Setup auto-negotiation and flow control advertisements,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
* and then perform auto-negotiation.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
*********************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
e1000_copper_link_autoneg(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
    DEBUGFUNC("e1000_copper_link_autoneg");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
    /* Perform some bounds checking on the hw->autoneg_advertised
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
     * parameter.  If this variable is zero, then set it to the default.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
    hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
    /* If autoneg_advertised is zero, we assume it was not defaulted
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
     * by the calling code so we set to advertise full capability.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
    if(hw->autoneg_advertised == 0)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
        hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
    /* IFE phy only supports 10/100 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
    if (hw->phy_type == e1000_phy_ife)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
        hw->autoneg_advertised &= AUTONEG_ADVERTISE_10_100_ALL;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
    DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
    ret_val = e1000_phy_setup_autoneg(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
    if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
        DEBUGOUT("Error Setting up Auto-Negotiation\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
    DEBUGOUT("Restarting Auto-Neg\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
    /* Restart auto-negotiation by setting the Auto Neg Enable bit and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
     * the Auto Neg Restart bit in the PHY control register.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
    ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
    phy_data |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
    ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
    /* Does the user want to wait for Auto-Neg to complete here, or
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
     * check at a later time (for example, callback routine).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
    if(hw->wait_autoneg_complete) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
        ret_val = e1000_wait_autoneg(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
            DEBUGOUT("Error while waiting for autoneg to complete\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
    hw->get_link_status = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
* Config the MAC and the PHY after link is up.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
*   1) Set up the MAC to the current PHY speed/duplex
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
*      if we are on 82543.  If we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
*      are on newer silicon, we only need to configure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
*      collision distance in the Transmit Control Register.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
*   2) Set up flow control on the MAC to that established with
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
*      the link partner.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
*   3) Config DSP to improve Gigabit link quality for some PHY revisions.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
e1000_copper_link_postconfig(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
    DEBUGFUNC("e1000_copper_link_postconfig");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
    if(hw->mac_type >= e1000_82544) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
        e1000_config_collision_dist(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
        ret_val = e1000_config_mac_to_phy(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
            DEBUGOUT("Error configuring MAC to PHY settings\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
    ret_val = e1000_config_fc_after_link_up(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
    if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
        DEBUGOUT("Error Configuring Flow Control\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
    /* Config DSP to improve Giga link quality */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
    if(hw->phy_type == e1000_phy_igp) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
        ret_val = e1000_config_dsp_after_link_change(hw, TRUE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
            DEBUGOUT("Error Configuring DSP after link up\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
* Detects which PHY is present and setup the speed and duplex
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
e1000_setup_copper_link(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
    uint16_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
    uint16_t reg_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
    DEBUGFUNC("e1000_setup_copper_link");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
    case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
        /* Set the mac to wait the maximum time between each
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
         * iteration and increase the max iterations when
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
         * polling the phy; this fixes erroneous timeouts at 10Mbps. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
        ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
        ret_val = e1000_read_kmrn_reg(hw, GG82563_REG(0x34, 9), &reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
        reg_data |= 0x3F;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
        ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
    /* Check if it is a valid PHY and set PHY mode if necessary. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
    ret_val = e1000_copper_link_preconfig(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
        /* Kumeran registers are written-only */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
        reg_data = E1000_KUMCTRLSTA_INB_CTRL_LINK_STATUS_TX_TIMEOUT_DEFAULT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
        reg_data |= E1000_KUMCTRLSTA_INB_CTRL_DIS_PADDING;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
        ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_INB_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
                                       reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
    if (hw->phy_type == e1000_phy_igp ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
        hw->phy_type == e1000_phy_igp_3 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
        hw->phy_type == e1000_phy_igp_2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
        ret_val = e1000_copper_link_igp_setup(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
    } else if (hw->phy_type == e1000_phy_m88) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
        ret_val = e1000_copper_link_mgp_setup(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
    } else if (hw->phy_type == e1000_phy_gg82563) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
        ret_val = e1000_copper_link_ggp_setup(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
    if(hw->autoneg) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
        /* Setup autoneg and flow control advertisement
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
          * and perform autonegotiation */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
        ret_val = e1000_copper_link_autoneg(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
        /* PHY will be set to 10H, 10F, 100H,or 100F
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
          * depending on value from forced_speed_duplex. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
        DEBUGOUT("Forcing speed and duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
        ret_val = e1000_phy_force_speed_duplex(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
            DEBUGOUT("Error Forcing Speed and Duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
    /* Check link status. Wait up to 100 microseconds for link to become
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
     * valid.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
    for(i = 0; i < 10; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
        if(phy_data & MII_SR_LINK_STATUS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
            /* Config the MAC and PHY after link is up */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
            ret_val = e1000_copper_link_postconfig(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
            DEBUGOUT("Valid link established!!!\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
            return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
        udelay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
    DEBUGOUT("Unable to establish link!!!\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
* Configure the MAC-to-PHY interface for 10/100Mbps
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
e1000_configure_kmrn_for_10_100(struct e1000_hw *hw, uint16_t duplex)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
    int32_t ret_val = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
    uint32_t tipg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
    uint16_t reg_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
    DEBUGFUNC("e1000_configure_kmrn_for_10_100");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
    reg_data = E1000_KUMCTRLSTA_HD_CTRL_10_100_DEFAULT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
    ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_HD_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
                                   reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
    /* Configure Transmit Inter-Packet Gap */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
    tipg = E1000_READ_REG(hw, TIPG);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
    tipg &= ~E1000_TIPG_IPGT_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
    tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_10_100;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
    E1000_WRITE_REG(hw, TIPG, tipg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
    ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
    if (duplex == HALF_DUPLEX)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
        reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
    else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
        reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
    ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
e1000_configure_kmrn_for_1000(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
    int32_t ret_val = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
    uint16_t reg_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
    uint32_t tipg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
    DEBUGFUNC("e1000_configure_kmrn_for_1000");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
    reg_data = E1000_KUMCTRLSTA_HD_CTRL_1000_DEFAULT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
    ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_HD_CTRL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
                                   reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
    /* Configure Transmit Inter-Packet Gap */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
    tipg = E1000_READ_REG(hw, TIPG);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
    tipg &= ~E1000_TIPG_IPGT_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
    tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
    E1000_WRITE_REG(hw, TIPG, tipg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
    ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
    reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
    ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
* Configures PHY autoneg and flow control advertisement settings
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
e1000_phy_setup_autoneg(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
    uint16_t mii_autoneg_adv_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
    uint16_t mii_1000t_ctrl_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
    DEBUGFUNC("e1000_phy_setup_autoneg");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
    /* Read the MII Auto-Neg Advertisement Register (Address 4). */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
    ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
    if (hw->phy_type != e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
        /* Read the MII 1000Base-T Control Register (Address 9). */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
        ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
    } else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
        mii_1000t_ctrl_reg=0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
    /* Need to parse both autoneg_advertised and fc and set up
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
     * the appropriate PHY registers.  First we will parse for
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
     * autoneg_advertised software override.  Since we can advertise
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
     * a plethora of combinations, we need to check each bit
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
     * individually.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
    /* First we clear all the 10/100 mb speed bits in the Auto-Neg
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
     * Advertisement Register (Address 4) and the 1000 mb speed bits in
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
     * the  1000Base-T Control Register (Address 9).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
    mii_autoneg_adv_reg &= ~REG4_SPEED_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
    mii_1000t_ctrl_reg &= ~REG9_SPEED_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
    DEBUGOUT1("autoneg_advertised %x\n", hw->autoneg_advertised);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
    /* Do we want to advertise 10 Mb Half Duplex? */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
    if(hw->autoneg_advertised & ADVERTISE_10_HALF) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
        DEBUGOUT("Advertise 10mb Half duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
        mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
    /* Do we want to advertise 10 Mb Full Duplex? */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
    if(hw->autoneg_advertised & ADVERTISE_10_FULL) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
        DEBUGOUT("Advertise 10mb Full duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
        mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
    /* Do we want to advertise 100 Mb Half Duplex? */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
    if(hw->autoneg_advertised & ADVERTISE_100_HALF) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
        DEBUGOUT("Advertise 100mb Half duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
        mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
    /* Do we want to advertise 100 Mb Full Duplex? */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
    if(hw->autoneg_advertised & ADVERTISE_100_FULL) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
        DEBUGOUT("Advertise 100mb Full duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
        mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
    /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
    if(hw->autoneg_advertised & ADVERTISE_1000_HALF) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
        DEBUGOUT("Advertise 1000mb Half duplex requested, request denied!\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
    /* Do we want to advertise 1000 Mb Full Duplex? */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
    if(hw->autoneg_advertised & ADVERTISE_1000_FULL) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
        DEBUGOUT("Advertise 1000mb Full duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
        mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
        if (hw->phy_type == e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
            DEBUGOUT("e1000_phy_ife is a 10/100 PHY. Gigabit speed is not supported.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
    /* Check for a software override of the flow control settings, and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
     * setup the PHY advertisement registers accordingly.  If
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
     * auto-negotiation is enabled, then software will have to set the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
     * "PAUSE" bits to the correct value in the Auto-Negotiation
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
     * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
     *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
     * The possible values of the "fc" parameter are:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
     *      0:  Flow control is completely disabled
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
     *      1:  Rx flow control is enabled (we can receive pause frames
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
     *          but not send pause frames).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
     *      2:  Tx flow control is enabled (we can send pause frames
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
     *          but we do not support receiving pause frames).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
     *      3:  Both Rx and TX flow control (symmetric) are enabled.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
     *  other:  No software override.  The flow control configuration
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
     *          in the EEPROM is used.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
    switch (hw->fc) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
    case e1000_fc_none: /* 0 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
        /* Flow control (RX & TX) is completely disabled by a
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
         * software over-ride.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
        mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
    case e1000_fc_rx_pause: /* 1 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
        /* RX Flow control is enabled, and TX Flow control is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
         * disabled, by a software over-ride.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
        /* Since there really isn't a way to advertise that we are
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
         * capable of RX Pause ONLY, we will advertise that we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
         * support both symmetric and asymmetric RX PAUSE.  Later
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
         * (in e1000_config_fc_after_link_up) we will disable the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
         *hw's ability to send PAUSE frames.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
        mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
    case e1000_fc_tx_pause: /* 2 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
        /* TX Flow control is enabled, and RX Flow control is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
         * disabled, by a software over-ride.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
        mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
        mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
    case e1000_fc_full: /* 3 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
        /* Flow control (both RX and TX) is enabled by a software
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
         * over-ride.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
        mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
        DEBUGOUT("Flow control param set incorrectly\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
        return -E1000_ERR_CONFIG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
    ret_val = e1000_write_phy_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
    DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
    if (hw->phy_type != e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
        ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
* Force PHY speed and duplex settings to hw->forced_speed_duplex
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
e1000_phy_force_speed_duplex(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
    uint16_t mii_ctrl_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
    uint16_t mii_status_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
    uint16_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
    DEBUGFUNC("e1000_phy_force_speed_duplex");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
    /* Turn off Flow control if we are forcing speed and duplex. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
    hw->fc = e1000_fc_none;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
    DEBUGOUT1("hw->fc = %d\n", hw->fc);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
    /* Read the Device Control Register. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
    /* Set the bits to Force Speed and Duplex in the Device Ctrl Reg. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
    ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
    ctrl &= ~(DEVICE_SPEED_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
    /* Clear the Auto Speed Detect Enable bit. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
    ctrl &= ~E1000_CTRL_ASDE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
    /* Read the MII Control Register. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
    ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &mii_ctrl_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
    /* We need to disable autoneg in order to force link and duplex. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
    mii_ctrl_reg &= ~MII_CR_AUTO_NEG_EN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
    /* Are we forcing Full or Half Duplex? */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
    if(hw->forced_speed_duplex == e1000_100_full ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
       hw->forced_speed_duplex == e1000_10_full) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
        /* We want to force full duplex so we SET the full duplex bits in the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
         * Device and MII Control Registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
        ctrl |= E1000_CTRL_FD;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
        mii_ctrl_reg |= MII_CR_FULL_DUPLEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
        DEBUGOUT("Full Duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
        /* We want to force half duplex so we CLEAR the full duplex bits in
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
         * the Device and MII Control Registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
        ctrl &= ~E1000_CTRL_FD;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
        mii_ctrl_reg &= ~MII_CR_FULL_DUPLEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
        DEBUGOUT("Half Duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
    /* Are we forcing 100Mbps??? */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
    if(hw->forced_speed_duplex == e1000_100_full ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
       hw->forced_speed_duplex == e1000_100_half) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
        /* Set the 100Mb bit and turn off the 1000Mb and 10Mb bits. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
        ctrl |= E1000_CTRL_SPD_100;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
        mii_ctrl_reg |= MII_CR_SPEED_100;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
        mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
        DEBUGOUT("Forcing 100mb ");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
        /* Set the 10Mb bit and turn off the 1000Mb and 100Mb bits. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
        ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
        mii_ctrl_reg |= MII_CR_SPEED_10;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
        mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
        DEBUGOUT("Forcing 10mb ");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
    e1000_config_collision_dist(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
    /* Write the configured values back to the Device Control Reg. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
    E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
    if ((hw->phy_type == e1000_phy_m88) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
        (hw->phy_type == e1000_phy_gg82563)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
        /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
         * forced whenever speed are duplex are forced.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
        phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
        ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
        DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
        /* Need to reset the PHY or these changes will be ignored */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
        mii_ctrl_reg |= MII_CR_RESET;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
    /* Disable MDI-X support for 10/100 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
    } else if (hw->phy_type == e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
        ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
        phy_data &= ~IFE_PMC_AUTO_MDIX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
        phy_data &= ~IFE_PMC_FORCE_MDIX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
        ret_val = e1000_write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
        /* Clear Auto-Crossover to force MDI manually.  IGP requires MDI
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
         * forced whenever speed or duplex are forced.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
        phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
        phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
    /* Write back the modified PHY MII control register. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
    ret_val = e1000_write_phy_reg(hw, PHY_CTRL, mii_ctrl_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
    udelay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
    /* The wait_autoneg_complete flag may be a little misleading here.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
     * Since we are forcing speed and duplex, Auto-Neg is not enabled.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
     * But we do want to delay for a period while forcing only so we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
     * don't generate false No Link messages.  So we will wait here
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
     * only if the user has set wait_autoneg_complete to 1, which is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
     * the default.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
    if(hw->wait_autoneg_complete) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
        /* We will wait for autoneg to complete. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
        DEBUGOUT("Waiting for forced speed/duplex link.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
        mii_status_reg = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
        /* We will wait for autoneg to complete or 4.5 seconds to expire. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
        for(i = PHY_FORCE_TIME; i > 0; i--) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
            /* Read the MII Status Register and wait for Auto-Neg Complete bit
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
             * to be set.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
            ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
            ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
            if(mii_status_reg & MII_SR_LINK_STATUS) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
            msec_delay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
        if((i == 0) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
           ((hw->phy_type == e1000_phy_m88) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
            (hw->phy_type == e1000_phy_gg82563))) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
            /* We didn't get link.  Reset the DSP and wait again for link. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
            ret_val = e1000_phy_reset_dsp(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
            if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
                DEBUGOUT("Error Resetting PHY DSP\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
        /* This loop will early-out if the link condition has been met.  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
        for(i = PHY_FORCE_TIME; i > 0; i--) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
            if(mii_status_reg & MII_SR_LINK_STATUS) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
            msec_delay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
            /* Read the MII Status Register and wait for Auto-Neg Complete bit
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
             * to be set.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
            ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
            ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
    if (hw->phy_type == e1000_phy_m88) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
        /* Because we reset the PHY above, we need to re-force TX_CLK in the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
         * Extended PHY Specific Control Register to 25MHz clock.  This value
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
         * defaults back to a 2.5MHz clock when the PHY is reset.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
        ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
        phy_data |= M88E1000_EPSCR_TX_CLK_25;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
        ret_val = e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
        /* In addition, because of the s/w reset above, we need to enable CRS on
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
         * TX.  This must be set for both full and half duplex operation.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
        phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
        ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
        if((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
           (!hw->autoneg) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
           (hw->forced_speed_duplex == e1000_10_full ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
            hw->forced_speed_duplex == e1000_10_half)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
            ret_val = e1000_polarity_reversal_workaround(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
    } else if (hw->phy_type == e1000_phy_gg82563) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
        /* The TX_CLK of the Extended PHY Specific Control Register defaults
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
         * to 2.5MHz on a reset.  We need to re-force it back to 25MHz, if
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
         * we're not in a forced 10/duplex configuration. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
        phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
        if ((hw->forced_speed_duplex == e1000_10_full) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
            (hw->forced_speed_duplex == e1000_10_half))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
            phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5MHZ;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
        else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
            phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25MHZ;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
        /* Also due to the reset, we need to enable CRS on Tx. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
        phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
* Sets the collision distance in the Transmit Control register
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
* Link should have been established previously. Reads the speed and duplex
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
* information from the Device Status register.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
e1000_config_collision_dist(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
    uint32_t tctl, coll_dist;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
    DEBUGFUNC("e1000_config_collision_dist");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
    if (hw->mac_type < e1000_82543)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
        coll_dist = E1000_COLLISION_DISTANCE_82542;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
    else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
        coll_dist = E1000_COLLISION_DISTANCE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
    tctl = E1000_READ_REG(hw, TCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
    tctl &= ~E1000_TCTL_COLD;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
    tctl |= coll_dist << E1000_COLD_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
    E1000_WRITE_REG(hw, TCTL, tctl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
* Sets MAC speed and duplex settings to reflect the those in the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
* mii_reg - data to write to the MII control register
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
* The contents of the PHY register containing the needed information need to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
* be passed in.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
e1000_config_mac_to_phy(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
    DEBUGFUNC("e1000_config_mac_to_phy");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
    /* 82544 or newer MAC, Auto Speed Detection takes care of
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
    * MAC speed/duplex configuration.*/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
    if (hw->mac_type >= e1000_82544)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
    /* Read the Device Control Register and set the bits to Force Speed
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
     * and Duplex.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
    ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
    ctrl &= ~(E1000_CTRL_SPD_SEL | E1000_CTRL_ILOS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
    /* Set up duplex in the Device Control and Transmit Control
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
     * registers depending on negotiated values.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
    if(phy_data & M88E1000_PSSR_DPLX)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
        ctrl |= E1000_CTRL_FD;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
    else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
        ctrl &= ~E1000_CTRL_FD;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
    e1000_config_collision_dist(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
    /* Set up speed in the Device Control register depending on
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
     * negotiated values.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
    if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
        ctrl |= E1000_CTRL_SPD_1000;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
    else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
        ctrl |= E1000_CTRL_SPD_100;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
    /* Write the configured values back to the Device Control Reg. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
    E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
 * Forces the MAC's flow control settings.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
 * Sets the TFCE and RFCE bits in the device control register to reflect
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
 * the adapter settings. TFCE and RFCE need to be explicitly set by
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
 * software when a Copper PHY is used because autonegotiation is managed
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
 * by the PHY rather than the MAC. Software must also configure these
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
 * bits when link is forced on a fiber connection.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
e1000_force_mac_fc(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
    DEBUGFUNC("e1000_force_mac_fc");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
    /* Get the current configuration of the Device Control Register */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
    /* Because we didn't get link via the internal auto-negotiation
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
     * mechanism (we either forced link or we got link via PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
     * auto-neg), we have to manually enable/disable transmit an
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
     * receive flow control.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
     *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
     * The "Case" statement below enables/disable flow control
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
     * according to the "hw->fc" parameter.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
     *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
     * The possible values of the "fc" parameter are:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
     *      0:  Flow control is completely disabled
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
     *      1:  Rx flow control is enabled (we can receive pause
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
     *          frames but not send pause frames).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
     *      2:  Tx flow control is enabled (we can send pause frames
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
     *          frames but we do not receive pause frames).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
     *      3:  Both Rx and TX flow control (symmetric) is enabled.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
     *  other:  No other values should be possible at this point.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
    switch (hw->fc) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
    case e1000_fc_none:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
        ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
    case e1000_fc_rx_pause:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
        ctrl &= (~E1000_CTRL_TFCE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
        ctrl |= E1000_CTRL_RFCE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
    case e1000_fc_tx_pause:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
        ctrl &= (~E1000_CTRL_RFCE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
        ctrl |= E1000_CTRL_TFCE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
    case e1000_fc_full:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
        ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
        DEBUGOUT("Flow control param set incorrectly\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
        return -E1000_ERR_CONFIG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
    /* Disable TX Flow Control for 82542 (rev 2.0) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
    if(hw->mac_type == e1000_82542_rev2_0)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
        ctrl &= (~E1000_CTRL_TFCE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
    E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
 * Configures flow control settings after link is established
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
 * Should be called immediately after a valid link has been established.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
 * Forces MAC flow control settings if link was forced. When in MII/GMII mode
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
 * and autonegotiation is enabled, the MAC flow control settings will be set
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
 * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
 * and RFCE bits will be automaticaly set to the negotiated flow control mode.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
e1000_config_fc_after_link_up(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
    uint16_t mii_status_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
    uint16_t mii_nway_adv_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
    uint16_t mii_nway_lp_ability_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
    uint16_t speed;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
    uint16_t duplex;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
    DEBUGFUNC("e1000_config_fc_after_link_up");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
    /* Check for the case where we have fiber media and auto-neg failed
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
     * so we had to force link.  In this case, we need to force the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
     * configuration of the MAC to match the "fc" parameter.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
    if(((hw->media_type == e1000_media_type_fiber) && (hw->autoneg_failed)) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
       ((hw->media_type == e1000_media_type_internal_serdes) && (hw->autoneg_failed)) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
       ((hw->media_type == e1000_media_type_copper) && (!hw->autoneg))) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
        ret_val = e1000_force_mac_fc(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
            DEBUGOUT("Error forcing flow control settings\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
    /* Check for the case where we have copper media and auto-neg is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
     * enabled.  In this case, we need to check and see if Auto-Neg
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
     * has completed, and if so, how the PHY and link partner has
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
     * flow control configured.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
    if((hw->media_type == e1000_media_type_copper) && hw->autoneg) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
        /* Read the MII Status Register and check to see if AutoNeg
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
         * has completed.  We read this twice because this reg has
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
         * some "sticky" (latched) bits.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
        if(mii_status_reg & MII_SR_AUTONEG_COMPLETE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
            /* The AutoNeg process has completed, so we now need to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
             * read both the Auto Negotiation Advertisement Register
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
             * (Address 4) and the Auto_Negotiation Base Page Ability
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
             * Register (Address 5) to determine how flow control was
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
             * negotiated.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
            ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
                                         &mii_nway_adv_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
            ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
                                         &mii_nway_lp_ability_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
            /* Two bits in the Auto Negotiation Advertisement Register
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
             * (Address 4) and two bits in the Auto Negotiation Base
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
             * Page Ability Register (Address 5) determine flow control
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
             * for both the PHY and the link partner.  The following
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
             * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
             * 1999, describes these PAUSE resolution bits and how flow
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
             * control is determined based upon these settings.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
             * NOTE:  DC = Don't Care
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
             *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
             *   LOCAL DEVICE  |   LINK PARTNER
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
             * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
             *-------|---------|-------|---------|--------------------
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
             *   0   |    0    |  DC   |   DC    | e1000_fc_none
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
             *   0   |    1    |   0   |   DC    | e1000_fc_none
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
             *   0   |    1    |   1   |    0    | e1000_fc_none
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
             *   0   |    1    |   1   |    1    | e1000_fc_tx_pause
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
             *   1   |    0    |   0   |   DC    | e1000_fc_none
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
             *   1   |   DC    |   1   |   DC    | e1000_fc_full
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
             *   1   |    1    |   0   |    0    | e1000_fc_none
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
             *   1   |    1    |   0   |    1    | e1000_fc_rx_pause
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
             *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
            /* Are both PAUSE bits set to 1?  If so, this implies
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
             * Symmetric Flow Control is enabled at both ends.  The
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
             * ASM_DIR bits are irrelevant per the spec.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
             *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
             * For Symmetric Flow Control:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
             *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
             *   LOCAL DEVICE  |   LINK PARTNER
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
             * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
             *-------|---------|-------|---------|--------------------
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
             *   1   |   DC    |   1   |   DC    | e1000_fc_full
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
             *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
            if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
               (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
                /* Now we need to check if the user selected RX ONLY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
                 * of pause frames.  In this case, we had to advertise
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
                 * FULL flow control because we could not advertise RX
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
                 * ONLY. Hence, we must now check to see if we need to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
                 * turn OFF  the TRANSMISSION of PAUSE frames.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
                 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
                if(hw->original_fc == e1000_fc_full) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
                    hw->fc = e1000_fc_full;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
                    DEBUGOUT("Flow Control = FULL.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
                } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
                    hw->fc = e1000_fc_rx_pause;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
                    DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
                }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
            /* For receiving PAUSE frames ONLY.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
             *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
             *   LOCAL DEVICE  |   LINK PARTNER
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
             * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
             *-------|---------|-------|---------|--------------------
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
             *   0   |    1    |   1   |    1    | e1000_fc_tx_pause
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
             *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
            else if(!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
                    (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
                    (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
                    (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
                hw->fc = e1000_fc_tx_pause;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
                DEBUGOUT("Flow Control = TX PAUSE frames only.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
            /* For transmitting PAUSE frames ONLY.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
             *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
             *   LOCAL DEVICE  |   LINK PARTNER
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
             * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
             *-------|---------|-------|---------|--------------------
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
             *   1   |    1    |   0   |    1    | e1000_fc_rx_pause
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
             *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
            else if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
                    (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
                    !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
                    (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
                hw->fc = e1000_fc_rx_pause;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
                DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
            /* Per the IEEE spec, at this point flow control should be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
             * disabled.  However, we want to consider that we could
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
             * be connected to a legacy switch that doesn't advertise
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
             * desired flow control, but can be forced on the link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
             * partner.  So if we advertised no flow control, that is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
             * what we will resolve to.  If we advertised some kind of
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
             * receive capability (Rx Pause Only or Full Flow Control)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
             * and the link partner advertised none, we will configure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
             * ourselves to enable Rx Flow Control only.  We can do
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
             * this safely for two reasons:  If the link partner really
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
             * didn't want flow control enabled, and we enable Rx, no
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
             * harm done since we won't be receiving any PAUSE frames
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
             * anyway.  If the intent on the link partner was to have
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
             * flow control enabled, then by us enabling RX only, we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
             * can at least receive pause frames and process them.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
             * This is a good idea because in most cases, since we are
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
             * predominantly a server NIC, more times than not we will
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
             * be asked to delay transmission of packets than asking
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
             * our link partner to pause transmission of frames.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
            else if((hw->original_fc == e1000_fc_none ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
                     hw->original_fc == e1000_fc_tx_pause) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
                    hw->fc_strict_ieee) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
                hw->fc = e1000_fc_none;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
                DEBUGOUT("Flow Control = NONE.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
                hw->fc = e1000_fc_rx_pause;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
                DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
            /* Now we need to do one last check...  If we auto-
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
             * negotiated to HALF DUPLEX, flow control should not be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
             * enabled per IEEE 802.3 spec.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
            ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
            if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
                DEBUGOUT("Error getting link speed and duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
            if(duplex == HALF_DUPLEX)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
                hw->fc = e1000_fc_none;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
            /* Now we call a subroutine to actually force the MAC
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
             * controller to use the correct flow control settings.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
            ret_val = e1000_force_mac_fc(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
            if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
                DEBUGOUT("Error forcing flow control settings\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
            DEBUGOUT("Copper PHY and Auto Neg has not completed.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
 * Checks to see if the link status of the hardware has changed.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
 * Called by any function that needs to check the link status of the adapter.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
e1000_check_for_link(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
    uint32_t rxcw = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
    uint32_t status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
    uint32_t rctl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
    uint32_t icr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
    uint32_t signal = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
    DEBUGFUNC("e1000_check_for_link");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
    status = E1000_READ_REG(hw, STATUS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
    /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
     * set when the optics detect a signal. On older adapters, it will be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
     * cleared when there is a signal.  This applies to fiber media only.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
    if((hw->media_type == e1000_media_type_fiber) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
       (hw->media_type == e1000_media_type_internal_serdes)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
        rxcw = E1000_READ_REG(hw, RXCW);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
        if(hw->media_type == e1000_media_type_fiber) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
            signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
            if(status & E1000_STATUS_LU)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
                hw->get_link_status = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
    /* If we have a copper PHY then we only want to go out to the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
     * registers to see if Auto-Neg has completed and/or if our link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
     * status has changed.  The get_link_status flag will be set if we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
     * receive a Link Status Change interrupt or we have Rx Sequence
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
     * Errors.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
    if((hw->media_type == e1000_media_type_copper) && hw->get_link_status) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
        /* First we want to see if the MII Status Register reports
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
         * link.  If so, then we want to get the current speed/duplex
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
         * of the PHY.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
         * Read the register twice since the link bit is sticky.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
        if(phy_data & MII_SR_LINK_STATUS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
            hw->get_link_status = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
            /* Check if there was DownShift, must be checked immediately after
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
             * link-up */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
            e1000_check_downshift(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
            /* If we are on 82544 or 82543 silicon and speed/duplex
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
             * are forced to 10H or 10F, then we will implement the polarity
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
             * reversal workaround.  We disable interrupts first, and upon
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
             * returning, place the devices interrupt state to its previous
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
             * value except for the link status change interrupt which will
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
             * happen due to the execution of this workaround.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
            if((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
               (!hw->autoneg) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
               (hw->forced_speed_duplex == e1000_10_full ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
                hw->forced_speed_duplex == e1000_10_half)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
                E1000_WRITE_REG(hw, IMC, 0xffffffff);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
                ret_val = e1000_polarity_reversal_workaround(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
                icr = E1000_READ_REG(hw, ICR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
                E1000_WRITE_REG(hw, ICS, (icr & ~E1000_ICS_LSC));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
                E1000_WRITE_REG(hw, IMS, IMS_ENABLE_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
            /* No link detected */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
            e1000_config_dsp_after_link_change(hw, FALSE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
            return 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
        /* If we are forcing speed/duplex, then we simply return since
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
         * we have already determined whether we have link or not.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
        if(!hw->autoneg) return -E1000_ERR_CONFIG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
        /* optimize the dsp settings for the igp phy */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
        e1000_config_dsp_after_link_change(hw, TRUE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
        /* We have a M88E1000 PHY and Auto-Neg is enabled.  If we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
         * have Si on board that is 82544 or newer, Auto
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
         * Speed Detection takes care of MAC speed/duplex
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
         * configuration.  So we only need to configure Collision
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
         * Distance in the MAC.  Otherwise, we need to force
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
         * speed/duplex on the MAC to the current PHY speed/duplex
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
         * settings.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
        if(hw->mac_type >= e1000_82544)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
            e1000_config_collision_dist(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
        else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
            ret_val = e1000_config_mac_to_phy(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
            if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
                DEBUGOUT("Error configuring MAC to PHY settings\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
        /* Configure Flow Control now that Auto-Neg has completed. First, we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
         * need to restore the desired flow control settings because we may
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
         * have had to re-autoneg with a different link partner.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
        ret_val = e1000_config_fc_after_link_up(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
            DEBUGOUT("Error configuring flow control\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
        /* At this point we know that we are on copper and we have
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
         * auto-negotiated link.  These are conditions for checking the link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
         * partner capability register.  We use the link speed to determine if
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
         * TBI compatibility needs to be turned on or off.  If the link is not
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
         * at gigabit speed, then TBI compatibility is not needed.  If we are
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
         * at gigabit speed, we turn on TBI compatibility.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
        if(hw->tbi_compatibility_en) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
            uint16_t speed, duplex;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
            ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
            if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
                DEBUGOUT("Error getting link speed and duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
            if (speed != SPEED_1000) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
                /* If link speed is not set to gigabit speed, we do not need
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
                 * to enable TBI compatibility.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
                 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
                if(hw->tbi_compatibility_on) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
                    /* If we previously were in the mode, turn it off. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
                    rctl = E1000_READ_REG(hw, RCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
                    rctl &= ~E1000_RCTL_SBP;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
                    E1000_WRITE_REG(hw, RCTL, rctl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
                    hw->tbi_compatibility_on = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
                }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
                /* If TBI compatibility is was previously off, turn it on. For
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
                 * compatibility with a TBI link partner, we will store bad
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
                 * packets. Some frames have an additional byte on the end and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
                 * will look like CRC errors to to the hardware.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
                 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
                if(!hw->tbi_compatibility_on) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
                    hw->tbi_compatibility_on = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
                    rctl = E1000_READ_REG(hw, RCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
                    rctl |= E1000_RCTL_SBP;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
                    E1000_WRITE_REG(hw, RCTL, rctl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
                }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
    /* If we don't have link (auto-negotiation failed or link partner cannot
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
     * auto-negotiate), the cable is plugged in (we have signal), and our
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
     * link partner is not trying to auto-negotiate with us (we are receiving
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
     * idles or data), we need to force link up. We also need to give
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
     * auto-negotiation time to complete, in case the cable was just plugged
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
     * in. The autoneg_failed flag does this.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
    else if((((hw->media_type == e1000_media_type_fiber) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
              ((ctrl & E1000_CTRL_SWDPIN1) == signal)) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
             (hw->media_type == e1000_media_type_internal_serdes)) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
            (!(status & E1000_STATUS_LU)) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
            (!(rxcw & E1000_RXCW_C))) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
        if(hw->autoneg_failed == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
            hw->autoneg_failed = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
            return 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
        DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
        /* Disable auto-negotiation in the TXCW register */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
        E1000_WRITE_REG(hw, TXCW, (hw->txcw & ~E1000_TXCW_ANE));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
        /* Force link-up and also force full-duplex. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
        ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
        ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
        E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
        /* Configure Flow Control after forcing link up. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
        ret_val = e1000_config_fc_after_link_up(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
            DEBUGOUT("Error configuring flow control\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
    /* If we are forcing link and we are receiving /C/ ordered sets, re-enable
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
     * auto-negotiation in the TXCW register and disable forced link in the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
     * Device Control register in an attempt to auto-negotiate with our link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
     * partner.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
    else if(((hw->media_type == e1000_media_type_fiber) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
             (hw->media_type == e1000_media_type_internal_serdes)) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
            (ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
        DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
        E1000_WRITE_REG(hw, TXCW, hw->txcw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
        E1000_WRITE_REG(hw, CTRL, (ctrl & ~E1000_CTRL_SLU));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
        hw->serdes_link_down = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
    /* If we force link for non-auto-negotiation switch, check link status
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
     * based on MAC synchronization for internal serdes media type.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
    else if((hw->media_type == e1000_media_type_internal_serdes) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
            !(E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
        /* SYNCH bit and IV bit are sticky. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
        udelay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
        if(E1000_RXCW_SYNCH & E1000_READ_REG(hw, RXCW)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
            if(!(rxcw & E1000_RXCW_IV)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
                hw->serdes_link_down = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
                DEBUGOUT("SERDES: Link is up.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
            hw->serdes_link_down = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
            DEBUGOUT("SERDES: Link is down.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
    if((hw->media_type == e1000_media_type_internal_serdes) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
       (E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
        hw->serdes_link_down = !(E1000_STATUS_LU & E1000_READ_REG(hw, STATUS));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
 * Detects the current speed and duplex settings of the hardware.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
 * speed - Speed of the connection
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
 * duplex - Duplex setting of the connection
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
e1000_get_speed_and_duplex(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
                           uint16_t *speed,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
                           uint16_t *duplex)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
    uint32_t status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
    DEBUGFUNC("e1000_get_speed_and_duplex");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
    if(hw->mac_type >= e1000_82543) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
        status = E1000_READ_REG(hw, STATUS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
        if(status & E1000_STATUS_SPEED_1000) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
            *speed = SPEED_1000;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
            DEBUGOUT("1000 Mbs, ");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
        } else if(status & E1000_STATUS_SPEED_100) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
            *speed = SPEED_100;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
            DEBUGOUT("100 Mbs, ");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
            *speed = SPEED_10;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
            DEBUGOUT("10 Mbs, ");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
        if(status & E1000_STATUS_FD) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
            *duplex = FULL_DUPLEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
            DEBUGOUT("Full Duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
            *duplex = HALF_DUPLEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
            DEBUGOUT(" Half Duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
        DEBUGOUT("1000 Mbs, Full Duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
        *speed = SPEED_1000;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
        *duplex = FULL_DUPLEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
    /* IGP01 PHY may advertise full duplex operation after speed downgrade even
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
     * if it is operating at half duplex.  Here we set the duplex settings to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
     * match the duplex in the link partner's capabilities.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
    if(hw->phy_type == e1000_phy_igp && hw->speed_downgraded) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
        ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_EXP, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
        if(!(phy_data & NWAY_ER_LP_NWAY_CAPS))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
            *duplex = HALF_DUPLEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
        else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
            ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
            if((*speed == SPEED_100 && !(phy_data & NWAY_LPAR_100TX_FD_CAPS)) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
               (*speed == SPEED_10 && !(phy_data & NWAY_LPAR_10T_FD_CAPS)))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
                *duplex = HALF_DUPLEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
    if ((hw->mac_type == e1000_80003es2lan) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
        (hw->media_type == e1000_media_type_copper)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
        if (*speed == SPEED_1000)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
            ret_val = e1000_configure_kmrn_for_1000(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
        else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
            ret_val = e1000_configure_kmrn_for_10_100(hw, *duplex);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
    if ((hw->phy_type == e1000_phy_igp_3) && (*speed == SPEED_1000)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
        ret_val = e1000_kumeran_lock_loss_workaround(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
* Blocks until autoneg completes or times out (~4.5 seconds)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
e1000_wait_autoneg(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
    uint16_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
    DEBUGFUNC("e1000_wait_autoneg");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
    DEBUGOUT("Waiting for Auto-Neg to complete.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
    /* We will wait for autoneg to complete or 4.5 seconds to expire. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
    for(i = PHY_AUTO_NEG_TIME; i > 0; i--) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
        /* Read the MII Status Register and wait for Auto-Neg
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
         * Complete bit to be set.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
        if(phy_data & MII_SR_AUTONEG_COMPLETE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
            return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
        msec_delay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
* Raises the Management Data Clock
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
* ctrl - Device control register's current value
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
e1000_raise_mdi_clk(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
                    uint32_t *ctrl)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
    /* Raise the clock input to the Management Data Clock (by setting the MDC
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
     * bit), and then delay 10 microseconds.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
    E1000_WRITE_REG(hw, CTRL, (*ctrl | E1000_CTRL_MDC));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
    udelay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
* Lowers the Management Data Clock
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
* ctrl - Device control register's current value
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
e1000_lower_mdi_clk(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
                    uint32_t *ctrl)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
    /* Lower the clock input to the Management Data Clock (by clearing the MDC
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
     * bit), and then delay 10 microseconds.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
    E1000_WRITE_REG(hw, CTRL, (*ctrl & ~E1000_CTRL_MDC));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
    udelay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
* Shifts data bits out to the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
* data - Data to send out to the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
* count - Number of bits to shift out
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
* Bits are shifted out in MSB to LSB order.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
e1000_shift_out_mdi_bits(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
                         uint32_t data,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
                         uint16_t count)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
    uint32_t mask;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
    /* We need to shift "count" number of bits out to the PHY. So, the value
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
     * in the "data" parameter will be shifted out to the PHY one bit at a
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
     * time. In order to do this, "data" must be broken down into bits.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
    mask = 0x01;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
    mask <<= (count - 1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
    /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
    ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
    while(mask) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
        /* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
         * then raising and lowering the Management Data Clock. A "0" is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
         * shifted out to the PHY by setting the MDIO bit to "0" and then
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
         * raising and lowering the clock.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
        if(data & mask) ctrl |= E1000_CTRL_MDIO;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
        else ctrl &= ~E1000_CTRL_MDIO;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
        E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
        udelay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
        e1000_raise_mdi_clk(hw, &ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
        e1000_lower_mdi_clk(hw, &ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
        mask = mask >> 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
* Shifts data bits in from the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
* Bits are shifted in in MSB to LSB order.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
static uint16_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
e1000_shift_in_mdi_bits(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
    uint16_t data = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
    uint8_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
    /* In order to read a register from the PHY, we need to shift in a total
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
     * of 18 bits from the PHY. The first two bit (turnaround) times are used
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
     * to avoid contention on the MDIO pin when a read operation is performed.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
     * These two bits are ignored by us and thrown away. Bits are "shifted in"
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
     * by raising the input to the Management Data Clock (setting the MDC bit),
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
     * and then reading the value of the MDIO bit.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
    /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
    ctrl &= ~E1000_CTRL_MDIO_DIR;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
    ctrl &= ~E1000_CTRL_MDIO;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
    E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
    /* Raise and Lower the clock before reading in the data. This accounts for
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
     * the turnaround bits. The first clock occurred when we clocked out the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
     * last bit of the Register Address.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
    e1000_raise_mdi_clk(hw, &ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
    e1000_lower_mdi_clk(hw, &ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
    for(data = 0, i = 0; i < 16; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
        data = data << 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
        e1000_raise_mdi_clk(hw, &ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
        ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
        /* Check to see if we shifted in a "1". */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
        if(ctrl & E1000_CTRL_MDIO) data |= 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
        e1000_lower_mdi_clk(hw, &ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
    e1000_raise_mdi_clk(hw, &ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
    e1000_lower_mdi_clk(hw, &ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
    return data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
    uint32_t swfw_sync = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
    uint32_t swmask = mask;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
    uint32_t fwmask = mask << 16;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
    int32_t timeout = 200;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
    DEBUGFUNC("e1000_swfw_sync_acquire");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
    if (hw->swfwhw_semaphore_present)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
        return e1000_get_software_flag(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
    if (!hw->swfw_sync_present)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
        return e1000_get_hw_eeprom_semaphore(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
    while(timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
            if (e1000_get_hw_eeprom_semaphore(hw))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
                return -E1000_ERR_SWFW_SYNC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
            swfw_sync = E1000_READ_REG(hw, SW_FW_SYNC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
            if (!(swfw_sync & (fwmask | swmask))) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
            /* firmware currently using resource (fwmask) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
            /* or other software thread currently using resource (swmask) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
            e1000_put_hw_eeprom_semaphore(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
            msec_delay_irq(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
            timeout--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
    if (!timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
        DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
        return -E1000_ERR_SWFW_SYNC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
    swfw_sync |= swmask;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
    E1000_WRITE_REG(hw, SW_FW_SYNC, swfw_sync);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
    e1000_put_hw_eeprom_semaphore(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
    uint32_t swfw_sync;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
    uint32_t swmask = mask;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
    DEBUGFUNC("e1000_swfw_sync_release");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
    if (hw->swfwhw_semaphore_present) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
        e1000_release_software_flag(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
        return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
    if (!hw->swfw_sync_present) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
        e1000_put_hw_eeprom_semaphore(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
        return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
    /* if (e1000_get_hw_eeprom_semaphore(hw))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
     *    return -E1000_ERR_SWFW_SYNC; */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
    while (e1000_get_hw_eeprom_semaphore(hw) != E1000_SUCCESS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
        /* empty */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
    swfw_sync = E1000_READ_REG(hw, SW_FW_SYNC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
    swfw_sync &= ~swmask;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
    E1000_WRITE_REG(hw, SW_FW_SYNC, swfw_sync);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
    e1000_put_hw_eeprom_semaphore(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
* Reads the value from a PHY register, if the value is on a specific non zero
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
* page, sets the page first.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
* reg_addr - address of the PHY register to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
e1000_read_phy_reg(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
                   uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
                   uint16_t *phy_data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
    uint32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
    uint16_t swfw;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
    DEBUGFUNC("e1000_read_phy_reg");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
    if ((hw->mac_type == e1000_80003es2lan) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
        (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
        swfw = E1000_SWFW_PHY1_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
        swfw = E1000_SWFW_PHY0_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
    if (e1000_swfw_sync_acquire(hw, swfw))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
        return -E1000_ERR_SWFW_SYNC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
    if ((hw->phy_type == e1000_phy_igp ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
        hw->phy_type == e1000_phy_igp_3 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
        hw->phy_type == e1000_phy_igp_2) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
       (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
        ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
                                         (uint16_t)reg_addr);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
            e1000_swfw_sync_release(hw, swfw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
    } else if (hw->phy_type == e1000_phy_gg82563) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
        if (((reg_addr & MAX_PHY_REG_ADDRESS) > MAX_PHY_MULTI_PAGE_REG) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
            (hw->mac_type == e1000_80003es2lan)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
            /* Select Configuration Page */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
            if ((reg_addr & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
                ret_val = e1000_write_phy_reg_ex(hw, GG82563_PHY_PAGE_SELECT,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
                          (uint16_t)((uint16_t)reg_addr >> GG82563_PAGE_SHIFT));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
                /* Use Alternative Page Select register to access
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
                 * registers 30 and 31
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
                 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
                ret_val = e1000_write_phy_reg_ex(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
                                                 GG82563_PHY_PAGE_SELECT_ALT,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
                          (uint16_t)((uint16_t)reg_addr >> GG82563_PAGE_SHIFT));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
            if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
                e1000_swfw_sync_release(hw, swfw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
    ret_val = e1000_read_phy_reg_ex(hw, MAX_PHY_REG_ADDRESS & reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
                                    phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
    e1000_swfw_sync_release(hw, swfw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
e1000_read_phy_reg_ex(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
                      uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
                      uint16_t *phy_data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
    uint32_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
    uint32_t mdic = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
    const uint32_t phy_addr = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
    DEBUGFUNC("e1000_read_phy_reg_ex");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
    if(reg_addr > MAX_PHY_REG_ADDRESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
        DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
        return -E1000_ERR_PARAM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
    if(hw->mac_type > e1000_82543) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
        /* Set up Op-code, Phy Address, and register address in the MDI
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
         * Control register.  The MAC will take care of interfacing with the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
         * PHY to retrieve the desired data.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
        mdic = ((reg_addr << E1000_MDIC_REG_SHIFT) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
                (phy_addr << E1000_MDIC_PHY_SHIFT) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
                (E1000_MDIC_OP_READ));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
        E1000_WRITE_REG(hw, MDIC, mdic);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
        /* Poll the ready bit to see if the MDI read completed */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
        for(i = 0; i < 64; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
            udelay(50);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
            mdic = E1000_READ_REG(hw, MDIC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
            if(mdic & E1000_MDIC_READY) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
        if(!(mdic & E1000_MDIC_READY)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
            DEBUGOUT("MDI Read did not complete\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
            return -E1000_ERR_PHY;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
        if(mdic & E1000_MDIC_ERROR) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
            DEBUGOUT("MDI Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
            return -E1000_ERR_PHY;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
        *phy_data = (uint16_t) mdic;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
        /* We must first send a preamble through the MDIO pin to signal the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
         * beginning of an MII instruction.  This is done by sending 32
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
         * consecutive "1" bits.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
        e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
        /* Now combine the next few fields that are required for a read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
         * operation.  We use this method instead of calling the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
         * e1000_shift_out_mdi_bits routine five different times. The format of
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
         * a MII read instruction consists of a shift out of 14 bits and is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
         * defined as follows:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
         *    <Preamble><SOF><Op Code><Phy Addr><Reg Addr>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
         * followed by a shift in of 18 bits.  This first two bits shifted in
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
         * are TurnAround bits used to avoid contention on the MDIO pin when a
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
         * READ operation is performed.  These two bits are thrown away
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
         * followed by a shift in of 16 bits which contains the desired data.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
        mdic = ((reg_addr) | (phy_addr << 5) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
                (PHY_OP_READ << 10) | (PHY_SOF << 12));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
        e1000_shift_out_mdi_bits(hw, mdic, 14);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
        /* Now that we've shifted out the read command to the MII, we need to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
         * "shift in" the 16-bit value (18 total bits) of the requested PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
         * register address.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
        *phy_data = e1000_shift_in_mdi_bits(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
* Writes a value to a PHY register
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
* reg_addr - address of the PHY register to write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
* data - data to write to the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
e1000_write_phy_reg(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
                    uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
                    uint16_t phy_data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
    uint32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
    uint16_t swfw;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
    DEBUGFUNC("e1000_write_phy_reg");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
    if ((hw->mac_type == e1000_80003es2lan) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
        (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
        swfw = E1000_SWFW_PHY1_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
        swfw = E1000_SWFW_PHY0_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
    if (e1000_swfw_sync_acquire(hw, swfw))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
        return -E1000_ERR_SWFW_SYNC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
    if ((hw->phy_type == e1000_phy_igp ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
        hw->phy_type == e1000_phy_igp_3 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
        hw->phy_type == e1000_phy_igp_2) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
       (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
        ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
                                         (uint16_t)reg_addr);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
            e1000_swfw_sync_release(hw, swfw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
    } else if (hw->phy_type == e1000_phy_gg82563) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
        if (((reg_addr & MAX_PHY_REG_ADDRESS) > MAX_PHY_MULTI_PAGE_REG) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
            (hw->mac_type == e1000_80003es2lan)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
            /* Select Configuration Page */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
            if ((reg_addr & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
                ret_val = e1000_write_phy_reg_ex(hw, GG82563_PHY_PAGE_SELECT,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
                          (uint16_t)((uint16_t)reg_addr >> GG82563_PAGE_SHIFT));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
                /* Use Alternative Page Select register to access
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
                 * registers 30 and 31
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
                 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
                ret_val = e1000_write_phy_reg_ex(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
                                                 GG82563_PHY_PAGE_SELECT_ALT,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
                          (uint16_t)((uint16_t)reg_addr >> GG82563_PAGE_SHIFT));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
            if (ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
                e1000_swfw_sync_release(hw, swfw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
    ret_val = e1000_write_phy_reg_ex(hw, MAX_PHY_REG_ADDRESS & reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
                                     phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
    e1000_swfw_sync_release(hw, swfw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
e1000_write_phy_reg_ex(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
                    uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
                    uint16_t phy_data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
    uint32_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
    uint32_t mdic = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
    const uint32_t phy_addr = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
    DEBUGFUNC("e1000_write_phy_reg_ex");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
    if(reg_addr > MAX_PHY_REG_ADDRESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
        DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
        return -E1000_ERR_PARAM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
    if(hw->mac_type > e1000_82543) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
        /* Set up Op-code, Phy Address, register address, and data intended
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
         * for the PHY register in the MDI Control register.  The MAC will take
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
         * care of interfacing with the PHY to send the desired data.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
        mdic = (((uint32_t) phy_data) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
                (reg_addr << E1000_MDIC_REG_SHIFT) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
                (phy_addr << E1000_MDIC_PHY_SHIFT) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
                (E1000_MDIC_OP_WRITE));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
        E1000_WRITE_REG(hw, MDIC, mdic);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
        /* Poll the ready bit to see if the MDI read completed */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
        for(i = 0; i < 640; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
            udelay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
            mdic = E1000_READ_REG(hw, MDIC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
            if(mdic & E1000_MDIC_READY) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
        if(!(mdic & E1000_MDIC_READY)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
            DEBUGOUT("MDI Write did not complete\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
            return -E1000_ERR_PHY;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
        /* We'll need to use the SW defined pins to shift the write command
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
         * out to the PHY. We first send a preamble to the PHY to signal the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
         * beginning of the MII instruction.  This is done by sending 32
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
         * consecutive "1" bits.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
        e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
        /* Now combine the remaining required fields that will indicate a
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
         * write operation. We use this method instead of calling the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
         * e1000_shift_out_mdi_bits routine for each field in the command. The
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
         * format of a MII write instruction is as follows:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
         * <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
        mdic = ((PHY_TURNAROUND) | (reg_addr << 2) | (phy_addr << 7) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
                (PHY_OP_WRITE << 12) | (PHY_SOF << 14));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
        mdic <<= 16;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
        mdic |= (uint32_t) phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
        e1000_shift_out_mdi_bits(hw, mdic, 32);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
e1000_read_kmrn_reg(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
                    uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
                    uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
    uint32_t reg_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
    uint16_t swfw;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
    DEBUGFUNC("e1000_read_kmrn_reg");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
    if ((hw->mac_type == e1000_80003es2lan) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
        (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
        swfw = E1000_SWFW_PHY1_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
        swfw = E1000_SWFW_PHY0_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
    if (e1000_swfw_sync_acquire(hw, swfw))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
        return -E1000_ERR_SWFW_SYNC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
    /* Write register address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
    reg_val = ((reg_addr << E1000_KUMCTRLSTA_OFFSET_SHIFT) &
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
              E1000_KUMCTRLSTA_OFFSET) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
              E1000_KUMCTRLSTA_REN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
    E1000_WRITE_REG(hw, KUMCTRLSTA, reg_val);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
    udelay(2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
    /* Read the data returned */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
    reg_val = E1000_READ_REG(hw, KUMCTRLSTA);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
    *data = (uint16_t)reg_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
    e1000_swfw_sync_release(hw, swfw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
e1000_write_kmrn_reg(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
                     uint32_t reg_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
                     uint16_t data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
    uint32_t reg_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
    uint16_t swfw;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
    DEBUGFUNC("e1000_write_kmrn_reg");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
    if ((hw->mac_type == e1000_80003es2lan) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
        (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
        swfw = E1000_SWFW_PHY1_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
        swfw = E1000_SWFW_PHY0_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
    if (e1000_swfw_sync_acquire(hw, swfw))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
        return -E1000_ERR_SWFW_SYNC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
    reg_val = ((reg_addr << E1000_KUMCTRLSTA_OFFSET_SHIFT) &
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
              E1000_KUMCTRLSTA_OFFSET) | data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
    E1000_WRITE_REG(hw, KUMCTRLSTA, reg_val);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
    udelay(2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
    e1000_swfw_sync_release(hw, swfw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
* Returns the PHY to the power-on reset state
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
e1000_phy_hw_reset(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
    uint32_t ctrl, ctrl_ext;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
    uint32_t led_ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
    uint16_t swfw;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
    DEBUGFUNC("e1000_phy_hw_reset");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
    /* In the case of the phy reset being blocked, it's not an error, we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
     * simply return success without performing the reset. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
    ret_val = e1000_check_phy_reset_block(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
    DEBUGOUT("Resetting Phy...\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
    if(hw->mac_type > e1000_82543) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
        if ((hw->mac_type == e1000_80003es2lan) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
            (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
            swfw = E1000_SWFW_PHY1_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
            swfw = E1000_SWFW_PHY0_SM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
        if (e1000_swfw_sync_acquire(hw, swfw)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
            e1000_release_software_semaphore(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
            return -E1000_ERR_SWFW_SYNC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
        /* Read the device control register and assert the E1000_CTRL_PHY_RST
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
         * bit. Then, take it out of reset.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
         * For pre-e1000_82571 hardware, we delay for 10ms between the assert
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
         * and deassert.  For e1000_82571 hardware and later, we instead delay
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
         * for 50us between and 10ms after the deassertion.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
        ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
        E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
        if (hw->mac_type < e1000_82571)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
            msec_delay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
        else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
            udelay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
        E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
        if (hw->mac_type >= e1000_82571)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
            msec_delay_irq(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
        e1000_swfw_sync_release(hw, swfw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
        /* Read the Extended Device Control Register, assert the PHY_RESET_DIR
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
         * bit to put the PHY into reset. Then, take it out of reset.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
        ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
        ctrl_ext |= E1000_CTRL_EXT_SDP4_DIR;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
        ctrl_ext &= ~E1000_CTRL_EXT_SDP4_DATA;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
        msec_delay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
        ctrl_ext |= E1000_CTRL_EXT_SDP4_DATA;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
    udelay(150);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
    if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
        /* Configure activity LED after PHY reset */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
        led_ctrl = E1000_READ_REG(hw, LEDCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
        led_ctrl &= IGP_ACTIVITY_LED_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
        led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
        E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
    /* Wait for FW to finish PHY configuration. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
    ret_val = e1000_get_phy_cfg_done(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
    e1000_release_software_semaphore(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
        if ((hw->mac_type == e1000_ich8lan) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
            (hw->phy_type == e1000_phy_igp_3)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
            ret_val = e1000_init_lcd_from_nvm(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
* Resets the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
* Sets bit 15 of the MII Control regiser
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
e1000_phy_reset(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
    DEBUGFUNC("e1000_phy_reset");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
    /* In the case of the phy reset being blocked, it's not an error, we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
     * simply return success without performing the reset. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
    ret_val = e1000_check_phy_reset_block(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
    case e1000_82541_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
    case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
    case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
        ret_val = e1000_phy_hw_reset(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
        ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
        phy_data |= MII_CR_RESET;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
        ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
        udelay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
    if(hw->phy_type == e1000_phy_igp || hw->phy_type == e1000_phy_igp_2)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
        e1000_phy_init_script(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
* Work-around for 82566 power-down: on D3 entry-
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
* 1) disable gigabit link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
* 2) write VR power-down enable
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
* 3) read it back
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
* if successful continue, else issue LCD reset and repeat
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
* hw - struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
e1000_phy_powerdown_workaround(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
    int32_t reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
    int32_t retry = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
    DEBUGFUNC("e1000_phy_powerdown_workaround");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
    if (hw->phy_type != e1000_phy_igp_3)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
        return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
    do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
        /* Disable link */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
        reg = E1000_READ_REG(hw, PHY_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
        E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
                        E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
        /* Write VR power-down enable */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
        e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
        e1000_write_phy_reg(hw, IGP3_VR_CTRL, phy_data |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
                            IGP3_VR_CTRL_MODE_SHUT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
        /* Read it back and test */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
        e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
        if ((phy_data & IGP3_VR_CTRL_MODE_SHUT) || retry)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
        /* Issue PHY reset and repeat at most one more time */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
        reg = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
        E1000_WRITE_REG(hw, CTRL, reg | E1000_CTRL_PHY_RST);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
        retry++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
    } while (retry);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
    return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
* Work-around for 82566 Kumeran PCS lock loss:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
* On link status change (i.e. PCI reset, speed change) and link is up and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
* speed is gigabit-
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
* 0) if workaround is optionally disabled do nothing
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
* 1) wait 1ms for Kumeran link to come up
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
* 2) check Kumeran Diagnostic register PCS lock loss bit
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
* 3) if not set the link is locked (all is good), otherwise...
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
* 4) reset the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
* 5) repeat up to 10 times
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
* Note: this is only called for IGP3 copper when speed is 1gb.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
* hw - struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
e1000_kumeran_lock_loss_workaround(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
    int32_t reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
    int32_t cnt;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
    if (hw->kmrn_lock_loss_workaround_disabled)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
    /* Make sure link is up before proceeding. If not just return.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
     * Attempting this while link is negotiating fouls up link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
     * stability */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
    ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
    ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
    if (phy_data & MII_SR_LINK_STATUS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
        for (cnt = 0; cnt < 10; cnt++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
            /* read once to clear */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
            ret_val = e1000_read_phy_reg(hw, IGP3_KMRN_DIAG, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
            /* and again to get new status */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
            ret_val = e1000_read_phy_reg(hw, IGP3_KMRN_DIAG, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
            /* check for PCS lock */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
            if (!(phy_data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
                return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
            /* Issue PHY reset */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
            e1000_phy_hw_reset(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
            msec_delay_irq(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
        /* Disable GigE link negotiation */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
        reg = E1000_READ_REG(hw, PHY_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
        E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
                        E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
        /* unable to acquire PCS lock */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
        return E1000_ERR_PHY;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
* Probes the expected PHY address for known PHY IDs
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
e1000_detect_gig_phy(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
    int32_t phy_init_status, ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
    uint16_t phy_id_high, phy_id_low;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
    boolean_t match = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
    DEBUGFUNC("e1000_detect_gig_phy");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
    /* The 82571 firmware may still be configuring the PHY.  In this
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
     * case, we cannot access the PHY until the configuration is done.  So
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
     * we explicitly set the PHY values. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
    if (hw->mac_type == e1000_82571 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
        hw->mac_type == e1000_82572) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
        hw->phy_id = IGP01E1000_I_PHY_ID;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
        hw->phy_type = e1000_phy_igp_2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
    /* ESB-2 PHY reads require e1000_phy_gg82563 to be set because of a work-
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
     * around that forces PHY page 0 to be set or the reads fail.  The rest of
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
     * the code in this routine uses e1000_read_phy_reg to read the PHY ID.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
     * So for ESB-2 we need to have this set so our reads won't fail.  If the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
     * attached PHY is not a e1000_phy_gg82563, the routines below will figure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
     * this out as well. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
    if (hw->mac_type == e1000_80003es2lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
        hw->phy_type = e1000_phy_gg82563;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
    /* Read the PHY ID Registers to identify which PHY is onboard. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
    ret_val = e1000_read_phy_reg(hw, PHY_ID1, &phy_id_high);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
    hw->phy_id = (uint32_t) (phy_id_high << 16);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
    udelay(20);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
    ret_val = e1000_read_phy_reg(hw, PHY_ID2, &phy_id_low);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
    hw->phy_id |= (uint32_t) (phy_id_low & PHY_REVISION_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
    hw->phy_revision = (uint32_t) phy_id_low & ~PHY_REVISION_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
    case e1000_82543:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
        if(hw->phy_id == M88E1000_E_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
    case e1000_82544:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
        if(hw->phy_id == M88E1000_I_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
    case e1000_82540:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
    case e1000_82545:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
    case e1000_82545_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
    case e1000_82546:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
    case e1000_82546_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
        if(hw->phy_id == M88E1011_I_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
    case e1000_82541:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
    case e1000_82541_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
    case e1000_82547:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
    case e1000_82547_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
        if(hw->phy_id == IGP01E1000_I_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
    case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
        if(hw->phy_id == M88E1111_I_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
        if (hw->phy_id == GG82563_E_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
    case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
        if (hw->phy_id == IGP03E1000_E_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
        if (hw->phy_id == IFE_E_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
        if (hw->phy_id == IFE_PLUS_E_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
        if (hw->phy_id == IFE_C_E_PHY_ID) match = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
        DEBUGOUT1("Invalid MAC type %d\n", hw->mac_type);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
        return -E1000_ERR_CONFIG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
    phy_init_status = e1000_set_phy_type(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
    if ((match) && (phy_init_status == E1000_SUCCESS)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
        DEBUGOUT1("PHY ID 0x%X detected\n", hw->phy_id);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
    DEBUGOUT1("Invalid PHY ID 0x%X\n", hw->phy_id);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
    return -E1000_ERR_PHY;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
* Resets the PHY's DSP
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
e1000_phy_reset_dsp(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4018
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
    DEBUGFUNC("e1000_phy_reset_dsp");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4020
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
    do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
        if (hw->phy_type != e1000_phy_gg82563) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
            ret_val = e1000_write_phy_reg(hw, 29, 0x001d);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
            if(ret_val) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
        ret_val = e1000_write_phy_reg(hw, 30, 0x00c1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
        if(ret_val) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
        ret_val = e1000_write_phy_reg(hw, 30, 0x0000);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
        if(ret_val) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
        ret_val = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
    } while(0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4034
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4035
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
* Get PHY information from various PHY registers for igp PHY only.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
* phy_info - PHY information structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
e1000_phy_igp_get_info(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
                       struct e1000_phy_info *phy_info)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
    uint16_t phy_data, polarity, min_length, max_length, average;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
    DEBUGFUNC("e1000_phy_igp_get_info");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4050
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4051
    /* The downshift status is checked only once, after link is established,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
     * and it stored in the hw->speed_downgraded parameter. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
    phy_info->downshift = (e1000_downshift)hw->speed_downgraded;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
    /* IGP01E1000 does not need to support it. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
    phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
    /* IGP01E1000 always correct polarity reversal */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
    phy_info->polarity_correction = e1000_polarity_reversal_enabled;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4060
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
    /* Check polarity status */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
    ret_val = e1000_check_polarity(hw, &polarity);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4063
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4066
    phy_info->cable_polarity = polarity;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4068
    ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
    phy_info->mdix_mode = (phy_data & IGP01E1000_PSSR_MDIX) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
                          IGP01E1000_PSSR_MDIX_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
    if((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
       IGP01E1000_PSSR_SPEED_1000MBPS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
        /* Local/Remote Receiver Information are only valid at 1000 Mbps */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
        ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
        phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
                             SR_1000T_LOCAL_RX_STATUS_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
        phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
                              SR_1000T_REMOTE_RX_STATUS_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
        /* Get cable length */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
        ret_val = e1000_get_cable_length(hw, &min_length, &max_length);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4089
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
        /* Translate to old method */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
        average = (max_length + min_length) / 2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4094
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
        if(average <= e1000_igp_cable_length_50)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
            phy_info->cable_length = e1000_cable_length_50;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
        else if(average <= e1000_igp_cable_length_80)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
            phy_info->cable_length = e1000_cable_length_50_80;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4099
        else if(average <= e1000_igp_cable_length_110)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
            phy_info->cable_length = e1000_cable_length_80_110;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
        else if(average <= e1000_igp_cable_length_140)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
            phy_info->cable_length = e1000_cable_length_110_140;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
        else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
            phy_info->cable_length = e1000_cable_length_140;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
* Get PHY information from various PHY registers for ife PHY only.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4113
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
* phy_info - PHY information structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
e1000_phy_ife_get_info(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
                       struct e1000_phy_info *phy_info)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4121
    uint16_t phy_data, polarity;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
    DEBUGFUNC("e1000_phy_ife_get_info");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
    phy_info->downshift = (e1000_downshift)hw->speed_downgraded;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
    phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
    ret_val = e1000_read_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
    phy_info->polarity_correction =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
                        (phy_data & IFE_PSC_AUTO_POLARITY_DISABLE) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
                        IFE_PSC_AUTO_POLARITY_DISABLE_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
    if (phy_info->polarity_correction == e1000_polarity_reversal_enabled) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
        ret_val = e1000_check_polarity(hw, &polarity);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
        /* Polarity is forced. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
        polarity = (phy_data & IFE_PSC_FORCE_POLARITY) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
                       IFE_PSC_FORCE_POLARITY_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
    phy_info->cable_polarity = polarity;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
    ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
    phy_info->mdix_mode =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
                     (phy_data & (IFE_PMC_AUTO_MDIX | IFE_PMC_FORCE_MDIX)) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
                     IFE_PMC_MDIX_MODE_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
* Get PHY information from various PHY registers fot m88 PHY only.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
* phy_info - PHY information structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
e1000_phy_m88_get_info(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
                       struct e1000_phy_info *phy_info)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
    uint16_t phy_data, polarity;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4169
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
    DEBUGFUNC("e1000_phy_m88_get_info");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
    /* The downshift status is checked only once, after link is established,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
     * and it stored in the hw->speed_downgraded parameter. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
    phy_info->downshift = (e1000_downshift)hw->speed_downgraded;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4179
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
    phy_info->extended_10bt_distance =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
        (phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
        M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
    phy_info->polarity_correction =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
        (phy_data & M88E1000_PSCR_POLARITY_REVERSAL) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
        M88E1000_PSCR_POLARITY_REVERSAL_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4186
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
    /* Check polarity status */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
    ret_val = e1000_check_polarity(hw, &polarity);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
    phy_info->cable_polarity = polarity;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4192
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4193
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4194
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4195
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
    phy_info->mdix_mode = (phy_data & M88E1000_PSSR_MDIX) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
                          M88E1000_PSSR_MDIX_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4200
    if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4201
        /* Cable Length Estimation and Local/Remote Receiver Information
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
         * are only valid at 1000 Mbps.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4204
        if (hw->phy_type != e1000_phy_gg82563) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
            phy_info->cable_length = ((phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
                                      M88E1000_PSSR_CABLE_LENGTH_SHIFT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
            ret_val = e1000_read_phy_reg(hw, GG82563_PHY_DSP_DISTANCE,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4209
                                         &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4213
            phy_info->cable_length = phy_data & GG82563_DSPD_CABLE_LENGTH;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
        ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
        phy_info->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4221
                             SR_1000T_LOCAL_RX_STATUS_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
        phy_info->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4224
                              SR_1000T_REMOTE_RX_STATUS_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4225
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4226
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4227
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4228
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4229
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4231
* Get PHY information from various PHY registers
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4234
* phy_info - PHY information structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4235
******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4236
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
e1000_phy_get_info(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
                   struct e1000_phy_info *phy_info)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4241
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4242
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4243
    DEBUGFUNC("e1000_phy_get_info");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
    phy_info->cable_length = e1000_cable_length_undefined;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
    phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_undefined;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
    phy_info->cable_polarity = e1000_rev_polarity_undefined;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
    phy_info->downshift = e1000_downshift_undefined;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
    phy_info->polarity_correction = e1000_polarity_reversal_undefined;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
    phy_info->mdix_mode = e1000_auto_x_mode_undefined;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
    phy_info->local_rx = e1000_1000t_rx_status_undefined;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4252
    phy_info->remote_rx = e1000_1000t_rx_status_undefined;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
    if(hw->media_type != e1000_media_type_copper) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
        DEBUGOUT("PHY info is only valid for copper media\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4256
        return -E1000_ERR_CONFIG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4259
    ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4260
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4262
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4263
    ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4264
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4265
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4266
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4267
    if((phy_data & MII_SR_LINK_STATUS) != MII_SR_LINK_STATUS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4268
        DEBUGOUT("PHY info is only valid if link is up\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4269
        return -E1000_ERR_CONFIG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4270
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
    if (hw->phy_type == e1000_phy_igp ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
        hw->phy_type == e1000_phy_igp_3 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
        hw->phy_type == e1000_phy_igp_2)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
        return e1000_phy_igp_get_info(hw, phy_info);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4276
    else if (hw->phy_type == e1000_phy_ife)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4277
        return e1000_phy_ife_get_info(hw, phy_info);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4278
    else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
        return e1000_phy_m88_get_info(hw, phy_info);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4283
e1000_validate_mdi_setting(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4284
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
    DEBUGFUNC("e1000_validate_mdi_settings");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
    if(!hw->autoneg && (hw->mdix == 0 || hw->mdix == 3)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
        DEBUGOUT("Invalid MDI setting detected\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
        hw->mdix = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4290
        return -E1000_ERR_CONFIG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4293
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
 * Sets up eeprom variables in the hw struct.  Must be called after mac_type
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
 * is configured.  Additionally, if this is ICH8, the flash controller GbE
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
 * registers must be mapped, or this will crash.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
e1000_init_eeprom_params(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
    uint32_t eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
    int32_t ret_val = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
    uint16_t eeprom_size;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4311
    DEBUGFUNC("e1000_init_eeprom_params");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4312
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
    case e1000_82542_rev2_0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4315
    case e1000_82542_rev2_1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
    case e1000_82543:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
    case e1000_82544:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4318
        eeprom->type = e1000_eeprom_microwire;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
        eeprom->word_size = 64;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
        eeprom->opcode_bits = 3;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
        eeprom->address_bits = 6;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
        eeprom->delay_usec = 50;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
        eeprom->use_eerd = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
        eeprom->use_eewr = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
    case e1000_82540:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
    case e1000_82545:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
    case e1000_82545_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
    case e1000_82546:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
    case e1000_82546_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
        eeprom->type = e1000_eeprom_microwire;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
        eeprom->opcode_bits = 3;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
        eeprom->delay_usec = 50;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
        if(eecd & E1000_EECD_SIZE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
            eeprom->word_size = 256;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
            eeprom->address_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
            eeprom->word_size = 64;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
            eeprom->address_bits = 6;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
        eeprom->use_eerd = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
        eeprom->use_eewr = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
    case e1000_82541:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
    case e1000_82541_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
    case e1000_82547:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
    case e1000_82547_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
        if (eecd & E1000_EECD_TYPE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
            eeprom->type = e1000_eeprom_spi;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
            eeprom->opcode_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
            eeprom->delay_usec = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
            if (eecd & E1000_EECD_ADDR_BITS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4353
                eeprom->page_size = 32;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
                eeprom->address_bits = 16;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
                eeprom->page_size = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
                eeprom->address_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
            eeprom->type = e1000_eeprom_microwire;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
            eeprom->opcode_bits = 3;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
            eeprom->delay_usec = 50;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
            if (eecd & E1000_EECD_ADDR_BITS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
                eeprom->word_size = 256;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
                eeprom->address_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
                eeprom->word_size = 64;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
                eeprom->address_bits = 6;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4371
        eeprom->use_eerd = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
        eeprom->use_eewr = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4374
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
    case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
        eeprom->type = e1000_eeprom_spi;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
        eeprom->opcode_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
        eeprom->delay_usec = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
        if (eecd & E1000_EECD_ADDR_BITS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
            eeprom->page_size = 32;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
            eeprom->address_bits = 16;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
            eeprom->page_size = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
            eeprom->address_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
        eeprom->use_eerd = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
        eeprom->use_eewr = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
    case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4390
        eeprom->type = e1000_eeprom_spi;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
        eeprom->opcode_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
        eeprom->delay_usec = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
        if (eecd & E1000_EECD_ADDR_BITS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
            eeprom->page_size = 32;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
            eeprom->address_bits = 16;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4396
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
            eeprom->page_size = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
            eeprom->address_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
        eeprom->use_eerd = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
        eeprom->use_eewr = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
        if(e1000_is_onboard_nvm_eeprom(hw) == FALSE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
            eeprom->type = e1000_eeprom_flash;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
            eeprom->word_size = 2048;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
            /* Ensure that the Autonomous FLASH update bit is cleared due to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
             * Flash update issue on parts which use a FLASH for NVM. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
            eecd &= ~E1000_EECD_AUPDEN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
            E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4410
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
        eeprom->type = e1000_eeprom_spi;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
        eeprom->opcode_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
        eeprom->delay_usec = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
        if (eecd & E1000_EECD_ADDR_BITS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4417
            eeprom->page_size = 32;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4418
            eeprom->address_bits = 16;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
            eeprom->page_size = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
            eeprom->address_bits = 8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
        eeprom->use_eerd = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
        eeprom->use_eewr = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
    case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
    {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
        int32_t  i = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4429
        uint32_t flash_size = E1000_READ_ICH8_REG(hw, ICH8_FLASH_GFPREG);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
        eeprom->type = e1000_eeprom_ich8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
        eeprom->use_eerd = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
        eeprom->use_eewr = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
        eeprom->word_size = E1000_SHADOW_RAM_WORDS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4435
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
        /* Zero the shadow RAM structure. But don't load it from NVM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
         * so as to save time for driver init */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
        if (hw->eeprom_shadow_ram != NULL) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
            for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
                hw->eeprom_shadow_ram[i].modified = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
                hw->eeprom_shadow_ram[i].eeprom_word = 0xFFFF;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
        hw->flash_base_addr = (flash_size & ICH8_GFPREG_BASE_MASK) *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
                              ICH8_FLASH_SECTOR_SIZE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
        hw->flash_bank_size = ((flash_size >> 16) & ICH8_GFPREG_BASE_MASK) + 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
        hw->flash_bank_size -= (flash_size & ICH8_GFPREG_BASE_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
        hw->flash_bank_size *= ICH8_FLASH_SECTOR_SIZE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
        hw->flash_bank_size /= 2 * sizeof(uint16_t);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4453
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4455
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4458
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
    if (eeprom->type == e1000_eeprom_spi) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
        /* eeprom_size will be an enum [0..8] that maps to eeprom sizes 128B to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4461
         * 32KB (incremented by powers of 2).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4462
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
        if(hw->mac_type <= e1000_82547_rev_2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
            /* Set to default value for initial eeprom read. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
            eeprom->word_size = 64;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
            ret_val = e1000_read_eeprom(hw, EEPROM_CFG, 1, &eeprom_size);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
            eeprom_size = (eeprom_size & EEPROM_SIZE_MASK) >> EEPROM_SIZE_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
            /* 256B eeprom size was not supported in earlier hardware, so we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
             * bump eeprom_size up one to ensure that "1" (which maps to 256B)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
             * is never the result used in the shifting logic below. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
            if(eeprom_size)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
                eeprom_size++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
            eeprom_size = (uint16_t)((eecd & E1000_EECD_SIZE_EX_MASK) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
                          E1000_EECD_SIZE_EX_SHIFT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
        eeprom->word_size = 1 << (eeprom_size + EEPROM_WORD_SIZE_SHIFT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4483
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4486
 * Raises the EEPROM's clock input.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
 * eecd - EECD's current value
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4490
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
e1000_raise_ee_clk(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4493
                   uint32_t *eecd)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
    /* Raise the clock input to the EEPROM (by setting the SK bit), and then
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
     * wait <delay> microseconds.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
    *eecd = *eecd | E1000_EECD_SK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
    E1000_WRITE_REG(hw, EECD, *eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4501
    udelay(hw->eeprom.delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
 * Lowers the EEPROM's clock input.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4508
 * eecd - EECD's current value
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
e1000_lower_ee_clk(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
                   uint32_t *eecd)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4514
    /* Lower the clock input to the EEPROM (by clearing the SK bit), and then
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
     * wait 50 microseconds.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
    *eecd = *eecd & ~E1000_EECD_SK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4518
    E1000_WRITE_REG(hw, EECD, *eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
    udelay(hw->eeprom.delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4521
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4523
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
 * Shift data bits out to the EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4527
 * data - data to send to the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4528
 * count - number of bits to shift out
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
e1000_shift_out_ee_bits(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
                        uint16_t data,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
                        uint16_t count)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4536
    uint32_t eecd;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
    uint32_t mask;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
    /* We need to shift "count" bits out to the EEPROM. So, value in the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
     * "data" parameter will be shifted out to the EEPROM one bit at a time.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
     * In order to do this, "data" must be broken down into bits.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4542
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
    mask = 0x01 << (count - 1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
    eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
    if (eeprom->type == e1000_eeprom_microwire) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
        eecd &= ~E1000_EECD_DO;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4547
    } else if (eeprom->type == e1000_eeprom_spi) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
        eecd |= E1000_EECD_DO;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4549
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4550
    do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
        /* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1",
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
         * and then raising and then lowering the clock (the SK bit controls
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
         * the clock input to the EEPROM).  A "0" is shifted out to the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
         * by setting "DI" to "0" and then raising and then lowering the clock.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
        eecd &= ~E1000_EECD_DI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
        if(data & mask)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
            eecd |= E1000_EECD_DI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
        udelay(eeprom->delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
        e1000_raise_ee_clk(hw, &eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
        e1000_lower_ee_clk(hw, &eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
        mask = mask >> 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
    } while(mask);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
    /* We leave the "DI" bit set to "0" when we leave this routine. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
    eecd &= ~E1000_EECD_DI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
    E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
 * Shift data bits in from the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
static uint16_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
e1000_shift_in_ee_bits(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
                       uint16_t count)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4586
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
    uint32_t eecd;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
    uint32_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
    uint16_t data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
    /* In order to read a register from the EEPROM, we need to shift 'count'
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
     * bits in from the EEPROM. Bits are "shifted in" by raising the clock
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
     * input to the EEPROM (setting the SK bit), and then reading the value of
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
     * the "DO" bit.  During this "shifting in" process the "DI" bit should
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
     * always be clear.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
    eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
    eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
    data = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
    for(i = 0; i < count; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
        data = data << 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
        e1000_raise_ee_clk(hw, &eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
        eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
        eecd &= ~(E1000_EECD_DI);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
        if(eecd & E1000_EECD_DO)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
            data |= 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
        e1000_lower_ee_clk(hw, &eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
    return data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
 * Prepares EEPROM for access
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
 * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
 * function should be called before issuing a command to the EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
e1000_acquire_eeprom(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
    uint32_t eecd, i=0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4633
    DEBUGFUNC("e1000_acquire_eeprom");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4634
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
    if (e1000_swfw_sync_acquire(hw, E1000_SWFW_EEP_SM))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
        return -E1000_ERR_SWFW_SYNC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4637
    eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
    if (hw->mac_type != e1000_82573) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4640
        /* Request EEPROM Access */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
        if(hw->mac_type > e1000_82544) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
            eecd |= E1000_EECD_REQ;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4643
            E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
            eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
            while((!(eecd & E1000_EECD_GNT)) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
                  (i < E1000_EEPROM_GRANT_ATTEMPTS)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
                i++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
                udelay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
                eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
            if(!(eecd & E1000_EECD_GNT)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
                eecd &= ~E1000_EECD_REQ;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
                E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
                DEBUGOUT("Could not acquire EEPROM grant\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
                e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
                return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
    /* Setup EEPROM for Read/Write */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
    if (eeprom->type == e1000_eeprom_microwire) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
        /* Clear SK and DI */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
        eecd &= ~(E1000_EECD_DI | E1000_EECD_SK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
        /* Set CS */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
        eecd |= E1000_EECD_CS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
    } else if (eeprom->type == e1000_eeprom_spi) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
        /* Clear SK and CS */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
        eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
        udelay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
 * Returns EEPROM to a "standby" state
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4686
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
e1000_standby_eeprom(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
    uint32_t eecd;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
    eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
    if(eeprom->type == e1000_eeprom_microwire) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
        eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
        udelay(eeprom->delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
        /* Clock high */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
        eecd |= E1000_EECD_SK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
        udelay(eeprom->delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4706
        /* Select EEPROM */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
        eecd |= E1000_EECD_CS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
        udelay(eeprom->delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4711
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
        /* Clock low */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
        eecd &= ~E1000_EECD_SK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
        udelay(eeprom->delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
    } else if(eeprom->type == e1000_eeprom_spi) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
        /* Toggle CS to flush commands */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
        eecd |= E1000_EECD_CS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
        udelay(eeprom->delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
        eecd &= ~E1000_EECD_CS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4724
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4725
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
        udelay(eeprom->delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4729
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
 * Terminates a command by inverting the EEPROM's chip select pin
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4732
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4736
e1000_release_eeprom(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
    uint32_t eecd;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
    DEBUGFUNC("e1000_release_eeprom");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
    eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
    if (hw->eeprom.type == e1000_eeprom_spi) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4745
        eecd |= E1000_EECD_CS;  /* Pull CS high */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
        eecd &= ~E1000_EECD_SK; /* Lower SCK */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4750
        udelay(hw->eeprom.delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
    } else if(hw->eeprom.type == e1000_eeprom_microwire) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
        /* cleanup eeprom */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
        /* CS on Microwire is active-high */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
        eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
        /* Rising edge of clock */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
        eecd |= E1000_EECD_SK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4761
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
        udelay(hw->eeprom.delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
        /* Falling edge of clock */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
        eecd &= ~E1000_EECD_SK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
        udelay(hw->eeprom.delay_usec);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
    /* Stop requesting EEPROM access */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4773
    if(hw->mac_type > e1000_82544) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
        eecd &= ~E1000_EECD_REQ;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
        E1000_WRITE_REG(hw, EECD, eecd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4778
    e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4781
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
 * Reads a 16 bit word from the EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
e1000_spi_eeprom_ready(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
    uint16_t retry_count = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
    uint8_t spi_stat_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
    DEBUGFUNC("e1000_spi_eeprom_ready");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
    /* Read "Status Register" repeatedly until the LSB is cleared.  The
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
     * EEPROM will signal that the command has been completed by clearing
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
     * bit 0 of the internal status register.  If it's not cleared within
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
     * 5 milliseconds, then error out.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
    retry_count = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
    do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4801
        e1000_shift_out_ee_bits(hw, EEPROM_RDSR_OPCODE_SPI,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
                                hw->eeprom.opcode_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
        spi_stat_reg = (uint8_t)e1000_shift_in_ee_bits(hw, 8);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
        if (!(spi_stat_reg & EEPROM_STATUS_RDY_SPI))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4806
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
        udelay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
        retry_count += 5;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
        e1000_standby_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
    } while(retry_count < EEPROM_MAX_RETRY_SPI);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
    /* ATMEL SPI write time could vary from 0-20mSec on 3.3V devices (and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
     * only 0-5mSec on 5V devices)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
    if(retry_count >= EEPROM_MAX_RETRY_SPI) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
        DEBUGOUT("SPI EEPROM Status error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4824
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4825
 * Reads a 16 bit word from the EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4826
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
 * offset - offset of  word in the EEPROM to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
 * data - word read from the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
 * words - number of words to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4833
e1000_read_eeprom(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4834
                  uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4835
                  uint16_t words,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4836
                  uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4837
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
    uint32_t i = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4841
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4842
    DEBUGFUNC("e1000_read_eeprom");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4843
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
    /* A check for invalid values:  offset too large, too many words, and not
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
     * enough words.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
    if((offset >= eeprom->word_size) || (words > eeprom->word_size - offset) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4848
       (words == 0)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
        DEBUGOUT("\"words\" parameter out of bounds\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
    /* FLASH reads without acquiring the semaphore are safe */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4854
    if (e1000_is_onboard_nvm_eeprom(hw) == TRUE &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
    hw->eeprom.use_eerd == FALSE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
        switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
        case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4858
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
            /* Prepare the EEPROM for reading  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4861
            if (e1000_acquire_eeprom(hw) != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
                return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4865
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
    if (eeprom->use_eerd == TRUE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
        ret_val = e1000_read_eeprom_eerd(hw, offset, words, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4869
        if ((e1000_is_onboard_nvm_eeprom(hw) == TRUE) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
            (hw->mac_type != e1000_82573))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
            e1000_release_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4872
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4873
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4874
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
    if (eeprom->type == e1000_eeprom_ich8)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
        return e1000_read_eeprom_ich8(hw, offset, words, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
    if (eeprom->type == e1000_eeprom_spi) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4879
        uint16_t word_in;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4880
        uint8_t read_opcode = EEPROM_READ_OPCODE_SPI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4881
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
        if(e1000_spi_eeprom_ready(hw)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
            e1000_release_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
            return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4886
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4887
        e1000_standby_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4888
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
        /* Some SPI eeproms use the 8th address bit embedded in the opcode */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4890
        if((eeprom->address_bits == 8) && (offset >= 128))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
            read_opcode |= EEPROM_A8_OPCODE_SPI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4893
        /* Send the READ command (opcode + addr)  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
        e1000_shift_out_ee_bits(hw, read_opcode, eeprom->opcode_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4895
        e1000_shift_out_ee_bits(hw, (uint16_t)(offset*2), eeprom->address_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
        /* Read the data.  The address of the eeprom internally increments with
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
         * each byte (spi) being read, saving on the overhead of eeprom setup
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4899
         * and tear-down.  The address counter will roll over if reading beyond
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
         * the size of the eeprom, thus allowing the entire memory to be read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
         * starting from any offset. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
        for (i = 0; i < words; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
            word_in = e1000_shift_in_ee_bits(hw, 16);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
            data[i] = (word_in >> 8) | (word_in << 8);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
    } else if(eeprom->type == e1000_eeprom_microwire) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
        for (i = 0; i < words; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
            /* Send the READ command (opcode + addr)  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4909
            e1000_shift_out_ee_bits(hw, EEPROM_READ_OPCODE_MICROWIRE,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
                                    eeprom->opcode_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
            e1000_shift_out_ee_bits(hw, (uint16_t)(offset + i),
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4912
                                    eeprom->address_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4913
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
            /* Read the data.  For microwire, each word requires the overhead
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
             * of eeprom setup and tear-down. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4916
            data[i] = e1000_shift_in_ee_bits(hw, 16);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
            e1000_standby_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4921
    /* End this read operation */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4922
    e1000_release_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4925
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4926
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4927
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4928
 * Reads a 16 bit word from the EEPROM using the EERD register.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4931
 * offset - offset of  word in the EEPROM to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4932
 * data - word read from the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
 * words - number of words to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4934
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4935
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4936
e1000_read_eeprom_eerd(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
                  uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4938
                  uint16_t words,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
                  uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4941
    uint32_t i, eerd = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4942
    int32_t error = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4943
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4944
    for (i = 0; i < words; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4945
        eerd = ((offset+i) << E1000_EEPROM_RW_ADDR_SHIFT) +
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
                         E1000_EEPROM_RW_REG_START;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4947
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4948
        E1000_WRITE_REG(hw, EERD, eerd);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4949
        error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_READ);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4950
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4951
        if(error) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4952
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4953
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4954
        data[i] = (E1000_READ_REG(hw, EERD) >> E1000_EEPROM_RW_REG_DATA);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4955
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4956
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4957
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4960
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4962
 * Writes a 16 bit word from the EEPROM using the EEWR register.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4963
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4964
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
 * offset - offset of  word in the EEPROM to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4966
 * data - word read from the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
 * words - number of words to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
e1000_write_eeprom_eewr(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
                   uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
                   uint16_t words,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
                   uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
    uint32_t    register_value = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
    uint32_t    i              = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
    int32_t     error          = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
    if (e1000_swfw_sync_acquire(hw, E1000_SWFW_EEP_SM))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
        return -E1000_ERR_SWFW_SYNC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4982
    for (i = 0; i < words; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4983
        register_value = (data[i] << E1000_EEPROM_RW_REG_DATA) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4984
                         ((offset+i) << E1000_EEPROM_RW_ADDR_SHIFT) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4985
                         E1000_EEPROM_RW_REG_START;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
        error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
        if(error) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4989
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
        E1000_WRITE_REG(hw, EEWR, register_value);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4993
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
        error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4995
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
        if(error) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
    e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
 * Polls the status bit (bit 1) of the EERD to determine when the read is done.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
    uint32_t attempts = 100000;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
    uint32_t i, reg = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
    int32_t done = E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
    for(i = 0; i < attempts; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5018
        if(eerd == E1000_EEPROM_POLL_READ)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
            reg = E1000_READ_REG(hw, EERD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5020
        else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
            reg = E1000_READ_REG(hw, EEWR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5022
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5023
        if(reg & E1000_EEPROM_RW_REG_DONE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
            done = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5025
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5026
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5027
        udelay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5029
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
    return done;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5032
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5033
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
* Description:     Determines if the onboard NVM is FLASH or EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
*
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
* hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
static boolean_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5041
    uint32_t eecd = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
    DEBUGFUNC("e1000_is_onboard_nvm_eeprom");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5044
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
        return FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
    if (hw->mac_type == e1000_82573) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
        eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
        /* Isolate bits 15 & 16 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
        eecd = ((eecd >> 15) & 0x03);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5054
        /* If both bits are set, device is Flash type */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
        if(eecd == 0x03) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5056
            return FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
    return TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5061
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5063
 * Verifies that the EEPROM has a valid checksum
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
 * Reads the first 64 16 bit words of the EEPROM and sums the values read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5068
 * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
 * valid.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
e1000_validate_eeprom_checksum(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5073
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
    uint16_t checksum = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
    uint16_t i, eeprom_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5076
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5077
    DEBUGFUNC("e1000_validate_eeprom_checksum");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
    if ((hw->mac_type == e1000_82573) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5080
        (e1000_is_onboard_nvm_eeprom(hw) == FALSE)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
        /* Check bit 4 of word 10h.  If it is 0, firmware is done updating
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5082
         * 10h-12h.  Checksum may need to be fixed. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5083
        e1000_read_eeprom(hw, 0x10, 1, &eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5084
        if ((eeprom_data & 0x10) == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
            /* Read 0x23 and check bit 15.  This bit is a 1 when the checksum
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5086
             * has already been fixed.  If the checksum is still wrong and this
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5087
             * bit is a 1, we need to return bad checksum.  Otherwise, we need
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
             * to set this bit to a 1 and update the checksum. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5089
            e1000_read_eeprom(hw, 0x23, 1, &eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5090
            if ((eeprom_data & 0x8000) == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
                eeprom_data |= 0x8000;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5092
                e1000_write_eeprom(hw, 0x23, 1, &eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5093
                e1000_update_eeprom_checksum(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5094
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
    if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
        /* Drivers must allocate the shadow ram structure for the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
         * EEPROM checksum to be updated.  Otherwise, this bit as well
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5101
         * as the checksum must both be set correctly for this
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
         * validation to pass.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
        e1000_read_eeprom(hw, 0x19, 1, &eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5105
        if ((eeprom_data & 0x40) == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
            eeprom_data |= 0x40;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5107
            e1000_write_eeprom(hw, 0x19, 1, &eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5108
            e1000_update_eeprom_checksum(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5112
    for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
        if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5114
            DEBUGOUT("EEPROM Read Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5115
            return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
        checksum += eeprom_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5119
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
    if(checksum == (uint16_t) EEPROM_SUM)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5121
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
    else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
        DEBUGOUT("EEPROM Checksum Invalid\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5127
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
 * Calculates the EEPROM checksum and writes it to the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
 * Sums the first 63 16 bit words of the EEPROM. Subtracts the sum from 0xBABA.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
 * Writes the difference to word offset 63 of the EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5136
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5137
e1000_update_eeprom_checksum(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5139
    uint32_t ctrl_ext;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5140
    uint16_t checksum = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
    uint16_t i, eeprom_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5142
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
    DEBUGFUNC("e1000_update_eeprom_checksum");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5145
    for(i = 0; i < EEPROM_CHECKSUM_REG; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5146
        if(e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
            DEBUGOUT("EEPROM Read Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
            return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5150
        checksum += eeprom_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5151
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5152
    checksum = (uint16_t) EEPROM_SUM - checksum;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5153
    if(e1000_write_eeprom(hw, EEPROM_CHECKSUM_REG, 1, &checksum) < 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
        DEBUGOUT("EEPROM Write Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
    } else if (hw->eeprom.type == e1000_eeprom_flash) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5157
        e1000_commit_shadow_ram(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5158
    } else if (hw->eeprom.type == e1000_eeprom_ich8) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5159
        e1000_commit_shadow_ram(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5160
        /* Reload the EEPROM, or else modifications will not appear
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
         * until after next adapter reset. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
        ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
        ctrl_ext |= E1000_CTRL_EXT_EE_RST;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5164
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5165
        msec_delay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5166
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5167
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5169
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5171
 * Parent function for writing words to the different EEPROM types.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5172
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
 * offset - offset within the EEPROM to be written to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
 * words - number of words to write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5176
 * data - 16 bit word to be written to the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5177
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5178
 * If e1000_update_eeprom_checksum is not called after this function, the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5179
 * EEPROM will most likely contain an invalid checksum.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5181
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
e1000_write_eeprom(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5183
                   uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5184
                   uint16_t words,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
                   uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5186
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5188
    int32_t status = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5190
    DEBUGFUNC("e1000_write_eeprom");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
    /* A check for invalid values:  offset too large, too many words, and not
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5193
     * enough words.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5194
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
    if((offset >= eeprom->word_size) || (words > eeprom->word_size - offset) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
       (words == 0)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
        DEBUGOUT("\"words\" parameter out of bounds\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5198
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5200
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5201
    /* 82573 writes only through eewr */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5202
    if(eeprom->use_eewr == TRUE)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
        return e1000_write_eeprom_eewr(hw, offset, words, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5205
    if (eeprom->type == e1000_eeprom_ich8)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
        return e1000_write_eeprom_ich8(hw, offset, words, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5207
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
    /* Prepare the EEPROM for writing  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
    if (e1000_acquire_eeprom(hw) != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5210
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5211
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5212
    if(eeprom->type == e1000_eeprom_microwire) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5213
        status = e1000_write_eeprom_microwire(hw, offset, words, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5214
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5215
        status = e1000_write_eeprom_spi(hw, offset, words, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
        msec_delay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5217
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5218
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5219
    /* Done with writing */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5220
    e1000_release_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5221
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5222
    return status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5223
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5225
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5226
 * Writes a 16 bit word to a given offset in an SPI EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5227
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5228
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
 * offset - offset within the EEPROM to be written to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
 * words - number of words to write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
 * data - pointer to array of 8 bit words to be written to the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5232
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5234
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
e1000_write_eeprom_spi(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
                       uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
                       uint16_t words,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
                       uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
    uint16_t widx = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5242
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
    DEBUGFUNC("e1000_write_eeprom_spi");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5244
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
    while (widx < words) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
        uint8_t write_opcode = EEPROM_WRITE_OPCODE_SPI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5247
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
        if(e1000_spi_eeprom_ready(hw)) return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
        e1000_standby_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5252
        /*  Send the WRITE ENABLE command (8 bit opcode )  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5253
        e1000_shift_out_ee_bits(hw, EEPROM_WREN_OPCODE_SPI,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
                                    eeprom->opcode_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5255
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5256
        e1000_standby_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
        /* Some SPI eeproms use the 8th address bit embedded in the opcode */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5259
        if((eeprom->address_bits == 8) && (offset >= 128))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
            write_opcode |= EEPROM_A8_OPCODE_SPI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5262
        /* Send the Write command (8-bit opcode + addr) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5263
        e1000_shift_out_ee_bits(hw, write_opcode, eeprom->opcode_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5265
        e1000_shift_out_ee_bits(hw, (uint16_t)((offset + widx)*2),
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5266
                                eeprom->address_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5267
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5268
        /* Send the data */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5269
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5270
        /* Loop to allow for up to whole page write (32 bytes) of eeprom */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5271
        while (widx < words) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
            uint16_t word_out = data[widx];
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
            word_out = (word_out >> 8) | (word_out << 8);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
            e1000_shift_out_ee_bits(hw, word_out, 16);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
            widx++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5277
            /* Some larger eeprom sizes are capable of a 32-byte PAGE WRITE
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
             * operation, while the smaller eeproms are capable of an 8-byte
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5279
             * PAGE WRITE operation.  Break the inner loop to pass new address
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5280
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5281
            if((((offset + widx)*2) % eeprom->page_size) == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
                e1000_standby_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5284
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5286
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5287
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5288
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5289
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5292
 * Writes a 16 bit word to a given offset in a Microwire EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
 * offset - offset within the EEPROM to be written to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
 * words - number of words to write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
 * data - pointer to array of 16 bit words to be written to the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5300
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5301
e1000_write_eeprom_microwire(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5302
                             uint16_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5303
                             uint16_t words,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
                             uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5305
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
    uint32_t eecd;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
    uint16_t words_written = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
    uint16_t i = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5310
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5311
    DEBUGFUNC("e1000_write_eeprom_microwire");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5312
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5313
    /* Send the write enable command to the EEPROM (3-bit opcode plus
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
     * 6/8-bit dummy address beginning with 11).  It's less work to include
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5315
     * the 11 of the dummy address as part of the opcode than it is to shift
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5316
     * it over the correct number of bits for the address.  This puts the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5317
     * EEPROM into write/erase mode.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5318
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5319
    e1000_shift_out_ee_bits(hw, EEPROM_EWEN_OPCODE_MICROWIRE,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5320
                            (uint16_t)(eeprom->opcode_bits + 2));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5321
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5322
    e1000_shift_out_ee_bits(hw, 0, (uint16_t)(eeprom->address_bits - 2));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
    /* Prepare the EEPROM */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5325
    e1000_standby_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5326
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5327
    while (words_written < words) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5328
        /* Send the Write command (3-bit opcode + addr) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5329
        e1000_shift_out_ee_bits(hw, EEPROM_WRITE_OPCODE_MICROWIRE,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5330
                                eeprom->opcode_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5331
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5332
        e1000_shift_out_ee_bits(hw, (uint16_t)(offset + words_written),
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5333
                                eeprom->address_bits);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5334
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
        /* Send the data */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5336
        e1000_shift_out_ee_bits(hw, data[words_written], 16);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5337
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5338
        /* Toggle the CS line.  This in effect tells the EEPROM to execute
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
         * the previous command.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5340
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5341
        e1000_standby_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
        /* Read DO repeatedly until it is high (equal to '1').  The EEPROM will
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
         * signal that the command has been completed by raising the DO signal.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5345
         * If DO does not go high in 10 milliseconds, then error out.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5346
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5347
        for(i = 0; i < 200; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5348
            eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
            if(eecd & E1000_EECD_DO) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
            udelay(50);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5351
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
        if(i == 200) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5353
            DEBUGOUT("EEPROM Write did not complete\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5354
            return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5355
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
        /* Recover from write */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
        e1000_standby_eeprom(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5359
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5360
        words_written++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5361
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5362
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5363
    /* Send the write disable command to the EEPROM (3-bit opcode plus
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
     * 6/8-bit dummy address beginning with 10).  It's less work to include
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
     * the 10 of the dummy address as part of the opcode than it is to shift
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5366
     * it over the correct number of bits for the address.  This takes the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5367
     * EEPROM out of write/erase mode.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5369
    e1000_shift_out_ee_bits(hw, EEPROM_EWDS_OPCODE_MICROWIRE,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5370
                            (uint16_t)(eeprom->opcode_bits + 2));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5372
    e1000_shift_out_ee_bits(hw, 0, (uint16_t)(eeprom->address_bits - 2));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5378
 * Flushes the cached eeprom to NVM. This is done by saving the modified values
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
 * in the eeprom cache and the non modified values in the currently active bank
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5380
 * to the new bank.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5381
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
 * offset - offset of  word in the EEPROM to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
 * data - word read from the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5385
 * words - number of words to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5387
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5388
e1000_commit_shadow_ram(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5389
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
    uint32_t attempts = 100000;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
    uint32_t eecd = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
    uint32_t flop = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
    uint32_t i = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5394
    int32_t error = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5395
    uint32_t old_bank_offset = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5396
    uint32_t new_bank_offset = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5397
    uint32_t sector_retries = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5398
    uint8_t low_byte = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5399
    uint8_t high_byte = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5400
    uint8_t temp_byte = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5401
    boolean_t sector_write_failed = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5402
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5403
    if (hw->mac_type == e1000_82573) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5404
        /* The flop register will be used to determine if flash type is STM */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5405
        flop = E1000_READ_REG(hw, FLOP);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5406
        for (i=0; i < attempts; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5407
            eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5408
            if ((eecd & E1000_EECD_FLUPD) == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5409
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5410
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5411
            udelay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5412
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5413
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5414
        if (i == attempts) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5415
            return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5416
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5417
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5418
        /* If STM opcode located in bits 15:8 of flop, reset firmware */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5419
        if ((flop & 0xFF00) == E1000_STM_OPCODE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5420
            E1000_WRITE_REG(hw, HICR, E1000_HICR_FW_RESET);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5421
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5422
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5423
        /* Perform the flash update */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5424
        E1000_WRITE_REG(hw, EECD, eecd | E1000_EECD_FLUPD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5425
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5426
        for (i=0; i < attempts; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5427
            eecd = E1000_READ_REG(hw, EECD);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5428
            if ((eecd & E1000_EECD_FLUPD) == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5429
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5430
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5431
            udelay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5432
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5433
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5434
        if (i == attempts) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5435
            return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5436
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5437
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5438
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5439
    if (hw->mac_type == e1000_ich8lan && hw->eeprom_shadow_ram != NULL) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5440
        /* We're writing to the opposite bank so if we're on bank 1,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5441
         * write to bank 0 etc.  We also need to erase the segment that
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5442
         * is going to be written */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5443
        if (!(E1000_READ_REG(hw, EECD) & E1000_EECD_SEC1VAL)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5444
            new_bank_offset = hw->flash_bank_size * 2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5445
            old_bank_offset = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5446
            e1000_erase_ich8_4k_segment(hw, 1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5447
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5448
            old_bank_offset = hw->flash_bank_size * 2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5449
            new_bank_offset = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5450
            e1000_erase_ich8_4k_segment(hw, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5451
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5452
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5453
        do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5454
            sector_write_failed = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5455
            /* Loop for every byte in the shadow RAM,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5456
             * which is in units of words. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5457
            for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5458
                /* Determine whether to write the value stored
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5459
                 * in the other NVM bank or a modified value stored
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5460
                 * in the shadow RAM */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5461
                if (hw->eeprom_shadow_ram[i].modified == TRUE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5462
                    low_byte = (uint8_t)hw->eeprom_shadow_ram[i].eeprom_word;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5463
                    e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5464
                                         &temp_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5465
                    udelay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5466
                    error = e1000_verify_write_ich8_byte(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5467
                                                 (i << 1) + new_bank_offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5468
                                                 low_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5469
                    if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5470
                        sector_write_failed = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5471
                    high_byte =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5472
                        (uint8_t)(hw->eeprom_shadow_ram[i].eeprom_word >> 8);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5473
                    e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset + 1,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5474
                                         &temp_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5475
                    udelay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5476
                } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5477
                    e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5478
                                         &low_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5479
                    udelay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5480
                    error = e1000_verify_write_ich8_byte(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5481
                                 (i << 1) + new_bank_offset, low_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5482
                    if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5483
                        sector_write_failed = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5484
                    e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset + 1,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5485
                                         &high_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5486
                }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5487
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5488
                /* If the word is 0x13, then make sure the signature bits
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5489
                 * (15:14) are 11b until the commit has completed.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5490
                 * This will allow us to write 10b which indicates the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5491
                 * signature is valid.  We want to do this after the write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5492
                 * has completed so that we don't mark the segment valid
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5493
                 * while the write is still in progress */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5494
                if (i == E1000_ICH8_NVM_SIG_WORD)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5495
                    high_byte = E1000_ICH8_NVM_SIG_MASK | high_byte;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5496
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5497
                error = e1000_verify_write_ich8_byte(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5498
                             (i << 1) + new_bank_offset + 1, high_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5499
                if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5500
                    sector_write_failed = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5501
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5502
                if (sector_write_failed == FALSE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5503
                    /* Clear the now not used entry in the cache */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5504
                    hw->eeprom_shadow_ram[i].modified = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5505
                    hw->eeprom_shadow_ram[i].eeprom_word = 0xFFFF;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5506
                }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5507
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5508
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5509
            /* Don't bother writing the segment valid bits if sector
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5510
             * programming failed. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5511
            if (sector_write_failed == FALSE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5512
                /* Finally validate the new segment by setting bit 15:14
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5513
                 * to 10b in word 0x13 , this can be done without an
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5514
                 * erase as well since these bits are 11 to start with
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5515
                 * and we need to change bit 14 to 0b */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5516
                e1000_read_ich8_byte(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5517
                    E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5518
                    &high_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5519
                high_byte &= 0xBF;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5520
                error = e1000_verify_write_ich8_byte(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5521
                            E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5522
                            high_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5523
                if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5524
                    sector_write_failed = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5525
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5526
                /* And invalidate the previously valid segment by setting
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5527
                 * its signature word (0x13) high_byte to 0b. This can be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5528
                 * done without an erase because flash erase sets all bits
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5529
                 * to 1's. We can write 1's to 0's without an erase */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5530
                error = e1000_verify_write_ich8_byte(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5531
                            E1000_ICH8_NVM_SIG_WORD * 2 + 1 + old_bank_offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5532
                            0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5533
                if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5534
                    sector_write_failed = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5535
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5536
        } while (++sector_retries < 10 && sector_write_failed == TRUE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5537
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5538
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5539
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5540
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5541
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5542
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5543
 * Reads the adapter's part number from the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5544
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5545
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5546
 * part_num - Adapter's part number
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5547
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5548
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5549
e1000_read_part_num(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5550
                    uint32_t *part_num)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5551
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5552
    uint16_t offset = EEPROM_PBA_BYTE_1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5553
    uint16_t eeprom_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5554
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5555
    DEBUGFUNC("e1000_read_part_num");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5556
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5557
    /* Get word 0 from EEPROM */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5558
    if(e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5559
        DEBUGOUT("EEPROM Read Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5560
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5561
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5562
    /* Save word 0 in upper half of part_num */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5563
    *part_num = (uint32_t) (eeprom_data << 16);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5564
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5565
    /* Get word 1 from EEPROM */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5566
    if(e1000_read_eeprom(hw, ++offset, 1, &eeprom_data) < 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5567
        DEBUGOUT("EEPROM Read Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5568
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5569
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5570
    /* Save word 1 in lower half of part_num */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5571
    *part_num |= eeprom_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5572
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5573
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5574
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5575
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5576
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5577
 * Reads the adapter's MAC address from the EEPROM and inverts the LSB for the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5578
 * second function of dual function devices
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5579
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5580
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5581
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5582
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5583
e1000_read_mac_addr(struct e1000_hw * hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5584
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5585
    uint16_t offset;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5586
    uint16_t eeprom_data, i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5587
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5588
    DEBUGFUNC("e1000_read_mac_addr");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5589
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5590
    for(i = 0; i < NODE_ADDRESS_SIZE; i += 2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5591
        offset = i >> 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5592
        if(e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5593
            DEBUGOUT("EEPROM Read Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5594
            return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5595
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5596
        hw->perm_mac_addr[i] = (uint8_t) (eeprom_data & 0x00FF);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5597
        hw->perm_mac_addr[i+1] = (uint8_t) (eeprom_data >> 8);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5598
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5599
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5600
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5601
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5602
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5603
    case e1000_82546:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5604
    case e1000_82546_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5605
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5606
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5607
        if(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5608
            hw->perm_mac_addr[5] ^= 0x01;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5609
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5610
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5611
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5612
    for(i = 0; i < NODE_ADDRESS_SIZE; i++)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5613
        hw->mac_addr[i] = hw->perm_mac_addr[i];
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5614
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5615
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5616
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5617
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5618
 * Initializes receive address filters.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5619
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5620
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5621
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5622
 * Places the MAC address in receive address register 0 and clears the rest
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5623
 * of the receive addresss registers. Clears the multicast table. Assumes
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5624
 * the receiver is in reset when the routine is called.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5625
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5626
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5627
e1000_init_rx_addrs(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5628
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5629
    uint32_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5630
    uint32_t rar_num;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5631
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5632
    DEBUGFUNC("e1000_init_rx_addrs");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5633
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5634
    /* Setup the receive address. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5635
    DEBUGOUT("Programming MAC Address into RAR[0]\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5636
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5637
    e1000_rar_set(hw, hw->mac_addr, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5638
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5639
    rar_num = E1000_RAR_ENTRIES;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5640
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5641
    /* Reserve a spot for the Locally Administered Address to work around
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5642
     * an 82571 issue in which a reset on one port will reload the MAC on
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5643
     * the other port. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5644
    if ((hw->mac_type == e1000_82571) && (hw->laa_is_present == TRUE))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5645
        rar_num -= 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5646
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5647
        rar_num = E1000_RAR_ENTRIES_ICH8LAN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5648
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5649
    /* Zero out the other 15 receive addresses. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5650
    DEBUGOUT("Clearing RAR[1-15]\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5651
    for(i = 1; i < rar_num; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5652
        E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5653
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5654
        E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5655
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5656
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5657
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5658
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5659
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5660
 * Updates the MAC's list of multicast addresses.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5661
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5662
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5663
 * mc_addr_list - the list of new multicast addresses
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5664
 * mc_addr_count - number of addresses
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5665
 * pad - number of bytes between addresses in the list
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5666
 * rar_used_count - offset where to start adding mc addresses into the RAR's
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5667
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5668
 * The given list replaces any existing list. Clears the last 15 receive
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5669
 * address registers and the multicast table. Uses receive address registers
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5670
 * for the first 15 multicast addresses, and hashes the rest into the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5671
 * multicast table.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5672
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5673
#if 0
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5674
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5675
e1000_mc_addr_list_update(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5676
                          uint8_t *mc_addr_list,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5677
                          uint32_t mc_addr_count,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5678
                          uint32_t pad,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5679
                          uint32_t rar_used_count)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5680
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5681
    uint32_t hash_value;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5682
    uint32_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5683
    uint32_t num_rar_entry;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5684
    uint32_t num_mta_entry;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5685
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5686
    DEBUGFUNC("e1000_mc_addr_list_update");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5687
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5688
    /* Set the new number of MC addresses that we are being requested to use. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5689
    hw->num_mc_addrs = mc_addr_count;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5690
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5691
    /* Clear RAR[1-15] */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5692
    DEBUGOUT(" Clearing RAR[1-15]\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5693
    num_rar_entry = E1000_RAR_ENTRIES;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5694
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5695
        num_rar_entry = E1000_RAR_ENTRIES_ICH8LAN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5696
    /* Reserve a spot for the Locally Administered Address to work around
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5697
     * an 82571 issue in which a reset on one port will reload the MAC on
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5698
     * the other port. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5699
    if ((hw->mac_type == e1000_82571) && (hw->laa_is_present == TRUE))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5700
        num_rar_entry -= 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5701
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5702
    for(i = rar_used_count; i < num_rar_entry; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5703
        E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5704
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5705
        E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5706
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5707
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5708
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5709
    /* Clear the MTA */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5710
    DEBUGOUT(" Clearing MTA\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5711
    num_mta_entry = E1000_NUM_MTA_REGISTERS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5712
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5713
        num_mta_entry = E1000_NUM_MTA_REGISTERS_ICH8LAN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5714
    for(i = 0; i < num_mta_entry; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5715
        E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5716
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5717
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5718
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5719
    /* Add the new addresses */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5720
    for(i = 0; i < mc_addr_count; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5721
        DEBUGOUT(" Adding the multicast addresses:\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5722
        DEBUGOUT7(" MC Addr #%d =%.2X %.2X %.2X %.2X %.2X %.2X\n", i,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5723
                  mc_addr_list[i * (ETH_LENGTH_OF_ADDRESS + pad)],
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5724
                  mc_addr_list[i * (ETH_LENGTH_OF_ADDRESS + pad) + 1],
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5725
                  mc_addr_list[i * (ETH_LENGTH_OF_ADDRESS + pad) + 2],
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5726
                  mc_addr_list[i * (ETH_LENGTH_OF_ADDRESS + pad) + 3],
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5727
                  mc_addr_list[i * (ETH_LENGTH_OF_ADDRESS + pad) + 4],
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5728
                  mc_addr_list[i * (ETH_LENGTH_OF_ADDRESS + pad) + 5]);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5729
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5730
        hash_value = e1000_hash_mc_addr(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5731
                                        mc_addr_list +
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5732
                                        (i * (ETH_LENGTH_OF_ADDRESS + pad)));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5733
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5734
        DEBUGOUT1(" Hash value = 0x%03X\n", hash_value);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5735
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5736
        /* Place this multicast address in the RAR if there is room, *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5737
         * else put it in the MTA
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5738
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5739
        if (rar_used_count < num_rar_entry) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5740
            e1000_rar_set(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5741
                          mc_addr_list + (i * (ETH_LENGTH_OF_ADDRESS + pad)),
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5742
                          rar_used_count);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5743
            rar_used_count++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5744
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5745
            e1000_mta_set(hw, hash_value);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5746
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5747
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5748
    DEBUGOUT("MC Update Complete\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5749
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5750
#endif  /*  0  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5751
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5752
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5753
 * Hashes an address to determine its location in the multicast table
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5754
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5755
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5756
 * mc_addr - the multicast address to hash
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5757
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5758
uint32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5759
e1000_hash_mc_addr(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5760
                   uint8_t *mc_addr)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5761
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5762
    uint32_t hash_value = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5763
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5764
    /* The portion of the address that is used for the hash table is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5765
     * determined by the mc_filter_type setting.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5766
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5767
    switch (hw->mc_filter_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5768
    /* [0] [1] [2] [3] [4] [5]
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5769
     * 01  AA  00  12  34  56
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5770
     * LSB                 MSB
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5771
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5772
    case 0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5773
        if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5774
            /* [47:38] i.e. 0x158 for above example address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5775
            hash_value = ((mc_addr[4] >> 6) | (((uint16_t) mc_addr[5]) << 2));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5776
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5777
            /* [47:36] i.e. 0x563 for above example address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5778
            hash_value = ((mc_addr[4] >> 4) | (((uint16_t) mc_addr[5]) << 4));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5779
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5780
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5781
    case 1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5782
        if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5783
            /* [46:37] i.e. 0x2B1 for above example address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5784
            hash_value = ((mc_addr[4] >> 5) | (((uint16_t) mc_addr[5]) << 3));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5785
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5786
            /* [46:35] i.e. 0xAC6 for above example address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5787
            hash_value = ((mc_addr[4] >> 3) | (((uint16_t) mc_addr[5]) << 5));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5788
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5789
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5790
    case 2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5791
        if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5792
            /*[45:36] i.e. 0x163 for above example address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5793
            hash_value = ((mc_addr[4] >> 4) | (((uint16_t) mc_addr[5]) << 4));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5794
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5795
            /* [45:34] i.e. 0x5D8 for above example address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5796
            hash_value = ((mc_addr[4] >> 2) | (((uint16_t) mc_addr[5]) << 6));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5797
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5798
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5799
    case 3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5800
        if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5801
            /* [43:34] i.e. 0x18D for above example address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5802
            hash_value = ((mc_addr[4] >> 2) | (((uint16_t) mc_addr[5]) << 6));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5803
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5804
            /* [43:32] i.e. 0x634 for above example address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5805
            hash_value = ((mc_addr[4]) | (((uint16_t) mc_addr[5]) << 8));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5806
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5807
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5808
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5809
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5810
    hash_value &= 0xFFF;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5811
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5812
        hash_value &= 0x3FF;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5813
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5814
    return hash_value;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5815
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5816
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5817
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5818
 * Sets the bit in the multicast table corresponding to the hash value.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5819
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5820
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5821
 * hash_value - Multicast address hash value
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5822
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5823
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5824
e1000_mta_set(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5825
              uint32_t hash_value)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5826
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5827
    uint32_t hash_bit, hash_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5828
    uint32_t mta;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5829
    uint32_t temp;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5830
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5831
    /* The MTA is a register array of 128 32-bit registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5832
     * It is treated like an array of 4096 bits.  We want to set
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5833
     * bit BitArray[hash_value]. So we figure out what register
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5834
     * the bit is in, read it, OR in the new bit, then write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5835
     * back the new value.  The register is determined by the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5836
     * upper 7 bits of the hash value and the bit within that
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5837
     * register are determined by the lower 5 bits of the value.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5838
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5839
    hash_reg = (hash_value >> 5) & 0x7F;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5840
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5841
        hash_reg &= 0x1F;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5842
    hash_bit = hash_value & 0x1F;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5843
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5844
    mta = E1000_READ_REG_ARRAY(hw, MTA, hash_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5845
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5846
    mta |= (1 << hash_bit);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5847
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5848
    /* If we are on an 82544 and we are trying to write an odd offset
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5849
     * in the MTA, save off the previous entry before writing and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5850
     * restore the old value after writing.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5851
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5852
    if((hw->mac_type == e1000_82544) && ((hash_reg & 0x1) == 1)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5853
        temp = E1000_READ_REG_ARRAY(hw, MTA, (hash_reg - 1));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5854
        E1000_WRITE_REG_ARRAY(hw, MTA, hash_reg, mta);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5855
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5856
        E1000_WRITE_REG_ARRAY(hw, MTA, (hash_reg - 1), temp);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5857
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5858
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5859
        E1000_WRITE_REG_ARRAY(hw, MTA, hash_reg, mta);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5860
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5861
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5862
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5863
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5864
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5865
 * Puts an ethernet address into a receive address register.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5866
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5867
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5868
 * addr - Address to put into receive address register
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5869
 * index - Receive address register to write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5870
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5871
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5872
e1000_rar_set(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5873
              uint8_t *addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5874
              uint32_t index)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5875
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5876
    uint32_t rar_low, rar_high;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5877
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5878
    /* HW expects these in little endian so we reverse the byte order
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5879
     * from network order (big endian) to little endian
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5880
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5881
    rar_low = ((uint32_t) addr[0] |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5882
               ((uint32_t) addr[1] << 8) |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5883
               ((uint32_t) addr[2] << 16) | ((uint32_t) addr[3] << 24));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5884
    rar_high = ((uint32_t) addr[4] | ((uint32_t) addr[5] << 8));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5885
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5886
    /* Disable Rx and flush all Rx frames before enabling RSS to avoid Rx
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5887
     * unit hang.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5888
     *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5889
     * Description:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5890
     * If there are any Rx frames queued up or otherwise present in the HW
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5891
     * before RSS is enabled, and then we enable RSS, the HW Rx unit will
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5892
     * hang.  To work around this issue, we have to disable receives and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5893
     * flush out all Rx frames before we enable RSS. To do so, we modify we
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5894
     * redirect all Rx traffic to manageability and then reset the HW.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5895
     * This flushes away Rx frames, and (since the redirections to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5896
     * manageability persists across resets) keeps new ones from coming in
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5897
     * while we work.  Then, we clear the Address Valid AV bit for all MAC
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5898
     * addresses and undo the re-direction to manageability.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5899
     * Now, frames are coming in again, but the MAC won't accept them, so
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5900
     * far so good.  We now proceed to initialize RSS (if necessary) and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5901
     * configure the Rx unit.  Last, we re-enable the AV bits and continue
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5902
     * on our merry way.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5903
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5904
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5905
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5906
    case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5907
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5908
        if (hw->leave_av_bit_off == TRUE)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5909
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5910
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5911
        /* Indicate to hardware the Address is Valid. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5912
        rar_high |= E1000_RAH_AV;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5913
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5914
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5915
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5916
    E1000_WRITE_REG_ARRAY(hw, RA, (index << 1), rar_low);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5917
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5918
    E1000_WRITE_REG_ARRAY(hw, RA, ((index << 1) + 1), rar_high);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5919
    E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5920
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5921
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5922
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5923
 * Writes a value to the specified offset in the VLAN filter table.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5924
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5925
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5926
 * offset - Offset in VLAN filer table to write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5927
 * value - Value to write into VLAN filter table
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5928
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5929
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5930
e1000_write_vfta(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5931
                 uint32_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5932
                 uint32_t value)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5933
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5934
    uint32_t temp;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5935
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5936
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5937
        return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5938
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5939
    if ((hw->mac_type == e1000_82544) && ((offset & 0x1) == 1)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5940
        temp = E1000_READ_REG_ARRAY(hw, VFTA, (offset - 1));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5941
        E1000_WRITE_REG_ARRAY(hw, VFTA, offset, value);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5942
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5943
        E1000_WRITE_REG_ARRAY(hw, VFTA, (offset - 1), temp);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5944
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5945
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5946
        E1000_WRITE_REG_ARRAY(hw, VFTA, offset, value);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5947
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5948
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5949
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5950
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5951
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5952
 * Clears the VLAN filer table
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5953
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5954
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5955
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5956
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5957
e1000_clear_vfta(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5958
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5959
    uint32_t offset;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5960
    uint32_t vfta_value = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5961
    uint32_t vfta_offset = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5962
    uint32_t vfta_bit_in_reg = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5963
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5964
    if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5965
        return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5966
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5967
    if (hw->mac_type == e1000_82573) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5968
        if (hw->mng_cookie.vlan_id != 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5969
            /* The VFTA is a 4096b bit-field, each identifying a single VLAN
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5970
             * ID.  The following operations determine which 32b entry
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5971
             * (i.e. offset) into the array we want to set the VLAN ID
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5972
             * (i.e. bit) of the manageability unit. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5973
            vfta_offset = (hw->mng_cookie.vlan_id >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5974
                           E1000_VFTA_ENTRY_SHIFT) &
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5975
                          E1000_VFTA_ENTRY_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5976
            vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5977
                                    E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5978
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5979
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5980
    for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5981
        /* If the offset we want to clear is the same offset of the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5982
         * manageability VLAN ID, then clear all bits except that of the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5983
         * manageability unit */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5984
        vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5985
        E1000_WRITE_REG_ARRAY(hw, VFTA, offset, vfta_value);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5986
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5987
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5988
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5989
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5990
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5991
e1000_id_led_init(struct e1000_hw * hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5992
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5993
    uint32_t ledctl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5994
    const uint32_t ledctl_mask = 0x000000FF;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5995
    const uint32_t ledctl_on = E1000_LEDCTL_MODE_LED_ON;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5996
    const uint32_t ledctl_off = E1000_LEDCTL_MODE_LED_OFF;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5997
    uint16_t eeprom_data, i, temp;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5998
    const uint16_t led_mask = 0x0F;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5999
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6000
    DEBUGFUNC("e1000_id_led_init");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6001
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6002
    if(hw->mac_type < e1000_82540) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6003
        /* Nothing to do */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6004
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6005
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6006
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6007
    ledctl = E1000_READ_REG(hw, LEDCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6008
    hw->ledctl_default = ledctl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6009
    hw->ledctl_mode1 = hw->ledctl_default;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6010
    hw->ledctl_mode2 = hw->ledctl_default;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6011
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6012
    if(e1000_read_eeprom(hw, EEPROM_ID_LED_SETTINGS, 1, &eeprom_data) < 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6013
        DEBUGOUT("EEPROM Read Error\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6014
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6015
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6016
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6017
    if ((hw->mac_type == e1000_82573) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6018
        (eeprom_data == ID_LED_RESERVED_82573))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6019
        eeprom_data = ID_LED_DEFAULT_82573;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6020
    else if ((eeprom_data == ID_LED_RESERVED_0000) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6021
            (eeprom_data == ID_LED_RESERVED_FFFF)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6022
        if (hw->mac_type == e1000_ich8lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6023
            eeprom_data = ID_LED_DEFAULT_ICH8LAN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6024
        else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6025
            eeprom_data = ID_LED_DEFAULT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6026
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6027
    for (i = 0; i < 4; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6028
        temp = (eeprom_data >> (i << 2)) & led_mask;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6029
        switch(temp) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6030
        case ID_LED_ON1_DEF2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6031
        case ID_LED_ON1_ON2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6032
        case ID_LED_ON1_OFF2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6033
            hw->ledctl_mode1 &= ~(ledctl_mask << (i << 3));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6034
            hw->ledctl_mode1 |= ledctl_on << (i << 3);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6035
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6036
        case ID_LED_OFF1_DEF2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6037
        case ID_LED_OFF1_ON2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6038
        case ID_LED_OFF1_OFF2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6039
            hw->ledctl_mode1 &= ~(ledctl_mask << (i << 3));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6040
            hw->ledctl_mode1 |= ledctl_off << (i << 3);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6041
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6042
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6043
            /* Do nothing */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6044
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6045
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6046
        switch(temp) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6047
        case ID_LED_DEF1_ON2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6048
        case ID_LED_ON1_ON2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6049
        case ID_LED_OFF1_ON2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6050
            hw->ledctl_mode2 &= ~(ledctl_mask << (i << 3));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6051
            hw->ledctl_mode2 |= ledctl_on << (i << 3);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6052
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6053
        case ID_LED_DEF1_OFF2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6054
        case ID_LED_ON1_OFF2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6055
        case ID_LED_OFF1_OFF2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6056
            hw->ledctl_mode2 &= ~(ledctl_mask << (i << 3));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6057
            hw->ledctl_mode2 |= ledctl_off << (i << 3);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6058
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6059
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6060
            /* Do nothing */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6061
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6062
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6063
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6064
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6065
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6066
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6067
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6068
 * Prepares SW controlable LED for use and saves the current state of the LED.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6069
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6070
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6071
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6072
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6073
e1000_setup_led(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6074
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6075
    uint32_t ledctl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6076
    int32_t ret_val = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6077
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6078
    DEBUGFUNC("e1000_setup_led");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6079
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6080
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6081
    case e1000_82542_rev2_0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6082
    case e1000_82542_rev2_1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6083
    case e1000_82543:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6084
    case e1000_82544:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6085
        /* No setup necessary */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6086
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6087
    case e1000_82541:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6088
    case e1000_82547:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6089
    case e1000_82541_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6090
    case e1000_82547_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6091
        /* Turn off PHY Smart Power Down (if enabled) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6092
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_GMII_FIFO,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6093
                                     &hw->phy_spd_default);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6094
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6095
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6096
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6097
                                      (uint16_t)(hw->phy_spd_default &
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6098
                                      ~IGP01E1000_GMII_SPD));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6099
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6100
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6101
        /* Fall Through */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6102
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6103
        if(hw->media_type == e1000_media_type_fiber) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6104
            ledctl = E1000_READ_REG(hw, LEDCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6105
            /* Save current LEDCTL settings */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6106
            hw->ledctl_default = ledctl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6107
            /* Turn off LED0 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6108
            ledctl &= ~(E1000_LEDCTL_LED0_IVRT |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6109
                        E1000_LEDCTL_LED0_BLINK |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6110
                        E1000_LEDCTL_LED0_MODE_MASK);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6111
            ledctl |= (E1000_LEDCTL_MODE_LED_OFF <<
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6112
                       E1000_LEDCTL_LED0_MODE_SHIFT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6113
            E1000_WRITE_REG(hw, LEDCTL, ledctl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6114
        } else if(hw->media_type == e1000_media_type_copper)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6115
            E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6116
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6117
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6118
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6119
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6120
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6121
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6122
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6123
 * Used on 82571 and later Si that has LED blink bits.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6124
 * Callers must use their own timer and should have already called
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6125
 * e1000_id_led_init()
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6126
 * Call e1000_cleanup led() to stop blinking
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6127
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6128
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6129
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6130
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6131
e1000_blink_led_start(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6132
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6133
    int16_t  i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6134
    uint32_t ledctl_blink = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6135
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6136
    DEBUGFUNC("e1000_id_led_blink_on");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6137
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6138
    if (hw->mac_type < e1000_82571) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6139
        /* Nothing to do */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6140
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6141
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6142
    if (hw->media_type == e1000_media_type_fiber) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6143
        /* always blink LED0 for PCI-E fiber */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6144
        ledctl_blink = E1000_LEDCTL_LED0_BLINK |
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6145
                     (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6146
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6147
        /* set the blink bit for each LED that's "on" (0x0E) in ledctl_mode2 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6148
        ledctl_blink = hw->ledctl_mode2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6149
        for (i=0; i < 4; i++)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6150
            if (((hw->ledctl_mode2 >> (i * 8)) & 0xFF) ==
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6151
                E1000_LEDCTL_MODE_LED_ON)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6152
                ledctl_blink |= (E1000_LEDCTL_LED0_BLINK << (i * 8));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6153
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6154
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6155
    E1000_WRITE_REG(hw, LEDCTL, ledctl_blink);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6156
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6157
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6158
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6159
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6160
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6161
 * Restores the saved state of the SW controlable LED.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6162
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6163
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6164
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6165
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6166
e1000_cleanup_led(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6167
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6168
    int32_t ret_val = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6169
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6170
    DEBUGFUNC("e1000_cleanup_led");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6171
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6172
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6173
    case e1000_82542_rev2_0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6174
    case e1000_82542_rev2_1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6175
    case e1000_82543:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6176
    case e1000_82544:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6177
        /* No cleanup necessary */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6178
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6179
    case e1000_82541:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6180
    case e1000_82547:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6181
    case e1000_82541_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6182
    case e1000_82547_rev_2:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6183
        /* Turn on PHY Smart Power Down (if previously enabled) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6184
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6185
                                      hw->phy_spd_default);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6186
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6187
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6188
        /* Fall Through */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6189
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6190
        if (hw->phy_type == e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6191
            e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6192
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6193
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6194
        /* Restore LEDCTL settings */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6195
        E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_default);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6196
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6197
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6198
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6199
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6200
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6201
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6202
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6203
 * Turns on the software controllable LED
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6204
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6205
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6206
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6207
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6208
e1000_led_on(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6209
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6210
    uint32_t ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6211
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6212
    DEBUGFUNC("e1000_led_on");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6213
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6214
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6215
    case e1000_82542_rev2_0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6216
    case e1000_82542_rev2_1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6217
    case e1000_82543:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6218
        /* Set SW Defineable Pin 0 to turn on the LED */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6219
        ctrl |= E1000_CTRL_SWDPIN0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6220
        ctrl |= E1000_CTRL_SWDPIO0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6221
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6222
    case e1000_82544:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6223
        if(hw->media_type == e1000_media_type_fiber) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6224
            /* Set SW Defineable Pin 0 to turn on the LED */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6225
            ctrl |= E1000_CTRL_SWDPIN0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6226
            ctrl |= E1000_CTRL_SWDPIO0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6227
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6228
            /* Clear SW Defineable Pin 0 to turn on the LED */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6229
            ctrl &= ~E1000_CTRL_SWDPIN0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6230
            ctrl |= E1000_CTRL_SWDPIO0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6231
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6232
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6233
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6234
        if(hw->media_type == e1000_media_type_fiber) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6235
            /* Clear SW Defineable Pin 0 to turn on the LED */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6236
            ctrl &= ~E1000_CTRL_SWDPIN0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6237
            ctrl |= E1000_CTRL_SWDPIO0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6238
        } else if (hw->phy_type == e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6239
            e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6240
                 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6241
        } else if (hw->media_type == e1000_media_type_copper) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6242
            E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6243
            return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6244
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6245
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6246
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6247
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6248
    E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6249
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6250
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6251
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6252
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6253
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6254
 * Turns off the software controllable LED
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6255
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6256
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6257
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6258
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6259
e1000_led_off(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6260
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6261
    uint32_t ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6262
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6263
    DEBUGFUNC("e1000_led_off");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6264
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6265
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6266
    case e1000_82542_rev2_0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6267
    case e1000_82542_rev2_1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6268
    case e1000_82543:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6269
        /* Clear SW Defineable Pin 0 to turn off the LED */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6270
        ctrl &= ~E1000_CTRL_SWDPIN0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6271
        ctrl |= E1000_CTRL_SWDPIO0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6272
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6273
    case e1000_82544:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6274
        if(hw->media_type == e1000_media_type_fiber) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6275
            /* Clear SW Defineable Pin 0 to turn off the LED */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6276
            ctrl &= ~E1000_CTRL_SWDPIN0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6277
            ctrl |= E1000_CTRL_SWDPIO0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6278
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6279
            /* Set SW Defineable Pin 0 to turn off the LED */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6280
            ctrl |= E1000_CTRL_SWDPIN0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6281
            ctrl |= E1000_CTRL_SWDPIO0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6282
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6283
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6284
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6285
        if(hw->media_type == e1000_media_type_fiber) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6286
            /* Set SW Defineable Pin 0 to turn off the LED */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6287
            ctrl |= E1000_CTRL_SWDPIN0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6288
            ctrl |= E1000_CTRL_SWDPIO0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6289
        } else if (hw->phy_type == e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6290
            e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6291
                 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6292
        } else if (hw->media_type == e1000_media_type_copper) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6293
            E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6294
            return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6295
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6296
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6297
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6298
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6299
    E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6300
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6301
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6302
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6303
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6304
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6305
 * Clears all hardware statistics counters.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6306
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6307
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6308
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6309
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6310
e1000_clear_hw_cntrs(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6311
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6312
    volatile uint32_t temp;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6313
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6314
    temp = E1000_READ_REG(hw, CRCERRS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6315
    temp = E1000_READ_REG(hw, SYMERRS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6316
    temp = E1000_READ_REG(hw, MPC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6317
    temp = E1000_READ_REG(hw, SCC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6318
    temp = E1000_READ_REG(hw, ECOL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6319
    temp = E1000_READ_REG(hw, MCC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6320
    temp = E1000_READ_REG(hw, LATECOL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6321
    temp = E1000_READ_REG(hw, COLC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6322
    temp = E1000_READ_REG(hw, DC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6323
    temp = E1000_READ_REG(hw, SEC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6324
    temp = E1000_READ_REG(hw, RLEC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6325
    temp = E1000_READ_REG(hw, XONRXC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6326
    temp = E1000_READ_REG(hw, XONTXC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6327
    temp = E1000_READ_REG(hw, XOFFRXC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6328
    temp = E1000_READ_REG(hw, XOFFTXC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6329
    temp = E1000_READ_REG(hw, FCRUC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6330
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6331
    if (hw->mac_type != e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6332
    temp = E1000_READ_REG(hw, PRC64);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6333
    temp = E1000_READ_REG(hw, PRC127);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6334
    temp = E1000_READ_REG(hw, PRC255);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6335
    temp = E1000_READ_REG(hw, PRC511);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6336
    temp = E1000_READ_REG(hw, PRC1023);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6337
    temp = E1000_READ_REG(hw, PRC1522);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6338
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6339
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6340
    temp = E1000_READ_REG(hw, GPRC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6341
    temp = E1000_READ_REG(hw, BPRC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6342
    temp = E1000_READ_REG(hw, MPRC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6343
    temp = E1000_READ_REG(hw, GPTC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6344
    temp = E1000_READ_REG(hw, GORCL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6345
    temp = E1000_READ_REG(hw, GORCH);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6346
    temp = E1000_READ_REG(hw, GOTCL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6347
    temp = E1000_READ_REG(hw, GOTCH);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6348
    temp = E1000_READ_REG(hw, RNBC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6349
    temp = E1000_READ_REG(hw, RUC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6350
    temp = E1000_READ_REG(hw, RFC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6351
    temp = E1000_READ_REG(hw, ROC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6352
    temp = E1000_READ_REG(hw, RJC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6353
    temp = E1000_READ_REG(hw, TORL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6354
    temp = E1000_READ_REG(hw, TORH);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6355
    temp = E1000_READ_REG(hw, TOTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6356
    temp = E1000_READ_REG(hw, TOTH);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6357
    temp = E1000_READ_REG(hw, TPR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6358
    temp = E1000_READ_REG(hw, TPT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6359
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6360
    if (hw->mac_type != e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6361
    temp = E1000_READ_REG(hw, PTC64);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6362
    temp = E1000_READ_REG(hw, PTC127);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6363
    temp = E1000_READ_REG(hw, PTC255);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6364
    temp = E1000_READ_REG(hw, PTC511);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6365
    temp = E1000_READ_REG(hw, PTC1023);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6366
    temp = E1000_READ_REG(hw, PTC1522);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6367
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6368
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6369
    temp = E1000_READ_REG(hw, MPTC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6370
    temp = E1000_READ_REG(hw, BPTC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6371
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6372
    if(hw->mac_type < e1000_82543) return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6373
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6374
    temp = E1000_READ_REG(hw, ALGNERRC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6375
    temp = E1000_READ_REG(hw, RXERRC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6376
    temp = E1000_READ_REG(hw, TNCRS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6377
    temp = E1000_READ_REG(hw, CEXTERR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6378
    temp = E1000_READ_REG(hw, TSCTC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6379
    temp = E1000_READ_REG(hw, TSCTFC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6380
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6381
    if(hw->mac_type <= e1000_82544) return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6382
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6383
    temp = E1000_READ_REG(hw, MGTPRC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6384
    temp = E1000_READ_REG(hw, MGTPDC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6385
    temp = E1000_READ_REG(hw, MGTPTC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6386
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6387
    if(hw->mac_type <= e1000_82547_rev_2) return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6388
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6389
    temp = E1000_READ_REG(hw, IAC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6390
    temp = E1000_READ_REG(hw, ICRXOC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6391
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6392
    if (hw->mac_type == e1000_ich8lan) return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6393
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6394
    temp = E1000_READ_REG(hw, ICRXPTC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6395
    temp = E1000_READ_REG(hw, ICRXATC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6396
    temp = E1000_READ_REG(hw, ICTXPTC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6397
    temp = E1000_READ_REG(hw, ICTXATC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6398
    temp = E1000_READ_REG(hw, ICTXQEC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6399
    temp = E1000_READ_REG(hw, ICTXQMTC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6400
    temp = E1000_READ_REG(hw, ICRXDMTC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6401
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6402
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6403
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6404
 * Resets Adaptive IFS to its default state.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6405
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6406
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6407
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6408
 * Call this after e1000_init_hw. You may override the IFS defaults by setting
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6409
 * hw->ifs_params_forced to TRUE. However, you must initialize hw->
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6410
 * current_ifs_val, ifs_min_val, ifs_max_val, ifs_step_size, and ifs_ratio
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6411
 * before calling this function.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6412
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6413
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6414
e1000_reset_adaptive(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6415
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6416
    DEBUGFUNC("e1000_reset_adaptive");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6417
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6418
    if(hw->adaptive_ifs) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6419
        if(!hw->ifs_params_forced) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6420
            hw->current_ifs_val = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6421
            hw->ifs_min_val = IFS_MIN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6422
            hw->ifs_max_val = IFS_MAX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6423
            hw->ifs_step_size = IFS_STEP;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6424
            hw->ifs_ratio = IFS_RATIO;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6425
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6426
        hw->in_ifs_mode = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6427
        E1000_WRITE_REG(hw, AIT, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6428
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6429
        DEBUGOUT("Not in Adaptive IFS mode!\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6430
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6431
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6432
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6433
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6434
 * Called during the callback/watchdog routine to update IFS value based on
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6435
 * the ratio of transmits to collisions.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6436
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6437
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6438
 * tx_packets - Number of transmits since last callback
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6439
 * total_collisions - Number of collisions since last callback
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6440
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6441
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6442
e1000_update_adaptive(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6443
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6444
    DEBUGFUNC("e1000_update_adaptive");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6445
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6446
    if(hw->adaptive_ifs) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6447
        if((hw->collision_delta * hw->ifs_ratio) > hw->tx_packet_delta) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6448
            if(hw->tx_packet_delta > MIN_NUM_XMITS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6449
                hw->in_ifs_mode = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6450
                if(hw->current_ifs_val < hw->ifs_max_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6451
                    if(hw->current_ifs_val == 0)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6452
                        hw->current_ifs_val = hw->ifs_min_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6453
                    else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6454
                        hw->current_ifs_val += hw->ifs_step_size;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6455
                    E1000_WRITE_REG(hw, AIT, hw->current_ifs_val);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6456
                }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6457
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6458
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6459
            if(hw->in_ifs_mode && (hw->tx_packet_delta <= MIN_NUM_XMITS)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6460
                hw->current_ifs_val = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6461
                hw->in_ifs_mode = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6462
                E1000_WRITE_REG(hw, AIT, 0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6463
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6464
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6465
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6466
        DEBUGOUT("Not in Adaptive IFS mode!\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6467
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6468
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6469
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6470
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6471
 * Adjusts the statistic counters when a frame is accepted by TBI_ACCEPT
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6472
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6473
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6474
 * frame_len - The length of the frame in question
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6475
 * mac_addr - The Ethernet destination address of the frame in question
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6476
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6477
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6478
e1000_tbi_adjust_stats(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6479
                       struct e1000_hw_stats *stats,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6480
                       uint32_t frame_len,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6481
                       uint8_t *mac_addr)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6482
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6483
    uint64_t carry_bit;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6484
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6485
    /* First adjust the frame length. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6486
    frame_len--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6487
    /* We need to adjust the statistics counters, since the hardware
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6488
     * counters overcount this packet as a CRC error and undercount
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6489
     * the packet as a good packet
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6490
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6491
    /* This packet should not be counted as a CRC error.    */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6492
    stats->crcerrs--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6493
    /* This packet does count as a Good Packet Received.    */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6494
    stats->gprc++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6495
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6496
    /* Adjust the Good Octets received counters             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6497
    carry_bit = 0x80000000 & stats->gorcl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6498
    stats->gorcl += frame_len;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6499
    /* If the high bit of Gorcl (the low 32 bits of the Good Octets
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6500
     * Received Count) was one before the addition,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6501
     * AND it is zero after, then we lost the carry out,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6502
     * need to add one to Gorch (Good Octets Received Count High).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6503
     * This could be simplified if all environments supported
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6504
     * 64-bit integers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6505
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6506
    if(carry_bit && ((stats->gorcl & 0x80000000) == 0))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6507
        stats->gorch++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6508
    /* Is this a broadcast or multicast?  Check broadcast first,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6509
     * since the test for a multicast frame will test positive on
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6510
     * a broadcast frame.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6511
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6512
    if((mac_addr[0] == (uint8_t) 0xff) && (mac_addr[1] == (uint8_t) 0xff))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6513
        /* Broadcast packet */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6514
        stats->bprc++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6515
    else if(*mac_addr & 0x01)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6516
        /* Multicast packet */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6517
        stats->mprc++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6518
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6519
    if(frame_len == hw->max_frame_size) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6520
        /* In this case, the hardware has overcounted the number of
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6521
         * oversize frames.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6522
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6523
        if(stats->roc > 0)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6524
            stats->roc--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6525
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6526
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6527
    /* Adjust the bin counters when the extra byte put the frame in the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6528
     * wrong bin. Remember that the frame_len was adjusted above.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6529
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6530
    if(frame_len == 64) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6531
        stats->prc64++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6532
        stats->prc127--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6533
    } else if(frame_len == 127) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6534
        stats->prc127++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6535
        stats->prc255--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6536
    } else if(frame_len == 255) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6537
        stats->prc255++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6538
        stats->prc511--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6539
    } else if(frame_len == 511) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6540
        stats->prc511++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6541
        stats->prc1023--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6542
    } else if(frame_len == 1023) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6543
        stats->prc1023++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6544
        stats->prc1522--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6545
    } else if(frame_len == 1522) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6546
        stats->prc1522++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6547
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6548
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6549
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6550
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6551
 * Gets the current PCI bus type, speed, and width of the hardware
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6552
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6553
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6554
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6555
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6556
e1000_get_bus_info(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6557
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6558
    uint32_t status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6559
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6560
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6561
    case e1000_82542_rev2_0:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6562
    case e1000_82542_rev2_1:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6563
        hw->bus_type = e1000_bus_type_unknown;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6564
        hw->bus_speed = e1000_bus_speed_unknown;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6565
        hw->bus_width = e1000_bus_width_unknown;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6566
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6567
    case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6568
    case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6569
        hw->bus_type = e1000_bus_type_pci_express;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6570
        hw->bus_speed = e1000_bus_speed_2500;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6571
        hw->bus_width = e1000_bus_width_pciex_1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6572
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6573
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6574
    case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6575
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6576
        hw->bus_type = e1000_bus_type_pci_express;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6577
        hw->bus_speed = e1000_bus_speed_2500;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6578
        hw->bus_width = e1000_bus_width_pciex_4;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6579
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6580
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6581
        status = E1000_READ_REG(hw, STATUS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6582
        hw->bus_type = (status & E1000_STATUS_PCIX_MODE) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6583
                       e1000_bus_type_pcix : e1000_bus_type_pci;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6584
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6585
        if(hw->device_id == E1000_DEV_ID_82546EB_QUAD_COPPER) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6586
            hw->bus_speed = (hw->bus_type == e1000_bus_type_pci) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6587
                            e1000_bus_speed_66 : e1000_bus_speed_120;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6588
        } else if(hw->bus_type == e1000_bus_type_pci) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6589
            hw->bus_speed = (status & E1000_STATUS_PCI66) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6590
                            e1000_bus_speed_66 : e1000_bus_speed_33;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6591
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6592
            switch (status & E1000_STATUS_PCIX_SPEED) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6593
            case E1000_STATUS_PCIX_SPEED_66:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6594
                hw->bus_speed = e1000_bus_speed_66;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6595
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6596
            case E1000_STATUS_PCIX_SPEED_100:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6597
                hw->bus_speed = e1000_bus_speed_100;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6598
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6599
            case E1000_STATUS_PCIX_SPEED_133:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6600
                hw->bus_speed = e1000_bus_speed_133;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6601
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6602
            default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6603
                hw->bus_speed = e1000_bus_speed_reserved;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6604
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6605
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6606
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6607
        hw->bus_width = (status & E1000_STATUS_BUS64) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6608
                        e1000_bus_width_64 : e1000_bus_width_32;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6609
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6610
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6611
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6612
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6613
 * Reads a value from one of the devices registers using port I/O (as opposed
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6614
 * memory mapped I/O). Only 82544 and newer devices support port I/O.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6615
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6616
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6617
 * offset - offset to read from
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6618
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6619
#if 0
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6620
uint32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6621
e1000_read_reg_io(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6622
                  uint32_t offset)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6623
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6624
    unsigned long io_addr = hw->io_base;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6625
    unsigned long io_data = hw->io_base + 4;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6626
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6627
    e1000_io_write(hw, io_addr, offset);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6628
    return e1000_io_read(hw, io_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6629
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6630
#endif  /*  0  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6631
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6632
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6633
 * Writes a value to one of the devices registers using port I/O (as opposed to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6634
 * memory mapped I/O). Only 82544 and newer devices support port I/O.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6635
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6636
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6637
 * offset - offset to write to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6638
 * value - value to write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6639
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6640
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6641
e1000_write_reg_io(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6642
                   uint32_t offset,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6643
                   uint32_t value)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6644
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6645
    unsigned long io_addr = hw->io_base;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6646
    unsigned long io_data = hw->io_base + 4;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6647
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6648
    e1000_io_write(hw, io_addr, offset);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6649
    e1000_io_write(hw, io_data, value);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6650
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6651
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6652
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6653
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6654
 * Estimates the cable length.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6655
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6656
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6657
 * min_length - The estimated minimum length
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6658
 * max_length - The estimated maximum length
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6659
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6660
 * returns: - E1000_ERR_XXX
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6661
 *            E1000_SUCCESS
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6662
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6663
 * This function always returns a ranged length (minimum & maximum).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6664
 * So for M88 phy's, this function interprets the one value returned from the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6665
 * register to the minimum and maximum range.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6666
 * For IGP phy's, the function calculates the range by the AGC registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6667
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6668
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6669
e1000_get_cable_length(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6670
                       uint16_t *min_length,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6671
                       uint16_t *max_length)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6672
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6673
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6674
    uint16_t agc_value = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6675
    uint16_t i, phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6676
    uint16_t cable_length;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6677
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6678
    DEBUGFUNC("e1000_get_cable_length");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6679
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6680
    *min_length = *max_length = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6681
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6682
    /* Use old method for Phy older than IGP */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6683
    if(hw->phy_type == e1000_phy_m88) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6684
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6685
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6686
                                     &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6687
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6688
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6689
        cable_length = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6690
                       M88E1000_PSSR_CABLE_LENGTH_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6691
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6692
        /* Convert the enum value to ranged values */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6693
        switch (cable_length) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6694
        case e1000_cable_length_50:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6695
            *min_length = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6696
            *max_length = e1000_igp_cable_length_50;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6697
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6698
        case e1000_cable_length_50_80:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6699
            *min_length = e1000_igp_cable_length_50;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6700
            *max_length = e1000_igp_cable_length_80;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6701
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6702
        case e1000_cable_length_80_110:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6703
            *min_length = e1000_igp_cable_length_80;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6704
            *max_length = e1000_igp_cable_length_110;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6705
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6706
        case e1000_cable_length_110_140:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6707
            *min_length = e1000_igp_cable_length_110;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6708
            *max_length = e1000_igp_cable_length_140;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6709
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6710
        case e1000_cable_length_140:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6711
            *min_length = e1000_igp_cable_length_140;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6712
            *max_length = e1000_igp_cable_length_170;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6713
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6714
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6715
            return -E1000_ERR_PHY;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6716
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6717
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6718
    } else if (hw->phy_type == e1000_phy_gg82563) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6719
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_DSP_DISTANCE,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6720
                                     &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6721
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6722
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6723
        cable_length = phy_data & GG82563_DSPD_CABLE_LENGTH;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6724
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6725
        switch (cable_length) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6726
        case e1000_gg_cable_length_60:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6727
            *min_length = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6728
            *max_length = e1000_igp_cable_length_60;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6729
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6730
        case e1000_gg_cable_length_60_115:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6731
            *min_length = e1000_igp_cable_length_60;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6732
            *max_length = e1000_igp_cable_length_115;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6733
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6734
        case e1000_gg_cable_length_115_150:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6735
            *min_length = e1000_igp_cable_length_115;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6736
            *max_length = e1000_igp_cable_length_150;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6737
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6738
        case e1000_gg_cable_length_150:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6739
            *min_length = e1000_igp_cable_length_150;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6740
            *max_length = e1000_igp_cable_length_180;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6741
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6742
        default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6743
            return -E1000_ERR_PHY;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6744
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6745
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6746
    } else if(hw->phy_type == e1000_phy_igp) { /* For IGP PHY */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6747
        uint16_t cur_agc_value;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6748
        uint16_t min_agc_value = IGP01E1000_AGC_LENGTH_TABLE_SIZE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6749
        uint16_t agc_reg_array[IGP01E1000_PHY_CHANNEL_NUM] =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6750
                                                         {IGP01E1000_PHY_AGC_A,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6751
                                                          IGP01E1000_PHY_AGC_B,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6752
                                                          IGP01E1000_PHY_AGC_C,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6753
                                                          IGP01E1000_PHY_AGC_D};
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6754
        /* Read the AGC registers for all channels */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6755
        for(i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6756
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6757
            ret_val = e1000_read_phy_reg(hw, agc_reg_array[i], &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6758
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6759
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6760
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6761
            cur_agc_value = phy_data >> IGP01E1000_AGC_LENGTH_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6762
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6763
            /* Value bound check. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6764
            if ((cur_agc_value >= IGP01E1000_AGC_LENGTH_TABLE_SIZE - 1) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6765
                (cur_agc_value == 0))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6766
                return -E1000_ERR_PHY;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6767
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6768
            agc_value += cur_agc_value;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6769
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6770
            /* Update minimal AGC value. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6771
            if (min_agc_value > cur_agc_value)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6772
                min_agc_value = cur_agc_value;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6773
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6774
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6775
        /* Remove the minimal AGC result for length < 50m */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6776
        if (agc_value < IGP01E1000_PHY_CHANNEL_NUM * e1000_igp_cable_length_50) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6777
            agc_value -= min_agc_value;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6778
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6779
            /* Get the average length of the remaining 3 channels */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6780
            agc_value /= (IGP01E1000_PHY_CHANNEL_NUM - 1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6781
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6782
            /* Get the average length of all the 4 channels. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6783
            agc_value /= IGP01E1000_PHY_CHANNEL_NUM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6784
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6785
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6786
        /* Set the range of the calculated length. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6787
        *min_length = ((e1000_igp_cable_length_table[agc_value] -
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6788
                       IGP01E1000_AGC_RANGE) > 0) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6789
                       (e1000_igp_cable_length_table[agc_value] -
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6790
                       IGP01E1000_AGC_RANGE) : 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6791
        *max_length = e1000_igp_cable_length_table[agc_value] +
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6792
                      IGP01E1000_AGC_RANGE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6793
    } else if (hw->phy_type == e1000_phy_igp_2 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6794
               hw->phy_type == e1000_phy_igp_3) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6795
        uint16_t cur_agc_index, max_agc_index = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6796
        uint16_t min_agc_index = IGP02E1000_AGC_LENGTH_TABLE_SIZE - 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6797
        uint16_t agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6798
                                                         {IGP02E1000_PHY_AGC_A,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6799
                                                          IGP02E1000_PHY_AGC_B,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6800
                                                          IGP02E1000_PHY_AGC_C,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6801
                                                          IGP02E1000_PHY_AGC_D};
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6802
        /* Read the AGC registers for all channels */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6803
        for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6804
            ret_val = e1000_read_phy_reg(hw, agc_reg_array[i], &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6805
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6806
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6807
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6808
	    /* Getting bits 15:9, which represent the combination of course and
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6809
             * fine gain values.  The result is a number that can be put into
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6810
             * the lookup table to obtain the approximate cable length. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6811
            cur_agc_index = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) &
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6812
                            IGP02E1000_AGC_LENGTH_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6813
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6814
            /* Array index bound check. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6815
            if ((cur_agc_index >= IGP02E1000_AGC_LENGTH_TABLE_SIZE) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6816
                (cur_agc_index == 0))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6817
                return -E1000_ERR_PHY;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6818
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6819
            /* Remove min & max AGC values from calculation. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6820
            if (e1000_igp_2_cable_length_table[min_agc_index] >
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6821
                e1000_igp_2_cable_length_table[cur_agc_index])
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6822
                min_agc_index = cur_agc_index;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6823
            if (e1000_igp_2_cable_length_table[max_agc_index] <
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6824
                e1000_igp_2_cable_length_table[cur_agc_index])
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6825
                max_agc_index = cur_agc_index;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6826
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6827
            agc_value += e1000_igp_2_cable_length_table[cur_agc_index];
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6828
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6829
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6830
        agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] +
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6831
                      e1000_igp_2_cable_length_table[max_agc_index]);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6832
        agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6833
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6834
        /* Calculate cable length with the error range of +/- 10 meters. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6835
        *min_length = ((agc_value - IGP02E1000_AGC_RANGE) > 0) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6836
                       (agc_value - IGP02E1000_AGC_RANGE) : 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6837
        *max_length = agc_value + IGP02E1000_AGC_RANGE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6838
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6839
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6840
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6841
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6842
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6843
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6844
 * Check the cable polarity
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6845
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6846
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6847
 * polarity - output parameter : 0 - Polarity is not reversed
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6848
 *                               1 - Polarity is reversed.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6849
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6850
 * returns: - E1000_ERR_XXX
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6851
 *            E1000_SUCCESS
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6852
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6853
 * For phy's older then IGP, this function simply reads the polarity bit in the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6854
 * Phy Status register.  For IGP phy's, this bit is valid only if link speed is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6855
 * 10 Mbps.  If the link speed is 100 Mbps there is no polarity so this bit will
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6856
 * return 0.  If the link speed is 1000 Mbps the polarity status is in the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6857
 * IGP01E1000_PHY_PCS_INIT_REG.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6858
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6859
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6860
e1000_check_polarity(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6861
                     uint16_t *polarity)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6862
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6863
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6864
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6865
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6866
    DEBUGFUNC("e1000_check_polarity");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6867
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6868
    if ((hw->phy_type == e1000_phy_m88) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6869
        (hw->phy_type == e1000_phy_gg82563)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6870
        /* return the Polarity bit in the Status register. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6871
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6872
                                     &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6873
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6874
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6875
        *polarity = (phy_data & M88E1000_PSSR_REV_POLARITY) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6876
                    M88E1000_PSSR_REV_POLARITY_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6877
    } else if (hw->phy_type == e1000_phy_igp ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6878
              hw->phy_type == e1000_phy_igp_3 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6879
              hw->phy_type == e1000_phy_igp_2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6880
        /* Read the Status register to check the speed */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6881
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6882
                                     &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6883
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6884
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6885
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6886
        /* If speed is 1000 Mbps, must read the IGP01E1000_PHY_PCS_INIT_REG to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6887
         * find the polarity status */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6888
        if((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6889
           IGP01E1000_PSSR_SPEED_1000MBPS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6890
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6891
            /* Read the GIG initialization PCS register (0x00B4) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6892
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6893
                                         &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6894
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6895
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6896
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6897
            /* Check the polarity bits */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6898
            *polarity = (phy_data & IGP01E1000_PHY_POLARITY_MASK) ? 1 : 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6899
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6900
            /* For 10 Mbps, read the polarity bit in the status register. (for
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6901
             * 100 Mbps this bit is always 0) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6902
            *polarity = phy_data & IGP01E1000_PSSR_POLARITY_REVERSED;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6903
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6904
    } else if (hw->phy_type == e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6905
        ret_val = e1000_read_phy_reg(hw, IFE_PHY_EXTENDED_STATUS_CONTROL,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6906
                                     &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6907
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6908
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6909
        *polarity = (phy_data & IFE_PESC_POLARITY_REVERSED) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6910
                           IFE_PESC_POLARITY_REVERSED_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6911
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6912
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6913
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6914
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6915
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6916
 * Check if Downshift occured
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6917
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6918
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6919
 * downshift - output parameter : 0 - No Downshift ocured.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6920
 *                                1 - Downshift ocured.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6921
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6922
 * returns: - E1000_ERR_XXX
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6923
 *            E1000_SUCCESS
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6924
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6925
 * For phy's older then IGP, this function reads the Downshift bit in the Phy
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6926
 * Specific Status register.  For IGP phy's, it reads the Downgrade bit in the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6927
 * Link Health register.  In IGP this bit is latched high, so the driver must
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6928
 * read it immediately after link is established.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6929
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6930
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6931
e1000_check_downshift(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6932
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6933
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6934
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6935
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6936
    DEBUGFUNC("e1000_check_downshift");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6937
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6938
    if (hw->phy_type == e1000_phy_igp ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6939
        hw->phy_type == e1000_phy_igp_3 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6940
        hw->phy_type == e1000_phy_igp_2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6941
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6942
                                     &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6943
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6944
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6945
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6946
        hw->speed_downgraded = (phy_data & IGP01E1000_PLHR_SS_DOWNGRADE) ? 1 : 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6947
    } else if ((hw->phy_type == e1000_phy_m88) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6948
               (hw->phy_type == e1000_phy_gg82563)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6949
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6950
                                     &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6951
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6952
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6953
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6954
        hw->speed_downgraded = (phy_data & M88E1000_PSSR_DOWNSHIFT) >>
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6955
                               M88E1000_PSSR_DOWNSHIFT_SHIFT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6956
    } else if (hw->phy_type == e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6957
        /* e1000_phy_ife supports 10/100 speed only */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6958
        hw->speed_downgraded = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6959
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6960
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6961
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6962
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6963
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6964
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6965
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6966
 * 82541_rev_2 & 82547_rev_2 have the capability to configure the DSP when a
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6967
 * gigabit link is achieved to improve link quality.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6968
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6969
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6970
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6971
 * returns: - E1000_ERR_PHY if fail to read/write the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6972
 *            E1000_SUCCESS at any other case.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6973
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6974
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6975
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6976
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6977
e1000_config_dsp_after_link_change(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6978
                                   boolean_t link_up)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6979
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6980
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6981
    uint16_t phy_data, phy_saved_data, speed, duplex, i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6982
    uint16_t dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6983
                                        {IGP01E1000_PHY_AGC_PARAM_A,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6984
                                        IGP01E1000_PHY_AGC_PARAM_B,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6985
                                        IGP01E1000_PHY_AGC_PARAM_C,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6986
                                        IGP01E1000_PHY_AGC_PARAM_D};
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6987
    uint16_t min_length, max_length;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6988
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6989
    DEBUGFUNC("e1000_config_dsp_after_link_change");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6990
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6991
    if(hw->phy_type != e1000_phy_igp)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6992
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6993
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6994
    if(link_up) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6995
        ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6996
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6997
            DEBUGOUT("Error getting link speed and duplex\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6998
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6999
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7000
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7001
        if(speed == SPEED_1000) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7002
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7003
            ret_val = e1000_get_cable_length(hw, &min_length, &max_length);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7004
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7005
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7006
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7007
            if((hw->dsp_config_state == e1000_dsp_config_enabled) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7008
                min_length >= e1000_igp_cable_length_50) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7009
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7010
                for(i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7011
                    ret_val = e1000_read_phy_reg(hw, dsp_reg_array[i],
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7012
                                                 &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7013
                    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7014
                        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7015
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7016
                    phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7017
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7018
                    ret_val = e1000_write_phy_reg(hw, dsp_reg_array[i],
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7019
                                                  phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7020
                    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7021
                        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7022
                }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7023
                hw->dsp_config_state = e1000_dsp_config_activated;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7024
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7025
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7026
            if((hw->ffe_config_state == e1000_ffe_config_enabled) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7027
               (min_length < e1000_igp_cable_length_50)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7028
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7029
                uint16_t ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7030
                uint32_t idle_errs = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7031
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7032
                /* clear previous idle error counts */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7033
                ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7034
                                             &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7035
                if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7036
                    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7037
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7038
                for(i = 0; i < ffe_idle_err_timeout; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7039
                    udelay(1000);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7040
                    ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7041
                                                 &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7042
                    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7043
                        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7044
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7045
                    idle_errs += (phy_data & SR_1000T_IDLE_ERROR_CNT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7046
                    if(idle_errs > SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7047
                        hw->ffe_config_state = e1000_ffe_config_active;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7048
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7049
                        ret_val = e1000_write_phy_reg(hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7050
                                    IGP01E1000_PHY_DSP_FFE,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7051
                                    IGP01E1000_PHY_DSP_FFE_CM_CP);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7052
                        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7053
                            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7054
                        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7055
                    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7056
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7057
                    if(idle_errs)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7058
                        ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_100;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7059
                }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7060
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7061
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7062
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7063
        if(hw->dsp_config_state == e1000_dsp_config_activated) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7064
            /* Save off the current value of register 0x2F5B to be restored at
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7065
             * the end of the routines. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7066
            ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7067
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7068
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7069
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7070
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7071
            /* Disable the PHY transmitter */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7072
            ret_val = e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7073
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7074
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7075
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7076
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7077
            msec_delay_irq(20);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7078
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7079
            ret_val = e1000_write_phy_reg(hw, 0x0000,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7080
                                          IGP01E1000_IEEE_FORCE_GIGA);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7081
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7082
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7083
            for(i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7084
                ret_val = e1000_read_phy_reg(hw, dsp_reg_array[i], &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7085
                if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7086
                    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7087
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7088
                phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7089
                phy_data |=  IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7090
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7091
                ret_val = e1000_write_phy_reg(hw,dsp_reg_array[i], phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7092
                if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7093
                    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7094
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7095
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7096
            ret_val = e1000_write_phy_reg(hw, 0x0000,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7097
                                          IGP01E1000_IEEE_RESTART_AUTONEG);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7098
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7099
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7100
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7101
            msec_delay_irq(20);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7102
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7103
            /* Now enable the transmitter */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7104
            ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7105
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7106
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7107
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7108
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7109
            hw->dsp_config_state = e1000_dsp_config_enabled;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7110
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7111
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7112
        if(hw->ffe_config_state == e1000_ffe_config_active) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7113
            /* Save off the current value of register 0x2F5B to be restored at
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7114
             * the end of the routines. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7115
            ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7116
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7117
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7118
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7119
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7120
            /* Disable the PHY transmitter */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7121
            ret_val = e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7122
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7123
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7124
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7125
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7126
            msec_delay_irq(20);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7127
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7128
            ret_val = e1000_write_phy_reg(hw, 0x0000,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7129
                                          IGP01E1000_IEEE_FORCE_GIGA);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7130
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7131
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7132
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_DSP_FFE,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7133
                                          IGP01E1000_PHY_DSP_FFE_DEFAULT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7134
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7135
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7136
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7137
            ret_val = e1000_write_phy_reg(hw, 0x0000,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7138
                                          IGP01E1000_IEEE_RESTART_AUTONEG);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7139
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7140
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7141
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7142
            msec_delay_irq(20);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7143
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7144
            /* Now enable the transmitter */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7145
            ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7146
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7147
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7148
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7149
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7150
            hw->ffe_config_state = e1000_ffe_config_enabled;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7151
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7152
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7153
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7154
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7155
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7156
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7157
 * Set PHY to class A mode
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7158
 * Assumes the following operations will follow to enable the new class mode.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7159
 *  1. Do a PHY soft reset
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7160
 *  2. Restart auto-negotiation or force link.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7161
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7162
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7163
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7164
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7165
e1000_set_phy_mode(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7166
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7167
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7168
    uint16_t eeprom_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7169
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7170
    DEBUGFUNC("e1000_set_phy_mode");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7171
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7172
    if((hw->mac_type == e1000_82545_rev_3) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7173
       (hw->media_type == e1000_media_type_copper)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7174
        ret_val = e1000_read_eeprom(hw, EEPROM_PHY_CLASS_WORD, 1, &eeprom_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7175
        if(ret_val) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7176
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7177
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7178
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7179
        if((eeprom_data != EEPROM_RESERVED_WORD) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7180
           (eeprom_data & EEPROM_PHY_CLASS_A)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7181
            ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x000B);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7182
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7183
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7184
            ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0x8104);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7185
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7186
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7187
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7188
            hw->phy_reset_disable = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7189
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7190
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7191
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7192
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7193
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7194
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7195
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7196
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7197
 * This function sets the lplu state according to the active flag.  When
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7198
 * activating lplu this function also disables smart speed and vise versa.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7199
 * lplu will not be activated unless the device autonegotiation advertisment
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7200
 * meets standards of either 10 or 10/100 or 10/100/1000 at all duplexes.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7201
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7202
 * active - true to enable lplu false to disable lplu.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7203
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7204
 * returns: - E1000_ERR_PHY if fail to read/write the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7205
 *            E1000_SUCCESS at any other case.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7206
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7207
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7208
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7209
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7210
e1000_set_d3_lplu_state(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7211
                        boolean_t active)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7212
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7213
    uint32_t phy_ctrl = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7214
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7215
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7216
    DEBUGFUNC("e1000_set_d3_lplu_state");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7217
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7218
    if (hw->phy_type != e1000_phy_igp && hw->phy_type != e1000_phy_igp_2
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7219
        && hw->phy_type != e1000_phy_igp_3)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7220
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7221
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7222
    /* During driver activity LPLU should not be used or it will attain link
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7223
     * from the lowest speeds starting from 10Mbps. The capability is used for
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7224
     * Dx transitions and states */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7225
    if (hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7226
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_GMII_FIFO, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7227
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7228
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7229
    } else if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7230
        /* MAC writes into PHY register based on the state transition
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7231
         * and start auto-negotiation. SW driver can overwrite the settings
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7232
         * in CSR PHY power control E1000_PHY_CTRL register. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7233
        phy_ctrl = E1000_READ_REG(hw, PHY_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7234
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7235
        ret_val = e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7236
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7237
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7238
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7239
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7240
    if(!active) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7241
        if(hw->mac_type == e1000_82541_rev_2 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7242
           hw->mac_type == e1000_82547_rev_2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7243
            phy_data &= ~IGP01E1000_GMII_FLEX_SPD;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7244
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7245
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7246
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7247
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7248
            if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7249
                phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7250
                E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7251
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7252
                phy_data &= ~IGP02E1000_PM_D3_LPLU;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7253
                ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7254
                                              phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7255
                if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7256
                    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7257
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7258
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7259
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7260
        /* LPLU and SmartSpeed are mutually exclusive.  LPLU is used during
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7261
         * Dx states where the power conservation is most important.  During
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7262
         * driver activity we should enable SmartSpeed, so performance is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7263
         * maintained. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7264
        if (hw->smart_speed == e1000_smart_speed_on) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7265
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7266
                                         &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7267
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7268
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7269
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7270
            phy_data |= IGP01E1000_PSCFR_SMART_SPEED;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7271
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7272
                                          phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7273
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7274
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7275
        } else if (hw->smart_speed == e1000_smart_speed_off) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7276
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7277
                                         &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7278
	    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7279
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7280
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7281
            phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7282
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7283
                                          phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7284
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7285
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7286
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7287
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7288
    } else if((hw->autoneg_advertised == AUTONEG_ADVERTISE_SPEED_DEFAULT) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7289
              (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_ALL ) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7290
              (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_100_ALL)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7291
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7292
        if(hw->mac_type == e1000_82541_rev_2 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7293
            hw->mac_type == e1000_82547_rev_2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7294
            phy_data |= IGP01E1000_GMII_FLEX_SPD;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7295
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7296
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7297
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7298
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7299
            if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7300
                phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7301
                E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7302
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7303
                phy_data |= IGP02E1000_PM_D3_LPLU;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7304
                ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7305
                                              phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7306
                if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7307
                    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7308
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7309
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7310
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7311
        /* When LPLU is enabled we should disable SmartSpeed */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7312
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7313
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7314
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7315
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7316
        phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7317
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7318
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7319
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7320
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7321
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7322
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7323
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7324
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7325
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7326
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7327
 * This function sets the lplu d0 state according to the active flag.  When
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7328
 * activating lplu this function also disables smart speed and vise versa.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7329
 * lplu will not be activated unless the device autonegotiation advertisment
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7330
 * meets standards of either 10 or 10/100 or 10/100/1000 at all duplexes.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7331
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7332
 * active - true to enable lplu false to disable lplu.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7333
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7334
 * returns: - E1000_ERR_PHY if fail to read/write the PHY
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7335
 *            E1000_SUCCESS at any other case.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7336
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7337
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7338
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7339
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7340
e1000_set_d0_lplu_state(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7341
                        boolean_t active)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7342
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7343
    uint32_t phy_ctrl = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7344
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7345
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7346
    DEBUGFUNC("e1000_set_d0_lplu_state");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7347
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7348
    if(hw->mac_type <= e1000_82547_rev_2)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7349
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7350
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7351
    if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7352
        phy_ctrl = E1000_READ_REG(hw, PHY_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7353
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7354
        ret_val = e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7355
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7356
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7357
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7358
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7359
    if (!active) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7360
        if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7361
            phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7362
            E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7363
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7364
            phy_data &= ~IGP02E1000_PM_D0_LPLU;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7365
            ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7366
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7367
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7368
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7369
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7370
        /* LPLU and SmartSpeed are mutually exclusive.  LPLU is used during
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7371
         * Dx states where the power conservation is most important.  During
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7372
         * driver activity we should enable SmartSpeed, so performance is
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7373
         * maintained. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7374
        if (hw->smart_speed == e1000_smart_speed_on) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7375
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7376
                                         &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7377
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7378
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7379
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7380
            phy_data |= IGP01E1000_PSCFR_SMART_SPEED;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7381
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7382
                                          phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7383
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7384
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7385
        } else if (hw->smart_speed == e1000_smart_speed_off) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7386
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7387
                                         &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7388
	    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7389
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7390
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7391
            phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7392
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7393
                                          phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7394
            if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7395
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7396
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7397
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7398
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7399
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7400
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7401
        if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7402
            phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7403
            E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7404
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7405
            phy_data |= IGP02E1000_PM_D0_LPLU;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7406
            ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7407
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7408
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7409
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7410
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7411
        /* When LPLU is enabled we should disable SmartSpeed */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7412
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7413
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7414
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7415
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7416
        phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7417
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7418
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7419
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7420
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7421
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7422
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7423
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7424
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7425
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7426
 * Change VCO speed register to improve Bit Error Rate performance of SERDES.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7427
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7428
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7429
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7430
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7431
e1000_set_vco_speed(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7432
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7433
    int32_t  ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7434
    uint16_t default_page = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7435
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7436
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7437
    DEBUGFUNC("e1000_set_vco_speed");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7438
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7439
    switch(hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7440
    case e1000_82545_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7441
    case e1000_82546_rev_3:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7442
       break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7443
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7444
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7445
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7446
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7447
    /* Set PHY register 30, page 5, bit 8 to 0 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7448
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7449
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, &default_page);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7450
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7451
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7452
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7453
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0005);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7454
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7455
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7456
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7457
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7458
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7459
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7460
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7461
    phy_data &= ~M88E1000_PHY_VCO_REG_BIT8;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7462
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7463
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7464
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7465
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7466
    /* Set PHY register 30, page 4, bit 11 to 1 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7467
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7468
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0004);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7469
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7470
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7471
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7472
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7473
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7474
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7475
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7476
    phy_data |= M88E1000_PHY_VCO_REG_BIT11;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7477
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7478
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7479
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7480
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7481
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, default_page);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7482
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7483
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7484
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7485
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7486
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7487
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7488
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7489
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7490
 * This function reads the cookie from ARC ram.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7491
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7492
 * returns: - E1000_SUCCESS .
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7493
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7494
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7495
e1000_host_if_read_cookie(struct e1000_hw * hw, uint8_t *buffer)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7496
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7497
    uint8_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7498
    uint32_t offset = E1000_MNG_DHCP_COOKIE_OFFSET;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7499
    uint8_t length = E1000_MNG_DHCP_COOKIE_LENGTH;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7500
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7501
    length = (length >> 2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7502
    offset = (offset >> 2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7503
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7504
    for (i = 0; i < length; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7505
        *((uint32_t *) buffer + i) =
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7506
            E1000_READ_REG_ARRAY_DWORD(hw, HOST_IF, offset + i);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7507
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7508
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7509
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7510
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7511
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7512
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7513
 * This function checks whether the HOST IF is enabled for command operaton
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7514
 * and also checks whether the previous command is completed.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7515
 * It busy waits in case of previous command is not completed.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7516
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7517
 * returns: - E1000_ERR_HOST_INTERFACE_COMMAND in case if is not ready or
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7518
 *            timeout
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7519
 *          - E1000_SUCCESS for success.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7520
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7521
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7522
e1000_mng_enable_host_if(struct e1000_hw * hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7523
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7524
    uint32_t hicr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7525
    uint8_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7526
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7527
    /* Check that the host interface is enabled. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7528
    hicr = E1000_READ_REG(hw, HICR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7529
    if ((hicr & E1000_HICR_EN) == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7530
        DEBUGOUT("E1000_HOST_EN bit disabled.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7531
        return -E1000_ERR_HOST_INTERFACE_COMMAND;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7532
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7533
    /* check the previous command is completed */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7534
    for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7535
        hicr = E1000_READ_REG(hw, HICR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7536
        if (!(hicr & E1000_HICR_C))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7537
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7538
        msec_delay_irq(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7539
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7540
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7541
    if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7542
        DEBUGOUT("Previous command timeout failed .\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7543
        return -E1000_ERR_HOST_INTERFACE_COMMAND;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7544
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7545
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7546
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7547
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7548
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7549
 * This function writes the buffer content at the offset given on the host if.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7550
 * It also does alignment considerations to do the writes in most efficient way.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7551
 * Also fills up the sum of the buffer in *buffer parameter.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7552
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7553
 * returns  - E1000_SUCCESS for success.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7554
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7555
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7556
e1000_mng_host_if_write(struct e1000_hw * hw, uint8_t *buffer,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7557
                        uint16_t length, uint16_t offset, uint8_t *sum)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7558
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7559
    uint8_t *tmp;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7560
    uint8_t *bufptr = buffer;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7561
    uint32_t data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7562
    uint16_t remaining, i, j, prev_bytes;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7563
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7564
    /* sum = only sum of the data and it is not checksum */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7565
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7566
    if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7567
        return -E1000_ERR_PARAM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7568
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7569
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7570
    tmp = (uint8_t *)&data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7571
    prev_bytes = offset & 0x3;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7572
    offset &= 0xFFFC;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7573
    offset >>= 2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7574
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7575
    if (prev_bytes) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7576
        data = E1000_READ_REG_ARRAY_DWORD(hw, HOST_IF, offset);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7577
        for (j = prev_bytes; j < sizeof(uint32_t); j++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7578
            *(tmp + j) = *bufptr++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7579
            *sum += *(tmp + j);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7580
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7581
        E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, offset, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7582
        length -= j - prev_bytes;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7583
        offset++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7584
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7585
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7586
    remaining = length & 0x3;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7587
    length -= remaining;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7588
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7589
    /* Calculate length in DWORDs */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7590
    length >>= 2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7591
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7592
    /* The device driver writes the relevant command block into the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7593
     * ram area. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7594
    for (i = 0; i < length; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7595
        for (j = 0; j < sizeof(uint32_t); j++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7596
            *(tmp + j) = *bufptr++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7597
            *sum += *(tmp + j);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7598
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7599
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7600
        E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, offset + i, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7601
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7602
    if (remaining) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7603
        for (j = 0; j < sizeof(uint32_t); j++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7604
            if (j < remaining)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7605
                *(tmp + j) = *bufptr++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7606
            else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7607
                *(tmp + j) = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7608
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7609
            *sum += *(tmp + j);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7610
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7611
        E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, offset + i, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7612
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7613
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7614
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7615
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7616
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7617
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7618
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7619
 * This function writes the command header after does the checksum calculation.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7620
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7621
 * returns  - E1000_SUCCESS for success.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7622
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7623
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7624
e1000_mng_write_cmd_header(struct e1000_hw * hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7625
                           struct e1000_host_mng_command_header * hdr)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7626
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7627
    uint16_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7628
    uint8_t sum;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7629
    uint8_t *buffer;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7630
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7631
    /* Write the whole command header structure which includes sum of
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7632
     * the buffer */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7633
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7634
    uint16_t length = sizeof(struct e1000_host_mng_command_header);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7635
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7636
    sum = hdr->checksum;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7637
    hdr->checksum = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7638
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7639
    buffer = (uint8_t *) hdr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7640
    i = length;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7641
    while(i--)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7642
        sum += buffer[i];
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7643
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7644
    hdr->checksum = 0 - sum;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7645
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7646
    length >>= 2;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7647
    /* The device driver writes the relevant command block into the ram area. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7648
    for (i = 0; i < length; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7649
        E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, i, *((uint32_t *) hdr + i));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7650
        E1000_WRITE_FLUSH(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7651
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7652
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7653
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7654
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7655
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7656
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7657
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7658
 * This function indicates to ARC that a new command is pending which completes
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7659
 * one write operation by the driver.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7660
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7661
 * returns  - E1000_SUCCESS for success.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7662
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7663
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7664
e1000_mng_write_commit(
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7665
    struct e1000_hw * hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7666
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7667
    uint32_t hicr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7668
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7669
    hicr = E1000_READ_REG(hw, HICR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7670
    /* Setting this bit tells the ARC that a new command is pending. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7671
    E1000_WRITE_REG(hw, HICR, hicr | E1000_HICR_C);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7672
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7673
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7674
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7675
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7676
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7677
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7678
 * This function checks the mode of the firmware.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7679
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7680
 * returns  - TRUE when the mode is IAMT or FALSE.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7681
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7682
boolean_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7683
e1000_check_mng_mode(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7684
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7685
    uint32_t fwsm;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7686
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7687
    fwsm = E1000_READ_REG(hw, FWSM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7688
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7689
    if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7690
        if ((fwsm & E1000_FWSM_MODE_MASK) ==
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7691
            (E1000_MNG_ICH_IAMT_MODE << E1000_FWSM_MODE_SHIFT))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7692
            return TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7693
    } else if ((fwsm & E1000_FWSM_MODE_MASK) ==
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7694
               (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7695
        return TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7696
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7697
    return FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7698
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7699
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7700
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7701
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7702
 * This function writes the dhcp info .
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7703
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7704
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7705
e1000_mng_write_dhcp_info(struct e1000_hw * hw, uint8_t *buffer,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7706
			  uint16_t length)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7707
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7708
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7709
    struct e1000_host_mng_command_header hdr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7710
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7711
    hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7712
    hdr.command_length = length;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7713
    hdr.reserved1 = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7714
    hdr.reserved2 = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7715
    hdr.checksum = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7716
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7717
    ret_val = e1000_mng_enable_host_if(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7718
    if (ret_val == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7719
        ret_val = e1000_mng_host_if_write(hw, buffer, length, sizeof(hdr),
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7720
                                          &(hdr.checksum));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7721
        if (ret_val == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7722
            ret_val = e1000_mng_write_cmd_header(hw, &hdr);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7723
            if (ret_val == E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7724
                ret_val = e1000_mng_write_commit(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7725
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7726
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7727
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7728
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7729
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7730
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7731
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7732
 * This function calculates the checksum.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7733
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7734
 * returns  - checksum of buffer contents.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7735
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7736
uint8_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7737
e1000_calculate_mng_checksum(char *buffer, uint32_t length)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7738
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7739
    uint8_t sum = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7740
    uint32_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7741
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7742
    if (!buffer)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7743
        return 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7744
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7745
    for (i=0; i < length; i++)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7746
        sum += buffer[i];
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7747
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7748
    return (uint8_t) (0 - sum);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7749
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7750
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7751
/*****************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7752
 * This function checks whether tx pkt filtering needs to be enabled or not.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7753
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7754
 * returns  - TRUE for packet filtering or FALSE.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7755
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7756
boolean_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7757
e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7758
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7759
    /* called in init as well as watchdog timer functions */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7760
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7761
    int32_t ret_val, checksum;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7762
    boolean_t tx_filter = FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7763
    struct e1000_host_mng_dhcp_cookie *hdr = &(hw->mng_cookie);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7764
    uint8_t *buffer = (uint8_t *) &(hw->mng_cookie);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7765
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7766
    if (e1000_check_mng_mode(hw)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7767
        ret_val = e1000_mng_enable_host_if(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7768
        if (ret_val == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7769
            ret_val = e1000_host_if_read_cookie(hw, buffer);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7770
            if (ret_val == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7771
                checksum = hdr->checksum;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7772
                hdr->checksum = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7773
                if ((hdr->signature == E1000_IAMT_SIGNATURE) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7774
                    checksum == e1000_calculate_mng_checksum((char *)buffer,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7775
                                               E1000_MNG_DHCP_COOKIE_LENGTH)) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7776
                    if (hdr->status &
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7777
                        E1000_MNG_DHCP_COOKIE_STATUS_PARSING_SUPPORT)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7778
                        tx_filter = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7779
                } else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7780
                    tx_filter = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7781
            } else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7782
                tx_filter = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7783
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7784
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7785
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7786
    hw->tx_pkt_filtering = tx_filter;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7787
    return tx_filter;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7788
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7789
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7790
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7791
 * Verifies the hardware needs to allow ARPs to be processed by the host
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7792
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7793
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7794
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7795
 * returns: - TRUE/FALSE
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7796
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7797
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7798
uint32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7799
e1000_enable_mng_pass_thru(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7800
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7801
    uint32_t manc;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7802
    uint32_t fwsm, factps;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7803
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7804
    if (hw->asf_firmware_present) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7805
        manc = E1000_READ_REG(hw, MANC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7806
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7807
        if (!(manc & E1000_MANC_RCV_TCO_EN) ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7808
            !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7809
            return FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7810
        if (e1000_arc_subsystem_valid(hw) == TRUE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7811
            fwsm = E1000_READ_REG(hw, FWSM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7812
            factps = E1000_READ_REG(hw, FACTPS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7813
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7814
            if (((fwsm & E1000_FWSM_MODE_MASK) ==
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7815
                (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT)) &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7816
                (factps & E1000_FACTPS_MNGCG))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7817
                return TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7818
        } else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7819
            if ((manc & E1000_MANC_SMBUS_EN) && !(manc & E1000_MANC_ASF_EN))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7820
                return TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7821
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7822
    return FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7823
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7824
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7825
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7826
e1000_polarity_reversal_workaround(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7827
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7828
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7829
    uint16_t mii_status_reg;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7830
    uint16_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7831
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7832
    /* Polarity reversal workaround for forced 10F/10H links. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7833
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7834
    /* Disable the transmitter on the PHY */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7835
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7836
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0019);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7837
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7838
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7839
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFFFF);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7840
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7841
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7842
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7843
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0000);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7844
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7845
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7846
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7847
    /* This loop will early-out if the NO link condition has been met. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7848
    for(i = PHY_FORCE_TIME; i > 0; i--) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7849
        /* Read the MII Status Register and wait for Link Status bit
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7850
         * to be clear.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7851
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7852
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7853
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7854
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7855
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7856
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7857
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7858
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7859
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7860
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7861
        if((mii_status_reg & ~MII_SR_LINK_STATUS) == 0) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7862
        msec_delay_irq(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7863
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7864
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7865
    /* Recommended delay time after link has been lost */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7866
    msec_delay_irq(1000);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7867
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7868
    /* Now we will re-enable th transmitter on the PHY */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7869
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7870
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0019);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7871
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7872
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7873
    msec_delay_irq(50);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7874
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFFF0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7875
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7876
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7877
    msec_delay_irq(50);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7878
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFF00);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7879
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7880
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7881
    msec_delay_irq(50);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7882
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0x0000);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7883
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7884
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7885
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7886
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0000);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7887
    if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7888
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7889
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7890
    /* This loop will early-out if the link condition has been met. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7891
    for(i = PHY_FORCE_TIME; i > 0; i--) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7892
        /* Read the MII Status Register and wait for Link Status bit
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7893
         * to be set.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7894
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7895
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7896
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7897
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7898
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7899
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7900
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7901
        if(ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7902
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7903
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7904
        if(mii_status_reg & MII_SR_LINK_STATUS) break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7905
        msec_delay_irq(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7906
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7907
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7908
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7909
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7910
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7911
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7912
 * Disables PCI-Express master access.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7913
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7914
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7915
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7916
 * returns: - none.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7917
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7918
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7919
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7920
e1000_set_pci_express_master_disable(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7921
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7922
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7923
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7924
    DEBUGFUNC("e1000_set_pci_express_master_disable");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7925
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7926
    if (hw->bus_type != e1000_bus_type_pci_express)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7927
        return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7928
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7929
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7930
    ctrl |= E1000_CTRL_GIO_MASTER_DISABLE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7931
    E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7932
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7933
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7934
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7935
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7936
 * Enables PCI-Express master access.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7937
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7938
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7939
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7940
 * returns: - none.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7941
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7942
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7943
#if 0
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7944
void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7945
e1000_enable_pciex_master(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7946
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7947
    uint32_t ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7948
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7949
    DEBUGFUNC("e1000_enable_pciex_master");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7950
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7951
    if (hw->bus_type != e1000_bus_type_pci_express)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7952
        return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7953
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7954
    ctrl = E1000_READ_REG(hw, CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7955
    ctrl &= ~E1000_CTRL_GIO_MASTER_DISABLE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7956
    E1000_WRITE_REG(hw, CTRL, ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7957
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7958
#endif  /*  0  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7959
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7960
/*******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7961
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7962
 * Disables PCI-Express master access and verifies there are no pending requests
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7963
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7964
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7965
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7966
 * returns: - E1000_ERR_MASTER_REQUESTS_PENDING if master disable bit hasn't
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7967
 *            caused the master requests to be disabled.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7968
 *            E1000_SUCCESS master requests disabled.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7969
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7970
 ******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7971
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7972
e1000_disable_pciex_master(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7973
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7974
    int32_t timeout = MASTER_DISABLE_TIMEOUT;   /* 80ms */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7975
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7976
    DEBUGFUNC("e1000_disable_pciex_master");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7977
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7978
    if (hw->bus_type != e1000_bus_type_pci_express)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7979
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7980
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7981
    e1000_set_pci_express_master_disable(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7982
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7983
    while(timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7984
        if(!(E1000_READ_REG(hw, STATUS) & E1000_STATUS_GIO_MASTER_ENABLE))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7985
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7986
        else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7987
            udelay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7988
        timeout--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7989
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7990
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7991
    if(!timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7992
        DEBUGOUT("Master requests are pending.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7993
        return -E1000_ERR_MASTER_REQUESTS_PENDING;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7994
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7995
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7996
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7997
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7998
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7999
/*******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8000
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8001
 * Check for EEPROM Auto Read bit done.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8002
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8003
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8004
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8005
 * returns: - E1000_ERR_RESET if fail to reset MAC
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8006
 *            E1000_SUCCESS at any other case.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8007
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8008
 ******************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8009
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8010
e1000_get_auto_rd_done(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8011
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8012
    int32_t timeout = AUTO_READ_DONE_TIMEOUT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8013
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8014
    DEBUGFUNC("e1000_get_auto_rd_done");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8015
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8016
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8017
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8018
        msec_delay(5);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8019
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8020
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8021
    case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8022
    case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8023
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8024
    case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8025
        while (timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8026
            if (E1000_READ_REG(hw, EECD) & E1000_EECD_AUTO_RD)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8027
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8028
            else msec_delay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8029
            timeout--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8030
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8031
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8032
        if(!timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8033
            DEBUGOUT("Auto read by HW from EEPROM has not completed.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8034
            return -E1000_ERR_RESET;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8035
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8036
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8037
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8038
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8039
    /* PHY configuration from NVM just starts after EECD_AUTO_RD sets to high.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8040
     * Need to wait for PHY configuration completion before accessing NVM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8041
     * and PHY. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8042
    if (hw->mac_type == e1000_82573)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8043
        msec_delay(25);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8044
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8045
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8046
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8047
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8048
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8049
 * Checks if the PHY configuration is done
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8050
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8051
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8052
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8053
 * returns: - E1000_ERR_RESET if fail to reset MAC
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8054
 *            E1000_SUCCESS at any other case.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8055
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8056
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8057
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8058
e1000_get_phy_cfg_done(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8059
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8060
    int32_t timeout = PHY_CFG_TIMEOUT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8061
    uint32_t cfg_mask = E1000_EEPROM_CFG_DONE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8062
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8063
    DEBUGFUNC("e1000_get_phy_cfg_done");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8064
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8065
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8066
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8067
        msec_delay_irq(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8068
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8069
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8070
        /* Separate *_CFG_DONE_* bit for each port */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8071
        if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8072
            cfg_mask = E1000_EEPROM_CFG_DONE_PORT_1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8073
        /* Fall Through */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8074
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8075
    case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8076
        while (timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8077
            if (E1000_READ_REG(hw, EEMNGCTL) & cfg_mask)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8078
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8079
            else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8080
                msec_delay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8081
            timeout--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8082
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8083
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8084
        if (!timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8085
            DEBUGOUT("MNG configuration cycle has not completed.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8086
            return -E1000_ERR_RESET;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8087
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8088
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8089
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8090
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8091
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8092
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8093
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8094
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8095
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8096
 * Using the combination of SMBI and SWESMBI semaphore bits when resetting
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8097
 * adapter or Eeprom access.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8098
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8099
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8100
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8101
 * returns: - E1000_ERR_EEPROM if fail to access EEPROM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8102
 *            E1000_SUCCESS at any other case.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8103
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8104
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8105
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8106
e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8107
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8108
    int32_t timeout;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8109
    uint32_t swsm;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8110
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8111
    DEBUGFUNC("e1000_get_hw_eeprom_semaphore");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8112
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8113
    if(!hw->eeprom_semaphore_present)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8114
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8115
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8116
    if (hw->mac_type == e1000_80003es2lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8117
        /* Get the SW semaphore. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8118
        if (e1000_get_software_semaphore(hw) != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8119
            return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8120
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8121
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8122
    /* Get the FW semaphore. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8123
    timeout = hw->eeprom.word_size + 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8124
    while(timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8125
        swsm = E1000_READ_REG(hw, SWSM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8126
        swsm |= E1000_SWSM_SWESMBI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8127
        E1000_WRITE_REG(hw, SWSM, swsm);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8128
        /* if we managed to set the bit we got the semaphore. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8129
        swsm = E1000_READ_REG(hw, SWSM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8130
        if(swsm & E1000_SWSM_SWESMBI)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8131
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8132
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8133
        udelay(50);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8134
        timeout--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8135
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8136
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8137
    if(!timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8138
        /* Release semaphores */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8139
        e1000_put_hw_eeprom_semaphore(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8140
        DEBUGOUT("Driver can't access the Eeprom - SWESMBI bit is set.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8141
        return -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8142
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8143
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8144
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8145
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8146
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8147
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8148
 * This function clears HW semaphore bits.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8149
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8150
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8151
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8152
 * returns: - None.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8153
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8154
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8155
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8156
e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8157
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8158
    uint32_t swsm;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8159
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8160
    DEBUGFUNC("e1000_put_hw_eeprom_semaphore");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8161
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8162
    if(!hw->eeprom_semaphore_present)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8163
        return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8164
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8165
    swsm = E1000_READ_REG(hw, SWSM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8166
    if (hw->mac_type == e1000_80003es2lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8167
        /* Release both semaphores. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8168
        swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8169
    } else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8170
        swsm &= ~(E1000_SWSM_SWESMBI);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8171
    E1000_WRITE_REG(hw, SWSM, swsm);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8172
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8173
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8174
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8175
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8176
 * Obtaining software semaphore bit (SMBI) before resetting PHY.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8177
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8178
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8179
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8180
 * returns: - E1000_ERR_RESET if fail to obtain semaphore.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8181
 *            E1000_SUCCESS at any other case.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8182
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8183
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8184
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8185
e1000_get_software_semaphore(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8186
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8187
    int32_t timeout = hw->eeprom.word_size + 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8188
    uint32_t swsm;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8189
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8190
    DEBUGFUNC("e1000_get_software_semaphore");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8191
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8192
    if (hw->mac_type != e1000_80003es2lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8193
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8194
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8195
    while(timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8196
        swsm = E1000_READ_REG(hw, SWSM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8197
        /* If SMBI bit cleared, it is now set and we hold the semaphore */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8198
        if(!(swsm & E1000_SWSM_SMBI))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8199
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8200
        msec_delay_irq(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8201
        timeout--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8202
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8203
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8204
    if(!timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8205
        DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8206
        return -E1000_ERR_RESET;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8207
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8208
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8209
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8210
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8211
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8212
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8213
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8214
 * Release semaphore bit (SMBI).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8215
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8216
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8217
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8218
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8219
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8220
e1000_release_software_semaphore(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8221
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8222
    uint32_t swsm;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8223
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8224
    DEBUGFUNC("e1000_release_software_semaphore");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8225
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8226
    if (hw->mac_type != e1000_80003es2lan)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8227
        return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8228
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8229
    swsm = E1000_READ_REG(hw, SWSM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8230
    /* Release the SW semaphores.*/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8231
    swsm &= ~E1000_SWSM_SMBI;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8232
    E1000_WRITE_REG(hw, SWSM, swsm);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8233
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8234
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8235
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8236
 * Checks if PHY reset is blocked due to SOL/IDER session, for example.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8237
 * Returning E1000_BLK_PHY_RESET isn't necessarily an error.  But it's up to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8238
 * the caller to figure out how to deal with it.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8239
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8240
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8241
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8242
 * returns: - E1000_BLK_PHY_RESET
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8243
 *            E1000_SUCCESS
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8244
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8245
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8246
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8247
e1000_check_phy_reset_block(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8248
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8249
    uint32_t manc = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8250
    uint32_t fwsm = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8251
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8252
    if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8253
        fwsm = E1000_READ_REG(hw, FWSM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8254
        return (fwsm & E1000_FWSM_RSPCIPHY) ? E1000_SUCCESS
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8255
                                            : E1000_BLK_PHY_RESET;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8256
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8257
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8258
    if (hw->mac_type > e1000_82547_rev_2)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8259
        manc = E1000_READ_REG(hw, MANC);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8260
    return (manc & E1000_MANC_BLK_PHY_RST_ON_IDE) ?
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8261
	    E1000_BLK_PHY_RESET : E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8262
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8263
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8264
static uint8_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8265
e1000_arc_subsystem_valid(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8266
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8267
    uint32_t fwsm;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8268
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8269
    /* On 8257x silicon, registers in the range of 0x8800 - 0x8FFC
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8270
     * may not be provided a DMA clock when no manageability features are
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8271
     * enabled.  We do not want to perform any reads/writes to these registers
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8272
     * if this is the case.  We read FWSM to determine the manageability mode.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8273
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8274
    switch (hw->mac_type) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8275
    case e1000_82571:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8276
    case e1000_82572:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8277
    case e1000_82573:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8278
    case e1000_80003es2lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8279
        fwsm = E1000_READ_REG(hw, FWSM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8280
        if((fwsm & E1000_FWSM_MODE_MASK) != 0)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8281
            return TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8282
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8283
    case e1000_ich8lan:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8284
        return TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8285
    default:
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8286
        break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8287
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8288
    return FALSE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8289
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8290
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8291
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8292
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8293
 * Configure PCI-Ex no-snoop
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8294
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8295
 * hw - Struct containing variables accessed by shared code.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8296
 * no_snoop - Bitmap of no-snoop events.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8297
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8298
 * returns: E1000_SUCCESS
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8299
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8300
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8301
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8302
e1000_set_pci_ex_no_snoop(struct e1000_hw *hw, uint32_t no_snoop)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8303
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8304
    uint32_t gcr_reg = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8305
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8306
    DEBUGFUNC("e1000_set_pci_ex_no_snoop");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8307
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8308
    if (hw->bus_type == e1000_bus_type_unknown)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8309
        e1000_get_bus_info(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8310
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8311
    if (hw->bus_type != e1000_bus_type_pci_express)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8312
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8313
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8314
    if (no_snoop) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8315
        gcr_reg = E1000_READ_REG(hw, GCR);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8316
        gcr_reg &= ~(PCI_EX_NO_SNOOP_ALL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8317
        gcr_reg |= no_snoop;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8318
        E1000_WRITE_REG(hw, GCR, gcr_reg);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8319
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8320
    if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8321
        uint32_t ctrl_ext;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8322
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8323
        E1000_WRITE_REG(hw, GCR, PCI_EX_82566_SNOOP_ALL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8324
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8325
        ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8326
        ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8327
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8328
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8329
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8330
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8331
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8332
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8333
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8334
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8335
 * Get software semaphore FLAG bit (SWFLAG).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8336
 * SWFLAG is used to synchronize the access to all shared resource between
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8337
 * SW, FW and HW.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8338
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8339
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8340
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8341
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8342
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8343
e1000_get_software_flag(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8344
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8345
    int32_t timeout = PHY_CFG_TIMEOUT;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8346
    uint32_t extcnf_ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8347
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8348
    DEBUGFUNC("e1000_get_software_flag");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8349
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8350
    if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8351
        while (timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8352
            extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8353
            extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8354
            E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8355
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8356
            extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8357
            if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8358
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8359
            msec_delay_irq(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8360
            timeout--;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8361
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8362
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8363
        if (!timeout) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8364
            DEBUGOUT("FW or HW locks the resource too long.\n");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8365
            return -E1000_ERR_CONFIG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8366
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8367
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8368
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8369
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8370
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8371
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8372
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8373
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8374
 * Release software semaphore FLAG bit (SWFLAG).
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8375
 * SWFLAG is used to synchronize the access to all shared resource between
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8376
 * SW, FW and HW.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8377
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8378
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8379
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8380
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8381
static void
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8382
e1000_release_software_flag(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8383
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8384
    uint32_t extcnf_ctrl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8385
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8386
    DEBUGFUNC("e1000_release_software_flag");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8387
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8388
    if (hw->mac_type == e1000_ich8lan) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8389
        extcnf_ctrl= E1000_READ_REG(hw, EXTCNF_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8390
        extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8391
        E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8392
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8393
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8394
    return;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8395
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8396
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8397
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8398
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8399
 * Disable dynamic power down mode in ife PHY.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8400
 * It can be used to workaround band-gap problem.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8401
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8402
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8403
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8404
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8405
#if 0
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8406
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8407
e1000_ife_disable_dynamic_power_down(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8408
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8409
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8410
    int32_t ret_val = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8411
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8412
    DEBUGFUNC("e1000_ife_disable_dynamic_power_down");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8413
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8414
    if (hw->phy_type == e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8415
        ret_val = e1000_read_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8416
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8417
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8418
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8419
        phy_data |=  IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8420
        ret_val = e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8421
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8422
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8423
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8424
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8425
#endif  /*  0  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8426
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8427
/***************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8428
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8429
 * Enable dynamic power down mode in ife PHY.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8430
 * It can be used to workaround band-gap problem.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8431
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8432
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8433
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8434
 ***************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8435
#if 0
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8436
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8437
e1000_ife_enable_dynamic_power_down(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8438
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8439
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8440
    int32_t ret_val = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8441
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8442
    DEBUGFUNC("e1000_ife_enable_dynamic_power_down");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8443
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8444
    if (hw->phy_type == e1000_phy_ife) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8445
        ret_val = e1000_read_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8446
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8447
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8448
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8449
        phy_data &=  ~IFE_PSC_DISABLE_DYNAMIC_POWER_DOWN;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8450
        ret_val = e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8451
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8452
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8453
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8454
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8455
#endif  /*  0  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8456
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8457
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8458
 * Reads a 16 bit word or words from the EEPROM using the ICH8's flash access
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8459
 * register.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8460
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8461
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8462
 * offset - offset of word in the EEPROM to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8463
 * data - word read from the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8464
 * words - number of words to read
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8465
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8466
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8467
e1000_read_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, uint16_t words,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8468
                       uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8469
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8470
    int32_t  error = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8471
    uint32_t flash_bank = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8472
    uint32_t act_offset = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8473
    uint32_t bank_offset = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8474
    uint16_t word = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8475
    uint16_t i = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8476
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8477
    /* We need to know which is the valid flash bank.  In the event
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8478
     * that we didn't allocate eeprom_shadow_ram, we may not be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8479
     * managing flash_bank.  So it cannot be trusted and needs
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8480
     * to be updated with each read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8481
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8482
    /* Value of bit 22 corresponds to the flash bank we're on. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8483
    flash_bank = (E1000_READ_REG(hw, EECD) & E1000_EECD_SEC1VAL) ? 1 : 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8484
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8485
    /* Adjust offset appropriately if we're on bank 1 - adjust for word size */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8486
    bank_offset = flash_bank * (hw->flash_bank_size * 2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8487
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8488
    error = e1000_get_software_flag(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8489
    if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8490
        return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8491
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8492
    for (i = 0; i < words; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8493
        if (hw->eeprom_shadow_ram != NULL &&
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8494
            hw->eeprom_shadow_ram[offset+i].modified == TRUE) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8495
            data[i] = hw->eeprom_shadow_ram[offset+i].eeprom_word;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8496
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8497
            /* The NVM part needs a byte offset, hence * 2 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8498
            act_offset = bank_offset + ((offset + i) * 2);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8499
            error = e1000_read_ich8_word(hw, act_offset, &word);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8500
            if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8501
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8502
            data[i] = word;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8503
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8504
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8505
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8506
    e1000_release_software_flag(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8507
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8508
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8509
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8510
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8511
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8512
 * Writes a 16 bit word or words to the EEPROM using the ICH8's flash access
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8513
 * register.  Actually, writes are written to the shadow ram cache in the hw
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8514
 * structure hw->e1000_shadow_ram.  e1000_commit_shadow_ram flushes this to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8515
 * the NVM, which occurs when the NVM checksum is updated.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8516
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8517
 * hw - Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8518
 * offset - offset of word in the EEPROM to write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8519
 * words - number of words to write
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8520
 * data - words to write to the EEPROM
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8521
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8522
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8523
e1000_write_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, uint16_t words,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8524
                        uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8525
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8526
    uint32_t i = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8527
    int32_t error = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8528
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8529
    error = e1000_get_software_flag(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8530
    if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8531
        return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8532
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8533
    /* A driver can write to the NVM only if it has eeprom_shadow_ram
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8534
     * allocated.  Subsequent reads to the modified words are read from
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8535
     * this cached structure as well.  Writes will only go into this
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8536
     * cached structure unless it's followed by a call to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8537
     * e1000_update_eeprom_checksum() where it will commit the changes
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8538
     * and clear the "modified" field.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8539
     */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8540
    if (hw->eeprom_shadow_ram != NULL) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8541
        for (i = 0; i < words; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8542
            if ((offset + i) < E1000_SHADOW_RAM_WORDS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8543
                hw->eeprom_shadow_ram[offset+i].modified = TRUE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8544
                hw->eeprom_shadow_ram[offset+i].eeprom_word = data[i];
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8545
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8546
                error = -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8547
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8548
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8549
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8550
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8551
        /* Drivers have the option to not allocate eeprom_shadow_ram as long
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8552
         * as they don't perform any NVM writes.  An attempt in doing so
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8553
         * will result in this error.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8554
         */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8555
        error = -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8556
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8557
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8558
    e1000_release_software_flag(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8559
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8560
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8561
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8562
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8563
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8564
 * This function does initial flash setup so that a new read/write/erase cycle
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8565
 * can be started.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8566
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8567
 * hw - The pointer to the hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8568
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8569
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8570
e1000_ich8_cycle_init(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8571
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8572
    union ich8_hws_flash_status hsfsts;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8573
    int32_t error = E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8574
    int32_t i     = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8575
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8576
    DEBUGFUNC("e1000_ich8_cycle_init");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8577
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8578
    hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8579
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8580
    /* May be check the Flash Des Valid bit in Hw status */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8581
    if (hsfsts.hsf_status.fldesvalid == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8582
        DEBUGOUT("Flash descriptor invalid.  SW Sequencing must be used.");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8583
        return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8584
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8585
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8586
    /* Clear FCERR in Hw status by writing 1 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8587
    /* Clear DAEL in Hw status by writing a 1 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8588
    hsfsts.hsf_status.flcerr = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8589
    hsfsts.hsf_status.dael = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8590
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8591
    E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8592
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8593
    /* Either we should have a hardware SPI cycle in progress bit to check
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8594
     * against, in order to start a new cycle or FDONE bit should be changed
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8595
     * in the hardware so that it is 1 after harware reset, which can then be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8596
     * used as an indication whether a cycle is in progress or has been
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8597
     * completed .. we should also have some software semaphore mechanism to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8598
     * guard FDONE or the cycle in progress bit so that two threads access to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8599
     * those bits can be sequentiallized or a way so that 2 threads dont
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8600
     * start the cycle at the same time */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8601
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8602
    if (hsfsts.hsf_status.flcinprog == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8603
        /* There is no cycle running at present, so we can start a cycle */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8604
        /* Begin by setting Flash Cycle Done. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8605
        hsfsts.hsf_status.flcdone = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8606
        E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8607
        error = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8608
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8609
        /* otherwise poll for sometime so the current cycle has a chance
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8610
         * to end before giving up. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8611
        for (i = 0; i < ICH8_FLASH_COMMAND_TIMEOUT; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8612
            hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8613
            if (hsfsts.hsf_status.flcinprog == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8614
                error = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8615
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8616
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8617
            udelay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8618
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8619
        if (error == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8620
            /* Successful in waiting for previous cycle to timeout,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8621
             * now set the Flash Cycle Done. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8622
            hsfsts.hsf_status.flcdone = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8623
            E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8624
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8625
            DEBUGOUT("Flash controller busy, cannot get access");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8626
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8627
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8628
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8629
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8630
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8631
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8632
 * This function starts a flash cycle and waits for its completion
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8633
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8634
 * hw - The pointer to the hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8635
 ****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8636
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8637
e1000_ich8_flash_cycle(struct e1000_hw *hw, uint32_t timeout)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8638
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8639
    union ich8_hws_flash_ctrl hsflctl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8640
    union ich8_hws_flash_status hsfsts;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8641
    int32_t error = E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8642
    uint32_t i = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8643
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8644
    /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8645
    hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8646
    hsflctl.hsf_ctrl.flcgo = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8647
    E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8648
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8649
    /* wait till FDONE bit is set to 1 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8650
    do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8651
        hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8652
        if (hsfsts.hsf_status.flcdone == 1)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8653
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8654
        udelay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8655
        i++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8656
    } while (i < timeout);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8657
    if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8658
        error = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8659
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8660
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8661
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8662
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8663
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8664
 * Reads a byte or word from the NVM using the ICH8 flash access registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8665
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8666
 * hw - The pointer to the hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8667
 * index - The index of the byte or word to read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8668
 * size - Size of data to read, 1=byte 2=word
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8669
 * data - Pointer to the word to store the value read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8670
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8671
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8672
e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8673
                     uint32_t size, uint16_t* data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8674
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8675
    union ich8_hws_flash_status hsfsts;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8676
    union ich8_hws_flash_ctrl hsflctl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8677
    uint32_t flash_linear_address;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8678
    uint32_t flash_data = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8679
    int32_t error = -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8680
    int32_t count = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8681
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8682
    DEBUGFUNC("e1000_read_ich8_data");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8683
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8684
    if (size < 1  || size > 2 || data == 0x0 ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8685
        index > ICH8_FLASH_LINEAR_ADDR_MASK)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8686
        return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8687
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8688
    flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) +
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8689
                           hw->flash_base_addr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8690
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8691
    do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8692
        udelay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8693
        /* Steps */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8694
        error = e1000_ich8_cycle_init(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8695
        if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8696
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8697
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8698
        hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8699
        /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8700
        hsflctl.hsf_ctrl.fldbcount = size - 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8701
        hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_READ;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8702
        E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8703
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8704
        /* Write the last 24 bits of index into Flash Linear address field in
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8705
         * Flash Address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8706
        /* TODO: TBD maybe check the index against the size of flash */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8707
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8708
        E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8709
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8710
        error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_COMMAND_TIMEOUT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8711
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8712
        /* Check if FCERR is set to 1, if set to 1, clear it and try the whole
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8713
         * sequence a few more times, else read in (shift in) the Flash Data0,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8714
         * the order is least significant byte first msb to lsb */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8715
        if (error == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8716
            flash_data = E1000_READ_ICH8_REG(hw, ICH8_FLASH_FDATA0);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8717
            if (size == 1) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8718
                *data = (uint8_t)(flash_data & 0x000000FF);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8719
            } else if (size == 2) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8720
                *data = (uint16_t)(flash_data & 0x0000FFFF);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8721
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8722
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8723
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8724
            /* If we've gotten here, then things are probably completely hosed,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8725
             * but if the error condition is detected, it won't hurt to give
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8726
             * it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8727
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8728
            hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8729
            if (hsfsts.hsf_status.flcerr == 1) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8730
                /* Repeat for some time before giving up. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8731
                continue;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8732
            } else if (hsfsts.hsf_status.flcdone == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8733
                DEBUGOUT("Timeout error - flash cycle did not complete.");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8734
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8735
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8736
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8737
    } while (count++ < ICH8_FLASH_CYCLE_REPEAT_COUNT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8738
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8739
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8740
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8741
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8742
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8743
 * Writes One /two bytes to the NVM using the ICH8 flash access registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8744
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8745
 * hw - The pointer to the hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8746
 * index - The index of the byte/word to read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8747
 * size - Size of data to read, 1=byte 2=word
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8748
 * data - The byte(s) to write to the NVM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8749
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8750
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8751
e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8752
                      uint16_t data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8753
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8754
    union ich8_hws_flash_status hsfsts;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8755
    union ich8_hws_flash_ctrl hsflctl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8756
    uint32_t flash_linear_address;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8757
    uint32_t flash_data = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8758
    int32_t error = -E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8759
    int32_t count = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8760
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8761
    DEBUGFUNC("e1000_write_ich8_data");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8762
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8763
    if (size < 1  || size > 2 || data > size * 0xff ||
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8764
        index > ICH8_FLASH_LINEAR_ADDR_MASK)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8765
        return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8766
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8767
    flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) +
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8768
                           hw->flash_base_addr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8769
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8770
    do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8771
        udelay(1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8772
        /* Steps */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8773
        error = e1000_ich8_cycle_init(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8774
        if (error != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8775
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8776
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8777
        hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8778
        /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8779
        hsflctl.hsf_ctrl.fldbcount = size -1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8780
        hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_WRITE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8781
        E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8782
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8783
        /* Write the last 24 bits of index into Flash Linear address field in
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8784
         * Flash Address */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8785
        E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8786
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8787
        if (size == 1)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8788
            flash_data = (uint32_t)data & 0x00FF;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8789
        else
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8790
            flash_data = (uint32_t)data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8791
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8792
        E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FDATA0, flash_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8793
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8794
        /* check if FCERR is set to 1 , if set to 1, clear it and try the whole
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8795
         * sequence a few more times else done */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8796
        error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_COMMAND_TIMEOUT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8797
        if (error == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8798
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8799
        } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8800
            /* If we're here, then things are most likely completely hosed,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8801
             * but if the error condition is detected, it won't hurt to give
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8802
             * it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8803
             */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8804
            hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8805
            if (hsfsts.hsf_status.flcerr == 1) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8806
                /* Repeat for some time before giving up. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8807
                continue;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8808
            } else if (hsfsts.hsf_status.flcdone == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8809
                DEBUGOUT("Timeout error - flash cycle did not complete.");
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8810
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8811
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8812
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8813
    } while (count++ < ICH8_FLASH_CYCLE_REPEAT_COUNT);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8814
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8815
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8816
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8817
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8818
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8819
 * Reads a single byte from the NVM using the ICH8 flash access registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8820
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8821
 * hw - pointer to e1000_hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8822
 * index - The index of the byte to read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8823
 * data - Pointer to a byte to store the value read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8824
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8825
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8826
e1000_read_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t* data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8827
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8828
    int32_t status = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8829
    uint16_t word = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8830
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8831
    status = e1000_read_ich8_data(hw, index, 1, &word);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8832
    if (status == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8833
        *data = (uint8_t)word;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8834
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8835
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8836
    return status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8837
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8838
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8839
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8840
 * Writes a single byte to the NVM using the ICH8 flash access registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8841
 * Performs verification by reading back the value and then going through
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8842
 * a retry algorithm before giving up.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8843
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8844
 * hw - pointer to e1000_hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8845
 * index - The index of the byte to write.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8846
 * byte - The byte to write to the NVM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8847
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8848
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8849
e1000_verify_write_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t byte)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8850
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8851
    int32_t error = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8852
    int32_t program_retries;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8853
    uint8_t temp_byte;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8854
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8855
    e1000_write_ich8_byte(hw, index, byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8856
    udelay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8857
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8858
    for (program_retries = 0; program_retries < 100; program_retries++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8859
        e1000_read_ich8_byte(hw, index, &temp_byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8860
        if (temp_byte == byte)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8861
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8862
        udelay(10);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8863
        e1000_write_ich8_byte(hw, index, byte);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8864
        udelay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8865
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8866
    if (program_retries == 100)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8867
        error = E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8868
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8869
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8870
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8871
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8872
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8873
 * Writes a single byte to the NVM using the ICH8 flash access registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8874
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8875
 * hw - pointer to e1000_hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8876
 * index - The index of the byte to read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8877
 * data - The byte to write to the NVM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8878
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8879
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8880
e1000_write_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8881
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8882
    int32_t status = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8883
    uint16_t word = (uint16_t)data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8884
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8885
    status = e1000_write_ich8_data(hw, index, 1, word);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8886
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8887
    return status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8888
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8889
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8890
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8891
 * Reads a word from the NVM using the ICH8 flash access registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8892
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8893
 * hw - pointer to e1000_hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8894
 * index - The starting byte index of the word to read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8895
 * data - Pointer to a word to store the value read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8896
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8897
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8898
e1000_read_ich8_word(struct e1000_hw *hw, uint32_t index, uint16_t *data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8899
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8900
    int32_t status = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8901
    status = e1000_read_ich8_data(hw, index, 2, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8902
    return status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8903
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8904
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8905
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8906
 * Writes a word to the NVM using the ICH8 flash access registers.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8907
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8908
 * hw - pointer to e1000_hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8909
 * index - The starting byte index of the word to read.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8910
 * data - The word to write to the NVM.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8911
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8912
#if 0
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8913
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8914
e1000_write_ich8_word(struct e1000_hw *hw, uint32_t index, uint16_t data)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8915
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8916
    int32_t status = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8917
    status = e1000_write_ich8_data(hw, index, 2, data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8918
    return status;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8919
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8920
#endif  /*  0  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8921
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8922
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8923
 * Erases the bank specified. Each bank is a 4k block. Segments are 0 based.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8924
 * segment N is 4096 * N + flash_reg_addr.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8925
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8926
 * hw - pointer to e1000_hw structure
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8927
 * segment - 0 for first segment, 1 for second segment, etc.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8928
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8929
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8930
e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t segment)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8931
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8932
    union ich8_hws_flash_status hsfsts;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8933
    union ich8_hws_flash_ctrl hsflctl;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8934
    uint32_t flash_linear_address;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8935
    int32_t  count = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8936
    int32_t  error = E1000_ERR_EEPROM;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8937
    int32_t  iteration, seg_size;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8938
    int32_t  sector_size;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8939
    int32_t  j = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8940
    int32_t  error_flag = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8941
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8942
    hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8943
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8944
    /* Determine HW Sector size: Read BERASE bits of Hw flash Status register */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8945
    /* 00: The Hw sector is 256 bytes, hence we need to erase 16
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8946
     *     consecutive sectors.  The start index for the nth Hw sector can be
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8947
     *     calculated as = segment * 4096 + n * 256
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8948
     * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8949
     *     The start index for the nth Hw sector can be calculated
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8950
     *     as = segment * 4096
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8951
     * 10: Error condition
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8952
     * 11: The Hw sector size is much bigger than the size asked to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8953
     *     erase...error condition */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8954
    if (hsfsts.hsf_status.berasesz == 0x0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8955
        /* Hw sector size 256 */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8956
        sector_size = seg_size = ICH8_FLASH_SEG_SIZE_256;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8957
        iteration = ICH8_FLASH_SECTOR_SIZE / ICH8_FLASH_SEG_SIZE_256;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8958
    } else if (hsfsts.hsf_status.berasesz == 0x1) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8959
        sector_size = seg_size = ICH8_FLASH_SEG_SIZE_4K;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8960
        iteration = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8961
    } else if (hsfsts.hsf_status.berasesz == 0x3) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8962
        sector_size = seg_size = ICH8_FLASH_SEG_SIZE_64K;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8963
        iteration = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8964
    } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8965
        return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8966
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8967
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8968
    for (j = 0; j < iteration ; j++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8969
        do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8970
            count++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8971
            /* Steps */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8972
            error = e1000_ich8_cycle_init(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8973
            if (error != E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8974
                error_flag = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8975
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8976
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8977
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8978
            /* Write a value 11 (block Erase) in Flash Cycle field in Hw flash
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8979
             * Control */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8980
            hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8981
            hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_ERASE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8982
            E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8983
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8984
            /* Write the last 24 bits of an index within the block into Flash
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8985
             * Linear address field in Flash Address.  This probably needs to
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8986
             * be calculated here based off the on-chip segment size and the
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8987
             * software segment size assumed (4K) */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8988
            /* TBD */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8989
            flash_linear_address = segment * sector_size + j * seg_size;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8990
            flash_linear_address &= ICH8_FLASH_LINEAR_ADDR_MASK;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8991
            flash_linear_address += hw->flash_base_addr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8992
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8993
            E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8994
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8995
            error = e1000_ich8_flash_cycle(hw, 1000000);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8996
            /* Check if FCERR is set to 1.  If 1, clear it and try the whole
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8997
             * sequence a few more times else Done */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8998
            if (error == E1000_SUCCESS) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8999
                break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9000
            } else {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9001
                hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9002
                if (hsfsts.hsf_status.flcerr == 1) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9003
                    /* repeat for some time before giving up */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9004
                    continue;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9005
                } else if (hsfsts.hsf_status.flcdone == 0) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9006
                    error_flag = 1;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9007
                    break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9008
                }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9009
            }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9010
        } while ((count < ICH8_FLASH_CYCLE_REPEAT_COUNT) && !error_flag);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9011
        if (error_flag == 1)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9012
            break;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9013
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9014
    if (error_flag != 1)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9015
        error = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9016
    return error;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9017
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9018
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9019
/******************************************************************************
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9020
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9021
 * Reverse duplex setting without breaking the link.
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9022
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9023
 * hw: Struct containing variables accessed by shared code
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9024
 *
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9025
 *****************************************************************************/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9026
#if 0
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9027
int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9028
e1000_duplex_reversal(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9029
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9030
    int32_t ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9031
    uint16_t phy_data;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9032
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9033
    if (hw->phy_type != e1000_phy_igp_3)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9034
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9035
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9036
    ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9037
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9038
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9039
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9040
    phy_data ^= MII_CR_FULL_DUPLEX;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9041
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9042
    ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9043
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9044
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9045
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9046
    ret_val = e1000_read_phy_reg(hw, IGP3E1000_PHY_MISC_CTRL, &phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9047
    if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9048
        return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9049
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9050
    phy_data |= IGP3_PHY_MISC_DUPLEX_MANUAL_SET;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9051
    ret_val = e1000_write_phy_reg(hw, IGP3E1000_PHY_MISC_CTRL, phy_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9052
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9053
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9054
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9055
#endif  /*  0  */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9056
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9057
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9058
e1000_init_lcd_from_nvm_config_region(struct e1000_hw *hw,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9059
                                      uint32_t cnf_base_addr, uint32_t cnf_size)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9060
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9061
    uint32_t ret_val = E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9062
    uint16_t word_addr, reg_data, reg_addr;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9063
    uint16_t i;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9064
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9065
    /* cnf_base_addr is in DWORD */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9066
    word_addr = (uint16_t)(cnf_base_addr << 1);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9067
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9068
    /* cnf_size is returned in size of dwords */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9069
    for (i = 0; i < cnf_size; i++) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9070
        ret_val = e1000_read_eeprom(hw, (word_addr + i*2), 1, &reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9071
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9072
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9073
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9074
        ret_val = e1000_read_eeprom(hw, (word_addr + i*2 + 1), 1, &reg_addr);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9075
        if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9076
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9077
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9078
        ret_val = e1000_get_software_flag(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9079
        if (ret_val != E1000_SUCCESS)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9080
            return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9081
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9082
        ret_val = e1000_write_phy_reg_ex(hw, (uint32_t)reg_addr, reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9083
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9084
        e1000_release_software_flag(hw);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9085
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9086
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9087
    return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9088
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9089
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9090
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9091
static int32_t
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9092
e1000_init_lcd_from_nvm(struct e1000_hw *hw)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9093
{
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9094
    uint32_t reg_data, cnf_base_addr, cnf_size, ret_val, loop;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9095
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9096
    if (hw->phy_type != e1000_phy_igp_3)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9097
          return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9098
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9099
    /* Check if SW needs configure the PHY */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9100
    reg_data = E1000_READ_REG(hw, FEXTNVM);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9101
    if (!(reg_data & FEXTNVM_SW_CONFIG))
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9102
        return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9103
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9104
    /* Wait for basic configuration completes before proceeding*/
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9105
    loop = 0;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9106
    do {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9107
        reg_data = E1000_READ_REG(hw, STATUS) & E1000_STATUS_LAN_INIT_DONE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9108
        udelay(100);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9109
        loop++;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9110
    } while ((!reg_data) && (loop < 50));
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9111
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9112
    /* Clear the Init Done bit for the next init event */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9113
    reg_data = E1000_READ_REG(hw, STATUS);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9114
    reg_data &= ~E1000_STATUS_LAN_INIT_DONE;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9115
    E1000_WRITE_REG(hw, STATUS, reg_data);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9116
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9117
    /* Make sure HW does not configure LCD from PHY extended configuration
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9118
       before SW configuration */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9119
    reg_data = E1000_READ_REG(hw, EXTCNF_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9120
    if ((reg_data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE) == 0x0000) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9121
        reg_data = E1000_READ_REG(hw, EXTCNF_SIZE);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9122
        cnf_size = reg_data & E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9123
        cnf_size >>= 16;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9124
        if (cnf_size) {
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9125
            reg_data = E1000_READ_REG(hw, EXTCNF_CTRL);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9126
            cnf_base_addr = reg_data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9127
            /* cnf_base_addr is in DWORD */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9128
            cnf_base_addr >>= 16;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9129
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9130
            /* Configure LCD from extended configuration region. */
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9131
            ret_val = e1000_init_lcd_from_nvm_config_region(hw, cnf_base_addr,
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9132
                                                            cnf_size);
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9133
            if (ret_val)
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9134
                return ret_val;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9135
        }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9136
    }
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9137
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9138
    return E1000_SUCCESS;
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9139
}
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9140
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9141
9feff35c9617 First version with e1000 driver (to be continued...)
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9142