devices/e1000e/lib-2.6.32-orig.c
author Florian Pose <fp@igh-essen.com>
Wed, 04 Jan 2012 12:30:30 +0100
branchredundancy
changeset 2326 a0762c46360e
parent 2136 729df853b3fb
permissions -rw-r--r--
Fixed crash on loading e100 driver for 2.6.33 (allocating cbs_pool).
2136
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2008 Intel Corporation.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
#include <linux/netdevice.h>
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
#include <linux/ethtool.h>
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include <linux/delay.h>
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#include <linux/pci.h>
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include "e1000.h"
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
enum e1000_mng_mode {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
	e1000_mng_mode_none = 0,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
	e1000_mng_mode_asf,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
	e1000_mng_mode_pt,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
	e1000_mng_mode_ipmi,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
	e1000_mng_mode_host_if_only
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
};
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#define E1000_FACTPS_MNGCG		0x20000000
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
/* Intel(R) Active Management Technology signature */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
#define E1000_IAMT_SIGNATURE		0x544D4149
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
 *  e1000e_get_bus_info_pcie - Get PCIe bus information
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
 *  Determines and stores the system bus information for a particular
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
 *  network interface.  The following bus information is determined and stored:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
 *  bus speed, bus width, type (PCIe), and PCIe function.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
	struct e1000_bus_info *bus = &hw->bus;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
	struct e1000_adapter *adapter = hw->adapter;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
	u32 status;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
	u16 pcie_link_status, pci_header_type, cap_offset;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
	cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	if (!cap_offset) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
		bus->width = e1000_bus_width_unknown;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
		pci_read_config_word(adapter->pdev,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
				     cap_offset + PCIE_LINK_STATUS,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
				     &pcie_link_status);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
		bus->width = (enum e1000_bus_width)((pcie_link_status &
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
						     PCIE_LINK_WIDTH_MASK) >>
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
						    PCIE_LINK_WIDTH_SHIFT);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	pci_read_config_word(adapter->pdev, PCI_HEADER_TYPE_REGISTER,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
			     &pci_header_type);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	if (pci_header_type & PCI_HEADER_TYPE_MULTIFUNC) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
		status = er32(STATUS);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
		bus->func = (status & E1000_STATUS_FUNC_MASK)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
			    >> E1000_STATUS_FUNC_SHIFT;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
		bus->func = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
 *  e1000e_write_vfta - Write value to VLAN filter table
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
 *  @offset: register offset in VLAN filter table
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
 *  @value: register value written to VLAN filter table
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
 *  Writes value at the given offset in the register array which stores
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
 *  the VLAN filter table.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
void e1000e_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
	E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, value);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
	e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
 *  e1000e_init_rx_addrs - Initialize receive address's
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
 *  @rar_count: receive address registers
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
 *  Setups the receive address registers by setting the base receive address
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
 *  register to the devices MAC address and clearing all the other receive
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
 *  address registers to 0.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
	u32 i;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
	/* Setup the receive address */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
	hw_dbg(hw, "Programming MAC Address into RAR[0]\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
	e1000e_rar_set(hw, hw->mac.addr, 0);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
	/* Zero out the other (rar_entry_count - 1) receive addresses */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
	hw_dbg(hw, "Clearing RAR[1-%u]\n", rar_count-1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
	for (i = 1; i < rar_count; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
		E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1), 0);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
		e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
		E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((i << 1) + 1), 0);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
		e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
 *  e1000e_rar_set - Set receive address register
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
 *  @addr: pointer to the receive address
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
 *  @index: receive address array register
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
 *  Sets the receive address array register at index to the address passed
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
 *  in by addr.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
