devices/e1000e/ich8lan-2.6.37-ethercat.c
author Florian Pose <fp@gh.de>
Tue, 03 May 2016 14:13:11 +0200
changeset 2642 9dc0b2262f90
parent 2239 fb6ec8610ada
permissions -rw-r--r--
Fixed endianess of EoE parameters.
2092
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2010 Intel Corporation.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 * 82562G 10/100 Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 * 82562G-2 10/100 Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 * 82562GT 10/100 Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
 * 82562GT-2 10/100 Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
 * 82562V 10/100 Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
 * 82562V-2 10/100 Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
 * 82566DC-2 Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
 * 82566DC Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
 * 82566DM-2 Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
 * 82566DM Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
 * 82566MC Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
 * 82566MM Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
 * 82567LM Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
 * 82567LF Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
 * 82567V Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
 * 82567LM-2 Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
 * 82567LF-2 Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
 * 82567V-2 Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
 * 82567LF-3 Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
 * 82567LM-3 Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
 * 82567LM-4 Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
 * 82577LM Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
 * 82577LC Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
 * 82578DM Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
 * 82578DC Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
 * 82579LM Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
 * 82579V Gigabit Network Connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
#include "e1000-2.6.37-ethercat.h"
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
#define ICH_FLASH_GFPREG		0x0000
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
#define ICH_FLASH_HSFSTS		0x0004
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
#define ICH_FLASH_HSFCTL		0x0006
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
#define ICH_FLASH_FADDR			0x0008
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
#define ICH_FLASH_FDATA0		0x0010
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
#define ICH_FLASH_PR0			0x0074
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
#define ICH_FLASH_READ_COMMAND_TIMEOUT	500
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
#define ICH_FLASH_WRITE_COMMAND_TIMEOUT	500
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
#define ICH_FLASH_ERASE_COMMAND_TIMEOUT	3000000
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
#define ICH_FLASH_LINEAR_ADDR_MASK	0x00FFFFFF
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
#define ICH_FLASH_CYCLE_REPEAT_COUNT	10
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
#define ICH_CYCLE_READ			0
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
#define ICH_CYCLE_WRITE			2
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
#define ICH_CYCLE_ERASE			3
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
#define FLASH_GFPREG_BASE_MASK		0x1FFF
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
#define FLASH_SECTOR_ADDR_SHIFT		12
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
#define ICH_FLASH_SEG_SIZE_256		256
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
#define ICH_FLASH_SEG_SIZE_4K		4096
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
#define ICH_FLASH_SEG_SIZE_8K		8192
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
#define ICH_FLASH_SEG_SIZE_64K		65536
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
#define E1000_ICH_FWSM_RSPCIPHY	0x00000040 /* Reset PHY on PCI Reset */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
/* FW established a valid mode */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
#define E1000_ICH_FWSM_FW_VALID		0x00008000
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
#define E1000_ICH_MNG_IAMT_MODE		0x2
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
#define ID_LED_DEFAULT_ICH8LAN  ((ID_LED_DEF1_DEF2 << 12) | \
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
				 (ID_LED_DEF1_OFF2 <<  8) | \
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
				 (ID_LED_DEF1_ON2  <<  4) | \
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
				 (ID_LED_DEF1_DEF2))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
#define E1000_ICH_NVM_SIG_WORD		0x13
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
#define E1000_ICH_NVM_SIG_MASK		0xC000
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
#define E1000_ICH_NVM_VALID_SIG_MASK    0xC0
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
#define E1000_ICH_NVM_SIG_VALUE         0x80
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
#define E1000_ICH8_LAN_INIT_TIMEOUT	1500
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
#define E1000_FEXTNVM_SW_CONFIG		1
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
#define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
#define E1000_FEXTNVM4_BEACON_DURATION_MASK    0x7
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
#define E1000_FEXTNVM4_BEACON_DURATION_8USEC   0x7
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
#define E1000_FEXTNVM4_BEACON_DURATION_16USEC  0x3
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
#define PCIE_ICH8_SNOOP_ALL		PCIE_NO_SNOOP_ALL
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
#define E1000_ICH_RAR_ENTRIES		7
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
#define PHY_PAGE_SHIFT 5
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
#define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
			   ((reg) & MAX_PHY_REG_ADDRESS))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
