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