void e1000e_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
	u32 rar_low, rar_high;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
	 * HW expects these in little endian so we reverse the byte order
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
	 * from network order (big endian) to little endian
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
	rar_low = ((u32) addr[0] |
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
		   ((u32) addr[1] << 8) |
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
		    ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
	rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
	rar_high |= E1000_RAH_AV;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
	E1000_WRITE_REG_ARRAY(hw, E1000_RA, (index << 1), rar_low);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
	E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((index << 1) + 1), rar_high);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
 *  e1000_hash_mc_addr - Generate a multicast hash value
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
 *  @mc_addr: pointer to a multicast address
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
 *  Generates a multicast address hash value which is used to determine
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
 *  the multicast filter table array address and new table value.  See
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
 *  e1000_mta_set_generic()
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
	u32 hash_value, hash_mask;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
	u8 bit_shift = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
	/* Register count multiplied by bits per register */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
	hash_mask = (hw->mac.mta_reg_count * 32) - 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
	 * For a mc_filter_type of 0, bit_shift is the number of left-shifts
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
	 * where 0xFF would still fall within the hash mask.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
	while (hash_mask >> bit_shift != 0xFF)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
		bit_shift++;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
	 * The portion of the address that is used for the hash table
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
	 * is determined by the mc_filter_type setting.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
	 * The algorithm is such that there is a total of 8 bits of shifting.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
	 * The bit_shift for a mc_filter_type of 0 represents the number of
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
	 * left-shifts where the MSB of mc_addr[5] would still fall within
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
	 * the hash_mask.  Case 0 does this exactly.  Since there are a total
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
	 * of 8 bits of shifting, then mc_addr[4] will shift right the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
	 * remaining number of bits. Thus 8 - bit_shift.  The rest of the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
	 * cases are a variation of this algorithm...essentially raising the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
	 * number of bits to shift mc_addr[5] left, while still keeping the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
	 * 8-bit shifting total.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
	 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
	 * For example, given the following Destination MAC Address and an
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
	 * mta register count of 128 (thus a 4096-bit vector and 0xFFF mask),
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
	 * we can see that the bit_shift for case 0 is 4.  These are the hash
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
	 * values resulting from each mc_filter_type...
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
	 * [0] [1] [2] [3] [4] [5]
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
	 * 01  AA  00  12  34  56
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
	 * LSB		 MSB
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
	 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
	 * case 0: hash_value = ((0x34 >> 4) | (0x56 << 4)) & 0xFFF = 0x563
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
	 * case 1: hash_value = ((0x34 >> 3) | (0x56 << 5)) & 0xFFF = 0xAC6
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
	 * case 2: hash_value = ((0x34 >> 2) | (0x56 << 6)) & 0xFFF = 0x163
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
	 * case 3: hash_value = ((0x34 >> 0) | (0x56 << 8)) & 0xFFF = 0x634
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
	switch (hw->mac.mc_filter_type) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
	default:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
	case 0:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
	case 1:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
		bit_shift += 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
	case 2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
		bit_shift += 2;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
	case 3:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
		bit_shift += 4;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
	hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
				  (((u16) mc_addr[5]) << bit_shift)));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
	return hash_value;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
 *  e1000e_update_mc_addr_list_generic - Update Multicast addresses
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
 *  @mc_addr_list: array of multicast addresses to program
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
 *  @mc_addr_count: number of multicast addresses to program
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
 *  @rar_used_count: the first RAR register free to program
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
 *  @rar_count: total number of supported Receive Address Registers
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
 *  Updates the Receive Address Registers and Multicast Table Array.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
 *  The caller must have a packed mc_addr_list of multicast addresses.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
 *  The parameter rar_count will usually be hw->mac.rar_entry_count
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
 *  unless there are workarounds that change this.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
					u8 *mc_addr_list, u32 mc_addr_count,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
					u32 rar_used_count, u32 rar_count)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
	u32 i;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
	u32 *mcarray = kzalloc(hw->mac.mta_reg_count * sizeof(u32), GFP_ATOMIC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
	if (!mcarray) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
		printk(KERN_ERR "multicast array memory allocation failed\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
		return;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
	 * Load the first set of multicast addresses into the exact
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
	 * filters (RAR).  If there are not enough to fill the RAR
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
	 * array, clear the filters.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
	for (i = rar_used_count; i < rar_count; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
		if (mc_addr_count) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
			e1000e_rar_set(hw, mc_addr_list, i);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
			mc_addr_count--;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
			mc_addr_list += ETH_ALEN;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
		} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
			E1000_WRITE_REG_ARRAY(hw, E1000_RA, i << 1, 0);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
			e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
			E1000_WRITE_REG_ARRAY(hw, E1000_RA, (i << 1) + 1, 0);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
			e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
	/* Load any remaining multicast addresses into the hash table. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
	for (; mc_addr_count > 0; mc_addr_count--) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
		u32 hash_value, hash_reg, hash_bit, mta;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
		hash_value = e1000_hash_mc_addr(hw, mc_addr_list);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
		hw_dbg(hw, "Hash value = 0x%03X\n", hash_value);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
		hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
		hash_bit = hash_value & 0x1F;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
		mta = (1 << hash_bit);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
		mcarray[hash_reg] |= mta;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
		mc_addr_list += ETH_ALEN;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
	/* write the hash table completely */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
	for (i = 0; i < hw->mac.mta_reg_count; i++)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, mcarray[i]);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
	e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
	kfree(mcarray);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
 *  e1000e_clear_hw_cntrs_base - Clear base hardware counters
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
 *  Clears the base hardware counters by reading the counter registers.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
	u32 temp;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
	temp = er32(CRCERRS);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
	temp = er32(SYMERRS);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
	temp = er32(MPC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
	temp = er32(SCC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
	temp = er32(ECOL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
	temp = er32(MCC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
	temp = er32(LATECOL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
	temp = er32(COLC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
	temp = er32(DC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
	temp = er32(SEC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
	temp = er32(RLEC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
	temp = er32(XONRXC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
	temp = er32(XONTXC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
	temp = er32(XOFFRXC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
	temp = er32(XOFFTXC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
	temp = er32(FCRUC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
	temp = er32(GPRC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
	temp = er32(BPRC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
	temp = er32(MPRC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
	temp = er32(GPTC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
	temp = er32(GORCL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
	temp = er32(GORCH);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	temp = er32(GOTCL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
	temp = er32(GOTCH);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
	temp = er32(RNBC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
	temp = er32(RUC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
	temp = er32(RFC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
	temp = er32(ROC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
	temp = er32(RJC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
	temp = er32(TORL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
	temp = er32(TORH);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
	temp = er32(TOTL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
	temp = er32(TOTH);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
	temp = er32(TPR);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
	temp = er32(TPT);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
	temp = er32(MPTC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
	temp = er32(BPTC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
 *  e1000e_check_for_copper_link - Check for link (Copper)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
 *  Checks to see of the link status of the hardware has changed.  If a
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
 *  change in link status has been detected, then we read the PHY registers
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
 *  to get the current speed/duplex if link exists.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
	bool link;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
	 * We only want to go out to the PHY registers to see if Auto-Neg
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
	 * has completed and/or if our link status has changed.  The
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
	 * get_link_status flag is set upon receiving a Link Status
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
	 * Change or Rx Sequence Error interrupt.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
	if (!mac->get_link_status)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
		return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
	 * First we want to see if the MII Status Register reports
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
	 * link.  If so, then we want to get the current speed/duplex
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
	 * of the PHY.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
	ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
	if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
	if (!link)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
		return ret_val; /* No link detected */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
	mac->get_link_status = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
	 * Check if there was DownShift, must be checked
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
	 * immediately after link-up
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
	e1000e_check_downshift(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
	 * If we are forcing speed/duplex, then we simply return since
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
	 * we have already determined whether we have link or not.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
	if (!mac->autoneg) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
		ret_val = -E1000_ERR_CONFIG;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
	 * Auto-Neg is enabled.  Auto Speed Detection takes care
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
	 * of MAC speed/duplex configuration.  So we only need to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
	 * configure Collision Distance in the MAC.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
	e1000e_config_collision_dist(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
	 * Configure Flow Control now that Auto-Neg has completed.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
	 * First, we need to restore the desired flow control
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
	 * settings because we may have had to re-autoneg with a
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
	 * different link partner.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
	ret_val = e1000e_config_fc_after_link_up(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
	if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
		hw_dbg(hw, "Error configuring flow control\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
	return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
 *  e1000e_check_for_fiber_link - Check for link (Fiber)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
 *  Checks for link up on the hardware.  If link is not up and we have
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
 *  a signal, then we need to force link up.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
s32 e1000e_check_for_fiber_link(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
	u32 rxcw;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
	u32 ctrl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
	u32 status;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
	ctrl = er32(CTRL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
	status = er32(STATUS);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
	rxcw = er32(RXCW);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
	 * If we don't have link (auto-negotiation failed or link partner
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
	 * cannot auto-negotiate), the cable is plugged in (we have signal),
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
	 * and our link partner is not trying to auto-negotiate with us (we
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
	 * are receiving idles or data), we need to force link up. We also
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
	 * need to give auto-negotiation time to complete, in case the cable
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
	 * was just plugged in. The autoneg_failed flag does this.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
	/* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
	if ((ctrl & E1000_CTRL_SWDPIN1) && (!(status & E1000_STATUS_LU)) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
	    (!(rxcw & E1000_RXCW_C))) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
		if (mac->autoneg_failed == 0) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
			mac->autoneg_failed = 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
			return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
		hw_dbg(hw, "NOT RXing /C/, disable AutoNeg and force link.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
		/* Disable auto-negotiation in the TXCW register */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
		ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
		/* Force link-up and also force full-duplex. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
		ctrl = er32(CTRL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
		ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
		ew32(CTRL, ctrl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
		/* Configure Flow Control after forcing link up. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
		ret_val = e1000e_config_fc_after_link_up(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
			hw_dbg(hw, "Error configuring flow control\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
	} else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
		 * If we are forcing link and we are receiving /C/ ordered
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
		 * sets, re-enable auto-negotiation in the TXCW register
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
		 * and disable forced link in the Device Control register
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
		 * in an attempt to auto-negotiate with our link partner.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
		hw_dbg(hw, "RXing /C/, enable AutoNeg and stop forcing link.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
		ew32(TXCW, mac->txcw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
		ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
		mac->serdes_has_link = true;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
 *  e1000e_check_for_serdes_link - Check for link (Serdes)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
 *  Checks for link up on the hardware.  If link is not up and we have
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
 *  a signal, then we need to force link up.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
s32 e1000e_check_for_serdes_link(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
	u32 rxcw;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
	u32 ctrl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
	u32 status;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
	ctrl = er32(CTRL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
	status = er32(STATUS);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
	rxcw = er32(RXCW);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
	 * If we don't have link (auto-negotiation failed or link partner
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
	 * cannot auto-negotiate), and our link partner is not trying to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
	 * auto-negotiate with us (we are receiving idles or data),
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
	 * we need to force link up. We also need to give auto-negotiation
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
	 * time to complete.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
	/* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
	if ((!(status & E1000_STATUS_LU)) && (!(rxcw & E1000_RXCW_C))) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
		if (mac->autoneg_failed == 0) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
			mac->autoneg_failed = 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
			return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
		hw_dbg(hw, "NOT RXing /C/, disable AutoNeg and force link.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
		/* Disable auto-negotiation in the TXCW register */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
		ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
		/* Force link-up and also force full-duplex. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
		ctrl = er32(CTRL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
		ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
		ew32(CTRL, ctrl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
		/* Configure Flow Control after forcing link up. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
		ret_val = e1000e_config_fc_after_link_up(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
			hw_dbg(hw, "Error configuring flow control\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
	} else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
		 * If we are forcing link and we are receiving /C/ ordered
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
		 * sets, re-enable auto-negotiation in the TXCW register
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
		 * and disable forced link in the Device Control register
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
		 * in an attempt to auto-negotiate with our link partner.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
		hw_dbg(hw, "RXing /C/, enable AutoNeg and stop forcing link.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
		ew32(TXCW, mac->txcw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
		ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
		mac->serdes_has_link = true;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
	} else if (!(E1000_TXCW_ANE & er32(TXCW))) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
		 * If we force link for non-auto-negotiation switch, check
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
		 * link status based on MAC synchronization for internal
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
		 * serdes media type.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
		/* SYNCH bit and IV bit are sticky. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
		udelay(10);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
		rxcw = er32(RXCW);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
		if (rxcw & E1000_RXCW_SYNCH) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
			if (!(rxcw & E1000_RXCW_IV)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
				mac->serdes_has_link = true;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
				hw_dbg(hw, "SERDES: Link up - forced.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
			}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
		} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
			mac->serdes_has_link = false;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
			hw_dbg(hw, "SERDES: Link down - force failed.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
	if (E1000_TXCW_ANE & er32(TXCW)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
		status = er32(STATUS);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
		if (status & E1000_STATUS_LU) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
			/* SYNCH bit and IV bit are sticky, so reread rxcw.  */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
			udelay(10);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
			rxcw = er32(RXCW);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
			if (rxcw & E1000_RXCW_SYNCH) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
				if (!(rxcw & E1000_RXCW_IV)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
					mac->serdes_has_link = true;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
					hw_dbg(hw, "SERDES: Link up - autoneg "
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
					   "completed sucessfully.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
				} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
					mac->serdes_has_link = false;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
					hw_dbg(hw, "SERDES: Link down - invalid"
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
					   "codewords detected in autoneg.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
				}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
			} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
				mac->serdes_has_link = false;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
				hw_dbg(hw, "SERDES: Link down - no sync.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
			}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
		} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
			mac->serdes_has_link = false;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
			hw_dbg(hw, "SERDES: Link down - autoneg failed\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
 *  e1000_set_default_fc_generic - Set flow control default values
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
 *  Read the EEPROM for the default values for flow control and store the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
 *  values.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
static s32 e1000_set_default_fc_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
	u16 nvm_data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
	 * Read and store word 0x0F of the EEPROM. This word contains bits
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
	 * that determine the hardware's default PAUSE (flow control) mode,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
	 * a bit that determines whether the HW defaults to enabling or
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
	 * disabling auto-negotiation, and the direction of the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
	 * SW defined pins. If there is no SW over-ride of the flow
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
	 * control setting, then the variable hw->fc will
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
	 * be initialized based on a value in the EEPROM.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
	ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &nvm_data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
	if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
		hw_dbg(hw, "NVM Read Error\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
	if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
		hw->fc.requested_mode = e1000_fc_none;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
	else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) ==
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
		 NVM_WORD0F_ASM_DIR)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
		hw->fc.requested_mode = e1000_fc_tx_pause;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	else
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
		hw->fc.requested_mode = e1000_fc_full;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
 *  e1000e_setup_link - Setup flow control and link settings
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
 *  Determines which flow control settings to use, then configures flow
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
 *  control.  Calls the appropriate media-specific link configuration
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
 *  function.  Assuming the adapter has a valid link partner, a valid link
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
 *  should be established.  Assumes the hardware has previously been reset
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
 *  and the transmitter and receiver are not enabled.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
s32 e1000e_setup_link(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
	 * In the case of the phy reset being blocked, we already have a link.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
	 * We do not need to set it up again.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
	if (e1000_check_reset_block(hw))
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
		return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
	 * If requested flow control is set to default, set flow control
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
	 * based on the EEPROM flow control settings.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
	if (hw->fc.requested_mode == e1000_fc_default) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
		ret_val = e1000_set_default_fc_generic(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
		if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
	 * Save off the requested flow control mode for use later.  Depending
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
	 * on the link partner's capabilities, we may or may not use this mode.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
	hw->fc.current_mode = hw->fc.requested_mode;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
	hw_dbg(hw, "After fix-ups FlowControl is now = %x\n",
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
		hw->fc.current_mode);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
	/* Call the necessary media_type subroutine to configure the link. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
	ret_val = mac->ops.setup_physical_interface(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
	if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	 * Initialize the flow control address, type, and PAUSE timer
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
	 * registers to their default values.  This is done even if flow
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
	 * control is disabled, because it does not hurt anything to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
	 * initialize these registers.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
	hw_dbg(hw, "Initializing the Flow Control address, type and timer regs\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
	ew32(FCT, FLOW_CONTROL_TYPE);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
	ew32(FCAH, FLOW_CONTROL_ADDRESS_HIGH);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
	ew32(FCAL, FLOW_CONTROL_ADDRESS_LOW);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
	ew32(FCTTV, hw->fc.pause_time);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
	return e1000e_set_fc_watermarks(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
 *  e1000_commit_fc_settings_generic - Configure flow control
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
 *  Write the flow control settings to the Transmit Config Word Register (TXCW)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
 *  base on the flow control settings in e1000_mac_info.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
	u32 txcw;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
	 * Check for a software override of the flow control settings, and
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
	 * setup the device accordingly.  If auto-negotiation is enabled, then
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
	 * software will have to set the "PAUSE" bits to the correct value in
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
	 * the Transmit Config Word Register (TXCW) and re-start auto-
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
	 * negotiation.  However, if auto-negotiation is disabled, then
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
	 * software will have to manually configure the two flow control enable
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
	 * bits in the CTRL register.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
	 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
	 * The possible values of the "fc" parameter are:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
	 *      0:  Flow control is completely disabled
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
	 *      1:  Rx flow control is enabled (we can receive pause frames,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
	 *	  but not send pause frames).
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
	 *      2:  Tx flow control is enabled (we can send pause frames but we
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
	 *	  do not support receiving pause frames).
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
	 *      3:  Both Rx and Tx flow control (symmetric) are enabled.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
	switch (hw->fc.current_mode) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
	case e1000_fc_none:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
		/* Flow control completely disabled by a software over-ride. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
		txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
	case e1000_fc_rx_pause:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
		 * Rx Flow control is enabled and Tx Flow control is disabled
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
		 * by a software over-ride. Since there really isn't a way to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
		 * advertise that we are capable of Rx Pause ONLY, we will
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
		 * advertise that we support both symmetric and asymmetric Rx
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
		 * PAUSE.  Later, we will disable the adapter's ability to send
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
		 * PAUSE frames.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
		txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
	case e1000_fc_tx_pause:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
		 * Tx Flow control is enabled, and Rx Flow control is disabled,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
		 * by a software over-ride.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
		txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
	case e1000_fc_full:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
		 * Flow control (both Rx and Tx) is enabled by a software
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
		 * over-ride.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
		txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
	default:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
		hw_dbg(hw, "Flow control param set incorrectly\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
		return -E1000_ERR_CONFIG;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
	ew32(TXCW, txcw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
	mac->txcw = txcw;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
 *  e1000_poll_fiber_serdes_link_generic - Poll for link up
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
 *  Polls for link up by reading the status register, if link fails to come
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
 *  up with auto-negotiation, then the link is forced if a signal is detected.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
	u32 i, status;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
	 * If we have a signal (the cable is plugged in, or assumed true for
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
	 * serdes media) then poll for a "Link-Up" indication in the Device
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
	 * Status Register.  Time-out if a link isn't seen in 500 milliseconds
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
	 * seconds (Auto-negotiation should complete in less than 500
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
	 * milliseconds even if the other end is doing it in SW).
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
	for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
		msleep(10);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
		status = er32(STATUS);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
		if (status & E1000_STATUS_LU)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
	if (i == FIBER_LINK_UP_LIMIT) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
		hw_dbg(hw, "Never got a valid link from auto-neg!!!\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
		mac->autoneg_failed = 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
		 * AutoNeg failed to achieve a link, so we'll call
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
		 * mac->check_for_link. This routine will force the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
		 * link up if we detect a signal. This will allow us to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
		 * communicate with non-autonegotiating link partners.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
		ret_val = mac->ops.check_for_link(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
			hw_dbg(hw, "Error while checking for link\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
		mac->autoneg_failed = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
		mac->autoneg_failed = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
		hw_dbg(hw, "Valid Link Found\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
 *  e1000e_setup_fiber_serdes_link - Setup link for fiber/serdes
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
 *  Configures collision distance and flow control for fiber and serdes
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
 *  links.  Upon successful setup, poll for link.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
	u32 ctrl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
	ctrl = er32(CTRL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
	/* Take the link out of reset */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
	ctrl &= ~E1000_CTRL_LRST;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
	e1000e_config_collision_dist(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
	ret_val = e1000_commit_fc_settings_generic(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
	if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
	 * Since auto-negotiation is enabled, take the link out of reset (the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
	 * link will be in reset, because we previously reset the chip). This
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
	 * will restart auto-negotiation.  If auto-negotiation is successful
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
	 * then the link-up status bit will be set and the flow control enable
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
	 * bits (RFCE and TFCE) will be set according to their negotiated value.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
	hw_dbg(hw, "Auto-negotiation enabled\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
	ew32(CTRL, ctrl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
	e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
	msleep(1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
	 * For these adapters, the SW definable pin 1 is set when the optics
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
	 * detect a signal.  If we have a signal, then poll for a "Link-Up"
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
	 * indication.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
	if (hw->phy.media_type == e1000_media_type_internal_serdes ||
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
	    (er32(CTRL) & E1000_CTRL_SWDPIN1)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
		ret_val = e1000_poll_fiber_serdes_link_generic(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
		hw_dbg(hw, "No signal detected\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
 *  e1000e_config_collision_dist - Configure collision distance
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
 *  Configures the collision distance to the default value and is used
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
 *  during link setup. Currently no func pointer exists and all
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
 *  implementations are handled in the generic version of this function.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
void e1000e_config_collision_dist(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
	u32 tctl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
	tctl = er32(TCTL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
	tctl &= ~E1000_TCTL_COLD;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
	tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
	ew32(TCTL, tctl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
	e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
 *  e1000e_set_fc_watermarks - Set flow control high/low watermarks
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
 *  Sets the flow control high/low threshold (watermark) registers.  If
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
 *  flow control XON frame transmission is enabled, then set XON frame
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
 *  transmission as well.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
s32 e1000e_set_fc_watermarks(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
	u32 fcrtl = 0, fcrth = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
	 * Set the flow control receive threshold registers.  Normally,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
	 * these registers will be set to a default threshold that may be
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
	 * adjusted later by the driver's runtime code.  However, if the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
	 * ability to transmit pause frames is not enabled, then these
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
	 * registers will be set to 0.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
	if (hw->fc.current_mode & e1000_fc_tx_pause) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
		 * We need to set up the Receive Threshold high and low water
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
		 * marks as well as (optionally) enabling the transmission of
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
		 * XON frames.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
		fcrtl = hw->fc.low_water;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
		fcrtl |= E1000_FCRTL_XONE;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
		fcrth = hw->fc.high_water;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	ew32(FCRTL, fcrtl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
	ew32(FCRTH, fcrth);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
 *  e1000e_force_mac_fc - Force the MAC's flow control settings
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
 *  Force the MAC's flow control settings.  Sets the TFCE and RFCE bits in the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
 *  device control register to reflect the adapter settings.  TFCE and RFCE
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
 *  need to be explicitly set by software when a copper PHY is used because
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
 *  autonegotiation is managed by the PHY rather than the MAC.  Software must
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
 *  also configure these bits when link is forced on a fiber connection.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
s32 e1000e_force_mac_fc(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
	u32 ctrl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
	ctrl = er32(CTRL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
	 * Because we didn't get link via the internal auto-negotiation
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
	 * mechanism (we either forced link or we got link via PHY
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
	 * auto-neg), we have to manually enable/disable transmit an
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
	 * receive flow control.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
	 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
	 * The "Case" statement below enables/disable flow control
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
	 * according to the "hw->fc.current_mode" parameter.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
	 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
	 * The possible values of the "fc" parameter are:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
	 *      0:  Flow control is completely disabled
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
	 *      1:  Rx flow control is enabled (we can receive pause
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
	 *	  frames but not send pause frames).
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
	 *      2:  Tx flow control is enabled (we can send pause frames
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
	 *	  frames but we do not receive pause frames).
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
	 *      3:  Both Rx and Tx flow control (symmetric) is enabled.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
	 *  other:  No other values should be possible at this point.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
	hw_dbg(hw, "hw->fc.current_mode = %u\n", hw->fc.current_mode);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
	switch (hw->fc.current_mode) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
	case e1000_fc_none:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
		ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
	case e1000_fc_rx_pause:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
		ctrl &= (~E1000_CTRL_TFCE);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
		ctrl |= E1000_CTRL_RFCE;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
	case e1000_fc_tx_pause:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
		ctrl &= (~E1000_CTRL_RFCE);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
		ctrl |= E1000_CTRL_TFCE;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
	case e1000_fc_full:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
		ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
	default:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
		hw_dbg(hw, "Flow control param set incorrectly\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
		return -E1000_ERR_CONFIG;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
	ew32(CTRL, ctrl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
 *  e1000e_config_fc_after_link_up - Configures flow control after link
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
 *  Checks the status of auto-negotiation after link up to ensure that the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
 *  speed and duplex were not forced.  If the link needed to be forced, then
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
 *  flow control needs to be forced also.  If auto-negotiation is enabled
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
 *  and did not fail, then we configure flow control based on our link
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
 *  partner.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
	s32 ret_val = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
	u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	u16 speed, duplex;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	 * Check for the case where we have fiber media and auto-neg failed
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
	 * so we had to force link.  In this case, we need to force the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
	 * configuration of the MAC to match the "fc" parameter.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
	if (mac->autoneg_failed) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
		if (hw->phy.media_type == e1000_media_type_fiber ||
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
		    hw->phy.media_type == e1000_media_type_internal_serdes)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
			ret_val = e1000e_force_mac_fc(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
		if (hw->phy.media_type == e1000_media_type_copper)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
			ret_val = e1000e_force_mac_fc(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
	if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
		hw_dbg(hw, "Error forcing flow control settings\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
	 * Check for the case where we have copper media and auto-neg is
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
	 * enabled.  In this case, we need to check and see if Auto-Neg
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
	 * has completed, and if so, how the PHY and link partner has
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
	 * flow control configured.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	if ((hw->phy.media_type == e1000_media_type_copper) && mac->autoneg) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
		 * Read the MII Status Register and check to see if AutoNeg
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
		 * has completed.  We read this twice because this reg has
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
		 * some "sticky" (latched) bits.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		ret_val = e1e_rphy(hw, PHY_STATUS, &mii_status_reg);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
		if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
		ret_val = e1e_rphy(hw, PHY_STATUS, &mii_status_reg);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
		if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
		if (!(mii_status_reg & MII_SR_AUTONEG_COMPLETE)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
			hw_dbg(hw, "Copper PHY and Auto Neg "
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
				 "has not completed.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
		 * The AutoNeg process has completed, so we now need to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
		 * read both the Auto Negotiation Advertisement
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
		 * Register (Address 4) and the Auto_Negotiation Base
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
		 * Page Ability Register (Address 5) to determine how
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
		 * flow control was negotiated.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
		ret_val = e1e_rphy(hw, PHY_AUTONEG_ADV, &mii_nway_adv_reg);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
		if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
		ret_val = e1e_rphy(hw, PHY_LP_ABILITY, &mii_nway_lp_ability_reg);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
		if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
		 * Two bits in the Auto Negotiation Advertisement Register
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
		 * (Address 4) and two bits in the Auto Negotiation Base
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
		 * Page Ability Register (Address 5) determine flow control
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
		 * for both the PHY and the link partner.  The following
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
		 * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
		 * 1999, describes these PAUSE resolution bits and how flow
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
		 * control is determined based upon these settings.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
		 * NOTE:  DC = Don't Care
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
		 *   LOCAL DEVICE  |   LINK PARTNER
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
		 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
		 *-------|---------|-------|---------|--------------------
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
		 *   0   |    0    |  DC   |   DC    | e1000_fc_none
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
		 *   0   |    1    |   0   |   DC    | e1000_fc_none
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
		 *   0   |    1    |   1   |    0    | e1000_fc_none
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
		 *   0   |    1    |   1   |    1    | e1000_fc_tx_pause
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
		 *   1   |    0    |   0   |   DC    | e1000_fc_none
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
		 *   1   |   DC    |   1   |   DC    | e1000_fc_full
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
		 *   1   |    1    |   0   |    0    | e1000_fc_none
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
		 *   1   |    1    |   0   |    1    | e1000_fc_rx_pause
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
		 * Are both PAUSE bits set to 1?  If so, this implies
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
		 * Symmetric Flow Control is enabled at both ends.  The
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
		 * ASM_DIR bits are irrelevant per the spec.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
		 * For Symmetric Flow Control:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
		 *   LOCAL DEVICE  |   LINK PARTNER
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
		 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
		 *-------|---------|-------|---------|--------------------
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
		 *   1   |   DC    |   1   |   DC    | E1000_fc_full
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
		if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
		    (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
			/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
			 * Now we need to check if the user selected Rx ONLY
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
			 * of pause frames.  In this case, we had to advertise
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
			 * FULL flow control because we could not advertise Rx
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
			 * ONLY. Hence, we must now check to see if we need to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
			 * turn OFF  the TRANSMISSION of PAUSE frames.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
			 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
			if (hw->fc.requested_mode == e1000_fc_full) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
				hw->fc.current_mode = e1000_fc_full;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
				hw_dbg(hw, "Flow Control = FULL.\r\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
			} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
				hw->fc.current_mode = e1000_fc_rx_pause;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
				hw_dbg(hw, "Flow Control = "
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
					 "RX PAUSE frames only.\r\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
			}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
		 * For receiving PAUSE frames ONLY.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
		 *   LOCAL DEVICE  |   LINK PARTNER
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
		 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
		 *-------|---------|-------|---------|--------------------
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
		 *   0   |    1    |   1   |    1    | e1000_fc_tx_pause
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
		else if (!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
			  (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
			  (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
			  (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
			hw->fc.current_mode = e1000_fc_tx_pause;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
			hw_dbg(hw, "Flow Control = Tx PAUSE frames only.\r\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
		 * For transmitting PAUSE frames ONLY.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
		 *   LOCAL DEVICE  |   LINK PARTNER
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
		 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
		 *-------|---------|-------|---------|--------------------
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
		 *   1   |    1    |   0   |    1    | e1000_fc_rx_pause
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
		 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
		else if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
			 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
			 !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
			 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
			hw->fc.current_mode = e1000_fc_rx_pause;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
			hw_dbg(hw, "Flow Control = Rx PAUSE frames only.\r\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
		} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
			/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
			 * Per the IEEE spec, at this point flow control
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
			 * should be disabled.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
			 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
			hw->fc.current_mode = e1000_fc_none;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
			hw_dbg(hw, "Flow Control = NONE.\r\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
		 * Now we need to do one last check...  If we auto-
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
		 * negotiated to HALF DUPLEX, flow control should not be
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
		 * enabled per IEEE 802.3 spec.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
		ret_val = mac->ops.get_link_up_info(hw, &speed, &duplex);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
			hw_dbg(hw, "Error getting link speed and duplex\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
		if (duplex == HALF_DUPLEX)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
			hw->fc.current_mode = e1000_fc_none;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
		 * Now we call a subroutine to actually force the MAC
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
		 * controller to use the correct flow control settings.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
		ret_val = e1000e_force_mac_fc(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
			hw_dbg(hw, "Error forcing flow control settings\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
 *  e1000e_get_speed_and_duplex_copper - Retrieve current speed/duplex
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
 *  @speed: stores the current speed
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
 *  @duplex: stores the current duplex
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
 *  Read the status register for the current speed/duplex and store the current
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
 *  speed and duplex for copper connections.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
	u32 status;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
	status = er32(STATUS);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
	if (status & E1000_STATUS_SPEED_1000) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
		*speed = SPEED_1000;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
		hw_dbg(hw, "1000 Mbs, ");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
	} else if (status & E1000_STATUS_SPEED_100) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
		*speed = SPEED_100;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
		hw_dbg(hw, "100 Mbs, ");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
		*speed = SPEED_10;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
		hw_dbg(hw, "10 Mbs, ");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
	if (status & E1000_STATUS_FD) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
		*duplex = FULL_DUPLEX;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
		hw_dbg(hw, "Full Duplex\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
		*duplex = HALF_DUPLEX;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
		hw_dbg(hw, "Half Duplex\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
 *  e1000e_get_speed_and_duplex_fiber_serdes - Retrieve current speed/duplex
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
 *  @speed: stores the current speed
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
 *  @duplex: stores the current duplex
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
 *  Sets the speed and duplex to gigabit full duplex (the only possible option)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
 *  for fiber/serdes links.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
	*speed = SPEED_1000;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
	*duplex = FULL_DUPLEX;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
 *  e1000e_get_hw_semaphore - Acquire hardware semaphore
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
 *  Acquire the HW semaphore to access the PHY or NVM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
s32 e1000e_get_hw_semaphore(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
	u32 swsm;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
	s32 timeout = hw->nvm.word_size + 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
	s32 i = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
	/* Get the SW semaphore */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
	while (i < timeout) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
		swsm = er32(SWSM);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
		if (!(swsm & E1000_SWSM_SMBI))
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
		udelay(50);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
		i++;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
	if (i == timeout) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
		hw_dbg(hw, "Driver can't access device - SMBI bit is set.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
		return -E1000_ERR_NVM;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
	/* Get the FW semaphore. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
	for (i = 0; i < timeout; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
		swsm = er32(SWSM);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
		ew32(SWSM, swsm | E1000_SWSM_SWESMBI);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
		/* Semaphore acquired if bit latched */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
		if (er32(SWSM) & E1000_SWSM_SWESMBI)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
		udelay(50);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
	if (i == timeout) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
		/* Release semaphores */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
		e1000e_put_hw_semaphore(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
		hw_dbg(hw, "Driver can't access the NVM\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
		return -E1000_ERR_NVM;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
 *  e1000e_put_hw_semaphore - Release hardware semaphore
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
 *  Release hardware semaphore used to access the PHY or NVM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
void e1000e_put_hw_semaphore(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
	u32 swsm;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
	swsm = er32(SWSM);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
	swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
	ew32(SWSM, swsm);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
 *  e1000e_get_auto_rd_done - Check for auto read completion
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
 *  Check EEPROM for Auto Read done bit.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
s32 e1000e_get_auto_rd_done(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
	s32 i = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
	while (i < AUTO_READ_DONE_TIMEOUT) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
		if (er32(EECD) & E1000_EECD_AUTO_RD)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
		msleep(1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
		i++;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
	if (i == AUTO_READ_DONE_TIMEOUT) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
		hw_dbg(hw, "Auto read by HW from NVM has not completed.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
		return -E1000_ERR_RESET;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
 *  e1000e_valid_led_default - Verify a valid default LED config
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
 *  @data: pointer to the NVM (EEPROM)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
 *  Read the EEPROM for the current default LED configuration.  If the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
 *  LED configuration is not valid, set to a valid LED configuration.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
	ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
	if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
		hw_dbg(hw, "NVM Read Error\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
	if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
		*data = ID_LED_DEFAULT;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
 *  e1000e_id_led_init -
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
s32 e1000e_id_led_init(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
	const u32 ledctl_mask = 0x000000FF;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
	const u32 ledctl_on = E1000_LEDCTL_MODE_LED_ON;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
	const u32 ledctl_off = E1000_LEDCTL_MODE_LED_OFF;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
	u16 data, i, temp;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
	const u16 led_mask = 0x0F;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
	ret_val = hw->nvm.ops.valid_led_default(hw, &data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
	if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
	mac->ledctl_default = er32(LEDCTL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
	mac->ledctl_mode1 = mac->ledctl_default;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
	mac->ledctl_mode2 = mac->ledctl_default;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
	for (i = 0; i < 4; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
		temp = (data >> (i << 2)) & led_mask;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
		switch (temp) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
		case ID_LED_ON1_DEF2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
		case ID_LED_ON1_ON2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
		case ID_LED_ON1_OFF2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
			mac->ledctl_mode1 &= ~(ledctl_mask << (i << 3));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
			mac->ledctl_mode1 |= ledctl_on << (i << 3);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
		case ID_LED_OFF1_DEF2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
		case ID_LED_OFF1_ON2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
		case ID_LED_OFF1_OFF2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
			mac->ledctl_mode1 &= ~(ledctl_mask << (i << 3));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
			mac->ledctl_mode1 |= ledctl_off << (i << 3);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
		default:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
			/* Do nothing */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
		switch (temp) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
		case ID_LED_DEF1_ON2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
		case ID_LED_ON1_ON2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
		case ID_LED_OFF1_ON2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
			mac->ledctl_mode2 &= ~(ledctl_mask << (i << 3));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
			mac->ledctl_mode2 |= ledctl_on << (i << 3);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
		case ID_LED_DEF1_OFF2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
		case ID_LED_ON1_OFF2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
		case ID_LED_OFF1_OFF2:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
			mac->ledctl_mode2 &= ~(ledctl_mask << (i << 3));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
			mac->ledctl_mode2 |= ledctl_off << (i << 3);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
		default:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
			/* Do nothing */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
 *  e1000e_setup_led_generic - Configures SW controllable LED
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
 *  This prepares the SW controllable LED for use and saves the current state
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
 *  of the LED so it can be later restored.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
s32 e1000e_setup_led_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
	u32 ledctl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
	if (hw->mac.ops.setup_led != e1000e_setup_led_generic) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
		return -E1000_ERR_CONFIG;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
	if (hw->phy.media_type == e1000_media_type_fiber) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
		ledctl = er32(LEDCTL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
		hw->mac.ledctl_default = ledctl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
		/* Turn off LED0 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
		ledctl &= ~(E1000_LEDCTL_LED0_IVRT |
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
		            E1000_LEDCTL_LED0_BLINK |
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
		            E1000_LEDCTL_LED0_MODE_MASK);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
		ledctl |= (E1000_LEDCTL_MODE_LED_OFF <<
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
		           E1000_LEDCTL_LED0_MODE_SHIFT);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
		ew32(LEDCTL, ledctl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
	} else if (hw->phy.media_type == e1000_media_type_copper) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
		ew32(LEDCTL, hw->mac.ledctl_mode1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
 *  e1000e_cleanup_led_generic - Set LED config to default operation
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
 *  Remove the current LED configuration and set the LED configuration
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
 *  to the default value, saved from the EEPROM.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
s32 e1000e_cleanup_led_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
	ew32(LEDCTL, hw->mac.ledctl_default);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
 *  e1000e_blink_led - Blink LED
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
 *  Blink the LEDs which are set to be on.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
s32 e1000e_blink_led(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	u32 ledctl_blink = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
	u32 i;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
	if (hw->phy.media_type == e1000_media_type_fiber) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
		/* always blink LED0 for PCI-E fiber */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
		ledctl_blink = E1000_LEDCTL_LED0_BLINK |
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
		     (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED0_MODE_SHIFT);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
		 * set the blink bit for each LED that's "on" (0x0E)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
		 * in ledctl_mode2
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
		ledctl_blink = hw->mac.ledctl_mode2;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
		for (i = 0; i < 4; i++)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
			if (((hw->mac.ledctl_mode2 >> (i * 8)) & 0xFF) ==
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
			    E1000_LEDCTL_MODE_LED_ON)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
				ledctl_blink |= (E1000_LEDCTL_LED0_BLINK <<
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
						 (i * 8));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
	ew32(LEDCTL, ledctl_blink);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
 *  e1000e_led_on_generic - Turn LED on
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
 *  Turn LED on.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
s32 e1000e_led_on_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
	u32 ctrl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
	switch (hw->phy.media_type) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
	case e1000_media_type_fiber:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
		ctrl = er32(CTRL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
		ctrl &= ~E1000_CTRL_SWDPIN0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
		ctrl |= E1000_CTRL_SWDPIO0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
		ew32(CTRL, ctrl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
	case e1000_media_type_copper:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
		ew32(LEDCTL, hw->mac.ledctl_mode2);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
	default:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
 *  e1000e_led_off_generic - Turn LED off
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
 *  Turn LED off.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
s32 e1000e_led_off_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
	u32 ctrl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
	switch (hw->phy.media_type) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
	case e1000_media_type_fiber:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
		ctrl = er32(CTRL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
		ctrl |= E1000_CTRL_SWDPIN0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
		ctrl |= E1000_CTRL_SWDPIO0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
		ew32(CTRL, ctrl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
	case e1000_media_type_copper:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
		ew32(LEDCTL, hw->mac.ledctl_mode1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
	default:
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
		break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
 *  e1000e_set_pcie_no_snoop - Set PCI-express capabilities
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
 *  @no_snoop: bitmap of snoop events
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
 *  Set the PCI-express register to snoop for events enabled in 'no_snoop'.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
	u32 gcr;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
	if (no_snoop) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
		gcr = er32(GCR);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
		gcr &= ~(PCIE_NO_SNOOP_ALL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
		gcr |= no_snoop;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
		ew32(GCR, gcr);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
 *  e1000e_disable_pcie_master - Disables PCI-express master access
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
 *  Returns 0 if successful, else returns -10
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
 *  (-E1000_ERR_MASTER_REQUESTS_PENDING) if master disable bit has not caused
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
 *  the master requests to be disabled.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
 *  Disables PCI-Express master access and verifies there are no pending
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
 *  requests.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
s32 e1000e_disable_pcie_master(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
	u32 ctrl;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
	s32 timeout = MASTER_DISABLE_TIMEOUT;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
	ctrl = er32(CTRL);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
	ctrl |= E1000_CTRL_GIO_MASTER_DISABLE;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
	ew32(CTRL, ctrl);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
	while (timeout) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
		if (!(er32(STATUS) &
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
		      E1000_STATUS_GIO_MASTER_ENABLE))
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
		udelay(100);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
		timeout--;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
	if (!timeout) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
		hw_dbg(hw, "Master requests are pending.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
		return -E1000_ERR_MASTER_REQUESTS_PENDING;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
 *  e1000e_reset_adaptive - Reset Adaptive Interframe Spacing
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
 *  Reset the Adaptive Interframe Spacing throttle to default values.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
void e1000e_reset_adaptive(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
	mac->current_ifs_val = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
	mac->ifs_min_val = IFS_MIN;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
	mac->ifs_max_val = IFS_MAX;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
	mac->ifs_step_size = IFS_STEP;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
	mac->ifs_ratio = IFS_RATIO;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
	mac->in_ifs_mode = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
	ew32(AIT, 0);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
 *  e1000e_update_adaptive - Update Adaptive Interframe Spacing
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
 *  Update the Adaptive Interframe Spacing Throttle value based on the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
 *  time between transmitted packets and time between collisions.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
void e1000e_update_adaptive(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
	struct e1000_mac_info *mac = &hw->mac;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
	if ((mac->collision_delta * mac->ifs_ratio) > mac->tx_packet_delta) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
		if (mac->tx_packet_delta > MIN_NUM_XMITS) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
			mac->in_ifs_mode = 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
			if (mac->current_ifs_val < mac->ifs_max_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
				if (!mac->current_ifs_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
					mac->current_ifs_val = mac->ifs_min_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
				else
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
					mac->current_ifs_val +=
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
						mac->ifs_step_size;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
				ew32(AIT, mac->current_ifs_val);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
			}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
		if (mac->in_ifs_mode &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
		    (mac->tx_packet_delta <= MIN_NUM_XMITS)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
			mac->current_ifs_val = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
			mac->in_ifs_mode = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
			ew32(AIT, 0);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
 *  e1000_raise_eec_clk - Raise EEPROM clock
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
 *  @eecd: pointer to the EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
 *  Enable/Raise the EEPROM clock bit.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
static void e1000_raise_eec_clk(struct e1000_hw *hw, u32 *eecd)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
	*eecd = *eecd | E1000_EECD_SK;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
	ew32(EECD, *eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
	e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
	udelay(hw->nvm.delay_usec);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
 *  e1000_lower_eec_clk - Lower EEPROM clock
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
 *  @eecd: pointer to the EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
 *  Clear/Lower the EEPROM clock bit.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
static void e1000_lower_eec_clk(struct e1000_hw *hw, u32 *eecd)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
	*eecd = *eecd & ~E1000_EECD_SK;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
	ew32(EECD, *eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
	e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
	udelay(hw->nvm.delay_usec);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
 *  e1000_shift_out_eec_bits - Shift data bits our to the EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
 *  @data: data to send to the EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
 *  @count: number of bits to shift out
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
 *  We need to shift 'count' bits out to the EEPROM.  So, the value in the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
 *  "data" parameter will be shifted out to the EEPROM one bit at a time.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
 *  In order to do this, "data" must be broken down into bits.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
static void e1000_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
	struct e1000_nvm_info *nvm = &hw->nvm;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
	u32 eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
	u32 mask;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
	mask = 0x01 << (count - 1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
	if (nvm->type == e1000_nvm_eeprom_spi)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
		eecd |= E1000_EECD_DO;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
	do {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
		eecd &= ~E1000_EECD_DI;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
		if (data & mask)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
			eecd |= E1000_EECD_DI;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
		ew32(EECD, eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
		e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
		udelay(nvm->delay_usec);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
		e1000_raise_eec_clk(hw, &eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
		e1000_lower_eec_clk(hw, &eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
		mask >>= 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
	} while (mask);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
	eecd &= ~E1000_EECD_DI;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
	ew32(EECD, eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
 *  e1000_shift_in_eec_bits - Shift data bits in from the EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
 *  @count: number of bits to shift in
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
 *  In order to read a register from the EEPROM, we need to shift 'count' bits
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
 *  in from the EEPROM.  Bits are "shifted in" by raising the clock input to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
 *  the EEPROM (setting the SK bit), and then reading the value of the data out
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
 *  "DO" bit.  During this "shifting in" process the data in "DI" bit should
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
 *  always be clear.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
static u16 e1000_shift_in_eec_bits(struct e1000_hw *hw, u16 count)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
	u32 eecd;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
	u32 i;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
	u16 data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
	eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
	eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
	data = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
	for (i = 0; i < count; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
		data <<= 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
		e1000_raise_eec_clk(hw, &eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
		eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
		eecd &= ~E1000_EECD_DI;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
		if (eecd & E1000_EECD_DO)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
			data |= 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
		e1000_lower_eec_clk(hw, &eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
	return data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
 *  e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
 *  @ee_reg: EEPROM flag for polling
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
 *  Polls the EEPROM status bit for either read or write completion based
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
 *  upon the value of 'ee_reg'.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
	u32 attempts = 100000;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
	u32 i, reg = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
	for (i = 0; i < attempts; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
		if (ee_reg == E1000_NVM_POLL_READ)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
			reg = er32(EERD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
		else
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
			reg = er32(EEWR);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
		if (reg & E1000_NVM_RW_REG_DONE)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
			return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
		udelay(5);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
	return -E1000_ERR_NVM;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
 *  e1000e_acquire_nvm - Generic request for access to EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
 *  Set the EEPROM access request bit and wait for EEPROM access grant bit.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
 *  Return successful if access grant bit set, else clear the request for
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
 *  EEPROM access and return -E1000_ERR_NVM (-1).
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
s32 e1000e_acquire_nvm(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
	u32 eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
	s32 timeout = E1000_NVM_GRANT_ATTEMPTS;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	ew32(EECD, eecd | E1000_EECD_REQ);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
	eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
	while (timeout) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
		if (eecd & E1000_EECD_GNT)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
		udelay(5);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
		eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
		timeout--;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
	if (!timeout) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
		eecd &= ~E1000_EECD_REQ;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
		ew32(EECD, eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
		hw_dbg(hw, "Could not acquire NVM grant\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
		return -E1000_ERR_NVM;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
 *  e1000_standby_nvm - Return EEPROM to standby state
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
 *  Return the EEPROM to a standby state.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
static void e1000_standby_nvm(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
	struct e1000_nvm_info *nvm = &hw->nvm;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
	u32 eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	if (nvm->type == e1000_nvm_eeprom_spi) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
		/* Toggle CS to flush commands */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
		eecd |= E1000_EECD_CS;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
		ew32(EECD, eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
		e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
		udelay(nvm->delay_usec);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
		eecd &= ~E1000_EECD_CS;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
		ew32(EECD, eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
		e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
		udelay(nvm->delay_usec);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
 *  e1000_stop_nvm - Terminate EEPROM command
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
 *  Terminates the current command by inverting the EEPROM's chip select pin.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
static void e1000_stop_nvm(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
	u32 eecd;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
	eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
	if (hw->nvm.type == e1000_nvm_eeprom_spi) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
		/* Pull CS high */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
		eecd |= E1000_EECD_CS;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
		e1000_lower_eec_clk(hw, &eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
 *  e1000e_release_nvm - Release exclusive access to EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
 *  Stop any current commands to the EEPROM and clear the EEPROM request bit.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
void e1000e_release_nvm(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
	u32 eecd;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
	e1000_stop_nvm(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
	eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
	eecd &= ~E1000_EECD_REQ;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
	ew32(EECD, eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
 *  e1000_ready_nvm_eeprom - Prepares EEPROM for read/write
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
 *  Setups the EEPROM for reading and writing.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
	struct e1000_nvm_info *nvm = &hw->nvm;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
	u32 eecd = er32(EECD);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
	u16 timeout = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
	u8 spi_stat_reg;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
	if (nvm->type == e1000_nvm_eeprom_spi) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
		/* Clear SK and CS */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
		eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
		ew32(EECD, eecd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
		udelay(1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
		timeout = NVM_MAX_RETRY_SPI;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
		 * Read "Status Register" repeatedly until the LSB is cleared.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
		 * The EEPROM will signal that the command has been completed
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
		 * by clearing bit 0 of the internal status register.  If it's
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
		 * not cleared within 'timeout', then error out.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
		while (timeout) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
			e1000_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
						 hw->nvm.opcode_bits);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
			spi_stat_reg = (u8)e1000_shift_in_eec_bits(hw, 8);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
			if (!(spi_stat_reg & NVM_STATUS_RDY_SPI))
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
				break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
			udelay(5);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
			e1000_standby_nvm(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
			timeout--;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
		if (!timeout) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
			hw_dbg(hw, "SPI NVM Status error\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
			return -E1000_ERR_NVM;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
 *  e1000e_read_nvm_eerd - Reads EEPROM using EERD register
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
 *  @offset: offset of word in the EEPROM to read
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
 *  @words: number of words to read
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
 *  @data: word read from the EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
 *  Reads a 16 bit word from the EEPROM using the EERD register.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
	struct e1000_nvm_info *nvm = &hw->nvm;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
	u32 i, eerd = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
	s32 ret_val = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
	 * A check for invalid values:  offset too large, too many words,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
	 * too many words for the offset, and not enough words.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
	if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
	    (words == 0)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
		hw_dbg(hw, "nvm parameter(s) out of bounds\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
		return -E1000_ERR_NVM;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
	for (i = 0; i < words; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
		eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) +
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
		       E1000_NVM_RW_REG_START;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
		ew32(EERD, eerd);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
		ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
		if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
		data[i] = (er32(EERD) >> E1000_NVM_RW_REG_DATA);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
	return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
 *  e1000e_write_nvm_spi - Write to EEPROM using SPI
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
 *  @offset: offset within the EEPROM to be written to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
 *  @words: number of words to write
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
 *  @data: 16 bit word(s) to be written to the EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
 *  Writes data to EEPROM at offset using SPI interface.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
 *  If e1000e_update_nvm_checksum is not called after this function , the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
 *  EEPROM will most likely contain an invalid checksum.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
	struct e1000_nvm_info *nvm = &hw->nvm;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
	u16 widx = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
	 * A check for invalid values:  offset too large, too many words,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
	 * and not enough words.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
	if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
	    (words == 0)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
		hw_dbg(hw, "nvm parameter(s) out of bounds\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
		return -E1000_ERR_NVM;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
	ret_val = nvm->ops.acquire_nvm(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
	if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
	msleep(10);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
	while (widx < words) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
		u8 write_opcode = NVM_WRITE_OPCODE_SPI;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
		ret_val = e1000_ready_nvm_eeprom(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
			nvm->ops.release_nvm(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
		e1000_standby_nvm(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
		/* Send the WRITE ENABLE command (8 bit opcode) */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
		e1000_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
					 nvm->opcode_bits);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
		e1000_standby_nvm(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
		/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
		 * Some SPI eeproms use the 8th address bit embedded in the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
		 * opcode
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
		 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
		if ((nvm->address_bits == 8) && (offset >= 128))
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
			write_opcode |= NVM_A8_OPCODE_SPI;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
		/* Send the Write command (8-bit opcode + addr) */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
		e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
		e1000_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
					 nvm->address_bits);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
		/* Loop to allow for up to whole page write of eeprom */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
		while (widx < words) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
			u16 word_out = data[widx];
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
			word_out = (word_out >> 8) | (word_out << 8);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
			e1000_shift_out_eec_bits(hw, word_out, 16);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
			widx++;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
			if ((((offset + widx) * 2) % nvm->page_size) == 0) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
				e1000_standby_nvm(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
				break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
			}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
	msleep(10);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
	nvm->ops.release_nvm(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
 *  e1000e_read_mac_addr - Read device MAC address
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
 *  Reads the device MAC address from the EEPROM and stores the value.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
 *  Since devices with two ports use the same EEPROM, we increment the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
 *  last bit in the MAC address for the second port.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
s32 e1000e_read_mac_addr(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
	u16 offset, nvm_data, i;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
	u16 mac_addr_offset = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
	if (hw->mac.type == e1000_82571) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
		/* Check for an alternate MAC address.  An alternate MAC
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
		 * address can be setup by pre-boot software and must be
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
		 * treated like a permanent address and must override the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
		 * actual permanent MAC address.*/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
		ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
					 &mac_addr_offset);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
			hw_dbg(hw, "NVM Read Error\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
		if (mac_addr_offset == 0xFFFF)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
			mac_addr_offset = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
		if (mac_addr_offset) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
			if (hw->bus.func == E1000_FUNC_1)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
				mac_addr_offset += ETH_ALEN/sizeof(u16);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
			/* make sure we have a valid mac address here
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
			* before using it */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
			ret_val = e1000_read_nvm(hw, mac_addr_offset, 1,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
						 &nvm_data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
			if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
				hw_dbg(hw, "NVM Read Error\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
				return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
			}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
			if (nvm_data & 0x0001)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
				mac_addr_offset = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
		if (mac_addr_offset)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
		hw->dev_spec.e82571.alt_mac_addr_is_present = 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
	for (i = 0; i < ETH_ALEN; i += 2) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
		offset = mac_addr_offset + (i >> 1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
		ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
			hw_dbg(hw, "NVM Read Error\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
		hw->mac.perm_addr[i] = (u8)(nvm_data & 0xFF);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
		hw->mac.perm_addr[i+1] = (u8)(nvm_data >> 8);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
	/* Flip last bit of mac address if we're on second port */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
	if (!mac_addr_offset && hw->bus.func == E1000_FUNC_1)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
		hw->mac.perm_addr[5] ^= 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
	for (i = 0; i < ETH_ALEN; i++)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
		hw->mac.addr[i] = hw->mac.perm_addr[i];
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
 *  e1000e_validate_nvm_checksum_generic - Validate EEPROM checksum
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
 *  Calculates the EEPROM checksum by reading/adding each word of the EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
 *  and then verifies that the sum of the EEPROM is equal to 0xBABA.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
	u16 checksum = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
	u16 i, nvm_data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
	for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
		ret_val = e1000_read_nvm(hw, i, 1, &nvm_data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
			hw_dbg(hw, "NVM Read Error\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
		checksum += nvm_data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
	if (checksum != (u16) NVM_SUM) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
		hw_dbg(hw, "NVM Checksum Invalid\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
		return -E1000_ERR_NVM;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
 *  e1000e_update_nvm_checksum_generic - Update EEPROM checksum
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
 *  Updates the EEPROM checksum by reading/adding each word of the EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
 *  up to the checksum.  Then calculates the EEPROM checksum and writes the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
 *  value to the EEPROM.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
	u16 checksum = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
	u16 i, nvm_data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
	for (i = 0; i < NVM_CHECKSUM_REG; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
		ret_val = e1000_read_nvm(hw, i, 1, &nvm_data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
		if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
			hw_dbg(hw, "NVM Read Error while updating checksum.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
		checksum += nvm_data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
	checksum = (u16) NVM_SUM - checksum;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
	ret_val = e1000_write_nvm(hw, NVM_CHECKSUM_REG, 1, &checksum);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
	if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
		hw_dbg(hw, "NVM Write Error while updating checksum.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
	return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
 *  e1000e_reload_nvm - Reloads EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
 *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
 *  extended control register.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
void e1000e_reload_nvm(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
	u32 ctrl_ext;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
	udelay(10);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
	ctrl_ext = er32(CTRL_EXT);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
	ctrl_ext |= E1000_CTRL_EXT_EE_RST;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
	ew32(CTRL_EXT, ctrl_ext);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
	e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
 *  e1000_calculate_checksum - Calculate checksum for buffer
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
 *  @buffer: pointer to EEPROM
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
 *  @length: size of EEPROM to calculate a checksum for
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
 *  Calculates the checksum for some buffer on a specified length.  The
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
 *  checksum calculated is returned.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
static u8 e1000_calculate_checksum(u8 *buffer, u32 length)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
	u32 i;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
	u8  sum = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
	if (!buffer)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
		return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
	for (i = 0; i < length; i++)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
		sum += buffer[i];
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
	return (u8) (0 - sum);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
 *  e1000_mng_enable_host_if - Checks host interface is enabled
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
 *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
 *  This function checks whether the HOST IF is enabled for command operation
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
 *  and also checks whether the previous command is completed.  It busy waits
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
 *  in case of previous command is not completed.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
static s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
	u32 hicr;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
	u8 i;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
	/* Check that the host interface is enabled. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
	hicr = er32(HICR);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
	if ((hicr & E1000_HICR_EN) == 0) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
		hw_dbg(hw, "E1000_HOST_EN bit disabled.\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
		return -E1000_ERR_HOST_INTERFACE_COMMAND;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
	/* check the previous command is completed */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
	for (i = 0; i < E1000_MNG_DHCP_COMMAND_TIMEOUT; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
		hicr = er32(HICR);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
		if (!(hicr & E1000_HICR_C))
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
			break;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
		mdelay(1);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
	if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
		hw_dbg(hw, "Previous command timeout failed .\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
		return -E1000_ERR_HOST_INTERFACE_COMMAND;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
 *  e1000e_check_mng_mode_generic - check management mode
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
 *  Reads the firmware semaphore register and returns true (>0) if
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
 *  manageability is enabled, else false (0).
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
bool e1000e_check_mng_mode_generic(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
	u32 fwsm = er32(FWSM);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
	return (fwsm & E1000_FWSM_MODE_MASK) ==
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
		(E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
 *  e1000e_enable_tx_pkt_filtering - Enable packet filtering on Tx
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
 *  Enables packet filtering on transmit packets if manageability is enabled
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
 *  and host interface is enabled.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
	struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
	u32 *buffer = (u32 *)&hw->mng_cookie;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
	u32 offset;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
	s32 ret_val, hdr_csum, csum;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
	u8 i, len;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
	/* No manageability, no filtering */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
	if (!e1000e_check_mng_mode(hw)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
		hw->mac.tx_pkt_filtering = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
		return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
	 * If we can't read from the host interface for whatever
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
	 * reason, disable filtering.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
	ret_val = e1000_mng_enable_host_if(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
	if (ret_val != 0) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
		hw->mac.tx_pkt_filtering = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
	/* Read in the header.  Length and offset are in dwords. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
	len    = E1000_MNG_DHCP_COOKIE_LENGTH >> 2;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
	offset = E1000_MNG_DHCP_COOKIE_OFFSET >> 2;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
	for (i = 0; i < len; i++)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
		*(buffer + i) = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF, offset + i);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
	hdr_csum = hdr->checksum;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
	hdr->checksum = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
	csum = e1000_calculate_checksum((u8 *)hdr,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
					E1000_MNG_DHCP_COOKIE_LENGTH);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
	 * If either the checksums or signature don't match, then
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
	 * the cookie area isn't considered valid, in which case we
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
	 * take the safe route of assuming Tx filtering is enabled.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
	if ((hdr_csum != csum) || (hdr->signature != E1000_IAMT_SIGNATURE)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
		hw->mac.tx_pkt_filtering = 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
		return 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
	/* Cookie area is valid, make the final check for filtering. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
	if (!(hdr->status & E1000_MNG_DHCP_COOKIE_STATUS_PARSING)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
		hw->mac.tx_pkt_filtering = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
		return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
	hw->mac.tx_pkt_filtering = 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
	return 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
 *  e1000_mng_write_cmd_header - Writes manageability command header
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
 *  @hdr: pointer to the host interface command header
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
 *  Writes the command header after does the checksum calculation.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
static s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
				  struct e1000_host_mng_command_header *hdr)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
	u16 i, length = sizeof(struct e1000_host_mng_command_header);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
	/* Write the whole command header structure with new checksum. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
	hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
	length >>= 2;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
	/* Write the relevant command block into the ram area. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
	for (i = 0; i < length; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
		E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, i,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
					    *((u32 *) hdr + i));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
		e1e_flush();
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
 *  e1000_mng_host_if_write - Writes to the manageability host interface
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
 *  @buffer: pointer to the host interface buffer
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
 *  @length: size of the buffer
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
 *  @offset: location in the buffer to write to
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
 *  @sum: sum of the data (not checksum)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
 *  This function writes the buffer content at the offset given on the host if.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
 *  It also does alignment considerations to do the writes in most efficient
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
 *  way.  Also fills up the sum of the buffer in *buffer parameter.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
static s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
				   u16 length, u16 offset, u8 *sum)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
	u8 *tmp;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
	u8 *bufptr = buffer;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
	u32 data = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
	u16 remaining, i, j, prev_bytes;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
	/* sum = only sum of the data and it is not checksum */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
	if (length == 0 || offset + length > E1000_HI_MAX_MNG_DATA_LENGTH)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
		return -E1000_ERR_PARAM;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
	tmp = (u8 *)&data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
	prev_bytes = offset & 0x3;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
	offset >>= 2;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
	if (prev_bytes) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
		data = E1000_READ_REG_ARRAY(hw, E1000_HOST_IF, offset);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
		for (j = prev_bytes; j < sizeof(u32); j++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
			*(tmp + j) = *bufptr++;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
			*sum += *(tmp + j);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
		E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset, data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
		length -= j - prev_bytes;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
		offset++;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
	remaining = length & 0x3;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
	length -= remaining;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
	/* Calculate length in DWORDs */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
	length >>= 2;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
	/*
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
	 * The device driver writes the relevant command block into the
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
	 * ram area.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
	 */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
	for (i = 0; i < length; i++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
		for (j = 0; j < sizeof(u32); j++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
			*(tmp + j) = *bufptr++;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
			*sum += *(tmp + j);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
		E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
	if (remaining) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
		for (j = 0; j < sizeof(u32); j++) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
			if (j < remaining)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
				*(tmp + j) = *bufptr++;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
			else
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
				*(tmp + j) = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
			*sum += *(tmp + j);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
		E1000_WRITE_REG_ARRAY(hw, E1000_HOST_IF, offset + i, data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
 *  e1000e_mng_write_dhcp_info - Writes DHCP info to host interface
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
 *  @buffer: pointer to the host interface
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
 *  @length: size of the buffer
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
 *  Writes the DHCP information to the host interface.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
	struct e1000_host_mng_command_header hdr;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
	u32 hicr;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
	hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
	hdr.command_length = length;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
	hdr.reserved1 = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
	hdr.reserved2 = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
	hdr.checksum = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
	/* Enable the host interface */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
	ret_val = e1000_mng_enable_host_if(hw);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
	if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
	/* Populate the host interface with the contents of "buffer". */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
	ret_val = e1000_mng_host_if_write(hw, buffer, length,
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
					  sizeof(hdr), &(hdr.checksum));
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
	if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
	/* Write the manageability command header */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
	ret_val = e1000_mng_write_cmd_header(hw, &hdr);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
	if (ret_val)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
	/* Tell the ARC a new command is pending. */
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
	hicr = er32(HICR);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
	ew32(HICR, hicr | E1000_HICR_C);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
/**
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
 *  e1000e_enable_mng_pass_thru - Enable processing of ARP's
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
 *  @hw: pointer to the HW structure
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
 *
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
 *  Verifies the hardware needs to allow ARPs to be processed by the host.
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
 **/
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
	u32 manc;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
	u32 fwsm, factps;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
	bool ret_val = 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
	manc = er32(MANC);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
	if (!(manc & E1000_MANC_RCV_TCO_EN) ||
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
	    !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
	if (hw->mac.arc_subsystem_valid) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
		fwsm = er32(FWSM);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
		factps = er32(FACTPS);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
		if (!(factps & E1000_FACTPS_MNGCG) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
		    ((fwsm & E1000_FWSM_MODE_MASK) ==
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
		     (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
			ret_val = 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
	} else {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
		if ((manc & E1000_MANC_SMBUS_EN) &&
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
		    !(manc & E1000_MANC_ASF_EN)) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
			ret_val = 1;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
			return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
		}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
	return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
s32 e1000e_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
{
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
	s32 ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
	u16 nvm_data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
	ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
	if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
		hw_dbg(hw, "NVM Read Error\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
	*pba_num = (u32)(nvm_data << 16);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
	ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
	if (ret_val) {
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
		hw_dbg(hw, "NVM Read Error\n");
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
		return ret_val;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
	}
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
	*pba_num |= nvm_data;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
	return 0;
729df853b3fb Added e1000e driver for 2.6.32.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
}