devices/e1000/e1000_hw-2.6.20-orig.c
author Florian Pose <fp@igh-essen.com>
Mon, 22 Sep 2008 14:43:40 +0000
changeset 1216 e70c4d71cebd
parent 680 48c2dbc12bde
permissions -rw-r--r--
Changed VoE mailbox type to 0xff.
680
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2006 Intel Corporation.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
/* e1000_hw.c
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 * Shared functions for accessing and configuring the MAC
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include "e1000_hw.h"
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
static int32_t e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
static void e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
static int32_t e1000_read_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
static int32_t e1000_write_kmrn_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
static int32_t e1000_get_software_semaphore(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
static void e1000_release_software_semaphore(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
static uint8_t e1000_arc_subsystem_valid(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
static int32_t e1000_check_downshift(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
static int32_t e1000_check_polarity(struct e1000_hw *hw, e1000_rev_polarity *polarity);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
static void e1000_clear_hw_cntrs(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
static void e1000_clear_vfta(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
static int32_t e1000_commit_shadow_ram(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
static int32_t e1000_config_dsp_after_link_change(struct e1000_hw *hw, boolean_t link_up);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
static int32_t e1000_config_fc_after_link_up(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
static int32_t e1000_detect_gig_phy(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
static int32_t e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
static int32_t e1000_get_auto_rd_done(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
static int32_t e1000_get_cable_length(struct e1000_hw *hw, uint16_t *min_length, uint16_t *max_length);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
static int32_t e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
static int32_t e1000_get_phy_cfg_done(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
static int32_t e1000_get_software_flag(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
static int32_t e1000_ich8_cycle_init(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
static int32_t e1000_ich8_flash_cycle(struct e1000_hw *hw, uint32_t timeout);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
static int32_t e1000_id_led_init(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
static int32_t e1000_init_lcd_from_nvm_config_region(struct e1000_hw *hw, uint32_t cnf_base_addr, uint32_t cnf_size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
static int32_t e1000_init_lcd_from_nvm(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
static void e1000_init_rx_addrs(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
static void e1000_initialize_hardware_bits(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
static boolean_t e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
static int32_t e1000_kumeran_lock_loss_workaround(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
static int32_t e1000_mng_enable_host_if(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
static int32_t e1000_mng_host_if_write(struct e1000_hw *hw, uint8_t *buffer, uint16_t length, uint16_t offset, uint8_t *sum);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
static int32_t e1000_mng_write_cmd_header(struct e1000_hw* hw, struct e1000_host_mng_command_header* hdr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
static int32_t e1000_mng_write_commit(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
static int32_t e1000_phy_ife_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
static int32_t e1000_phy_igp_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
static int32_t e1000_read_eeprom_eerd(struct e1000_hw *hw, uint16_t offset, uint16_t words, uint16_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
static int32_t e1000_write_eeprom_eewr(struct e1000_hw *hw, uint16_t offset, uint16_t words, uint16_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
static int32_t e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
static int32_t e1000_phy_m88_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
static void e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
static int32_t e1000_read_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
static int32_t e1000_verify_write_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
static int32_t e1000_write_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
static int32_t e1000_read_ich8_word(struct e1000_hw *hw, uint32_t index, uint16_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
static int32_t e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size, uint16_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
static int32_t e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size, uint16_t data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
static int32_t e1000_read_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, uint16_t words, uint16_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
static int32_t e1000_write_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, uint16_t words, uint16_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
static void e1000_release_software_flag(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
static int32_t e1000_set_d3_lplu_state(struct e1000_hw *hw, boolean_t active);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
static int32_t e1000_set_d0_lplu_state(struct e1000_hw *hw, boolean_t active);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
static int32_t e1000_set_pci_ex_no_snoop(struct e1000_hw *hw, uint32_t no_snoop);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
static void e1000_set_pci_express_master_disable(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
static int32_t e1000_wait_autoneg(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
static void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset, uint32_t value);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
static int32_t e1000_set_phy_type(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
static void e1000_phy_init_script(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
static int32_t e1000_setup_copper_link(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
static int32_t e1000_setup_fiber_serdes_link(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
static int32_t e1000_adjust_serdes_amplitude(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
static int32_t e1000_phy_force_speed_duplex(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
static int32_t e1000_config_mac_to_phy(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
static void e1000_raise_mdi_clk(struct e1000_hw *hw, uint32_t *ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
static void e1000_lower_mdi_clk(struct e1000_hw *hw, uint32_t *ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
static void e1000_shift_out_mdi_bits(struct e1000_hw *hw, uint32_t data,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
                                     uint16_t count);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
static uint16_t e1000_shift_in_mdi_bits(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
static int32_t e1000_phy_reset_dsp(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
static int32_t e1000_write_eeprom_spi(struct e1000_hw *hw, uint16_t offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
                                      uint16_t words, uint16_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
static int32_t e1000_write_eeprom_microwire(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
                                            uint16_t offset, uint16_t words,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
                                            uint16_t *data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
static int32_t e1000_spi_eeprom_ready(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
static void e1000_raise_ee_clk(struct e1000_hw *hw, uint32_t *eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
static void e1000_lower_ee_clk(struct e1000_hw *hw, uint32_t *eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
static void e1000_shift_out_ee_bits(struct e1000_hw *hw, uint16_t data,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
                                    uint16_t count);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
static int32_t e1000_write_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
                                      uint16_t phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
static int32_t e1000_read_phy_reg_ex(struct e1000_hw *hw,uint32_t reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
                                     uint16_t *phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
static uint16_t e1000_shift_in_ee_bits(struct e1000_hw *hw, uint16_t count);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
static int32_t e1000_acquire_eeprom(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
static void e1000_release_eeprom(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
static void e1000_standby_eeprom(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
static int32_t e1000_set_vco_speed(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
static int32_t e1000_polarity_reversal_workaround(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
static int32_t e1000_set_phy_mode(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
static int32_t e1000_host_if_read_cookie(struct e1000_hw *hw, uint8_t *buffer);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
static uint8_t e1000_calculate_mng_checksum(char *buffer, uint32_t length);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
static int32_t e1000_configure_kmrn_for_10_100(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
                                               uint16_t duplex);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
static int32_t e1000_configure_kmrn_for_1000(struct e1000_hw *hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
/* IGP cable length table */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
static const
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
uint16_t e1000_igp_cable_length_table[IGP01E1000_AGC_LENGTH_TABLE_SIZE] =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
    { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
      5, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 25, 25, 25,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
      25, 25, 25, 25, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
      40, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 60, 60,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
      60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 90, 90, 90,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
      90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
      100, 100, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
      110, 110, 110, 110, 110, 110, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120};
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
static const
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
uint16_t e1000_igp_2_cable_length_table[IGP02E1000_AGC_LENGTH_TABLE_SIZE] =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
    { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
      0, 0, 0, 3, 6, 10, 13, 16, 19, 23, 26, 29, 32, 35, 38, 41,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
      6, 10, 14, 18, 22, 26, 30, 33, 37, 41, 44, 48, 51, 54, 58, 61,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
      21, 26, 31, 35, 40, 44, 49, 53, 57, 61, 65, 68, 72, 75, 79, 82,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
      40, 45, 51, 56, 61, 66, 70, 75, 79, 83, 87, 91, 94, 98, 101, 104,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
      60, 66, 72, 77, 82, 87, 92, 96, 100, 104, 108, 111, 114, 117, 119, 121,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
      83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
      104, 109, 114, 118, 121, 124};
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
 * Set the phy type member in the hw struct.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
