devices/e1000e/ich8lan-2.6.37-ethercat.c
author Florian Pose <fp@igh-essen.com>
Wed, 09 Nov 2011 12:58:09 +0100
branchredundancy
changeset 2157 8fa0571f9996
parent 2135 f99b2249704c
child 2234 18f9c69d9590
permissions -rw-r--r--
Poll both devices.
2135
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2010 Intel Corporation.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
f99b2249704c 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
f99b2249704c 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,
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
f99b2249704c 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
f99b2249704c 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.,
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
f99b2249704c 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>
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
/*
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
 * 82562G 10/100 Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
 * 82562G-2 10/100 Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 * 82562GT 10/100 Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
 * 82562GT-2 10/100 Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
 * 82562V 10/100 Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
 * 82562V-2 10/100 Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
 * 82566DC-2 Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
 * 82566DC Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
 * 82566DM-2 Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
 * 82566DM Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
 * 82566MC Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
 * 82566MM Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
 * 82567LM Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
 * 82567LF Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
 * 82567V Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
 * 82567LM-2 Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
 * 82567LF-2 Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
 * 82567V-2 Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
 * 82567LF-3 Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
 * 82567LM-3 Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
 * 82567LM-4 Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
 * 82577LM Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
 * 82577LC Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
 * 82578DM Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
 * 82578DC Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
 * 82579LM Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
 * 82579V Gigabit Network Connection
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
#include "e1000-2.6.37-ethercat.h"
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
#define ICH_FLASH_GFPREG		0x0000
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
#define ICH_FLASH_HSFSTS		0x0004
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
#define ICH_FLASH_HSFCTL		0x0006
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
#define ICH_FLASH_FADDR			0x0008
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
#define ICH_FLASH_FDATA0		0x0010
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
#define ICH_FLASH_PR0			0x0074
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
#define ICH_FLASH_READ_COMMAND_TIMEOUT	500
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
#define ICH_FLASH_WRITE_COMMAND_TIMEOUT	500
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
#define ICH_FLASH_ERASE_COMMAND_TIMEOUT	3000000
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
#define ICH_FLASH_LINEAR_ADDR_MASK	0x00FFFFFF
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
#define ICH_FLASH_CYCLE_REPEAT_COUNT	10
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
#define ICH_CYCLE_READ			0
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
#define ICH_CYCLE_WRITE			2
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
#define ICH_CYCLE_ERASE			3
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
#define FLASH_GFPREG_BASE_MASK		0x1FFF
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
#define FLASH_SECTOR_ADDR_SHIFT		12
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
#define ICH_FLASH_SEG_SIZE_256		256
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
#define ICH_FLASH_SEG_SIZE_4K		4096
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
#define ICH_FLASH_SEG_SIZE_8K		8192
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
#define ICH_FLASH_SEG_SIZE_64K		65536
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
/* FW established a valid mode */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
#define E1000_ICH_FWSM_FW_VALID		0x00008000
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
#define E1000_ICH_MNG_IAMT_MODE		0x2
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
f99b2249704c 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) | \
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
				 (ID_LED_DEF1_OFF2 <<  8) | \
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
				 (ID_LED_DEF1_ON2  <<  4) | \
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
				 (ID_LED_DEF1_DEF2))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