#define IGP3_KMRN_DIAG  PHY_REG(770, 19) /* KMRN Diagnostic */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
#define IGP3_VR_CTRL    PHY_REG(776, 18) /* Voltage Regulator Control */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
#define IGP3_KMRN_DIAG_PCS_LOCK_LOSS	0x0002
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
#define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
#define IGP3_VR_CTRL_MODE_SHUTDOWN	0x0200
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
#define HV_LED_CONFIG		PHY_REG(768, 30) /* LED Configuration */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
#define SW_FLAG_TIMEOUT    1000 /* SW Semaphore flag timeout in milliseconds */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
/* SMBus Address Phy Register */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
#define HV_SMB_ADDR            PHY_REG(768, 26)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
#define HV_SMB_ADDR_MASK       0x007F
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
#define HV_SMB_ADDR_PEC_EN     0x0200
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
#define HV_SMB_ADDR_VALID      0x0080
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
/* PHY Power Management Control */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
#define HV_PM_CTRL		PHY_REG(770, 17)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
/* PHY Low Power Idle Control */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
#define I82579_LPI_CTRL			PHY_REG(772, 20)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
#define I82579_LPI_CTRL_ENABLE_MASK	0x6000
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
/* Strapping Option Register - RO */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
#define E1000_STRAP                     0x0000C
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
#define E1000_STRAP_SMBUS_ADDRESS_MASK  0x00FE0000
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
#define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
/* OEM Bits Phy Register */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
#define HV_OEM_BITS            PHY_REG(768, 25)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
#define HV_OEM_BITS_LPLU       0x0004 /* Low Power Link Up */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
#define HV_OEM_BITS_GBE_DIS    0x0040 /* Gigabit Disable */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
#define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
#define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
#define E1000_NVM_K1_ENABLE 0x1  /* NVM Enable K1 bit */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
/* KMRN Mode Control */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
#define HV_KMRN_MODE_CTRL      PHY_REG(769, 16)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
#define HV_KMRN_MDIO_SLOW      0x0400
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
/* Offset 04h HSFSTS */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
union ich8_hws_flash_status {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
	struct ich8_hsfsts {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
		u16 flcdone    :1; /* bit 0 Flash Cycle Done */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
		u16 flcerr     :1; /* bit 1 Flash Cycle Error */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
		u16 dael       :1; /* bit 2 Direct Access error Log */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
		u16 berasesz   :2; /* bit 4:3 Sector Erase Size */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
		u16 flcinprog  :1; /* bit 5 flash cycle in Progress */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
		u16 reserved1  :2; /* bit 13:6 Reserved */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
		u16 reserved2  :6; /* bit 13:6 Reserved */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
		u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
		u16 flockdn    :1; /* bit 15 Flash Config Lock-Down */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
	} hsf_status;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
	u16 regval;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
/* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
/* Offset 06h FLCTL */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
union ich8_hws_flash_ctrl {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
	struct ich8_hsflctl {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
		u16 flcgo      :1;   /* 0 Flash Cycle Go */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
		u16 flcycle    :2;   /* 2:1 Flash Cycle */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
		u16 reserved   :5;   /* 7:3 Reserved  */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
		u16 fldbcount  :2;   /* 9:8 Flash Data Byte Count */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
		u16 flockdn    :6;   /* 15:10 Reserved */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
	} hsf_ctrl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
	u16 regval;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
/* ICH Flash Region Access Permissions */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
union ich8_hws_flash_regacc {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
	struct ich8_flracc {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
		u32 grra      :8; /* 0:7 GbE region Read Access */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
		u32 grwa      :8; /* 8:15 GbE region Write Access */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
		u32 gmrag     :8; /* 23:16 GbE Master Read Access Grant */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
		u32 gmwag     :8; /* 31:24 GbE Master Write Access Grant */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
	} hsf_flregacc;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
	u16 regval;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
/* ICH Flash Protected Region */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
union ich8_flash_protected_range {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
	struct ich8_pr {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
		u32 base:13;     /* 0:12 Protected Range Base */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
		u32 reserved1:2; /* 13:14 Reserved */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
		u32 rpe:1;       /* 15 Read Protection Enable */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
		u32 limit:13;    /* 16:28 Protected Range Limit */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
		u32 reserved2:2; /* 29:30 Reserved */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
		u32 wpe:1;       /* 31 Write Protection Enable */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
	} range;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
	u32 regval;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
						u32 offset, u8 byte);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
					 u8 *data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
					 u16 *data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
					 u8 size, u16 *data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
static s32  e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
static s32 e1000_k1_workaround_lv(struct e1000_hw *hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
	return readw(hw->flash_address + reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
	return readl(hw->flash_address + reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
	writew(val, hw->flash_address + reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
	writel(val, hw->flash_address + reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
#define er16flash(reg)		__er16flash(hw, (reg))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
#define er32flash(reg)		__er32flash(hw, (reg))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
#define ew16flash(reg,val)	__ew16flash(hw, (reg), (val))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
#define ew32flash(reg,val)	__ew32flash(hw, (reg), (val))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
 *  e1000_init_phy_params_pchlan - Initialize PHY function pointers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
 *  Initialize family-specific PHY parameters and function pointers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
	struct e1000_phy_info *phy = &hw->phy;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
	u32 ctrl, fwsm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
	phy->addr                     = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
	phy->reset_delay_us           = 100;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
	phy->ops.read_reg             = e1000_read_phy_reg_hv;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
	phy->ops.read_reg_locked      = e1000_read_phy_reg_hv_locked;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
	phy->ops.set_d0_lplu_state    = e1000_set_lplu_state_pchlan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
	phy->ops.set_d3_lplu_state    = e1000_set_lplu_state_pchlan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
	phy->ops.write_reg            = e1000_write_phy_reg_hv;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
	phy->ops.write_reg_locked     = e1000_write_phy_reg_hv_locked;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
	phy->ops.power_up             = e1000_power_up_phy_copper;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
	phy->ops.power_down           = e1000_power_down_phy_copper_ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
	phy->autoneg_mask             = AUTONEG_ADVERTISE_SPEED_DEFAULT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
	 * The MAC-PHY interconnect may still be in SMBus mode
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
	 * after Sx->S0.  If the manageability engine (ME) is
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
	 * disabled, then toggle the LANPHYPC Value bit to force
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
	 * the interconnect to PCIe mode.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
	fwsm = er32(FWSM);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
	if (!(fwsm & E1000_ICH_FWSM_FW_VALID)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
		ctrl = er32(CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
		ctrl |=  E1000_CTRL_LANPHYPC_OVERRIDE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
		ctrl &= ~E1000_CTRL_LANPHYPC_VALUE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
		ew32(CTRL, ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
		udelay(10);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
		ctrl &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
		ew32(CTRL, ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
		msleep(50);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
		 * Gate automatic PHY configuration by hardware on
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
		 * non-managed 82579
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
		if (hw->mac.type == e1000_pch2lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
			e1000_gate_hw_phy_config_ich8lan(hw, true);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
	 * Reset the PHY before any acccess to it.  Doing so, ensures that
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
	 * the PHY is in a known good state before we read/write PHY registers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
	 * The generic reset is sufficient here, because we haven't determined
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	 * the PHY type yet.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
	ret_val = e1000e_phy_hw_reset_generic(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
	/* Ungate automatic PHY configuration on non-managed 82579 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
	if ((hw->mac.type == e1000_pch2lan)  &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
	    !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
		msleep(10);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
		e1000_gate_hw_phy_config_ich8lan(hw, false);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
	phy->id = e1000_phy_unknown;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
	switch (hw->mac.type) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
		ret_val = e1000e_get_phy_id(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
		if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
		/* fall-through */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
	case e1000_pch2lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
		 * In case the PHY needs to be in mdio slow mode,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
		 * set slow mode and try to get the PHY id again.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
		ret_val = e1000_set_mdio_slow_mode_hv(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
		ret_val = e1000e_get_phy_id(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
	phy->type = e1000e_get_phy_type_from_id(phy->id);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
	switch (phy->type) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
	case e1000_phy_82577:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
	case e1000_phy_82579:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
		phy->ops.check_polarity = e1000_check_polarity_82577;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
		phy->ops.force_speed_duplex =
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
			e1000_phy_force_speed_duplex_82577;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
		phy->ops.get_cable_length = e1000_get_cable_length_82577;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
		phy->ops.get_info = e1000_get_phy_info_82577;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
		phy->ops.commit = e1000e_phy_sw_reset;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
	case e1000_phy_82578:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
		phy->ops.check_polarity = e1000_check_polarity_m88;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
		phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
		phy->ops.get_cable_length = e1000e_get_cable_length_m88;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
		phy->ops.get_info = e1000e_get_phy_info_m88;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
		ret_val = -E1000_ERR_PHY;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
 *  e1000_init_phy_params_ich8lan - Initialize PHY function pointers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
 *  Initialize family-specific PHY parameters and function pointers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
	struct e1000_phy_info *phy = &hw->phy;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
	u16 i = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
	phy->addr			= 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
	phy->reset_delay_us		= 100;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
	phy->ops.power_up               = e1000_power_up_phy_copper;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
	phy->ops.power_down             = e1000_power_down_phy_copper_ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
	 * We may need to do this twice - once for IGP and if that fails,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
	 * we'll set BM func pointers and try again
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
	ret_val = e1000e_determine_phy_address(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
	if (ret_val) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
		phy->ops.write_reg = e1000e_write_phy_reg_bm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
		phy->ops.read_reg  = e1000e_read_phy_reg_bm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
		ret_val = e1000e_determine_phy_address(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
		if (ret_val) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
			e_dbg("Cannot determine PHY addr. Erroring out\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
	phy->id = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
	while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
	       (i++ < 100)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
		msleep(1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
		ret_val = e1000e_get_phy_id(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
	/* Verify phy id */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
	switch (phy->id) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
	case IGP03E1000_E_PHY_ID:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
		phy->type = e1000_phy_igp_3;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
		phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
		phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
		phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
		phy->ops.get_info = e1000e_get_phy_info_igp;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
		phy->ops.check_polarity = e1000_check_polarity_igp;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
		phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
	case IFE_E_PHY_ID:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
	case IFE_PLUS_E_PHY_ID:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
	case IFE_C_E_PHY_ID:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
		phy->type = e1000_phy_ife;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
		phy->autoneg_mask = E1000_ALL_NOT_GIG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
		phy->ops.get_info = e1000_get_phy_info_ife;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
		phy->ops.check_polarity = e1000_check_polarity_ife;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
		phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
	case BME1000_E_PHY_ID:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
		phy->type = e1000_phy_bm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
		phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
		phy->ops.read_reg = e1000e_read_phy_reg_bm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
		phy->ops.write_reg = e1000e_write_phy_reg_bm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
		phy->ops.commit = e1000e_phy_sw_reset;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
		phy->ops.get_info = e1000e_get_phy_info_m88;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
		phy->ops.check_polarity = e1000_check_polarity_m88;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
		phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
		return -E1000_ERR_PHY;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
 *  e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
 *  Initialize family-specific NVM parameters and function
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
 *  pointers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
	struct e1000_nvm_info *nvm = &hw->nvm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
	struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
	u32 gfpreg, sector_base_addr, sector_end_addr;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
	u16 i;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
	/* Can't read flash registers if the register set isn't mapped. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
	if (!hw->flash_address) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
		e_dbg("ERROR: Flash registers not mapped\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
		return -E1000_ERR_CONFIG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
	nvm->type = e1000_nvm_flash_sw;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
	gfpreg = er32flash(ICH_FLASH_GFPREG);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
	 * sector_X_addr is a "sector"-aligned address (4096 bytes)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
	 * Add 1 to sector_end_addr since this sector is included in
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
	 * the overall size.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
	sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
	sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
	/* flash_base_addr is byte-aligned */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
	nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
	 * find total size of the NVM, then cut in half since the total
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
	 * size represents two separate NVM banks.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
	nvm->flash_bank_size = (sector_end_addr - sector_base_addr)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
				<< FLASH_SECTOR_ADDR_SHIFT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
	nvm->flash_bank_size /= 2;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
	/* Adjust to word count */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
	nvm->flash_bank_size /= sizeof(u16);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
	nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
	/* Clear shadow ram */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
	for (i = 0; i < nvm->word_size; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
		dev_spec->shadow_ram[i].modified = false;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
		dev_spec->shadow_ram[i].value    = 0xFFFF;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
 *  e1000_init_mac_params_ich8lan - Initialize MAC function pointers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
 *  Initialize family-specific MAC parameters and function
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
 *  pointers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
	struct e1000_hw *hw = &adapter->hw;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
	struct e1000_mac_info *mac = &hw->mac;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
	/* Set media type function pointer */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
	hw->phy.media_type = e1000_media_type_copper;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
	/* Set mta register count */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
	mac->mta_reg_count = 32;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
	/* Set rar entry count */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
	mac->rar_entry_count = E1000_ICH_RAR_ENTRIES;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
	if (mac->type == e1000_ich8lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
		mac->rar_entry_count--;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
	/* FWSM register */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
	mac->has_fwsm = true;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
	/* ARC subsystem not supported */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
	mac->arc_subsystem_valid = false;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
	/* Adaptive IFS supported */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
	mac->adaptive_ifs = true;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
	/* LED operations */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
	switch (mac->type) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
	case e1000_ich8lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
	case e1000_ich9lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
	case e1000_ich10lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
		/* check management mode */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
		mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
		/* ID LED init */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
		mac->ops.id_led_init = e1000e_id_led_init;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
		/* setup LED */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
		mac->ops.setup_led = e1000e_setup_led_generic;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
		/* cleanup LED */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
		mac->ops.cleanup_led = e1000_cleanup_led_ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
		/* turn on/off LED */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
		mac->ops.led_on = e1000_led_on_ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
		mac->ops.led_off = e1000_led_off_ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
	case e1000_pchlan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
	case e1000_pch2lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
		/* check management mode */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
		mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
		/* ID LED init */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
		mac->ops.id_led_init = e1000_id_led_init_pchlan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
		/* setup LED */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
		mac->ops.setup_led = e1000_setup_led_pchlan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
		/* cleanup LED */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
		mac->ops.cleanup_led = e1000_cleanup_led_pchlan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
		/* turn on/off LED */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
		mac->ops.led_on = e1000_led_on_pchlan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
		mac->ops.led_off = e1000_led_off_pchlan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
	/* Enable PCS Lock-loss workaround for ICH8 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
	if (mac->type == e1000_ich8lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
		e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
	/* Gate automatic PHY configuration by hardware on managed 82579 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
	if ((mac->type == e1000_pch2lan) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
	    (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
		e1000_gate_hw_phy_config_ich8lan(hw, true);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
 *  e1000_set_eee_pchlan - Enable/disable EEE support
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
 *  Enable/disable EEE based on setting in dev_spec structure.  The bits in
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
 *  the LPI Control register will remain set only if/when link is up.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
static s32 e1000_set_eee_pchlan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
	u16 phy_reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
	if (hw->phy.type != e1000_phy_82579)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
	ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
	if (hw->dev_spec.ich8lan.eee_disable)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
		phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
	else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
		phy_reg |= I82579_LPI_CTRL_ENABLE_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
	ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
 *  e1000_check_for_copper_link_ich8lan - Check for link (Copper)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
 *  Checks to see of the link status of the hardware has changed.  If a
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
 *  change in link status has been detected, then we read the PHY registers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
 *  to get the current speed/duplex if link exists.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
	struct e1000_mac_info *mac = &hw->mac;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
	bool link;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
	 * We only want to go out to the PHY registers to see if Auto-Neg
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
	 * has completed and/or if our link status has changed.  The
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
	 * get_link_status flag is set upon receiving a Link Status
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
	 * Change or Rx Sequence Error interrupt.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
	if (!mac->get_link_status) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
		ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
	 * First we want to see if the MII Status Register reports
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
	 * link.  If so, then we want to get the current speed/duplex
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	 * of the PHY.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
	ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
	if (hw->mac.type == e1000_pchlan) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
		ret_val = e1000_k1_gig_workaround_hv(hw, link);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
	if (!link)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
		goto out; /* No link detected */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
	mac->get_link_status = false;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
	if (hw->phy.type == e1000_phy_82578) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
		ret_val = e1000_link_stall_workaround_hv(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
	if (hw->mac.type == e1000_pch2lan) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
		ret_val = e1000_k1_workaround_lv(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
	 * Check if there was DownShift, must be checked
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
	 * immediately after link-up
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
	e1000e_check_downshift(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
	/* Enable/Disable EEE after link up */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
	ret_val = e1000_set_eee_pchlan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
	 * If we are forcing speed/duplex, then we simply return since
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
	 * we have already determined whether we have link or not.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
	if (!mac->autoneg) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
		ret_val = -E1000_ERR_CONFIG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
	 * Auto-Neg is enabled.  Auto Speed Detection takes care
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
	 * of MAC speed/duplex configuration.  So we only need to
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
	 * configure Collision Distance in the MAC.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
	e1000e_config_collision_dist(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
	 * Configure Flow Control now that Auto-Neg has completed.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
	 * First, we need to restore the desired flow control
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
	 * settings because we may have had to re-autoneg with a
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
	 * different link partner.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
	ret_val = e1000e_config_fc_after_link_up(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
		e_dbg("Error configuring flow control\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
	struct e1000_hw *hw = &adapter->hw;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
	s32 rc;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
	rc = e1000_init_mac_params_ich8lan(adapter);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
	if (rc)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
		return rc;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
	rc = e1000_init_nvm_params_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
	if (rc)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
		return rc;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
	switch (hw->mac.type) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
	case e1000_ich8lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
	case e1000_ich9lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
	case e1000_ich10lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
		rc = e1000_init_phy_params_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
	case e1000_pchlan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
	case e1000_pch2lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
		rc = e1000_init_phy_params_pchlan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
	if (rc)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
		return rc;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
	if (adapter->hw.phy.type == e1000_phy_ife) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
		adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
		adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
	if ((adapter->hw.mac.type == e1000_ich8lan) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
	    (adapter->hw.phy.type == e1000_phy_igp_3))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
		adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
	/* Disable EEE by default until IEEE802.3az spec is finalized */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
	if (adapter->flags2 & FLAG2_HAS_EEE)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
		adapter->hw.dev_spec.ich8lan.eee_disable = true;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
static DEFINE_MUTEX(nvm_mutex);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
 *  e1000_acquire_nvm_ich8lan - Acquire NVM mutex
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
 *  Acquires the mutex for performing NVM operations.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
	mutex_lock(&nvm_mutex);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
 *  e1000_release_nvm_ich8lan - Release NVM mutex
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
 *  Releases the mutex used while performing NVM operations.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
static void e1000_release_nvm_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
	mutex_unlock(&nvm_mutex);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
static DEFINE_MUTEX(swflag_mutex);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
 *  e1000_acquire_swflag_ich8lan - Acquire software control flag
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
 *  Acquires the software control flag for performing PHY and select
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
 *  MAC CSR accesses.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
	u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
	mutex_lock(&swflag_mutex);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
	while (timeout) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
		extcnf_ctrl = er32(EXTCNF_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
		if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
		mdelay(1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
		timeout--;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
	if (!timeout) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
		e_dbg("SW/FW/HW has locked the resource for too long.\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
		ret_val = -E1000_ERR_CONFIG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
	timeout = SW_FLAG_TIMEOUT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
	extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
	ew32(EXTCNF_CTRL, extcnf_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
	while (timeout) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
		extcnf_ctrl = er32(EXTCNF_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
		if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
		mdelay(1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
		timeout--;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	if (!timeout) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
		e_dbg("Failed to acquire the semaphore.\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
		extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
		ew32(EXTCNF_CTRL, extcnf_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
		ret_val = -E1000_ERR_CONFIG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
		mutex_unlock(&swflag_mutex);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
 *  e1000_release_swflag_ich8lan - Release software control flag
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
 *  Releases the software control flag for performing PHY and select
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
 *  MAC CSR accesses.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
	u32 extcnf_ctrl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
	extcnf_ctrl = er32(EXTCNF_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
	extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
	ew32(EXTCNF_CTRL, extcnf_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
	mutex_unlock(&swflag_mutex);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
 *  e1000_check_mng_mode_ich8lan - Checks management mode
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
 *  This checks if the adapter has any manageability enabled.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
 *  This is a function pointer entry point only called by read/write
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
 *  routines for the PHY and NVM parts.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
	u32 fwsm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
	fwsm = er32(FWSM);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
	return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
	       ((fwsm & E1000_FWSM_MODE_MASK) ==
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
		(E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
 *  e1000_check_mng_mode_pchlan - Checks management mode
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
 *  This checks if the adapter has iAMT enabled.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
 *  This is a function pointer entry point only called by read/write
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
 *  routines for the PHY and NVM parts.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
	u32 fwsm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
	fwsm = er32(FWSM);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
	return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
	       (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
 *  e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
 *  Checks if firmware is blocking the reset of the PHY.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
 *  This is a function pointer entry point only called by
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
 *  reset routines.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
	u32 fwsm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
	fwsm = er32(FWSM);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
	return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
 *  e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
 *  Assumes semaphore already acquired.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
static s32 e1000_write_smbus_addr(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
	u16 phy_data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
	u32 strap = er32(STRAP);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
	strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
	ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
	phy_data &= ~HV_SMB_ADDR_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
	phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
	phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
	ret_val = e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
 *  e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
 *  @hw:   pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
 *  SW should configure the LCD from the NVM extended configuration region
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
 *  as a workaround for certain parts.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
	struct e1000_phy_info *phy = &hw->phy;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
	u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
	u16 word_addr, reg_data, reg_addr, phy_page = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
	 * Initialize the PHY from the NVM on ICH platforms.  This
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
	 * is needed due to an issue where the NVM configuration is
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
	 * not properly autoloaded after power transitions.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
	 * Therefore, after each PHY reset, we will load the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
	 * configuration data out of the NVM manually.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
	switch (hw->mac.type) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
	case e1000_ich8lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
		if (phy->type != e1000_phy_igp_3)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
		if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
		    (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
			sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
		/* Fall-thru */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
	case e1000_pchlan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
	case e1000_pch2lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
		sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
	ret_val = hw->phy.ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	data = er32(FEXTNVM);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
	if (!(data & sw_cfg_mask))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
	 * Make sure HW does not configure LCD from PHY
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
	 * extended configuration before SW configuration
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
	data = er32(EXTCNF_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
	if (!(hw->mac.type == e1000_pch2lan)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
		if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
	cnf_size = er32(EXTCNF_SIZE);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
	cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
	cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
	if (!cnf_size)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
	cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
	cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
	if ((!(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	    (hw->mac.type == e1000_pchlan)) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
	     (hw->mac.type == e1000_pch2lan)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
		 * HW configures the SMBus address and LEDs when the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
		 * OEM and LCD Write Enable bits are set in the NVM.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
		 * When both NVM bits are cleared, SW will configure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		 * them instead.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
		ret_val = e1000_write_smbus_addr(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
		data = er32(LEDCTL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
		ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
							(u16)data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
	/* Configure LCD from extended configuration region. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
	/* cnf_base_addr is in DWORD */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
	word_addr = (u16)(cnf_base_addr << 1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
	for (i = 0; i < cnf_size; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
		ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
					 &reg_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
		ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1),
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
					 1, &reg_addr);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
		/* Save off the PHY page for future writes. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
		if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
			phy_page = reg_data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
			continue;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
		reg_addr &= PHY_REG_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
		reg_addr |= phy_page;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
		ret_val = phy->ops.write_reg_locked(hw, (u32)reg_addr,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
						    reg_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
	hw->phy.ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
 *  e1000_k1_gig_workaround_hv - K1 Si workaround
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
 *  @hw:   pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
 *  @link: link up bool flag
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
 *  If K1 is enabled for 1Gbps, the MAC might stall when transitioning
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
 *  from a lower speed.  This workaround disables K1 whenever link is at 1Gig
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
 *  If link is down, the function will restore the default K1 setting located
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
 *  in the NVM.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
	u16 status_reg = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
	bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
	if (hw->mac.type != e1000_pchlan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
	/* Wrap the whole flow with the sw flag */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
	ret_val = hw->phy.ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
	/* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
	if (link) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
		if (hw->phy.type == e1000_phy_82578) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
			ret_val = hw->phy.ops.read_reg_locked(hw, BM_CS_STATUS,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
			                                          &status_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
				goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
			status_reg &= BM_CS_STATUS_LINK_UP |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
			              BM_CS_STATUS_RESOLVED |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
			              BM_CS_STATUS_SPEED_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
			if (status_reg == (BM_CS_STATUS_LINK_UP |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
			                   BM_CS_STATUS_RESOLVED |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
			                   BM_CS_STATUS_SPEED_1000))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
				k1_enable = false;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
		if (hw->phy.type == e1000_phy_82577) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
			ret_val = hw->phy.ops.read_reg_locked(hw, HV_M_STATUS,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
			                                          &status_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
				goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
			status_reg &= HV_M_STATUS_LINK_UP |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
			              HV_M_STATUS_AUTONEG_COMPLETE |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
			              HV_M_STATUS_SPEED_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
			if (status_reg == (HV_M_STATUS_LINK_UP |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
			                   HV_M_STATUS_AUTONEG_COMPLETE |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
			                   HV_M_STATUS_SPEED_1000))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
				k1_enable = false;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
		/* Link stall fix for link up */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
		ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
		                                           0x0100);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
			goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
	} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
		/* Link stall fix for link down */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
		ret_val = hw->phy.ops.write_reg_locked(hw, PHY_REG(770, 19),
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
		                                           0x4100);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
			goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
	ret_val = e1000_configure_k1_ich8lan(hw, k1_enable);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
release:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
	hw->phy.ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
 *  e1000_configure_k1_ich8lan - Configure K1 power state
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
 *  @enable: K1 state to configure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
 *  Configure the K1 power state based on the provided parameter.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
 *  Assumes semaphore already acquired.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
 *  Success returns 0, Failure returns -E1000_ERR_PHY (-2)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
	u32 ctrl_reg = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
	u32 ctrl_ext = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
	u32 reg = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
	u16 kmrn_reg = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
	ret_val = e1000e_read_kmrn_reg_locked(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
	                                     E1000_KMRNCTRLSTA_K1_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
	                                     &kmrn_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
	if (k1_enable)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
		kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
	else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
		kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
	ret_val = e1000e_write_kmrn_reg_locked(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
	                                      E1000_KMRNCTRLSTA_K1_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
	                                      kmrn_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
	udelay(20);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
	ctrl_ext = er32(CTRL_EXT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
	ctrl_reg = er32(CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
	reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
	reg |= E1000_CTRL_FRCSPD;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
	ew32(CTRL, reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
	ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
	udelay(20);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
	ew32(CTRL, ctrl_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
	ew32(CTRL_EXT, ctrl_ext);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
	udelay(20);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
 *  e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
 *  @hw:       pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
 *  @d0_state: boolean if entering d0 or d3 device state
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
 *  SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
 *  collectively called OEM bits.  The OEM Write Enable bit and SW Config bit
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
 *  in NVM determines whether HW should configure LPLU and Gbe Disable.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
	u32 mac_reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
	u16 oem_reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
	if ((hw->mac.type != e1000_pch2lan) && (hw->mac.type != e1000_pchlan))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
	ret_val = hw->phy.ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
	if (!(hw->mac.type == e1000_pch2lan)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
		mac_reg = er32(EXTCNF_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
		if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
	mac_reg = er32(FEXTNVM);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
	if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
	mac_reg = er32(PHY_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
	ret_val = hw->phy.ops.read_reg_locked(hw, HV_OEM_BITS, &oem_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
	oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
	if (d0_state) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
		if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
			oem_reg |= HV_OEM_BITS_GBE_DIS;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
		if (mac_reg & E1000_PHY_CTRL_D0A_LPLU)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
			oem_reg |= HV_OEM_BITS_LPLU;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
	} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
		if (mac_reg & E1000_PHY_CTRL_NOND0A_GBE_DISABLE)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
			oem_reg |= HV_OEM_BITS_GBE_DIS;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
		if (mac_reg & E1000_PHY_CTRL_NOND0A_LPLU)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
			oem_reg |= HV_OEM_BITS_LPLU;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
	/* Restart auto-neg to activate the bits */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
	if (!e1000_check_reset_block(hw))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
		oem_reg |= HV_OEM_BITS_RESTART_AN;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
	ret_val = hw->phy.ops.write_reg_locked(hw, HV_OEM_BITS, oem_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
	hw->phy.ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
 *  e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
 *  @hw:   pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
	u16 data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
	ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
	data |= HV_KMRN_MDIO_SLOW;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
	ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
 *  e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
 *  done after every PHY reset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
	u16 phy_data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
	if (hw->mac.type != e1000_pchlan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
	/* Set MDIO slow mode before any other MDIO access */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	if (hw->phy.type == e1000_phy_82577) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
		ret_val = e1000_set_mdio_slow_mode_hv(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
	if (((hw->phy.type == e1000_phy_82577) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
	     ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
	    ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
		/* Disable generation of early preamble */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
		ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
		/* Preamble tuning for SSC */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
		ret_val = e1e_wphy(hw, PHY_REG(770, 16), 0xA204);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
	if (hw->phy.type == e1000_phy_82578) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
		 * Return registers to default by doing a soft reset then
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
		 * writing 0x3140 to the control register.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
		if (hw->phy.revision < 2) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
			e1000e_phy_sw_reset(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
			ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
	/* Select page 0 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
	ret_val = hw->phy.ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
	hw->phy.addr = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
	ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
	hw->phy.ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
	 * Configure the K1 Si workaround during phy reset assuming there is
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
	 * link so that it disables K1 if link is in 1Gbps.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
	ret_val = e1000_k1_gig_workaround_hv(hw, true);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
	/* Workaround for link disconnects on a busy hub in half duplex */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
	ret_val = hw->phy.ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
	ret_val = hw->phy.ops.read_reg_locked(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
	                                      PHY_REG(BM_PORT_CTRL_PAGE, 17),
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
	                                      &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
		goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
	ret_val = hw->phy.ops.write_reg_locked(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	                                       PHY_REG(BM_PORT_CTRL_PAGE, 17),
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
	                                       phy_data & 0x00FF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
release:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	hw->phy.ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
 *  e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
 *  @hw:   pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
	u32 mac_reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
	u16 i;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
	/* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
	for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
		mac_reg = er32(RAL(i));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
		e1e_wphy(hw, BM_RAR_L(i), (u16)(mac_reg & 0xFFFF));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
		e1e_wphy(hw, BM_RAR_M(i), (u16)((mac_reg >> 16) & 0xFFFF));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
		mac_reg = er32(RAH(i));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
		e1e_wphy(hw, BM_RAR_H(i), (u16)(mac_reg & 0xFFFF));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
		e1e_wphy(hw, BM_RAR_CTRL(i), (u16)((mac_reg >> 16) & 0x8000));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
static u32 e1000_calc_rx_da_crc(u8 mac[])
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
	u32 poly = 0xEDB88320;	/* Polynomial for 802.3 CRC calculation */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	u32 i, j, mask, crc;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
	crc = 0xffffffff;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	for (i = 0; i < 6; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
		crc = crc ^ mac[i];
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
		for (j = 8; j > 0; j--) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
			mask = (crc & 1) * (-1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
			crc = (crc >> 1) ^ (poly & mask);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
	return ~crc;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
 *  e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
 *  with 82579 PHY
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
 *  @enable: flag to enable/disable workaround when enabling/disabling jumbos
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
	u16 phy_reg, data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
	u32 mac_reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
	u16 i;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
	if (hw->mac.type != e1000_pch2lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
	/* disable Rx path while enabling/disabling workaround */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
	e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
	ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
	if (enable) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
		 * Write Rx addresses (rar_entry_count for RAL/H, +4 for
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
		 * SHRAL/H) and initial CRC values to the MAC
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
		for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
			u8 mac_addr[ETH_ALEN] = {0};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
			u32 addr_high, addr_low;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
			addr_high = er32(RAH(i));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
			if (!(addr_high & E1000_RAH_AV))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
				continue;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
			addr_low = er32(RAL(i));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
			mac_addr[0] = (addr_low & 0xFF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
			mac_addr[1] = ((addr_low >> 8) & 0xFF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
			mac_addr[2] = ((addr_low >> 16) & 0xFF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
			mac_addr[3] = ((addr_low >> 24) & 0xFF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
			mac_addr[4] = (addr_high & 0xFF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
			mac_addr[5] = ((addr_high >> 8) & 0xFF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
			ew32(PCH_RAICC(i),
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
					e1000_calc_rx_da_crc(mac_addr));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
		/* Write Rx addresses to the PHY */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
		e1000_copy_rx_addrs_to_phy_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
		/* Enable jumbo frame workaround in the MAC */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
		mac_reg = er32(FFLT_DBG);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
		mac_reg &= ~(1 << 14);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
		mac_reg |= (7 << 15);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
		ew32(FFLT_DBG, mac_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
		mac_reg = er32(RCTL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
		mac_reg |= E1000_RCTL_SECRC;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
		ew32(RCTL, mac_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
		ret_val = e1000e_read_kmrn_reg(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
						E1000_KMRNCTRLSTA_CTRL_OFFSET,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
						&data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
		ret_val = e1000e_write_kmrn_reg(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
						E1000_KMRNCTRLSTA_CTRL_OFFSET,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
						data | (1 << 0));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
		ret_val = e1000e_read_kmrn_reg(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
						E1000_KMRNCTRLSTA_HD_CTRL,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
						&data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
		data &= ~(0xF << 8);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
		data |= (0xB << 8);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
		ret_val = e1000e_write_kmrn_reg(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
						E1000_KMRNCTRLSTA_HD_CTRL,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
						data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
		/* Enable jumbo frame workaround in the PHY */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
		e1e_rphy(hw, PHY_REG(769, 23), &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
		data &= ~(0x7F << 5);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
		data |= (0x37 << 5);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
		ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
		e1e_rphy(hw, PHY_REG(769, 16), &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
		data &= ~(1 << 13);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
		ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
		e1e_rphy(hw, PHY_REG(776, 20), &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
		data &= ~(0x3FF << 2);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
		data |= (0x1A << 2);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
		ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
		ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xFE00);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
		e1e_rphy(hw, HV_PM_CTRL, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
		ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
	} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
		/* Write MAC register values back to h/w defaults */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
		mac_reg = er32(FFLT_DBG);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
		mac_reg &= ~(0xF << 14);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
		ew32(FFLT_DBG, mac_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
		mac_reg = er32(RCTL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
		mac_reg &= ~E1000_RCTL_SECRC;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
		ew32(RCTL, mac_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
		ret_val = e1000e_read_kmrn_reg(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
						E1000_KMRNCTRLSTA_CTRL_OFFSET,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
						&data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
		ret_val = e1000e_write_kmrn_reg(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
						E1000_KMRNCTRLSTA_CTRL_OFFSET,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
						data & ~(1 << 0));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
		ret_val = e1000e_read_kmrn_reg(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
						E1000_KMRNCTRLSTA_HD_CTRL,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
						&data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
		data &= ~(0xF << 8);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
		data |= (0xB << 8);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
		ret_val = e1000e_write_kmrn_reg(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
						E1000_KMRNCTRLSTA_HD_CTRL,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
						data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
		/* Write PHY register values back to h/w defaults */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
		e1e_rphy(hw, PHY_REG(769, 23), &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
		data &= ~(0x7F << 5);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
		ret_val = e1e_wphy(hw, PHY_REG(769, 23), data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
		e1e_rphy(hw, PHY_REG(769, 16), &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
		data |= (1 << 13);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
		ret_val = e1e_wphy(hw, PHY_REG(769, 16), data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
		e1e_rphy(hw, PHY_REG(776, 20), &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
		data &= ~(0x3FF << 2);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
		data |= (0x8 << 2);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
		ret_val = e1e_wphy(hw, PHY_REG(776, 20), data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
		ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
		e1e_rphy(hw, HV_PM_CTRL, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
		ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
	/* re-enable Rx path after enabling/disabling workaround */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
	ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
 *  e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
 *  done after every PHY reset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
	if (hw->mac.type != e1000_pch2lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
	/* Set MDIO slow mode before any other MDIO access */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
	ret_val = e1000_set_mdio_slow_mode_hv(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
 *  e1000_k1_gig_workaround_lv - K1 Si workaround
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
 *  @hw:   pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
 *  Workaround to set the K1 beacon duration for 82579 parts
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
static s32 e1000_k1_workaround_lv(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
	u16 status_reg = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
	u32 mac_reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
	if (hw->mac.type != e1000_pch2lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
	/* Set K1 beacon duration based on 1Gbps speed or otherwise */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
	ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
	if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
	    == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
		mac_reg = er32(FEXTNVM4);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
		mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
		if (status_reg & HV_M_STATUS_SPEED_1000)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
			mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
		else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
			mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
		ew32(FEXTNVM4, mac_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
 *  e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
 *  @hw:   pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
 *  @gate: boolean set to true to gate, false to ungate
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
 *  Gate/ungate the automatic PHY configuration via hardware; perform
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
 *  the configuration via software instead.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
	u32 extcnf_ctrl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
	if (hw->mac.type != e1000_pch2lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
		return;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
	extcnf_ctrl = er32(EXTCNF_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
	if (gate)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
		extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
	else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
		extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
	ew32(EXTCNF_CTRL, extcnf_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
	return;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
 *  e1000_lan_init_done_ich8lan - Check for PHY config completion
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
 *  Check the appropriate indication the MAC has finished configuring the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
 *  PHY after a software reset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
	u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
	/* Wait for basic configuration completes before proceeding */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
	do {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
		data = er32(STATUS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
		data &= E1000_STATUS_LAN_INIT_DONE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
		udelay(100);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
	} while ((!data) && --loop);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
	 * If basic configuration is incomplete before the above loop
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
	 * count reaches 0, loading the configuration from NVM will
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
	 * leave the PHY in a bad state possibly resulting in no link.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
	if (loop == 0)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
		e_dbg("LAN_INIT_DONE not set, increase timeout\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
	/* Clear the Init Done bit for the next init event */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
	data = er32(STATUS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
	data &= ~E1000_STATUS_LAN_INIT_DONE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
	ew32(STATUS, data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
 *  e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
	u16 reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
	if (e1000_check_reset_block(hw))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
	/* Allow time for h/w to get to quiescent state after reset */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
	msleep(10);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
	/* Perform any necessary post-reset workarounds */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
	switch (hw->mac.type) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
	case e1000_pchlan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
		ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
	case e1000_pch2lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
		ret_val = e1000_lv_phy_workarounds_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
	/* Dummy read to clear the phy wakeup bit after lcd reset */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
	if (hw->mac.type >= e1000_pchlan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
		e1e_rphy(hw, BM_WUC, &reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
	/* Configure the LCD with the extended configuration region in NVM */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
	ret_val = e1000_sw_lcd_config_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
	/* Configure the LCD with the OEM bits in NVM */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
	ret_val = e1000_oem_bits_config_ich8lan(hw, true);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
	/* Ungate automatic PHY configuration on non-managed 82579 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
	if ((hw->mac.type == e1000_pch2lan) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
	    !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
		msleep(10);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
		e1000_gate_hw_phy_config_ich8lan(hw, false);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
 *  e1000_phy_hw_reset_ich8lan - Performs a PHY reset
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
 *  Resets the PHY
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
 *  This is a function pointer entry point called by drivers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
 *  or other shared routines.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
	/* Gate automatic PHY configuration by hardware on non-managed 82579 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
	if ((hw->mac.type == e1000_pch2lan) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
	    !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
		e1000_gate_hw_phy_config_ich8lan(hw, true);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
	ret_val = e1000e_phy_hw_reset_generic(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
	ret_val = e1000_post_phy_reset_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
 *  e1000_set_lplu_state_pchlan - Set Low Power Link Up state
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
 *  @active: true to enable LPLU, false to disable
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
 *  Sets the LPLU state according to the active flag.  For PCH, if OEM write
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
 *  bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
 *  the phy speed. This function will manually set the LPLU bit and restart
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
 *  auto-neg as hw would do. D3 and D0 LPLU will call the same function
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
 *  since it configures the same bit.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
	u16 oem_reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
	ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
	if (active)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
		oem_reg |= HV_OEM_BITS_LPLU;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
	else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
		oem_reg &= ~HV_OEM_BITS_LPLU;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
	oem_reg |= HV_OEM_BITS_RESTART_AN;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
	ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
 *  e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
 *  @active: true to enable LPLU, false to disable
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
 *  Sets the LPLU D0 state according to the active flag.  When
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
 *  activating LPLU this function also disables smart speed
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
 *  and vice versa.  LPLU will not be activated unless the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
 *  device autonegotiation advertisement meets standards of
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
 *  either 10 or 10/100 or 10/100/1000 at all duplexes.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
 *  This is a function pointer entry point only called by
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
 *  PHY setup routines.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
	struct e1000_phy_info *phy = &hw->phy;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
	u32 phy_ctrl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	u16 data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
	if (phy->type == e1000_phy_ife)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
	phy_ctrl = er32(PHY_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
	if (active) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
		phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
		ew32(PHY_CTRL, phy_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
		if (phy->type != e1000_phy_igp_3)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
			return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
		 * Call gig speed drop workaround on LPLU before accessing
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
		 * any PHY registers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
		if (hw->mac.type == e1000_ich8lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
			e1000e_gig_downshift_workaround_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
		/* When LPLU is enabled, we should disable SmartSpeed */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
		ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
		data &= ~IGP01E1000_PSCFR_SMART_SPEED;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
		ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
	} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
		phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
		ew32(PHY_CTRL, phy_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
		if (phy->type != e1000_phy_igp_3)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
			return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
		 * LPLU and SmartSpeed are mutually exclusive.  LPLU is used
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
		 * during Dx states where the power conservation is most
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
		 * important.  During driver activity we should enable
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
		 * SmartSpeed, so performance is maintained.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
		if (phy->smart_speed == e1000_smart_speed_on) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
			ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
					   &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
			data |= IGP01E1000_PSCFR_SMART_SPEED;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
			ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
					   data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
		} else if (phy->smart_speed == e1000_smart_speed_off) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
			ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
					   &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
			data &= ~IGP01E1000_PSCFR_SMART_SPEED;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
			ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
					   data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
 *  e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
 *  @active: true to enable LPLU, false to disable
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
 *  Sets the LPLU D3 state according to the active flag.  When
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
 *  activating LPLU this function also disables smart speed
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
 *  and vice versa.  LPLU will not be activated unless the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
 *  device autonegotiation advertisement meets standards of
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
 *  either 10 or 10/100 or 10/100/1000 at all duplexes.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
 *  This is a function pointer entry point only called by
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
 *  PHY setup routines.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
	struct e1000_phy_info *phy = &hw->phy;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
	u32 phy_ctrl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
	u16 data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
	phy_ctrl = er32(PHY_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
	if (!active) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
		phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
		ew32(PHY_CTRL, phy_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
		if (phy->type != e1000_phy_igp_3)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
			return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
		 * LPLU and SmartSpeed are mutually exclusive.  LPLU is used
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
		 * during Dx states where the power conservation is most
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
		 * important.  During driver activity we should enable
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
		 * SmartSpeed, so performance is maintained.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
		if (phy->smart_speed == e1000_smart_speed_on) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
			ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
					   &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
			data |= IGP01E1000_PSCFR_SMART_SPEED;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
			ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
					   data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
		} else if (phy->smart_speed == e1000_smart_speed_off) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
			ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
					   &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
			data &= ~IGP01E1000_PSCFR_SMART_SPEED;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
			ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
					   data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
	} else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
		   (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
		   (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
		phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
		ew32(PHY_CTRL, phy_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
		if (phy->type != e1000_phy_igp_3)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
			return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
		 * Call gig speed drop workaround on LPLU before accessing
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
		 * any PHY registers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
		if (hw->mac.type == e1000_ich8lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
			e1000e_gig_downshift_workaround_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
		/* When LPLU is enabled, we should disable SmartSpeed */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
		ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
		data &= ~IGP01E1000_PSCFR_SMART_SPEED;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
		ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
 *  e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
 *  @bank:  pointer to the variable that returns the active bank
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
 *  Reads signature byte from the NVM using the flash access registers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
 *  Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
	u32 eecd;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
	struct e1000_nvm_info *nvm = &hw->nvm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
	u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
	u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
	u8 sig_byte = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
	switch (hw->mac.type) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
	case e1000_ich8lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
	case e1000_ich9lan:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
		eecd = er32(EECD);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
		if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
		    E1000_EECD_SEC1VAL_VALID_MASK) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
			if (eecd & E1000_EECD_SEC1VAL)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
				*bank = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
			else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
				*bank = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
			return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
		e_dbg("Unable to determine valid NVM bank via EEC - "
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
		       "reading flash signature\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
		/* fall-thru */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
		/* set bank to 0 in case flash read fails */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
		*bank = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
		/* Check bank 0 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
		ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
		                                        &sig_byte);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
		if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
		    E1000_ICH_NVM_SIG_VALUE) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
			*bank = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
			return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
		/* Check bank 1 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
		ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset +
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
		                                        bank1_offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
		                                        &sig_byte);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
		if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) ==
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
		    E1000_ICH_NVM_SIG_VALUE) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
			*bank = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
			return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
		e_dbg("ERROR: No valid NVM bank present\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
		return -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
 *  e1000_read_nvm_ich8lan - Read word(s) from the NVM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
 *  @offset: The offset (in bytes) of the word(s) to read.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
 *  @words: Size of data to read in words
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
 *  @data: Pointer to the word(s) to read at offset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
 *  Reads a word(s) from the NVM using the flash access registers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
				  u16 *data)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
	struct e1000_nvm_info *nvm = &hw->nvm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
	struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
	u32 act_offset;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
	u32 bank = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
	u16 i, word;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
	if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
	    (words == 0)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
		e_dbg("nvm parameter(s) out of bounds\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
		ret_val = -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
	nvm->ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
	ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
	if (ret_val) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
		e_dbg("Could not detect valid bank, assuming bank 0\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
		bank = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
	act_offset = (bank) ? nvm->flash_bank_size : 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
	act_offset += offset;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
	ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
	for (i = 0; i < words; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
		if ((dev_spec->shadow_ram) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
		    (dev_spec->shadow_ram[offset+i].modified)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
			data[i] = dev_spec->shadow_ram[offset+i].value;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
		} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
			ret_val = e1000_read_flash_word_ich8lan(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
								act_offset + i,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
								&word);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
				break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
			data[i] = word;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
	nvm->ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
		e_dbg("NVM read error: %d\n", ret_val);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
 *  e1000_flash_cycle_init_ich8lan - Initialize flash
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
 *  This function does initial flash setup so that a new read/write/erase cycle
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
 *  can be started.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
	union ich8_hws_flash_status hsfsts;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
	s32 ret_val = -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
	s32 i = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
	hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
	/* Check if the flash descriptor is valid */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
	if (hsfsts.hsf_status.fldesvalid == 0) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
		e_dbg("Flash descriptor invalid.  "
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
			 "SW Sequencing must be used.\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
		return -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
	/* Clear FCERR and DAEL in hw status by writing 1 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	hsfsts.hsf_status.flcerr = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
	hsfsts.hsf_status.dael = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
	ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
	 * Either we should have a hardware SPI cycle in progress
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
	 * bit to check against, in order to start a new cycle or
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
	 * FDONE bit should be changed in the hardware so that it
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
	 * is 1 after hardware reset, which can then be used as an
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
	 * indication whether a cycle is in progress or has been
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
	 * completed.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
	if (hsfsts.hsf_status.flcinprog == 0) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
		 * There is no cycle running at present,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
		 * so we can start a cycle.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
		 * Begin by setting Flash Cycle Done.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
		hsfsts.hsf_status.flcdone = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
		ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
		ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
	} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
		 * Otherwise poll for sometime so the current
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
		 * cycle has a chance to end before giving up.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
		for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
			hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
			if (hsfsts.hsf_status.flcinprog == 0) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
				ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
				break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
			}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
			udelay(1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
		if (ret_val == 0) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
			/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
			 * Successful in waiting for previous cycle to timeout,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
			 * now set the Flash Cycle Done.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
			 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
			hsfsts.hsf_status.flcdone = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
			ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
		} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
			e_dbg("Flash controller busy, cannot get access\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
 *  e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
 *  @timeout: maximum time to wait for completion
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
 *  This function starts a flash cycle and waits for its completion.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
	union ich8_hws_flash_ctrl hsflctl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
	union ich8_hws_flash_status hsfsts;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
	s32 ret_val = -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
	u32 i = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
	/* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
	hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
	hsflctl.hsf_ctrl.flcgo = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
	ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
	/* wait till FDONE bit is set to 1 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
	do {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
		hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
		if (hsfsts.hsf_status.flcdone == 1)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
		udelay(1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
	} while (i++ < timeout);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
	if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
		return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
 *  e1000_read_flash_word_ich8lan - Read word from flash
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
 *  @offset: offset to data location
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
 *  @data: pointer to the location for storing the data
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
 *  Reads the flash word at offset into data.  Offset is converted
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
 *  to bytes before read.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
					 u16 *data)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
	/* Must convert offset into bytes. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
	offset <<= 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
	return e1000_read_flash_data_ich8lan(hw, offset, 2, data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
 *  e1000_read_flash_byte_ich8lan - Read byte from flash
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
 *  @offset: The offset of the byte to read.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
 *  @data: Pointer to a byte to store the value read.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
 *  Reads a single byte from the NVM using the flash access registers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
					 u8 *data)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
	u16 word = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
	ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
	*data = (u8)word;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
 *  e1000_read_flash_data_ich8lan - Read byte or word from NVM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
 *  @offset: The offset (in bytes) of the byte or word to read.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
 *  @size: Size of data to read, 1=byte 2=word
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
 *  @data: Pointer to the word to store the value read.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
 *  Reads a byte or word from the NVM using the flash access registers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
					 u8 size, u16 *data)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
	union ich8_hws_flash_status hsfsts;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
	union ich8_hws_flash_ctrl hsflctl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
	u32 flash_linear_addr;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
	u32 flash_data = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
	s32 ret_val = -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
	u8 count = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
	if (size < 1  || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
		return -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
	flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
			    hw->nvm.flash_base_addr;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
	do {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
		udelay(1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
		/* Steps */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
		ret_val = e1000_flash_cycle_init_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
		if (ret_val != 0)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
		hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
		/* 0b/1b corresponds to 1 or 2 byte size, respectively. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
		hsflctl.hsf_ctrl.fldbcount = size - 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
		hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
		ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
		ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
		ret_val = e1000_flash_cycle_ich8lan(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
						ICH_FLASH_READ_COMMAND_TIMEOUT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
		 * Check if FCERR is set to 1, if set to 1, clear it
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
		 * and try the whole sequence a few more times, else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
		 * read in (shift in) the Flash Data0, the order is
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
		 * least significant byte first msb to lsb
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
		if (ret_val == 0) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
			flash_data = er32flash(ICH_FLASH_FDATA0);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
			if (size == 1) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
				*data = (u8)(flash_data & 0x000000FF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
			} else if (size == 2) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
				*data = (u16)(flash_data & 0x0000FFFF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
			}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
		} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
			/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
			 * If we've gotten here, then things are probably
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
			 * completely hosed, but if the error condition is
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
			 * detected, it won't hurt to give it another try...
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
			 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
			 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
			hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
			if (hsfsts.hsf_status.flcerr == 1) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
				/* Repeat for some time before giving up. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
				continue;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
			} else if (hsfsts.hsf_status.flcdone == 0) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
				e_dbg("Timeout error - flash cycle "
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
					 "did not complete.\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
				break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
			}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
	} while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
 *  e1000_write_nvm_ich8lan - Write word(s) to the NVM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
 *  @offset: The offset (in bytes) of the word(s) to write.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
 *  @words: Size of data to write in words
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
 *  @data: Pointer to the word(s) to write at offset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
 *  Writes a byte or word to the NVM using the flash access registers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
				   u16 *data)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
	struct e1000_nvm_info *nvm = &hw->nvm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
	struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
	u16 i;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
	if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
	    (words == 0)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
		e_dbg("nvm parameter(s) out of bounds\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
		return -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
	nvm->ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
	for (i = 0; i < words; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
		dev_spec->shadow_ram[offset+i].modified = true;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
		dev_spec->shadow_ram[offset+i].value = data[i];
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
	nvm->ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
 *  e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
 *  The NVM checksum is updated by calling the generic update_nvm_checksum,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
 *  which writes the checksum to the shadow ram.  The changes in the shadow
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
 *  ram are then committed to the EEPROM by processing each bank at a time
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
 *  checking for the modified bit and writing only the pending changes.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
 *  After a successful commit, the shadow ram is cleared and is ready for
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
 *  future writes.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
	struct e1000_nvm_info *nvm = &hw->nvm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
	struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
	u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
	u16 data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
	ret_val = e1000e_update_nvm_checksum_generic(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
	if (nvm->type != e1000_nvm_flash_sw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
	nvm->ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
	 * We're writing to the opposite bank so if we're on bank 1,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
	 * write to bank 0 etc.  We also need to erase the segment that
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
	 * is going to be written
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
	ret_val =  e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
	if (ret_val) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
		e_dbg("Could not detect valid bank, assuming bank 0\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
		bank = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
	if (bank == 0) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
		new_bank_offset = nvm->flash_bank_size;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
		old_bank_offset = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
		ret_val = e1000_erase_flash_bank_ich8lan(hw, 1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
			goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
	} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
		old_bank_offset = nvm->flash_bank_size;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
		new_bank_offset = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
		ret_val = e1000_erase_flash_bank_ich8lan(hw, 0);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
			goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
	for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
		 * Determine whether to write the value stored
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
		 * in the other NVM bank or a modified value stored
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
		 * in the shadow RAM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
		if (dev_spec->shadow_ram[i].modified) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
			data = dev_spec->shadow_ram[i].value;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
		} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
			ret_val = e1000_read_flash_word_ich8lan(hw, i +
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
			                                        old_bank_offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
			                                        &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
				break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
		 * If the word is 0x13, then make sure the signature bits
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
		 * (15:14) are 11b until the commit has completed.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
		 * This will allow us to write 10b which indicates the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
		 * signature is valid.  We want to do this after the write
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
		 * has completed so that we don't mark the segment valid
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
		 * while the write is still in progress
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
		if (i == E1000_ICH_NVM_SIG_WORD)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
			data |= E1000_ICH_NVM_SIG_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
		/* Convert offset to bytes. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
		act_offset = (i + new_bank_offset) << 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
		udelay(100);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
		/* Write the bytes to the new bank. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
		ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
							       act_offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
							       (u8)data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
		udelay(100);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
		ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
							  act_offset + 1,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
							  (u8)(data >> 8));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
	 * Don't bother writing the segment valid bits if sector
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
	 * programming failed.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
	if (ret_val) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
		/* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
		e_dbg("Flash commit failed.\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
		goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
	 * Finally validate the new segment by setting bit 15:14
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
	 * to 10b in word 0x13 , this can be done without an
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
	 * erase as well since these bits are 11 to start with
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
	 * and we need to change bit 14 to 0b
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
	act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
	ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
		goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
	data &= 0xBFFF;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
	ret_val = e1000_retry_write_flash_byte_ich8lan(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
						       act_offset * 2 + 1,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
						       (u8)(data >> 8));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
		goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
	 * And invalidate the previously valid segment by setting
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
	 * its signature word (0x13) high_byte to 0b. This can be
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
	 * done without an erase because flash erase sets all bits
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
	 * to 1's. We can write 1's to 0's without an erase
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
	act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
	ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
		goto release;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
	/* Great!  Everything worked, we can now clear the cached entries. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
	for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
		dev_spec->shadow_ram[i].modified = false;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
		dev_spec->shadow_ram[i].value = 0xFFFF;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
release:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
	nvm->ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
	 * Reload the EEPROM, or else modifications will not appear
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
	 * until after the next adapter reset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
	if (!ret_val) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
		e1000e_reload_nvm(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
		msleep(10);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
		e_dbg("NVM update error: %d\n", ret_val);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
 *  e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
 *  Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
 *  If the bit is 0, that the EEPROM had been modified, but the checksum was not
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
 *  calculated, in which case we need to calculate the checksum and set bit 6.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
	u16 data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
	 * Read 0x19 and check bit 6.  If this bit is 0, the checksum
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
	 * needs to be fixed.  This bit is an indication that the NVM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
	 * was prepared by OEM software and did not calculate the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
	 * checksum...a likely scenario.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
	ret_val = e1000_read_nvm(hw, 0x19, 1, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
	if ((data & 0x40) == 0) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
		data |= 0x40;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
		ret_val = e1000_write_nvm(hw, 0x19, 1, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
		ret_val = e1000e_update_nvm_checksum(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
	return e1000e_validate_nvm_checksum_generic(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
 *  e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
 *  To prevent malicious write/erase of the NVM, set it to be read-only
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
 *  so that the hardware ignores all write/erase cycles of the NVM via
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
 *  the flash control registers.  The shadow-ram copy of the NVM will
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
 *  still be updated, however any updates to this copy will not stick
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
 *  across driver reloads.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
	struct e1000_nvm_info *nvm = &hw->nvm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
	union ich8_flash_protected_range pr0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
	union ich8_hws_flash_status hsfsts;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
	u32 gfpreg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
	nvm->ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
	gfpreg = er32flash(ICH_FLASH_GFPREG);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
	/* Write-protect GbE Sector of NVM */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
	pr0.regval = er32flash(ICH_FLASH_PR0);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
	pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
	pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
	pr0.range.wpe = true;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
	ew32flash(ICH_FLASH_PR0, pr0.regval);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
	 * Lock down a subset of GbE Flash Control Registers, e.g.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
	 * PR0 to prevent the write-protection from being lifted.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
	 * Once FLOCKDN is set, the registers protected by it cannot
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
	 * be written until FLOCKDN is cleared by a hardware reset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
	hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
	hsfsts.hsf_status.flockdn = true;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
	ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
	nvm->ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
 *  e1000_write_flash_data_ich8lan - Writes bytes to the NVM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
 *  @offset: The offset (in bytes) of the byte/word to read.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
 *  @size: Size of data to read, 1=byte 2=word
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
 *  @data: The byte(s) to write to the NVM.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
 *  Writes one/two bytes to the NVM using the flash access registers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
					  u8 size, u16 data)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
	union ich8_hws_flash_status hsfsts;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
	union ich8_hws_flash_ctrl hsflctl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
	u32 flash_linear_addr;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
	u32 flash_data = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
	u8 count = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
	if (size < 1 || size > 2 || data > size * 0xff ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
	    offset > ICH_FLASH_LINEAR_ADDR_MASK)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
		return -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
	flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) +
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
			    hw->nvm.flash_base_addr;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
	do {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
		udelay(1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
		/* Steps */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
		ret_val = e1000_flash_cycle_init_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
		hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
		/* 0b/1b corresponds to 1 or 2 byte size, respectively. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
		hsflctl.hsf_ctrl.fldbcount = size -1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
		hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
		ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
		ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
		if (size == 1)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
			flash_data = (u32)data & 0x00FF;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
		else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
			flash_data = (u32)data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
		ew32flash(ICH_FLASH_FDATA0, flash_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
		 * check if FCERR is set to 1 , if set to 1, clear it
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
		 * and try the whole sequence a few more times else done
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
		ret_val = e1000_flash_cycle_ich8lan(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
					       ICH_FLASH_WRITE_COMMAND_TIMEOUT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
		if (!ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
		 * If we're here, then things are most likely
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
		 * completely hosed, but if the error condition
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
		 * is detected, it won't hurt to give it another
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
		 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
		hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
		if (hsfsts.hsf_status.flcerr == 1)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
			/* Repeat for some time before giving up. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
			continue;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
		if (hsfsts.hsf_status.flcdone == 0) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
			e_dbg("Timeout error - flash cycle "
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
				 "did not complete.");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
	} while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
 *  e1000_write_flash_byte_ich8lan - Write a single byte to NVM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
 *  @offset: The index of the byte to read.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
 *  @data: The byte to write to the NVM.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
 *  Writes a single byte to the NVM using the flash access registers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
					  u8 data)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
	u16 word = (u16)data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
	return e1000_write_flash_data_ich8lan(hw, offset, 1, word);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
 *  e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
 *  @offset: The offset of the byte to write.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
 *  @byte: The byte to write to the NVM.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
 *  Writes a single byte to the NVM using the flash access registers.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
 *  Goes through a retry algorithm before giving up.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
						u32 offset, u8 byte)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
	u16 program_retries;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
	ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
	if (!ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
	for (program_retries = 0; program_retries < 100; program_retries++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
		e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
		udelay(100);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
		ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
		if (!ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
	if (program_retries == 100)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
		return -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
 *  e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
 *  @bank: 0 for first bank, 1 for second bank, etc.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
 *  Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
 *  bank N is 4096 * N + flash_reg_addr.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
	struct e1000_nvm_info *nvm = &hw->nvm;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
	union ich8_hws_flash_status hsfsts;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
	union ich8_hws_flash_ctrl hsflctl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
	u32 flash_linear_addr;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
	/* bank size is in 16bit words - adjust to bytes */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
	u32 flash_bank_size = nvm->flash_bank_size * 2;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
	s32 count = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
	s32 j, iteration, sector_size;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
	hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
	 * Determine HW Sector size: Read BERASE bits of hw flash status
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
	 * register
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
	 * 00: The Hw sector is 256 bytes, hence we need to erase 16
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
	 *     consecutive sectors.  The start index for the nth Hw sector
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
	 *     can be calculated as = bank * 4096 + n * 256
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
	 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
	 *     The start index for the nth Hw sector can be calculated
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
	 *     as = bank * 4096
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
	 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
	 *     (ich9 only, otherwise error condition)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
	 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
	switch (hsfsts.hsf_status.berasesz) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
	case 0:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
		/* Hw sector size 256 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
		sector_size = ICH_FLASH_SEG_SIZE_256;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
		iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
	case 1:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
		sector_size = ICH_FLASH_SEG_SIZE_4K;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
		iteration = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
	case 2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
		sector_size = ICH_FLASH_SEG_SIZE_8K;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
		iteration = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
	case 3:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
		sector_size = ICH_FLASH_SEG_SIZE_64K;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
		iteration = 1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
		return -E1000_ERR_NVM;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
	/* Start with the base address, then add the sector offset. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
	flash_linear_addr = hw->nvm.flash_base_addr;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
	flash_linear_addr += (bank) ? flash_bank_size : 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
	for (j = 0; j < iteration ; j++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
		do {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
			/* Steps */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
			ret_val = e1000_flash_cycle_init_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
			if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
			/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
			 * Write a value 11 (block Erase) in Flash
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
			 * Cycle field in hw flash control
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
			 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
			hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
			hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
			ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
			/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
			 * Write the last 24 bits of an index within the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
			 * block into Flash Linear address field in Flash
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
			 * Address.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
			 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
			flash_linear_addr += (j * sector_size);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
			ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
			ret_val = e1000_flash_cycle_ich8lan(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
					       ICH_FLASH_ERASE_COMMAND_TIMEOUT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
			if (ret_val == 0)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
				break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
			/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
			 * Check if FCERR is set to 1.  If 1,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
			 * clear it and try the whole sequence
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
			 * a few more times else Done
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
			 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
			hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
			if (hsfsts.hsf_status.flcerr == 1)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
				/* repeat for some time before giving up */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
				continue;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
			else if (hsfsts.hsf_status.flcdone == 0)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
				return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
		} while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
 *  e1000_valid_led_default_ich8lan - Set the default LED settings
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
 *  @data: Pointer to the LED settings
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
 *  Reads the LED default settings from the NVM to data.  If the NVM LED
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
 *  settings is all 0's or F's, set the LED default to a valid LED default
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
 *  setting.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
	ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
	if (ret_val) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
		e_dbg("NVM Read Error\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
	if (*data == ID_LED_RESERVED_0000 ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
	    *data == ID_LED_RESERVED_FFFF)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
		*data = ID_LED_DEFAULT_ICH8LAN;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
 *  e1000_id_led_init_pchlan - store LED configurations
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
 *  PCH does not control LEDs via the LEDCTL register, rather it uses
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
 *  the PHY LED configuration register.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
 *  PCH also does not have an "always on" or "always off" mode which
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
 *  complicates the ID feature.  Instead of using the "on" mode to indicate
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
 *  in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init()),
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
 *  use "link_up" mode.  The LEDs will still ID on request if there is no
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
 *  link based on logic in e1000_led_[on|off]_pchlan().
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
	struct e1000_mac_info *mac = &hw->mac;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
	const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
	const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
	u16 data, i, temp, shift;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
	/* Get default ID LED modes */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
	ret_val = hw->nvm.ops.valid_led_default(hw, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
		goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
	mac->ledctl_default = er32(LEDCTL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
	mac->ledctl_mode1 = mac->ledctl_default;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
	mac->ledctl_mode2 = mac->ledctl_default;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
	for (i = 0; i < 4; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
		temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
		shift = (i * 5);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
		switch (temp) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
		case ID_LED_ON1_DEF2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
		case ID_LED_ON1_ON2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
		case ID_LED_ON1_OFF2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
			mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
			mac->ledctl_mode1 |= (ledctl_on << shift);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
		case ID_LED_OFF1_DEF2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
		case ID_LED_OFF1_ON2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
		case ID_LED_OFF1_OFF2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
			mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
			mac->ledctl_mode1 |= (ledctl_off << shift);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
		default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
			/* Do nothing */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
		switch (temp) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
		case ID_LED_DEF1_ON2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
		case ID_LED_ON1_ON2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
		case ID_LED_OFF1_ON2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
			mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
			mac->ledctl_mode2 |= (ledctl_on << shift);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
		case ID_LED_DEF1_OFF2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
		case ID_LED_ON1_OFF2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
		case ID_LED_OFF1_OFF2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
			mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
			mac->ledctl_mode2 |= (ledctl_off << shift);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
		default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
			/* Do nothing */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
 *  e1000_get_bus_info_ich8lan - Get/Set the bus type and width
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
 *  ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
 *  register, so the the bus width is hard coded.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
	struct e1000_bus_info *bus = &hw->bus;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
	ret_val = e1000e_get_bus_info_pcie(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
	 * ICH devices are "PCI Express"-ish.  They have
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
	 * a configuration space, but do not contain
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
	 * PCI Express Capability registers, so bus width
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
	 * must be hardcoded.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
	if (bus->width == e1000_bus_width_unknown)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
		bus->width = e1000_bus_width_pcie_x1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
 *  e1000_reset_hw_ich8lan - Reset the hardware
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
 *  Does a full reset of the hardware which includes a reset of the PHY and
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
 *  MAC.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
	struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
	u16 reg;
2239
fb6ec8610ada Avoided unused variable warnings.
Florian Pose <fp@igh-essen.com>
parents: 2092
diff changeset
  2981
	u32 ctrl, icr __attribute__ ((unused)), kab;
2092
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
	 * Prevent the PCI-E bus from sticking if there is no TLP connection
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
	 * on the last TLP read/write transaction when MAC is reset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
	ret_val = e1000e_disable_pcie_master(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
		e_dbg("PCI-E Master disable polling has failed.\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
	e_dbg("Masking off all interrupts\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
	ew32(IMC, 0xffffffff);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
	 * Disable the Transmit and Receive units.  Then delay to allow
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
	 * any pending transactions to complete before we hit the MAC
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
	 * with the global reset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
	ew32(RCTL, 0);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
	ew32(TCTL, E1000_TCTL_PSP);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
	e1e_flush();
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
	msleep(10);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
	/* Workaround for ICH8 bit corruption issue in FIFO memory */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
	if (hw->mac.type == e1000_ich8lan) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
		/* Set Tx and Rx buffer allocation to 8k apiece. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
		ew32(PBA, E1000_PBA_8K);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
		/* Set Packet Buffer Size to 16k. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
		ew32(PBS, E1000_PBS_16K);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
	if (hw->mac.type == e1000_pchlan) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
		/* Save the NVM K1 bit setting*/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
		ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
		if (reg & E1000_NVM_K1_ENABLE)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
			dev_spec->nvm_k1_enabled = true;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
		else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
			dev_spec->nvm_k1_enabled = false;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
	ctrl = er32(CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
	if (!e1000_check_reset_block(hw)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
		 * Full-chip reset requires MAC and PHY reset at the same
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
		 * time to make sure the interface between MAC and the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
		 * external PHY is reset.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
		ctrl |= E1000_CTRL_PHY_RST;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
		 * Gate automatic PHY configuration by hardware on
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
		 * non-managed 82579
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
		if ((hw->mac.type == e1000_pch2lan) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
		    !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
			e1000_gate_hw_phy_config_ich8lan(hw, true);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
	ret_val = e1000_acquire_swflag_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
	e_dbg("Issuing a global reset to ich8lan\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
	ew32(CTRL, (ctrl | E1000_CTRL_RST));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
	msleep(20);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
	if (!ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
		e1000_release_swflag_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
	if (ctrl & E1000_CTRL_PHY_RST) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
		ret_val = hw->phy.ops.get_cfg_done(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
		ret_val = e1000_post_phy_reset_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
			goto out;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
	 * For PCH, this write will make sure that any noise
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
	 * will be detected as a CRC error and be dropped rather than show up
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
	 * as a bad packet to the DMA engine.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
	if (hw->mac.type == e1000_pchlan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
		ew32(CRC_OFFSET, 0x65656565);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
	ew32(IMC, 0xffffffff);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
	icr = er32(ICR);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
	kab = er32(KABGTXD);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
	kab |= E1000_KABGTXD_BGSQLBIAS;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
	ew32(KABGTXD, kab);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
out:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
 *  e1000_init_hw_ich8lan - Initialize the hardware
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
 *  Prepares the hardware for transmit and receive by doing the following:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
 *   - initialize hardware bits
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
 *   - initialize LED identification
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
 *   - setup receive address registers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
 *   - setup flow control
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
 *   - setup transmit descriptors
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
 *   - clear statistics
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
	struct e1000_mac_info *mac = &hw->mac;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
	u32 ctrl_ext, txdctl, snoop;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
	u16 i;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
	e1000_initialize_hw_bits_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
	/* Initialize identification LED */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
	ret_val = mac->ops.id_led_init(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
		e_dbg("Error initializing identification LED\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
		/* This is not fatal and we should not stop init due to this */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
	/* Setup the receive address. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
	e1000e_init_rx_addrs(hw, mac->rar_entry_count);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
	/* Zero out the Multicast HASH table */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
	e_dbg("Zeroing the MTA\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
	for (i = 0; i < mac->mta_reg_count; i++)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
		E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
	 * The 82578 Rx buffer will stall if wakeup is enabled in host and
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
	 * the ME.  Reading the BM_WUC register will clear the host wakeup bit.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
	 * Reset the phy after disabling host wakeup to reset the Rx buffer.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
	if (hw->phy.type == e1000_phy_82578) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
		hw->phy.ops.read_reg(hw, BM_WUC, &i);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
		ret_val = e1000_phy_hw_reset_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
	/* Setup link and flow control */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
	ret_val = e1000_setup_link_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
	/* Set the transmit descriptor write-back policy for both queues */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
	txdctl = er32(TXDCTL(0));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
	txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
		 E1000_TXDCTL_FULL_TX_DESC_WB;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
	txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
		 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
	ew32(TXDCTL(0), txdctl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
	txdctl = er32(TXDCTL(1));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
	txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
		 E1000_TXDCTL_FULL_TX_DESC_WB;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
	txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
		 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
	ew32(TXDCTL(1), txdctl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
	 * ICH8 has opposite polarity of no_snoop bits.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
	 * By default, we should use snoop behavior.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
	if (mac->type == e1000_ich8lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
		snoop = PCIE_ICH8_SNOOP_ALL;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
	else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
		snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
	e1000e_set_pcie_no_snoop(hw, snoop);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
	ctrl_ext = er32(CTRL_EXT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
	ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
	ew32(CTRL_EXT, ctrl_ext);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
	 * Clear all of the statistics registers (clear on read).  It is
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
	 * important that we do this after we have tried to establish link
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
	 * because the symbol error count will increment wildly if there
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
	 * is no link.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
	e1000_clear_hw_cntrs_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
 *  e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
 *  Sets/Clears required hardware bits necessary for correctly setting up the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
 *  hardware for transmit and receive.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
	u32 reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
	/* Extended Device Control */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
	reg = er32(CTRL_EXT);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
	reg |= (1 << 22);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
	/* Enable PHY low-power state when MAC is at D3 w/o WoL */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
	if (hw->mac.type >= e1000_pchlan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
		reg |= E1000_CTRL_EXT_PHYPDEN;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
	ew32(CTRL_EXT, reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
	/* Transmit Descriptor Control 0 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
	reg = er32(TXDCTL(0));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
	reg |= (1 << 22);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
	ew32(TXDCTL(0), reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
	/* Transmit Descriptor Control 1 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
	reg = er32(TXDCTL(1));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
	reg |= (1 << 22);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
	ew32(TXDCTL(1), reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
	/* Transmit Arbitration Control 0 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
	reg = er32(TARC(0));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
	if (hw->mac.type == e1000_ich8lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
		reg |= (1 << 28) | (1 << 29);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
	reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
	ew32(TARC(0), reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
	/* Transmit Arbitration Control 1 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
	reg = er32(TARC(1));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
	if (er32(TCTL) & E1000_TCTL_MULR)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
		reg &= ~(1 << 28);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
	else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
		reg |= (1 << 28);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
	reg |= (1 << 24) | (1 << 26) | (1 << 30);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
	ew32(TARC(1), reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
	/* Device Status */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
	if (hw->mac.type == e1000_ich8lan) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
		reg = er32(STATUS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
		reg &= ~(1 << 31);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
		ew32(STATUS, reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
	 * work-around descriptor data corruption issue during nfs v2 udp
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
	 * traffic, just disable the nfs filtering capability
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
	reg = er32(RFCTL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
	reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
	ew32(RFCTL, reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
 *  e1000_setup_link_ich8lan - Setup flow control and link settings
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
 *  Determines which flow control settings to use, then configures flow
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
 *  control.  Calls the appropriate media-specific link configuration
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
 *  function.  Assuming the adapter has a valid link partner, a valid link
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
 *  should be established.  Assumes the hardware has previously been reset
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
 *  and the transmitter and receiver are not enabled.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
	if (e1000_check_reset_block(hw))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
		return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
	 * ICH parts do not have a word in the NVM to determine
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
	 * the default flow control setting, so we explicitly
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
	 * set it to full.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
	if (hw->fc.requested_mode == e1000_fc_default) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
		/* Workaround h/w hang when Tx flow control enabled */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
		if (hw->mac.type == e1000_pchlan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
			hw->fc.requested_mode = e1000_fc_rx_pause;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
		else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
			hw->fc.requested_mode = e1000_fc_full;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
	 * Save off the requested flow control mode for use later.  Depending
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
	 * on the link partner's capabilities, we may or may not use this mode.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
	hw->fc.current_mode = hw->fc.requested_mode;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
	e_dbg("After fix-ups FlowControl is now = %x\n",
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
		hw->fc.current_mode);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
	/* Continue to configure the copper link. */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
	ret_val = e1000_setup_copper_link_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
	ew32(FCTTV, hw->fc.pause_time);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
	if ((hw->phy.type == e1000_phy_82578) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
	    (hw->phy.type == e1000_phy_82579) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
	    (hw->phy.type == e1000_phy_82577)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
		ew32(FCRTV_PCH, hw->fc.refresh_time);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
		ret_val = hw->phy.ops.write_reg(hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
		                             PHY_REG(BM_PORT_CTRL_PAGE, 27),
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
		                             hw->fc.pause_time);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
	return e1000e_set_fc_watermarks(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
 *  e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
 *  Configures the kumeran interface to the PHY to wait the appropriate time
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
 *  when polling the PHY, then call the generic setup_copper_link to finish
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
 *  configuring the copper link.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
	u32 ctrl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
	u16 reg_data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
	ctrl = er32(CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
	ctrl |= E1000_CTRL_SLU;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
	ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
	ew32(CTRL, ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
	 * Set the mac to wait the maximum time between each iteration
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
	 * and increase the max iterations when polling the phy;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
	 * this fixes erroneous timeouts at 10Mbps.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
	ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
	ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
	                               &reg_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
	reg_data |= 0x3F;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
	ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
	                                reg_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
	switch (hw->phy.type) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
	case e1000_phy_igp_3:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
		ret_val = e1000e_copper_link_setup_igp(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
	case e1000_phy_bm:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
	case e1000_phy_82578:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
		ret_val = e1000e_copper_link_setup_m88(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
	case e1000_phy_82577:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
	case e1000_phy_82579:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
		ret_val = e1000_copper_link_setup_82577(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
	case e1000_phy_ife:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
		ret_val = hw->phy.ops.read_reg(hw, IFE_PHY_MDIX_CONTROL,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
		                               &reg_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
		reg_data &= ~IFE_PMC_AUTO_MDIX;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
		switch (hw->phy.mdix) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
		case 1:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
			reg_data &= ~IFE_PMC_FORCE_MDIX;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
		case 2:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
			reg_data |= IFE_PMC_FORCE_MDIX;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
		case 0:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
		default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
			reg_data |= IFE_PMC_AUTO_MDIX;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
		ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_MDIX_CONTROL,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
		                                reg_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
	default:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
		break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
	return e1000e_setup_copper_link(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
 *  e1000_get_link_up_info_ich8lan - Get current link speed and duplex
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
 *  @speed: pointer to store current link speed
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
 *  @duplex: pointer to store the current link duplex
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
 *  Calls the generic get_speed_and_duplex to retrieve the current link
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
 *  information and then calls the Kumeran lock loss workaround for links at
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
 *  gigabit speeds.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
					  u16 *duplex)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
	ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
		return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
	if ((hw->mac.type == e1000_ich8lan) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
	    (hw->phy.type == e1000_phy_igp_3) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
	    (*speed == SPEED_1000)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
		ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
 *  e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
 *  Work-around for 82566 Kumeran PCS lock loss:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
 *  On link status change (i.e. PCI reset, speed change) and link is up and
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
 *  speed is gigabit-
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
 *    0) if workaround is optionally disabled do nothing
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
 *    1) wait 1ms for Kumeran link to come up
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
 *    2) check Kumeran Diagnostic register PCS lock loss bit
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
 *    3) if not set the link is locked (all is good), otherwise...
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
 *    4) reset the PHY
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
 *    5) repeat up to 10 times
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
 *  Note: this is only called for IGP3 copper when speed is 1gb.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
	struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
	u32 phy_ctrl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
	u16 i, data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
	bool link;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
	if (!dev_spec->kmrn_lock_loss_workaround_enabled)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
		return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
	 * Make sure link is up before proceeding.  If not just return.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
	 * Attempting this while link is negotiating fouled up link
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
	 * stability
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
	ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
	if (!link)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
		return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
	for (i = 0; i < 10; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
		/* read once to clear */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
		ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
		/* and again to get new status */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
		ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
			return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
		/* check for PCS lock */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
		if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
			return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
		/* Issue PHY reset */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
		e1000_phy_hw_reset(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
		mdelay(5);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
	/* Disable GigE link negotiation */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
	phy_ctrl = er32(PHY_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
	phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
		     E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
	ew32(PHY_CTRL, phy_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
	 * Call gig speed drop workaround on Gig disable before accessing
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
	 * any PHY registers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
	e1000e_gig_downshift_workaround_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
	/* unable to acquire PCS lock */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
	return -E1000_ERR_PHY;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
 *  e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
 *  @state: boolean value used to set the current Kumeran workaround state
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
 *  If ICH8, set the current Kumeran workaround state (enabled - true
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
 *  /disabled - false).
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
						 bool state)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
	struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
	if (hw->mac.type != e1000_ich8lan) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
		e_dbg("Workaround applies to ICH8 only.\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
		return;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
	dev_spec->kmrn_lock_loss_workaround_enabled = state;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
 *  e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
 *  Workaround for 82566 power-down on D3 entry:
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
 *    1) disable gigabit link
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
 *    2) write VR power-down enable
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
 *    3) read it back
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
 *  Continue if successful, else issue LCD reset and repeat
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
	u32 reg;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
	u16 data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
	u8  retry = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
	if (hw->phy.type != e1000_phy_igp_3)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
		return;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
	/* Try the workaround twice (if needed) */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
	do {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
		/* Disable link */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
		reg = er32(PHY_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
		reg |= (E1000_PHY_CTRL_GBE_DISABLE |
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
			E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
		ew32(PHY_CTRL, reg);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
		/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
		 * Call gig speed drop workaround on Gig disable before
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
		 * accessing any PHY registers
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
		 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
		if (hw->mac.type == e1000_ich8lan)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
			e1000e_gig_downshift_workaround_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
		/* Write VR power-down enable */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
		e1e_rphy(hw, IGP3_VR_CTRL, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
		data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
		e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
		/* Read it back and test */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
		e1e_rphy(hw, IGP3_VR_CTRL, &data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
		data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
		if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
			break;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
		/* Issue PHY reset and repeat at most one more time */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
		reg = er32(CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
		ew32(CTRL, reg | E1000_CTRL_PHY_RST);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
		retry++;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
	} while (retry);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
 *  e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
 *  Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
 *  LPLU, Gig disable, MDIC PHY reset):
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
 *    1) Set Kumeran Near-end loopback
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
 *    2) Clear Kumeran Near-end loopback
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
 *  Should only be called for ICH8[m] devices with IGP_3 Phy.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
	u16 reg_data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
	if ((hw->mac.type != e1000_ich8lan) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
	    (hw->phy.type != e1000_phy_igp_3))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
		return;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
	ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
				      &reg_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
		return;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
	reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
	ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
				       reg_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
	if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
		return;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
	reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
	ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
				       reg_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
 *  e1000e_disable_gig_wol_ich8lan - disable gig during WoL
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
 *  During S0 to Sx transition, it is possible the link remains at gig
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
 *  instead of negotiating to a lower speed.  Before going to Sx, set
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
 *  'LPLU Enabled' and 'Gig Disable' to force link speed negotiation
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
 *  to a lower speed.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
 *  Should only be called for applicable parts.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
	u32 phy_ctrl;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
	s32 ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
	phy_ctrl = er32(PHY_CTRL);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
	phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU | E1000_PHY_CTRL_GBE_DISABLE;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
	ew32(PHY_CTRL, phy_ctrl);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
	if (hw->mac.type >= e1000_pchlan) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
		e1000_oem_bits_config_ich8lan(hw, true);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
		ret_val = hw->phy.ops.acquire(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
		if (ret_val)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
			return;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
		e1000_write_smbus_addr(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
		hw->phy.ops.release(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
 *  e1000_cleanup_led_ich8lan - Restore the default LED operation
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
 *  Return the LED back to the default configuration.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
	if (hw->phy.type == e1000_phy_ife)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
		return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
	ew32(LEDCTL, hw->mac.ledctl_default);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
 *  e1000_led_on_ich8lan - Turn LEDs on
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
 *  Turn on the LEDs.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
static s32 e1000_led_on_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
	if (hw->phy.type == e1000_phy_ife)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
		return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
				(IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
	ew32(LEDCTL, hw->mac.ledctl_mode2);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
 *  e1000_led_off_ich8lan - Turn LEDs off
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
 *  Turn off the LEDs.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
	if (hw->phy.type == e1000_phy_ife)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
		return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
			       (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
	ew32(LEDCTL, hw->mac.ledctl_mode1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
	return 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
 *  e1000_setup_led_pchlan - Configures SW controllable LED
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
 *  This prepares the SW controllable LED for use.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
	return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
					(u16)hw->mac.ledctl_mode1);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
 *  e1000_cleanup_led_pchlan - Restore the default LED operation
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
 *  Return the LED back to the default configuration.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
	return hw->phy.ops.write_reg(hw, HV_LED_CONFIG,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
					(u16)hw->mac.ledctl_default);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
 *  e1000_led_on_pchlan - Turn LEDs on
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
 *  Turn on the LEDs.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
	u16 data = (u16)hw->mac.ledctl_mode2;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
	u32 i, led;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
	 * If no link, then turn LED on by setting the invert bit
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
	 * for each LED that's mode is "link_up" in ledctl_mode2.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
	if (!(er32(STATUS) & E1000_STATUS_LU)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
		for (i = 0; i < 3; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
			led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
			if ((led & E1000_PHY_LED0_MODE_MASK) !=
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
			    E1000_LEDCTL_MODE_LINK_UP)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
				continue;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
			if (led & E1000_PHY_LED0_IVRT)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
				data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
			else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
				data |= (E1000_PHY_LED0_IVRT << (i * 5));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
	return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
 *  e1000_led_off_pchlan - Turn LEDs off
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
 *  Turn off the LEDs.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
	u16 data = (u16)hw->mac.ledctl_mode1;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
	u32 i, led;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
	/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
	 * If no link, then turn LED off by clearing the invert bit
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
	 * for each LED that's mode is "link_up" in ledctl_mode1.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
	 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
	if (!(er32(STATUS) & E1000_STATUS_LU)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
		for (i = 0; i < 3; i++) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
			led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
			if ((led & E1000_PHY_LED0_MODE_MASK) !=
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
			    E1000_LEDCTL_MODE_LINK_UP)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
				continue;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
			if (led & E1000_PHY_LED0_IVRT)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
				data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
			else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
				data |= (E1000_PHY_LED0_IVRT << (i * 5));
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
	return hw->phy.ops.write_reg(hw, HV_LED_CONFIG, data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
 *  e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
 *  Read appropriate register for the config done bit for completion status
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
 *  and configure the PHY through s/w for EEPROM-less parts.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
 *  NOTE: some silicon which is EEPROM-less will fail trying to read the
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
 *  config done bit, so only an error is logged and continues.  If we were
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
 *  to return with error, EEPROM-less silicon would not be able to be reset
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
 *  or change link.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
	s32 ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
	u32 bank = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
	u32 status;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
	e1000e_get_cfg_done(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
	/* Wait for indication from h/w that it has completed basic config */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	if (hw->mac.type >= e1000_ich10lan) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
		e1000_lan_init_done_ich8lan(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
	} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
		ret_val = e1000e_get_auto_rd_done(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
		if (ret_val) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
			/*
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
			 * When auto config read does not complete, do not
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
			 * return with an error. This can happen in situations
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
			 * where there is no eeprom and prevents getting link.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
			 */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
			e_dbg("Auto Read Done did not complete\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
			ret_val = 0;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
	/* Clear PHY Reset Asserted bit */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	status = er32(STATUS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
	if (status & E1000_STATUS_PHYRA)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
		ew32(STATUS, status & ~E1000_STATUS_PHYRA);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
	else
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
		e_dbg("PHY Reset Asserted not set - needs delay\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
	/* If EEPROM is not marked present, init the IGP 3 PHY manually */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
	if (hw->mac.type <= e1000_ich9lan) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
		if (((er32(EECD) & E1000_EECD_PRES) == 0) &&
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
		    (hw->phy.type == e1000_phy_igp_3)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
			e1000e_phy_init_script_igp3(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
	} else {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
		if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
			/* Maybe we should do a basic PHY config */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
			e_dbg("EEPROM not present\n");
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
			ret_val = -E1000_ERR_CONFIG;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
		}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
	return ret_val;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
 * @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
 * In the case of a PHY power down to save power, or to turn off link during a
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
 * driver unload, or wake on lan is not enabled, remove the link.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
	/* If the management interface is not enabled, then power down */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
	if (!(hw->mac.ops.check_mng_mode(hw) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
	      hw->phy.ops.check_reset_block(hw)))
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
		e1000_power_down_phy_copper(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
/**
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
 *  e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
 *  @hw: pointer to the HW structure
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
 *
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
 *  Clears hardware counters specific to the silicon family and calls
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
 *  clear_hw_cntrs_generic to clear all general purpose counters.
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
 **/
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
{
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
	u16 phy_data;
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
	e1000e_clear_hw_cntrs_base(hw);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
	er32(ALGNERRC);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
	er32(RXERRC);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
	er32(TNCRS);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
	er32(CEXTERR);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
	er32(TSCTC);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
	er32(TSCTFC);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
	er32(MGTPRC);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
	er32(MGTPDC);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
	er32(MGTPTC);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
	er32(IAC);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
	er32(ICRXOC);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
	/* Clear PHY statistics registers */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
	if ((hw->phy.type == e1000_phy_82578) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
	    (hw->phy.type == e1000_phy_82579) ||
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
	    (hw->phy.type == e1000_phy_82577)) {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
		hw->phy.ops.read_reg(hw, HV_SCC_UPPER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
		hw->phy.ops.read_reg(hw, HV_SCC_LOWER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
		hw->phy.ops.read_reg(hw, HV_ECOL_UPPER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
		hw->phy.ops.read_reg(hw, HV_ECOL_LOWER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
		hw->phy.ops.read_reg(hw, HV_MCC_UPPER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
		hw->phy.ops.read_reg(hw, HV_MCC_LOWER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
		hw->phy.ops.read_reg(hw, HV_LATECOL_UPPER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
		hw->phy.ops.read_reg(hw, HV_LATECOL_LOWER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
		hw->phy.ops.read_reg(hw, HV_COLC_UPPER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
		hw->phy.ops.read_reg(hw, HV_COLC_LOWER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
		hw->phy.ops.read_reg(hw, HV_DC_UPPER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
		hw->phy.ops.read_reg(hw, HV_DC_LOWER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
		hw->phy.ops.read_reg(hw, HV_TNCRS_UPPER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
		hw->phy.ops.read_reg(hw, HV_TNCRS_LOWER, &phy_data);
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
	}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
}
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
static struct e1000_mac_operations ich8_mac_ops = {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
	.id_led_init		= e1000e_id_led_init,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
	/* check_mng_mode dependent on mac type */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
	.check_for_link		= e1000_check_for_copper_link_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
	/* cleanup_led dependent on mac type */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
	.clear_hw_cntrs		= e1000_clear_hw_cntrs_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
	.get_bus_info		= e1000_get_bus_info_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
	.set_lan_id		= e1000_set_lan_id_single_port,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
	.get_link_up_info	= e1000_get_link_up_info_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
	/* led_on dependent on mac type */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
	/* led_off dependent on mac type */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
	.update_mc_addr_list	= e1000e_update_mc_addr_list_generic,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
	.reset_hw		= e1000_reset_hw_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
	.init_hw		= e1000_init_hw_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
	.setup_link		= e1000_setup_link_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
	.setup_physical_interface= e1000_setup_copper_link_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
	/* id_led_init dependent on mac type */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
static struct e1000_phy_operations ich8_phy_ops = {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
	.acquire		= e1000_acquire_swflag_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
	.check_reset_block	= e1000_check_reset_block_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
	.commit			= NULL,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
	.get_cfg_done		= e1000_get_cfg_done_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
	.get_cable_length	= e1000e_get_cable_length_igp_2,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
	.read_reg		= e1000e_read_phy_reg_igp,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
	.release		= e1000_release_swflag_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
	.reset			= e1000_phy_hw_reset_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
	.set_d0_lplu_state	= e1000_set_d0_lplu_state_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
	.set_d3_lplu_state	= e1000_set_d3_lplu_state_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
	.write_reg		= e1000e_write_phy_reg_igp,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
static struct e1000_nvm_operations ich8_nvm_ops = {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
	.acquire		= e1000_acquire_nvm_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
	.read		 	= e1000_read_nvm_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
	.release		= e1000_release_nvm_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
	.update			= e1000_update_nvm_checksum_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
	.valid_led_default	= e1000_valid_led_default_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
	.validate		= e1000_validate_nvm_checksum_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
	.write			= e1000_write_nvm_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
struct e1000_info e1000_ich8_info = {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
	.mac			= e1000_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
	.flags			= FLAG_HAS_WOL
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
				  | FLAG_IS_ICH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
				  | FLAG_RX_CSUM_ENABLED
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
				  | FLAG_HAS_CTRLEXT_ON_LOAD
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
				  | FLAG_HAS_AMT
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
				  | FLAG_HAS_FLASH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
				  | FLAG_APME_IN_WUC,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
	.pba			= 8,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
	.max_hw_frame_size	= ETH_FRAME_LEN + ETH_FCS_LEN,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
	.get_variants		= e1000_get_variants_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
	.mac_ops		= &ich8_mac_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
	.phy_ops		= &ich8_phy_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
	.nvm_ops		= &ich8_nvm_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
struct e1000_info e1000_ich9_info = {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
	.mac			= e1000_ich9lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
	.flags			= FLAG_HAS_JUMBO_FRAMES
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
				  | FLAG_IS_ICH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
				  | FLAG_HAS_WOL
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
				  | FLAG_RX_CSUM_ENABLED
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
				  | FLAG_HAS_CTRLEXT_ON_LOAD
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
				  | FLAG_HAS_AMT
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
				  | FLAG_HAS_ERT
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
				  | FLAG_HAS_FLASH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
				  | FLAG_APME_IN_WUC,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
	.pba			= 10,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
	.max_hw_frame_size	= DEFAULT_JUMBO,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
	.get_variants		= e1000_get_variants_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
	.mac_ops		= &ich8_mac_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
	.phy_ops		= &ich8_phy_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
	.nvm_ops		= &ich8_nvm_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
struct e1000_info e1000_ich10_info = {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
	.mac			= e1000_ich10lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
	.flags			= FLAG_HAS_JUMBO_FRAMES
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
				  | FLAG_IS_ICH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
				  | FLAG_HAS_WOL
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
				  | FLAG_RX_CSUM_ENABLED
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
				  | FLAG_HAS_CTRLEXT_ON_LOAD
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
				  | FLAG_HAS_AMT
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
				  | FLAG_HAS_ERT
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
				  | FLAG_HAS_FLASH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
				  | FLAG_APME_IN_WUC,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
	.pba			= 10,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
	.max_hw_frame_size	= DEFAULT_JUMBO,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
	.get_variants		= e1000_get_variants_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
	.mac_ops		= &ich8_mac_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
	.phy_ops		= &ich8_phy_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
	.nvm_ops		= &ich8_nvm_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
struct e1000_info e1000_pch_info = {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
	.mac			= e1000_pchlan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
	.flags			= FLAG_IS_ICH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
				  | FLAG_HAS_WOL
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
				  | FLAG_RX_CSUM_ENABLED
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
				  | FLAG_HAS_CTRLEXT_ON_LOAD
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
				  | FLAG_HAS_AMT
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
				  | FLAG_HAS_FLASH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
				  | FLAG_HAS_JUMBO_FRAMES
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
				  | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
				  | FLAG_APME_IN_WUC,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
	.flags2			= FLAG2_HAS_PHY_STATS,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
	.pba			= 26,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
	.max_hw_frame_size	= 4096,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
	.get_variants		= e1000_get_variants_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
	.mac_ops		= &ich8_mac_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
	.phy_ops		= &ich8_phy_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
	.nvm_ops		= &ich8_nvm_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
};
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
struct e1000_info e1000_pch2_info = {
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
	.mac			= e1000_pch2lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
	.flags			= FLAG_IS_ICH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
				  | FLAG_HAS_WOL
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
				  | FLAG_RX_CSUM_ENABLED
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
				  | FLAG_HAS_CTRLEXT_ON_LOAD
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
				  | FLAG_HAS_AMT
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
				  | FLAG_HAS_FLASH
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
				  | FLAG_HAS_JUMBO_FRAMES
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
				  | FLAG_APME_IN_WUC,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
	.flags2			= FLAG2_HAS_PHY_STATS
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
				  | FLAG2_HAS_EEE,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
	.pba			= 26,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
	.max_hw_frame_size	= DEFAULT_JUMBO,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
	.get_variants		= e1000_get_variants_ich8lan,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
	.mac_ops		= &ich8_mac_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
	.phy_ops		= &ich8_phy_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
	.nvm_ops		= &ich8_nvm_ops,
941f2d72f115 Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
};