e1000_set_phy_type(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
    DEBUGFUNC("e1000_set_phy_type");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
    if (hw->mac_type == e1000_undefined)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
        return -E1000_ERR_PHY_TYPE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
    switch (hw->phy_id) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
    case M88E1000_E_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
    case M88E1000_I_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
    case M88E1011_I_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
    case M88E1111_I_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
        hw->phy_type = e1000_phy_m88;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
    case IGP01E1000_I_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
        if (hw->mac_type == e1000_82541 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
            hw->mac_type == e1000_82541_rev_2 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
            hw->mac_type == e1000_82547 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
            hw->mac_type == e1000_82547_rev_2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
            hw->phy_type = e1000_phy_igp;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
    case IGP03E1000_E_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
        hw->phy_type = e1000_phy_igp_3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
    case IFE_E_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
    case IFE_PLUS_E_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
    case IFE_C_E_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
        hw->phy_type = e1000_phy_ife;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
    case GG82563_E_PHY_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
        if (hw->mac_type == e1000_80003es2lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
            hw->phy_type = e1000_phy_gg82563;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
        /* Fall Through */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
        /* Should never have loaded on this device */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
        hw->phy_type = e1000_phy_undefined;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
        return -E1000_ERR_PHY_TYPE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
 * IGP phy init script - initializes the GbE PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
e1000_phy_init_script(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
    uint32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
    uint16_t phy_saved_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
    DEBUGFUNC("e1000_phy_init_script");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
    if (hw->phy_init_script) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
        msleep(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
        /* Save off the current value of register 0x2F5B to be restored at
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
         * the end of this routine. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
        ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
        /* Disabled the PHY transmitter */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
        e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
        msleep(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
        e1000_write_phy_reg(hw,0x0000,0x0140);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
        msleep(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
        switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
        case e1000_82541:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
        case e1000_82547:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
            e1000_write_phy_reg(hw, 0x1F95, 0x0001);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
            e1000_write_phy_reg(hw, 0x1F71, 0xBD21);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
            e1000_write_phy_reg(hw, 0x1F79, 0x0018);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
            e1000_write_phy_reg(hw, 0x1F30, 0x1600);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
            e1000_write_phy_reg(hw, 0x1F31, 0x0014);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
            e1000_write_phy_reg(hw, 0x1F32, 0x161C);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
            e1000_write_phy_reg(hw, 0x1F94, 0x0003);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
            e1000_write_phy_reg(hw, 0x1F96, 0x003F);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
            e1000_write_phy_reg(hw, 0x2010, 0x0008);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
        case e1000_82541_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
        case e1000_82547_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
            e1000_write_phy_reg(hw, 0x1F73, 0x0099);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
        e1000_write_phy_reg(hw, 0x0000, 0x3300);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
        msleep(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
        /* Now enable the transmitter */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
        e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
        if (hw->mac_type == e1000_82547) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
            uint16_t fused, fine, coarse;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
            /* Move to analog registers page */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
            e1000_read_phy_reg(hw, IGP01E1000_ANALOG_SPARE_FUSE_STATUS, &fused);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
            if (!(fused & IGP01E1000_ANALOG_SPARE_FUSE_ENABLED)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
                e1000_read_phy_reg(hw, IGP01E1000_ANALOG_FUSE_STATUS, &fused);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
                fine = fused & IGP01E1000_ANALOG_FUSE_FINE_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
                coarse = fused & IGP01E1000_ANALOG_FUSE_COARSE_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
                if (coarse > IGP01E1000_ANALOG_FUSE_COARSE_THRESH) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
                    coarse -= IGP01E1000_ANALOG_FUSE_COARSE_10;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
                    fine -= IGP01E1000_ANALOG_FUSE_FINE_1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
                } else if (coarse == IGP01E1000_ANALOG_FUSE_COARSE_THRESH)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
                    fine -= IGP01E1000_ANALOG_FUSE_FINE_10;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
                fused = (fused & IGP01E1000_ANALOG_FUSE_POLY_MASK) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
                        (fine & IGP01E1000_ANALOG_FUSE_FINE_MASK) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
                        (coarse & IGP01E1000_ANALOG_FUSE_COARSE_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
                e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_CONTROL, fused);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
                e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_BYPASS,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
                                    IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
 * Set the mac type member in the hw struct.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
e1000_set_mac_type(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
	DEBUGFUNC("e1000_set_mac_type");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
	switch (hw->device_id) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
	case E1000_DEV_ID_82542:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
		switch (hw->revision_id) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
		case E1000_82542_2_0_REV_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
			hw->mac_type = e1000_82542_rev2_0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
		case E1000_82542_2_1_REV_ID:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
			hw->mac_type = e1000_82542_rev2_1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
		default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
			/* Invalid 82542 revision ID */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
			return -E1000_ERR_MAC_TYPE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	case E1000_DEV_ID_82543GC_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
	case E1000_DEV_ID_82543GC_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
		hw->mac_type = e1000_82543;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
	case E1000_DEV_ID_82544EI_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
	case E1000_DEV_ID_82544EI_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
	case E1000_DEV_ID_82544GC_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
	case E1000_DEV_ID_82544GC_LOM:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
		hw->mac_type = e1000_82544;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
	case E1000_DEV_ID_82540EM:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
	case E1000_DEV_ID_82540EM_LOM:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
	case E1000_DEV_ID_82540EP:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
	case E1000_DEV_ID_82540EP_LOM:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
	case E1000_DEV_ID_82540EP_LP:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
		hw->mac_type = e1000_82540;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
	case E1000_DEV_ID_82545EM_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
	case E1000_DEV_ID_82545EM_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
		hw->mac_type = e1000_82545;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
	case E1000_DEV_ID_82545GM_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
	case E1000_DEV_ID_82545GM_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
	case E1000_DEV_ID_82545GM_SERDES:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
		hw->mac_type = e1000_82545_rev_3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
	case E1000_DEV_ID_82546EB_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
	case E1000_DEV_ID_82546EB_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
	case E1000_DEV_ID_82546EB_QUAD_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
		hw->mac_type = e1000_82546;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
	case E1000_DEV_ID_82546GB_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
	case E1000_DEV_ID_82546GB_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
	case E1000_DEV_ID_82546GB_SERDES:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
	case E1000_DEV_ID_82546GB_PCIE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
	case E1000_DEV_ID_82546GB_QUAD_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
		hw->mac_type = e1000_82546_rev_3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
	case E1000_DEV_ID_82541EI:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
	case E1000_DEV_ID_82541EI_MOBILE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
	case E1000_DEV_ID_82541ER_LOM:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
		hw->mac_type = e1000_82541;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
	case E1000_DEV_ID_82541ER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
	case E1000_DEV_ID_82541GI:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
	case E1000_DEV_ID_82541GI_LF:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
	case E1000_DEV_ID_82541GI_MOBILE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
		hw->mac_type = e1000_82541_rev_2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
	case E1000_DEV_ID_82547EI:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
	case E1000_DEV_ID_82547EI_MOBILE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
		hw->mac_type = e1000_82547;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
	case E1000_DEV_ID_82547GI:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
		hw->mac_type = e1000_82547_rev_2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
	case E1000_DEV_ID_82571EB_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
	case E1000_DEV_ID_82571EB_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
	case E1000_DEV_ID_82571EB_SERDES:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
	case E1000_DEV_ID_82571EB_QUAD_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
	case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
		hw->mac_type = e1000_82571;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
	case E1000_DEV_ID_82572EI_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
	case E1000_DEV_ID_82572EI_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
	case E1000_DEV_ID_82572EI_SERDES:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
	case E1000_DEV_ID_82572EI:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
		hw->mac_type = e1000_82572;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
	case E1000_DEV_ID_82573E:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
	case E1000_DEV_ID_82573E_IAMT:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
	case E1000_DEV_ID_82573L:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
		hw->mac_type = e1000_82573;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
	case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
	case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
	case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
	case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
		hw->mac_type = e1000_80003es2lan;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
	case E1000_DEV_ID_ICH8_IGP_M_AMT:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
	case E1000_DEV_ID_ICH8_IGP_AMT:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
	case E1000_DEV_ID_ICH8_IGP_C:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
	case E1000_DEV_ID_ICH8_IFE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
	case E1000_DEV_ID_ICH8_IFE_GT:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
	case E1000_DEV_ID_ICH8_IFE_G:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
	case E1000_DEV_ID_ICH8_IGP_M:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
		hw->mac_type = e1000_ich8lan;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
	default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
		/* Should never have loaded on this device */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
		return -E1000_ERR_MAC_TYPE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
	switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
	case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
		hw->swfwhw_semaphore_present = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
		hw->asf_firmware_present = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
	case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
		hw->swfw_sync_present = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
		/* fall through */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
	case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
	case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
	case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
		hw->eeprom_semaphore_present = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
		/* fall through */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
	case e1000_82541:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
	case e1000_82547:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
	case e1000_82541_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
	case e1000_82547_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
		hw->asf_firmware_present = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
	default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
	/* The 82543 chip does not count tx_carrier_errors properly in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
	 * FD mode
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
	 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
	if (hw->mac_type == e1000_82543)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
		hw->bad_tx_carr_stats_fd = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
	/* capable of receiving management packets to the host */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
	if (hw->mac_type >= e1000_82571)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
		hw->has_manc2h = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
	/* In rare occasions, ESB2 systems would end up started without
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
	 * the RX unit being turned on.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
	 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
	if (hw->mac_type == e1000_80003es2lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
		hw->rx_needs_kicking = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
	if (hw->mac_type > e1000_82544)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
		hw->has_smbus = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
	return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
 * Set media type and TBI compatibility.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
 * **************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
e1000_set_media_type(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
    uint32_t status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
    DEBUGFUNC("e1000_set_media_type");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
    if (hw->mac_type != e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
        /* tbi_compatibility is only valid on 82543 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
        hw->tbi_compatibility_en = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
    switch (hw->device_id) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
    case E1000_DEV_ID_82545GM_SERDES:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
    case E1000_DEV_ID_82546GB_SERDES:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
    case E1000_DEV_ID_82571EB_SERDES:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
    case E1000_DEV_ID_82572EI_SERDES:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
    case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
        hw->media_type = e1000_media_type_internal_serdes;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
        switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
        case e1000_82542_rev2_0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
        case e1000_82542_rev2_1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
            hw->media_type = e1000_media_type_fiber;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
        case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
        case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
            /* The STATUS_TBIMODE bit is reserved or reused for the this
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
             * device.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
            hw->media_type = e1000_media_type_copper;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
            status = E1000_READ_REG(hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
            if (status & E1000_STATUS_TBIMODE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
                hw->media_type = e1000_media_type_fiber;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
                /* tbi_compatibility not valid on fiber */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
                hw->tbi_compatibility_en = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
                hw->media_type = e1000_media_type_copper;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
 * Reset the transmit and receive units; mask and clear all interrupts.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
e1000_reset_hw(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
    uint32_t ctrl_ext;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
    uint32_t icr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
    uint32_t manc;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
    uint32_t led_ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
    uint32_t timeout;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
    uint32_t extcnf_ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
    DEBUGFUNC("e1000_reset_hw");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
    /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
    if (hw->mac_type == e1000_82542_rev2_0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
        DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
        e1000_pci_clear_mwi(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
    if (hw->bus_type == e1000_bus_type_pci_express) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
        /* Prevent the PCI-E bus from sticking if there is no TLP connection
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
         * on the last TLP read/write transaction when MAC is reset.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
        if (e1000_disable_pciex_master(hw) != E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
            DEBUGOUT("PCI-E Master disable polling has failed.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
    /* Clear interrupt mask to stop board from generating interrupts */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
    DEBUGOUT("Masking off all interrupts\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
    E1000_WRITE_REG(hw, IMC, 0xffffffff);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
    /* Disable the Transmit and Receive units.  Then delay to allow
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
     * any pending transactions to complete before we hit the MAC with
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
     * the global reset.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
    E1000_WRITE_REG(hw, RCTL, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
    E1000_WRITE_REG(hw, TCTL, E1000_TCTL_PSP);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
    /* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
    hw->tbi_compatibility_on = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
    /* Delay to allow any outstanding PCI transactions to complete before
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
     * resetting the device
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
    msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
    /* Must reset the PHY before resetting the MAC */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
    if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
        E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_PHY_RST));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
        msleep(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
    /* Must acquire the MDIO ownership before MAC reset.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
     * Ownership defaults to firmware after a reset. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
    if (hw->mac_type == e1000_82573) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
        timeout = 10;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
        extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
        extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
        do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
            E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
            extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
            if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
            else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
                extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
            msleep(2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
            timeout--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
        } while (timeout);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
    /* Workaround for ICH8 bit corruption issue in FIFO memory */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
    if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
        /* Set Tx and Rx buffer allocation to 8k apiece. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
        E1000_WRITE_REG(hw, PBA, E1000_PBA_8K);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
        /* Set Packet Buffer Size to 16k. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
        E1000_WRITE_REG(hw, PBS, E1000_PBS_16K);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
    /* Issue a global reset to the MAC.  This will reset the chip's
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
     * transmit, receive, DMA, and link units.  It will not effect
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
     * the current PCI configuration.  The global reset bit is self-
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
     * clearing, and should clear within a microsecond.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
    DEBUGOUT("Issuing a global reset to MAC\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
        case e1000_82544:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
        case e1000_82540:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
        case e1000_82545:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
        case e1000_82546:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
        case e1000_82541:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
        case e1000_82541_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
            /* These controllers can't ack the 64-bit write when issuing the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
             * reset, so use IO-mapping as a workaround to issue the reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
            E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_RST));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
        case e1000_82545_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
        case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
            /* Reset is performed on a shadow of the control register */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
            E1000_WRITE_REG(hw, CTRL_DUP, (ctrl | E1000_CTRL_RST));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
        case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
            if (!hw->phy_reset_disable &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
                e1000_check_phy_reset_block(hw) == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
                /* e1000_ich8lan PHY HW reset requires MAC CORE reset
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
                 * at the same time to make sure the interface between
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
                 * MAC and the external PHY is reset.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
                 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
                ctrl |= E1000_CTRL_PHY_RST;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
            e1000_get_software_flag(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
            E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
            msleep(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
            E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
    /* After MAC reset, force reload of EEPROM to restore power-on settings to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
     * device.  Later controllers reload the EEPROM automatically, so just wait
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
     * for reload to complete.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
        case e1000_82542_rev2_0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
        case e1000_82542_rev2_1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
        case e1000_82543:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
        case e1000_82544:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
            /* Wait for reset to complete */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
            udelay(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
            ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
            ctrl_ext |= E1000_CTRL_EXT_EE_RST;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
            E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
            E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
            /* Wait for EEPROM reload */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
            msleep(2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
        case e1000_82541:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
        case e1000_82541_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
        case e1000_82547:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
        case e1000_82547_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
            /* Wait for EEPROM reload */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
            msleep(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
        case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
            if (e1000_is_onboard_nvm_eeprom(hw) == FALSE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
                udelay(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
                ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
                ctrl_ext |= E1000_CTRL_EXT_EE_RST;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
                E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
                E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
            /* fall through */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
            /* Auto read done will delay 5ms or poll based on mac type */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
            ret_val = e1000_get_auto_rd_done(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
    /* Disable HW ARPs on ASF enabled adapters */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
    if (hw->mac_type >= e1000_82540 && hw->mac_type <= e1000_82547_rev_2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
        manc = E1000_READ_REG(hw, MANC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
        manc &= ~(E1000_MANC_ARP_EN);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
        E1000_WRITE_REG(hw, MANC, manc);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
    if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
        e1000_phy_init_script(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
        /* Configure activity LED after PHY reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
        led_ctrl = E1000_READ_REG(hw, LEDCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
        led_ctrl &= IGP_ACTIVITY_LED_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
        led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
        E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
    /* Clear interrupt mask to stop board from generating interrupts */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
    DEBUGOUT("Masking off all interrupts\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
    E1000_WRITE_REG(hw, IMC, 0xffffffff);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
    /* Clear any pending interrupt events. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
    icr = E1000_READ_REG(hw, ICR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
    /* If MWI was previously enabled, reenable it. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
    if (hw->mac_type == e1000_82542_rev2_0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
        if (hw->pci_cmd_word & PCI_COMMAND_INVALIDATE)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
            e1000_pci_set_mwi(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
    if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
        uint32_t kab = E1000_READ_REG(hw, KABGTXD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
        kab |= E1000_KABGTXD_BGSQLBIAS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
        E1000_WRITE_REG(hw, KABGTXD, kab);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
 * Initialize a number of hardware-dependent bits
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
 * This function contains hardware limitation workarounds for PCI-E adapters
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
e1000_initialize_hardware_bits(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
    if ((hw->mac_type >= e1000_82571) && (!hw->initialize_hw_bits_disable)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
        /* Settings common to all PCI-express silicon */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
        uint32_t reg_ctrl, reg_ctrl_ext;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
        uint32_t reg_tarc0, reg_tarc1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
        uint32_t reg_tctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
        uint32_t reg_txdctl, reg_txdctl1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
        /* link autonegotiation/sync workarounds */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
        reg_tarc0 = E1000_READ_REG(hw, TARC0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
        reg_tarc0 &= ~((1 << 30)|(1 << 29)|(1 << 28)|(1 << 27));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
        /* Enable not-done TX descriptor counting */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
        reg_txdctl = E1000_READ_REG(hw, TXDCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
        reg_txdctl |= E1000_TXDCTL_COUNT_DESC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
        E1000_WRITE_REG(hw, TXDCTL, reg_txdctl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
        reg_txdctl1 = E1000_READ_REG(hw, TXDCTL1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
        reg_txdctl1 |= E1000_TXDCTL_COUNT_DESC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
        E1000_WRITE_REG(hw, TXDCTL1, reg_txdctl1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
        switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
            case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
            case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
                /* Clear PHY TX compatible mode bits */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
                reg_tarc1 = E1000_READ_REG(hw, TARC1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
                reg_tarc1 &= ~((1 << 30)|(1 << 29));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
                /* link autonegotiation/sync workarounds */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
                reg_tarc0 |= ((1 << 26)|(1 << 25)|(1 << 24)|(1 << 23));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
                /* TX ring control fixes */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
                reg_tarc1 |= ((1 << 26)|(1 << 25)|(1 << 24));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
                /* Multiple read bit is reversed polarity */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
                reg_tctl = E1000_READ_REG(hw, TCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
                if (reg_tctl & E1000_TCTL_MULR)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
                    reg_tarc1 &= ~(1 << 28);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
                else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
                    reg_tarc1 |= (1 << 28);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
                E1000_WRITE_REG(hw, TARC1, reg_tarc1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
            case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
                reg_ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
                reg_ctrl_ext &= ~(1 << 23);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
                reg_ctrl_ext |= (1 << 22);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
                /* TX byte count fix */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
                reg_ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
                reg_ctrl &= ~(1 << 29);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
                E1000_WRITE_REG(hw, CTRL_EXT, reg_ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
                E1000_WRITE_REG(hw, CTRL, reg_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
            case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
                /* improve small packet performace for fiber/serdes */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
                if ((hw->media_type == e1000_media_type_fiber) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
                    (hw->media_type == e1000_media_type_internal_serdes)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
                    reg_tarc0 &= ~(1 << 20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
                /* Multiple read bit is reversed polarity */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
                reg_tctl = E1000_READ_REG(hw, TCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
                reg_tarc1 = E1000_READ_REG(hw, TARC1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
                if (reg_tctl & E1000_TCTL_MULR)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
                    reg_tarc1 &= ~(1 << 28);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
                else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
                    reg_tarc1 |= (1 << 28);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
                E1000_WRITE_REG(hw, TARC1, reg_tarc1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
            case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
                /* Reduce concurrent DMA requests to 3 from 4 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
                if ((hw->revision_id < 3) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
                    ((hw->device_id != E1000_DEV_ID_ICH8_IGP_M_AMT) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
                     (hw->device_id != E1000_DEV_ID_ICH8_IGP_M)))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
                    reg_tarc0 |= ((1 << 29)|(1 << 28));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
                reg_ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
                reg_ctrl_ext |= (1 << 22);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
                E1000_WRITE_REG(hw, CTRL_EXT, reg_ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
                /* workaround TX hang with TSO=on */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
                reg_tarc0 |= ((1 << 27)|(1 << 26)|(1 << 24)|(1 << 23));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
                /* Multiple read bit is reversed polarity */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
                reg_tctl = E1000_READ_REG(hw, TCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
                reg_tarc1 = E1000_READ_REG(hw, TARC1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
                if (reg_tctl & E1000_TCTL_MULR)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
                    reg_tarc1 &= ~(1 << 28);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
                else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
                    reg_tarc1 |= (1 << 28);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
                /* workaround TX hang with TSO=on */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
                reg_tarc1 |= ((1 << 30)|(1 << 26)|(1 << 24));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
                E1000_WRITE_REG(hw, TARC1, reg_tarc1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
            default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
        E1000_WRITE_REG(hw, TARC0, reg_tarc0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
 * Performs basic configuration of the adapter.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
 * Assumes that the controller has previously been reset and is in a
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
 * post-reset uninitialized state. Initializes the receive address registers,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
 * multicast table, and VLAN filter table. Calls routines to setup link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
 * configuration and flow control settings. Clears all on-chip counters. Leaves
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
 * the transmit and receive units disabled and uninitialized.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
e1000_init_hw(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
    uint32_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
    uint16_t pcix_cmd_word;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
    uint16_t pcix_stat_hi_word;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
    uint16_t cmd_mmrbc;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
    uint16_t stat_mmrbc;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
    uint32_t mta_size;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
    uint32_t reg_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
    uint32_t ctrl_ext;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
    DEBUGFUNC("e1000_init_hw");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
    /* force full DMA clock frequency for 10/100 on ICH8 A0-B0 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
    if ((hw->mac_type == e1000_ich8lan) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
        ((hw->revision_id < 3) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
         ((hw->device_id != E1000_DEV_ID_ICH8_IGP_M_AMT) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
          (hw->device_id != E1000_DEV_ID_ICH8_IGP_M)))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
            reg_data = E1000_READ_REG(hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
            reg_data &= ~0x80000000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
            E1000_WRITE_REG(hw, STATUS, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
    /* Initialize Identification LED */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
    ret_val = e1000_id_led_init(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
    if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
        DEBUGOUT("Error Initializing Identification LED\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
    /* Set the media type and TBI compatibility */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
    e1000_set_media_type(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
    /* Must be called after e1000_set_media_type because media_type is used */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
    e1000_initialize_hardware_bits(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
    /* Disabling VLAN filtering. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
    DEBUGOUT("Initializing the IEEE VLAN\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
    /* VET hardcoded to standard value and VFTA removed in ICH8 LAN */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
    if (hw->mac_type != e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
        if (hw->mac_type < e1000_82545_rev_3)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
            E1000_WRITE_REG(hw, VET, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
        e1000_clear_vfta(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
    /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
    if (hw->mac_type == e1000_82542_rev2_0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
        DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
        e1000_pci_clear_mwi(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
        E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
        msleep(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
    /* Setup the receive address. This involves initializing all of the Receive
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
     * Address Registers (RARs 0 - 15).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
    e1000_init_rx_addrs(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
    /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
    if (hw->mac_type == e1000_82542_rev2_0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
        E1000_WRITE_REG(hw, RCTL, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
        msleep(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
        if (hw->pci_cmd_word & PCI_COMMAND_INVALIDATE)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
            e1000_pci_set_mwi(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
    /* Zero out the Multicast HASH table */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
    DEBUGOUT("Zeroing the MTA\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
    mta_size = E1000_MC_TBL_SIZE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
    if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
        mta_size = E1000_MC_TBL_SIZE_ICH8LAN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
    for (i = 0; i < mta_size; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
        E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
        /* use write flush to prevent Memory Write Block (MWB) from
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
         * occuring when accessing our register space */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
    /* Set the PCI priority bit correctly in the CTRL register.  This
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
     * determines if the adapter gives priority to receives, or if it
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
     * gives equal priority to transmits and receives.  Valid only on
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
     * 82542 and 82543 silicon.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
    if (hw->dma_fairness && hw->mac_type <= e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
        ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
        E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
    case e1000_82545_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
    case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
        /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
        if (hw->bus_type == e1000_bus_type_pcix) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
            e1000_read_pci_cfg(hw, PCIX_COMMAND_REGISTER, &pcix_cmd_word);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
            e1000_read_pci_cfg(hw, PCIX_STATUS_REGISTER_HI,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
                &pcix_stat_hi_word);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
            cmd_mmrbc = (pcix_cmd_word & PCIX_COMMAND_MMRBC_MASK) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
                PCIX_COMMAND_MMRBC_SHIFT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
            stat_mmrbc = (pcix_stat_hi_word & PCIX_STATUS_HI_MMRBC_MASK) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
                PCIX_STATUS_HI_MMRBC_SHIFT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
            if (stat_mmrbc == PCIX_STATUS_HI_MMRBC_4K)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
                stat_mmrbc = PCIX_STATUS_HI_MMRBC_2K;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
            if (cmd_mmrbc > stat_mmrbc) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
                pcix_cmd_word &= ~PCIX_COMMAND_MMRBC_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
                pcix_cmd_word |= stat_mmrbc << PCIX_COMMAND_MMRBC_SHIFT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
                e1000_write_pci_cfg(hw, PCIX_COMMAND_REGISTER,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
                    &pcix_cmd_word);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
    /* More time needed for PHY to initialize */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
    if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
        msleep(15);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
    /* Call a subroutine to configure the link and setup flow control. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
    ret_val = e1000_setup_link(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
    /* Set the transmit descriptor write-back policy */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
    if (hw->mac_type > e1000_82544) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
        ctrl = E1000_READ_REG(hw, TXDCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
        ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
        E1000_WRITE_REG(hw, TXDCTL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
    if (hw->mac_type == e1000_82573) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
        e1000_enable_tx_pkt_filtering(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
        /* Enable retransmit on late collisions */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
        reg_data = E1000_READ_REG(hw, TCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
        reg_data |= E1000_TCTL_RTLC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
        E1000_WRITE_REG(hw, TCTL, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
        /* Configure Gigabit Carry Extend Padding */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
        reg_data = E1000_READ_REG(hw, TCTL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
        reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
        reg_data |= DEFAULT_80003ES2LAN_TCTL_EXT_GCEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
        E1000_WRITE_REG(hw, TCTL_EXT, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
        /* Configure Transmit Inter-Packet Gap */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
        reg_data = E1000_READ_REG(hw, TIPG);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
        reg_data &= ~E1000_TIPG_IPGT_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
        reg_data |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
        E1000_WRITE_REG(hw, TIPG, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
        reg_data = E1000_READ_REG_ARRAY(hw, FFLT, 0x0001);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
        reg_data &= ~0x00100000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
        E1000_WRITE_REG_ARRAY(hw, FFLT, 0x0001, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
        /* Fall through */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
    case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
    case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
    case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
        ctrl = E1000_READ_REG(hw, TXDCTL1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
        ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
        E1000_WRITE_REG(hw, TXDCTL1, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
    if (hw->mac_type == e1000_82573) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
        uint32_t gcr = E1000_READ_REG(hw, GCR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
        gcr |= E1000_GCR_L1_ACT_WITHOUT_L0S_RX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
        E1000_WRITE_REG(hw, GCR, gcr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
    /* Clear all of the statistics registers (clear on read).  It is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
     * important that we do this after we have tried to establish link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
     * because the symbol error count will increment wildly if there
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
     * is no link.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
    e1000_clear_hw_cntrs(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
    /* ICH8 No-snoop bits are opposite polarity.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
     * Set to snoop by default after reset. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
    if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
        e1000_set_pci_ex_no_snoop(hw, PCI_EX_82566_SNOOP_ALL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
    if (hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
        hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
        ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
        /* Relaxed ordering must be disabled to avoid a parity
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
         * error crash in a PCI slot. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
        ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
 * Adjust SERDES output amplitude based on EEPROM setting.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
 * hw - Struct containing variables accessed by shared code.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
e1000_adjust_serdes_amplitude(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
    uint16_t eeprom_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
    int32_t  ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
    DEBUGFUNC("e1000_adjust_serdes_amplitude");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
    if (hw->media_type != e1000_media_type_internal_serdes)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
    case e1000_82545_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
    case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
    ret_val = e1000_read_eeprom(hw, EEPROM_SERDES_AMPLITUDE, 1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
    if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
    if (eeprom_data != EEPROM_RESERVED_WORD) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
        /* Adjust SERDES output amplitude only. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
        eeprom_data &= EEPROM_SERDES_AMPLITUDE_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
        ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_EXT_CTRL, eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
 * Configures flow control and link settings.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
 * Determines which flow control settings to use. Calls the apropriate media-
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
 * specific link configuration function. Configures the flow control settings.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
 * Assuming the adapter has a valid link partner, a valid link should be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
 * established. Assumes the hardware has previously been reset and the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
 * transmitter and receiver are not enabled.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
e1000_setup_link(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
    uint32_t ctrl_ext;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
    uint16_t eeprom_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
    DEBUGFUNC("e1000_setup_link");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
    /* In the case of the phy reset being blocked, we already have a link.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
     * We do not have to set it up again. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
    if (e1000_check_phy_reset_block(hw))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
    /* Read and store word 0x0F of the EEPROM. This word contains bits
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
     * that determine the hardware's default PAUSE (flow control) mode,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
     * a bit that determines whether the HW defaults to enabling or
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
     * disabling auto-negotiation, and the direction of the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
     * SW defined pins. If there is no SW over-ride of the flow
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
     * control setting, then the variable hw->fc will
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
     * be initialized based on a value in the EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
    if (hw->fc == E1000_FC_DEFAULT) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
        switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
        case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
        case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
            hw->fc = E1000_FC_FULL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
            ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
                                        1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
            if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
                DEBUGOUT("EEPROM Read Error\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
                return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
            if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
                hw->fc = E1000_FC_NONE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
            else if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
                    EEPROM_WORD0F_ASM_DIR)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
                hw->fc = E1000_FC_TX_PAUSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
            else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
                hw->fc = E1000_FC_FULL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
    /* We want to save off the original Flow Control configuration just
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
     * in case we get disconnected and then reconnected into a different
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
     * hub or switch with different Flow Control capabilities.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
    if (hw->mac_type == e1000_82542_rev2_0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
        hw->fc &= (~E1000_FC_TX_PAUSE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
    if ((hw->mac_type < e1000_82543) && (hw->report_tx_early == 1))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
        hw->fc &= (~E1000_FC_RX_PAUSE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
    hw->original_fc = hw->fc;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
    DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
    /* Take the 4 bits from EEPROM word 0x0F that determine the initial
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
     * polarity value for the SW controlled pins, and setup the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
     * Extended Device Control reg with that info.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
     * This is needed because one of the SW controlled pins is used for
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
     * signal detection.  So this should be done before e1000_setup_pcs_link()
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
     * or e1000_phy_setup() is called.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
    if (hw->mac_type == e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
        ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
                                    1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
            DEBUGOUT("EEPROM Read Error\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
        ctrl_ext = ((eeprom_data & EEPROM_WORD0F_SWPDIO_EXT) <<
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
                    SWDPIO__EXT_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
    /* Call the necessary subroutine to configure the link. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
    ret_val = (hw->media_type == e1000_media_type_copper) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
              e1000_setup_copper_link(hw) :
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
              e1000_setup_fiber_serdes_link(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
    /* Initialize the flow control address, type, and PAUSE timer
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
     * registers to their default values.  This is done even if flow
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
     * control is disabled, because it does not hurt anything to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
     * initialize these registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
    DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
    /* FCAL/H and FCT are hardcoded to standard values in e1000_ich8lan. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
    if (hw->mac_type != e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
        E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
        E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
        E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
    E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
    /* Set the flow control receive threshold registers.  Normally,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
     * these registers will be set to a default threshold that may be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
     * adjusted later by the driver's runtime code.  However, if the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
     * ability to transmit pause frames in not enabled, then these
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
     * registers will be set to 0.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
    if (!(hw->fc & E1000_FC_TX_PAUSE)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
        E1000_WRITE_REG(hw, FCRTL, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
        E1000_WRITE_REG(hw, FCRTH, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
        /* We need to set up the Receive Threshold high and low water marks
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
         * as well as (optionally) enabling the transmission of XON frames.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
        if (hw->fc_send_xon) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
            E1000_WRITE_REG(hw, FCRTL, (hw->fc_low_water | E1000_FCRTL_XONE));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
            E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
            E1000_WRITE_REG(hw, FCRTL, hw->fc_low_water);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
            E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
 * Sets up link for a fiber based or serdes based adapter
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
 * Manipulates Physical Coding Sublayer functions in order to configure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
 * link. Assumes the hardware has been previously reset and the transmitter
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
 * and receiver are not enabled.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
    uint32_t status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
    uint32_t txcw = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
    uint32_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
    uint32_t signal = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
    DEBUGFUNC("e1000_setup_fiber_serdes_link");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
    /* On 82571 and 82572 Fiber connections, SerDes loopback mode persists
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
     * until explicitly turned off or a power cycle is performed.  A read to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
     * the register does not indicate its status.  Therefore, we ensure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
     * loopback mode is disabled during initialization.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
    if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
        E1000_WRITE_REG(hw, SCTL, E1000_DISABLE_SERDES_LOOPBACK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
    /* On adapters with a MAC newer than 82544, SWDP 1 will be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
     * set when the optics detect a signal. On older adapters, it will be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
     * cleared when there is a signal.  This applies to fiber media only.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
     * If we're on serdes media, adjust the output amplitude to value
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
     * set in the EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
    if (hw->media_type == e1000_media_type_fiber)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
        signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
    ret_val = e1000_adjust_serdes_amplitude(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
    /* Take the link out of reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
    ctrl &= ~(E1000_CTRL_LRST);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
    /* Adjust VCO speed to improve BER performance */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
    ret_val = e1000_set_vco_speed(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
    e1000_config_collision_dist(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
    /* Check for a software override of the flow control settings, and setup
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
     * the device accordingly.  If auto-negotiation is enabled, then software
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
     * will have to set the "PAUSE" bits to the correct value in the Tranmsit
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
     * Config Word Register (TXCW) and re-start auto-negotiation.  However, if
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
     * auto-negotiation is disabled, then software will have to manually
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
     * configure the two flow control enable bits in the CTRL register.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
     *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
     * The possible values of the "fc" parameter are:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
     *      0:  Flow control is completely disabled
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
     *      1:  Rx flow control is enabled (we can receive pause frames, but
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
     *          not send pause frames).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
     *      2:  Tx flow control is enabled (we can send pause frames but we do
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
     *          not support receiving pause frames).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
     *      3:  Both Rx and TX flow control (symmetric) are enabled.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
    switch (hw->fc) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
    case E1000_FC_NONE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
        /* Flow control is completely disabled by a software over-ride. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
        txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
    case E1000_FC_RX_PAUSE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
        /* RX Flow control is enabled and TX Flow control is disabled by a
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
         * software over-ride. Since there really isn't a way to advertise
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
         * that we are capable of RX Pause ONLY, we will advertise that we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
         * support both symmetric and asymmetric RX PAUSE. Later, we will
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
         *  disable the adapter's ability to send PAUSE frames.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
        txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
    case E1000_FC_TX_PAUSE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
        /* TX Flow control is enabled, and RX Flow control is disabled, by a
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
         * software over-ride.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
        txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
    case E1000_FC_FULL:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
        /* Flow control (both RX and TX) is enabled by a software over-ride. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
        txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
        DEBUGOUT("Flow control param set incorrectly\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
        return -E1000_ERR_CONFIG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
    /* Since auto-negotiation is enabled, take the link out of reset (the link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
     * will be in reset, because we previously reset the chip). This will
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
     * restart auto-negotiation.  If auto-neogtiation is successful then the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
     * link-up status bit will be set and the flow control enable bits (RFCE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
     * and TFCE) will be set according to their negotiated value.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
    DEBUGOUT("Auto-negotiation enabled\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
    E1000_WRITE_REG(hw, TXCW, txcw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
    E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
    hw->txcw = txcw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
    msleep(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
    /* If we have a signal (the cable is plugged in) then poll for a "Link-Up"
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
     * indication in the Device Status Register.  Time-out if a link isn't
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
     * seen in 500 milliseconds seconds (Auto-negotiation should complete in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
     * less than 500 milliseconds even if the other end is doing it in SW).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
     * For internal serdes, we just assume a signal is present, then poll.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
    if (hw->media_type == e1000_media_type_internal_serdes ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
       (E1000_READ_REG(hw, CTRL) & E1000_CTRL_SWDPIN1) == signal) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
        DEBUGOUT("Looking for Link\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
        for (i = 0; i < (LINK_UP_TIMEOUT / 10); i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
            msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
            status = E1000_READ_REG(hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
            if (status & E1000_STATUS_LU) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
        if (i == (LINK_UP_TIMEOUT / 10)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
            DEBUGOUT("Never got a valid link from auto-neg!!!\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
            hw->autoneg_failed = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
            /* AutoNeg failed to achieve a link, so we'll call
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
             * e1000_check_for_link. This routine will force the link up if
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
             * we detect a signal. This will allow us to communicate with
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
             * non-autonegotiating link partners.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
            ret_val = e1000_check_for_link(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
            if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
                DEBUGOUT("Error while checking for link\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
            hw->autoneg_failed = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
            hw->autoneg_failed = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
            DEBUGOUT("Valid Link Found\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
        DEBUGOUT("No Signal Detected\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
* Make sure we have a valid PHY and change PHY mode before link setup.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
e1000_copper_link_preconfig(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
    DEBUGFUNC("e1000_copper_link_preconfig");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
    /* With 82543, we need to force speed and duplex on the MAC equal to what
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
     * the PHY speed and duplex configuration is. In addition, we need to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
     * perform a hardware reset on the PHY to take it out of reset.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
    if (hw->mac_type > e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
        ctrl |= E1000_CTRL_SLU;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
        ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
        E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
        ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
        E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
        ret_val = e1000_phy_hw_reset(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
    /* Make sure we have a valid PHY */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
    ret_val = e1000_detect_gig_phy(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
    if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
        DEBUGOUT("Error, did not detect valid phy.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
    DEBUGOUT1("Phy ID = %x \n", hw->phy_id);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
    /* Set PHY to class A mode (if necessary) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
    ret_val = e1000_set_phy_mode(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
    if ((hw->mac_type == e1000_82545_rev_3) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
       (hw->mac_type == e1000_82546_rev_3)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
        phy_data |= 0x00000008;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
        ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
    if (hw->mac_type <= e1000_82543 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
        hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
        hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
        hw->phy_reset_disable = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
   return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
/********************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
* Copper link setup for e1000_phy_igp series.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
*********************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
e1000_copper_link_igp_setup(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
    uint32_t led_ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
    DEBUGFUNC("e1000_copper_link_igp_setup");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
    if (hw->phy_reset_disable)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
    ret_val = e1000_phy_reset(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
    if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
        DEBUGOUT("Error Resetting the PHY\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
    /* Wait 15ms for MAC to configure PHY from eeprom settings */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
    msleep(15);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
    if (hw->mac_type != e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
    /* Configure activity LED after PHY reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
    led_ctrl = E1000_READ_REG(hw, LEDCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
    led_ctrl &= IGP_ACTIVITY_LED_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
    led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
    E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
    /* The NVM settings will configure LPLU in D3 for IGP2 and IGP3 PHYs */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
    if (hw->phy_type == e1000_phy_igp) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
        /* disable lplu d3 during driver init */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
        ret_val = e1000_set_d3_lplu_state(hw, FALSE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
            DEBUGOUT("Error Disabling LPLU D3\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
    /* disable lplu d0 during driver init */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
    ret_val = e1000_set_d0_lplu_state(hw, FALSE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
    if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
        DEBUGOUT("Error Disabling LPLU D0\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
    /* Configure mdi-mdix settings */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
    ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
    if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
        hw->dsp_config_state = e1000_dsp_config_disabled;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
        /* Force MDI for earlier revs of the IGP PHY */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
        phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX | IGP01E1000_PSCR_FORCE_MDI_MDIX);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
        hw->mdix = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
        hw->dsp_config_state = e1000_dsp_config_enabled;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
        phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
        switch (hw->mdix) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
        case 1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
            phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
        case 2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
            phy_data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
        case 0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
            phy_data |= IGP01E1000_PSCR_AUTO_MDIX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
    ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
    /* set auto-master slave resolution settings */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
    if (hw->autoneg) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
        e1000_ms_type phy_ms_setting = hw->master_slave;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
        if (hw->ffe_config_state == e1000_ffe_config_active)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
            hw->ffe_config_state = e1000_ffe_config_enabled;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
        if (hw->dsp_config_state == e1000_dsp_config_activated)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
            hw->dsp_config_state = e1000_dsp_config_enabled;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
        /* when autonegotiation advertisment is only 1000Mbps then we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
          * should disable SmartSpeed and enable Auto MasterSlave
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
          * resolution as hardware default. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
        if (hw->autoneg_advertised == ADVERTISE_1000_FULL) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
            /* Disable SmartSpeed */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
                                         &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
            phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
                                          phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
            /* Set auto Master/Slave resolution process */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
            ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
            phy_data &= ~CR_1000T_MS_ENABLE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
            ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
        ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
        /* load defaults for future use */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
        hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
                                        ((phy_data & CR_1000T_MS_VALUE) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
                                         e1000_ms_force_master :
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
                                         e1000_ms_force_slave) :
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
                                         e1000_ms_auto;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
        switch (phy_ms_setting) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
        case e1000_ms_force_master:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
            phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
        case e1000_ms_force_slave:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
            phy_data |= CR_1000T_MS_ENABLE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
            phy_data &= ~(CR_1000T_MS_VALUE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
        case e1000_ms_auto:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
            phy_data &= ~CR_1000T_MS_ENABLE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
            default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
        ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
/********************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
* Copper link setup for e1000_phy_gg82563 series.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
*********************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
e1000_copper_link_ggp_setup(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
    uint32_t reg_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
    DEBUGFUNC("e1000_copper_link_ggp_setup");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
    if (!hw->phy_reset_disable) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
        /* Enable CRS on TX for half-duplex operation. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
                                     &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
        phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
        /* Use 25MHz for both link down and 1000BASE-T for Tx clock */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
        phy_data |= GG82563_MSCR_TX_CLK_1000MBPS_25MHZ;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
                                      phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
        /* Options:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
         *   MDI/MDI-X = 0 (default)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
         *   0 - Auto for all speeds
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
         *   1 - MDI mode
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
         *   2 - MDI-X mode
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
         *   3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
        phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
        switch (hw->mdix) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
        case 1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
            phy_data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
        case 2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
            phy_data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
        case 0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
            phy_data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
        /* Options:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
         *   disable_polarity_correction = 0 (default)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
         *       Automatic Correction for Reversed Cable Polarity
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
         *   0 - Disabled
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
         *   1 - Enabled
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
        phy_data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
        if (hw->disable_polarity_correction == 1)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
            phy_data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_SPEC_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
        /* SW Reset the PHY so all changes take effect */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
        ret_val = e1000_phy_reset(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
            DEBUGOUT("Error Resetting the PHY\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
    } /* phy_reset_disable */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
    if (hw->mac_type == e1000_80003es2lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
        /* Bypass RX and TX FIFO's */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
        ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_FIFO_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
                                       E1000_KUMCTRLSTA_FIFO_CTRL_RX_BYPASS |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
                                       E1000_KUMCTRLSTA_FIFO_CTRL_TX_BYPASS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_SPEC_CTRL_2, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
        phy_data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_SPEC_CTRL_2, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
        reg_data = E1000_READ_REG(hw, CTRL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
        reg_data &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
        E1000_WRITE_REG(hw, CTRL_EXT, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_PWR_MGMT_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
                                          &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
        /* Do not init these registers when the HW is in IAMT mode, since the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
         * firmware will have already initialized them.  We only initialize
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
         * them if the HW is not in IAMT mode.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
        if (e1000_check_mng_mode(hw) == FALSE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
            /* Enable Electrical Idle on the PHY */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
            phy_data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
            ret_val = e1000_write_phy_reg(hw, GG82563_PHY_PWR_MGMT_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
                                          phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
            ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
                                         &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
            phy_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
            ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
                                          phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
        /* Workaround: Disable padding in Kumeran interface in the MAC
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
         * and in the PHY to avoid CRC errors.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_INBAND_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
                                     &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
        phy_data |= GG82563_ICR_DIS_PADDING;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_INBAND_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
                                      phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
/********************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
* Copper link setup for e1000_phy_m88 series.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
*********************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
e1000_copper_link_mgp_setup(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
    DEBUGFUNC("e1000_copper_link_mgp_setup");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
    if (hw->phy_reset_disable)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
    /* Enable CRS on TX. This must be set for half-duplex operation. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
    phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
    /* Options:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
     *   MDI/MDI-X = 0 (default)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
     *   0 - Auto for all speeds
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
     *   1 - MDI mode
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
     *   2 - MDI-X mode
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
     *   3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
    phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
    switch (hw->mdix) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
    case 1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
        phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
    case 2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
        phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
    case 3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
        phy_data |= M88E1000_PSCR_AUTO_X_1000T;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
    case 0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
        phy_data |= M88E1000_PSCR_AUTO_X_MODE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
    /* Options:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
     *   disable_polarity_correction = 0 (default)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
     *       Automatic Correction for Reversed Cable Polarity
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
     *   0 - Disabled
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
     *   1 - Enabled
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
    phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
    if (hw->disable_polarity_correction == 1)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
        phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
    if (hw->phy_revision < M88E1011_I_REV_4) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
        /* Force TX_CLK in the Extended PHY Specific Control Register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
         * to 25MHz clock.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
        ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
        phy_data |= M88E1000_EPSCR_TX_CLK_25;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
        if ((hw->phy_revision == E1000_REVISION_2) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
            (hw->phy_id == M88E1111_I_PHY_ID)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
            /* Vidalia Phy, set the downshift counter to 5x */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
            phy_data &= ~(M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
            phy_data |= M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
            ret_val = e1000_write_phy_reg(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
                                        M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
            /* Configure Master and Slave downshift values */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
            phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
                              M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
            phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
                             M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
            ret_val = e1000_write_phy_reg(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
                                        M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
               return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
    /* SW Reset the PHY so all changes take effect */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
    ret_val = e1000_phy_reset(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
    if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
        DEBUGOUT("Error Resetting the PHY\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
   return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
/********************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
* Setup auto-negotiation and flow control advertisements,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
* and then perform auto-negotiation.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
*********************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
e1000_copper_link_autoneg(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
    DEBUGFUNC("e1000_copper_link_autoneg");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
    /* Perform some bounds checking on the hw->autoneg_advertised
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
     * parameter.  If this variable is zero, then set it to the default.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
    hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
    /* If autoneg_advertised is zero, we assume it was not defaulted
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
     * by the calling code so we set to advertise full capability.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
    if (hw->autoneg_advertised == 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
        hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
    /* IFE phy only supports 10/100 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
    if (hw->phy_type == e1000_phy_ife)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
        hw->autoneg_advertised &= AUTONEG_ADVERTISE_10_100_ALL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
    DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
    ret_val = e1000_phy_setup_autoneg(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
    if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
        DEBUGOUT("Error Setting up Auto-Negotiation\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
    DEBUGOUT("Restarting Auto-Neg\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
    /* Restart auto-negotiation by setting the Auto Neg Enable bit and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
     * the Auto Neg Restart bit in the PHY control register.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
    ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
    phy_data |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
    ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
    /* Does the user want to wait for Auto-Neg to complete here, or
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
     * check at a later time (for example, callback routine).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
    if (hw->wait_autoneg_complete) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
        ret_val = e1000_wait_autoneg(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
            DEBUGOUT("Error while waiting for autoneg to complete\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
    hw->get_link_status = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
* Config the MAC and the PHY after link is up.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
*   1) Set up the MAC to the current PHY speed/duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
*      if we are on 82543.  If we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
*      are on newer silicon, we only need to configure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
*      collision distance in the Transmit Control Register.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
*   2) Set up flow control on the MAC to that established with
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
*      the link partner.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
*   3) Config DSP to improve Gigabit link quality for some PHY revisions.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
e1000_copper_link_postconfig(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
    DEBUGFUNC("e1000_copper_link_postconfig");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
    if (hw->mac_type >= e1000_82544) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
        e1000_config_collision_dist(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
        ret_val = e1000_config_mac_to_phy(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
            DEBUGOUT("Error configuring MAC to PHY settings\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
    ret_val = e1000_config_fc_after_link_up(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
    if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
        DEBUGOUT("Error Configuring Flow Control\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
    /* Config DSP to improve Giga link quality */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
    if (hw->phy_type == e1000_phy_igp) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
        ret_val = e1000_config_dsp_after_link_change(hw, TRUE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
            DEBUGOUT("Error Configuring DSP after link up\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
* Detects which PHY is present and setup the speed and duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
e1000_setup_copper_link(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
    uint16_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
    uint16_t reg_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
    DEBUGFUNC("e1000_setup_copper_link");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
    case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
        /* Set the mac to wait the maximum time between each
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
         * iteration and increase the max iterations when
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
         * polling the phy; this fixes erroneous timeouts at 10Mbps. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
        ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
        ret_val = e1000_read_kmrn_reg(hw, GG82563_REG(0x34, 9), &reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
        reg_data |= 0x3F;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
        ret_val = e1000_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
    /* Check if it is a valid PHY and set PHY mode if necessary. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
    ret_val = e1000_copper_link_preconfig(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
        /* Kumeran registers are written-only */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
        reg_data = E1000_KUMCTRLSTA_INB_CTRL_LINK_STATUS_TX_TIMEOUT_DEFAULT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
        reg_data |= E1000_KUMCTRLSTA_INB_CTRL_DIS_PADDING;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
        ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_INB_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
                                       reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
    if (hw->phy_type == e1000_phy_igp ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
        hw->phy_type == e1000_phy_igp_3 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
        hw->phy_type == e1000_phy_igp_2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
        ret_val = e1000_copper_link_igp_setup(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
    } else if (hw->phy_type == e1000_phy_m88) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
        ret_val = e1000_copper_link_mgp_setup(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
    } else if (hw->phy_type == e1000_phy_gg82563) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
        ret_val = e1000_copper_link_ggp_setup(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
    if (hw->autoneg) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
        /* Setup autoneg and flow control advertisement
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
          * and perform autonegotiation */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
        ret_val = e1000_copper_link_autoneg(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
        /* PHY will be set to 10H, 10F, 100H,or 100F
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
          * depending on value from forced_speed_duplex. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
        DEBUGOUT("Forcing speed and duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
        ret_val = e1000_phy_force_speed_duplex(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
            DEBUGOUT("Error Forcing Speed and Duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
    /* Check link status. Wait up to 100 microseconds for link to become
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
     * valid.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
    for (i = 0; i < 10; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
        if (phy_data & MII_SR_LINK_STATUS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
            /* Config the MAC and PHY after link is up */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
            ret_val = e1000_copper_link_postconfig(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
            DEBUGOUT("Valid link established!!!\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
            return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
        udelay(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
    DEBUGOUT("Unable to establish link!!!\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
* Configure the MAC-to-PHY interface for 10/100Mbps
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
e1000_configure_kmrn_for_10_100(struct e1000_hw *hw, uint16_t duplex)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
    int32_t ret_val = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
    uint32_t tipg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
    uint16_t reg_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
    DEBUGFUNC("e1000_configure_kmrn_for_10_100");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
    reg_data = E1000_KUMCTRLSTA_HD_CTRL_10_100_DEFAULT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
    ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_HD_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
                                   reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
    /* Configure Transmit Inter-Packet Gap */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
    tipg = E1000_READ_REG(hw, TIPG);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
    tipg &= ~E1000_TIPG_IPGT_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
    tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_10_100;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
    E1000_WRITE_REG(hw, TIPG, tipg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
    ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
    if (duplex == HALF_DUPLEX)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
        reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
    else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
        reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
    ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
e1000_configure_kmrn_for_1000(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
    int32_t ret_val = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
    uint16_t reg_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
    uint32_t tipg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
    DEBUGFUNC("e1000_configure_kmrn_for_1000");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
    reg_data = E1000_KUMCTRLSTA_HD_CTRL_1000_DEFAULT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
    ret_val = e1000_write_kmrn_reg(hw, E1000_KUMCTRLSTA_OFFSET_HD_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
                                   reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
    /* Configure Transmit Inter-Packet Gap */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
    tipg = E1000_READ_REG(hw, TIPG);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
    tipg &= ~E1000_TIPG_IPGT_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
    tipg |= DEFAULT_80003ES2LAN_TIPG_IPGT_1000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
    E1000_WRITE_REG(hw, TIPG, tipg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
    ret_val = e1000_read_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
    reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
    ret_val = e1000_write_phy_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
* Configures PHY autoneg and flow control advertisement settings
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
e1000_phy_setup_autoneg(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
    uint16_t mii_autoneg_adv_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
    uint16_t mii_1000t_ctrl_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
    DEBUGFUNC("e1000_phy_setup_autoneg");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
    /* Read the MII Auto-Neg Advertisement Register (Address 4). */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
    ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
    if (hw->phy_type != e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
        /* Read the MII 1000Base-T Control Register (Address 9). */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
        ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
    } else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
        mii_1000t_ctrl_reg=0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
    /* Need to parse both autoneg_advertised and fc and set up
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
     * the appropriate PHY registers.  First we will parse for
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
     * autoneg_advertised software override.  Since we can advertise
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
     * a plethora of combinations, we need to check each bit
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
     * individually.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
    /* First we clear all the 10/100 mb speed bits in the Auto-Neg
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
     * Advertisement Register (Address 4) and the 1000 mb speed bits in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
     * the  1000Base-T Control Register (Address 9).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
    mii_autoneg_adv_reg &= ~REG4_SPEED_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
    mii_1000t_ctrl_reg &= ~REG9_SPEED_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
    DEBUGOUT1("autoneg_advertised %x\n", hw->autoneg_advertised);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
    /* Do we want to advertise 10 Mb Half Duplex? */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
    if (hw->autoneg_advertised & ADVERTISE_10_HALF) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
        DEBUGOUT("Advertise 10mb Half duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
        mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
    /* Do we want to advertise 10 Mb Full Duplex? */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
    if (hw->autoneg_advertised & ADVERTISE_10_FULL) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
        DEBUGOUT("Advertise 10mb Full duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
        mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
    /* Do we want to advertise 100 Mb Half Duplex? */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
    if (hw->autoneg_advertised & ADVERTISE_100_HALF) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
        DEBUGOUT("Advertise 100mb Half duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
        mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
    /* Do we want to advertise 100 Mb Full Duplex? */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
    if (hw->autoneg_advertised & ADVERTISE_100_FULL) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
        DEBUGOUT("Advertise 100mb Full duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
        mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
    /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
    if (hw->autoneg_advertised & ADVERTISE_1000_HALF) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
        DEBUGOUT("Advertise 1000mb Half duplex requested, request denied!\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
    /* Do we want to advertise 1000 Mb Full Duplex? */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
    if (hw->autoneg_advertised & ADVERTISE_1000_FULL) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
        DEBUGOUT("Advertise 1000mb Full duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
        mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
        if (hw->phy_type == e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
            DEBUGOUT("e1000_phy_ife is a 10/100 PHY. Gigabit speed is not supported.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
    /* Check for a software override of the flow control settings, and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
     * setup the PHY advertisement registers accordingly.  If
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
     * auto-negotiation is enabled, then software will have to set the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
     * "PAUSE" bits to the correct value in the Auto-Negotiation
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
     * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
     *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
     * The possible values of the "fc" parameter are:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
     *      0:  Flow control is completely disabled
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
     *      1:  Rx flow control is enabled (we can receive pause frames
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
     *          but not send pause frames).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
     *      2:  Tx flow control is enabled (we can send pause frames
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
     *          but we do not support receiving pause frames).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
     *      3:  Both Rx and TX flow control (symmetric) are enabled.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
     *  other:  No software override.  The flow control configuration
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
     *          in the EEPROM is used.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
    switch (hw->fc) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
    case E1000_FC_NONE: /* 0 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
        /* Flow control (RX & TX) is completely disabled by a
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
         * software over-ride.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
        mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
    case E1000_FC_RX_PAUSE: /* 1 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
        /* RX Flow control is enabled, and TX Flow control is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
         * disabled, by a software over-ride.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
        /* Since there really isn't a way to advertise that we are
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
         * capable of RX Pause ONLY, we will advertise that we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
         * support both symmetric and asymmetric RX PAUSE.  Later
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
         * (in e1000_config_fc_after_link_up) we will disable the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
         *hw's ability to send PAUSE frames.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
        mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
    case E1000_FC_TX_PAUSE: /* 2 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
        /* TX Flow control is enabled, and RX Flow control is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
         * disabled, by a software over-ride.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
        mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
        mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
    case E1000_FC_FULL: /* 3 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
        /* Flow control (both RX and TX) is enabled by a software
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
         * over-ride.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
        mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
        DEBUGOUT("Flow control param set incorrectly\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
        return -E1000_ERR_CONFIG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
    ret_val = e1000_write_phy_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
    DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
    if (hw->phy_type != e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
        ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
* Force PHY speed and duplex settings to hw->forced_speed_duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
e1000_phy_force_speed_duplex(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
    uint16_t mii_ctrl_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
    uint16_t mii_status_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
    uint16_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
    DEBUGFUNC("e1000_phy_force_speed_duplex");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
    /* Turn off Flow control if we are forcing speed and duplex. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
    hw->fc = E1000_FC_NONE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
    DEBUGOUT1("hw->fc = %d\n", hw->fc);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
    /* Read the Device Control Register. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
    /* Set the bits to Force Speed and Duplex in the Device Ctrl Reg. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
    ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
    ctrl &= ~(DEVICE_SPEED_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
    /* Clear the Auto Speed Detect Enable bit. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
    ctrl &= ~E1000_CTRL_ASDE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
    /* Read the MII Control Register. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
    ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &mii_ctrl_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
    /* We need to disable autoneg in order to force link and duplex. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
    mii_ctrl_reg &= ~MII_CR_AUTO_NEG_EN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
    /* Are we forcing Full or Half Duplex? */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
    if (hw->forced_speed_duplex == e1000_100_full ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
        hw->forced_speed_duplex == e1000_10_full) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
        /* We want to force full duplex so we SET the full duplex bits in the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
         * Device and MII Control Registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
        ctrl |= E1000_CTRL_FD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
        mii_ctrl_reg |= MII_CR_FULL_DUPLEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
        DEBUGOUT("Full Duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
        /* We want to force half duplex so we CLEAR the full duplex bits in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
         * the Device and MII Control Registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
        ctrl &= ~E1000_CTRL_FD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
        mii_ctrl_reg &= ~MII_CR_FULL_DUPLEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
        DEBUGOUT("Half Duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
    /* Are we forcing 100Mbps??? */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
    if (hw->forced_speed_duplex == e1000_100_full ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
       hw->forced_speed_duplex == e1000_100_half) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
        /* Set the 100Mb bit and turn off the 1000Mb and 10Mb bits. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
        ctrl |= E1000_CTRL_SPD_100;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
        mii_ctrl_reg |= MII_CR_SPEED_100;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
        mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
        DEBUGOUT("Forcing 100mb ");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
        /* Set the 10Mb bit and turn off the 1000Mb and 100Mb bits. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
        ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
        mii_ctrl_reg |= MII_CR_SPEED_10;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
        mii_ctrl_reg &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
        DEBUGOUT("Forcing 10mb ");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
    e1000_config_collision_dist(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
    /* Write the configured values back to the Device Control Reg. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
    E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
    if ((hw->phy_type == e1000_phy_m88) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
        (hw->phy_type == e1000_phy_gg82563)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
        /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
         * forced whenever speed are duplex are forced.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
        phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
        ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
        DEBUGOUT1("M88E1000 PSCR: %x \n", phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
        /* Need to reset the PHY or these changes will be ignored */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
        mii_ctrl_reg |= MII_CR_RESET;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
    /* Disable MDI-X support for 10/100 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
    } else if (hw->phy_type == e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
        ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
        phy_data &= ~IFE_PMC_AUTO_MDIX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
        phy_data &= ~IFE_PMC_FORCE_MDIX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
        ret_val = e1000_write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
        /* Clear Auto-Crossover to force MDI manually.  IGP requires MDI
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
         * forced whenever speed or duplex are forced.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
        phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
        phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
    /* Write back the modified PHY MII control register. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
    ret_val = e1000_write_phy_reg(hw, PHY_CTRL, mii_ctrl_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
    udelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
    /* The wait_autoneg_complete flag may be a little misleading here.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
     * Since we are forcing speed and duplex, Auto-Neg is not enabled.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
     * But we do want to delay for a period while forcing only so we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
     * don't generate false No Link messages.  So we will wait here
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
     * only if the user has set wait_autoneg_complete to 1, which is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
     * the default.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
    if (hw->wait_autoneg_complete) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
        /* We will wait for autoneg to complete. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
        DEBUGOUT("Waiting for forced speed/duplex link.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
        mii_status_reg = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
        /* We will wait for autoneg to complete or 4.5 seconds to expire. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
        for (i = PHY_FORCE_TIME; i > 0; i--) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
            /* Read the MII Status Register and wait for Auto-Neg Complete bit
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
             * to be set.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
            ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
            ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
            if (mii_status_reg & MII_SR_LINK_STATUS) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
            msleep(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
        if ((i == 0) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
           ((hw->phy_type == e1000_phy_m88) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
            (hw->phy_type == e1000_phy_gg82563))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
            /* We didn't get link.  Reset the DSP and wait again for link. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
            ret_val = e1000_phy_reset_dsp(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
            if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
                DEBUGOUT("Error Resetting PHY DSP\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
        /* This loop will early-out if the link condition has been met.  */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
        for (i = PHY_FORCE_TIME; i > 0; i--) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
            if (mii_status_reg & MII_SR_LINK_STATUS) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
            msleep(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
            /* Read the MII Status Register and wait for Auto-Neg Complete bit
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
             * to be set.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
            ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
            ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
    if (hw->phy_type == e1000_phy_m88) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
        /* Because we reset the PHY above, we need to re-force TX_CLK in the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
         * Extended PHY Specific Control Register to 25MHz clock.  This value
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
         * defaults back to a 2.5MHz clock when the PHY is reset.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
        ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
        phy_data |= M88E1000_EPSCR_TX_CLK_25;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
        ret_val = e1000_write_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
        /* In addition, because of the s/w reset above, we need to enable CRS on
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
         * TX.  This must be set for both full and half duplex operation.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
        phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
        ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
        if ((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
            (!hw->autoneg) && (hw->forced_speed_duplex == e1000_10_full ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
             hw->forced_speed_duplex == e1000_10_half)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
            ret_val = e1000_polarity_reversal_workaround(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
    } else if (hw->phy_type == e1000_phy_gg82563) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
        /* The TX_CLK of the Extended PHY Specific Control Register defaults
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
         * to 2.5MHz on a reset.  We need to re-force it back to 25MHz, if
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
         * we're not in a forced 10/duplex configuration. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
        phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
        if ((hw->forced_speed_duplex == e1000_10_full) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
            (hw->forced_speed_duplex == e1000_10_half))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
            phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5MHZ;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
            phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25MHZ;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
        /* Also due to the reset, we need to enable CRS on Tx. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
        phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
        ret_val = e1000_write_phy_reg(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
* Sets the collision distance in the Transmit Control register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
* Link should have been established previously. Reads the speed and duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
* information from the Device Status register.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
e1000_config_collision_dist(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
    uint32_t tctl, coll_dist;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
    DEBUGFUNC("e1000_config_collision_dist");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
    if (hw->mac_type < e1000_82543)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
        coll_dist = E1000_COLLISION_DISTANCE_82542;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
    else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
        coll_dist = E1000_COLLISION_DISTANCE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
    tctl = E1000_READ_REG(hw, TCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
    tctl &= ~E1000_TCTL_COLD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
    tctl |= coll_dist << E1000_COLD_SHIFT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
    E1000_WRITE_REG(hw, TCTL, tctl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
* Sets MAC speed and duplex settings to reflect the those in the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
* mii_reg - data to write to the MII control register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
* The contents of the PHY register containing the needed information need to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
* be passed in.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
e1000_config_mac_to_phy(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
    DEBUGFUNC("e1000_config_mac_to_phy");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
    /* 82544 or newer MAC, Auto Speed Detection takes care of
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
    * MAC speed/duplex configuration.*/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
    if (hw->mac_type >= e1000_82544)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
    /* Read the Device Control Register and set the bits to Force Speed
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
     * and Duplex.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
    ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
    ctrl &= ~(E1000_CTRL_SPD_SEL | E1000_CTRL_ILOS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
    /* Set up duplex in the Device Control and Transmit Control
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
     * registers depending on negotiated values.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
    if (phy_data & M88E1000_PSSR_DPLX)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
        ctrl |= E1000_CTRL_FD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
    else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
        ctrl &= ~E1000_CTRL_FD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
    e1000_config_collision_dist(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
    /* Set up speed in the Device Control register depending on
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
     * negotiated values.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
    if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
        ctrl |= E1000_CTRL_SPD_1000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
    else if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
        ctrl |= E1000_CTRL_SPD_100;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
    /* Write the configured values back to the Device Control Reg. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
    E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
 * Forces the MAC's flow control settings.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
 * Sets the TFCE and RFCE bits in the device control register to reflect
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
 * the adapter settings. TFCE and RFCE need to be explicitly set by
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
 * software when a Copper PHY is used because autonegotiation is managed
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
 * by the PHY rather than the MAC. Software must also configure these
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
 * bits when link is forced on a fiber connection.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
e1000_force_mac_fc(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
    DEBUGFUNC("e1000_force_mac_fc");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
    /* Get the current configuration of the Device Control Register */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
    /* Because we didn't get link via the internal auto-negotiation
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
     * mechanism (we either forced link or we got link via PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
     * auto-neg), we have to manually enable/disable transmit an
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
     * receive flow control.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
     *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
     * The "Case" statement below enables/disable flow control
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
     * according to the "hw->fc" parameter.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
     *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
     * The possible values of the "fc" parameter are:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
     *      0:  Flow control is completely disabled
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
     *      1:  Rx flow control is enabled (we can receive pause
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
     *          frames but not send pause frames).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
     *      2:  Tx flow control is enabled (we can send pause frames
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
     *          frames but we do not receive pause frames).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
     *      3:  Both Rx and TX flow control (symmetric) is enabled.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
     *  other:  No other values should be possible at this point.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
    switch (hw->fc) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
    case E1000_FC_NONE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
        ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
    case E1000_FC_RX_PAUSE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
        ctrl &= (~E1000_CTRL_TFCE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
        ctrl |= E1000_CTRL_RFCE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
    case E1000_FC_TX_PAUSE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
        ctrl &= (~E1000_CTRL_RFCE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
        ctrl |= E1000_CTRL_TFCE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
    case E1000_FC_FULL:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
        ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
        DEBUGOUT("Flow control param set incorrectly\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
        return -E1000_ERR_CONFIG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
    /* Disable TX Flow Control for 82542 (rev 2.0) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
    if (hw->mac_type == e1000_82542_rev2_0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
        ctrl &= (~E1000_CTRL_TFCE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
    E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
 * Configures flow control settings after link is established
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
 * Should be called immediately after a valid link has been established.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
 * Forces MAC flow control settings if link was forced. When in MII/GMII mode
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
 * and autonegotiation is enabled, the MAC flow control settings will be set
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
 * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
 * and RFCE bits will be automaticaly set to the negotiated flow control mode.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
e1000_config_fc_after_link_up(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
    uint16_t mii_status_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
    uint16_t mii_nway_adv_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
    uint16_t mii_nway_lp_ability_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
    uint16_t speed;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
    uint16_t duplex;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
    DEBUGFUNC("e1000_config_fc_after_link_up");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
    /* Check for the case where we have fiber media and auto-neg failed
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
     * so we had to force link.  In this case, we need to force the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
     * configuration of the MAC to match the "fc" parameter.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
    if (((hw->media_type == e1000_media_type_fiber) && (hw->autoneg_failed)) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
        ((hw->media_type == e1000_media_type_internal_serdes) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
         (hw->autoneg_failed)) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
        ((hw->media_type == e1000_media_type_copper) && (!hw->autoneg))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
        ret_val = e1000_force_mac_fc(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
            DEBUGOUT("Error forcing flow control settings\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
    /* Check for the case where we have copper media and auto-neg is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
     * enabled.  In this case, we need to check and see if Auto-Neg
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
     * has completed, and if so, how the PHY and link partner has
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
     * flow control configured.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
    if ((hw->media_type == e1000_media_type_copper) && hw->autoneg) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
        /* Read the MII Status Register and check to see if AutoNeg
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
         * has completed.  We read this twice because this reg has
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
         * some "sticky" (latched) bits.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
        if (mii_status_reg & MII_SR_AUTONEG_COMPLETE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
            /* The AutoNeg process has completed, so we now need to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
             * read both the Auto Negotiation Advertisement Register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
             * (Address 4) and the Auto_Negotiation Base Page Ability
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
             * Register (Address 5) to determine how flow control was
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
             * negotiated.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
            ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
                                         &mii_nway_adv_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
            ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
                                         &mii_nway_lp_ability_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
            /* Two bits in the Auto Negotiation Advertisement Register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
             * (Address 4) and two bits in the Auto Negotiation Base
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
             * Page Ability Register (Address 5) determine flow control
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
             * for both the PHY and the link partner.  The following
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
             * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
             * 1999, describes these PAUSE resolution bits and how flow
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
             * control is determined based upon these settings.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
             * NOTE:  DC = Don't Care
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
             *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
             *   LOCAL DEVICE  |   LINK PARTNER
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
             * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
             *-------|---------|-------|---------|--------------------
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
             *   0   |    0    |  DC   |   DC    | E1000_FC_NONE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
             *   0   |    1    |   0   |   DC    | E1000_FC_NONE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
             *   0   |    1    |   1   |    0    | E1000_FC_NONE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
             *   0   |    1    |   1   |    1    | E1000_FC_TX_PAUSE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
             *   1   |    0    |   0   |   DC    | E1000_FC_NONE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
             *   1   |   DC    |   1   |   DC    | E1000_FC_FULL
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
             *   1   |    1    |   0   |    0    | E1000_FC_NONE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
             *   1   |    1    |   0   |    1    | E1000_FC_RX_PAUSE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
             *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
            /* Are both PAUSE bits set to 1?  If so, this implies
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
             * Symmetric Flow Control is enabled at both ends.  The
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
             * ASM_DIR bits are irrelevant per the spec.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
             *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
             * For Symmetric Flow Control:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
             *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
             *   LOCAL DEVICE  |   LINK PARTNER
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
             * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
             *-------|---------|-------|---------|--------------------
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
             *   1   |   DC    |   1   |   DC    | E1000_FC_FULL
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
             *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
            if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
                (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
                /* Now we need to check if the user selected RX ONLY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
                 * of pause frames.  In this case, we had to advertise
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
                 * FULL flow control because we could not advertise RX
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
                 * ONLY. Hence, we must now check to see if we need to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
                 * turn OFF  the TRANSMISSION of PAUSE frames.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
                 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
                if (hw->original_fc == E1000_FC_FULL) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
                    hw->fc = E1000_FC_FULL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
                    DEBUGOUT("Flow Control = FULL.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
                } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
                    hw->fc = E1000_FC_RX_PAUSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
                    DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
            /* For receiving PAUSE frames ONLY.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
             *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
             *   LOCAL DEVICE  |   LINK PARTNER
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
             * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
             *-------|---------|-------|---------|--------------------
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
             *   0   |    1    |   1   |    1    | E1000_FC_TX_PAUSE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
             *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
            else if (!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
                     (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
                     (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
                     (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
                hw->fc = E1000_FC_TX_PAUSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
                DEBUGOUT("Flow Control = TX PAUSE frames only.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
            /* For transmitting PAUSE frames ONLY.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
             *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
             *   LOCAL DEVICE  |   LINK PARTNER
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
             * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
             *-------|---------|-------|---------|--------------------
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
             *   1   |    1    |   0   |    1    | E1000_FC_RX_PAUSE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
             *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
            else if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
                     (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
                     !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
                     (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
                hw->fc = E1000_FC_RX_PAUSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
                DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
            /* Per the IEEE spec, at this point flow control should be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
             * disabled.  However, we want to consider that we could
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
             * be connected to a legacy switch that doesn't advertise
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
             * desired flow control, but can be forced on the link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
             * partner.  So if we advertised no flow control, that is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
             * what we will resolve to.  If we advertised some kind of
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
             * receive capability (Rx Pause Only or Full Flow Control)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
             * and the link partner advertised none, we will configure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
             * ourselves to enable Rx Flow Control only.  We can do
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
             * this safely for two reasons:  If the link partner really
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
             * didn't want flow control enabled, and we enable Rx, no
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
             * harm done since we won't be receiving any PAUSE frames
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
             * anyway.  If the intent on the link partner was to have
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
             * flow control enabled, then by us enabling RX only, we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
             * can at least receive pause frames and process them.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
             * This is a good idea because in most cases, since we are
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
             * predominantly a server NIC, more times than not we will
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
             * be asked to delay transmission of packets than asking
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
             * our link partner to pause transmission of frames.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
            else if ((hw->original_fc == E1000_FC_NONE ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
                      hw->original_fc == E1000_FC_TX_PAUSE) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
                      hw->fc_strict_ieee) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
                hw->fc = E1000_FC_NONE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
                DEBUGOUT("Flow Control = NONE.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
                hw->fc = E1000_FC_RX_PAUSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
                DEBUGOUT("Flow Control = RX PAUSE frames only.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
            /* Now we need to do one last check...  If we auto-
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
             * negotiated to HALF DUPLEX, flow control should not be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
             * enabled per IEEE 802.3 spec.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
            ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
            if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
                DEBUGOUT("Error getting link speed and duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
            if (duplex == HALF_DUPLEX)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
                hw->fc = E1000_FC_NONE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
            /* Now we call a subroutine to actually force the MAC
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
             * controller to use the correct flow control settings.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
            ret_val = e1000_force_mac_fc(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
            if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
                DEBUGOUT("Error forcing flow control settings\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
            DEBUGOUT("Copper PHY and Auto Neg has not completed.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
 * Checks to see if the link status of the hardware has changed.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
 * Called by any function that needs to check the link status of the adapter.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
e1000_check_for_link(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
    uint32_t rxcw = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
    uint32_t status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
    uint32_t rctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
    uint32_t icr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
    uint32_t signal = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
    DEBUGFUNC("e1000_check_for_link");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
    status = E1000_READ_REG(hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
    /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
     * set when the optics detect a signal. On older adapters, it will be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
     * cleared when there is a signal.  This applies to fiber media only.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
    if ((hw->media_type == e1000_media_type_fiber) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
        (hw->media_type == e1000_media_type_internal_serdes)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
        rxcw = E1000_READ_REG(hw, RXCW);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
        if (hw->media_type == e1000_media_type_fiber) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
            signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
            if (status & E1000_STATUS_LU)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
                hw->get_link_status = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
    /* If we have a copper PHY then we only want to go out to the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
     * registers to see if Auto-Neg has completed and/or if our link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
     * status has changed.  The get_link_status flag will be set if we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
     * receive a Link Status Change interrupt or we have Rx Sequence
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
     * Errors.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
    if ((hw->media_type == e1000_media_type_copper) && hw->get_link_status) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
        /* First we want to see if the MII Status Register reports
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
         * link.  If so, then we want to get the current speed/duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
         * of the PHY.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
         * Read the register twice since the link bit is sticky.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
        if (phy_data & MII_SR_LINK_STATUS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
            hw->get_link_status = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
            /* Check if there was DownShift, must be checked immediately after
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
             * link-up */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
            e1000_check_downshift(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
            /* If we are on 82544 or 82543 silicon and speed/duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
             * are forced to 10H or 10F, then we will implement the polarity
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
             * reversal workaround.  We disable interrupts first, and upon
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
             * returning, place the devices interrupt state to its previous
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
             * value except for the link status change interrupt which will
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
             * happen due to the execution of this workaround.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
            if ((hw->mac_type == e1000_82544 || hw->mac_type == e1000_82543) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
                (!hw->autoneg) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
                (hw->forced_speed_duplex == e1000_10_full ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
                 hw->forced_speed_duplex == e1000_10_half)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
                E1000_WRITE_REG(hw, IMC, 0xffffffff);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
                ret_val = e1000_polarity_reversal_workaround(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
                icr = E1000_READ_REG(hw, ICR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
                E1000_WRITE_REG(hw, ICS, (icr & ~E1000_ICS_LSC));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
                E1000_WRITE_REG(hw, IMS, IMS_ENABLE_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
            /* No link detected */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
            e1000_config_dsp_after_link_change(hw, FALSE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
            return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
        /* If we are forcing speed/duplex, then we simply return since
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
         * we have already determined whether we have link or not.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
        if (!hw->autoneg) return -E1000_ERR_CONFIG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
        /* optimize the dsp settings for the igp phy */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
        e1000_config_dsp_after_link_change(hw, TRUE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
        /* We have a M88E1000 PHY and Auto-Neg is enabled.  If we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
         * have Si on board that is 82544 or newer, Auto
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
         * Speed Detection takes care of MAC speed/duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
         * configuration.  So we only need to configure Collision
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
         * Distance in the MAC.  Otherwise, we need to force
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
         * speed/duplex on the MAC to the current PHY speed/duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
         * settings.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
        if (hw->mac_type >= e1000_82544)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
            e1000_config_collision_dist(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
        else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
            ret_val = e1000_config_mac_to_phy(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
            if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
                DEBUGOUT("Error configuring MAC to PHY settings\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
        /* Configure Flow Control now that Auto-Neg has completed. First, we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
         * need to restore the desired flow control settings because we may
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
         * have had to re-autoneg with a different link partner.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
        ret_val = e1000_config_fc_after_link_up(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
            DEBUGOUT("Error configuring flow control\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
        /* At this point we know that we are on copper and we have
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
         * auto-negotiated link.  These are conditions for checking the link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
         * partner capability register.  We use the link speed to determine if
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
         * TBI compatibility needs to be turned on or off.  If the link is not
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
         * at gigabit speed, then TBI compatibility is not needed.  If we are
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
         * at gigabit speed, we turn on TBI compatibility.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
        if (hw->tbi_compatibility_en) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
            uint16_t speed, duplex;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
            ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
            if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
                DEBUGOUT("Error getting link speed and duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
            if (speed != SPEED_1000) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
                /* If link speed is not set to gigabit speed, we do not need
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
                 * to enable TBI compatibility.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
                 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
                if (hw->tbi_compatibility_on) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
                    /* If we previously were in the mode, turn it off. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
                    rctl = E1000_READ_REG(hw, RCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
                    rctl &= ~E1000_RCTL_SBP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
                    E1000_WRITE_REG(hw, RCTL, rctl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
                    hw->tbi_compatibility_on = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
                /* If TBI compatibility is was previously off, turn it on. For
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
                 * compatibility with a TBI link partner, we will store bad
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
                 * packets. Some frames have an additional byte on the end and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
                 * will look like CRC errors to to the hardware.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
                 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
                if (!hw->tbi_compatibility_on) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
                    hw->tbi_compatibility_on = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
                    rctl = E1000_READ_REG(hw, RCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
                    rctl |= E1000_RCTL_SBP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
                    E1000_WRITE_REG(hw, RCTL, rctl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
    /* If we don't have link (auto-negotiation failed or link partner cannot
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
     * auto-negotiate), the cable is plugged in (we have signal), and our
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
     * link partner is not trying to auto-negotiate with us (we are receiving
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
     * idles or data), we need to force link up. We also need to give
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
     * auto-negotiation time to complete, in case the cable was just plugged
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
     * in. The autoneg_failed flag does this.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
    else if ((((hw->media_type == e1000_media_type_fiber) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
              ((ctrl & E1000_CTRL_SWDPIN1) == signal)) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
              (hw->media_type == e1000_media_type_internal_serdes)) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
              (!(status & E1000_STATUS_LU)) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
              (!(rxcw & E1000_RXCW_C))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
        if (hw->autoneg_failed == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
            hw->autoneg_failed = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
            return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
        DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
        /* Disable auto-negotiation in the TXCW register */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
        E1000_WRITE_REG(hw, TXCW, (hw->txcw & ~E1000_TXCW_ANE));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
        /* Force link-up and also force full-duplex. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
        ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
        ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
        E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
        /* Configure Flow Control after forcing link up. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
        ret_val = e1000_config_fc_after_link_up(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
            DEBUGOUT("Error configuring flow control\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
    /* If we are forcing link and we are receiving /C/ ordered sets, re-enable
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
     * auto-negotiation in the TXCW register and disable forced link in the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
     * Device Control register in an attempt to auto-negotiate with our link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
     * partner.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
    else if (((hw->media_type == e1000_media_type_fiber) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
              (hw->media_type == e1000_media_type_internal_serdes)) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
              (ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
        DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
        E1000_WRITE_REG(hw, TXCW, hw->txcw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
        E1000_WRITE_REG(hw, CTRL, (ctrl & ~E1000_CTRL_SLU));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
        hw->serdes_link_down = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
    /* If we force link for non-auto-negotiation switch, check link status
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
     * based on MAC synchronization for internal serdes media type.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
    else if ((hw->media_type == e1000_media_type_internal_serdes) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
             !(E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
        /* SYNCH bit and IV bit are sticky. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
        udelay(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
        if (E1000_RXCW_SYNCH & E1000_READ_REG(hw, RXCW)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
            if (!(rxcw & E1000_RXCW_IV)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
                hw->serdes_link_down = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
                DEBUGOUT("SERDES: Link is up.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
            hw->serdes_link_down = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
            DEBUGOUT("SERDES: Link is down.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
    if ((hw->media_type == e1000_media_type_internal_serdes) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
        (E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
        hw->serdes_link_down = !(E1000_STATUS_LU & E1000_READ_REG(hw, STATUS));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
 * Detects the current speed and duplex settings of the hardware.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
 * speed - Speed of the connection
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
 * duplex - Duplex setting of the connection
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
e1000_get_speed_and_duplex(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
                           uint16_t *speed,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
                           uint16_t *duplex)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
    uint32_t status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
    DEBUGFUNC("e1000_get_speed_and_duplex");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
    if (hw->mac_type >= e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
        status = E1000_READ_REG(hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
        if (status & E1000_STATUS_SPEED_1000) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
            *speed = SPEED_1000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
            DEBUGOUT("1000 Mbs, ");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
        } else if (status & E1000_STATUS_SPEED_100) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
            *speed = SPEED_100;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
            DEBUGOUT("100 Mbs, ");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
            *speed = SPEED_10;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
            DEBUGOUT("10 Mbs, ");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
        if (status & E1000_STATUS_FD) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
            *duplex = FULL_DUPLEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
            DEBUGOUT("Full Duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
            *duplex = HALF_DUPLEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
            DEBUGOUT(" Half Duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
        DEBUGOUT("1000 Mbs, Full Duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
        *speed = SPEED_1000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
        *duplex = FULL_DUPLEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
    /* IGP01 PHY may advertise full duplex operation after speed downgrade even
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
     * if it is operating at half duplex.  Here we set the duplex settings to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
     * match the duplex in the link partner's capabilities.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
    if (hw->phy_type == e1000_phy_igp && hw->speed_downgraded) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
        ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_EXP, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
        if (!(phy_data & NWAY_ER_LP_NWAY_CAPS))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
            *duplex = HALF_DUPLEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
        else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
            ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
            if ((*speed == SPEED_100 && !(phy_data & NWAY_LPAR_100TX_FD_CAPS)) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
               (*speed == SPEED_10 && !(phy_data & NWAY_LPAR_10T_FD_CAPS)))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
                *duplex = HALF_DUPLEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
    if ((hw->mac_type == e1000_80003es2lan) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
        (hw->media_type == e1000_media_type_copper)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
        if (*speed == SPEED_1000)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
            ret_val = e1000_configure_kmrn_for_1000(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
            ret_val = e1000_configure_kmrn_for_10_100(hw, *duplex);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
    if ((hw->phy_type == e1000_phy_igp_3) && (*speed == SPEED_1000)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
        ret_val = e1000_kumeran_lock_loss_workaround(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
* Blocks until autoneg completes or times out (~4.5 seconds)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
e1000_wait_autoneg(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
    uint16_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
    DEBUGFUNC("e1000_wait_autoneg");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
    DEBUGOUT("Waiting for Auto-Neg to complete.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
    /* We will wait for autoneg to complete or 4.5 seconds to expire. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
    for (i = PHY_AUTO_NEG_TIME; i > 0; i--) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
        /* Read the MII Status Register and wait for Auto-Neg
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
         * Complete bit to be set.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
        if (phy_data & MII_SR_AUTONEG_COMPLETE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
            return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
        msleep(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
* Raises the Management Data Clock
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
* ctrl - Device control register's current value
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
e1000_raise_mdi_clk(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
                    uint32_t *ctrl)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
    /* Raise the clock input to the Management Data Clock (by setting the MDC
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
     * bit), and then delay 10 microseconds.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
    E1000_WRITE_REG(hw, CTRL, (*ctrl | E1000_CTRL_MDC));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
    udelay(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
* Lowers the Management Data Clock
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
* ctrl - Device control register's current value
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
e1000_lower_mdi_clk(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
                    uint32_t *ctrl)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
    /* Lower the clock input to the Management Data Clock (by clearing the MDC
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
     * bit), and then delay 10 microseconds.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
    E1000_WRITE_REG(hw, CTRL, (*ctrl & ~E1000_CTRL_MDC));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
    udelay(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
* Shifts data bits out to the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
* data - Data to send out to the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
* count - Number of bits to shift out
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
* Bits are shifted out in MSB to LSB order.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
e1000_shift_out_mdi_bits(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
                         uint32_t data,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
                         uint16_t count)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
    uint32_t mask;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
    /* We need to shift "count" number of bits out to the PHY. So, the value
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
     * in the "data" parameter will be shifted out to the PHY one bit at a
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
     * time. In order to do this, "data" must be broken down into bits.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
    mask = 0x01;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
    mask <<= (count - 1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
    /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
    ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
    while (mask) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
        /* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
         * then raising and lowering the Management Data Clock. A "0" is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
         * shifted out to the PHY by setting the MDIO bit to "0" and then
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
         * raising and lowering the clock.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
        if (data & mask)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
            ctrl |= E1000_CTRL_MDIO;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
            ctrl &= ~E1000_CTRL_MDIO;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
        E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
        udelay(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
        e1000_raise_mdi_clk(hw, &ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
        e1000_lower_mdi_clk(hw, &ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
        mask = mask >> 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
* Shifts data bits in from the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
* Bits are shifted in in MSB to LSB order.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
static uint16_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
e1000_shift_in_mdi_bits(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
    uint16_t data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
    uint8_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
    /* In order to read a register from the PHY, we need to shift in a total
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
     * of 18 bits from the PHY. The first two bit (turnaround) times are used
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
     * to avoid contention on the MDIO pin when a read operation is performed.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
     * These two bits are ignored by us and thrown away. Bits are "shifted in"
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
     * by raising the input to the Management Data Clock (setting the MDC bit),
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
     * and then reading the value of the MDIO bit.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
    /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
    ctrl &= ~E1000_CTRL_MDIO_DIR;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
    ctrl &= ~E1000_CTRL_MDIO;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
    E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
    /* Raise and Lower the clock before reading in the data. This accounts for
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
     * the turnaround bits. The first clock occurred when we clocked out the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
     * last bit of the Register Address.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
    e1000_raise_mdi_clk(hw, &ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
    e1000_lower_mdi_clk(hw, &ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
    for (data = 0, i = 0; i < 16; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
        data = data << 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
        e1000_raise_mdi_clk(hw, &ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
        ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
        /* Check to see if we shifted in a "1". */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
        if (ctrl & E1000_CTRL_MDIO)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
            data |= 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
        e1000_lower_mdi_clk(hw, &ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
    e1000_raise_mdi_clk(hw, &ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
    e1000_lower_mdi_clk(hw, &ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
    return data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
e1000_swfw_sync_acquire(struct e1000_hw *hw, uint16_t mask)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
    uint32_t swfw_sync = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
    uint32_t swmask = mask;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
    uint32_t fwmask = mask << 16;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
    int32_t timeout = 200;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
    DEBUGFUNC("e1000_swfw_sync_acquire");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
    if (hw->swfwhw_semaphore_present)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
        return e1000_get_software_flag(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
    if (!hw->swfw_sync_present)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
        return e1000_get_hw_eeprom_semaphore(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
    while (timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
            if (e1000_get_hw_eeprom_semaphore(hw))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
                return -E1000_ERR_SWFW_SYNC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
            swfw_sync = E1000_READ_REG(hw, SW_FW_SYNC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
            if (!(swfw_sync & (fwmask | swmask))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
            /* firmware currently using resource (fwmask) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
            /* or other software thread currently using resource (swmask) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
            e1000_put_hw_eeprom_semaphore(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
            mdelay(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
            timeout--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
    if (!timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
        DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
        return -E1000_ERR_SWFW_SYNC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
    swfw_sync |= swmask;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
    E1000_WRITE_REG(hw, SW_FW_SYNC, swfw_sync);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
    e1000_put_hw_eeprom_semaphore(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
e1000_swfw_sync_release(struct e1000_hw *hw, uint16_t mask)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
    uint32_t swfw_sync;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
    uint32_t swmask = mask;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
    DEBUGFUNC("e1000_swfw_sync_release");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
    if (hw->swfwhw_semaphore_present) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
        e1000_release_software_flag(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
        return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
    if (!hw->swfw_sync_present) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
        e1000_put_hw_eeprom_semaphore(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
        return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
    /* if (e1000_get_hw_eeprom_semaphore(hw))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
     *    return -E1000_ERR_SWFW_SYNC; */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
    while (e1000_get_hw_eeprom_semaphore(hw) != E1000_SUCCESS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
        /* empty */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
    swfw_sync = E1000_READ_REG(hw, SW_FW_SYNC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
    swfw_sync &= ~swmask;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
    E1000_WRITE_REG(hw, SW_FW_SYNC, swfw_sync);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
    e1000_put_hw_eeprom_semaphore(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
* Reads the value from a PHY register, if the value is on a specific non zero
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
* page, sets the page first.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
* reg_addr - address of the PHY register to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
e1000_read_phy_reg(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
                   uint32_t reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
                   uint16_t *phy_data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
    uint32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
    uint16_t swfw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
    DEBUGFUNC("e1000_read_phy_reg");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
    if ((hw->mac_type == e1000_80003es2lan) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
        (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
        swfw = E1000_SWFW_PHY1_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
        swfw = E1000_SWFW_PHY0_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
    if (e1000_swfw_sync_acquire(hw, swfw))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
        return -E1000_ERR_SWFW_SYNC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
    if ((hw->phy_type == e1000_phy_igp ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
        hw->phy_type == e1000_phy_igp_3 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
        hw->phy_type == e1000_phy_igp_2) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
       (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
        ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
                                         (uint16_t)reg_addr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
            e1000_swfw_sync_release(hw, swfw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
    } else if (hw->phy_type == e1000_phy_gg82563) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
        if (((reg_addr & MAX_PHY_REG_ADDRESS) > MAX_PHY_MULTI_PAGE_REG) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
            (hw->mac_type == e1000_80003es2lan)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
            /* Select Configuration Page */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
            if ((reg_addr & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
                ret_val = e1000_write_phy_reg_ex(hw, GG82563_PHY_PAGE_SELECT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
                          (uint16_t)((uint16_t)reg_addr >> GG82563_PAGE_SHIFT));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
                /* Use Alternative Page Select register to access
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
                 * registers 30 and 31
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
                 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
                ret_val = e1000_write_phy_reg_ex(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
                                                 GG82563_PHY_PAGE_SELECT_ALT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
                          (uint16_t)((uint16_t)reg_addr >> GG82563_PAGE_SHIFT));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
            if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
                e1000_swfw_sync_release(hw, swfw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
    ret_val = e1000_read_phy_reg_ex(hw, MAX_PHY_REG_ADDRESS & reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
                                    phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
    e1000_swfw_sync_release(hw, swfw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
e1000_read_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
                      uint16_t *phy_data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
    uint32_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
    uint32_t mdic = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
    const uint32_t phy_addr = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
    DEBUGFUNC("e1000_read_phy_reg_ex");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
    if (reg_addr > MAX_PHY_REG_ADDRESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
        DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
        return -E1000_ERR_PARAM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
    if (hw->mac_type > e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
        /* Set up Op-code, Phy Address, and register address in the MDI
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
         * Control register.  The MAC will take care of interfacing with the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
         * PHY to retrieve the desired data.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
        mdic = ((reg_addr << E1000_MDIC_REG_SHIFT) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
                (phy_addr << E1000_MDIC_PHY_SHIFT) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
                (E1000_MDIC_OP_READ));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
        E1000_WRITE_REG(hw, MDIC, mdic);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
        /* Poll the ready bit to see if the MDI read completed */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
        for (i = 0; i < 64; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
            udelay(50);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
            mdic = E1000_READ_REG(hw, MDIC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
            if (mdic & E1000_MDIC_READY) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
        if (!(mdic & E1000_MDIC_READY)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
            DEBUGOUT("MDI Read did not complete\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
            return -E1000_ERR_PHY;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
        if (mdic & E1000_MDIC_ERROR) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
            DEBUGOUT("MDI Error\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
            return -E1000_ERR_PHY;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
        *phy_data = (uint16_t) mdic;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
        /* We must first send a preamble through the MDIO pin to signal the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
         * beginning of an MII instruction.  This is done by sending 32
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
         * consecutive "1" bits.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
        e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
        /* Now combine the next few fields that are required for a read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
         * operation.  We use this method instead of calling the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
         * e1000_shift_out_mdi_bits routine five different times. The format of
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
         * a MII read instruction consists of a shift out of 14 bits and is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
         * defined as follows:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
         *    <Preamble><SOF><Op Code><Phy Addr><Reg Addr>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
         * followed by a shift in of 18 bits.  This first two bits shifted in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
         * are TurnAround bits used to avoid contention on the MDIO pin when a
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
         * READ operation is performed.  These two bits are thrown away
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
         * followed by a shift in of 16 bits which contains the desired data.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
        mdic = ((reg_addr) | (phy_addr << 5) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
                (PHY_OP_READ << 10) | (PHY_SOF << 12));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
        e1000_shift_out_mdi_bits(hw, mdic, 14);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
        /* Now that we've shifted out the read command to the MII, we need to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
         * "shift in" the 16-bit value (18 total bits) of the requested PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
         * register address.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
        *phy_data = e1000_shift_in_mdi_bits(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
* Writes a value to a PHY register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
* reg_addr - address of the PHY register to write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
* data - data to write to the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
                    uint16_t phy_data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
    uint32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
    uint16_t swfw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
    DEBUGFUNC("e1000_write_phy_reg");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
    if ((hw->mac_type == e1000_80003es2lan) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
        (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
        swfw = E1000_SWFW_PHY1_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
        swfw = E1000_SWFW_PHY0_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
    if (e1000_swfw_sync_acquire(hw, swfw))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
        return -E1000_ERR_SWFW_SYNC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
    if ((hw->phy_type == e1000_phy_igp ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
        hw->phy_type == e1000_phy_igp_3 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
        hw->phy_type == e1000_phy_igp_2) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
       (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
        ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
                                         (uint16_t)reg_addr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
            e1000_swfw_sync_release(hw, swfw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
    } else if (hw->phy_type == e1000_phy_gg82563) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
        if (((reg_addr & MAX_PHY_REG_ADDRESS) > MAX_PHY_MULTI_PAGE_REG) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
            (hw->mac_type == e1000_80003es2lan)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
            /* Select Configuration Page */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
            if ((reg_addr & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
                ret_val = e1000_write_phy_reg_ex(hw, GG82563_PHY_PAGE_SELECT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
                          (uint16_t)((uint16_t)reg_addr >> GG82563_PAGE_SHIFT));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
                /* Use Alternative Page Select register to access
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
                 * registers 30 and 31
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
                 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
                ret_val = e1000_write_phy_reg_ex(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
                                                 GG82563_PHY_PAGE_SELECT_ALT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
                          (uint16_t)((uint16_t)reg_addr >> GG82563_PAGE_SHIFT));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
            if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
                e1000_swfw_sync_release(hw, swfw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
    ret_val = e1000_write_phy_reg_ex(hw, MAX_PHY_REG_ADDRESS & reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
                                     phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
    e1000_swfw_sync_release(hw, swfw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
e1000_write_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
                       uint16_t phy_data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
    uint32_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
    uint32_t mdic = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
    const uint32_t phy_addr = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
    DEBUGFUNC("e1000_write_phy_reg_ex");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
    if (reg_addr > MAX_PHY_REG_ADDRESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
        DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
        return -E1000_ERR_PARAM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
    if (hw->mac_type > e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
        /* Set up Op-code, Phy Address, register address, and data intended
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
         * for the PHY register in the MDI Control register.  The MAC will take
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
         * care of interfacing with the PHY to send the desired data.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
        mdic = (((uint32_t) phy_data) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
                (reg_addr << E1000_MDIC_REG_SHIFT) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
                (phy_addr << E1000_MDIC_PHY_SHIFT) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
                (E1000_MDIC_OP_WRITE));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
        E1000_WRITE_REG(hw, MDIC, mdic);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
        /* Poll the ready bit to see if the MDI read completed */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
        for (i = 0; i < 641; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
            udelay(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
            mdic = E1000_READ_REG(hw, MDIC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
            if (mdic & E1000_MDIC_READY) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
        if (!(mdic & E1000_MDIC_READY)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
            DEBUGOUT("MDI Write did not complete\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
            return -E1000_ERR_PHY;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
        /* We'll need to use the SW defined pins to shift the write command
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
         * out to the PHY. We first send a preamble to the PHY to signal the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
         * beginning of the MII instruction.  This is done by sending 32
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
         * consecutive "1" bits.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
        e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
        /* Now combine the remaining required fields that will indicate a
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
         * write operation. We use this method instead of calling the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
         * e1000_shift_out_mdi_bits routine for each field in the command. The
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
         * format of a MII write instruction is as follows:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
         * <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
        mdic = ((PHY_TURNAROUND) | (reg_addr << 2) | (phy_addr << 7) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
                (PHY_OP_WRITE << 12) | (PHY_SOF << 14));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
        mdic <<= 16;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
        mdic |= (uint32_t) phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
        e1000_shift_out_mdi_bits(hw, mdic, 32);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
e1000_read_kmrn_reg(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
                    uint32_t reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
                    uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
    uint32_t reg_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
    uint16_t swfw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
    DEBUGFUNC("e1000_read_kmrn_reg");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
    if ((hw->mac_type == e1000_80003es2lan) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
        (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
        swfw = E1000_SWFW_PHY1_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
        swfw = E1000_SWFW_PHY0_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
    if (e1000_swfw_sync_acquire(hw, swfw))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
        return -E1000_ERR_SWFW_SYNC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
    /* Write register address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
    reg_val = ((reg_addr << E1000_KUMCTRLSTA_OFFSET_SHIFT) &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
              E1000_KUMCTRLSTA_OFFSET) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
              E1000_KUMCTRLSTA_REN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
    E1000_WRITE_REG(hw, KUMCTRLSTA, reg_val);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
    udelay(2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
    /* Read the data returned */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
    reg_val = E1000_READ_REG(hw, KUMCTRLSTA);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
    *data = (uint16_t)reg_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
    e1000_swfw_sync_release(hw, swfw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
e1000_write_kmrn_reg(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
                     uint32_t reg_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
                     uint16_t data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
    uint32_t reg_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
    uint16_t swfw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
    DEBUGFUNC("e1000_write_kmrn_reg");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
    if ((hw->mac_type == e1000_80003es2lan) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
        (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
        swfw = E1000_SWFW_PHY1_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
        swfw = E1000_SWFW_PHY0_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
    if (e1000_swfw_sync_acquire(hw, swfw))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
        return -E1000_ERR_SWFW_SYNC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
    reg_val = ((reg_addr << E1000_KUMCTRLSTA_OFFSET_SHIFT) &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
              E1000_KUMCTRLSTA_OFFSET) | data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
    E1000_WRITE_REG(hw, KUMCTRLSTA, reg_val);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
    udelay(2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
    e1000_swfw_sync_release(hw, swfw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
* Returns the PHY to the power-on reset state
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
e1000_phy_hw_reset(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
    uint32_t ctrl, ctrl_ext;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
    uint32_t led_ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
    uint16_t swfw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
    DEBUGFUNC("e1000_phy_hw_reset");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
    /* In the case of the phy reset being blocked, it's not an error, we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
     * simply return success without performing the reset. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
    ret_val = e1000_check_phy_reset_block(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
    DEBUGOUT("Resetting Phy...\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
    if (hw->mac_type > e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
        if ((hw->mac_type == e1000_80003es2lan) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
            (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
            swfw = E1000_SWFW_PHY1_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
            swfw = E1000_SWFW_PHY0_SM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
        if (e1000_swfw_sync_acquire(hw, swfw)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
            DEBUGOUT("Unable to acquire swfw sync\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
            return -E1000_ERR_SWFW_SYNC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
        /* Read the device control register and assert the E1000_CTRL_PHY_RST
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
         * bit. Then, take it out of reset.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
         * For pre-e1000_82571 hardware, we delay for 10ms between the assert
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
         * and deassert.  For e1000_82571 hardware and later, we instead delay
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
         * for 50us between and 10ms after the deassertion.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
        ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
        E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
        if (hw->mac_type < e1000_82571)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
            msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
            udelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
        E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
        if (hw->mac_type >= e1000_82571)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
            mdelay(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
        e1000_swfw_sync_release(hw, swfw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
        /* Read the Extended Device Control Register, assert the PHY_RESET_DIR
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
         * bit to put the PHY into reset. Then, take it out of reset.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
        ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
        ctrl_ext |= E1000_CTRL_EXT_SDP4_DIR;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
        ctrl_ext &= ~E1000_CTRL_EXT_SDP4_DATA;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
        msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
        ctrl_ext |= E1000_CTRL_EXT_SDP4_DATA;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
    udelay(150);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
    if ((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
        /* Configure activity LED after PHY reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
        led_ctrl = E1000_READ_REG(hw, LEDCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
        led_ctrl &= IGP_ACTIVITY_LED_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
        led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
        E1000_WRITE_REG(hw, LEDCTL, led_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
    /* Wait for FW to finish PHY configuration. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
    ret_val = e1000_get_phy_cfg_done(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
    if (ret_val != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
    e1000_release_software_semaphore(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
    if ((hw->mac_type == e1000_ich8lan) && (hw->phy_type == e1000_phy_igp_3))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
        ret_val = e1000_init_lcd_from_nvm(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
* Resets the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
* Sets bit 15 of the MII Control register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
e1000_phy_reset(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
    DEBUGFUNC("e1000_phy_reset");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
    /* In the case of the phy reset being blocked, it's not an error, we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
     * simply return success without performing the reset. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
    ret_val = e1000_check_phy_reset_block(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
    switch (hw->phy_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
    case e1000_phy_igp:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
    case e1000_phy_igp_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
    case e1000_phy_igp_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
    case e1000_phy_ife:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
        ret_val = e1000_phy_hw_reset(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
        ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
        phy_data |= MII_CR_RESET;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
        ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
        udelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
    if (hw->phy_type == e1000_phy_igp || hw->phy_type == e1000_phy_igp_2)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
        e1000_phy_init_script(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
* Work-around for 82566 power-down: on D3 entry-
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
* 1) disable gigabit link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
* 2) write VR power-down enable
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
* 3) read it back
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
* if successful continue, else issue LCD reset and repeat
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
* hw - struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
e1000_phy_powerdown_workaround(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
    int32_t reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
    int32_t retry = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
    DEBUGFUNC("e1000_phy_powerdown_workaround");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
    if (hw->phy_type != e1000_phy_igp_3)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
        return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
    do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
        /* Disable link */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
        reg = E1000_READ_REG(hw, PHY_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
        E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
                        E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
        /* Write VR power-down enable - bits 9:8 should be 10b */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
        e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
        phy_data |= (1 << 9);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
        phy_data &= ~(1 << 8);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
        e1000_write_phy_reg(hw, IGP3_VR_CTRL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
        /* Read it back and test */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
        e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
        if (((phy_data & IGP3_VR_CTRL_MODE_MASK) == IGP3_VR_CTRL_MODE_SHUT) || retry)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
        /* Issue PHY reset and repeat at most one more time */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
        reg = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
        E1000_WRITE_REG(hw, CTRL, reg | E1000_CTRL_PHY_RST);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
        retry++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
    } while (retry);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
    return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
* Work-around for 82566 Kumeran PCS lock loss:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
* On link status change (i.e. PCI reset, speed change) and link is up and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
* speed is gigabit-
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
* 0) if workaround is optionally disabled do nothing
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
* 1) wait 1ms for Kumeran link to come up
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
* 2) check Kumeran Diagnostic register PCS lock loss bit
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
* 3) if not set the link is locked (all is good), otherwise...
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
* 4) reset the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
* 5) repeat up to 10 times
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
* Note: this is only called for IGP3 copper when speed is 1gb.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
* hw - struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
e1000_kumeran_lock_loss_workaround(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
    int32_t reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
    int32_t cnt;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
    if (hw->kmrn_lock_loss_workaround_disabled)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
    /* Make sure link is up before proceeding.  If not just return.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
     * Attempting this while link is negotiating fouled up link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
     * stability */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
    ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
    ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4018
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
    if (phy_data & MII_SR_LINK_STATUS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4020
        for (cnt = 0; cnt < 10; cnt++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
            /* read once to clear */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
            ret_val = e1000_read_phy_reg(hw, IGP3_KMRN_DIAG, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
            /* and again to get new status */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
            ret_val = e1000_read_phy_reg(hw, IGP3_KMRN_DIAG, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
            /* check for PCS lock */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
            if (!(phy_data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
                return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4034
            /* Issue PHY reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4035
            e1000_phy_hw_reset(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
            mdelay(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
        /* Disable GigE link negotiation */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
        reg = E1000_READ_REG(hw, PHY_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
        E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
                        E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
        /* unable to acquire PCS lock */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
        return E1000_ERR_PHY;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4050
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4051
* Probes the expected PHY address for known PHY IDs
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
e1000_detect_gig_phy(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
    int32_t phy_init_status, ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
    uint16_t phy_id_high, phy_id_low;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4060
    boolean_t match = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
    DEBUGFUNC("e1000_detect_gig_phy");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4063
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
    if (hw->phy_id != 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4066
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
    /* The 82571 firmware may still be configuring the PHY.  In this
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4068
     * case, we cannot access the PHY until the configuration is done.  So
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
     * we explicitly set the PHY values. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
    if (hw->mac_type == e1000_82571 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
        hw->mac_type == e1000_82572) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
        hw->phy_id = IGP01E1000_I_PHY_ID;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
        hw->phy_type = e1000_phy_igp_2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
    /* ESB-2 PHY reads require e1000_phy_gg82563 to be set because of a work-
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
     * around that forces PHY page 0 to be set or the reads fail.  The rest of
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
     * the code in this routine uses e1000_read_phy_reg to read the PHY ID.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
     * So for ESB-2 we need to have this set so our reads won't fail.  If the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
     * attached PHY is not a e1000_phy_gg82563, the routines below will figure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
     * this out as well. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
    if (hw->mac_type == e1000_80003es2lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
        hw->phy_type = e1000_phy_gg82563;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
    /* Read the PHY ID Registers to identify which PHY is onboard. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
    ret_val = e1000_read_phy_reg(hw, PHY_ID1, &phy_id_high);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4089
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
    hw->phy_id = (uint32_t) (phy_id_high << 16);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
    udelay(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
    ret_val = e1000_read_phy_reg(hw, PHY_ID2, &phy_id_low);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4094
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
    hw->phy_id |= (uint32_t) (phy_id_low & PHY_REVISION_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
    hw->phy_revision = (uint32_t) phy_id_low & ~PHY_REVISION_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4099
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
    case e1000_82543:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
        if (hw->phy_id == M88E1000_E_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
    case e1000_82544:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
        if (hw->phy_id == M88E1000_I_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
    case e1000_82540:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
    case e1000_82545:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
    case e1000_82545_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
    case e1000_82546:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
    case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
        if (hw->phy_id == M88E1011_I_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4113
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
    case e1000_82541:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
    case e1000_82541_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
    case e1000_82547:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
    case e1000_82547_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
        if (hw->phy_id == IGP01E1000_I_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
    case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4121
        if (hw->phy_id == M88E1111_I_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
        if (hw->phy_id == GG82563_E_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
    case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
        if (hw->phy_id == IGP03E1000_E_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
        if (hw->phy_id == IFE_E_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
        if (hw->phy_id == IFE_PLUS_E_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
        if (hw->phy_id == IFE_C_E_PHY_ID) match = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
        DEBUGOUT1("Invalid MAC type %d\n", hw->mac_type);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
        return -E1000_ERR_CONFIG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
    phy_init_status = e1000_set_phy_type(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
    if ((match) && (phy_init_status == E1000_SUCCESS)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
        DEBUGOUT1("PHY ID 0x%X detected\n", hw->phy_id);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
    DEBUGOUT1("Invalid PHY ID 0x%X\n", hw->phy_id);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
    return -E1000_ERR_PHY;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
* Resets the PHY's DSP
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
e1000_phy_reset_dsp(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
    DEBUGFUNC("e1000_phy_reset_dsp");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
    do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
        if (hw->phy_type != e1000_phy_gg82563) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
            ret_val = e1000_write_phy_reg(hw, 29, 0x001d);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
            if (ret_val) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
        ret_val = e1000_write_phy_reg(hw, 30, 0x00c1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
        if (ret_val) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
        ret_val = e1000_write_phy_reg(hw, 30, 0x0000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
        if (ret_val) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
        ret_val = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
    } while (0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4169
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
* Get PHY information from various PHY registers for igp PHY only.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
* phy_info - PHY information structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4179
e1000_phy_igp_get_info(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
                       struct e1000_phy_info *phy_info)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
    uint16_t phy_data, min_length, max_length, average;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
    e1000_rev_polarity polarity;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4186
    DEBUGFUNC("e1000_phy_igp_get_info");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
    /* The downshift status is checked only once, after link is established,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
     * and it stored in the hw->speed_downgraded parameter. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
    phy_info->downshift = (e1000_downshift)hw->speed_downgraded;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4192
    /* IGP01E1000 does not need to support it. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4193
    phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4194
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4195
    /* IGP01E1000 always correct polarity reversal */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
    phy_info->polarity_correction = e1000_polarity_reversal_enabled;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
    /* Check polarity status */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
    ret_val = e1000_check_polarity(hw, &polarity);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4200
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4201
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
    phy_info->cable_polarity = polarity;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4204
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
    ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4209
    phy_info->mdix_mode = (e1000_auto_x_mode)((phy_data & IGP01E1000_PSSR_MDIX) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
                          IGP01E1000_PSSR_MDIX_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
    if ((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4213
       IGP01E1000_PSSR_SPEED_1000MBPS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
        /* Local/Remote Receiver Information are only valid at 1000 Mbps */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
        ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
        phy_info->local_rx = ((phy_data & SR_1000T_LOCAL_RX_STATUS) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
                             SR_1000T_LOCAL_RX_STATUS_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4221
                             e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
        phy_info->remote_rx = ((phy_data & SR_1000T_REMOTE_RX_STATUS) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
                              SR_1000T_REMOTE_RX_STATUS_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4224
                              e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4225
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4226
        /* Get cable length */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4227
        ret_val = e1000_get_cable_length(hw, &min_length, &max_length);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4228
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4229
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4231
        /* Translate to old method */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
        average = (max_length + min_length) / 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4234
        if (average <= e1000_igp_cable_length_50)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4235
            phy_info->cable_length = e1000_cable_length_50;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4236
        else if (average <= e1000_igp_cable_length_80)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
            phy_info->cable_length = e1000_cable_length_50_80;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
        else if (average <= e1000_igp_cable_length_110)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
            phy_info->cable_length = e1000_cable_length_80_110;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
        else if (average <= e1000_igp_cable_length_140)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4241
            phy_info->cable_length = e1000_cable_length_110_140;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4242
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4243
            phy_info->cable_length = e1000_cable_length_140;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
* Get PHY information from various PHY registers for ife PHY only.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4252
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
* phy_info - PHY information structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4256
e1000_phy_ife_get_info(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
                       struct e1000_phy_info *phy_info)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4259
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4260
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
    e1000_rev_polarity polarity;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4262
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4263
    DEBUGFUNC("e1000_phy_ife_get_info");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4264
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4265
    phy_info->downshift = (e1000_downshift)hw->speed_downgraded;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4266
    phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_normal;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4267
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4268
    ret_val = e1000_read_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4269
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4270
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
    phy_info->polarity_correction =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
                        ((phy_data & IFE_PSC_AUTO_POLARITY_DISABLE) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
                        IFE_PSC_AUTO_POLARITY_DISABLE_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
                        e1000_polarity_reversal_disabled : e1000_polarity_reversal_enabled;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4276
    if (phy_info->polarity_correction == e1000_polarity_reversal_enabled) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4277
        ret_val = e1000_check_polarity(hw, &polarity);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4278
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
        /* Polarity is forced. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
        polarity = ((phy_data & IFE_PSC_FORCE_POLARITY) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4283
                     IFE_PSC_FORCE_POLARITY_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4284
                     e1000_rev_polarity_reversed : e1000_rev_polarity_normal;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
    phy_info->cable_polarity = polarity;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
    ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4290
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
    phy_info->mdix_mode = (e1000_auto_x_mode)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4293
                     ((phy_data & (IFE_PMC_AUTO_MDIX | IFE_PMC_FORCE_MDIX)) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
                     IFE_PMC_MDIX_MODE_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
* Get PHY information from various PHY registers fot m88 PHY only.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
* phy_info - PHY information structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
e1000_phy_m88_get_info(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
                       struct e1000_phy_info *phy_info)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4311
    e1000_rev_polarity polarity;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4312
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
    DEBUGFUNC("e1000_phy_m88_get_info");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4315
    /* The downshift status is checked only once, after link is established,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
     * and it stored in the hw->speed_downgraded parameter. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
    phy_info->downshift = (e1000_downshift)hw->speed_downgraded;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4318
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
    phy_info->extended_10bt_distance =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
        ((phy_data & M88E1000_PSCR_10BT_EXT_DIST_ENABLE) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
        M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
        e1000_10bt_ext_dist_enable_lower : e1000_10bt_ext_dist_enable_normal;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
    phy_info->polarity_correction =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
        ((phy_data & M88E1000_PSCR_POLARITY_REVERSAL) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
        M88E1000_PSCR_POLARITY_REVERSAL_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
        e1000_polarity_reversal_disabled : e1000_polarity_reversal_enabled;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
    /* Check polarity status */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
    ret_val = e1000_check_polarity(hw, &polarity);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
    phy_info->cable_polarity = polarity;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
    phy_info->mdix_mode = (e1000_auto_x_mode)((phy_data & M88E1000_PSSR_MDIX) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
                          M88E1000_PSSR_MDIX_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
    if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
        /* Cable Length Estimation and Local/Remote Receiver Information
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
         * are only valid at 1000 Mbps.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
        if (hw->phy_type != e1000_phy_gg82563) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
            phy_info->cable_length = (e1000_cable_length)((phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
                                      M88E1000_PSSR_CABLE_LENGTH_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4353
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
            ret_val = e1000_read_phy_reg(hw, GG82563_PHY_DSP_DISTANCE,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
                                         &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
            phy_info->cable_length = (e1000_cable_length)(phy_data & GG82563_DSPD_CABLE_LENGTH);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
        ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
        phy_info->local_rx = ((phy_data & SR_1000T_LOCAL_RX_STATUS) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
                             SR_1000T_LOCAL_RX_STATUS_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
                             e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
        phy_info->remote_rx = ((phy_data & SR_1000T_REMOTE_RX_STATUS) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
                              SR_1000T_REMOTE_RX_STATUS_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4371
                              e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4374
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
* Get PHY information from various PHY registers
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
* phy_info - PHY information structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
e1000_phy_get_info(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
                   struct e1000_phy_info *phy_info)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4390
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
    DEBUGFUNC("e1000_phy_get_info");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
    phy_info->cable_length = e1000_cable_length_undefined;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
    phy_info->extended_10bt_distance = e1000_10bt_ext_dist_enable_undefined;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
    phy_info->cable_polarity = e1000_rev_polarity_undefined;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4396
    phy_info->downshift = e1000_downshift_undefined;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
    phy_info->polarity_correction = e1000_polarity_reversal_undefined;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
    phy_info->mdix_mode = e1000_auto_x_mode_undefined;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
    phy_info->local_rx = e1000_1000t_rx_status_undefined;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
    phy_info->remote_rx = e1000_1000t_rx_status_undefined;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
    if (hw->media_type != e1000_media_type_copper) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
        DEBUGOUT("PHY info is only valid for copper media\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
        return -E1000_ERR_CONFIG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
    ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4410
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
    ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
    if ((phy_data & MII_SR_LINK_STATUS) != MII_SR_LINK_STATUS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
        DEBUGOUT("PHY info is only valid if link is up\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4417
        return -E1000_ERR_CONFIG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4418
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
    if (hw->phy_type == e1000_phy_igp ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
        hw->phy_type == e1000_phy_igp_3 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
        hw->phy_type == e1000_phy_igp_2)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
        return e1000_phy_igp_get_info(hw, phy_info);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
    else if (hw->phy_type == e1000_phy_ife)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
        return e1000_phy_ife_get_info(hw, phy_info);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
    else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
        return e1000_phy_m88_get_info(hw, phy_info);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4429
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
e1000_validate_mdi_setting(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
    DEBUGFUNC("e1000_validate_mdi_settings");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4435
    if (!hw->autoneg && (hw->mdix == 0 || hw->mdix == 3)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
        DEBUGOUT("Invalid MDI setting detected\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
        hw->mdix = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
        return -E1000_ERR_CONFIG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
 * Sets up eeprom variables in the hw struct.  Must be called after mac_type
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
 * is configured.  Additionally, if this is ICH8, the flash controller GbE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
 * registers must be mapped, or this will crash.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
e1000_init_eeprom_params(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4453
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4455
    uint32_t eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
    int32_t ret_val = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
    uint16_t eeprom_size;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4458
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
    DEBUGFUNC("e1000_init_eeprom_params");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4461
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4462
    case e1000_82542_rev2_0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
    case e1000_82542_rev2_1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
    case e1000_82543:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
    case e1000_82544:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
        eeprom->type = e1000_eeprom_microwire;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
        eeprom->word_size = 64;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
        eeprom->opcode_bits = 3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
        eeprom->address_bits = 6;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
        eeprom->delay_usec = 50;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
        eeprom->use_eerd = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
        eeprom->use_eewr = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
    case e1000_82540:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
    case e1000_82545:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
    case e1000_82545_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
    case e1000_82546:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
    case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
        eeprom->type = e1000_eeprom_microwire;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
        eeprom->opcode_bits = 3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
        eeprom->delay_usec = 50;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
        if (eecd & E1000_EECD_SIZE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4483
            eeprom->word_size = 256;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
            eeprom->address_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4486
            eeprom->word_size = 64;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
            eeprom->address_bits = 6;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
        eeprom->use_eerd = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4490
        eeprom->use_eewr = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
    case e1000_82541:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4493
    case e1000_82541_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
    case e1000_82547:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
    case e1000_82547_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
        if (eecd & E1000_EECD_TYPE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
            eeprom->type = e1000_eeprom_spi;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
            eeprom->opcode_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
            eeprom->delay_usec = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
            if (eecd & E1000_EECD_ADDR_BITS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4501
                eeprom->page_size = 32;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
                eeprom->address_bits = 16;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
                eeprom->page_size = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
                eeprom->address_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4508
            eeprom->type = e1000_eeprom_microwire;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
            eeprom->opcode_bits = 3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
            eeprom->delay_usec = 50;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
            if (eecd & E1000_EECD_ADDR_BITS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
                eeprom->word_size = 256;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
                eeprom->address_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4514
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
                eeprom->word_size = 64;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
                eeprom->address_bits = 6;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4518
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
        eeprom->use_eerd = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
        eeprom->use_eewr = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4521
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
    case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4523
    case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
        eeprom->type = e1000_eeprom_spi;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
        eeprom->opcode_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
        eeprom->delay_usec = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4527
        if (eecd & E1000_EECD_ADDR_BITS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4528
            eeprom->page_size = 32;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
            eeprom->address_bits = 16;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
            eeprom->page_size = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
            eeprom->address_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
        eeprom->use_eerd = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
        eeprom->use_eewr = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4536
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
    case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
        eeprom->type = e1000_eeprom_spi;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
        eeprom->opcode_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
        eeprom->delay_usec = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
        if (eecd & E1000_EECD_ADDR_BITS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4542
            eeprom->page_size = 32;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
            eeprom->address_bits = 16;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
            eeprom->page_size = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
            eeprom->address_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4547
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
        eeprom->use_eerd = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4549
        eeprom->use_eewr = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4550
        if (e1000_is_onboard_nvm_eeprom(hw) == FALSE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
            eeprom->type = e1000_eeprom_flash;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
            eeprom->word_size = 2048;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
            /* Ensure that the Autonomous FLASH update bit is cleared due to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
             * Flash update issue on parts which use a FLASH for NVM. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
            eecd &= ~E1000_EECD_AUPDEN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
            E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
        eeprom->type = e1000_eeprom_spi;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
        eeprom->opcode_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
        eeprom->delay_usec = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
        if (eecd & E1000_EECD_ADDR_BITS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
            eeprom->page_size = 32;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
            eeprom->address_bits = 16;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
            eeprom->page_size = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
            eeprom->address_bits = 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
        eeprom->use_eerd = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
        eeprom->use_eewr = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
    case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
        {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
        int32_t  i = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
        uint32_t flash_size = E1000_READ_ICH_FLASH_REG(hw, ICH_FLASH_GFPREG);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
        eeprom->type = e1000_eeprom_ich8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
        eeprom->use_eerd = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
        eeprom->use_eewr = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
        eeprom->word_size = E1000_SHADOW_RAM_WORDS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
        /* Zero the shadow RAM structure. But don't load it from NVM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
         * so as to save time for driver init */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4586
        if (hw->eeprom_shadow_ram != NULL) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
            for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
                hw->eeprom_shadow_ram[i].modified = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
                hw->eeprom_shadow_ram[i].eeprom_word = 0xFFFF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
        hw->flash_base_addr = (flash_size & ICH_GFPREG_BASE_MASK) *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
                              ICH_FLASH_SECTOR_SIZE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
        hw->flash_bank_size = ((flash_size >> 16) & ICH_GFPREG_BASE_MASK) + 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
        hw->flash_bank_size -= (flash_size & ICH_GFPREG_BASE_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
        hw->flash_bank_size *= ICH_FLASH_SECTOR_SIZE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
        hw->flash_bank_size /= 2 * sizeof(uint16_t);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
    if (eeprom->type == e1000_eeprom_spi) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
        /* eeprom_size will be an enum [0..8] that maps to eeprom sizes 128B to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
         * 32KB (incremented by powers of 2).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
        if (hw->mac_type <= e1000_82547_rev_2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
            /* Set to default value for initial eeprom read. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
            eeprom->word_size = 64;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
            ret_val = e1000_read_eeprom(hw, EEPROM_CFG, 1, &eeprom_size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
            eeprom_size = (eeprom_size & EEPROM_SIZE_MASK) >> EEPROM_SIZE_SHIFT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
            /* 256B eeprom size was not supported in earlier hardware, so we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
             * bump eeprom_size up one to ensure that "1" (which maps to 256B)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
             * is never the result used in the shifting logic below. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
            if (eeprom_size)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
                eeprom_size++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
            eeprom_size = (uint16_t)((eecd & E1000_EECD_SIZE_EX_MASK) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
                          E1000_EECD_SIZE_EX_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
        eeprom->word_size = 1 << (eeprom_size + EEPROM_WORD_SIZE_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4633
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4634
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
 * Raises the EEPROM's clock input.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4637
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
 * eecd - EECD's current value
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4640
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
e1000_raise_ee_clk(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4643
                   uint32_t *eecd)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
    /* Raise the clock input to the EEPROM (by setting the SK bit), and then
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
     * wait <delay> microseconds.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
    *eecd = *eecd | E1000_EECD_SK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
    E1000_WRITE_REG(hw, EECD, *eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
    udelay(hw->eeprom.delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
 * Lowers the EEPROM's clock input.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
 * eecd - EECD's current value
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
e1000_lower_ee_clk(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
                   uint32_t *eecd)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
    /* Lower the clock input to the EEPROM (by clearing the SK bit), and then
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
     * wait 50 microseconds.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
    *eecd = *eecd & ~E1000_EECD_SK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
    E1000_WRITE_REG(hw, EECD, *eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
    udelay(hw->eeprom.delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
 * Shift data bits out to the EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
 * data - data to send to the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
 * count - number of bits to shift out
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
e1000_shift_out_ee_bits(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
                        uint16_t data,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
                        uint16_t count)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4686
    uint32_t eecd;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
    uint32_t mask;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
    /* We need to shift "count" bits out to the EEPROM. So, value in the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
     * "data" parameter will be shifted out to the EEPROM one bit at a time.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
     * In order to do this, "data" must be broken down into bits.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
    mask = 0x01 << (count - 1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
    eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
    if (eeprom->type == e1000_eeprom_microwire) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
        eecd &= ~E1000_EECD_DO;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
    } else if (eeprom->type == e1000_eeprom_spi) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
        eecd |= E1000_EECD_DO;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
    do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
        /* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1",
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
         * and then raising and then lowering the clock (the SK bit controls
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
         * the clock input to the EEPROM).  A "0" is shifted out to the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
         * by setting "DI" to "0" and then raising and then lowering the clock.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4706
        eecd &= ~E1000_EECD_DI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
        if (data & mask)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
            eecd |= E1000_EECD_DI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4711
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
        udelay(eeprom->delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
        e1000_raise_ee_clk(hw, &eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
        e1000_lower_ee_clk(hw, &eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
        mask = mask >> 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
    } while (mask);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
    /* We leave the "DI" bit set to "0" when we leave this routine. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4724
    eecd &= ~E1000_EECD_DI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4725
    E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4729
 * Shift data bits in from the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4732
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
static uint16_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
e1000_shift_in_ee_bits(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
                       uint16_t count)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4736
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
    uint32_t eecd;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
    uint32_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
    uint16_t data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
    /* In order to read a register from the EEPROM, we need to shift 'count'
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
     * bits in from the EEPROM. Bits are "shifted in" by raising the clock
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
     * input to the EEPROM (setting the SK bit), and then reading the value of
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
     * the "DO" bit.  During this "shifting in" process the "DI" bit should
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4745
     * always be clear.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
    eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4750
    eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
    data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
    for (i = 0; i < count; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
        data = data << 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
        e1000_raise_ee_clk(hw, &eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
        eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
        eecd &= ~(E1000_EECD_DI);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
        if (eecd & E1000_EECD_DO)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4761
            data |= 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
        e1000_lower_ee_clk(hw, &eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
    return data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
 * Prepares EEPROM for access
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4773
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
 * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
 * function should be called before issuing a command to the EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4778
e1000_acquire_eeprom(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4781
    uint32_t eecd, i=0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
    DEBUGFUNC("e1000_acquire_eeprom");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
    if (e1000_swfw_sync_acquire(hw, E1000_SWFW_EEP_SM))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
        return -E1000_ERR_SWFW_SYNC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
    eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
    if (hw->mac_type != e1000_82573) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
        /* Request EEPROM Access */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
        if (hw->mac_type > e1000_82544) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
            eecd |= E1000_EECD_REQ;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
            E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
            eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
            while ((!(eecd & E1000_EECD_GNT)) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
                  (i < E1000_EEPROM_GRANT_ATTEMPTS)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
                i++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
                udelay(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
                eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4801
            if (!(eecd & E1000_EECD_GNT)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
                eecd &= ~E1000_EECD_REQ;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
                E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
                DEBUGOUT("Could not acquire EEPROM grant\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
                e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4806
                return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
    /* Setup EEPROM for Read/Write */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
    if (eeprom->type == e1000_eeprom_microwire) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
        /* Clear SK and DI */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
        eecd &= ~(E1000_EECD_DI | E1000_EECD_SK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
        /* Set CS */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
        eecd |= E1000_EECD_CS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
    } else if (eeprom->type == e1000_eeprom_spi) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
        /* Clear SK and CS */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
        eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4824
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4825
        udelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4826
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
 * Returns EEPROM to a "standby" state
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4833
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4834
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4835
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4836
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4837
e1000_standby_eeprom(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
    uint32_t eecd;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4841
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4842
    eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4843
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
    if (eeprom->type == e1000_eeprom_microwire) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
        eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4848
        udelay(eeprom->delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
        /* Clock high */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
        eecd |= E1000_EECD_SK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4854
        udelay(eeprom->delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
        /* Select EEPROM */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
        eecd |= E1000_EECD_CS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4858
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
        udelay(eeprom->delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4861
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
        /* Clock low */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
        eecd &= ~E1000_EECD_SK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4865
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
        udelay(eeprom->delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
    } else if (eeprom->type == e1000_eeprom_spi) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
        /* Toggle CS to flush commands */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4869
        eecd |= E1000_EECD_CS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4872
        udelay(eeprom->delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4873
        eecd &= ~E1000_EECD_CS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4874
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
        udelay(eeprom->delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4879
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4880
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4881
 * Terminates a command by inverting the EEPROM's chip select pin
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4886
e1000_release_eeprom(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4887
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4888
    uint32_t eecd;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4890
    DEBUGFUNC("e1000_release_eeprom");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
    eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4893
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
    if (hw->eeprom.type == e1000_eeprom_spi) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4895
        eecd |= E1000_EECD_CS;  /* Pull CS high */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
        eecd &= ~E1000_EECD_SK; /* Lower SCK */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4899
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
        udelay(hw->eeprom.delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
    } else if (hw->eeprom.type == e1000_eeprom_microwire) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
        /* cleanup eeprom */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
        /* CS on Microwire is active-high */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
        eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4909
        /* Rising edge of clock */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
        eecd |= E1000_EECD_SK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4912
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4913
        udelay(hw->eeprom.delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
        /* Falling edge of clock */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4916
        eecd &= ~E1000_EECD_SK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
        udelay(hw->eeprom.delay_usec);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4921
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4922
    /* Stop requesting EEPROM access */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
    if (hw->mac_type > e1000_82544) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
        eecd &= ~E1000_EECD_REQ;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4925
        E1000_WRITE_REG(hw, EECD, eecd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4926
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4927
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4928
    e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4931
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4932
 * Reads a 16 bit word from the EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4934
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4935
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4936
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
e1000_spi_eeprom_ready(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4938
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
    uint16_t retry_count = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
    uint8_t spi_stat_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4941
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4942
    DEBUGFUNC("e1000_spi_eeprom_ready");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4943
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4944
    /* Read "Status Register" repeatedly until the LSB is cleared.  The
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4945
     * EEPROM will signal that the command has been completed by clearing
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
     * bit 0 of the internal status register.  If it's not cleared within
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4947
     * 5 milliseconds, then error out.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4948
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4949
    retry_count = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4950
    do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4951
        e1000_shift_out_ee_bits(hw, EEPROM_RDSR_OPCODE_SPI,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4952
                                hw->eeprom.opcode_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4953
        spi_stat_reg = (uint8_t)e1000_shift_in_ee_bits(hw, 8);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4954
        if (!(spi_stat_reg & EEPROM_STATUS_RDY_SPI))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4955
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4956
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4957
        udelay(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
        retry_count += 5;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4960
        e1000_standby_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
    } while (retry_count < EEPROM_MAX_RETRY_SPI);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4962
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4963
    /* ATMEL SPI write time could vary from 0-20mSec on 3.3V devices (and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4964
     * only 0-5mSec on 5V devices)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4966
    if (retry_count >= EEPROM_MAX_RETRY_SPI) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
        DEBUGOUT("SPI EEPROM Status error\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
        return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
 * Reads a 16 bit word from the EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
 * offset - offset of  word in the EEPROM to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
 * data - word read from the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
 * words - number of words to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4982
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4983
e1000_read_eeprom(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4984
                  uint16_t offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4985
                  uint16_t words,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
                  uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4989
    uint32_t i = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
    DEBUGFUNC("e1000_read_eeprom");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4993
    /* If eeprom is not yet detected, do so now */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
    if (eeprom->word_size == 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4995
        e1000_init_eeprom_params(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
    /* A check for invalid values:  offset too large, too many words, and not
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
     * enough words.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
    if ((offset >= eeprom->word_size) || (words > eeprom->word_size - offset) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
       (words == 0)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
        DEBUGOUT2("\"words\" parameter out of bounds. Words = %d, size = %d\n", offset, eeprom->word_size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
        return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
    /* EEPROM's that don't use EERD to read require us to bit-bang the SPI
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
     * directly. In this case, we need to acquire the EEPROM so that
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
     * FW or other port software does not interrupt.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
    if (e1000_is_onboard_nvm_eeprom(hw) == TRUE &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
        hw->eeprom.use_eerd == FALSE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
        /* Prepare the EEPROM for bit-bang reading */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
        if (e1000_acquire_eeprom(hw) != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
    /* Eerd register EEPROM access requires no eeprom aquire/release */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5018
    if (eeprom->use_eerd == TRUE)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
        return e1000_read_eeprom_eerd(hw, offset, words, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5020
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
    /* ICH EEPROM access is done via the ICH flash controller */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5022
    if (eeprom->type == e1000_eeprom_ich8)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5023
        return e1000_read_eeprom_ich8(hw, offset, words, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5025
    /* Set up the SPI or Microwire EEPROM for bit-bang reading.  We have
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5026
     * acquired the EEPROM at this point, so any returns should relase it */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5027
    if (eeprom->type == e1000_eeprom_spi) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
        uint16_t word_in;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5029
        uint8_t read_opcode = EEPROM_READ_OPCODE_SPI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
        if (e1000_spi_eeprom_ready(hw)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5032
            e1000_release_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5033
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
        e1000_standby_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
        /* Some SPI eeproms use the 8th address bit embedded in the opcode */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
        if ((eeprom->address_bits == 8) && (offset >= 128))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
            read_opcode |= EEPROM_A8_OPCODE_SPI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5041
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
        /* Send the READ command (opcode + addr)  */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
        e1000_shift_out_ee_bits(hw, read_opcode, eeprom->opcode_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5044
        e1000_shift_out_ee_bits(hw, (uint16_t)(offset*2), eeprom->address_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
        /* Read the data.  The address of the eeprom internally increments with
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
         * each byte (spi) being read, saving on the overhead of eeprom setup
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
         * and tear-down.  The address counter will roll over if reading beyond
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
         * the size of the eeprom, thus allowing the entire memory to be read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
         * starting from any offset. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
        for (i = 0; i < words; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
            word_in = e1000_shift_in_ee_bits(hw, 16);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
            data[i] = (word_in >> 8) | (word_in << 8);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5054
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
    } else if (eeprom->type == e1000_eeprom_microwire) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5056
        for (i = 0; i < words; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
            /* Send the READ command (opcode + addr)  */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
            e1000_shift_out_ee_bits(hw, EEPROM_READ_OPCODE_MICROWIRE,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
                                    eeprom->opcode_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
            e1000_shift_out_ee_bits(hw, (uint16_t)(offset + i),
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5061
                                    eeprom->address_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5063
            /* Read the data.  For microwire, each word requires the overhead
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
             * of eeprom setup and tear-down. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
            data[i] = e1000_shift_in_ee_bits(hw, 16);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
            e1000_standby_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5068
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
    /* End this read operation */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
    e1000_release_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5073
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5076
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5077
 * Reads a 16 bit word from the EEPROM using the EERD register.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5080
 * offset - offset of  word in the EEPROM to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
 * data - word read from the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5082
 * words - number of words to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5083
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5084
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
e1000_read_eeprom_eerd(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5086
                  uint16_t offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5087
                  uint16_t words,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
                  uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5089
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5090
    uint32_t i, eerd = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
    int32_t error = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5092
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5093
    for (i = 0; i < words; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5094
        eerd = ((offset+i) << E1000_EEPROM_RW_ADDR_SHIFT) +
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
                         E1000_EEPROM_RW_REG_START;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
        E1000_WRITE_REG(hw, EERD, eerd);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
        error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_READ);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
        if (error) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5101
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
        data[i] = (E1000_READ_REG(hw, EERD) >> E1000_EEPROM_RW_REG_DATA);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5105
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5107
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5108
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
 * Writes a 16 bit word from the EEPROM using the EEWR register.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5112
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5114
 * offset - offset of  word in the EEPROM to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5115
 * data - word read from the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
 * words - number of words to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5119
e1000_write_eeprom_eewr(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
                   uint16_t offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5121
                   uint16_t words,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
                   uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
    uint32_t    register_value = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
    uint32_t    i              = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
    int32_t     error          = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5127
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
    if (e1000_swfw_sync_acquire(hw, E1000_SWFW_EEP_SM))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
        return -E1000_ERR_SWFW_SYNC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
    for (i = 0; i < words; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
        register_value = (data[i] << E1000_EEPROM_RW_REG_DATA) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
                         ((offset+i) << E1000_EEPROM_RW_ADDR_SHIFT) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
                         E1000_EEPROM_RW_REG_START;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5136
        error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5137
        if (error) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5139
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5140
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
        E1000_WRITE_REG(hw, EEWR, register_value);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5142
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
        error = e1000_poll_eerd_eewr_done(hw, E1000_EEPROM_POLL_WRITE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5145
        if (error) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5146
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5150
    e1000_swfw_sync_release(hw, E1000_SWFW_EEP_SM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5151
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5152
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5153
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
 * Polls the status bit (bit 1) of the EERD to determine when the read is done.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5157
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5158
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5159
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5160
e1000_poll_eerd_eewr_done(struct e1000_hw *hw, int eerd)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
    uint32_t attempts = 100000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
    uint32_t i, reg = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5164
    int32_t done = E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5165
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5166
    for (i = 0; i < attempts; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5167
        if (eerd == E1000_EEPROM_POLL_READ)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
            reg = E1000_READ_REG(hw, EERD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5169
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
            reg = E1000_READ_REG(hw, EEWR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5171
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5172
        if (reg & E1000_EEPROM_RW_REG_DONE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
            done = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5176
        udelay(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5177
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5178
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5179
    return done;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5181
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
/***************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5183
* Description:     Determines if the onboard NVM is FLASH or EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5184
*
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
* hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5186
****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
static boolean_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5188
e1000_is_onboard_nvm_eeprom(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5190
    uint32_t eecd = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
    DEBUGFUNC("e1000_is_onboard_nvm_eeprom");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5193
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5194
    if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
        return FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
    if (hw->mac_type == e1000_82573) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5198
        eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5200
        /* Isolate bits 15 & 16 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5201
        eecd = ((eecd >> 15) & 0x03);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5202
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
        /* If both bits are set, device is Flash type */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
        if (eecd == 0x03) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5205
            return FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5207
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
    return TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5210
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5211
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5212
 * Verifies that the EEPROM has a valid checksum
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5213
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5214
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5215
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
 * Reads the first 64 16 bit words of the EEPROM and sums the values read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5217
 * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5218
 * valid.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5219
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5220
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5221
e1000_validate_eeprom_checksum(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5222
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5223
    uint16_t checksum = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
    uint16_t i, eeprom_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5225
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5226
    DEBUGFUNC("e1000_validate_eeprom_checksum");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5227
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5228
    if ((hw->mac_type == e1000_82573) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
        (e1000_is_onboard_nvm_eeprom(hw) == FALSE)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
        /* Check bit 4 of word 10h.  If it is 0, firmware is done updating
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
         * 10h-12h.  Checksum may need to be fixed. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5232
        e1000_read_eeprom(hw, 0x10, 1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
        if ((eeprom_data & 0x10) == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5234
            /* Read 0x23 and check bit 15.  This bit is a 1 when the checksum
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
             * has already been fixed.  If the checksum is still wrong and this
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
             * bit is a 1, we need to return bad checksum.  Otherwise, we need
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
             * to set this bit to a 1 and update the checksum. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
            e1000_read_eeprom(hw, 0x23, 1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
            if ((eeprom_data & 0x8000) == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
                eeprom_data |= 0x8000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
                e1000_write_eeprom(hw, 0x23, 1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5242
                e1000_update_eeprom_checksum(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5244
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5247
    if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
        /* Drivers must allocate the shadow ram structure for the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
         * EEPROM checksum to be updated.  Otherwise, this bit as well
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
         * as the checksum must both be set correctly for this
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
         * validation to pass.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5252
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5253
        e1000_read_eeprom(hw, 0x19, 1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
        if ((eeprom_data & 0x40) == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5255
            eeprom_data |= 0x40;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5256
            e1000_write_eeprom(hw, 0x19, 1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
            e1000_update_eeprom_checksum(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5259
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
    for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5262
        if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5263
            DEBUGOUT("EEPROM Read Error\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5265
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5266
        checksum += eeprom_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5267
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5268
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5269
    if (checksum == (uint16_t) EEPROM_SUM)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5270
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5271
    else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
        DEBUGOUT("EEPROM Checksum Invalid\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
        return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5277
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
 * Calculates the EEPROM checksum and writes it to the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5279
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5280
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5281
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
 * Sums the first 63 16 bit words of the EEPROM. Subtracts the sum from 0xBABA.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
 * Writes the difference to word offset 63 of the EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5284
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5286
e1000_update_eeprom_checksum(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5287
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5288
    uint32_t ctrl_ext;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5289
    uint16_t checksum = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
    uint16_t i, eeprom_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5292
    DEBUGFUNC("e1000_update_eeprom_checksum");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
    for (i = 0; i < EEPROM_CHECKSUM_REG; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
        if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
            DEBUGOUT("EEPROM Read Error\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
        checksum += eeprom_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5300
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5301
    checksum = (uint16_t) EEPROM_SUM - checksum;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5302
    if (e1000_write_eeprom(hw, EEPROM_CHECKSUM_REG, 1, &checksum) < 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5303
        DEBUGOUT("EEPROM Write Error\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
        return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5305
    } else if (hw->eeprom.type == e1000_eeprom_flash) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
        e1000_commit_shadow_ram(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
    } else if (hw->eeprom.type == e1000_eeprom_ich8) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
        e1000_commit_shadow_ram(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
        /* Reload the EEPROM, or else modifications will not appear
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5310
         * until after next adapter reset. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5311
        ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5312
        ctrl_ext |= E1000_CTRL_EXT_EE_RST;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5313
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
        msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5315
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5316
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5317
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5318
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5319
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5320
 * Parent function for writing words to the different EEPROM types.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5321
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5322
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
 * offset - offset within the EEPROM to be written to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
 * words - number of words to write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5325
 * data - 16 bit word to be written to the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5326
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5327
 * If e1000_update_eeprom_checksum is not called after this function, the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5328
 * EEPROM will most likely contain an invalid checksum.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5329
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5330
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5331
e1000_write_eeprom(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5332
                   uint16_t offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5333
                   uint16_t words,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5334
                   uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5336
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5337
    int32_t status = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5338
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
    DEBUGFUNC("e1000_write_eeprom");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5340
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5341
    /* If eeprom is not yet detected, do so now */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
    if (eeprom->word_size == 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
        e1000_init_eeprom_params(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5345
    /* A check for invalid values:  offset too large, too many words, and not
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5346
     * enough words.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5347
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5348
    if ((offset >= eeprom->word_size) || (words > eeprom->word_size - offset) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
       (words == 0)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
        DEBUGOUT("\"words\" parameter out of bounds\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5351
        return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5353
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5354
    /* 82573 writes only through eewr */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5355
    if (eeprom->use_eewr == TRUE)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
        return e1000_write_eeprom_eewr(hw, offset, words, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
    if (eeprom->type == e1000_eeprom_ich8)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5359
        return e1000_write_eeprom_ich8(hw, offset, words, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5360
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5361
    /* Prepare the EEPROM for writing  */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5362
    if (e1000_acquire_eeprom(hw) != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5363
        return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
    if (eeprom->type == e1000_eeprom_microwire) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5366
        status = e1000_write_eeprom_microwire(hw, offset, words, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5367
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
        status = e1000_write_eeprom_spi(hw, offset, words, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5369
        msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5370
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5372
    /* Done with writing */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
    e1000_release_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
    return status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5378
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
 * Writes a 16 bit word to a given offset in an SPI EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5380
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5381
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
 * offset - offset within the EEPROM to be written to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
 * words - number of words to write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
 * data - pointer to array of 8 bit words to be written to the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5385
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5387
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5388
e1000_write_eeprom_spi(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5389
                       uint16_t offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
                       uint16_t words,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
                       uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5394
    uint16_t widx = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5395
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5396
    DEBUGFUNC("e1000_write_eeprom_spi");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5397
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5398
    while (widx < words) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5399
        uint8_t write_opcode = EEPROM_WRITE_OPCODE_SPI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5400
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5401
        if (e1000_spi_eeprom_ready(hw)) return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5402
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5403
        e1000_standby_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5404
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5405
        /*  Send the WRITE ENABLE command (8 bit opcode )  */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5406
        e1000_shift_out_ee_bits(hw, EEPROM_WREN_OPCODE_SPI,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5407
                                    eeprom->opcode_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5408
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5409
        e1000_standby_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5410
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5411
        /* Some SPI eeproms use the 8th address bit embedded in the opcode */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5412
        if ((eeprom->address_bits == 8) && (offset >= 128))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5413
            write_opcode |= EEPROM_A8_OPCODE_SPI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5414
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5415
        /* Send the Write command (8-bit opcode + addr) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5416
        e1000_shift_out_ee_bits(hw, write_opcode, eeprom->opcode_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5417
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5418
        e1000_shift_out_ee_bits(hw, (uint16_t)((offset + widx)*2),
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5419
                                eeprom->address_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5420
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5421
        /* Send the data */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5422
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5423
        /* Loop to allow for up to whole page write (32 bytes) of eeprom */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5424
        while (widx < words) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5425
            uint16_t word_out = data[widx];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5426
            word_out = (word_out >> 8) | (word_out << 8);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5427
            e1000_shift_out_ee_bits(hw, word_out, 16);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5428
            widx++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5429
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5430
            /* Some larger eeprom sizes are capable of a 32-byte PAGE WRITE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5431
             * operation, while the smaller eeproms are capable of an 8-byte
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5432
             * PAGE WRITE operation.  Break the inner loop to pass new address
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5433
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5434
            if ((((offset + widx)*2) % eeprom->page_size) == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5435
                e1000_standby_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5436
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5437
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5438
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5439
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5440
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5441
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5442
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5443
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5444
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5445
 * Writes a 16 bit word to a given offset in a Microwire EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5446
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5447
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5448
 * offset - offset within the EEPROM to be written to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5449
 * words - number of words to write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5450
 * data - pointer to array of 16 bit words to be written to the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5451
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5452
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5453
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5454
e1000_write_eeprom_microwire(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5455
                             uint16_t offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5456
                             uint16_t words,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5457
                             uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5458
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5459
    struct e1000_eeprom_info *eeprom = &hw->eeprom;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5460
    uint32_t eecd;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5461
    uint16_t words_written = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5462
    uint16_t i = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5463
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5464
    DEBUGFUNC("e1000_write_eeprom_microwire");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5465
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5466
    /* Send the write enable command to the EEPROM (3-bit opcode plus
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5467
     * 6/8-bit dummy address beginning with 11).  It's less work to include
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5468
     * the 11 of the dummy address as part of the opcode than it is to shift
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5469
     * it over the correct number of bits for the address.  This puts the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5470
     * EEPROM into write/erase mode.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5471
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5472
    e1000_shift_out_ee_bits(hw, EEPROM_EWEN_OPCODE_MICROWIRE,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5473
                            (uint16_t)(eeprom->opcode_bits + 2));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5474
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5475
    e1000_shift_out_ee_bits(hw, 0, (uint16_t)(eeprom->address_bits - 2));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5476
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5477
    /* Prepare the EEPROM */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5478
    e1000_standby_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5479
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5480
    while (words_written < words) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5481
        /* Send the Write command (3-bit opcode + addr) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5482
        e1000_shift_out_ee_bits(hw, EEPROM_WRITE_OPCODE_MICROWIRE,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5483
                                eeprom->opcode_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5484
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5485
        e1000_shift_out_ee_bits(hw, (uint16_t)(offset + words_written),
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5486
                                eeprom->address_bits);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5487
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5488
        /* Send the data */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5489
        e1000_shift_out_ee_bits(hw, data[words_written], 16);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5490
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5491
        /* Toggle the CS line.  This in effect tells the EEPROM to execute
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5492
         * the previous command.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5493
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5494
        e1000_standby_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5495
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5496
        /* Read DO repeatedly until it is high (equal to '1').  The EEPROM will
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5497
         * signal that the command has been completed by raising the DO signal.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5498
         * If DO does not go high in 10 milliseconds, then error out.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5499
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5500
        for (i = 0; i < 200; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5501
            eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5502
            if (eecd & E1000_EECD_DO) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5503
            udelay(50);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5504
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5505
        if (i == 200) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5506
            DEBUGOUT("EEPROM Write did not complete\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5507
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5508
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5509
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5510
        /* Recover from write */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5511
        e1000_standby_eeprom(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5512
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5513
        words_written++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5514
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5515
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5516
    /* Send the write disable command to the EEPROM (3-bit opcode plus
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5517
     * 6/8-bit dummy address beginning with 10).  It's less work to include
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5518
     * the 10 of the dummy address as part of the opcode than it is to shift
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5519
     * it over the correct number of bits for the address.  This takes the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5520
     * EEPROM out of write/erase mode.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5521
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5522
    e1000_shift_out_ee_bits(hw, EEPROM_EWDS_OPCODE_MICROWIRE,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5523
                            (uint16_t)(eeprom->opcode_bits + 2));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5524
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5525
    e1000_shift_out_ee_bits(hw, 0, (uint16_t)(eeprom->address_bits - 2));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5526
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5527
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5528
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5529
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5530
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5531
 * Flushes the cached eeprom to NVM. This is done by saving the modified values
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5532
 * in the eeprom cache and the non modified values in the currently active bank
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5533
 * to the new bank.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5534
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5535
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5536
 * offset - offset of  word in the EEPROM to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5537
 * data - word read from the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5538
 * words - number of words to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5539
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5540
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5541
e1000_commit_shadow_ram(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5542
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5543
    uint32_t attempts = 100000;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5544
    uint32_t eecd = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5545
    uint32_t flop = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5546
    uint32_t i = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5547
    int32_t error = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5548
    uint32_t old_bank_offset = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5549
    uint32_t new_bank_offset = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5550
    uint8_t low_byte = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5551
    uint8_t high_byte = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5552
    boolean_t sector_write_failed = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5553
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5554
    if (hw->mac_type == e1000_82573) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5555
        /* The flop register will be used to determine if flash type is STM */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5556
        flop = E1000_READ_REG(hw, FLOP);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5557
        for (i=0; i < attempts; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5558
            eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5559
            if ((eecd & E1000_EECD_FLUPD) == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5560
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5561
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5562
            udelay(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5563
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5564
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5565
        if (i == attempts) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5566
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5567
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5568
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5569
        /* If STM opcode located in bits 15:8 of flop, reset firmware */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5570
        if ((flop & 0xFF00) == E1000_STM_OPCODE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5571
            E1000_WRITE_REG(hw, HICR, E1000_HICR_FW_RESET);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5572
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5573
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5574
        /* Perform the flash update */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5575
        E1000_WRITE_REG(hw, EECD, eecd | E1000_EECD_FLUPD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5576
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5577
        for (i=0; i < attempts; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5578
            eecd = E1000_READ_REG(hw, EECD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5579
            if ((eecd & E1000_EECD_FLUPD) == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5580
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5581
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5582
            udelay(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5583
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5584
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5585
        if (i == attempts) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5586
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5587
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5588
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5589
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5590
    if (hw->mac_type == e1000_ich8lan && hw->eeprom_shadow_ram != NULL) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5591
        /* We're writing to the opposite bank so if we're on bank 1,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5592
         * write to bank 0 etc.  We also need to erase the segment that
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5593
         * is going to be written */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5594
        if (!(E1000_READ_REG(hw, EECD) & E1000_EECD_SEC1VAL)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5595
            new_bank_offset = hw->flash_bank_size * 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5596
            old_bank_offset = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5597
            e1000_erase_ich8_4k_segment(hw, 1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5598
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5599
            old_bank_offset = hw->flash_bank_size * 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5600
            new_bank_offset = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5601
            e1000_erase_ich8_4k_segment(hw, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5602
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5603
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5604
        sector_write_failed = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5605
        /* Loop for every byte in the shadow RAM,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5606
         * which is in units of words. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5607
        for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5608
            /* Determine whether to write the value stored
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5609
             * in the other NVM bank or a modified value stored
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5610
             * in the shadow RAM */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5611
            if (hw->eeprom_shadow_ram[i].modified == TRUE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5612
                low_byte = (uint8_t)hw->eeprom_shadow_ram[i].eeprom_word;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5613
                udelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5614
                error = e1000_verify_write_ich8_byte(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5615
                            (i << 1) + new_bank_offset, low_byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5616
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5617
                if (error != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5618
                    sector_write_failed = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5619
                else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5620
                    high_byte =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5621
                        (uint8_t)(hw->eeprom_shadow_ram[i].eeprom_word >> 8);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5622
                    udelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5623
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5624
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5625
                e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5626
                                     &low_byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5627
                udelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5628
                error = e1000_verify_write_ich8_byte(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5629
                            (i << 1) + new_bank_offset, low_byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5630
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5631
                if (error != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5632
                    sector_write_failed = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5633
                else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5634
                    e1000_read_ich8_byte(hw, (i << 1) + old_bank_offset + 1,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5635
                                         &high_byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5636
                    udelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5637
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5638
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5639
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5640
            /* If the write of the low byte was successful, go ahread and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5641
             * write the high byte while checking to make sure that if it
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5642
             * is the signature byte, then it is handled properly */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5643
            if (sector_write_failed == FALSE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5644
                /* If the word is 0x13, then make sure the signature bits
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5645
                 * (15:14) are 11b until the commit has completed.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5646
                 * This will allow us to write 10b which indicates the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5647
                 * signature is valid.  We want to do this after the write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5648
                 * has completed so that we don't mark the segment valid
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5649
                 * while the write is still in progress */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5650
                if (i == E1000_ICH_NVM_SIG_WORD)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5651
                    high_byte = E1000_ICH_NVM_SIG_MASK | high_byte;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5652
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5653
                error = e1000_verify_write_ich8_byte(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5654
                            (i << 1) + new_bank_offset + 1, high_byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5655
                if (error != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5656
                    sector_write_failed = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5657
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5658
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5659
                /* If the write failed then break from the loop and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5660
                 * return an error */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5661
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5662
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5663
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5664
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5665
        /* Don't bother writing the segment valid bits if sector
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5666
         * programming failed. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5667
        if (sector_write_failed == FALSE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5668
            /* Finally validate the new segment by setting bit 15:14
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5669
             * to 10b in word 0x13 , this can be done without an
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5670
             * erase as well since these bits are 11 to start with
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5671
             * and we need to change bit 14 to 0b */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5672
            e1000_read_ich8_byte(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5673
                                 E1000_ICH_NVM_SIG_WORD * 2 + 1 + new_bank_offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5674
                                 &high_byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5675
            high_byte &= 0xBF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5676
            error = e1000_verify_write_ich8_byte(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5677
                        E1000_ICH_NVM_SIG_WORD * 2 + 1 + new_bank_offset, high_byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5678
            /* And invalidate the previously valid segment by setting
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5679
             * its signature word (0x13) high_byte to 0b. This can be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5680
             * done without an erase because flash erase sets all bits
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5681
             * to 1's. We can write 1's to 0's without an erase */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5682
            if (error == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5683
                error = e1000_verify_write_ich8_byte(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5684
                            E1000_ICH_NVM_SIG_WORD * 2 + 1 + old_bank_offset, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5685
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5686
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5687
            /* Clear the now not used entry in the cache */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5688
            for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5689
                hw->eeprom_shadow_ram[i].modified = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5690
                hw->eeprom_shadow_ram[i].eeprom_word = 0xFFFF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5691
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5692
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5693
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5694
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5695
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5696
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5697
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5698
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5699
 * Reads the adapter's MAC address from the EEPROM and inverts the LSB for the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5700
 * second function of dual function devices
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5701
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5702
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5703
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5704
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5705
e1000_read_mac_addr(struct e1000_hw * hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5706
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5707
    uint16_t offset;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5708
    uint16_t eeprom_data, i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5709
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5710
    DEBUGFUNC("e1000_read_mac_addr");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5711
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5712
    for (i = 0; i < NODE_ADDRESS_SIZE; i += 2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5713
        offset = i >> 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5714
        if (e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5715
            DEBUGOUT("EEPROM Read Error\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5716
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5717
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5718
        hw->perm_mac_addr[i] = (uint8_t) (eeprom_data & 0x00FF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5719
        hw->perm_mac_addr[i+1] = (uint8_t) (eeprom_data >> 8);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5720
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5721
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5722
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5723
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5724
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5725
    case e1000_82546:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5726
    case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5727
    case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5728
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5729
        if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5730
            hw->perm_mac_addr[5] ^= 0x01;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5731
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5732
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5733
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5734
    for (i = 0; i < NODE_ADDRESS_SIZE; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5735
        hw->mac_addr[i] = hw->perm_mac_addr[i];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5736
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5737
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5738
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5739
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5740
 * Initializes receive address filters.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5741
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5742
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5743
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5744
 * Places the MAC address in receive address register 0 and clears the rest
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5745
 * of the receive addresss registers. Clears the multicast table. Assumes
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5746
 * the receiver is in reset when the routine is called.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5747
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5748
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5749
e1000_init_rx_addrs(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5750
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5751
    uint32_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5752
    uint32_t rar_num;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5753
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5754
    DEBUGFUNC("e1000_init_rx_addrs");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5755
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5756
    /* Setup the receive address. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5757
    DEBUGOUT("Programming MAC Address into RAR[0]\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5758
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5759
    e1000_rar_set(hw, hw->mac_addr, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5760
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5761
    rar_num = E1000_RAR_ENTRIES;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5762
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5763
    /* Reserve a spot for the Locally Administered Address to work around
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5764
     * an 82571 issue in which a reset on one port will reload the MAC on
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5765
     * the other port. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5766
    if ((hw->mac_type == e1000_82571) && (hw->laa_is_present == TRUE))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5767
        rar_num -= 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5768
    if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5769
        rar_num = E1000_RAR_ENTRIES_ICH8LAN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5770
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5771
    /* Zero out the other 15 receive addresses. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5772
    DEBUGOUT("Clearing RAR[1-15]\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5773
    for (i = 1; i < rar_num; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5774
        E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5775
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5776
        E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5777
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5778
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5779
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5780
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5781
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5782
 * Hashes an address to determine its location in the multicast table
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5783
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5784
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5785
 * mc_addr - the multicast address to hash
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5786
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5787
uint32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5788
e1000_hash_mc_addr(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5789
                   uint8_t *mc_addr)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5790
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5791
    uint32_t hash_value = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5792
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5793
    /* The portion of the address that is used for the hash table is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5794
     * determined by the mc_filter_type setting.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5795
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5796
    switch (hw->mc_filter_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5797
    /* [0] [1] [2] [3] [4] [5]
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5798
     * 01  AA  00  12  34  56
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5799
     * LSB                 MSB
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5800
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5801
    case 0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5802
        if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5803
            /* [47:38] i.e. 0x158 for above example address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5804
            hash_value = ((mc_addr[4] >> 6) | (((uint16_t) mc_addr[5]) << 2));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5805
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5806
            /* [47:36] i.e. 0x563 for above example address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5807
            hash_value = ((mc_addr[4] >> 4) | (((uint16_t) mc_addr[5]) << 4));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5808
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5809
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5810
    case 1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5811
        if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5812
            /* [46:37] i.e. 0x2B1 for above example address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5813
            hash_value = ((mc_addr[4] >> 5) | (((uint16_t) mc_addr[5]) << 3));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5814
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5815
            /* [46:35] i.e. 0xAC6 for above example address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5816
            hash_value = ((mc_addr[4] >> 3) | (((uint16_t) mc_addr[5]) << 5));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5817
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5818
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5819
    case 2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5820
        if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5821
            /*[45:36] i.e. 0x163 for above example address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5822
            hash_value = ((mc_addr[4] >> 4) | (((uint16_t) mc_addr[5]) << 4));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5823
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5824
            /* [45:34] i.e. 0x5D8 for above example address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5825
            hash_value = ((mc_addr[4] >> 2) | (((uint16_t) mc_addr[5]) << 6));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5826
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5827
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5828
    case 3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5829
        if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5830
            /* [43:34] i.e. 0x18D for above example address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5831
            hash_value = ((mc_addr[4] >> 2) | (((uint16_t) mc_addr[5]) << 6));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5832
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5833
            /* [43:32] i.e. 0x634 for above example address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5834
            hash_value = ((mc_addr[4]) | (((uint16_t) mc_addr[5]) << 8));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5835
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5836
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5837
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5838
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5839
    hash_value &= 0xFFF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5840
    if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5841
        hash_value &= 0x3FF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5842
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5843
    return hash_value;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5844
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5845
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5846
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5847
 * Sets the bit in the multicast table corresponding to the hash value.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5848
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5849
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5850
 * hash_value - Multicast address hash value
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5851
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5852
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5853
e1000_mta_set(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5854
              uint32_t hash_value)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5855
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5856
    uint32_t hash_bit, hash_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5857
    uint32_t mta;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5858
    uint32_t temp;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5859
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5860
    /* The MTA is a register array of 128 32-bit registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5861
     * It is treated like an array of 4096 bits.  We want to set
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5862
     * bit BitArray[hash_value]. So we figure out what register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5863
     * the bit is in, read it, OR in the new bit, then write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5864
     * back the new value.  The register is determined by the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5865
     * upper 7 bits of the hash value and the bit within that
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5866
     * register are determined by the lower 5 bits of the value.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5867
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5868
    hash_reg = (hash_value >> 5) & 0x7F;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5869
    if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5870
        hash_reg &= 0x1F;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5871
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5872
    hash_bit = hash_value & 0x1F;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5873
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5874
    mta = E1000_READ_REG_ARRAY(hw, MTA, hash_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5875
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5876
    mta |= (1 << hash_bit);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5877
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5878
    /* If we are on an 82544 and we are trying to write an odd offset
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5879
     * in the MTA, save off the previous entry before writing and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5880
     * restore the old value after writing.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5881
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5882
    if ((hw->mac_type == e1000_82544) && ((hash_reg & 0x1) == 1)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5883
        temp = E1000_READ_REG_ARRAY(hw, MTA, (hash_reg - 1));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5884
        E1000_WRITE_REG_ARRAY(hw, MTA, hash_reg, mta);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5885
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5886
        E1000_WRITE_REG_ARRAY(hw, MTA, (hash_reg - 1), temp);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5887
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5888
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5889
        E1000_WRITE_REG_ARRAY(hw, MTA, hash_reg, mta);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5890
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5891
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5892
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5893
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5894
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5895
 * Puts an ethernet address into a receive address register.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5896
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5897
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5898
 * addr - Address to put into receive address register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5899
 * index - Receive address register to write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5900
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5901
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5902
e1000_rar_set(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5903
              uint8_t *addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5904
              uint32_t index)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5905
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5906
    uint32_t rar_low, rar_high;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5907
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5908
    /* HW expects these in little endian so we reverse the byte order
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5909
     * from network order (big endian) to little endian
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5910
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5911
    rar_low = ((uint32_t) addr[0] |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5912
               ((uint32_t) addr[1] << 8) |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5913
               ((uint32_t) addr[2] << 16) | ((uint32_t) addr[3] << 24));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5914
    rar_high = ((uint32_t) addr[4] | ((uint32_t) addr[5] << 8));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5915
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5916
    /* Disable Rx and flush all Rx frames before enabling RSS to avoid Rx
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5917
     * unit hang.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5918
     *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5919
     * Description:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5920
     * If there are any Rx frames queued up or otherwise present in the HW
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5921
     * before RSS is enabled, and then we enable RSS, the HW Rx unit will
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5922
     * hang.  To work around this issue, we have to disable receives and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5923
     * flush out all Rx frames before we enable RSS. To do so, we modify we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5924
     * redirect all Rx traffic to manageability and then reset the HW.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5925
     * This flushes away Rx frames, and (since the redirections to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5926
     * manageability persists across resets) keeps new ones from coming in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5927
     * while we work.  Then, we clear the Address Valid AV bit for all MAC
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5928
     * addresses and undo the re-direction to manageability.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5929
     * Now, frames are coming in again, but the MAC won't accept them, so
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5930
     * far so good.  We now proceed to initialize RSS (if necessary) and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5931
     * configure the Rx unit.  Last, we re-enable the AV bits and continue
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5932
     * on our merry way.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5933
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5934
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5935
    case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5936
    case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5937
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5938
        if (hw->leave_av_bit_off == TRUE)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5939
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5940
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5941
        /* Indicate to hardware the Address is Valid. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5942
        rar_high |= E1000_RAH_AV;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5943
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5944
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5945
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5946
    E1000_WRITE_REG_ARRAY(hw, RA, (index << 1), rar_low);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5947
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5948
    E1000_WRITE_REG_ARRAY(hw, RA, ((index << 1) + 1), rar_high);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5949
    E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5950
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5951
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5952
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5953
 * Writes a value to the specified offset in the VLAN filter table.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5954
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5955
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5956
 * offset - Offset in VLAN filer table to write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5957
 * value - Value to write into VLAN filter table
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5958
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5959
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5960
e1000_write_vfta(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5961
                 uint32_t offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5962
                 uint32_t value)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5963
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5964
    uint32_t temp;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5965
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5966
    if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5967
        return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5968
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5969
    if ((hw->mac_type == e1000_82544) && ((offset & 0x1) == 1)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5970
        temp = E1000_READ_REG_ARRAY(hw, VFTA, (offset - 1));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5971
        E1000_WRITE_REG_ARRAY(hw, VFTA, offset, value);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5972
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5973
        E1000_WRITE_REG_ARRAY(hw, VFTA, (offset - 1), temp);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5974
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5975
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5976
        E1000_WRITE_REG_ARRAY(hw, VFTA, offset, value);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5977
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5978
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5979
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5980
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5981
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5982
 * Clears the VLAN filer table
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5983
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5984
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5985
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5986
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5987
e1000_clear_vfta(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5988
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5989
    uint32_t offset;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5990
    uint32_t vfta_value = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5991
    uint32_t vfta_offset = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5992
    uint32_t vfta_bit_in_reg = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5993
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5994
    if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5995
        return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5996
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5997
    if (hw->mac_type == e1000_82573) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5998
        if (hw->mng_cookie.vlan_id != 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5999
            /* The VFTA is a 4096b bit-field, each identifying a single VLAN
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6000
             * ID.  The following operations determine which 32b entry
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6001
             * (i.e. offset) into the array we want to set the VLAN ID
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6002
             * (i.e. bit) of the manageability unit. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6003
            vfta_offset = (hw->mng_cookie.vlan_id >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6004
                           E1000_VFTA_ENTRY_SHIFT) &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6005
                          E1000_VFTA_ENTRY_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6006
            vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6007
                                    E1000_VFTA_ENTRY_BIT_SHIFT_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6008
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6009
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6010
    for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6011
        /* If the offset we want to clear is the same offset of the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6012
         * manageability VLAN ID, then clear all bits except that of the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6013
         * manageability unit */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6014
        vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6015
        E1000_WRITE_REG_ARRAY(hw, VFTA, offset, vfta_value);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6016
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6017
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6018
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6019
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6020
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6021
e1000_id_led_init(struct e1000_hw * hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6022
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6023
    uint32_t ledctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6024
    const uint32_t ledctl_mask = 0x000000FF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6025
    const uint32_t ledctl_on = E1000_LEDCTL_MODE_LED_ON;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6026
    const uint32_t ledctl_off = E1000_LEDCTL_MODE_LED_OFF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6027
    uint16_t eeprom_data, i, temp;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6028
    const uint16_t led_mask = 0x0F;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6029
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6030
    DEBUGFUNC("e1000_id_led_init");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6031
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6032
    if (hw->mac_type < e1000_82540) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6033
        /* Nothing to do */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6034
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6035
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6036
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6037
    ledctl = E1000_READ_REG(hw, LEDCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6038
    hw->ledctl_default = ledctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6039
    hw->ledctl_mode1 = hw->ledctl_default;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6040
    hw->ledctl_mode2 = hw->ledctl_default;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6041
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6042
    if (e1000_read_eeprom(hw, EEPROM_ID_LED_SETTINGS, 1, &eeprom_data) < 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6043
        DEBUGOUT("EEPROM Read Error\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6044
        return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6045
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6046
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6047
    if ((hw->mac_type == e1000_82573) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6048
        (eeprom_data == ID_LED_RESERVED_82573))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6049
        eeprom_data = ID_LED_DEFAULT_82573;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6050
    else if ((eeprom_data == ID_LED_RESERVED_0000) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6051
            (eeprom_data == ID_LED_RESERVED_FFFF)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6052
        if (hw->mac_type == e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6053
            eeprom_data = ID_LED_DEFAULT_ICH8LAN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6054
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6055
            eeprom_data = ID_LED_DEFAULT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6056
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6057
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6058
    for (i = 0; i < 4; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6059
        temp = (eeprom_data >> (i << 2)) & led_mask;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6060
        switch (temp) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6061
        case ID_LED_ON1_DEF2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6062
        case ID_LED_ON1_ON2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6063
        case ID_LED_ON1_OFF2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6064
            hw->ledctl_mode1 &= ~(ledctl_mask << (i << 3));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6065
            hw->ledctl_mode1 |= ledctl_on << (i << 3);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6066
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6067
        case ID_LED_OFF1_DEF2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6068
        case ID_LED_OFF1_ON2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6069
        case ID_LED_OFF1_OFF2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6070
            hw->ledctl_mode1 &= ~(ledctl_mask << (i << 3));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6071
            hw->ledctl_mode1 |= ledctl_off << (i << 3);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6072
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6073
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6074
            /* Do nothing */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6075
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6076
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6077
        switch (temp) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6078
        case ID_LED_DEF1_ON2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6079
        case ID_LED_ON1_ON2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6080
        case ID_LED_OFF1_ON2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6081
            hw->ledctl_mode2 &= ~(ledctl_mask << (i << 3));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6082
            hw->ledctl_mode2 |= ledctl_on << (i << 3);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6083
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6084
        case ID_LED_DEF1_OFF2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6085
        case ID_LED_ON1_OFF2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6086
        case ID_LED_OFF1_OFF2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6087
            hw->ledctl_mode2 &= ~(ledctl_mask << (i << 3));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6088
            hw->ledctl_mode2 |= ledctl_off << (i << 3);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6089
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6090
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6091
            /* Do nothing */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6092
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6093
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6094
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6095
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6096
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6097
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6098
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6099
 * Prepares SW controlable LED for use and saves the current state of the LED.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6100
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6101
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6102
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6103
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6104
e1000_setup_led(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6105
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6106
    uint32_t ledctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6107
    int32_t ret_val = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6108
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6109
    DEBUGFUNC("e1000_setup_led");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6110
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6111
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6112
    case e1000_82542_rev2_0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6113
    case e1000_82542_rev2_1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6114
    case e1000_82543:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6115
    case e1000_82544:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6116
        /* No setup necessary */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6117
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6118
    case e1000_82541:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6119
    case e1000_82547:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6120
    case e1000_82541_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6121
    case e1000_82547_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6122
        /* Turn off PHY Smart Power Down (if enabled) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6123
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_GMII_FIFO,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6124
                                     &hw->phy_spd_default);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6125
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6126
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6127
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6128
                                      (uint16_t)(hw->phy_spd_default &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6129
                                      ~IGP01E1000_GMII_SPD));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6130
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6131
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6132
        /* Fall Through */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6133
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6134
        if (hw->media_type == e1000_media_type_fiber) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6135
            ledctl = E1000_READ_REG(hw, LEDCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6136
            /* Save current LEDCTL settings */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6137
            hw->ledctl_default = ledctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6138
            /* Turn off LED0 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6139
            ledctl &= ~(E1000_LEDCTL_LED0_IVRT |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6140
                        E1000_LEDCTL_LED0_BLINK |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6141
                        E1000_LEDCTL_LED0_MODE_MASK);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6142
            ledctl |= (E1000_LEDCTL_MODE_LED_OFF <<
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6143
                       E1000_LEDCTL_LED0_MODE_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6144
            E1000_WRITE_REG(hw, LEDCTL, ledctl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6145
        } else if (hw->media_type == e1000_media_type_copper)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6146
            E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6147
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6148
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6149
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6150
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6151
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6152
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6153
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6154
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6155
 * Used on 82571 and later Si that has LED blink bits.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6156
 * Callers must use their own timer and should have already called
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6157
 * e1000_id_led_init()
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6158
 * Call e1000_cleanup led() to stop blinking
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6159
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6160
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6161
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6162
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6163
e1000_blink_led_start(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6164
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6165
    int16_t  i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6166
    uint32_t ledctl_blink = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6167
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6168
    DEBUGFUNC("e1000_id_led_blink_on");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6169
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6170
    if (hw->mac_type < e1000_82571) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6171
        /* Nothing to do */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6172
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6173
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6174
    if (hw->media_type == e1000_media_type_fiber) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6175
        /* always blink LED0 for PCI-E fiber */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6176
        ledctl_blink = E1000_LEDCTL_LED0_BLINK |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6177
                     (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6178
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6179
        /* set the blink bit for each LED that's "on" (0x0E) in ledctl_mode2 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6180
        ledctl_blink = hw->ledctl_mode2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6181
        for (i=0; i < 4; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6182
            if (((hw->ledctl_mode2 >> (i * 8)) & 0xFF) ==
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6183
                E1000_LEDCTL_MODE_LED_ON)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6184
                ledctl_blink |= (E1000_LEDCTL_LED0_BLINK << (i * 8));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6185
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6186
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6187
    E1000_WRITE_REG(hw, LEDCTL, ledctl_blink);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6188
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6189
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6190
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6191
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6192
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6193
 * Restores the saved state of the SW controlable LED.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6194
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6195
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6196
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6197
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6198
e1000_cleanup_led(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6199
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6200
    int32_t ret_val = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6201
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6202
    DEBUGFUNC("e1000_cleanup_led");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6203
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6204
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6205
    case e1000_82542_rev2_0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6206
    case e1000_82542_rev2_1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6207
    case e1000_82543:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6208
    case e1000_82544:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6209
        /* No cleanup necessary */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6210
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6211
    case e1000_82541:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6212
    case e1000_82547:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6213
    case e1000_82541_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6214
    case e1000_82547_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6215
        /* Turn on PHY Smart Power Down (if previously enabled) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6216
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6217
                                      hw->phy_spd_default);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6218
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6219
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6220
        /* Fall Through */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6221
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6222
        if (hw->phy_type == e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6223
            e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6224
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6225
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6226
        /* Restore LEDCTL settings */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6227
        E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_default);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6228
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6229
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6230
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6231
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6232
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6233
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6234
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6235
 * Turns on the software controllable LED
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6236
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6237
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6238
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6239
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6240
e1000_led_on(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6241
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6242
    uint32_t ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6243
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6244
    DEBUGFUNC("e1000_led_on");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6245
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6246
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6247
    case e1000_82542_rev2_0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6248
    case e1000_82542_rev2_1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6249
    case e1000_82543:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6250
        /* Set SW Defineable Pin 0 to turn on the LED */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6251
        ctrl |= E1000_CTRL_SWDPIN0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6252
        ctrl |= E1000_CTRL_SWDPIO0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6253
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6254
    case e1000_82544:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6255
        if (hw->media_type == e1000_media_type_fiber) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6256
            /* Set SW Defineable Pin 0 to turn on the LED */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6257
            ctrl |= E1000_CTRL_SWDPIN0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6258
            ctrl |= E1000_CTRL_SWDPIO0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6259
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6260
            /* Clear SW Defineable Pin 0 to turn on the LED */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6261
            ctrl &= ~E1000_CTRL_SWDPIN0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6262
            ctrl |= E1000_CTRL_SWDPIO0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6263
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6264
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6265
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6266
        if (hw->media_type == e1000_media_type_fiber) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6267
            /* Clear SW Defineable Pin 0 to turn on the LED */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6268
            ctrl &= ~E1000_CTRL_SWDPIN0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6269
            ctrl |= E1000_CTRL_SWDPIO0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6270
        } else if (hw->phy_type == e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6271
            e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6272
                 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6273
        } else if (hw->media_type == e1000_media_type_copper) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6274
            E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6275
            return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6276
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6277
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6278
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6279
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6280
    E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6281
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6282
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6283
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6284
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6285
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6286
 * Turns off the software controllable LED
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6287
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6288
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6289
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6290
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6291
e1000_led_off(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6292
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6293
    uint32_t ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6294
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6295
    DEBUGFUNC("e1000_led_off");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6296
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6297
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6298
    case e1000_82542_rev2_0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6299
    case e1000_82542_rev2_1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6300
    case e1000_82543:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6301
        /* Clear SW Defineable Pin 0 to turn off the LED */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6302
        ctrl &= ~E1000_CTRL_SWDPIN0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6303
        ctrl |= E1000_CTRL_SWDPIO0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6304
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6305
    case e1000_82544:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6306
        if (hw->media_type == e1000_media_type_fiber) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6307
            /* Clear SW Defineable Pin 0 to turn off the LED */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6308
            ctrl &= ~E1000_CTRL_SWDPIN0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6309
            ctrl |= E1000_CTRL_SWDPIO0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6310
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6311
            /* Set SW Defineable Pin 0 to turn off the LED */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6312
            ctrl |= E1000_CTRL_SWDPIN0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6313
            ctrl |= E1000_CTRL_SWDPIO0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6314
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6315
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6316
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6317
        if (hw->media_type == e1000_media_type_fiber) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6318
            /* Set SW Defineable Pin 0 to turn off the LED */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6319
            ctrl |= E1000_CTRL_SWDPIN0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6320
            ctrl |= E1000_CTRL_SWDPIO0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6321
        } else if (hw->phy_type == e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6322
            e1000_write_phy_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6323
                 (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6324
        } else if (hw->media_type == e1000_media_type_copper) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6325
            E1000_WRITE_REG(hw, LEDCTL, hw->ledctl_mode1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6326
            return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6327
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6328
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6329
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6330
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6331
    E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6332
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6333
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6334
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6335
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6336
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6337
 * Clears all hardware statistics counters.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6338
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6339
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6340
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6341
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6342
e1000_clear_hw_cntrs(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6343
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6344
    volatile uint32_t temp;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6345
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6346
    temp = E1000_READ_REG(hw, CRCERRS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6347
    temp = E1000_READ_REG(hw, SYMERRS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6348
    temp = E1000_READ_REG(hw, MPC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6349
    temp = E1000_READ_REG(hw, SCC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6350
    temp = E1000_READ_REG(hw, ECOL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6351
    temp = E1000_READ_REG(hw, MCC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6352
    temp = E1000_READ_REG(hw, LATECOL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6353
    temp = E1000_READ_REG(hw, COLC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6354
    temp = E1000_READ_REG(hw, DC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6355
    temp = E1000_READ_REG(hw, SEC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6356
    temp = E1000_READ_REG(hw, RLEC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6357
    temp = E1000_READ_REG(hw, XONRXC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6358
    temp = E1000_READ_REG(hw, XONTXC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6359
    temp = E1000_READ_REG(hw, XOFFRXC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6360
    temp = E1000_READ_REG(hw, XOFFTXC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6361
    temp = E1000_READ_REG(hw, FCRUC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6362
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6363
    if (hw->mac_type != e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6364
    temp = E1000_READ_REG(hw, PRC64);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6365
    temp = E1000_READ_REG(hw, PRC127);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6366
    temp = E1000_READ_REG(hw, PRC255);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6367
    temp = E1000_READ_REG(hw, PRC511);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6368
    temp = E1000_READ_REG(hw, PRC1023);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6369
    temp = E1000_READ_REG(hw, PRC1522);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6370
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6371
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6372
    temp = E1000_READ_REG(hw, GPRC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6373
    temp = E1000_READ_REG(hw, BPRC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6374
    temp = E1000_READ_REG(hw, MPRC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6375
    temp = E1000_READ_REG(hw, GPTC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6376
    temp = E1000_READ_REG(hw, GORCL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6377
    temp = E1000_READ_REG(hw, GORCH);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6378
    temp = E1000_READ_REG(hw, GOTCL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6379
    temp = E1000_READ_REG(hw, GOTCH);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6380
    temp = E1000_READ_REG(hw, RNBC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6381
    temp = E1000_READ_REG(hw, RUC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6382
    temp = E1000_READ_REG(hw, RFC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6383
    temp = E1000_READ_REG(hw, ROC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6384
    temp = E1000_READ_REG(hw, RJC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6385
    temp = E1000_READ_REG(hw, TORL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6386
    temp = E1000_READ_REG(hw, TORH);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6387
    temp = E1000_READ_REG(hw, TOTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6388
    temp = E1000_READ_REG(hw, TOTH);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6389
    temp = E1000_READ_REG(hw, TPR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6390
    temp = E1000_READ_REG(hw, TPT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6391
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6392
    if (hw->mac_type != e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6393
    temp = E1000_READ_REG(hw, PTC64);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6394
    temp = E1000_READ_REG(hw, PTC127);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6395
    temp = E1000_READ_REG(hw, PTC255);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6396
    temp = E1000_READ_REG(hw, PTC511);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6397
    temp = E1000_READ_REG(hw, PTC1023);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6398
    temp = E1000_READ_REG(hw, PTC1522);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6399
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6400
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6401
    temp = E1000_READ_REG(hw, MPTC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6402
    temp = E1000_READ_REG(hw, BPTC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6403
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6404
    if (hw->mac_type < e1000_82543) return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6405
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6406
    temp = E1000_READ_REG(hw, ALGNERRC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6407
    temp = E1000_READ_REG(hw, RXERRC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6408
    temp = E1000_READ_REG(hw, TNCRS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6409
    temp = E1000_READ_REG(hw, CEXTERR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6410
    temp = E1000_READ_REG(hw, TSCTC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6411
    temp = E1000_READ_REG(hw, TSCTFC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6412
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6413
    if (hw->mac_type <= e1000_82544) return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6414
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6415
    temp = E1000_READ_REG(hw, MGTPRC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6416
    temp = E1000_READ_REG(hw, MGTPDC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6417
    temp = E1000_READ_REG(hw, MGTPTC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6418
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6419
    if (hw->mac_type <= e1000_82547_rev_2) return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6420
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6421
    temp = E1000_READ_REG(hw, IAC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6422
    temp = E1000_READ_REG(hw, ICRXOC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6423
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6424
    if (hw->mac_type == e1000_ich8lan) return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6425
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6426
    temp = E1000_READ_REG(hw, ICRXPTC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6427
    temp = E1000_READ_REG(hw, ICRXATC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6428
    temp = E1000_READ_REG(hw, ICTXPTC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6429
    temp = E1000_READ_REG(hw, ICTXATC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6430
    temp = E1000_READ_REG(hw, ICTXQEC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6431
    temp = E1000_READ_REG(hw, ICTXQMTC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6432
    temp = E1000_READ_REG(hw, ICRXDMTC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6433
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6434
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6435
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6436
 * Resets Adaptive IFS to its default state.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6437
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6438
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6439
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6440
 * Call this after e1000_init_hw. You may override the IFS defaults by setting
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6441
 * hw->ifs_params_forced to TRUE. However, you must initialize hw->
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6442
 * current_ifs_val, ifs_min_val, ifs_max_val, ifs_step_size, and ifs_ratio
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6443
 * before calling this function.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6444
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6445
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6446
e1000_reset_adaptive(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6447
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6448
    DEBUGFUNC("e1000_reset_adaptive");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6449
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6450
    if (hw->adaptive_ifs) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6451
        if (!hw->ifs_params_forced) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6452
            hw->current_ifs_val = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6453
            hw->ifs_min_val = IFS_MIN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6454
            hw->ifs_max_val = IFS_MAX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6455
            hw->ifs_step_size = IFS_STEP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6456
            hw->ifs_ratio = IFS_RATIO;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6457
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6458
        hw->in_ifs_mode = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6459
        E1000_WRITE_REG(hw, AIT, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6460
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6461
        DEBUGOUT("Not in Adaptive IFS mode!\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6462
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6463
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6464
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6465
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6466
 * Called during the callback/watchdog routine to update IFS value based on
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6467
 * the ratio of transmits to collisions.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6468
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6469
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6470
 * tx_packets - Number of transmits since last callback
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6471
 * total_collisions - Number of collisions since last callback
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6472
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6473
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6474
e1000_update_adaptive(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6475
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6476
    DEBUGFUNC("e1000_update_adaptive");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6477
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6478
    if (hw->adaptive_ifs) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6479
        if ((hw->collision_delta * hw->ifs_ratio) > hw->tx_packet_delta) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6480
            if (hw->tx_packet_delta > MIN_NUM_XMITS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6481
                hw->in_ifs_mode = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6482
                if (hw->current_ifs_val < hw->ifs_max_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6483
                    if (hw->current_ifs_val == 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6484
                        hw->current_ifs_val = hw->ifs_min_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6485
                    else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6486
                        hw->current_ifs_val += hw->ifs_step_size;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6487
                    E1000_WRITE_REG(hw, AIT, hw->current_ifs_val);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6488
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6489
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6490
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6491
            if (hw->in_ifs_mode && (hw->tx_packet_delta <= MIN_NUM_XMITS)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6492
                hw->current_ifs_val = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6493
                hw->in_ifs_mode = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6494
                E1000_WRITE_REG(hw, AIT, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6495
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6496
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6497
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6498
        DEBUGOUT("Not in Adaptive IFS mode!\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6499
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6500
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6501
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6502
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6503
 * Adjusts the statistic counters when a frame is accepted by TBI_ACCEPT
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6504
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6505
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6506
 * frame_len - The length of the frame in question
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6507
 * mac_addr - The Ethernet destination address of the frame in question
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6508
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6509
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6510
e1000_tbi_adjust_stats(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6511
                       struct e1000_hw_stats *stats,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6512
                       uint32_t frame_len,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6513
                       uint8_t *mac_addr)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6514
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6515
    uint64_t carry_bit;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6516
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6517
    /* First adjust the frame length. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6518
    frame_len--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6519
    /* We need to adjust the statistics counters, since the hardware
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6520
     * counters overcount this packet as a CRC error and undercount
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6521
     * the packet as a good packet
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6522
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6523
    /* This packet should not be counted as a CRC error.    */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6524
    stats->crcerrs--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6525
    /* This packet does count as a Good Packet Received.    */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6526
    stats->gprc++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6527
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6528
    /* Adjust the Good Octets received counters             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6529
    carry_bit = 0x80000000 & stats->gorcl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6530
    stats->gorcl += frame_len;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6531
    /* If the high bit of Gorcl (the low 32 bits of the Good Octets
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6532
     * Received Count) was one before the addition,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6533
     * AND it is zero after, then we lost the carry out,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6534
     * need to add one to Gorch (Good Octets Received Count High).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6535
     * This could be simplified if all environments supported
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6536
     * 64-bit integers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6537
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6538
    if (carry_bit && ((stats->gorcl & 0x80000000) == 0))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6539
        stats->gorch++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6540
    /* Is this a broadcast or multicast?  Check broadcast first,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6541
     * since the test for a multicast frame will test positive on
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6542
     * a broadcast frame.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6543
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6544
    if ((mac_addr[0] == (uint8_t) 0xff) && (mac_addr[1] == (uint8_t) 0xff))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6545
        /* Broadcast packet */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6546
        stats->bprc++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6547
    else if (*mac_addr & 0x01)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6548
        /* Multicast packet */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6549
        stats->mprc++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6550
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6551
    if (frame_len == hw->max_frame_size) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6552
        /* In this case, the hardware has overcounted the number of
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6553
         * oversize frames.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6554
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6555
        if (stats->roc > 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6556
            stats->roc--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6557
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6558
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6559
    /* Adjust the bin counters when the extra byte put the frame in the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6560
     * wrong bin. Remember that the frame_len was adjusted above.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6561
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6562
    if (frame_len == 64) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6563
        stats->prc64++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6564
        stats->prc127--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6565
    } else if (frame_len == 127) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6566
        stats->prc127++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6567
        stats->prc255--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6568
    } else if (frame_len == 255) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6569
        stats->prc255++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6570
        stats->prc511--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6571
    } else if (frame_len == 511) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6572
        stats->prc511++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6573
        stats->prc1023--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6574
    } else if (frame_len == 1023) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6575
        stats->prc1023++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6576
        stats->prc1522--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6577
    } else if (frame_len == 1522) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6578
        stats->prc1522++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6579
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6580
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6581
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6582
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6583
 * Gets the current PCI bus type, speed, and width of the hardware
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6584
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6585
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6586
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6587
void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6588
e1000_get_bus_info(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6589
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6590
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6591
    uint16_t pci_ex_link_status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6592
    uint32_t status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6593
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6594
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6595
    case e1000_82542_rev2_0:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6596
    case e1000_82542_rev2_1:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6597
        hw->bus_type = e1000_bus_type_pci;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6598
        hw->bus_speed = e1000_bus_speed_unknown;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6599
        hw->bus_width = e1000_bus_width_unknown;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6600
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6601
    case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6602
    case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6603
    case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6604
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6605
        hw->bus_type = e1000_bus_type_pci_express;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6606
        hw->bus_speed = e1000_bus_speed_2500;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6607
        ret_val = e1000_read_pcie_cap_reg(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6608
                                      PCI_EX_LINK_STATUS,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6609
                                      &pci_ex_link_status);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6610
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6611
            hw->bus_width = e1000_bus_width_unknown;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6612
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6613
            hw->bus_width = (pci_ex_link_status & PCI_EX_LINK_WIDTH_MASK) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6614
                          PCI_EX_LINK_WIDTH_SHIFT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6615
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6616
    case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6617
        hw->bus_type = e1000_bus_type_pci_express;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6618
        hw->bus_speed = e1000_bus_speed_2500;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6619
        hw->bus_width = e1000_bus_width_pciex_1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6620
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6621
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6622
        status = E1000_READ_REG(hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6623
        hw->bus_type = (status & E1000_STATUS_PCIX_MODE) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6624
                       e1000_bus_type_pcix : e1000_bus_type_pci;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6625
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6626
        if (hw->device_id == E1000_DEV_ID_82546EB_QUAD_COPPER) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6627
            hw->bus_speed = (hw->bus_type == e1000_bus_type_pci) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6628
                            e1000_bus_speed_66 : e1000_bus_speed_120;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6629
        } else if (hw->bus_type == e1000_bus_type_pci) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6630
            hw->bus_speed = (status & E1000_STATUS_PCI66) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6631
                            e1000_bus_speed_66 : e1000_bus_speed_33;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6632
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6633
            switch (status & E1000_STATUS_PCIX_SPEED) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6634
            case E1000_STATUS_PCIX_SPEED_66:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6635
                hw->bus_speed = e1000_bus_speed_66;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6636
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6637
            case E1000_STATUS_PCIX_SPEED_100:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6638
                hw->bus_speed = e1000_bus_speed_100;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6639
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6640
            case E1000_STATUS_PCIX_SPEED_133:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6641
                hw->bus_speed = e1000_bus_speed_133;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6642
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6643
            default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6644
                hw->bus_speed = e1000_bus_speed_reserved;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6645
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6646
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6647
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6648
        hw->bus_width = (status & E1000_STATUS_BUS64) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6649
                        e1000_bus_width_64 : e1000_bus_width_32;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6650
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6651
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6652
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6653
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6654
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6655
 * Writes a value to one of the devices registers using port I/O (as opposed to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6656
 * memory mapped I/O). Only 82544 and newer devices support port I/O.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6657
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6658
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6659
 * offset - offset to write to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6660
 * value - value to write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6661
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6662
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6663
e1000_write_reg_io(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6664
                   uint32_t offset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6665
                   uint32_t value)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6666
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6667
    unsigned long io_addr = hw->io_base;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6668
    unsigned long io_data = hw->io_base + 4;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6669
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6670
    e1000_io_write(hw, io_addr, offset);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6671
    e1000_io_write(hw, io_data, value);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6672
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6673
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6674
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6675
 * Estimates the cable length.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6676
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6677
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6678
 * min_length - The estimated minimum length
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6679
 * max_length - The estimated maximum length
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6680
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6681
 * returns: - E1000_ERR_XXX
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6682
 *            E1000_SUCCESS
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6683
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6684
 * This function always returns a ranged length (minimum & maximum).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6685
 * So for M88 phy's, this function interprets the one value returned from the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6686
 * register to the minimum and maximum range.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6687
 * For IGP phy's, the function calculates the range by the AGC registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6688
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6689
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6690
e1000_get_cable_length(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6691
                       uint16_t *min_length,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6692
                       uint16_t *max_length)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6693
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6694
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6695
    uint16_t agc_value = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6696
    uint16_t i, phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6697
    uint16_t cable_length;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6698
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6699
    DEBUGFUNC("e1000_get_cable_length");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6700
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6701
    *min_length = *max_length = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6702
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6703
    /* Use old method for Phy older than IGP */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6704
    if (hw->phy_type == e1000_phy_m88) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6705
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6706
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6707
                                     &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6708
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6709
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6710
        cable_length = (phy_data & M88E1000_PSSR_CABLE_LENGTH) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6711
                       M88E1000_PSSR_CABLE_LENGTH_SHIFT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6712
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6713
        /* Convert the enum value to ranged values */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6714
        switch (cable_length) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6715
        case e1000_cable_length_50:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6716
            *min_length = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6717
            *max_length = e1000_igp_cable_length_50;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6718
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6719
        case e1000_cable_length_50_80:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6720
            *min_length = e1000_igp_cable_length_50;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6721
            *max_length = e1000_igp_cable_length_80;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6722
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6723
        case e1000_cable_length_80_110:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6724
            *min_length = e1000_igp_cable_length_80;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6725
            *max_length = e1000_igp_cable_length_110;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6726
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6727
        case e1000_cable_length_110_140:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6728
            *min_length = e1000_igp_cable_length_110;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6729
            *max_length = e1000_igp_cable_length_140;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6730
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6731
        case e1000_cable_length_140:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6732
            *min_length = e1000_igp_cable_length_140;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6733
            *max_length = e1000_igp_cable_length_170;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6734
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6735
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6736
            return -E1000_ERR_PHY;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6737
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6738
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6739
    } else if (hw->phy_type == e1000_phy_gg82563) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6740
        ret_val = e1000_read_phy_reg(hw, GG82563_PHY_DSP_DISTANCE,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6741
                                     &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6742
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6743
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6744
        cable_length = phy_data & GG82563_DSPD_CABLE_LENGTH;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6745
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6746
        switch (cable_length) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6747
        case e1000_gg_cable_length_60:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6748
            *min_length = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6749
            *max_length = e1000_igp_cable_length_60;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6750
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6751
        case e1000_gg_cable_length_60_115:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6752
            *min_length = e1000_igp_cable_length_60;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6753
            *max_length = e1000_igp_cable_length_115;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6754
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6755
        case e1000_gg_cable_length_115_150:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6756
            *min_length = e1000_igp_cable_length_115;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6757
            *max_length = e1000_igp_cable_length_150;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6758
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6759
        case e1000_gg_cable_length_150:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6760
            *min_length = e1000_igp_cable_length_150;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6761
            *max_length = e1000_igp_cable_length_180;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6762
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6763
        default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6764
            return -E1000_ERR_PHY;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6765
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6766
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6767
    } else if (hw->phy_type == e1000_phy_igp) { /* For IGP PHY */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6768
        uint16_t cur_agc_value;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6769
        uint16_t min_agc_value = IGP01E1000_AGC_LENGTH_TABLE_SIZE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6770
        uint16_t agc_reg_array[IGP01E1000_PHY_CHANNEL_NUM] =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6771
                                                         {IGP01E1000_PHY_AGC_A,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6772
                                                          IGP01E1000_PHY_AGC_B,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6773
                                                          IGP01E1000_PHY_AGC_C,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6774
                                                          IGP01E1000_PHY_AGC_D};
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6775
        /* Read the AGC registers for all channels */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6776
        for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6777
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6778
            ret_val = e1000_read_phy_reg(hw, agc_reg_array[i], &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6779
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6780
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6781
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6782
            cur_agc_value = phy_data >> IGP01E1000_AGC_LENGTH_SHIFT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6783
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6784
            /* Value bound check. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6785
            if ((cur_agc_value >= IGP01E1000_AGC_LENGTH_TABLE_SIZE - 1) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6786
                (cur_agc_value == 0))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6787
                return -E1000_ERR_PHY;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6788
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6789
            agc_value += cur_agc_value;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6790
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6791
            /* Update minimal AGC value. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6792
            if (min_agc_value > cur_agc_value)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6793
                min_agc_value = cur_agc_value;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6794
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6795
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6796
        /* Remove the minimal AGC result for length < 50m */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6797
        if (agc_value < IGP01E1000_PHY_CHANNEL_NUM * e1000_igp_cable_length_50) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6798
            agc_value -= min_agc_value;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6799
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6800
            /* Get the average length of the remaining 3 channels */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6801
            agc_value /= (IGP01E1000_PHY_CHANNEL_NUM - 1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6802
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6803
            /* Get the average length of all the 4 channels. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6804
            agc_value /= IGP01E1000_PHY_CHANNEL_NUM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6805
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6806
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6807
        /* Set the range of the calculated length. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6808
        *min_length = ((e1000_igp_cable_length_table[agc_value] -
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6809
                       IGP01E1000_AGC_RANGE) > 0) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6810
                       (e1000_igp_cable_length_table[agc_value] -
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6811
                       IGP01E1000_AGC_RANGE) : 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6812
        *max_length = e1000_igp_cable_length_table[agc_value] +
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6813
                      IGP01E1000_AGC_RANGE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6814
    } else if (hw->phy_type == e1000_phy_igp_2 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6815
               hw->phy_type == e1000_phy_igp_3) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6816
        uint16_t cur_agc_index, max_agc_index = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6817
        uint16_t min_agc_index = IGP02E1000_AGC_LENGTH_TABLE_SIZE - 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6818
        uint16_t agc_reg_array[IGP02E1000_PHY_CHANNEL_NUM] =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6819
                                                         {IGP02E1000_PHY_AGC_A,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6820
                                                          IGP02E1000_PHY_AGC_B,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6821
                                                          IGP02E1000_PHY_AGC_C,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6822
                                                          IGP02E1000_PHY_AGC_D};
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6823
        /* Read the AGC registers for all channels */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6824
        for (i = 0; i < IGP02E1000_PHY_CHANNEL_NUM; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6825
            ret_val = e1000_read_phy_reg(hw, agc_reg_array[i], &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6826
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6827
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6828
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6829
            /* Getting bits 15:9, which represent the combination of course and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6830
             * fine gain values.  The result is a number that can be put into
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6831
             * the lookup table to obtain the approximate cable length. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6832
            cur_agc_index = (phy_data >> IGP02E1000_AGC_LENGTH_SHIFT) &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6833
                            IGP02E1000_AGC_LENGTH_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6834
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6835
            /* Array index bound check. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6836
            if ((cur_agc_index >= IGP02E1000_AGC_LENGTH_TABLE_SIZE) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6837
                (cur_agc_index == 0))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6838
                return -E1000_ERR_PHY;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6839
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6840
            /* Remove min & max AGC values from calculation. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6841
            if (e1000_igp_2_cable_length_table[min_agc_index] >
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6842
                e1000_igp_2_cable_length_table[cur_agc_index])
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6843
                min_agc_index = cur_agc_index;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6844
            if (e1000_igp_2_cable_length_table[max_agc_index] <
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6845
                e1000_igp_2_cable_length_table[cur_agc_index])
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6846
                max_agc_index = cur_agc_index;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6847
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6848
            agc_value += e1000_igp_2_cable_length_table[cur_agc_index];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6849
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6850
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6851
        agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] +
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6852
                      e1000_igp_2_cable_length_table[max_agc_index]);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6853
        agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6854
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6855
        /* Calculate cable length with the error range of +/- 10 meters. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6856
        *min_length = ((agc_value - IGP02E1000_AGC_RANGE) > 0) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6857
                       (agc_value - IGP02E1000_AGC_RANGE) : 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6858
        *max_length = agc_value + IGP02E1000_AGC_RANGE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6859
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6860
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6861
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6862
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6863
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6864
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6865
 * Check the cable polarity
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6866
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6867
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6868
 * polarity - output parameter : 0 - Polarity is not reversed
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6869
 *                               1 - Polarity is reversed.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6870
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6871
 * returns: - E1000_ERR_XXX
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6872
 *            E1000_SUCCESS
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6873
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6874
 * For phy's older then IGP, this function simply reads the polarity bit in the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6875
 * Phy Status register.  For IGP phy's, this bit is valid only if link speed is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6876
 * 10 Mbps.  If the link speed is 100 Mbps there is no polarity so this bit will
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6877
 * return 0.  If the link speed is 1000 Mbps the polarity status is in the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6878
 * IGP01E1000_PHY_PCS_INIT_REG.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6879
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6880
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6881
e1000_check_polarity(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6882
                     e1000_rev_polarity *polarity)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6883
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6884
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6885
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6886
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6887
    DEBUGFUNC("e1000_check_polarity");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6888
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6889
    if ((hw->phy_type == e1000_phy_m88) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6890
        (hw->phy_type == e1000_phy_gg82563)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6891
        /* return the Polarity bit in the Status register. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6892
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6893
                                     &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6894
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6895
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6896
        *polarity = ((phy_data & M88E1000_PSSR_REV_POLARITY) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6897
                     M88E1000_PSSR_REV_POLARITY_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6898
                     e1000_rev_polarity_reversed : e1000_rev_polarity_normal;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6899
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6900
    } else if (hw->phy_type == e1000_phy_igp ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6901
              hw->phy_type == e1000_phy_igp_3 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6902
              hw->phy_type == e1000_phy_igp_2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6903
        /* Read the Status register to check the speed */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6904
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6905
                                     &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6906
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6907
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6908
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6909
        /* If speed is 1000 Mbps, must read the IGP01E1000_PHY_PCS_INIT_REG to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6910
         * find the polarity status */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6911
        if ((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6912
           IGP01E1000_PSSR_SPEED_1000MBPS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6913
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6914
            /* Read the GIG initialization PCS register (0x00B4) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6915
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6916
                                         &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6917
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6918
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6919
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6920
            /* Check the polarity bits */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6921
            *polarity = (phy_data & IGP01E1000_PHY_POLARITY_MASK) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6922
                         e1000_rev_polarity_reversed : e1000_rev_polarity_normal;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6923
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6924
            /* For 10 Mbps, read the polarity bit in the status register. (for
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6925
             * 100 Mbps this bit is always 0) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6926
            *polarity = (phy_data & IGP01E1000_PSSR_POLARITY_REVERSED) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6927
                         e1000_rev_polarity_reversed : e1000_rev_polarity_normal;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6928
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6929
    } else if (hw->phy_type == e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6930
        ret_val = e1000_read_phy_reg(hw, IFE_PHY_EXTENDED_STATUS_CONTROL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6931
                                     &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6932
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6933
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6934
        *polarity = ((phy_data & IFE_PESC_POLARITY_REVERSED) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6935
                     IFE_PESC_POLARITY_REVERSED_SHIFT) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6936
                     e1000_rev_polarity_reversed : e1000_rev_polarity_normal;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6937
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6938
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6939
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6940
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6941
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6942
 * Check if Downshift occured
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6943
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6944
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6945
 * downshift - output parameter : 0 - No Downshift ocured.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6946
 *                                1 - Downshift ocured.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6947
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6948
 * returns: - E1000_ERR_XXX
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6949
 *            E1000_SUCCESS
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6950
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6951
 * For phy's older then IGP, this function reads the Downshift bit in the Phy
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6952
 * Specific Status register.  For IGP phy's, it reads the Downgrade bit in the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6953
 * Link Health register.  In IGP this bit is latched high, so the driver must
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6954
 * read it immediately after link is established.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6955
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6956
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6957
e1000_check_downshift(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6958
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6959
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6960
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6961
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6962
    DEBUGFUNC("e1000_check_downshift");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6963
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6964
    if (hw->phy_type == e1000_phy_igp ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6965
        hw->phy_type == e1000_phy_igp_3 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6966
        hw->phy_type == e1000_phy_igp_2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6967
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_LINK_HEALTH,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6968
                                     &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6969
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6970
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6971
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6972
        hw->speed_downgraded = (phy_data & IGP01E1000_PLHR_SS_DOWNGRADE) ? 1 : 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6973
    } else if ((hw->phy_type == e1000_phy_m88) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6974
               (hw->phy_type == e1000_phy_gg82563)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6975
        ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6976
                                     &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6977
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6978
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6979
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6980
        hw->speed_downgraded = (phy_data & M88E1000_PSSR_DOWNSHIFT) >>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6981
                               M88E1000_PSSR_DOWNSHIFT_SHIFT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6982
    } else if (hw->phy_type == e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6983
        /* e1000_phy_ife supports 10/100 speed only */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6984
        hw->speed_downgraded = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6985
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6986
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6987
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6988
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6989
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6990
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6991
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6992
 * 82541_rev_2 & 82547_rev_2 have the capability to configure the DSP when a
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6993
 * gigabit link is achieved to improve link quality.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6994
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6995
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6996
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6997
 * returns: - E1000_ERR_PHY if fail to read/write the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6998
 *            E1000_SUCCESS at any other case.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  6999
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7000
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7001
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7002
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7003
e1000_config_dsp_after_link_change(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7004
                                   boolean_t link_up)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7005
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7006
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7007
    uint16_t phy_data, phy_saved_data, speed, duplex, i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7008
    uint16_t dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7009
                                        {IGP01E1000_PHY_AGC_PARAM_A,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7010
                                        IGP01E1000_PHY_AGC_PARAM_B,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7011
                                        IGP01E1000_PHY_AGC_PARAM_C,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7012
                                        IGP01E1000_PHY_AGC_PARAM_D};
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7013
    uint16_t min_length, max_length;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7014
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7015
    DEBUGFUNC("e1000_config_dsp_after_link_change");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7016
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7017
    if (hw->phy_type != e1000_phy_igp)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7018
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7019
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7020
    if (link_up) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7021
        ret_val = e1000_get_speed_and_duplex(hw, &speed, &duplex);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7022
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7023
            DEBUGOUT("Error getting link speed and duplex\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7024
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7025
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7026
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7027
        if (speed == SPEED_1000) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7028
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7029
            ret_val = e1000_get_cable_length(hw, &min_length, &max_length);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7030
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7031
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7032
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7033
            if ((hw->dsp_config_state == e1000_dsp_config_enabled) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7034
                min_length >= e1000_igp_cable_length_50) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7035
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7036
                for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7037
                    ret_val = e1000_read_phy_reg(hw, dsp_reg_array[i],
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7038
                                                 &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7039
                    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7040
                        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7041
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7042
                    phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7043
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7044
                    ret_val = e1000_write_phy_reg(hw, dsp_reg_array[i],
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7045
                                                  phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7046
                    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7047
                        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7048
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7049
                hw->dsp_config_state = e1000_dsp_config_activated;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7050
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7051
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7052
            if ((hw->ffe_config_state == e1000_ffe_config_enabled) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7053
               (min_length < e1000_igp_cable_length_50)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7054
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7055
                uint16_t ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7056
                uint32_t idle_errs = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7057
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7058
                /* clear previous idle error counts */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7059
                ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7060
                                             &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7061
                if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7062
                    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7063
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7064
                for (i = 0; i < ffe_idle_err_timeout; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7065
                    udelay(1000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7066
                    ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7067
                                                 &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7068
                    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7069
                        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7070
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7071
                    idle_errs += (phy_data & SR_1000T_IDLE_ERROR_CNT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7072
                    if (idle_errs > SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7073
                        hw->ffe_config_state = e1000_ffe_config_active;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7074
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7075
                        ret_val = e1000_write_phy_reg(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7076
                                    IGP01E1000_PHY_DSP_FFE,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7077
                                    IGP01E1000_PHY_DSP_FFE_CM_CP);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7078
                        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7079
                            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7080
                        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7081
                    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7082
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7083
                    if (idle_errs)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7084
                        ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_100;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7085
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7086
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7087
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7088
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7089
        if (hw->dsp_config_state == e1000_dsp_config_activated) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7090
            /* Save off the current value of register 0x2F5B to be restored at
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7091
             * the end of the routines. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7092
            ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7093
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7094
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7095
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7096
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7097
            /* Disable the PHY transmitter */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7098
            ret_val = e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7099
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7100
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7101
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7102
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7103
            mdelay(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7104
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7105
            ret_val = e1000_write_phy_reg(hw, 0x0000,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7106
                                          IGP01E1000_IEEE_FORCE_GIGA);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7107
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7108
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7109
            for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7110
                ret_val = e1000_read_phy_reg(hw, dsp_reg_array[i], &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7111
                if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7112
                    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7113
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7114
                phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7115
                phy_data |=  IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7116
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7117
                ret_val = e1000_write_phy_reg(hw,dsp_reg_array[i], phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7118
                if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7119
                    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7120
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7121
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7122
            ret_val = e1000_write_phy_reg(hw, 0x0000,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7123
                                          IGP01E1000_IEEE_RESTART_AUTONEG);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7124
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7125
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7126
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7127
            mdelay(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7128
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7129
            /* Now enable the transmitter */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7130
            ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7131
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7132
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7133
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7134
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7135
            hw->dsp_config_state = e1000_dsp_config_enabled;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7136
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7137
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7138
        if (hw->ffe_config_state == e1000_ffe_config_active) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7139
            /* Save off the current value of register 0x2F5B to be restored at
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7140
             * the end of the routines. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7141
            ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7142
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7143
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7144
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7145
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7146
            /* Disable the PHY transmitter */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7147
            ret_val = e1000_write_phy_reg(hw, 0x2F5B, 0x0003);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7148
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7149
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7150
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7151
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7152
            mdelay(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7153
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7154
            ret_val = e1000_write_phy_reg(hw, 0x0000,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7155
                                          IGP01E1000_IEEE_FORCE_GIGA);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7156
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7157
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7158
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_DSP_FFE,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7159
                                          IGP01E1000_PHY_DSP_FFE_DEFAULT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7160
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7161
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7162
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7163
            ret_val = e1000_write_phy_reg(hw, 0x0000,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7164
                                          IGP01E1000_IEEE_RESTART_AUTONEG);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7165
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7166
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7167
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7168
            mdelay(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7169
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7170
            /* Now enable the transmitter */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7171
            ret_val = e1000_write_phy_reg(hw, 0x2F5B, phy_saved_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7172
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7173
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7174
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7175
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7176
            hw->ffe_config_state = e1000_ffe_config_enabled;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7177
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7178
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7179
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7180
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7181
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7182
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7183
 * Set PHY to class A mode
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7184
 * Assumes the following operations will follow to enable the new class mode.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7185
 *  1. Do a PHY soft reset
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7186
 *  2. Restart auto-negotiation or force link.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7187
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7188
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7189
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7190
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7191
e1000_set_phy_mode(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7192
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7193
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7194
    uint16_t eeprom_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7195
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7196
    DEBUGFUNC("e1000_set_phy_mode");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7197
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7198
    if ((hw->mac_type == e1000_82545_rev_3) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7199
        (hw->media_type == e1000_media_type_copper)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7200
        ret_val = e1000_read_eeprom(hw, EEPROM_PHY_CLASS_WORD, 1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7201
        if (ret_val) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7202
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7203
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7204
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7205
        if ((eeprom_data != EEPROM_RESERVED_WORD) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7206
            (eeprom_data & EEPROM_PHY_CLASS_A)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7207
            ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x000B);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7208
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7209
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7210
            ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0x8104);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7211
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7212
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7213
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7214
            hw->phy_reset_disable = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7215
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7216
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7217
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7218
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7219
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7220
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7221
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7222
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7223
 * This function sets the lplu state according to the active flag.  When
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7224
 * activating lplu this function also disables smart speed and vise versa.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7225
 * lplu will not be activated unless the device autonegotiation advertisment
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7226
 * meets standards of either 10 or 10/100 or 10/100/1000 at all duplexes.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7227
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7228
 * active - true to enable lplu false to disable lplu.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7229
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7230
 * returns: - E1000_ERR_PHY if fail to read/write the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7231
 *            E1000_SUCCESS at any other case.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7232
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7233
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7234
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7235
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7236
e1000_set_d3_lplu_state(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7237
                        boolean_t active)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7238
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7239
    uint32_t phy_ctrl = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7240
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7241
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7242
    DEBUGFUNC("e1000_set_d3_lplu_state");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7243
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7244
    if (hw->phy_type != e1000_phy_igp && hw->phy_type != e1000_phy_igp_2
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7245
        && hw->phy_type != e1000_phy_igp_3)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7246
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7247
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7248
    /* During driver activity LPLU should not be used or it will attain link
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7249
     * from the lowest speeds starting from 10Mbps. The capability is used for
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7250
     * Dx transitions and states */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7251
    if (hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7252
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_GMII_FIFO, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7253
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7254
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7255
    } else if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7256
        /* MAC writes into PHY register based on the state transition
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7257
         * and start auto-negotiation. SW driver can overwrite the settings
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7258
         * in CSR PHY power control E1000_PHY_CTRL register. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7259
        phy_ctrl = E1000_READ_REG(hw, PHY_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7260
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7261
        ret_val = e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7262
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7263
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7264
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7265
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7266
    if (!active) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7267
        if (hw->mac_type == e1000_82541_rev_2 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7268
            hw->mac_type == e1000_82547_rev_2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7269
            phy_data &= ~IGP01E1000_GMII_FLEX_SPD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7270
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7271
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7272
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7273
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7274
            if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7275
                phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7276
                E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7277
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7278
                phy_data &= ~IGP02E1000_PM_D3_LPLU;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7279
                ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7280
                                              phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7281
                if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7282
                    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7283
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7284
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7285
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7286
        /* LPLU and SmartSpeed are mutually exclusive.  LPLU is used during
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7287
         * Dx states where the power conservation is most important.  During
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7288
         * driver activity we should enable SmartSpeed, so performance is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7289
         * maintained. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7290
        if (hw->smart_speed == e1000_smart_speed_on) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7291
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7292
                                         &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7293
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7294
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7295
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7296
            phy_data |= IGP01E1000_PSCFR_SMART_SPEED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7297
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7298
                                          phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7299
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7300
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7301
        } else if (hw->smart_speed == e1000_smart_speed_off) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7302
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7303
                                         &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7304
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7305
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7306
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7307
            phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7308
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7309
                                          phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7310
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7311
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7312
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7313
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7314
    } else if ((hw->autoneg_advertised == AUTONEG_ADVERTISE_SPEED_DEFAULT) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7315
               (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_ALL ) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7316
               (hw->autoneg_advertised == AUTONEG_ADVERTISE_10_100_ALL)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7317
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7318
        if (hw->mac_type == e1000_82541_rev_2 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7319
            hw->mac_type == e1000_82547_rev_2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7320
            phy_data |= IGP01E1000_GMII_FLEX_SPD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7321
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_GMII_FIFO, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7322
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7323
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7324
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7325
            if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7326
                phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7327
                E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7328
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7329
                phy_data |= IGP02E1000_PM_D3_LPLU;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7330
                ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7331
                                              phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7332
                if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7333
                    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7334
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7335
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7336
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7337
        /* When LPLU is enabled we should disable SmartSpeed */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7338
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7339
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7340
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7341
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7342
        phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7343
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7344
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7345
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7346
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7347
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7348
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7349
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7350
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7351
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7352
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7353
 * This function sets the lplu d0 state according to the active flag.  When
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7354
 * activating lplu this function also disables smart speed and vise versa.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7355
 * lplu will not be activated unless the device autonegotiation advertisment
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7356
 * meets standards of either 10 or 10/100 or 10/100/1000 at all duplexes.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7357
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7358
 * active - true to enable lplu false to disable lplu.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7359
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7360
 * returns: - E1000_ERR_PHY if fail to read/write the PHY
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7361
 *            E1000_SUCCESS at any other case.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7362
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7363
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7364
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7365
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7366
e1000_set_d0_lplu_state(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7367
                        boolean_t active)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7368
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7369
    uint32_t phy_ctrl = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7370
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7371
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7372
    DEBUGFUNC("e1000_set_d0_lplu_state");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7373
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7374
    if (hw->mac_type <= e1000_82547_rev_2)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7375
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7376
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7377
    if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7378
        phy_ctrl = E1000_READ_REG(hw, PHY_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7379
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7380
        ret_val = e1000_read_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7381
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7382
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7383
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7384
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7385
    if (!active) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7386
        if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7387
            phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7388
            E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7389
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7390
            phy_data &= ~IGP02E1000_PM_D0_LPLU;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7391
            ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7392
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7393
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7394
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7395
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7396
        /* LPLU and SmartSpeed are mutually exclusive.  LPLU is used during
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7397
         * Dx states where the power conservation is most important.  During
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7398
         * driver activity we should enable SmartSpeed, so performance is
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7399
         * maintained. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7400
        if (hw->smart_speed == e1000_smart_speed_on) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7401
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7402
                                         &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7403
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7404
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7405
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7406
            phy_data |= IGP01E1000_PSCFR_SMART_SPEED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7407
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7408
                                          phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7409
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7410
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7411
        } else if (hw->smart_speed == e1000_smart_speed_off) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7412
            ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7413
                                         &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7414
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7415
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7416
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7417
            phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7418
            ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7419
                                          phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7420
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7421
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7422
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7423
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7424
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7425
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7426
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7427
        if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7428
            phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7429
            E1000_WRITE_REG(hw, PHY_CTRL, phy_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7430
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7431
            phy_data |= IGP02E1000_PM_D0_LPLU;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7432
            ret_val = e1000_write_phy_reg(hw, IGP02E1000_PHY_POWER_MGMT, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7433
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7434
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7435
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7436
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7437
        /* When LPLU is enabled we should disable SmartSpeed */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7438
        ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7439
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7440
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7441
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7442
        phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7443
        ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7444
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7445
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7446
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7447
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7448
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7449
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7450
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7451
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7452
 * Change VCO speed register to improve Bit Error Rate performance of SERDES.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7453
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7454
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7455
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7456
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7457
e1000_set_vco_speed(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7458
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7459
    int32_t  ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7460
    uint16_t default_page = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7461
    uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7462
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7463
    DEBUGFUNC("e1000_set_vco_speed");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7464
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7465
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7466
    case e1000_82545_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7467
    case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7468
       break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7469
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7470
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7471
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7472
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7473
    /* Set PHY register 30, page 5, bit 8 to 0 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7474
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7475
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, &default_page);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7476
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7477
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7478
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7479
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0005);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7480
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7481
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7482
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7483
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7484
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7485
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7486
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7487
    phy_data &= ~M88E1000_PHY_VCO_REG_BIT8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7488
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7489
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7490
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7491
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7492
    /* Set PHY register 30, page 4, bit 11 to 1 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7493
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7494
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0004);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7495
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7496
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7497
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7498
    ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7499
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7500
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7501
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7502
    phy_data |= M88E1000_PHY_VCO_REG_BIT11;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7503
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7504
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7505
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7506
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7507
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, default_page);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7508
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7509
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7510
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7511
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7512
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7513
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7514
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7515
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7516
 * This function reads the cookie from ARC ram.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7517
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7518
 * returns: - E1000_SUCCESS .
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7519
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7520
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7521
e1000_host_if_read_cookie(struct e1000_hw * hw, uint8_t *buffer)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7522
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7523
    uint8_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7524
    uint32_t offset = E1000_MNG_DHCP_COOKIE_OFFSET;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7525
    uint8_t length = E1000_MNG_DHCP_COOKIE_LENGTH;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7526
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7527
    length = (length >> 2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7528
    offset = (offset >> 2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7529
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7530
    for (i = 0; i < length; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7531
        *((uint32_t *) buffer + i) =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7532
            E1000_READ_REG_ARRAY_DWORD(hw, HOST_IF, offset + i);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7533
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7534
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7535
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7536
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7537
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7538
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7539
 * This function checks whether the HOST IF is enabled for command operaton
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7540
 * and also checks whether the previous command is completed.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7541
 * It busy waits in case of previous command is not completed.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7542
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7543
 * returns: - E1000_ERR_HOST_INTERFACE_COMMAND in case if is not ready or
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7544
 *            timeout
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7545
 *          - E1000_SUCCESS for success.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7546
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7547
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7548
e1000_mng_enable_host_if(struct e1000_hw * hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7549
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7550
    uint32_t hicr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7551
    uint8_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7552
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7553
    /* Check that the host interface is enabled. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7554
    hicr = E1000_READ_REG(hw, HICR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7555
    if ((hicr & E1000_HICR_EN) == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7556
        DEBUGOUT("E1000_HOST_EN bit disabled.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7557
        return -E1000_ERR_HOST_INTERFACE_COMMAND;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7558
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7559
    /* check the previous command is completed */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7560
    for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7561
        hicr = E1000_READ_REG(hw, HICR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7562
        if (!(hicr & E1000_HICR_C))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7563
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7564
        mdelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7565
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7566
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7567
    if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7568
        DEBUGOUT("Previous command timeout failed .\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7569
        return -E1000_ERR_HOST_INTERFACE_COMMAND;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7570
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7571
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7572
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7573
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7574
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7575
 * This function writes the buffer content at the offset given on the host if.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7576
 * It also does alignment considerations to do the writes in most efficient way.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7577
 * Also fills up the sum of the buffer in *buffer parameter.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7578
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7579
 * returns  - E1000_SUCCESS for success.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7580
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7581
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7582
e1000_mng_host_if_write(struct e1000_hw * hw, uint8_t *buffer,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7583
                        uint16_t length, uint16_t offset, uint8_t *sum)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7584
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7585
    uint8_t *tmp;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7586
    uint8_t *bufptr = buffer;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7587
    uint32_t data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7588
    uint16_t remaining, i, j, prev_bytes;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7589
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7590
    /* sum = only sum of the data and it is not checksum */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7591
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7592
    if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7593
        return -E1000_ERR_PARAM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7594
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7595
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7596
    tmp = (uint8_t *)&data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7597
    prev_bytes = offset & 0x3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7598
    offset &= 0xFFFC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7599
    offset >>= 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7600
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7601
    if (prev_bytes) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7602
        data = E1000_READ_REG_ARRAY_DWORD(hw, HOST_IF, offset);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7603
        for (j = prev_bytes; j < sizeof(uint32_t); j++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7604
            *(tmp + j) = *bufptr++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7605
            *sum += *(tmp + j);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7606
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7607
        E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, offset, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7608
        length -= j - prev_bytes;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7609
        offset++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7610
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7611
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7612
    remaining = length & 0x3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7613
    length -= remaining;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7614
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7615
    /* Calculate length in DWORDs */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7616
    length >>= 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7617
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7618
    /* The device driver writes the relevant command block into the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7619
     * ram area. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7620
    for (i = 0; i < length; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7621
        for (j = 0; j < sizeof(uint32_t); j++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7622
            *(tmp + j) = *bufptr++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7623
            *sum += *(tmp + j);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7624
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7625
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7626
        E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, offset + i, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7627
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7628
    if (remaining) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7629
        for (j = 0; j < sizeof(uint32_t); j++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7630
            if (j < remaining)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7631
                *(tmp + j) = *bufptr++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7632
            else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7633
                *(tmp + j) = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7634
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7635
            *sum += *(tmp + j);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7636
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7637
        E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, offset + i, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7638
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7639
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7640
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7641
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7642
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7643
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7644
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7645
 * This function writes the command header after does the checksum calculation.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7646
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7647
 * returns  - E1000_SUCCESS for success.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7648
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7649
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7650
e1000_mng_write_cmd_header(struct e1000_hw * hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7651
                           struct e1000_host_mng_command_header * hdr)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7652
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7653
    uint16_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7654
    uint8_t sum;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7655
    uint8_t *buffer;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7656
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7657
    /* Write the whole command header structure which includes sum of
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7658
     * the buffer */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7659
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7660
    uint16_t length = sizeof(struct e1000_host_mng_command_header);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7661
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7662
    sum = hdr->checksum;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7663
    hdr->checksum = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7664
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7665
    buffer = (uint8_t *) hdr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7666
    i = length;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7667
    while (i--)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7668
        sum += buffer[i];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7669
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7670
    hdr->checksum = 0 - sum;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7671
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7672
    length >>= 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7673
    /* The device driver writes the relevant command block into the ram area. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7674
    for (i = 0; i < length; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7675
        E1000_WRITE_REG_ARRAY_DWORD(hw, HOST_IF, i, *((uint32_t *) hdr + i));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7676
        E1000_WRITE_FLUSH(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7677
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7678
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7679
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7680
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7681
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7682
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7683
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7684
 * This function indicates to ARC that a new command is pending which completes
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7685
 * one write operation by the driver.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7686
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7687
 * returns  - E1000_SUCCESS for success.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7688
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7689
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7690
e1000_mng_write_commit(struct e1000_hw * hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7691
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7692
    uint32_t hicr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7693
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7694
    hicr = E1000_READ_REG(hw, HICR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7695
    /* Setting this bit tells the ARC that a new command is pending. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7696
    E1000_WRITE_REG(hw, HICR, hicr | E1000_HICR_C);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7697
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7698
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7699
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7700
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7701
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7702
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7703
 * This function checks the mode of the firmware.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7704
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7705
 * returns  - TRUE when the mode is IAMT or FALSE.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7706
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7707
boolean_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7708
e1000_check_mng_mode(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7709
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7710
    uint32_t fwsm;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7711
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7712
    fwsm = E1000_READ_REG(hw, FWSM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7713
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7714
    if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7715
        if ((fwsm & E1000_FWSM_MODE_MASK) ==
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7716
            (E1000_MNG_ICH_IAMT_MODE << E1000_FWSM_MODE_SHIFT))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7717
            return TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7718
    } else if ((fwsm & E1000_FWSM_MODE_MASK) ==
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7719
               (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7720
        return TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7721
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7722
    return FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7723
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7724
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7725
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7726
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7727
 * This function writes the dhcp info .
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7728
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7729
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7730
e1000_mng_write_dhcp_info(struct e1000_hw * hw, uint8_t *buffer,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7731
                          uint16_t length)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7732
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7733
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7734
    struct e1000_host_mng_command_header hdr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7735
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7736
    hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7737
    hdr.command_length = length;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7738
    hdr.reserved1 = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7739
    hdr.reserved2 = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7740
    hdr.checksum = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7741
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7742
    ret_val = e1000_mng_enable_host_if(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7743
    if (ret_val == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7744
        ret_val = e1000_mng_host_if_write(hw, buffer, length, sizeof(hdr),
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7745
                                          &(hdr.checksum));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7746
        if (ret_val == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7747
            ret_val = e1000_mng_write_cmd_header(hw, &hdr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7748
            if (ret_val == E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7749
                ret_val = e1000_mng_write_commit(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7750
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7751
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7752
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7753
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7754
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7755
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7756
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7757
 * This function calculates the checksum.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7758
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7759
 * returns  - checksum of buffer contents.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7760
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7761
static uint8_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7762
e1000_calculate_mng_checksum(char *buffer, uint32_t length)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7763
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7764
    uint8_t sum = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7765
    uint32_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7766
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7767
    if (!buffer)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7768
        return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7769
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7770
    for (i=0; i < length; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7771
        sum += buffer[i];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7772
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7773
    return (uint8_t) (0 - sum);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7774
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7775
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7776
/*****************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7777
 * This function checks whether tx pkt filtering needs to be enabled or not.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7778
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7779
 * returns  - TRUE for packet filtering or FALSE.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7780
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7781
boolean_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7782
e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7783
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7784
    /* called in init as well as watchdog timer functions */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7785
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7786
    int32_t ret_val, checksum;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7787
    boolean_t tx_filter = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7788
    struct e1000_host_mng_dhcp_cookie *hdr = &(hw->mng_cookie);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7789
    uint8_t *buffer = (uint8_t *) &(hw->mng_cookie);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7790
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7791
    if (e1000_check_mng_mode(hw)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7792
        ret_val = e1000_mng_enable_host_if(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7793
        if (ret_val == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7794
            ret_val = e1000_host_if_read_cookie(hw, buffer);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7795
            if (ret_val == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7796
                checksum = hdr->checksum;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7797
                hdr->checksum = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7798
                if ((hdr->signature == E1000_IAMT_SIGNATURE) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7799
                    checksum == e1000_calculate_mng_checksum((char *)buffer,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7800
                                               E1000_MNG_DHCP_COOKIE_LENGTH)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7801
                    if (hdr->status &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7802
                        E1000_MNG_DHCP_COOKIE_STATUS_PARSING_SUPPORT)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7803
                        tx_filter = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7804
                } else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7805
                    tx_filter = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7806
            } else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7807
                tx_filter = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7808
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7809
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7810
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7811
    hw->tx_pkt_filtering = tx_filter;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7812
    return tx_filter;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7813
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7814
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7815
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7816
 * Verifies the hardware needs to allow ARPs to be processed by the host
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7817
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7818
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7819
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7820
 * returns: - TRUE/FALSE
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7821
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7822
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7823
uint32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7824
e1000_enable_mng_pass_thru(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7825
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7826
    uint32_t manc;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7827
    uint32_t fwsm, factps;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7828
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7829
    if (hw->asf_firmware_present) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7830
        manc = E1000_READ_REG(hw, MANC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7831
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7832
        if (!(manc & E1000_MANC_RCV_TCO_EN) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7833
            !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7834
            return FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7835
        if (e1000_arc_subsystem_valid(hw) == TRUE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7836
            fwsm = E1000_READ_REG(hw, FWSM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7837
            factps = E1000_READ_REG(hw, FACTPS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7838
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7839
            if ((((fwsm & E1000_FWSM_MODE_MASK) >> E1000_FWSM_MODE_SHIFT) ==
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7840
                   e1000_mng_mode_pt) && !(factps & E1000_FACTPS_MNGCG))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7841
                return TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7842
        } else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7843
            if ((manc & E1000_MANC_SMBUS_EN) && !(manc & E1000_MANC_ASF_EN))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7844
                return TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7845
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7846
    return FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7847
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7848
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7849
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7850
e1000_polarity_reversal_workaround(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7851
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7852
    int32_t ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7853
    uint16_t mii_status_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7854
    uint16_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7855
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7856
    /* Polarity reversal workaround for forced 10F/10H links. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7857
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7858
    /* Disable the transmitter on the PHY */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7859
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7860
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0019);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7861
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7862
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7863
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7864
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7865
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7866
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7867
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7868
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7869
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7870
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7871
    /* This loop will early-out if the NO link condition has been met. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7872
    for (i = PHY_FORCE_TIME; i > 0; i--) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7873
        /* Read the MII Status Register and wait for Link Status bit
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7874
         * to be clear.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7875
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7876
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7877
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7878
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7879
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7880
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7881
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7882
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7883
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7884
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7885
        if ((mii_status_reg & ~MII_SR_LINK_STATUS) == 0) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7886
        mdelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7887
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7888
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7889
    /* Recommended delay time after link has been lost */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7890
    mdelay(1000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7891
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7892
    /* Now we will re-enable th transmitter on the PHY */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7893
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7894
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0019);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7895
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7896
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7897
    mdelay(50);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7898
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFFF0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7899
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7900
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7901
    mdelay(50);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7902
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFF00);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7903
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7904
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7905
    mdelay(50);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7906
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_GEN_CONTROL, 0x0000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7907
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7908
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7909
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7910
    ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7911
    if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7912
        return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7913
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7914
    /* This loop will early-out if the link condition has been met. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7915
    for (i = PHY_FORCE_TIME; i > 0; i--) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7916
        /* Read the MII Status Register and wait for Link Status bit
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7917
         * to be set.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7918
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7919
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7920
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7921
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7922
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7923
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7924
        ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7925
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7926
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7927
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7928
        if (mii_status_reg & MII_SR_LINK_STATUS) break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7929
        mdelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7930
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7931
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7932
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7933
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7934
/***************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7935
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7936
 * Disables PCI-Express master access.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7937
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7938
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7939
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7940
 * returns: - none.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7941
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7942
 ***************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7943
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7944
e1000_set_pci_express_master_disable(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7945
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7946
    uint32_t ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7947
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7948
    DEBUGFUNC("e1000_set_pci_express_master_disable");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7949
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7950
    if (hw->bus_type != e1000_bus_type_pci_express)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7951
        return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7952
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7953
    ctrl = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7954
    ctrl |= E1000_CTRL_GIO_MASTER_DISABLE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7955
    E1000_WRITE_REG(hw, CTRL, ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7956
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7957
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7958
/*******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7959
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7960
 * Disables PCI-Express master access and verifies there are no pending requests
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7961
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7962
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7963
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7964
 * returns: - E1000_ERR_MASTER_REQUESTS_PENDING if master disable bit hasn't
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7965
 *            caused the master requests to be disabled.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7966
 *            E1000_SUCCESS master requests disabled.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7967
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7968
 ******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7969
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7970
e1000_disable_pciex_master(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7971
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7972
    int32_t timeout = MASTER_DISABLE_TIMEOUT;   /* 80ms */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7973
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7974
    DEBUGFUNC("e1000_disable_pciex_master");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7975
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7976
    if (hw->bus_type != e1000_bus_type_pci_express)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7977
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7978
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7979
    e1000_set_pci_express_master_disable(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7980
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7981
    while (timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7982
        if (!(E1000_READ_REG(hw, STATUS) & E1000_STATUS_GIO_MASTER_ENABLE))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7983
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7984
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7985
            udelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7986
        timeout--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7987
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7988
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7989
    if (!timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7990
        DEBUGOUT("Master requests are pending.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7991
        return -E1000_ERR_MASTER_REQUESTS_PENDING;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7992
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7993
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7994
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7995
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7996
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7997
/*******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7998
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  7999
 * Check for EEPROM Auto Read bit done.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8000
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8001
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8002
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8003
 * returns: - E1000_ERR_RESET if fail to reset MAC
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8004
 *            E1000_SUCCESS at any other case.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8005
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8006
 ******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8007
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8008
e1000_get_auto_rd_done(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8009
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8010
    int32_t timeout = AUTO_READ_DONE_TIMEOUT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8011
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8012
    DEBUGFUNC("e1000_get_auto_rd_done");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8013
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8014
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8015
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8016
        msleep(5);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8017
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8018
    case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8019
    case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8020
    case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8021
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8022
    case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8023
        while (timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8024
            if (E1000_READ_REG(hw, EECD) & E1000_EECD_AUTO_RD)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8025
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8026
            else msleep(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8027
            timeout--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8028
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8029
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8030
        if (!timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8031
            DEBUGOUT("Auto read by HW from EEPROM has not completed.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8032
            return -E1000_ERR_RESET;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8033
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8034
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8035
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8036
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8037
    /* PHY configuration from NVM just starts after EECD_AUTO_RD sets to high.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8038
     * Need to wait for PHY configuration completion before accessing NVM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8039
     * and PHY. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8040
    if (hw->mac_type == e1000_82573)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8041
        msleep(25);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8042
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8043
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8044
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8045
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8046
/***************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8047
 * Checks if the PHY configuration is done
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8048
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8049
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8050
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8051
 * returns: - E1000_ERR_RESET if fail to reset MAC
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8052
 *            E1000_SUCCESS at any other case.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8053
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8054
 ***************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8055
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8056
e1000_get_phy_cfg_done(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8057
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8058
    int32_t timeout = PHY_CFG_TIMEOUT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8059
    uint32_t cfg_mask = E1000_EEPROM_CFG_DONE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8060
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8061
    DEBUGFUNC("e1000_get_phy_cfg_done");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8062
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8063
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8064
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8065
        mdelay(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8066
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8067
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8068
        /* Separate *_CFG_DONE_* bit for each port */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8069
        if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8070
            cfg_mask = E1000_EEPROM_CFG_DONE_PORT_1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8071
        /* Fall Through */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8072
    case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8073
    case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8074
        while (timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8075
            if (E1000_READ_REG(hw, EEMNGCTL) & cfg_mask)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8076
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8077
            else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8078
                msleep(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8079
            timeout--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8080
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8081
        if (!timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8082
            DEBUGOUT("MNG configuration cycle has not completed.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8083
            return -E1000_ERR_RESET;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8084
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8085
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8086
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8087
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8088
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8089
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8090
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8091
/***************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8092
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8093
 * Using the combination of SMBI and SWESMBI semaphore bits when resetting
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8094
 * adapter or Eeprom access.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8095
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8096
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8097
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8098
 * returns: - E1000_ERR_EEPROM if fail to access EEPROM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8099
 *            E1000_SUCCESS at any other case.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8100
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8101
 ***************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8102
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8103
e1000_get_hw_eeprom_semaphore(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8104
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8105
    int32_t timeout;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8106
    uint32_t swsm;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8107
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8108
    DEBUGFUNC("e1000_get_hw_eeprom_semaphore");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8109
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8110
    if (!hw->eeprom_semaphore_present)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8111
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8112
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8113
    if (hw->mac_type == e1000_80003es2lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8114
        /* Get the SW semaphore. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8115
        if (e1000_get_software_semaphore(hw) != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8116
            return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8117
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8118
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8119
    /* Get the FW semaphore. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8120
    timeout = hw->eeprom.word_size + 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8121
    while (timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8122
        swsm = E1000_READ_REG(hw, SWSM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8123
        swsm |= E1000_SWSM_SWESMBI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8124
        E1000_WRITE_REG(hw, SWSM, swsm);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8125
        /* if we managed to set the bit we got the semaphore. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8126
        swsm = E1000_READ_REG(hw, SWSM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8127
        if (swsm & E1000_SWSM_SWESMBI)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8128
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8129
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8130
        udelay(50);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8131
        timeout--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8132
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8133
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8134
    if (!timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8135
        /* Release semaphores */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8136
        e1000_put_hw_eeprom_semaphore(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8137
        DEBUGOUT("Driver can't access the Eeprom - SWESMBI bit is set.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8138
        return -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8139
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8140
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8141
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8142
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8143
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8144
/***************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8145
 * This function clears HW semaphore bits.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8146
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8147
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8148
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8149
 * returns: - None.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8150
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8151
 ***************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8152
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8153
e1000_put_hw_eeprom_semaphore(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8154
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8155
    uint32_t swsm;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8156
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8157
    DEBUGFUNC("e1000_put_hw_eeprom_semaphore");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8158
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8159
    if (!hw->eeprom_semaphore_present)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8160
        return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8161
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8162
    swsm = E1000_READ_REG(hw, SWSM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8163
    if (hw->mac_type == e1000_80003es2lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8164
        /* Release both semaphores. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8165
        swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8166
    } else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8167
        swsm &= ~(E1000_SWSM_SWESMBI);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8168
    E1000_WRITE_REG(hw, SWSM, swsm);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8169
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8170
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8171
/***************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8172
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8173
 * Obtaining software semaphore bit (SMBI) before resetting PHY.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8174
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8175
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8176
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8177
 * returns: - E1000_ERR_RESET if fail to obtain semaphore.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8178
 *            E1000_SUCCESS at any other case.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8179
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8180
 ***************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8181
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8182
e1000_get_software_semaphore(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8183
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8184
    int32_t timeout = hw->eeprom.word_size + 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8185
    uint32_t swsm;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8186
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8187
    DEBUGFUNC("e1000_get_software_semaphore");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8188
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8189
    if (hw->mac_type != e1000_80003es2lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8190
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8191
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8192
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8193
    while (timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8194
        swsm = E1000_READ_REG(hw, SWSM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8195
        /* If SMBI bit cleared, it is now set and we hold the semaphore */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8196
        if (!(swsm & E1000_SWSM_SMBI))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8197
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8198
        mdelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8199
        timeout--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8200
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8201
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8202
    if (!timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8203
        DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8204
        return -E1000_ERR_RESET;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8205
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8206
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8207
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8208
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8209
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8210
/***************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8211
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8212
 * Release semaphore bit (SMBI).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8213
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8214
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8215
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8216
 ***************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8217
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8218
e1000_release_software_semaphore(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8219
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8220
    uint32_t swsm;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8221
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8222
    DEBUGFUNC("e1000_release_software_semaphore");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8223
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8224
    if (hw->mac_type != e1000_80003es2lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8225
        return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8226
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8227
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8228
    swsm = E1000_READ_REG(hw, SWSM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8229
    /* Release the SW semaphores.*/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8230
    swsm &= ~E1000_SWSM_SMBI;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8231
    E1000_WRITE_REG(hw, SWSM, swsm);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8232
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8233
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8234
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8235
 * Checks if PHY reset is blocked due to SOL/IDER session, for example.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8236
 * Returning E1000_BLK_PHY_RESET isn't necessarily an error.  But it's up to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8237
 * the caller to figure out how to deal with it.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8238
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8239
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8240
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8241
 * returns: - E1000_BLK_PHY_RESET
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8242
 *            E1000_SUCCESS
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8243
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8244
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8245
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8246
e1000_check_phy_reset_block(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8247
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8248
    uint32_t manc = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8249
    uint32_t fwsm = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8250
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8251
    if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8252
        fwsm = E1000_READ_REG(hw, FWSM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8253
        return (fwsm & E1000_FWSM_RSPCIPHY) ? E1000_SUCCESS
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8254
                                            : E1000_BLK_PHY_RESET;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8255
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8256
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8257
    if (hw->mac_type > e1000_82547_rev_2)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8258
        manc = E1000_READ_REG(hw, MANC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8259
    return (manc & E1000_MANC_BLK_PHY_RST_ON_IDE) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8260
        E1000_BLK_PHY_RESET : E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8261
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8262
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8263
static uint8_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8264
e1000_arc_subsystem_valid(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8265
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8266
    uint32_t fwsm;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8267
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8268
    /* On 8257x silicon, registers in the range of 0x8800 - 0x8FFC
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8269
     * may not be provided a DMA clock when no manageability features are
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8270
     * enabled.  We do not want to perform any reads/writes to these registers
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8271
     * if this is the case.  We read FWSM to determine the manageability mode.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8272
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8273
    switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8274
    case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8275
    case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8276
    case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8277
    case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8278
        fwsm = E1000_READ_REG(hw, FWSM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8279
        if ((fwsm & E1000_FWSM_MODE_MASK) != 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8280
            return TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8281
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8282
    case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8283
        return TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8284
    default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8285
        break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8286
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8287
    return FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8288
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8289
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8290
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8291
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8292
 * Configure PCI-Ex no-snoop
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8293
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8294
 * hw - Struct containing variables accessed by shared code.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8295
 * no_snoop - Bitmap of no-snoop events.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8296
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8297
 * returns: E1000_SUCCESS
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8298
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8299
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8300
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8301
e1000_set_pci_ex_no_snoop(struct e1000_hw *hw, uint32_t no_snoop)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8302
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8303
    uint32_t gcr_reg = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8304
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8305
    DEBUGFUNC("e1000_set_pci_ex_no_snoop");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8306
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8307
    if (hw->bus_type == e1000_bus_type_unknown)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8308
        e1000_get_bus_info(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8309
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8310
    if (hw->bus_type != e1000_bus_type_pci_express)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8311
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8312
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8313
    if (no_snoop) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8314
        gcr_reg = E1000_READ_REG(hw, GCR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8315
        gcr_reg &= ~(PCI_EX_NO_SNOOP_ALL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8316
        gcr_reg |= no_snoop;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8317
        E1000_WRITE_REG(hw, GCR, gcr_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8318
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8319
    if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8320
        uint32_t ctrl_ext;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8321
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8322
        E1000_WRITE_REG(hw, GCR, PCI_EX_82566_SNOOP_ALL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8323
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8324
        ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8325
        ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8326
        E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8327
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8328
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8329
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8330
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8331
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8332
/***************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8333
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8334
 * Get software semaphore FLAG bit (SWFLAG).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8335
 * SWFLAG is used to synchronize the access to all shared resource between
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8336
 * SW, FW and HW.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8337
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8338
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8339
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8340
 ***************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8341
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8342
e1000_get_software_flag(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8343
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8344
    int32_t timeout = PHY_CFG_TIMEOUT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8345
    uint32_t extcnf_ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8346
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8347
    DEBUGFUNC("e1000_get_software_flag");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8348
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8349
    if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8350
        while (timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8351
            extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8352
            extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8353
            E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8354
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8355
            extcnf_ctrl = E1000_READ_REG(hw, EXTCNF_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8356
            if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8357
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8358
            mdelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8359
            timeout--;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8360
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8361
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8362
        if (!timeout) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8363
            DEBUGOUT("FW or HW locks the resource too long.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8364
            return -E1000_ERR_CONFIG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8365
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8366
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8367
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8368
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8369
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8370
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8371
/***************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8372
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8373
 * Release software semaphore FLAG bit (SWFLAG).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8374
 * SWFLAG is used to synchronize the access to all shared resource between
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8375
 * SW, FW and HW.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8376
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8377
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8378
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8379
 ***************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8380
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8381
e1000_release_software_flag(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8382
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8383
    uint32_t extcnf_ctrl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8384
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8385
    DEBUGFUNC("e1000_release_software_flag");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8386
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8387
    if (hw->mac_type == e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8388
        extcnf_ctrl= E1000_READ_REG(hw, EXTCNF_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8389
        extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8390
        E1000_WRITE_REG(hw, EXTCNF_CTRL, extcnf_ctrl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8391
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8392
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8393
    return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8394
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8395
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8396
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8397
 * Reads a 16 bit word or words from the EEPROM using the ICH8's flash access
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8398
 * register.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8399
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8400
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8401
 * offset - offset of word in the EEPROM to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8402
 * data - word read from the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8403
 * words - number of words to read
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8404
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8405
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8406
e1000_read_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, uint16_t words,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8407
                       uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8408
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8409
    int32_t  error = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8410
    uint32_t flash_bank = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8411
    uint32_t act_offset = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8412
    uint32_t bank_offset = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8413
    uint16_t word = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8414
    uint16_t i = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8415
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8416
    /* We need to know which is the valid flash bank.  In the event
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8417
     * that we didn't allocate eeprom_shadow_ram, we may not be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8418
     * managing flash_bank.  So it cannot be trusted and needs
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8419
     * to be updated with each read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8420
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8421
    /* Value of bit 22 corresponds to the flash bank we're on. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8422
    flash_bank = (E1000_READ_REG(hw, EECD) & E1000_EECD_SEC1VAL) ? 1 : 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8423
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8424
    /* Adjust offset appropriately if we're on bank 1 - adjust for word size */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8425
    bank_offset = flash_bank * (hw->flash_bank_size * 2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8426
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8427
    error = e1000_get_software_flag(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8428
    if (error != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8429
        return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8430
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8431
    for (i = 0; i < words; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8432
        if (hw->eeprom_shadow_ram != NULL &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8433
            hw->eeprom_shadow_ram[offset+i].modified == TRUE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8434
            data[i] = hw->eeprom_shadow_ram[offset+i].eeprom_word;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8435
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8436
            /* The NVM part needs a byte offset, hence * 2 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8437
            act_offset = bank_offset + ((offset + i) * 2);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8438
            error = e1000_read_ich8_word(hw, act_offset, &word);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8439
            if (error != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8440
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8441
            data[i] = word;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8442
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8443
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8444
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8445
    e1000_release_software_flag(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8446
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8447
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8448
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8449
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8450
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8451
 * Writes a 16 bit word or words to the EEPROM using the ICH8's flash access
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8452
 * register.  Actually, writes are written to the shadow ram cache in the hw
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8453
 * structure hw->e1000_shadow_ram.  e1000_commit_shadow_ram flushes this to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8454
 * the NVM, which occurs when the NVM checksum is updated.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8455
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8456
 * hw - Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8457
 * offset - offset of word in the EEPROM to write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8458
 * words - number of words to write
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8459
 * data - words to write to the EEPROM
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8460
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8461
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8462
e1000_write_eeprom_ich8(struct e1000_hw *hw, uint16_t offset, uint16_t words,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8463
                        uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8464
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8465
    uint32_t i = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8466
    int32_t error = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8467
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8468
    error = e1000_get_software_flag(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8469
    if (error != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8470
        return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8471
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8472
    /* A driver can write to the NVM only if it has eeprom_shadow_ram
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8473
     * allocated.  Subsequent reads to the modified words are read from
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8474
     * this cached structure as well.  Writes will only go into this
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8475
     * cached structure unless it's followed by a call to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8476
     * e1000_update_eeprom_checksum() where it will commit the changes
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8477
     * and clear the "modified" field.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8478
     */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8479
    if (hw->eeprom_shadow_ram != NULL) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8480
        for (i = 0; i < words; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8481
            if ((offset + i) < E1000_SHADOW_RAM_WORDS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8482
                hw->eeprom_shadow_ram[offset+i].modified = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8483
                hw->eeprom_shadow_ram[offset+i].eeprom_word = data[i];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8484
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8485
                error = -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8486
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8487
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8488
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8489
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8490
        /* Drivers have the option to not allocate eeprom_shadow_ram as long
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8491
         * as they don't perform any NVM writes.  An attempt in doing so
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8492
         * will result in this error.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8493
         */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8494
        error = -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8495
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8496
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8497
    e1000_release_software_flag(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8498
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8499
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8500
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8501
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8502
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8503
 * This function does initial flash setup so that a new read/write/erase cycle
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8504
 * can be started.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8505
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8506
 * hw - The pointer to the hw structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8507
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8508
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8509
e1000_ich8_cycle_init(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8510
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8511
    union ich8_hws_flash_status hsfsts;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8512
    int32_t error = E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8513
    int32_t i     = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8514
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8515
    DEBUGFUNC("e1000_ich8_cycle_init");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8516
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8517
    hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8518
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8519
    /* May be check the Flash Des Valid bit in Hw status */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8520
    if (hsfsts.hsf_status.fldesvalid == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8521
        DEBUGOUT("Flash descriptor invalid.  SW Sequencing must be used.");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8522
        return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8523
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8524
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8525
    /* Clear FCERR in Hw status by writing 1 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8526
    /* Clear DAEL in Hw status by writing a 1 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8527
    hsfsts.hsf_status.flcerr = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8528
    hsfsts.hsf_status.dael = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8529
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8530
    E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8531
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8532
    /* Either we should have a hardware SPI cycle in progress bit to check
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8533
     * against, in order to start a new cycle or FDONE bit should be changed
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8534
     * in the hardware so that it is 1 after harware reset, which can then be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8535
     * used as an indication whether a cycle is in progress or has been
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8536
     * completed .. we should also have some software semaphore mechanism to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8537
     * guard FDONE or the cycle in progress bit so that two threads access to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8538
     * those bits can be sequentiallized or a way so that 2 threads dont
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8539
     * start the cycle at the same time */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8540
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8541
    if (hsfsts.hsf_status.flcinprog == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8542
        /* There is no cycle running at present, so we can start a cycle */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8543
        /* Begin by setting Flash Cycle Done. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8544
        hsfsts.hsf_status.flcdone = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8545
        E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8546
        error = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8547
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8548
        /* otherwise poll for sometime so the current cycle has a chance
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8549
         * to end before giving up. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8550
        for (i = 0; i < ICH_FLASH_COMMAND_TIMEOUT; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8551
            hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8552
            if (hsfsts.hsf_status.flcinprog == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8553
                error = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8554
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8555
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8556
            udelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8557
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8558
        if (error == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8559
            /* Successful in waiting for previous cycle to timeout,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8560
             * now set the Flash Cycle Done. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8561
            hsfsts.hsf_status.flcdone = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8562
            E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8563
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8564
            DEBUGOUT("Flash controller busy, cannot get access");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8565
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8566
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8567
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8568
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8569
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8570
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8571
 * This function starts a flash cycle and waits for its completion
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8572
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8573
 * hw - The pointer to the hw structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8574
 ****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8575
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8576
e1000_ich8_flash_cycle(struct e1000_hw *hw, uint32_t timeout)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8577
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8578
    union ich8_hws_flash_ctrl hsflctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8579
    union ich8_hws_flash_status hsfsts;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8580
    int32_t error = E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8581
    uint32_t i = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8582
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8583
    /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8584
    hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8585
    hsflctl.hsf_ctrl.flcgo = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8586
    E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8587
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8588
    /* wait till FDONE bit is set to 1 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8589
    do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8590
        hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8591
        if (hsfsts.hsf_status.flcdone == 1)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8592
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8593
        udelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8594
        i++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8595
    } while (i < timeout);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8596
    if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8597
        error = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8598
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8599
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8600
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8601
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8602
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8603
 * Reads a byte or word from the NVM using the ICH8 flash access registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8604
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8605
 * hw - The pointer to the hw structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8606
 * index - The index of the byte or word to read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8607
 * size - Size of data to read, 1=byte 2=word
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8608
 * data - Pointer to the word to store the value read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8609
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8610
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8611
e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8612
                     uint32_t size, uint16_t* data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8613
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8614
    union ich8_hws_flash_status hsfsts;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8615
    union ich8_hws_flash_ctrl hsflctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8616
    uint32_t flash_linear_address;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8617
    uint32_t flash_data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8618
    int32_t error = -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8619
    int32_t count = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8620
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8621
    DEBUGFUNC("e1000_read_ich8_data");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8622
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8623
    if (size < 1  || size > 2 || data == 0x0 ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8624
        index > ICH_FLASH_LINEAR_ADDR_MASK)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8625
        return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8626
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8627
    flash_linear_address = (ICH_FLASH_LINEAR_ADDR_MASK & index) +
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8628
                           hw->flash_base_addr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8629
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8630
    do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8631
        udelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8632
        /* Steps */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8633
        error = e1000_ich8_cycle_init(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8634
        if (error != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8635
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8636
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8637
        hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8638
        /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8639
        hsflctl.hsf_ctrl.fldbcount = size - 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8640
        hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8641
        E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8642
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8643
        /* Write the last 24 bits of index into Flash Linear address field in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8644
         * Flash Address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8645
        /* TODO: TBD maybe check the index against the size of flash */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8646
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8647
        E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_address);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8648
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8649
        error = e1000_ich8_flash_cycle(hw, ICH_FLASH_COMMAND_TIMEOUT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8650
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8651
        /* Check if FCERR is set to 1, if set to 1, clear it and try the whole
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8652
         * sequence a few more times, else read in (shift in) the Flash Data0,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8653
         * the order is least significant byte first msb to lsb */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8654
        if (error == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8655
            flash_data = E1000_READ_ICH_FLASH_REG(hw, ICH_FLASH_FDATA0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8656
            if (size == 1) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8657
                *data = (uint8_t)(flash_data & 0x000000FF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8658
            } else if (size == 2) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8659
                *data = (uint16_t)(flash_data & 0x0000FFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8660
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8661
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8662
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8663
            /* If we've gotten here, then things are probably completely hosed,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8664
             * but if the error condition is detected, it won't hurt to give
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8665
             * it another try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8666
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8667
            hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8668
            if (hsfsts.hsf_status.flcerr == 1) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8669
                /* Repeat for some time before giving up. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8670
                continue;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8671
            } else if (hsfsts.hsf_status.flcdone == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8672
                DEBUGOUT("Timeout error - flash cycle did not complete.");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8673
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8674
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8675
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8676
    } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8677
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8678
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8679
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8680
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8681
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8682
 * Writes One /two bytes to the NVM using the ICH8 flash access registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8683
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8684
 * hw - The pointer to the hw structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8685
 * index - The index of the byte/word to read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8686
 * size - Size of data to read, 1=byte 2=word
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8687
 * data - The byte(s) to write to the NVM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8688
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8689
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8690
e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8691
                      uint16_t data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8692
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8693
    union ich8_hws_flash_status hsfsts;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8694
    union ich8_hws_flash_ctrl hsflctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8695
    uint32_t flash_linear_address;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8696
    uint32_t flash_data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8697
    int32_t error = -E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8698
    int32_t count = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8699
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8700
    DEBUGFUNC("e1000_write_ich8_data");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8701
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8702
    if (size < 1  || size > 2 || data > size * 0xff ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8703
        index > ICH_FLASH_LINEAR_ADDR_MASK)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8704
        return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8705
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8706
    flash_linear_address = (ICH_FLASH_LINEAR_ADDR_MASK & index) +
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8707
                           hw->flash_base_addr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8708
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8709
    do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8710
        udelay(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8711
        /* Steps */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8712
        error = e1000_ich8_cycle_init(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8713
        if (error != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8714
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8715
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8716
        hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8717
        /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8718
        hsflctl.hsf_ctrl.fldbcount = size -1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8719
        hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8720
        E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8721
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8722
        /* Write the last 24 bits of index into Flash Linear address field in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8723
         * Flash Address */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8724
        E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_address);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8725
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8726
        if (size == 1)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8727
            flash_data = (uint32_t)data & 0x00FF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8728
        else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8729
            flash_data = (uint32_t)data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8730
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8731
        E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8732
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8733
        /* check if FCERR is set to 1 , if set to 1, clear it and try the whole
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8734
         * sequence a few more times else done */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8735
        error = e1000_ich8_flash_cycle(hw, ICH_FLASH_COMMAND_TIMEOUT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8736
        if (error == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8737
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8738
        } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8739
            /* If we're here, then things are most likely completely hosed,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8740
             * but if the error condition is detected, it won't hurt to give
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8741
             * it another try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8742
             */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8743
            hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8744
            if (hsfsts.hsf_status.flcerr == 1) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8745
                /* Repeat for some time before giving up. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8746
                continue;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8747
            } else if (hsfsts.hsf_status.flcdone == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8748
                DEBUGOUT("Timeout error - flash cycle did not complete.");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8749
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8750
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8751
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8752
    } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8753
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8754
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8755
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8756
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8757
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8758
 * Reads a single byte from the NVM using the ICH8 flash access registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8759
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8760
 * hw - pointer to e1000_hw structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8761
 * index - The index of the byte to read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8762
 * data - Pointer to a byte to store the value read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8763
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8764
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8765
e1000_read_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t* data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8766
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8767
    int32_t status = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8768
    uint16_t word = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8769
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8770
    status = e1000_read_ich8_data(hw, index, 1, &word);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8771
    if (status == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8772
        *data = (uint8_t)word;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8773
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8774
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8775
    return status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8776
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8777
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8778
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8779
 * Writes a single byte to the NVM using the ICH8 flash access registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8780
 * Performs verification by reading back the value and then going through
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8781
 * a retry algorithm before giving up.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8782
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8783
 * hw - pointer to e1000_hw structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8784
 * index - The index of the byte to write.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8785
 * byte - The byte to write to the NVM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8786
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8787
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8788
e1000_verify_write_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t byte)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8789
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8790
    int32_t error = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8791
    int32_t program_retries = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8792
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8793
    DEBUGOUT2("Byte := %2.2X Offset := %d\n", byte, index);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8794
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8795
    error = e1000_write_ich8_byte(hw, index, byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8796
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8797
    if (error != E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8798
        for (program_retries = 0; program_retries < 100; program_retries++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8799
            DEBUGOUT2("Retrying \t Byte := %2.2X Offset := %d\n", byte, index);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8800
            error = e1000_write_ich8_byte(hw, index, byte);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8801
            udelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8802
            if (error == E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8803
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8804
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8805
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8806
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8807
    if (program_retries == 100)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8808
        error = E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8809
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8810
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8811
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8812
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8813
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8814
 * Writes a single byte to the NVM using the ICH8 flash access registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8815
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8816
 * hw - pointer to e1000_hw structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8817
 * index - The index of the byte to read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8818
 * data - The byte to write to the NVM.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8819
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8820
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8821
e1000_write_ich8_byte(struct e1000_hw *hw, uint32_t index, uint8_t data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8822
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8823
    int32_t status = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8824
    uint16_t word = (uint16_t)data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8825
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8826
    status = e1000_write_ich8_data(hw, index, 1, word);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8827
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8828
    return status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8829
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8830
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8831
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8832
 * Reads a word from the NVM using the ICH8 flash access registers.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8833
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8834
 * hw - pointer to e1000_hw structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8835
 * index - The starting byte index of the word to read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8836
 * data - Pointer to a word to store the value read.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8837
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8838
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8839
e1000_read_ich8_word(struct e1000_hw *hw, uint32_t index, uint16_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8840
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8841
    int32_t status = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8842
    status = e1000_read_ich8_data(hw, index, 2, data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8843
    return status;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8844
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8845
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8846
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8847
 * Erases the bank specified. Each bank may be a 4, 8 or 64k block. Banks are 0
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8848
 * based.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8849
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8850
 * hw - pointer to e1000_hw structure
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8851
 * bank - 0 for first bank, 1 for second bank
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8852
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8853
 * Note that this function may actually erase as much as 8 or 64 KBytes.  The
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8854
 * amount of NVM used in each bank is a *minimum* of 4 KBytes, but in fact the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8855
 * bank size may be 4, 8 or 64 KBytes
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8856
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8857
int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8858
e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8859
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8860
    union ich8_hws_flash_status hsfsts;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8861
    union ich8_hws_flash_ctrl hsflctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8862
    uint32_t flash_linear_address;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8863
    int32_t  count = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8864
    int32_t  error = E1000_ERR_EEPROM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8865
    int32_t  iteration;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8866
    int32_t  sub_sector_size = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8867
    int32_t  bank_size;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8868
    int32_t  j = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8869
    int32_t  error_flag = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8870
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8871
    hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8872
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8873
    /* Determine HW Sector size: Read BERASE bits of Hw flash Status register */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8874
    /* 00: The Hw sector is 256 bytes, hence we need to erase 16
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8875
     *     consecutive sectors.  The start index for the nth Hw sector can be
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8876
     *     calculated as bank * 4096 + n * 256
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8877
     * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8878
     *     The start index for the nth Hw sector can be calculated
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8879
     *     as bank * 4096
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8880
     * 10: The HW sector is 8K bytes
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8881
     * 11: The Hw sector size is 64K bytes */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8882
    if (hsfsts.hsf_status.berasesz == 0x0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8883
        /* Hw sector size 256 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8884
        sub_sector_size = ICH_FLASH_SEG_SIZE_256;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8885
        bank_size = ICH_FLASH_SECTOR_SIZE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8886
        iteration = ICH_FLASH_SECTOR_SIZE / ICH_FLASH_SEG_SIZE_256;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8887
    } else if (hsfsts.hsf_status.berasesz == 0x1) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8888
        bank_size = ICH_FLASH_SEG_SIZE_4K;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8889
        iteration = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8890
    } else if (hsfsts.hsf_status.berasesz == 0x3) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8891
        bank_size = ICH_FLASH_SEG_SIZE_64K;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8892
        iteration = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8893
    } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8894
        return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8895
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8896
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8897
    for (j = 0; j < iteration ; j++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8898
        do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8899
            count++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8900
            /* Steps */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8901
            error = e1000_ich8_cycle_init(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8902
            if (error != E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8903
                error_flag = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8904
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8905
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8906
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8907
            /* Write a value 11 (block Erase) in Flash Cycle field in Hw flash
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8908
             * Control */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8909
            hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8910
            hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8911
            E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8912
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8913
            /* Write the last 24 bits of an index within the block into Flash
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8914
             * Linear address field in Flash Address.  This probably needs to
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8915
             * be calculated here based off the on-chip erase sector size and
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8916
             * the software bank size (4, 8 or 64 KBytes) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8917
            flash_linear_address = bank * bank_size + j * sub_sector_size;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8918
            flash_linear_address += hw->flash_base_addr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8919
            flash_linear_address &= ICH_FLASH_LINEAR_ADDR_MASK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8920
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8921
            E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_address);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8922
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8923
            error = e1000_ich8_flash_cycle(hw, ICH_FLASH_ERASE_TIMEOUT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8924
            /* Check if FCERR is set to 1.  If 1, clear it and try the whole
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8925
             * sequence a few more times else Done */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8926
            if (error == E1000_SUCCESS) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8927
                break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8928
            } else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8929
                hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8930
                if (hsfsts.hsf_status.flcerr == 1) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8931
                    /* repeat for some time before giving up */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8932
                    continue;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8933
                } else if (hsfsts.hsf_status.flcdone == 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8934
                    error_flag = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8935
                    break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8936
                }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8937
            }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8938
        } while ((count < ICH_FLASH_CYCLE_REPEAT_COUNT) && !error_flag);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8939
        if (error_flag == 1)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8940
            break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8941
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8942
    if (error_flag != 1)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8943
        error = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8944
    return error;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8945
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8946
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8947
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8948
e1000_init_lcd_from_nvm_config_region(struct e1000_hw *hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8949
                                      uint32_t cnf_base_addr, uint32_t cnf_size)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8950
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8951
    uint32_t ret_val = E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8952
    uint16_t word_addr, reg_data, reg_addr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8953
    uint16_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8954
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8955
    /* cnf_base_addr is in DWORD */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8956
    word_addr = (uint16_t)(cnf_base_addr << 1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8957
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8958
    /* cnf_size is returned in size of dwords */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8959
    for (i = 0; i < cnf_size; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8960
        ret_val = e1000_read_eeprom(hw, (word_addr + i*2), 1, &reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8961
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8962
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8963
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8964
        ret_val = e1000_read_eeprom(hw, (word_addr + i*2 + 1), 1, &reg_addr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8965
        if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8966
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8967
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8968
        ret_val = e1000_get_software_flag(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8969
        if (ret_val != E1000_SUCCESS)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8970
            return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8971
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8972
        ret_val = e1000_write_phy_reg_ex(hw, (uint32_t)reg_addr, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8973
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8974
        e1000_release_software_flag(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8975
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8976
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8977
    return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8978
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8979
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8980
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8981
/******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8982
 * This function initializes the PHY from the NVM on ICH8 platforms. This
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8983
 * is needed due to an issue where the NVM configuration is not properly
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8984
 * autoloaded after power transitions. Therefore, after each PHY reset, we
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8985
 * will load the configuration data out of the NVM manually.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8986
 *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8987
 * hw: Struct containing variables accessed by shared code
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8988
 *****************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8989
static int32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8990
e1000_init_lcd_from_nvm(struct e1000_hw *hw)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8991
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8992
    uint32_t reg_data, cnf_base_addr, cnf_size, ret_val, loop;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8993
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8994
    if (hw->phy_type != e1000_phy_igp_3)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8995
          return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8996
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8997
    /* Check if SW needs configure the PHY */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8998
    reg_data = E1000_READ_REG(hw, FEXTNVM);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  8999
    if (!(reg_data & FEXTNVM_SW_CONFIG))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9000
        return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9001
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9002
    /* Wait for basic configuration completes before proceeding*/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9003
    loop = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9004
    do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9005
        reg_data = E1000_READ_REG(hw, STATUS) & E1000_STATUS_LAN_INIT_DONE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9006
        udelay(100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9007
        loop++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9008
    } while ((!reg_data) && (loop < 50));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9009
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9010
    /* Clear the Init Done bit for the next init event */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9011
    reg_data = E1000_READ_REG(hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9012
    reg_data &= ~E1000_STATUS_LAN_INIT_DONE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9013
    E1000_WRITE_REG(hw, STATUS, reg_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9014
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9015
    /* Make sure HW does not configure LCD from PHY extended configuration
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9016
       before SW configuration */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9017
    reg_data = E1000_READ_REG(hw, EXTCNF_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9018
    if ((reg_data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE) == 0x0000) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9019
        reg_data = E1000_READ_REG(hw, EXTCNF_SIZE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9020
        cnf_size = reg_data & E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9021
        cnf_size >>= 16;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9022
        if (cnf_size) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9023
            reg_data = E1000_READ_REG(hw, EXTCNF_CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9024
            cnf_base_addr = reg_data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9025
            /* cnf_base_addr is in DWORD */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9026
            cnf_base_addr >>= 16;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9027
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9028
            /* Configure LCD from extended configuration region. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9029
            ret_val = e1000_init_lcd_from_nvm_config_region(hw, cnf_base_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9030
                                                            cnf_size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9031
            if (ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9032
                return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9033
        }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9034
    }
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9035
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9036
    return E1000_SUCCESS;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9037
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  9038