#define E1000_ICH_NVM_SIG_WORD		0x13
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
#define E1000_ICH_NVM_SIG_MASK		0xC000
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
#define E1000_ICH_NVM_SIG_VALUE         0x80
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
#define E1000_ICH8_LAN_INIT_TIMEOUT	1500
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
#define E1000_FEXTNVM_SW_CONFIG		1
f99b2249704c 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 :/ */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
#define E1000_FEXTNVM4_BEACON_DURATION_MASK    0x7
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
#define E1000_FEXTNVM4_BEACON_DURATION_8USEC   0x7
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
#define E1000_FEXTNVM4_BEACON_DURATION_16USEC  0x3
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
#define E1000_ICH_RAR_ENTRIES		7
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
#define PHY_PAGE_SHIFT 5
f99b2249704c 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) | \
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
			   ((reg) & MAX_PHY_REG_ADDRESS))
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
#define IGP3_VR_CTRL_MODE_SHUTDOWN	0x0200
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
/* SMBus Address Phy Register */
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
#define HV_SMB_ADDR_MASK       0x007F
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
#define HV_SMB_ADDR_PEC_EN     0x0200
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
#define HV_SMB_ADDR_VALID      0x0080
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
/* PHY Power Management Control */
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
/* PHY Low Power Idle Control */
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
#define I82579_LPI_CTRL_ENABLE_MASK	0x6000
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
/* Strapping Option Register - RO */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
#define E1000_STRAP                     0x0000C
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
#define E1000_STRAP_SMBUS_ADDRESS_MASK  0x00FE0000
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
#define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
/* OEM Bits Phy Register */
f99b2249704c 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)
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
/* KMRN Mode Control */
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
#define HV_KMRN_MDIO_SLOW      0x0400
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
/* Offset 04h HSFSTS */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
union ich8_hws_flash_status {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
	struct ich8_hsfsts {
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
		u16 reserved1  :2; /* bit 13:6 Reserved */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
		u16 reserved2  :6; /* bit 13:6 Reserved */
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
	} hsf_status;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
	u16 regval;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
/* Offset 06h FLCTL */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
union ich8_hws_flash_ctrl {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
	struct ich8_hsflctl {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
		u16 flcgo      :1;   /* 0 Flash Cycle Go */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
		u16 flcycle    :2;   /* 2:1 Flash Cycle */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
		u16 reserved   :5;   /* 7:3 Reserved  */
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
		u16 flockdn    :6;   /* 15:10 Reserved */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
	} hsf_ctrl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
	u16 regval;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
/* ICH Flash Region Access Permissions */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
union ich8_hws_flash_regacc {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
	struct ich8_flracc {
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
	} hsf_flregacc;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
	u16 regval;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
/* ICH Flash Protected Region */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
union ich8_flash_protected_range {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
	struct ich8_pr {
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
		u32 reserved1:2; /* 13:14 Reserved */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
		u32 rpe:1;       /* 15 Read Protection Enable */
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
		u32 reserved2:2; /* 29:30 Reserved */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
		u32 wpe:1;       /* 31 Write Protection Enable */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
	} range;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
	u32 regval;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
						u32 offset, u8 byte);
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
					 u8 *data);
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
					 u16 *data);
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
					 u8 size, u16 *data);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
	return readw(hw->flash_address + reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
	return readl(hw->flash_address + reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
	writew(val, hw->flash_address + reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
	writel(val, hw->flash_address + reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
#define er16flash(reg)		__er16flash(hw, (reg))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
#define er32flash(reg)		__er32flash(hw, (reg))
f99b2249704c 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))
f99b2249704c 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))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
	struct e1000_phy_info *phy = &hw->phy;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
	u32 ctrl, fwsm;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
	phy->addr                     = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
	phy->reset_delay_us           = 100;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
	phy->autoneg_mask             = AUTONEG_ADVERTISE_SPEED_DEFAULT;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
	 * the interconnect to PCIe mode.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
	fwsm = er32(FWSM);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
	if (!(fwsm & E1000_ICH_FWSM_FW_VALID)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
		ctrl = er32(CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
		ctrl |=  E1000_CTRL_LANPHYPC_OVERRIDE;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
		ctrl &= ~E1000_CTRL_LANPHYPC_VALUE;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
		ew32(CTRL, ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
		udelay(10);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
		ctrl &= ~E1000_CTRL_LANPHYPC_OVERRIDE;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
		ew32(CTRL, ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
		msleep(50);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
		/*
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
		 * Gate automatic PHY configuration by hardware on
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
		 * non-managed 82579
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
		if (hw->mac.type == e1000_pch2lan)
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
	/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	 * the PHY type yet.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
	 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
	if ((hw->mac.type == e1000_pch2lan)  &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
	    !(fwsm & E1000_ICH_FWSM_FW_VALID)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
		msleep(10);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
	phy->id = e1000_phy_unknown;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
	switch (hw->mac.type) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
	default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
		ret_val = e1000e_get_phy_id(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
			goto out;
f99b2249704c 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))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
		/* fall-through */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
	case e1000_pch2lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
		/*
f99b2249704c 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,
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
		 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
		ret_val = e1000e_get_phy_id(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
	}
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
	switch (phy->type) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
	case e1000_phy_82577:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
	case e1000_phy_82579:
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
		phy->ops.force_speed_duplex =
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
			e1000_phy_force_speed_duplex_82577;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
		phy->ops.commit = e1000e_phy_sw_reset;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
	case e1000_phy_82578:
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
	default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
		ret_val = -E1000_ERR_PHY;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
	struct e1000_phy_info *phy = &hw->phy;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
	u16 i = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
	phy->addr			= 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
	phy->reset_delay_us		= 100;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
	/*
f99b2249704c 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,
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
	ret_val = e1000e_determine_phy_address(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
	if (ret_val) {
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
		ret_val = e1000e_determine_phy_address(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
		if (ret_val) {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
	phy->id = 0;
f99b2249704c 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)) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
	       (i++ < 100)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
		msleep(1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
		ret_val = e1000e_get_phy_id(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
	/* Verify phy id */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
	switch (phy->id) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
	case IGP03E1000_E_PHY_ID:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
		phy->type = e1000_phy_igp_3;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
		phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
	case IFE_E_PHY_ID:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
	case IFE_PLUS_E_PHY_ID:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
	case IFE_C_E_PHY_ID:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
		phy->type = e1000_phy_ife;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
		phy->autoneg_mask = E1000_ALL_NOT_GIG;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
	case BME1000_E_PHY_ID:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
		phy->type = e1000_phy_bm;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
		phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
		phy->ops.commit = e1000e_phy_sw_reset;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
	default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
		return -E1000_ERR_PHY;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
 *  Initialize family-specific NVM parameters and function
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
 *  pointers.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
	struct e1000_nvm_info *nvm = &hw->nvm;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
	u16 i;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
f99b2249704c 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. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
	if (!hw->flash_address) {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
		return -E1000_ERR_CONFIG;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
	nvm->type = e1000_nvm_flash_sw;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
	gfpreg = er32flash(ICH_FLASH_GFPREG);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
	/*
f99b2249704c 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)
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
	 * the overall size.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
	 */
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
	/* flash_base_addr is byte-aligned */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
	/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
	 * size represents two separate NVM banks.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
	 */
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
				<< FLASH_SECTOR_ADDR_SHIFT;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
	nvm->flash_bank_size /= 2;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
	/* Adjust to word count */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
	nvm->flash_bank_size /= sizeof(u16);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
	/* Clear shadow ram */
f99b2249704c 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++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
		dev_spec->shadow_ram[i].modified = false;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
		dev_spec->shadow_ram[i].value    = 0xFFFF;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
 *  Initialize family-specific MAC parameters and function
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
 *  pointers.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
	struct e1000_hw *hw = &adapter->hw;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
	struct e1000_mac_info *mac = &hw->mac;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
	/* Set media type function pointer */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
	/* Set mta register count */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
	mac->mta_reg_count = 32;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
	/* Set rar entry count */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
	if (mac->type == e1000_ich8lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
		mac->rar_entry_count--;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
	/* FWSM register */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
	mac->has_fwsm = true;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
	/* ARC subsystem not supported */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
	mac->arc_subsystem_valid = false;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
	/* Adaptive IFS supported */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
	mac->adaptive_ifs = true;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
	/* LED operations */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
	switch (mac->type) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
	case e1000_ich8lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
	case e1000_ich9lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
	case e1000_ich10lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
		/* check management mode */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
		/* ID LED init */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
		/* setup LED */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
		/* cleanup LED */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
		/* turn on/off LED */
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
	case e1000_pchlan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
	case e1000_pch2lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
		/* check management mode */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
		/* ID LED init */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
		/* setup LED */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
		/* cleanup LED */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
		/* turn on/off LED */
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
	default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
	/* Enable PCS Lock-loss workaround for ICH8 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
	if (mac->type == e1000_ich8lan)
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
	if ((mac->type == e1000_pch2lan) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
	    (er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
 *
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
	u16 phy_reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
	if (hw->phy.type != e1000_phy_82579)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
	if (hw->dev_spec.ich8lan.eee_disable)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
		phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
	else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
		phy_reg |= I82579_LPI_CTRL_ENABLE_MASK;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
/**
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
	struct e1000_mac_info *mac = &hw->mac;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
	bool link;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
	 * Change or Rx Sequence Error interrupt.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
	if (!mac->get_link_status) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
		ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	 * of the PHY.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
	 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
	if (hw->mac.type == e1000_pchlan) {
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
	if (!link)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
		goto out; /* No link detected */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
	mac->get_link_status = false;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
	if (hw->phy.type == e1000_phy_82578) {
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
	if (hw->mac.type == e1000_pch2lan) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
		ret_val = e1000_k1_workaround_lv(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
	/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
	 * immediately after link-up
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
	e1000e_check_downshift(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
	/* Enable/Disable EEE after link up */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
	ret_val = e1000_set_eee_pchlan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
	/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
	if (!mac->autoneg) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
		ret_val = -E1000_ERR_CONFIG;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
	 * configure Collision Distance in the MAC.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
	e1000e_config_collision_dist(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
	/*
f99b2249704c 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.
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
	 * different link partner.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
	 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
		e_dbg("Error configuring flow control\n");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
	struct e1000_hw *hw = &adapter->hw;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
	s32 rc;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
	rc = e1000_init_mac_params_ich8lan(adapter);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
	if (rc)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
		return rc;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
	rc = e1000_init_nvm_params_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
	if (rc)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
		return rc;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
	switch (hw->mac.type) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
	case e1000_ich8lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
	case e1000_ich9lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
	case e1000_ich10lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
		rc = e1000_init_phy_params_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
	case e1000_pchlan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
	case e1000_pch2lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
		rc = e1000_init_phy_params_pchlan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
	default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
	if (rc)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
		return rc;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
f99b2249704c 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) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
		adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
	if ((adapter->hw.mac.type == e1000_ich8lan) &&
f99b2249704c 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))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
		adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
	if (adapter->flags2 & FLAG2_HAS_EEE)
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
static DEFINE_MUTEX(nvm_mutex);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
/**
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
 *  e1000_acquire_nvm_ich8lan - Acquire NVM mutex
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
 *  Acquires the mutex for performing NVM operations.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
	mutex_lock(&nvm_mutex);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
/**
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
 *  e1000_release_nvm_ich8lan - Release NVM mutex
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
	mutex_unlock(&nvm_mutex);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
static DEFINE_MUTEX(swflag_mutex);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
 *  MAC CSR accesses.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
	u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
	mutex_lock(&swflag_mutex);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
	while (timeout) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
		extcnf_ctrl = er32(EXTCNF_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
		if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
		mdelay(1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
		timeout--;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
	if (!timeout) {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
		ret_val = -E1000_ERR_CONFIG;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
	timeout = SW_FLAG_TIMEOUT;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
	extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
	ew32(EXTCNF_CTRL, extcnf_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
	while (timeout) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
		extcnf_ctrl = er32(EXTCNF_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
		if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
		mdelay(1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
		timeout--;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	if (!timeout) {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
		extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
		ew32(EXTCNF_CTRL, extcnf_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
		ret_val = -E1000_ERR_CONFIG;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
		mutex_unlock(&swflag_mutex);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
 *  MAC CSR accesses.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
	u32 extcnf_ctrl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
	extcnf_ctrl = er32(EXTCNF_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
	extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
	ew32(EXTCNF_CTRL, extcnf_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
	mutex_unlock(&swflag_mutex);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
 *
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
 *  routines for the PHY and NVM parts.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
	u32 fwsm;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
	fwsm = er32(FWSM);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
	return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
	       ((fwsm & E1000_FWSM_MODE_MASK) ==
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
 *
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
 *  routines for the PHY and NVM parts.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
	u32 fwsm;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
	fwsm = er32(FWSM);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
	return (fwsm & E1000_ICH_FWSM_FW_VALID) &&
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
 *
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
 *  reset routines.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
	u32 fwsm;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
	fwsm = er32(FWSM);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
 *  Assumes semaphore already acquired.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
	u16 phy_data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
	u32 strap = er32(STRAP);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
	strap &= E1000_STRAP_SMBUS_ADDRESS_MASK;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
	phy_data &= ~HV_SMB_ADDR_MASK;
f99b2249704c 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);
f99b2249704c 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;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
 *  @hw:   pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
 *  as a workaround for certain parts.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
	struct e1000_phy_info *phy = &hw->phy;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
	s32 ret_val = 0;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
	 * not properly autoloaded after power transitions.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
	 * configuration data out of the NVM manually.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
	switch (hw->mac.type) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
	case e1000_ich8lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
		if (phy->type != e1000_phy_igp_3)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
f99b2249704c 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) ||
f99b2249704c 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)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
			sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
		/* Fall-thru */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
	case e1000_pchlan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
	case e1000_pch2lan:
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
	default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
	ret_val = hw->phy.ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	data = er32(FEXTNVM);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
	if (!(data & sw_cfg_mask))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
	/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
	 * extended configuration before SW configuration
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
	data = er32(EXTCNF_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
	if (!(hw->mac.type == e1000_pch2lan)) {
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
	cnf_size = er32(EXTCNF_SIZE);
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
	if (!cnf_size)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
f99b2249704c 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) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	    (hw->mac.type == e1000_pchlan)) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
	     (hw->mac.type == e1000_pch2lan)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
		/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		 * them instead.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
		ret_val = e1000_write_smbus_addr(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
		data = er32(LEDCTL);
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
							(u16)data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
	/* Configure LCD from extended configuration region. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
	/* cnf_base_addr is in DWORD */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
	word_addr = (u16)(cnf_base_addr << 1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
	for (i = 0; i < cnf_size; i++) {
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
					 &reg_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
f99b2249704c 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),
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
					 1, &reg_addr);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
f99b2249704c 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. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
		if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
			phy_page = reg_data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
			continue;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
		reg_addr &= PHY_REG_MASK;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
		reg_addr |= phy_page;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
						    reg_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
	hw->phy.ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
 *  @hw:   pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
 *  @link: link up bool flag
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
 *  in the NVM.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
	u16 status_reg = 0;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
	if (hw->mac.type != e1000_pchlan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
	ret_val = hw->phy.ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
	if (link) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
		if (hw->phy.type == e1000_phy_82578) {
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
			                                          &status_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
				goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
			status_reg &= BM_CS_STATUS_LINK_UP |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
			              BM_CS_STATUS_RESOLVED |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
			              BM_CS_STATUS_SPEED_MASK;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
f99b2249704c 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 |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
			                   BM_CS_STATUS_RESOLVED |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
			                   BM_CS_STATUS_SPEED_1000))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
				k1_enable = false;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
		if (hw->phy.type == e1000_phy_82577) {
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
			                                          &status_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
				goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
			status_reg &= HV_M_STATUS_LINK_UP |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
			              HV_M_STATUS_AUTONEG_COMPLETE |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
			              HV_M_STATUS_SPEED_MASK;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
f99b2249704c 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 |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
			                   HV_M_STATUS_AUTONEG_COMPLETE |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
			                   HV_M_STATUS_SPEED_1000))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
				k1_enable = false;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
		/* Link stall fix for link up */
f99b2249704c 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),
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
		                                           0x0100);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
			goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
	} else {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
		/* Link stall fix for link down */
f99b2249704c 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),
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
		                                           0x4100);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
			goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
release:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
	hw->phy.ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
 *  @enable: K1 state to configure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
 *  Assumes semaphore already acquired.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
 *
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
	u32 ctrl_reg = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
	u32 ctrl_ext = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
	u32 reg = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
	u16 kmrn_reg = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
	                                     E1000_KMRNCTRLSTA_K1_CONFIG,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
	                                     &kmrn_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
	if (k1_enable)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
		kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
	else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
		kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
	                                      E1000_KMRNCTRLSTA_K1_CONFIG,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
	                                      kmrn_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
	udelay(20);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
	ctrl_ext = er32(CTRL_EXT);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
	ctrl_reg = er32(CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
	reg |= E1000_CTRL_FRCSPD;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
	ew32(CTRL, reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
	udelay(20);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
	ew32(CTRL, ctrl_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
	ew32(CTRL_EXT, ctrl_ext);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
	udelay(20);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
 *  @hw:       pointer to the HW structure
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
	u32 mac_reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
	u16 oem_reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
f99b2249704c 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))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
	ret_val = hw->phy.ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
	if (!(hw->mac.type == e1000_pch2lan)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
		mac_reg = er32(EXTCNF_CTRL);
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
	mac_reg = er32(FEXTNVM);
f99b2249704c 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))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
	mac_reg = er32(PHY_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
	if (d0_state) {
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
			oem_reg |= HV_OEM_BITS_GBE_DIS;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
			oem_reg |= HV_OEM_BITS_LPLU;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
	} else {
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
			oem_reg |= HV_OEM_BITS_GBE_DIS;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
			oem_reg |= HV_OEM_BITS_LPLU;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
	/* Restart auto-neg to activate the bits */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
	if (!e1000_check_reset_block(hw))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
		oem_reg |= HV_OEM_BITS_RESTART_AN;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
	hw->phy.ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
 *  @hw:   pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
	u16 data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
	data |= HV_KMRN_MDIO_SLOW;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
 *  done after every PHY reset.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
	u16 phy_data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
	if (hw->mac.type != e1000_pchlan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	if (hw->phy.type == e1000_phy_82577) {
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
	if (((hw->phy.type == e1000_phy_82577) &&
f99b2249704c 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))) ||
f99b2249704c 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))) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
		/* Disable generation of early preamble */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
		/* Preamble tuning for SSC */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
	if (hw->phy.type == e1000_phy_82578) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
		/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
		 * writing 0x3140 to the control register.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
		if (hw->phy.revision < 2) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
			e1000e_phy_sw_reset(hw);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
	/* Select page 0 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
	ret_val = hw->phy.ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
	hw->phy.addr = 1;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
	hw->phy.ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
	/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
	 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
	ret_val = hw->phy.ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
		goto out;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
	                                      PHY_REG(BM_PORT_CTRL_PAGE, 17),
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
	                                      &phy_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
		goto release;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	                                       PHY_REG(BM_PORT_CTRL_PAGE, 17),
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
	                                       phy_data & 0x00FF);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
release:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	hw->phy.ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
 *  @hw:   pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
	u32 mac_reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
	u16 i;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
f99b2249704c 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 */
f99b2249704c 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++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
		mac_reg = er32(RAL(i));
f99b2249704c 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));
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
		mac_reg = er32(RAH(i));
f99b2249704c 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));
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
f99b2249704c 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[])
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
{
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	u32 i, j, mask, crc;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
	crc = 0xffffffff;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	for (i = 0; i < 6; i++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
		crc = crc ^ mac[i];
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
		for (j = 8; j > 0; j--) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
			mask = (crc & 1) * (-1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
			crc = (crc >> 1) ^ (poly & mask);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
	return ~crc;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
 *  with 82579 PHY
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
 *  @hw: pointer to the HW structure
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
	u16 phy_reg, data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
	u32 mac_reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
	u16 i;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
	if (hw->mac.type != e1000_pch2lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
	/* disable Rx path while enabling/disabling workaround */
f99b2249704c 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);
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
	if (enable) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
		/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
		 */
f99b2249704c 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++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
			u8 mac_addr[ETH_ALEN] = {0};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
			u32 addr_high, addr_low;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
			addr_high = er32(RAH(i));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
			if (!(addr_high & E1000_RAH_AV))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
				continue;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
			addr_low = er32(RAL(i));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
			mac_addr[0] = (addr_low & 0xFF);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
			mac_addr[1] = ((addr_low >> 8) & 0xFF);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
			mac_addr[2] = ((addr_low >> 16) & 0xFF);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
			mac_addr[3] = ((addr_low >> 24) & 0xFF);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
			mac_addr[4] = (addr_high & 0xFF);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
			mac_addr[5] = ((addr_high >> 8) & 0xFF);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
			ew32(PCH_RAICC(i),
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
					e1000_calc_rx_da_crc(mac_addr));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
		/* Write Rx addresses to the PHY */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
		/* Enable jumbo frame workaround in the MAC */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
		mac_reg = er32(FFLT_DBG);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
		mac_reg &= ~(1 << 14);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
		mac_reg |= (7 << 15);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
		ew32(FFLT_DBG, mac_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
		mac_reg = er32(RCTL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
		mac_reg |= E1000_RCTL_SECRC;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
		ew32(RCTL, mac_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
		ret_val = e1000e_read_kmrn_reg(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
						E1000_KMRNCTRLSTA_CTRL_OFFSET,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
						&data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
		ret_val = e1000e_write_kmrn_reg(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
						E1000_KMRNCTRLSTA_CTRL_OFFSET,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
						data | (1 << 0));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
		ret_val = e1000e_read_kmrn_reg(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
						E1000_KMRNCTRLSTA_HD_CTRL,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
						&data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
		data &= ~(0xF << 8);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
		data |= (0xB << 8);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
		ret_val = e1000e_write_kmrn_reg(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
						E1000_KMRNCTRLSTA_HD_CTRL,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
						data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
		/* Enable jumbo frame workaround in the PHY */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
		data &= ~(0x7F << 5);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
		data |= (0x37 << 5);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
			goto out;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
		data &= ~(1 << 13);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
			goto out;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
		data &= ~(0x3FF << 2);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
		data |= (0x1A << 2);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
			goto out;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
		e1e_rphy(hw, HV_PM_CTRL, &data);
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
	} else {
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
		mac_reg = er32(FFLT_DBG);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
		mac_reg &= ~(0xF << 14);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
		ew32(FFLT_DBG, mac_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
		mac_reg = er32(RCTL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
		mac_reg &= ~E1000_RCTL_SECRC;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
		ew32(RCTL, mac_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
		ret_val = e1000e_read_kmrn_reg(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
						E1000_KMRNCTRLSTA_CTRL_OFFSET,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
						&data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
		ret_val = e1000e_write_kmrn_reg(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
						E1000_KMRNCTRLSTA_CTRL_OFFSET,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
						data & ~(1 << 0));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
		ret_val = e1000e_read_kmrn_reg(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
						E1000_KMRNCTRLSTA_HD_CTRL,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
						&data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
		data &= ~(0xF << 8);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
		data |= (0xB << 8);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
		ret_val = e1000e_write_kmrn_reg(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
						E1000_KMRNCTRLSTA_HD_CTRL,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
						data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
f99b2249704c 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 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
		data &= ~(0x7F << 5);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
			goto out;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
		data |= (1 << 13);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
			goto out;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
		data &= ~(0x3FF << 2);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
		data |= (0x8 << 2);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
			goto out;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
		e1e_rphy(hw, HV_PM_CTRL, &data);
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
f99b2249704c 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 */
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
 *  done after every PHY reset.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
	if (hw->mac.type != e1000_pch2lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
f99b2249704c 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 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
 *  @hw:   pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
	u16 status_reg = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
	u32 mac_reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
	if (hw->mac.type != e1000_pch2lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
f99b2249704c 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 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
f99b2249704c 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))
f99b2249704c 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)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
		mac_reg = er32(FEXTNVM4);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
		mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
			mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
		else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
			mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
		ew32(FEXTNVM4, mac_reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
 *  @hw:   pointer to the HW structure
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
 *  the configuration via software instead.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
	u32 extcnf_ctrl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
	if (hw->mac.type != e1000_pch2lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
		return;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
	extcnf_ctrl = er32(EXTCNF_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
	if (gate)
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
	else
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
	ew32(EXTCNF_CTRL, extcnf_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
	return;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
 *  PHY after a software reset.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
{
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
	/* Wait for basic configuration completes before proceeding */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
	do {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
		data = er32(STATUS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
		data &= E1000_STATUS_LAN_INIT_DONE;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
		udelay(100);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
	} while ((!data) && --loop);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
	if (loop == 0)
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
	data = er32(STATUS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
	data &= ~E1000_STATUS_LAN_INIT_DONE;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
	ew32(STATUS, data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
	u16 reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
	if (e1000_check_reset_block(hw))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
	msleep(10);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
	/* Perform any necessary post-reset workarounds */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
	switch (hw->mac.type) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
	case e1000_pchlan:
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
	case e1000_pch2lan:
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
	default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
	if (hw->mac.type >= e1000_pchlan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
		e1e_rphy(hw, BM_WUC, &reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
f99b2249704c 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 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
f99b2249704c 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 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
	if ((hw->mac.type == e1000_pch2lan) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
	    !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
		msleep(10);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
 *  Resets the PHY
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
 *  or other shared routines.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
	if ((hw->mac.type == e1000_pch2lan) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
	    !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
 *  @hw: pointer to the HW structure
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
 *  since it configures the same bit.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
	u16 oem_reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
	if (active)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
		oem_reg |= HV_OEM_BITS_LPLU;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
	else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
		oem_reg &= ~HV_OEM_BITS_LPLU;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
	oem_reg |= HV_OEM_BITS_RESTART_AN;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
 *  @hw: pointer to the HW structure
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
 *  device autonegotiation advertisement meets standards of
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
 *  PHY setup routines.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
	struct e1000_phy_info *phy = &hw->phy;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
	u32 phy_ctrl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	u16 data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
	if (phy->type == e1000_phy_ife)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
	phy_ctrl = er32(PHY_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
	if (active) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
		phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
		ew32(PHY_CTRL, phy_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
		if (phy->type != e1000_phy_igp_3)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
			return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
		/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
		 * any PHY registers
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
		if (hw->mac.type == e1000_ich8lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
			e1000e_gig_downshift_workaround_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
f99b2249704c 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 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
		data &= ~IGP01E1000_PSCFR_SMART_SPEED;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
	} else {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
		phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
		ew32(PHY_CTRL, phy_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
		if (phy->type != e1000_phy_igp_3)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
			return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
		/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
		 * important.  During driver activity we should enable
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
		 * SmartSpeed, so performance is maintained.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
		 */
f99b2249704c 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) {
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
					   &data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
				return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
			data |= IGP01E1000_PSCFR_SMART_SPEED;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
					   data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
				return ret_val;
f99b2249704c 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) {
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
					   &data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
				return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
			data &= ~IGP01E1000_PSCFR_SMART_SPEED;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
					   data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
				return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
 *  @hw: pointer to the HW structure
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
 *  device autonegotiation advertisement meets standards of
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
 *  PHY setup routines.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
	struct e1000_phy_info *phy = &hw->phy;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
	u32 phy_ctrl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
	u16 data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
	phy_ctrl = er32(PHY_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
	if (!active) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
		phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
		ew32(PHY_CTRL, phy_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
		if (phy->type != e1000_phy_igp_3)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
			return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
		/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
		 * important.  During driver activity we should enable
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
		 * SmartSpeed, so performance is maintained.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
		 */
f99b2249704c 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) {
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
					   &data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
				return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
			data |= IGP01E1000_PSCFR_SMART_SPEED;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
					   data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
				return ret_val;
f99b2249704c 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) {
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
					   &data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
				return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
			data &= ~IGP01E1000_PSCFR_SMART_SPEED;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
					   data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
				return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
		}
f99b2249704c 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) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
		   (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
		   (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
		phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
		ew32(PHY_CTRL, phy_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
		if (phy->type != e1000_phy_igp_3)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
			return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
		/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
		 * any PHY registers
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
		if (hw->mac.type == e1000_ich8lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
			e1000e_gig_downshift_workaround_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
f99b2249704c 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 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
		data &= ~IGP01E1000_PSCFR_SMART_SPEED;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
 *  @hw: pointer to the HW structure
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
 *
f99b2249704c 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.
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
	u32 eecd;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
	struct e1000_nvm_info *nvm = &hw->nvm;
f99b2249704c 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);
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
	u8 sig_byte = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
	switch (hw->mac.type) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
	case e1000_ich8lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
	case e1000_ich9lan:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
		eecd = er32(EECD);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
		if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) ==
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
		    E1000_EECD_SEC1VAL_VALID_MASK) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
			if (eecd & E1000_EECD_SEC1VAL)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
				*bank = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
			else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
				*bank = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
			return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
		}
f99b2249704c 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 - "
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
		       "reading flash signature\n");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
		/* fall-thru */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
	default:
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
		*bank = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
		/* Check bank 0 */
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
		                                        &sig_byte);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
			return ret_val;
f99b2249704c 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) ==
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
		    E1000_ICH_NVM_SIG_VALUE) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
			*bank = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
			return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
		/* Check bank 1 */
f99b2249704c 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 +
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
		                                        bank1_offset,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
		                                        &sig_byte);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
			return ret_val;
f99b2249704c 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) ==
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
		    E1000_ICH_NVM_SIG_VALUE) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
			*bank = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
			return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
		return -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
 *  @hw: pointer to the HW structure
f99b2249704c 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.
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
				  u16 *data)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
	struct e1000_nvm_info *nvm = &hw->nvm;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
	u32 act_offset;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
	u32 bank = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
	u16 i, word;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
f99b2249704c 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) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
	    (words == 0)) {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
		ret_val = -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
	nvm->ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
	if (ret_val) {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
		bank = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
	act_offset += offset;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
	ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
	for (i = 0; i < words; i++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
		if ((dev_spec->shadow_ram) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
		    (dev_spec->shadow_ram[offset+i].modified)) {
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
		} else {
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
								act_offset + i,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
								&word);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
				break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
			data[i] = word;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
	nvm->ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
	if (ret_val)
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
/**
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
 *  e1000_flash_cycle_init_ich8lan - Initialize flash
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
 *  can be started.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
	union ich8_hws_flash_status hsfsts;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
	s32 ret_val = -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
	s32 i = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
	hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
	/* Check if the flash descriptor is valid */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
	if (hsfsts.hsf_status.fldesvalid == 0) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
		e_dbg("Flash descriptor invalid.  "
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
			 "SW Sequencing must be used.\n");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
		return -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	hsfsts.hsf_status.flcerr = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
	hsfsts.hsf_status.dael = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
	ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
	 * completed.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
	if (hsfsts.hsf_status.flcinprog == 0) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
		/*
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
		 * There is no cycle running at present,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
		 * so we can start a cycle.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
		 * Begin by setting Flash Cycle Done.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
		hsfsts.hsf_status.flcdone = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
		ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
		ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
	} else {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
		/*
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
		 * Otherwise poll for sometime so the current
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
		 */
f99b2249704c 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++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
			hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
			if (hsfsts.hsf_status.flcinprog == 0) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
				ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
				break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
			}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
			udelay(1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
		if (ret_val == 0) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
			/*
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
			 * now set the Flash Cycle Done.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
			 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
			hsfsts.hsf_status.flcdone = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
			ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
		} else {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
/**
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
 *  @timeout: maximum time to wait for completion
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
	union ich8_hws_flash_ctrl hsflctl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
	union ich8_hws_flash_status hsfsts;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
	s32 ret_val = -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
	u32 i = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
	hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
	hsflctl.hsf_ctrl.flcgo = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
	ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
	do {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
		hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
		if (hsfsts.hsf_status.flcdone == 1)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
		udelay(1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
	} while (i++ < timeout);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
		return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
 *  @offset: offset to data location
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
 *  to bytes before read.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
					 u16 *data)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
	/* Must convert offset into bytes. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
	offset <<= 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
 *  @hw: pointer to the HW structure
f99b2249704c 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.
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
					 u8 *data)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
	u16 word = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
	*data = (u8)word;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
 *  @hw: pointer to the HW structure
f99b2249704c 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.
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
					 u8 size, u16 *data)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
	union ich8_hws_flash_status hsfsts;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
	union ich8_hws_flash_ctrl hsflctl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
	u32 flash_linear_addr;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
	u32 flash_data = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
	s32 ret_val = -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
	u8 count = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
		return -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
f99b2249704c 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) +
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
			    hw->nvm.flash_base_addr;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
	do {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
		udelay(1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
		/* Steps */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
		if (ret_val != 0)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
		hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
f99b2249704c 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. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
		hsflctl.hsf_ctrl.fldbcount = size - 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
		hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
		ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
		ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
		ret_val = e1000_flash_cycle_ich8lan(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
						ICH_FLASH_READ_COMMAND_TIMEOUT);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
		/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
		 * least significant byte first msb to lsb
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
		if (ret_val == 0) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
			flash_data = er32flash(ICH_FLASH_FDATA0);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
			if (size == 1) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
				*data = (u8)(flash_data & 0x000000FF);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
			} else if (size == 2) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
				*data = (u16)(flash_data & 0x0000FFFF);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
			}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
		} else {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
			/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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...
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
			 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
			 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
			hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
			if (hsfsts.hsf_status.flcerr == 1) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
				/* Repeat for some time before giving up. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
				continue;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
			} else if (hsfsts.hsf_status.flcdone == 0) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
				e_dbg("Timeout error - flash cycle "
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
					 "did not complete.\n");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
				break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
			}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
	} while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
 *  @hw: pointer to the HW structure
f99b2249704c 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.
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
				   u16 *data)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
	struct e1000_nvm_info *nvm = &hw->nvm;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
	u16 i;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
f99b2249704c 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) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
	    (words == 0)) {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
		return -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
	nvm->ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
	for (i = 0; i < words; i++) {
f99b2249704c 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;
f99b2249704c 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];
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
	nvm->ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
 *
f99b2249704c 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,
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
 *  future writes.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
	struct e1000_nvm_info *nvm = &hw->nvm;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
	u16 data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
	if (nvm->type != e1000_nvm_flash_sw)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
	nvm->ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
	/*
f99b2249704c 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,
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
	 * is going to be written
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
	 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
	if (ret_val) {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
		bank = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
	if (bank == 0) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
		new_bank_offset = nvm->flash_bank_size;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
		old_bank_offset = 0;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
			goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
	} else {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
		old_bank_offset = nvm->flash_bank_size;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
		new_bank_offset = 0;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
			goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
f99b2249704c 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++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
		/*
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
		 * Determine whether to write the value stored
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
		 * in the shadow RAM
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
		if (dev_spec->shadow_ram[i].modified) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
			data = dev_spec->shadow_ram[i].value;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
		} else {
f99b2249704c 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 +
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
			                                        old_bank_offset,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
			                                        &data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
				break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
		/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
		 * while the write is still in progress
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
		if (i == E1000_ICH_NVM_SIG_WORD)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
			data |= E1000_ICH_NVM_SIG_MASK;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
		/* Convert offset to bytes. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
		act_offset = (i + new_bank_offset) << 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
		udelay(100);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
		/* Write the bytes to the new bank. */
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
							       act_offset,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
							       (u8)data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
		udelay(100);
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
							  act_offset + 1,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
							  (u8)(data >> 8));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
	/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
	 * programming failed.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
	if (ret_val) {
f99b2249704c 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() */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
		e_dbg("Flash commit failed.\n");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
		goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
	 */
f99b2249704c 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;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
		goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
	data &= 0xBFFF;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
						       act_offset * 2 + 1,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
						       (u8)(data >> 8));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
		goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
	 */
f99b2249704c 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;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
		goto release;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
f99b2249704c 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. */
f99b2249704c 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++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
		dev_spec->shadow_ram[i].modified = false;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
		dev_spec->shadow_ram[i].value = 0xFFFF;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
release:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
	nvm->ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
	/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
	 * until after the next adapter reset.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
	if (!ret_val) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
		e1000e_reload_nvm(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
		msleep(10);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
	if (ret_val)
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
 *
f99b2249704c 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.
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
	u16 data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
	 * checksum...a likely scenario.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
	 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
	if ((data & 0x40) == 0) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
		data |= 0x40;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
		ret_val = e1000e_update_nvm_checksum(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
	return e1000e_validate_nvm_checksum_generic(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
 *  across driver reloads.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
	struct e1000_nvm_info *nvm = &hw->nvm;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
	union ich8_flash_protected_range pr0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
	union ich8_hws_flash_status hsfsts;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
	u32 gfpreg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
	nvm->ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
	gfpreg = er32flash(ICH_FLASH_GFPREG);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
	/* Write-protect GbE Sector of NVM */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
	pr0.regval = er32flash(ICH_FLASH_PR0);
f99b2249704c 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;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
	pr0.range.wpe = true;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
	ew32flash(ICH_FLASH_PR0, pr0.regval);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
	/*
f99b2249704c 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.
f99b2249704c 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.
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
	hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
	hsfsts.hsf_status.flockdn = true;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
	ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
	nvm->ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
 *  @hw: pointer to the HW structure
f99b2249704c 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.
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
					  u8 size, u16 data)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
	union ich8_hws_flash_status hsfsts;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
	union ich8_hws_flash_ctrl hsflctl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
	u32 flash_linear_addr;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
	u32 flash_data = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
	u8 count = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
f99b2249704c 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 ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
	    offset > ICH_FLASH_LINEAR_ADDR_MASK)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
		return -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
f99b2249704c 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) +
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
			    hw->nvm.flash_base_addr;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
	do {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
		udelay(1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
		/* Steps */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
		hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
f99b2249704c 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. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
		hsflctl.hsf_ctrl.fldbcount = size -1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
		hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
		ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
		ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
		if (size == 1)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
			flash_data = (u32)data & 0x00FF;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
		else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
			flash_data = (u32)data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
		ew32flash(ICH_FLASH_FDATA0, flash_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
		/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
		ret_val = e1000_flash_cycle_ich8lan(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
					       ICH_FLASH_WRITE_COMMAND_TIMEOUT);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
		if (!ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
		/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
		 * completely hosed, but if the error condition
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
		 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
		hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
		if (hsfsts.hsf_status.flcerr == 1)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
			/* Repeat for some time before giving up. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
			continue;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
		if (hsfsts.hsf_status.flcdone == 0) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
			e_dbg("Timeout error - flash cycle "
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
				 "did not complete.");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
	} while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
 *  @hw: pointer to the HW structure
f99b2249704c 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.
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
					  u8 data)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
	u16 word = (u16)data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
 *  @hw: pointer to the HW structure
f99b2249704c 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.
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
 *
f99b2249704c 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.
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
						u32 offset, u8 byte)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
	u16 program_retries;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
	if (!ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
f99b2249704c 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++) {
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
		udelay(100);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
		if (!ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
	if (program_retries == 100)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
		return -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
 *  @hw: pointer to the HW structure
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
 *
f99b2249704c 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.
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
	struct e1000_nvm_info *nvm = &hw->nvm;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
	union ich8_hws_flash_status hsfsts;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
	union ich8_hws_flash_ctrl hsflctl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
	u32 flash_linear_addr;
f99b2249704c 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 */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
	s32 count = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
	s32 j, iteration, sector_size;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
	hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
	/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
	 * register
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
	 *     as = bank * 4096
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
	 *     (ich9 only, otherwise error condition)
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
	switch (hsfsts.hsf_status.berasesz) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
	case 0:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
		/* Hw sector size 256 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
		sector_size = ICH_FLASH_SEG_SIZE_256;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
	case 1:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
		sector_size = ICH_FLASH_SEG_SIZE_4K;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
		iteration = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
	case 2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
		sector_size = ICH_FLASH_SEG_SIZE_8K;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
		iteration = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
	case 3:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
		sector_size = ICH_FLASH_SEG_SIZE_64K;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
		iteration = 1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
	default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
		return -E1000_ERR_NVM;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
f99b2249704c 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. */
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
	for (j = 0; j < iteration ; j++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
		do {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
			/* Steps */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
			if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
				return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
			/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
			 * Cycle field in hw flash control
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
			 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
			hsflctl.regval = er16flash(ICH_FLASH_HSFCTL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
			hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
			ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
			/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
			 * Address.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
			 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
			flash_linear_addr += (j * sector_size);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
			ew32flash(ICH_FLASH_FADDR, flash_linear_addr);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
			ret_val = e1000_flash_cycle_ich8lan(hw,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
					       ICH_FLASH_ERASE_COMMAND_TIMEOUT);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
			if (ret_val == 0)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
				break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
			/*
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
			 * clear it and try the whole sequence
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
			 * a few more times else Done
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
			 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
			hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
			if (hsfsts.hsf_status.flcerr == 1)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
				/* repeat for some time before giving up */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
				continue;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
			else if (hsfsts.hsf_status.flcdone == 0)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
				return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
		} while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
 *  @data: Pointer to the LED settings
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
 *  setting.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
	if (ret_val) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
		e_dbg("NVM Read Error\n");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
	if (*data == ID_LED_RESERVED_0000 ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
	    *data == ID_LED_RESERVED_FFFF)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
		*data = ID_LED_DEFAULT_ICH8LAN;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
 *  the PHY LED configuration register.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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()),
f99b2249704c 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
f99b2249704c 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().
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
	struct e1000_mac_info *mac = &hw->mac;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
	s32 ret_val;
f99b2249704c 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;
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
	u16 data, i, temp, shift;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
	/* Get default ID LED modes */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
		goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
	mac->ledctl_default = er32(LEDCTL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
	mac->ledctl_mode1 = mac->ledctl_default;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
	mac->ledctl_mode2 = mac->ledctl_default;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
	for (i = 0; i < 4; i++) {
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
		shift = (i * 5);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
		switch (temp) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
		case ID_LED_ON1_DEF2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
		case ID_LED_ON1_ON2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
		case ID_LED_ON1_OFF2:
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
			mac->ledctl_mode1 |= (ledctl_on << shift);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
		case ID_LED_OFF1_DEF2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
		case ID_LED_OFF1_ON2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
		case ID_LED_OFF1_OFF2:
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
			mac->ledctl_mode1 |= (ledctl_off << shift);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
		default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
			/* Do nothing */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
		switch (temp) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
		case ID_LED_DEF1_ON2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
		case ID_LED_ON1_ON2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
		case ID_LED_OFF1_ON2:
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
			mac->ledctl_mode2 |= (ledctl_on << shift);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
		case ID_LED_DEF1_OFF2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
		case ID_LED_ON1_OFF2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
		case ID_LED_OFF1_OFF2:
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
			mac->ledctl_mode2 |= (ledctl_off << shift);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
		default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
			/* Do nothing */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
 *
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
	struct e1000_bus_info *bus = &hw->bus;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
	/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
	 * a configuration space, but do not contain
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
	 * PCI Express Capability registers, so bus width
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
	 * must be hardcoded.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
	if (bus->width == e1000_bus_width_unknown)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
		bus->width = e1000_bus_width_pcie_x1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
/**
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
 *  e1000_reset_hw_ich8lan - Reset the hardware
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
 *  MAC.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
{
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
	u16 reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
	u32 ctrl, icr, kab;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
	/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
	ret_val = e1000e_disable_pcie_master(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
	if (ret_val)
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
	e_dbg("Masking off all interrupts\n");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
	ew32(IMC, 0xffffffff);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
	 * with the global reset.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
	ew32(RCTL, 0);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
	ew32(TCTL, E1000_TCTL_PSP);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
	e1e_flush();
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
	msleep(10);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
	if (hw->mac.type == e1000_ich8lan) {
f99b2249704c 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. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
		ew32(PBA, E1000_PBA_8K);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
		/* Set Packet Buffer Size to 16k. */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
		ew32(PBS, E1000_PBS_16K);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
	if (hw->mac.type == e1000_pchlan) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
		/* Save the NVM K1 bit setting*/
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
		if (reg & E1000_NVM_K1_ENABLE)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
			dev_spec->nvm_k1_enabled = true;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
		else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
			dev_spec->nvm_k1_enabled = false;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
	ctrl = er32(CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
	if (!e1000_check_reset_block(hw)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
		/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
		 * external PHY is reset.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
		ctrl |= E1000_CTRL_PHY_RST;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
		/*
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
		 * Gate automatic PHY configuration by hardware on
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
		 * non-managed 82579
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
		if ((hw->mac.type == e1000_pch2lan) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
		    !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID))
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
	ret_val = e1000_acquire_swflag_ich8lan(hw);
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
	ew32(CTRL, (ctrl | E1000_CTRL_RST));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
	msleep(20);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
	if (!ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
		e1000_release_swflag_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
	if (ctrl & E1000_CTRL_PHY_RST) {
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
			goto out;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
	if (hw->mac.type == e1000_pchlan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
		ew32(CRC_OFFSET, 0x65656565);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
	ew32(IMC, 0xffffffff);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
	icr = er32(ICR);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
	kab = er32(KABGTXD);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
	kab |= E1000_KABGTXD_BGSQLBIAS;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
	ew32(KABGTXD, kab);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
out:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
/**
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
 *  e1000_init_hw_ich8lan - Initialize the hardware
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
 *
f99b2249704c 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:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
 *   - initialize hardware bits
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
 *   - initialize LED identification
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
 *   - setup receive address registers
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
 *   - setup flow control
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
 *   - setup transmit descriptors
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
 *   - clear statistics
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
	struct e1000_mac_info *mac = &hw->mac;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
	u32 ctrl_ext, txdctl, snoop;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
	u16 i;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
	e1000_initialize_hw_bits_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
	/* Initialize identification LED */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
		e_dbg("Error initializing identification LED\n");
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
	/* Setup the receive address. */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
	/* Zero out the Multicast HASH table */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
	e_dbg("Zeroing the MTA\n");
f99b2249704c 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++)
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
	/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
	if (hw->phy.type == e1000_phy_82578) {
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
	/* Setup link and flow control */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
	ret_val = e1000_setup_link_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
	txdctl = er32(TXDCTL(0));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
	txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
		 E1000_TXDCTL_FULL_TX_DESC_WB;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
	txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
		 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
	ew32(TXDCTL(0), txdctl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
	txdctl = er32(TXDCTL(1));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
	txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
		 E1000_TXDCTL_FULL_TX_DESC_WB;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
	txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
		 E1000_TXDCTL_MAX_TX_DESC_PREFETCH;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
	ew32(TXDCTL(1), txdctl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
	/*
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
	 * By default, we should use snoop behavior.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
	if (mac->type == e1000_ich8lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
		snoop = PCIE_ICH8_SNOOP_ALL;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
	else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
		snoop = (u32) ~(PCIE_NO_SNOOP_ALL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
	e1000e_set_pcie_no_snoop(hw, snoop);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
	ctrl_ext = er32(CTRL_EXT);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
	ctrl_ext |= E1000_CTRL_EXT_RO_DIS;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
	ew32(CTRL_EXT, ctrl_ext);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
	 * is no link.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
	e1000_clear_hw_cntrs_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
 *  hardware for transmit and receive.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
	u32 reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
	/* Extended Device Control */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
	reg = er32(CTRL_EXT);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
	reg |= (1 << 22);
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
	if (hw->mac.type >= e1000_pchlan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
		reg |= E1000_CTRL_EXT_PHYPDEN;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
	ew32(CTRL_EXT, reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
	/* Transmit Descriptor Control 0 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
	reg = er32(TXDCTL(0));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
	reg |= (1 << 22);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
	ew32(TXDCTL(0), reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
	/* Transmit Descriptor Control 1 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
	reg = er32(TXDCTL(1));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
	reg |= (1 << 22);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
	ew32(TXDCTL(1), reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
	/* Transmit Arbitration Control 0 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
	reg = er32(TARC(0));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
	if (hw->mac.type == e1000_ich8lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
		reg |= (1 << 28) | (1 << 29);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
	ew32(TARC(0), reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
	/* Transmit Arbitration Control 1 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
	reg = er32(TARC(1));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
	if (er32(TCTL) & E1000_TCTL_MULR)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
		reg &= ~(1 << 28);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
	else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
		reg |= (1 << 28);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
	reg |= (1 << 24) | (1 << 26) | (1 << 30);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
	ew32(TARC(1), reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
	/* Device Status */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
	if (hw->mac.type == e1000_ich8lan) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
		reg = er32(STATUS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
		reg &= ~(1 << 31);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
		ew32(STATUS, reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
	/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
	 * traffic, just disable the nfs filtering capability
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
	reg = er32(RFCTL);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
	ew32(RFCTL, reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
	if (e1000_check_reset_block(hw))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
		return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
	/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
	 * set it to full.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
	 */
f99b2249704c 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) {
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
		if (hw->mac.type == e1000_pchlan)
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
		else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
			hw->fc.requested_mode = e1000_fc_full;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
	/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
	 */
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
f99b2249704c 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",
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
		hw->fc.current_mode);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
	/* Continue to configure the copper link. */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
	ew32(FCTTV, hw->fc.pause_time);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
	if ((hw->phy.type == e1000_phy_82578) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
	    (hw->phy.type == e1000_phy_82579) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
	    (hw->phy.type == e1000_phy_82577)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
		ew32(FCRTV_PCH, hw->fc.refresh_time);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
		                             PHY_REG(BM_PORT_CTRL_PAGE, 27),
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
		                             hw->fc.pause_time);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
	return e1000e_set_fc_watermarks(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
 *  configuring the copper link.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
	u32 ctrl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
	u16 reg_data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
	ctrl = er32(CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
	ctrl |= E1000_CTRL_SLU;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
	ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
	ew32(CTRL, ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
	/*
f99b2249704c 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
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
	 * this fixes erroneous timeouts at 10Mbps.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
	 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
		return ret_val;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
	                               &reg_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
	reg_data |= 0x3F;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
	                                reg_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
	switch (hw->phy.type) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
	case e1000_phy_igp_3:
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
	case e1000_phy_bm:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
	case e1000_phy_82578:
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
	case e1000_phy_82577:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
	case e1000_phy_82579:
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
	case e1000_phy_ife:
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
		                               &reg_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
		reg_data &= ~IFE_PMC_AUTO_MDIX;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
		switch (hw->phy.mdix) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
		case 1:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
			reg_data &= ~IFE_PMC_FORCE_MDIX;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
		case 2:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
			reg_data |= IFE_PMC_FORCE_MDIX;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
		case 0:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
		default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
			reg_data |= IFE_PMC_AUTO_MDIX;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
		}
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
		                                reg_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
	default:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
		break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
	return e1000e_setup_copper_link(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
 *  @speed: pointer to store current link speed
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
 *  gigabit speeds.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
					  u16 *duplex)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
		return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
	if ((hw->mac.type == e1000_ich8lan) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
	    (hw->phy.type == e1000_phy_igp_3) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
	    (*speed == SPEED_1000)) {
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
 *
f99b2249704c 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:
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
 *  speed is gigabit-
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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...
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
 *    4) reset the PHY
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
 *    5) repeat up to 10 times
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
{
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
	u32 phy_ctrl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
	u16 i, data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
	bool link;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
		return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
	/*
f99b2249704c 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.
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
	 * stability
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
	 */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
	if (!link)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
		return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
	for (i = 0; i < 10; i++) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
		/* read once to clear */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
		/* and again to get new status */
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
			return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
		/* check for PCS lock */
f99b2249704c 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))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
			return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
		/* Issue PHY reset */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
		e1000_phy_hw_reset(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
		mdelay(5);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
	/* Disable GigE link negotiation */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
	phy_ctrl = er32(PHY_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
	phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
		     E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
	ew32(PHY_CTRL, phy_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
	/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
	 * any PHY registers
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
	e1000e_gig_downshift_workaround_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
	/* unable to acquire PCS lock */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
	return -E1000_ERR_PHY;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
 *  @hw: pointer to the HW structure
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
 *
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
 *  /disabled - false).
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
 **/
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
						 bool state)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
{
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
	if (hw->mac.type != e1000_ich8lan) {
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
		return;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
 *
f99b2249704c 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:
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
 *    1) disable gigabit link
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
 *    2) write VR power-down enable
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
 *    3) read it back
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
	u32 reg;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
	u16 data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
	u8  retry = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
		return;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
	/* Try the workaround twice (if needed) */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
	do {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
		/* Disable link */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
		reg = er32(PHY_CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
		reg |= (E1000_PHY_CTRL_GBE_DISABLE |
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
			E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
		ew32(PHY_CTRL, reg);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
		/*
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
		 * accessing any PHY registers
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
		 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
		if (hw->mac.type == e1000_ich8lan)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
			e1000e_gig_downshift_workaround_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
		/* Write VR power-down enable */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
		e1e_rphy(hw, IGP3_VR_CTRL, &data);
f99b2249704c 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;
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
		/* Read it back and test */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
		e1e_rphy(hw, IGP3_VR_CTRL, &data);
f99b2249704c 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;
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
			break;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
		reg = er32(CTRL);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
		ew32(CTRL, reg | E1000_CTRL_PHY_RST);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
		retry++;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
	} while (retry);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
 *
f99b2249704c 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),
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
 *  LPLU, Gig disable, MDIC PHY reset):
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
 *    1) Set Kumeran Near-end loopback
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
 *    2) Clear Kumeran Near-end loopback
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
	u16 reg_data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
	if ((hw->mac.type != e1000_ich8lan) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
	    (hw->phy.type != e1000_phy_igp_3))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
		return;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
				      &reg_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
		return;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
	reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
				       reg_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
	if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
		return;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
	reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK;
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
				       reg_data);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
 *  to a lower speed.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
 *  Should only be called for applicable parts.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
	u32 phy_ctrl;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
	s32 ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
	phy_ctrl = er32(PHY_CTRL);
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
	ew32(PHY_CTRL, phy_ctrl);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
	if (hw->mac.type >= e1000_pchlan) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
		e1000_oem_bits_config_ich8lan(hw, true);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
		ret_val = hw->phy.ops.acquire(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
		if (ret_val)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
			return;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
		e1000_write_smbus_addr(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
		hw->phy.ops.release(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
	if (hw->phy.type == e1000_phy_ife)
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
	ew32(LEDCTL, hw->mac.ledctl_default);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
/**
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
 *  e1000_led_on_ich8lan - Turn LEDs on
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
 *  Turn on the LEDs.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
	if (hw->phy.type == e1000_phy_ife)
f99b2249704c 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,
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
	ew32(LEDCTL, hw->mac.ledctl_mode2);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
/**
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
 *  e1000_led_off_ich8lan - Turn LEDs off
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
 *  Turn off the LEDs.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
	if (hw->phy.type == e1000_phy_ife)
f99b2249704c 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,
f99b2249704c 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));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
	ew32(LEDCTL, hw->mac.ledctl_mode1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
	return 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
{
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
					(u16)hw->mac.ledctl_mode1);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
 *
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
{
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
					(u16)hw->mac.ledctl_default);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
/**
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
 *  e1000_led_on_pchlan - Turn LEDs on
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
 *  Turn on the LEDs.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
	u16 data = (u16)hw->mac.ledctl_mode2;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
	u32 i, led;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
	/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
	if (!(er32(STATUS) & E1000_STATUS_LU)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
		for (i = 0; i < 3; i++) {
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
			if ((led & E1000_PHY_LED0_MODE_MASK) !=
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
			    E1000_LEDCTL_MODE_LINK_UP)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
				continue;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
			if (led & E1000_PHY_LED0_IVRT)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
				data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
			else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
				data |= (E1000_PHY_LED0_IVRT << (i * 5));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
/**
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
 *  e1000_led_off_pchlan - Turn LEDs off
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
 *
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
 *  Turn off the LEDs.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
	u16 data = (u16)hw->mac.ledctl_mode1;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
	u32 i, led;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
	/*
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
	 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
	if (!(er32(STATUS) & E1000_STATUS_LU)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
		for (i = 0; i < 3; i++) {
f99b2249704c 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;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
			if ((led & E1000_PHY_LED0_MODE_MASK) !=
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
			    E1000_LEDCTL_MODE_LINK_UP)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
				continue;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
			if (led & E1000_PHY_LED0_IVRT)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
				data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
			else
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
				data |= (E1000_PHY_LED0_IVRT << (i * 5));
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
 *
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
 *
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
 *  or change link.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
	s32 ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
	u32 bank = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
	u32 status;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
	e1000e_get_cfg_done(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	if (hw->mac.type >= e1000_ich10lan) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
		e1000_lan_init_done_ich8lan(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
	} else {
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
		if (ret_val) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
			/*
f99b2249704c 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
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
			 */
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
			ret_val = 0;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
	/* Clear PHY Reset Asserted bit */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	status = er32(STATUS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
	if (status & E1000_STATUS_PHYRA)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
		ew32(STATUS, status & ~E1000_STATUS_PHYRA);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
	else
f99b2249704c 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");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
	if (hw->mac.type <= e1000_ich9lan) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
		if (((er32(EECD) & E1000_EECD_PRES) == 0) &&
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
		    (hw->phy.type == e1000_phy_igp_3)) {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
			e1000e_phy_init_script_igp3(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
	} else {
f99b2249704c 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)) {
f99b2249704c 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 */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
			e_dbg("EEPROM not present\n");
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
			ret_val = -E1000_ERR_CONFIG;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
		}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
	return ret_val;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
 * @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
 *
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
{
f99b2249704c 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 */
f99b2249704c 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) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
	      hw->phy.ops.check_reset_block(hw)))
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
		e1000_power_down_phy_copper(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
/**
f99b2249704c 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
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
 *  @hw: pointer to the HW structure
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
 *
f99b2249704c 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
f99b2249704c 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.
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
 **/
f99b2249704c 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)
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
{
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
	u16 phy_data;
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
	e1000e_clear_hw_cntrs_base(hw);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
	er32(ALGNERRC);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
	er32(RXERRC);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
	er32(TNCRS);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
	er32(CEXTERR);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
	er32(TSCTC);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
	er32(TSCTFC);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
	er32(MGTPRC);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
	er32(MGTPDC);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
	er32(MGTPTC);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
	er32(IAC);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
	er32(ICRXOC);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
	/* Clear PHY statistics registers */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
	if ((hw->phy.type == e1000_phy_82578) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
	    (hw->phy.type == e1000_phy_82579) ||
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
	    (hw->phy.type == e1000_phy_82577)) {
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c 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);
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
	}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
}
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
f99b2249704c 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 = {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
	.id_led_init		= e1000e_id_led_init,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
	/* check_mng_mode dependent on mac type */
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
	/* cleanup_led dependent on mac type */
f99b2249704c 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,
f99b2249704c 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,
f99b2249704c 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,
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
	/* led_on dependent on mac type */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
	/* led_off dependent on mac type */
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
	.reset_hw		= e1000_reset_hw_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
	.init_hw		= e1000_init_hw_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
	.setup_link		= e1000_setup_link_ich8lan,
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
	/* id_led_init dependent on mac type */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
f99b2249704c 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 = {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
	.acquire		= e1000_acquire_swflag_ich8lan,
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
	.commit			= NULL,
f99b2249704c 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,
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
	.read_reg		= e1000e_read_phy_reg_igp,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
	.release		= e1000_release_swflag_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
	.reset			= e1000_phy_hw_reset_ich8lan,
f99b2249704c 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,
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
	.write_reg		= e1000e_write_phy_reg_igp,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
f99b2249704c 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 = {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
	.acquire		= e1000_acquire_nvm_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
	.read		 	= e1000_read_nvm_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
	.release		= e1000_release_nvm_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
	.update			= e1000_update_nvm_checksum_ich8lan,
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
	.validate		= e1000_validate_nvm_checksum_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
	.write			= e1000_write_nvm_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
struct e1000_info e1000_ich8_info = {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
	.mac			= e1000_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
	.flags			= FLAG_HAS_WOL
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
				  | FLAG_IS_ICH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
				  | FLAG_RX_CSUM_ENABLED
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
				  | FLAG_HAS_CTRLEXT_ON_LOAD
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
				  | FLAG_HAS_AMT
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
				  | FLAG_HAS_FLASH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
				  | FLAG_APME_IN_WUC,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
	.pba			= 8,
f99b2249704c 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,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
	.get_variants		= e1000_get_variants_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
	.mac_ops		= &ich8_mac_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
	.phy_ops		= &ich8_phy_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
	.nvm_ops		= &ich8_nvm_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
struct e1000_info e1000_ich9_info = {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
	.mac			= e1000_ich9lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
	.flags			= FLAG_HAS_JUMBO_FRAMES
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
				  | FLAG_IS_ICH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
				  | FLAG_HAS_WOL
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
				  | FLAG_RX_CSUM_ENABLED
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
				  | FLAG_HAS_CTRLEXT_ON_LOAD
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
				  | FLAG_HAS_AMT
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
				  | FLAG_HAS_ERT
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
				  | FLAG_HAS_FLASH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
				  | FLAG_APME_IN_WUC,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
	.pba			= 10,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
	.max_hw_frame_size	= DEFAULT_JUMBO,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
	.get_variants		= e1000_get_variants_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
	.mac_ops		= &ich8_mac_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
	.phy_ops		= &ich8_phy_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
	.nvm_ops		= &ich8_nvm_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
struct e1000_info e1000_ich10_info = {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
	.mac			= e1000_ich10lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
	.flags			= FLAG_HAS_JUMBO_FRAMES
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
				  | FLAG_IS_ICH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
				  | FLAG_HAS_WOL
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
				  | FLAG_RX_CSUM_ENABLED
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
				  | FLAG_HAS_CTRLEXT_ON_LOAD
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
				  | FLAG_HAS_AMT
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
				  | FLAG_HAS_ERT
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
				  | FLAG_HAS_FLASH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
				  | FLAG_APME_IN_WUC,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
	.pba			= 10,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
	.max_hw_frame_size	= DEFAULT_JUMBO,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
	.get_variants		= e1000_get_variants_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
	.mac_ops		= &ich8_mac_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
	.phy_ops		= &ich8_phy_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
	.nvm_ops		= &ich8_nvm_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
struct e1000_info e1000_pch_info = {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
	.mac			= e1000_pchlan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
	.flags			= FLAG_IS_ICH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
				  | FLAG_HAS_WOL
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
				  | FLAG_RX_CSUM_ENABLED
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
				  | FLAG_HAS_CTRLEXT_ON_LOAD
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
				  | FLAG_HAS_AMT
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
				  | FLAG_HAS_FLASH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
				  | FLAG_HAS_JUMBO_FRAMES
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
				  | FLAG_DISABLE_FC_PAUSE_TIME /* errata */
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
				  | FLAG_APME_IN_WUC,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
	.flags2			= FLAG2_HAS_PHY_STATS,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
	.pba			= 26,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
	.max_hw_frame_size	= 4096,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
	.get_variants		= e1000_get_variants_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
	.mac_ops		= &ich8_mac_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
	.phy_ops		= &ich8_phy_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
	.nvm_ops		= &ich8_nvm_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
};
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
struct e1000_info e1000_pch2_info = {
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
	.mac			= e1000_pch2lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
	.flags			= FLAG_IS_ICH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
				  | FLAG_HAS_WOL
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
				  | FLAG_RX_CSUM_ENABLED
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
				  | FLAG_HAS_CTRLEXT_ON_LOAD
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
				  | FLAG_HAS_AMT
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
				  | FLAG_HAS_FLASH
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
				  | FLAG_HAS_JUMBO_FRAMES
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
				  | FLAG_APME_IN_WUC,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
	.flags2			= FLAG2_HAS_PHY_STATS
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
				  | FLAG2_HAS_EEE,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
	.pba			= 26,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
	.max_hw_frame_size	= DEFAULT_JUMBO,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
	.get_variants		= e1000_get_variants_ich8lan,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
	.mac_ops		= &ich8_mac_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
	.phy_ops		= &ich8_phy_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
	.nvm_ops		= &ich8_nvm_ops,
f99b2249704c Added e1000e driver for 2.6.37.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
};