Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel PRO/1000 Linux driver |
Bruce Allan | f5e261e | 2012-01-01 16:00:03 +0000 | [diff] [blame] | 4 | Copyright(c) 1999 - 2012 Intel Corporation. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms and conditions of the GNU General Public License, |
| 8 | version 2, as published by the Free Software Foundation. |
| 9 | |
| 10 | This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License along with |
| 16 | this program; if not, write to the Free Software Foundation, Inc., |
| 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | |
| 19 | The full GNU General Public License is included in this distribution in |
| 20 | the file called "COPYING". |
| 21 | |
| 22 | Contact Information: |
| 23 | Linux NICS <linux.nics@intel.com> |
| 24 | e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 26 | |
| 27 | *******************************************************************************/ |
| 28 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 29 | /* 82562G 10/100 Network Connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 30 | * 82562G-2 10/100 Network Connection |
| 31 | * 82562GT 10/100 Network Connection |
| 32 | * 82562GT-2 10/100 Network Connection |
| 33 | * 82562V 10/100 Network Connection |
| 34 | * 82562V-2 10/100 Network Connection |
| 35 | * 82566DC-2 Gigabit Network Connection |
| 36 | * 82566DC Gigabit Network Connection |
| 37 | * 82566DM-2 Gigabit Network Connection |
| 38 | * 82566DM Gigabit Network Connection |
| 39 | * 82566MC Gigabit Network Connection |
| 40 | * 82566MM Gigabit Network Connection |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 41 | * 82567LM Gigabit Network Connection |
| 42 | * 82567LF Gigabit Network Connection |
Bruce Allan | 1605927 | 2008-11-21 16:51:06 -0800 | [diff] [blame] | 43 | * 82567V Gigabit Network Connection |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 44 | * 82567LM-2 Gigabit Network Connection |
| 45 | * 82567LF-2 Gigabit Network Connection |
| 46 | * 82567V-2 Gigabit Network Connection |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 47 | * 82567LF-3 Gigabit Network Connection |
| 48 | * 82567LM-3 Gigabit Network Connection |
Bruce Allan | 2f15f9d | 2008-08-26 18:36:36 -0700 | [diff] [blame] | 49 | * 82567LM-4 Gigabit Network Connection |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 50 | * 82577LM Gigabit Network Connection |
| 51 | * 82577LC Gigabit Network Connection |
| 52 | * 82578DM Gigabit Network Connection |
| 53 | * 82578DC Gigabit Network Connection |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 54 | * 82579LM Gigabit Network Connection |
| 55 | * 82579V Gigabit Network Connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 56 | */ |
| 57 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 58 | #include "e1000.h" |
| 59 | |
| 60 | #define ICH_FLASH_GFPREG 0x0000 |
| 61 | #define ICH_FLASH_HSFSTS 0x0004 |
| 62 | #define ICH_FLASH_HSFCTL 0x0006 |
| 63 | #define ICH_FLASH_FADDR 0x0008 |
| 64 | #define ICH_FLASH_FDATA0 0x0010 |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 65 | #define ICH_FLASH_PR0 0x0074 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 66 | |
| 67 | #define ICH_FLASH_READ_COMMAND_TIMEOUT 500 |
| 68 | #define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500 |
| 69 | #define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000 |
| 70 | #define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF |
| 71 | #define ICH_FLASH_CYCLE_REPEAT_COUNT 10 |
| 72 | |
| 73 | #define ICH_CYCLE_READ 0 |
| 74 | #define ICH_CYCLE_WRITE 2 |
| 75 | #define ICH_CYCLE_ERASE 3 |
| 76 | |
| 77 | #define FLASH_GFPREG_BASE_MASK 0x1FFF |
| 78 | #define FLASH_SECTOR_ADDR_SHIFT 12 |
| 79 | |
| 80 | #define ICH_FLASH_SEG_SIZE_256 256 |
| 81 | #define ICH_FLASH_SEG_SIZE_4K 4096 |
| 82 | #define ICH_FLASH_SEG_SIZE_8K 8192 |
| 83 | #define ICH_FLASH_SEG_SIZE_64K 65536 |
| 84 | |
| 85 | |
| 86 | #define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */ |
Bruce Allan | 6dfaa76 | 2010-05-05 22:00:06 +0000 | [diff] [blame] | 87 | /* FW established a valid mode */ |
| 88 | #define E1000_ICH_FWSM_FW_VALID 0x00008000 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 89 | |
| 90 | #define E1000_ICH_MNG_IAMT_MODE 0x2 |
| 91 | |
| 92 | #define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \ |
| 93 | (ID_LED_DEF1_OFF2 << 8) | \ |
| 94 | (ID_LED_DEF1_ON2 << 4) | \ |
| 95 | (ID_LED_DEF1_DEF2)) |
| 96 | |
| 97 | #define E1000_ICH_NVM_SIG_WORD 0x13 |
| 98 | #define E1000_ICH_NVM_SIG_MASK 0xC000 |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 99 | #define E1000_ICH_NVM_VALID_SIG_MASK 0xC0 |
| 100 | #define E1000_ICH_NVM_SIG_VALUE 0x80 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 101 | |
| 102 | #define E1000_ICH8_LAN_INIT_TIMEOUT 1500 |
| 103 | |
| 104 | #define E1000_FEXTNVM_SW_CONFIG 1 |
| 105 | #define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */ |
| 106 | |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 107 | #define E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK 0x0C000000 |
| 108 | #define E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC 0x08000000 |
| 109 | |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 110 | #define E1000_FEXTNVM4_BEACON_DURATION_MASK 0x7 |
| 111 | #define E1000_FEXTNVM4_BEACON_DURATION_8USEC 0x7 |
| 112 | #define E1000_FEXTNVM4_BEACON_DURATION_16USEC 0x3 |
| 113 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 114 | #define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL |
| 115 | |
| 116 | #define E1000_ICH_RAR_ENTRIES 7 |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 117 | #define E1000_PCH2_RAR_ENTRIES 5 /* RAR[0], SHRA[0-3] */ |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 118 | #define E1000_PCH_LPT_RAR_ENTRIES 12 /* RAR[0], SHRA[0-10] */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 119 | |
| 120 | #define PHY_PAGE_SHIFT 5 |
| 121 | #define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \ |
| 122 | ((reg) & MAX_PHY_REG_ADDRESS)) |
| 123 | #define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */ |
| 124 | #define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */ |
| 125 | |
| 126 | #define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002 |
| 127 | #define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300 |
| 128 | #define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200 |
| 129 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 130 | #define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */ |
| 131 | |
Bruce Allan | 53ac5a8 | 2009-10-26 11:23:06 +0000 | [diff] [blame] | 132 | #define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */ |
| 133 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 134 | /* SMBus Control Phy Register */ |
| 135 | #define CV_SMB_CTRL PHY_REG(769, 23) |
| 136 | #define CV_SMB_CTRL_FORCE_SMBUS 0x0001 |
| 137 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 138 | /* SMBus Address Phy Register */ |
| 139 | #define HV_SMB_ADDR PHY_REG(768, 26) |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 140 | #define HV_SMB_ADDR_MASK 0x007F |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 141 | #define HV_SMB_ADDR_PEC_EN 0x0200 |
| 142 | #define HV_SMB_ADDR_VALID 0x0080 |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 143 | #define HV_SMB_ADDR_FREQ_MASK 0x1100 |
| 144 | #define HV_SMB_ADDR_FREQ_LOW_SHIFT 8 |
| 145 | #define HV_SMB_ADDR_FREQ_HIGH_SHIFT 12 |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 146 | |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 147 | /* PHY Power Management Control */ |
| 148 | #define HV_PM_CTRL PHY_REG(770, 17) |
Bruce Allan | 36ceeb4 | 2012-03-20 03:47:47 +0000 | [diff] [blame] | 149 | #define HV_PM_CTRL_PLL_STOP_IN_K1_GIGA 0x100 |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 150 | |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 151 | /* PHY Low Power Idle Control */ |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 152 | #define I82579_LPI_CTRL PHY_REG(772, 20) |
| 153 | #define I82579_LPI_CTRL_ENABLE_MASK 0x6000 |
| 154 | #define I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT 0x80 |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 155 | |
Bruce Allan | 1effb45 | 2011-02-25 06:58:03 +0000 | [diff] [blame] | 156 | /* EMI Registers */ |
| 157 | #define I82579_EMI_ADDR 0x10 |
| 158 | #define I82579_EMI_DATA 0x11 |
| 159 | #define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */ |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 160 | #define I82579_MSE_THRESHOLD 0x084F /* Mean Square Error Threshold */ |
| 161 | #define I82579_MSE_LINK_DOWN 0x2411 /* MSE count before dropping link */ |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 162 | #define I217_EEE_ADVERTISEMENT 0x8001 /* IEEE MMD Register 7.60 */ |
| 163 | #define I217_EEE_LP_ABILITY 0x8002 /* IEEE MMD Register 7.61 */ |
| 164 | #define I217_EEE_100_SUPPORTED (1 << 1) /* 100BaseTx EEE supported */ |
| 165 | |
| 166 | /* Intel Rapid Start Technology Support */ |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 167 | #define I217_PROXY_CTRL BM_PHY_REG(BM_WUC_PAGE, 70) |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 168 | #define I217_PROXY_CTRL_AUTO_DISABLE 0x0080 |
| 169 | #define I217_SxCTRL PHY_REG(BM_PORT_CTRL_PAGE, 28) |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 170 | #define I217_SxCTRL_ENABLE_LPI_RESET 0x1000 |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 171 | #define I217_CGFREG PHY_REG(772, 29) |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 172 | #define I217_CGFREG_ENABLE_MTA_RESET 0x0002 |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 173 | #define I217_MEMPWR PHY_REG(772, 26) |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 174 | #define I217_MEMPWR_DISABLE_SMB_RELEASE 0x0010 |
Bruce Allan | 1effb45 | 2011-02-25 06:58:03 +0000 | [diff] [blame] | 175 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 176 | /* Strapping Option Register - RO */ |
| 177 | #define E1000_STRAP 0x0000C |
| 178 | #define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000 |
| 179 | #define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17 |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 180 | #define E1000_STRAP_SMT_FREQ_MASK 0x00003000 |
| 181 | #define E1000_STRAP_SMT_FREQ_SHIFT 12 |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 182 | |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 183 | /* OEM Bits Phy Register */ |
| 184 | #define HV_OEM_BITS PHY_REG(768, 25) |
| 185 | #define HV_OEM_BITS_LPLU 0x0004 /* Low Power Link Up */ |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 186 | #define HV_OEM_BITS_GBE_DIS 0x0040 /* Gigabit Disable */ |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 187 | #define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */ |
| 188 | |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 189 | #define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */ |
| 190 | #define E1000_NVM_K1_ENABLE 0x1 /* NVM Enable K1 bit */ |
| 191 | |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 192 | /* KMRN Mode Control */ |
| 193 | #define HV_KMRN_MODE_CTRL PHY_REG(769, 16) |
| 194 | #define HV_KMRN_MDIO_SLOW 0x0400 |
| 195 | |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 196 | /* KMRN FIFO Control and Status */ |
| 197 | #define HV_KMRN_FIFO_CTRLSTA PHY_REG(770, 16) |
| 198 | #define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK 0x7000 |
| 199 | #define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT 12 |
| 200 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 201 | /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ |
| 202 | /* Offset 04h HSFSTS */ |
| 203 | union ich8_hws_flash_status { |
| 204 | struct ich8_hsfsts { |
| 205 | u16 flcdone :1; /* bit 0 Flash Cycle Done */ |
| 206 | u16 flcerr :1; /* bit 1 Flash Cycle Error */ |
| 207 | u16 dael :1; /* bit 2 Direct Access error Log */ |
| 208 | u16 berasesz :2; /* bit 4:3 Sector Erase Size */ |
| 209 | u16 flcinprog :1; /* bit 5 flash cycle in Progress */ |
| 210 | u16 reserved1 :2; /* bit 13:6 Reserved */ |
| 211 | u16 reserved2 :6; /* bit 13:6 Reserved */ |
| 212 | u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */ |
| 213 | u16 flockdn :1; /* bit 15 Flash Config Lock-Down */ |
| 214 | } hsf_status; |
| 215 | u16 regval; |
| 216 | }; |
| 217 | |
| 218 | /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */ |
| 219 | /* Offset 06h FLCTL */ |
| 220 | union ich8_hws_flash_ctrl { |
| 221 | struct ich8_hsflctl { |
| 222 | u16 flcgo :1; /* 0 Flash Cycle Go */ |
| 223 | u16 flcycle :2; /* 2:1 Flash Cycle */ |
| 224 | u16 reserved :5; /* 7:3 Reserved */ |
| 225 | u16 fldbcount :2; /* 9:8 Flash Data Byte Count */ |
| 226 | u16 flockdn :6; /* 15:10 Reserved */ |
| 227 | } hsf_ctrl; |
| 228 | u16 regval; |
| 229 | }; |
| 230 | |
| 231 | /* ICH Flash Region Access Permissions */ |
| 232 | union ich8_hws_flash_regacc { |
| 233 | struct ich8_flracc { |
| 234 | u32 grra :8; /* 0:7 GbE region Read Access */ |
| 235 | u32 grwa :8; /* 8:15 GbE region Write Access */ |
| 236 | u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */ |
| 237 | u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */ |
| 238 | } hsf_flregacc; |
| 239 | u16 regval; |
| 240 | }; |
| 241 | |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 242 | /* ICH Flash Protected Region */ |
| 243 | union ich8_flash_protected_range { |
| 244 | struct ich8_pr { |
| 245 | u32 base:13; /* 0:12 Protected Range Base */ |
| 246 | u32 reserved1:2; /* 13:14 Reserved */ |
| 247 | u32 rpe:1; /* 15 Read Protection Enable */ |
| 248 | u32 limit:13; /* 16:28 Protected Range Limit */ |
| 249 | u32 reserved2:2; /* 29:30 Reserved */ |
| 250 | u32 wpe:1; /* 31 Write Protection Enable */ |
| 251 | } range; |
| 252 | u32 regval; |
| 253 | }; |
| 254 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 255 | static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw); |
| 256 | static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw); |
| 257 | static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 258 | static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank); |
| 259 | static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw, |
| 260 | u32 offset, u8 byte); |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 261 | static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, |
| 262 | u8 *data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 263 | static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset, |
| 264 | u16 *data); |
| 265 | static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, |
| 266 | u8 size, u16 *data); |
| 267 | static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw); |
| 268 | static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw); |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 269 | static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 270 | static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw); |
| 271 | static s32 e1000_led_on_ich8lan(struct e1000_hw *hw); |
| 272 | static s32 e1000_led_off_ich8lan(struct e1000_hw *hw); |
| 273 | static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw); |
| 274 | static s32 e1000_setup_led_pchlan(struct e1000_hw *hw); |
| 275 | static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw); |
| 276 | static s32 e1000_led_on_pchlan(struct e1000_hw *hw); |
| 277 | static s32 e1000_led_off_pchlan(struct e1000_hw *hw); |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 278 | static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active); |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 279 | static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 280 | static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 281 | static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link); |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 282 | static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw); |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 283 | static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw); |
| 284 | static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw); |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 285 | static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 286 | static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index); |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 287 | static s32 e1000_k1_workaround_lv(struct e1000_hw *hw); |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 288 | static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 289 | |
| 290 | static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg) |
| 291 | { |
| 292 | return readw(hw->flash_address + reg); |
| 293 | } |
| 294 | |
| 295 | static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg) |
| 296 | { |
| 297 | return readl(hw->flash_address + reg); |
| 298 | } |
| 299 | |
| 300 | static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val) |
| 301 | { |
| 302 | writew(val, hw->flash_address + reg); |
| 303 | } |
| 304 | |
| 305 | static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val) |
| 306 | { |
| 307 | writel(val, hw->flash_address + reg); |
| 308 | } |
| 309 | |
| 310 | #define er16flash(reg) __er16flash(hw, (reg)) |
| 311 | #define er32flash(reg) __er32flash(hw, (reg)) |
Bruce Allan | 0e15df4 | 2012-01-31 06:37:11 +0000 | [diff] [blame] | 312 | #define ew16flash(reg, val) __ew16flash(hw, (reg), (val)) |
| 313 | #define ew32flash(reg, val) __ew32flash(hw, (reg), (val)) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 314 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 315 | /** |
| 316 | * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers |
| 317 | * @hw: pointer to the HW structure |
| 318 | * |
| 319 | * Test access to the PHY registers by reading the PHY ID registers. If |
| 320 | * the PHY ID is already known (e.g. resume path) compare it with known ID, |
| 321 | * otherwise assume the read PHY ID is correct if it is valid. |
| 322 | * |
| 323 | * Assumes the sw/fw/hw semaphore is already acquired. |
| 324 | **/ |
| 325 | static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw) |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 326 | { |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 327 | u16 phy_reg = 0; |
| 328 | u32 phy_id = 0; |
| 329 | s32 ret_val; |
| 330 | u16 retry_count; |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 331 | |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 332 | for (retry_count = 0; retry_count < 2; retry_count++) { |
| 333 | ret_val = e1e_rphy_locked(hw, PHY_ID1, &phy_reg); |
| 334 | if (ret_val || (phy_reg == 0xFFFF)) |
| 335 | continue; |
| 336 | phy_id = (u32)(phy_reg << 16); |
| 337 | |
| 338 | ret_val = e1e_rphy_locked(hw, PHY_ID2, &phy_reg); |
| 339 | if (ret_val || (phy_reg == 0xFFFF)) { |
| 340 | phy_id = 0; |
| 341 | continue; |
| 342 | } |
| 343 | phy_id |= (u32)(phy_reg & PHY_REVISION_MASK); |
| 344 | break; |
| 345 | } |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 346 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 347 | if (hw->phy.id) { |
| 348 | if (hw->phy.id == phy_id) |
| 349 | return true; |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 350 | } else if (phy_id) { |
| 351 | hw->phy.id = phy_id; |
| 352 | hw->phy.revision = (u32)(phy_reg & ~PHY_REVISION_MASK); |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 353 | return true; |
| 354 | } |
| 355 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 356 | /* In case the PHY needs to be in mdio slow mode, |
Bruce Allan | a52359b | 2012-07-14 04:23:58 +0000 | [diff] [blame] | 357 | * set slow mode and try to get the PHY id again. |
| 358 | */ |
| 359 | hw->phy.ops.release(hw); |
| 360 | ret_val = e1000_set_mdio_slow_mode_hv(hw); |
| 361 | if (!ret_val) |
| 362 | ret_val = e1000e_get_phy_id(hw); |
| 363 | hw->phy.ops.acquire(hw); |
| 364 | |
| 365 | return !ret_val; |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | /** |
| 369 | * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds |
| 370 | * @hw: pointer to the HW structure |
| 371 | * |
| 372 | * Workarounds/flow necessary for PHY initialization during driver load |
| 373 | * and resume paths. |
| 374 | **/ |
| 375 | static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw) |
| 376 | { |
| 377 | u32 mac_reg, fwsm = er32(FWSM); |
| 378 | s32 ret_val; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 379 | u16 phy_reg; |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 380 | |
| 381 | ret_val = hw->phy.ops.acquire(hw); |
| 382 | if (ret_val) { |
| 383 | e_dbg("Failed to initialize PHY flow\n"); |
| 384 | return ret_val; |
| 385 | } |
| 386 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 387 | /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 388 | * inaccessible and resetting the PHY is not blocked, toggle the |
| 389 | * LANPHYPC Value bit to force the interconnect to PCIe mode. |
| 390 | */ |
| 391 | switch (hw->mac.type) { |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 392 | case e1000_pch_lpt: |
| 393 | if (e1000_phy_is_accessible_pchlan(hw)) |
| 394 | break; |
| 395 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 396 | /* Before toggling LANPHYPC, see if PHY is accessible by |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 397 | * forcing MAC to SMBus mode first. |
| 398 | */ |
| 399 | mac_reg = er32(CTRL_EXT); |
| 400 | mac_reg |= E1000_CTRL_EXT_FORCE_SMBUS; |
| 401 | ew32(CTRL_EXT, mac_reg); |
| 402 | |
| 403 | /* fall-through */ |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 404 | case e1000_pch2lan: |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 405 | /* Gate automatic PHY configuration by hardware on |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 406 | * non-managed 82579 |
| 407 | */ |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 408 | if ((hw->mac.type == e1000_pch2lan) && |
| 409 | !(fwsm & E1000_ICH_FWSM_FW_VALID)) |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 410 | e1000_gate_hw_phy_config_ich8lan(hw, true); |
| 411 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 412 | if (e1000_phy_is_accessible_pchlan(hw)) { |
| 413 | if (hw->mac.type == e1000_pch_lpt) { |
| 414 | /* Unforce SMBus mode in PHY */ |
| 415 | e1e_rphy_locked(hw, CV_SMB_CTRL, &phy_reg); |
| 416 | phy_reg &= ~CV_SMB_CTRL_FORCE_SMBUS; |
| 417 | e1e_wphy_locked(hw, CV_SMB_CTRL, phy_reg); |
| 418 | |
| 419 | /* Unforce SMBus mode in MAC */ |
| 420 | mac_reg = er32(CTRL_EXT); |
| 421 | mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS; |
| 422 | ew32(CTRL_EXT, mac_reg); |
| 423 | } |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 424 | break; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 425 | } |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 426 | |
| 427 | /* fall-through */ |
| 428 | case e1000_pchlan: |
| 429 | if ((hw->mac.type == e1000_pchlan) && |
| 430 | (fwsm & E1000_ICH_FWSM_FW_VALID)) |
| 431 | break; |
| 432 | |
| 433 | if (hw->phy.ops.check_reset_block(hw)) { |
| 434 | e_dbg("Required LANPHYPC toggle blocked by ME\n"); |
| 435 | break; |
| 436 | } |
| 437 | |
| 438 | e_dbg("Toggling LANPHYPC\n"); |
| 439 | |
| 440 | /* Set Phy Config Counter to 50msec */ |
| 441 | mac_reg = er32(FEXTNVM3); |
| 442 | mac_reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK; |
| 443 | mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC; |
| 444 | ew32(FEXTNVM3, mac_reg); |
| 445 | |
| 446 | /* Toggle LANPHYPC Value bit */ |
| 447 | mac_reg = er32(CTRL); |
| 448 | mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE; |
| 449 | mac_reg &= ~E1000_CTRL_LANPHYPC_VALUE; |
| 450 | ew32(CTRL, mac_reg); |
| 451 | e1e_flush(); |
| 452 | udelay(10); |
| 453 | mac_reg &= ~E1000_CTRL_LANPHYPC_OVERRIDE; |
| 454 | ew32(CTRL, mac_reg); |
| 455 | e1e_flush(); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 456 | if (hw->mac.type < e1000_pch_lpt) { |
| 457 | msleep(50); |
| 458 | } else { |
| 459 | u16 count = 20; |
| 460 | do { |
| 461 | usleep_range(5000, 10000); |
| 462 | } while (!(er32(CTRL_EXT) & |
| 463 | E1000_CTRL_EXT_LPCD) && count--); |
| 464 | } |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 465 | break; |
| 466 | default: |
| 467 | break; |
| 468 | } |
| 469 | |
| 470 | hw->phy.ops.release(hw); |
| 471 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 472 | /* Reset the PHY before any access to it. Doing so, ensures |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 473 | * that the PHY is in a known good state before we read/write |
| 474 | * PHY registers. The generic reset is sufficient here, |
| 475 | * because we haven't determined the PHY type yet. |
| 476 | */ |
| 477 | ret_val = e1000e_phy_hw_reset_generic(hw); |
| 478 | |
| 479 | /* Ungate automatic PHY configuration on non-managed 82579 */ |
| 480 | if ((hw->mac.type == e1000_pch2lan) && |
| 481 | !(fwsm & E1000_ICH_FWSM_FW_VALID)) { |
| 482 | usleep_range(10000, 20000); |
| 483 | e1000_gate_hw_phy_config_ich8lan(hw, false); |
| 484 | } |
| 485 | |
| 486 | return ret_val; |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 487 | } |
| 488 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 489 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 490 | * e1000_init_phy_params_pchlan - Initialize PHY function pointers |
| 491 | * @hw: pointer to the HW structure |
| 492 | * |
| 493 | * Initialize family-specific PHY parameters and function pointers. |
| 494 | **/ |
| 495 | static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) |
| 496 | { |
| 497 | struct e1000_phy_info *phy = &hw->phy; |
| 498 | s32 ret_val = 0; |
| 499 | |
| 500 | phy->addr = 1; |
| 501 | phy->reset_delay_us = 100; |
| 502 | |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 503 | phy->ops.set_page = e1000_set_page_igp; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 504 | phy->ops.read_reg = e1000_read_phy_reg_hv; |
| 505 | phy->ops.read_reg_locked = e1000_read_phy_reg_hv_locked; |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 506 | phy->ops.read_reg_page = e1000_read_phy_reg_page_hv; |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 507 | phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan; |
| 508 | phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 509 | phy->ops.write_reg = e1000_write_phy_reg_hv; |
| 510 | phy->ops.write_reg_locked = e1000_write_phy_reg_hv_locked; |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 511 | phy->ops.write_reg_page = e1000_write_phy_reg_page_hv; |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 512 | phy->ops.power_up = e1000_power_up_phy_copper; |
| 513 | phy->ops.power_down = e1000_power_down_phy_copper_ich8lan; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 514 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
| 515 | |
| 516 | phy->id = e1000_phy_unknown; |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 517 | |
| 518 | ret_val = e1000_init_phy_workarounds_pchlan(hw); |
| 519 | if (ret_val) |
| 520 | return ret_val; |
| 521 | |
| 522 | if (phy->id == e1000_phy_unknown) |
| 523 | switch (hw->mac.type) { |
| 524 | default: |
| 525 | ret_val = e1000e_get_phy_id(hw); |
| 526 | if (ret_val) |
| 527 | return ret_val; |
| 528 | if ((phy->id != 0) && (phy->id != PHY_REVISION_MASK)) |
| 529 | break; |
| 530 | /* fall-through */ |
| 531 | case e1000_pch2lan: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 532 | case e1000_pch_lpt: |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 533 | /* In case the PHY needs to be in mdio slow mode, |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 534 | * set slow mode and try to get the PHY id again. |
| 535 | */ |
| 536 | ret_val = e1000_set_mdio_slow_mode_hv(hw); |
| 537 | if (ret_val) |
| 538 | return ret_val; |
| 539 | ret_val = e1000e_get_phy_id(hw); |
| 540 | if (ret_val) |
| 541 | return ret_val; |
Bruce Allan | 664dc87 | 2010-11-24 06:01:46 +0000 | [diff] [blame] | 542 | break; |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 543 | } |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 544 | phy->type = e1000e_get_phy_type_from_id(phy->id); |
| 545 | |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 546 | switch (phy->type) { |
| 547 | case e1000_phy_82577: |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 548 | case e1000_phy_82579: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 549 | case e1000_phy_i217: |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 550 | phy->ops.check_polarity = e1000_check_polarity_82577; |
| 551 | phy->ops.force_speed_duplex = |
Bruce Allan | 6cc7aae | 2011-02-25 06:25:18 +0000 | [diff] [blame] | 552 | e1000_phy_force_speed_duplex_82577; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 553 | phy->ops.get_cable_length = e1000_get_cable_length_82577; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 554 | phy->ops.get_info = e1000_get_phy_info_82577; |
| 555 | phy->ops.commit = e1000e_phy_sw_reset; |
Bruce Allan | eab50ff | 2010-05-10 15:01:30 +0000 | [diff] [blame] | 556 | break; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 557 | case e1000_phy_82578: |
| 558 | phy->ops.check_polarity = e1000_check_polarity_m88; |
| 559 | phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88; |
| 560 | phy->ops.get_cable_length = e1000e_get_cable_length_m88; |
| 561 | phy->ops.get_info = e1000e_get_phy_info_m88; |
| 562 | break; |
| 563 | default: |
| 564 | ret_val = -E1000_ERR_PHY; |
| 565 | break; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | return ret_val; |
| 569 | } |
| 570 | |
| 571 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 572 | * e1000_init_phy_params_ich8lan - Initialize PHY function pointers |
| 573 | * @hw: pointer to the HW structure |
| 574 | * |
| 575 | * Initialize family-specific PHY parameters and function pointers. |
| 576 | **/ |
| 577 | static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw) |
| 578 | { |
| 579 | struct e1000_phy_info *phy = &hw->phy; |
| 580 | s32 ret_val; |
| 581 | u16 i = 0; |
| 582 | |
| 583 | phy->addr = 1; |
| 584 | phy->reset_delay_us = 100; |
| 585 | |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 586 | phy->ops.power_up = e1000_power_up_phy_copper; |
| 587 | phy->ops.power_down = e1000_power_down_phy_copper_ich8lan; |
| 588 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 589 | /* We may need to do this twice - once for IGP and if that fails, |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 590 | * we'll set BM func pointers and try again |
| 591 | */ |
| 592 | ret_val = e1000e_determine_phy_address(hw); |
| 593 | if (ret_val) { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 594 | phy->ops.write_reg = e1000e_write_phy_reg_bm; |
| 595 | phy->ops.read_reg = e1000e_read_phy_reg_bm; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 596 | ret_val = e1000e_determine_phy_address(hw); |
Bruce Allan | 9b71b41 | 2009-12-01 15:53:07 +0000 | [diff] [blame] | 597 | if (ret_val) { |
| 598 | e_dbg("Cannot determine PHY addr. Erroring out\n"); |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 599 | return ret_val; |
Bruce Allan | 9b71b41 | 2009-12-01 15:53:07 +0000 | [diff] [blame] | 600 | } |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 601 | } |
| 602 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 603 | phy->id = 0; |
| 604 | while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) && |
| 605 | (i++ < 100)) { |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 606 | usleep_range(1000, 2000); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 607 | ret_val = e1000e_get_phy_id(hw); |
| 608 | if (ret_val) |
| 609 | return ret_val; |
| 610 | } |
| 611 | |
| 612 | /* Verify phy id */ |
| 613 | switch (phy->id) { |
| 614 | case IGP03E1000_E_PHY_ID: |
| 615 | phy->type = e1000_phy_igp_3; |
| 616 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 617 | phy->ops.read_reg_locked = e1000e_read_phy_reg_igp_locked; |
| 618 | phy->ops.write_reg_locked = e1000e_write_phy_reg_igp_locked; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 619 | phy->ops.get_info = e1000e_get_phy_info_igp; |
| 620 | phy->ops.check_polarity = e1000_check_polarity_igp; |
| 621 | phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_igp; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 622 | break; |
| 623 | case IFE_E_PHY_ID: |
| 624 | case IFE_PLUS_E_PHY_ID: |
| 625 | case IFE_C_E_PHY_ID: |
| 626 | phy->type = e1000_phy_ife; |
| 627 | phy->autoneg_mask = E1000_ALL_NOT_GIG; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 628 | phy->ops.get_info = e1000_get_phy_info_ife; |
| 629 | phy->ops.check_polarity = e1000_check_polarity_ife; |
| 630 | phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ife; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 631 | break; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 632 | case BME1000_E_PHY_ID: |
| 633 | phy->type = e1000_phy_bm; |
| 634 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 635 | phy->ops.read_reg = e1000e_read_phy_reg_bm; |
| 636 | phy->ops.write_reg = e1000e_write_phy_reg_bm; |
| 637 | phy->ops.commit = e1000e_phy_sw_reset; |
Bruce Allan | 0be8401 | 2009-12-02 17:03:18 +0000 | [diff] [blame] | 638 | phy->ops.get_info = e1000e_get_phy_info_m88; |
| 639 | phy->ops.check_polarity = e1000_check_polarity_m88; |
| 640 | phy->ops.force_speed_duplex = e1000e_phy_force_speed_duplex_m88; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 641 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 642 | default: |
| 643 | return -E1000_ERR_PHY; |
| 644 | break; |
| 645 | } |
| 646 | |
| 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers |
| 652 | * @hw: pointer to the HW structure |
| 653 | * |
| 654 | * Initialize family-specific NVM parameters and function |
| 655 | * pointers. |
| 656 | **/ |
| 657 | static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw) |
| 658 | { |
| 659 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 660 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 661 | u32 gfpreg, sector_base_addr, sector_end_addr; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 662 | u16 i; |
| 663 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 664 | /* Can't read flash registers if the register set isn't mapped. */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 665 | if (!hw->flash_address) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 666 | e_dbg("ERROR: Flash registers not mapped\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 667 | return -E1000_ERR_CONFIG; |
| 668 | } |
| 669 | |
| 670 | nvm->type = e1000_nvm_flash_sw; |
| 671 | |
| 672 | gfpreg = er32flash(ICH_FLASH_GFPREG); |
| 673 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 674 | /* sector_X_addr is a "sector"-aligned address (4096 bytes) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 675 | * Add 1 to sector_end_addr since this sector is included in |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 676 | * the overall size. |
| 677 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 678 | sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK; |
| 679 | sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1; |
| 680 | |
| 681 | /* flash_base_addr is byte-aligned */ |
| 682 | nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT; |
| 683 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 684 | /* find total size of the NVM, then cut in half since the total |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 685 | * size represents two separate NVM banks. |
| 686 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 687 | nvm->flash_bank_size = (sector_end_addr - sector_base_addr) |
| 688 | << FLASH_SECTOR_ADDR_SHIFT; |
| 689 | nvm->flash_bank_size /= 2; |
| 690 | /* Adjust to word count */ |
| 691 | nvm->flash_bank_size /= sizeof(u16); |
| 692 | |
| 693 | nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS; |
| 694 | |
| 695 | /* Clear shadow ram */ |
| 696 | for (i = 0; i < nvm->word_size; i++) { |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 697 | dev_spec->shadow_ram[i].modified = false; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 698 | dev_spec->shadow_ram[i].value = 0xFFFF; |
| 699 | } |
| 700 | |
| 701 | return 0; |
| 702 | } |
| 703 | |
| 704 | /** |
| 705 | * e1000_init_mac_params_ich8lan - Initialize MAC function pointers |
| 706 | * @hw: pointer to the HW structure |
| 707 | * |
| 708 | * Initialize family-specific MAC parameters and function |
| 709 | * pointers. |
| 710 | **/ |
Bruce Allan | ec34c17 | 2012-02-01 10:53:05 +0000 | [diff] [blame] | 711 | static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 712 | { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 713 | struct e1000_mac_info *mac = &hw->mac; |
| 714 | |
| 715 | /* Set media type function pointer */ |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 716 | hw->phy.media_type = e1000_media_type_copper; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 717 | |
| 718 | /* Set mta register count */ |
| 719 | mac->mta_reg_count = 32; |
| 720 | /* Set rar entry count */ |
| 721 | mac->rar_entry_count = E1000_ICH_RAR_ENTRIES; |
| 722 | if (mac->type == e1000_ich8lan) |
| 723 | mac->rar_entry_count--; |
Bruce Allan | a65a4a0 | 2010-05-10 15:01:51 +0000 | [diff] [blame] | 724 | /* FWSM register */ |
| 725 | mac->has_fwsm = true; |
| 726 | /* ARC subsystem not supported */ |
| 727 | mac->arc_subsystem_valid = false; |
Bruce Allan | f464ba8 | 2010-01-07 16:31:35 +0000 | [diff] [blame] | 728 | /* Adaptive IFS supported */ |
| 729 | mac->adaptive_ifs = true; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 730 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 731 | /* LED and other operations */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 732 | switch (mac->type) { |
| 733 | case e1000_ich8lan: |
| 734 | case e1000_ich9lan: |
| 735 | case e1000_ich10lan: |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 736 | /* check management mode */ |
| 737 | mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 738 | /* ID LED init */ |
Bruce Allan | d1964eb | 2012-02-22 09:02:21 +0000 | [diff] [blame] | 739 | mac->ops.id_led_init = e1000e_id_led_init_generic; |
Bruce Allan | dbf80dc | 2011-04-16 00:34:40 +0000 | [diff] [blame] | 740 | /* blink LED */ |
| 741 | mac->ops.blink_led = e1000e_blink_led_generic; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 742 | /* setup LED */ |
| 743 | mac->ops.setup_led = e1000e_setup_led_generic; |
| 744 | /* cleanup LED */ |
| 745 | mac->ops.cleanup_led = e1000_cleanup_led_ich8lan; |
| 746 | /* turn on/off LED */ |
| 747 | mac->ops.led_on = e1000_led_on_ich8lan; |
| 748 | mac->ops.led_off = e1000_led_off_ich8lan; |
| 749 | break; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 750 | case e1000_pch2lan: |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 751 | mac->rar_entry_count = E1000_PCH2_RAR_ENTRIES; |
| 752 | mac->ops.rar_set = e1000_rar_set_pch2lan; |
| 753 | /* fall-through */ |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 754 | case e1000_pch_lpt: |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 755 | case e1000_pchlan: |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 756 | /* check management mode */ |
| 757 | mac->ops.check_mng_mode = e1000_check_mng_mode_pchlan; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 758 | /* ID LED init */ |
| 759 | mac->ops.id_led_init = e1000_id_led_init_pchlan; |
| 760 | /* setup LED */ |
| 761 | mac->ops.setup_led = e1000_setup_led_pchlan; |
| 762 | /* cleanup LED */ |
| 763 | mac->ops.cleanup_led = e1000_cleanup_led_pchlan; |
| 764 | /* turn on/off LED */ |
| 765 | mac->ops.led_on = e1000_led_on_pchlan; |
| 766 | mac->ops.led_off = e1000_led_off_pchlan; |
| 767 | break; |
| 768 | default: |
| 769 | break; |
| 770 | } |
| 771 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 772 | if (mac->type == e1000_pch_lpt) { |
| 773 | mac->rar_entry_count = E1000_PCH_LPT_RAR_ENTRIES; |
| 774 | mac->ops.rar_set = e1000_rar_set_pch_lpt; |
| 775 | } |
| 776 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 777 | /* Enable PCS Lock-loss workaround for ICH8 */ |
| 778 | if (mac->type == e1000_ich8lan) |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 779 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 780 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 781 | /* Gate automatic PHY configuration by hardware on managed |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 782 | * 82579 and i217 |
| 783 | */ |
| 784 | if ((mac->type == e1000_pch2lan || mac->type == e1000_pch_lpt) && |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 785 | (er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) |
| 786 | e1000_gate_hw_phy_config_ich8lan(hw, true); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 787 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 788 | return 0; |
| 789 | } |
| 790 | |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 791 | /** |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 792 | * e1000_set_eee_pchlan - Enable/disable EEE support |
| 793 | * @hw: pointer to the HW structure |
| 794 | * |
| 795 | * Enable/disable EEE based on setting in dev_spec structure. The bits in |
| 796 | * the LPI Control register will remain set only if/when link is up. |
| 797 | **/ |
| 798 | static s32 e1000_set_eee_pchlan(struct e1000_hw *hw) |
| 799 | { |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 800 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 801 | s32 ret_val = 0; |
| 802 | u16 phy_reg; |
| 803 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 804 | if ((hw->phy.type != e1000_phy_82579) && |
| 805 | (hw->phy.type != e1000_phy_i217)) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 806 | return 0; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 807 | |
| 808 | ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg); |
| 809 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 810 | return ret_val; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 811 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 812 | if (dev_spec->eee_disable) |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 813 | phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK; |
| 814 | else |
| 815 | phy_reg |= I82579_LPI_CTRL_ENABLE_MASK; |
| 816 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 817 | ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg); |
| 818 | if (ret_val) |
| 819 | return ret_val; |
| 820 | |
| 821 | if ((hw->phy.type == e1000_phy_i217) && !dev_spec->eee_disable) { |
| 822 | /* Save off link partner's EEE ability */ |
| 823 | ret_val = hw->phy.ops.acquire(hw); |
| 824 | if (ret_val) |
| 825 | return ret_val; |
| 826 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, |
| 827 | I217_EEE_LP_ABILITY); |
| 828 | if (ret_val) |
| 829 | goto release; |
| 830 | e1e_rphy_locked(hw, I82579_EMI_DATA, &dev_spec->eee_lp_ability); |
| 831 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 832 | /* EEE is not supported in 100Half, so ignore partner's EEE |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 833 | * in 100 ability if full-duplex is not advertised. |
| 834 | */ |
| 835 | e1e_rphy_locked(hw, PHY_LP_ABILITY, &phy_reg); |
| 836 | if (!(phy_reg & NWAY_LPAR_100TX_FD_CAPS)) |
| 837 | dev_spec->eee_lp_ability &= ~I217_EEE_100_SUPPORTED; |
| 838 | release: |
| 839 | hw->phy.ops.release(hw); |
| 840 | } |
| 841 | |
| 842 | return 0; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | /** |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 846 | * e1000_check_for_copper_link_ich8lan - Check for link (Copper) |
| 847 | * @hw: pointer to the HW structure |
| 848 | * |
| 849 | * Checks to see of the link status of the hardware has changed. If a |
| 850 | * change in link status has been detected, then we read the PHY registers |
| 851 | * to get the current speed/duplex if link exists. |
| 852 | **/ |
| 853 | static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) |
| 854 | { |
| 855 | struct e1000_mac_info *mac = &hw->mac; |
| 856 | s32 ret_val; |
| 857 | bool link; |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 858 | u16 phy_reg; |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 859 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 860 | /* We only want to go out to the PHY registers to see if Auto-Neg |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 861 | * has completed and/or if our link status has changed. The |
| 862 | * get_link_status flag is set upon receiving a Link Status |
| 863 | * Change or Rx Sequence Error interrupt. |
| 864 | */ |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 865 | if (!mac->get_link_status) |
| 866 | return 0; |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 867 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 868 | /* First we want to see if the MII Status Register reports |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 869 | * link. If so, then we want to get the current speed/duplex |
| 870 | * of the PHY. |
| 871 | */ |
| 872 | ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); |
| 873 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 874 | return ret_val; |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 875 | |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 876 | if (hw->mac.type == e1000_pchlan) { |
| 877 | ret_val = e1000_k1_gig_workaround_hv(hw, link); |
| 878 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 879 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 880 | } |
| 881 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 882 | /* Clear link partner's EEE ability */ |
| 883 | hw->dev_spec.ich8lan.eee_lp_ability = 0; |
| 884 | |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 885 | if (!link) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 886 | return 0; /* No link detected */ |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 887 | |
| 888 | mac->get_link_status = false; |
| 889 | |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 890 | switch (hw->mac.type) { |
| 891 | case e1000_pch2lan: |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 892 | ret_val = e1000_k1_workaround_lv(hw); |
| 893 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 894 | return ret_val; |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 895 | /* fall-thru */ |
| 896 | case e1000_pchlan: |
| 897 | if (hw->phy.type == e1000_phy_82578) { |
| 898 | ret_val = e1000_link_stall_workaround_hv(hw); |
| 899 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 900 | return ret_val; |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 901 | } |
| 902 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 903 | /* Workaround for PCHx parts in half-duplex: |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 904 | * Set the number of preambles removed from the packet |
| 905 | * when it is passed from the PHY to the MAC to prevent |
| 906 | * the MAC from misinterpreting the packet type. |
| 907 | */ |
| 908 | e1e_rphy(hw, HV_KMRN_FIFO_CTRLSTA, &phy_reg); |
| 909 | phy_reg &= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK; |
| 910 | |
| 911 | if ((er32(STATUS) & E1000_STATUS_FD) != E1000_STATUS_FD) |
| 912 | phy_reg |= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT); |
| 913 | |
| 914 | e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, phy_reg); |
| 915 | break; |
| 916 | default: |
| 917 | break; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 918 | } |
| 919 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 920 | /* Check if there was DownShift, must be checked |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 921 | * immediately after link-up |
| 922 | */ |
| 923 | e1000e_check_downshift(hw); |
| 924 | |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 925 | /* Enable/Disable EEE after link up */ |
| 926 | ret_val = e1000_set_eee_pchlan(hw); |
| 927 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 928 | return ret_val; |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 929 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 930 | /* If we are forcing speed/duplex, then we simply return since |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 931 | * we have already determined whether we have link or not. |
| 932 | */ |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 933 | if (!mac->autoneg) |
| 934 | return -E1000_ERR_CONFIG; |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 935 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 936 | /* Auto-Neg is enabled. Auto Speed Detection takes care |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 937 | * of MAC speed/duplex configuration. So we only need to |
| 938 | * configure Collision Distance in the MAC. |
| 939 | */ |
Bruce Allan | 57cde76 | 2012-02-22 09:02:58 +0000 | [diff] [blame] | 940 | mac->ops.config_collision_dist(hw); |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 941 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 942 | /* Configure Flow Control now that Auto-Neg has completed. |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 943 | * First, we need to restore the desired flow control |
| 944 | * settings because we may have had to re-autoneg with a |
| 945 | * different link partner. |
| 946 | */ |
| 947 | ret_val = e1000e_config_fc_after_link_up(hw); |
| 948 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 949 | e_dbg("Error configuring flow control\n"); |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 950 | |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 951 | return ret_val; |
| 952 | } |
| 953 | |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 954 | static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 955 | { |
| 956 | struct e1000_hw *hw = &adapter->hw; |
| 957 | s32 rc; |
| 958 | |
Bruce Allan | ec34c17 | 2012-02-01 10:53:05 +0000 | [diff] [blame] | 959 | rc = e1000_init_mac_params_ich8lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 960 | if (rc) |
| 961 | return rc; |
| 962 | |
| 963 | rc = e1000_init_nvm_params_ich8lan(hw); |
| 964 | if (rc) |
| 965 | return rc; |
| 966 | |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 967 | switch (hw->mac.type) { |
| 968 | case e1000_ich8lan: |
| 969 | case e1000_ich9lan: |
| 970 | case e1000_ich10lan: |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 971 | rc = e1000_init_phy_params_ich8lan(hw); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 972 | break; |
| 973 | case e1000_pchlan: |
| 974 | case e1000_pch2lan: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 975 | case e1000_pch_lpt: |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 976 | rc = e1000_init_phy_params_pchlan(hw); |
| 977 | break; |
| 978 | default: |
| 979 | break; |
| 980 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 981 | if (rc) |
| 982 | return rc; |
| 983 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 984 | /* Disable Jumbo Frame support on parts with Intel 10/100 PHY or |
Bruce Allan | 23e4f06 | 2011-02-25 07:44:51 +0000 | [diff] [blame] | 985 | * on parts with MACsec enabled in NVM (reflected in CTRL_EXT). |
| 986 | */ |
| 987 | if ((adapter->hw.phy.type == e1000_phy_ife) || |
| 988 | ((adapter->hw.mac.type >= e1000_pch2lan) && |
| 989 | (!(er32(CTRL_EXT) & E1000_CTRL_EXT_LSECCK)))) { |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 990 | adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES; |
| 991 | adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN; |
Bruce Allan | dbf80dc | 2011-04-16 00:34:40 +0000 | [diff] [blame] | 992 | |
| 993 | hw->mac.ops.blink_led = NULL; |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 994 | } |
| 995 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 996 | if ((adapter->hw.mac.type == e1000_ich8lan) && |
Bruce Allan | 462d599 | 2011-09-30 08:07:11 +0000 | [diff] [blame] | 997 | (adapter->hw.phy.type != e1000_phy_ife)) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 998 | adapter->flags |= FLAG_LSC_GIG_SPEED_DROP; |
| 999 | |
Bruce Allan | c6e7f51 | 2011-07-29 05:53:02 +0000 | [diff] [blame] | 1000 | /* Enable workaround for 82579 w/ ME enabled */ |
| 1001 | if ((adapter->hw.mac.type == e1000_pch2lan) && |
| 1002 | (er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) |
| 1003 | adapter->flags2 |= FLAG2_PCIM2PCI_ARBITER_WA; |
| 1004 | |
Bruce Allan | 5a86f28 | 2010-06-29 18:13:13 +0000 | [diff] [blame] | 1005 | /* Disable EEE by default until IEEE802.3az spec is finalized */ |
| 1006 | if (adapter->flags2 & FLAG2_HAS_EEE) |
| 1007 | adapter->hw.dev_spec.ich8lan.eee_disable = true; |
| 1008 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1009 | return 0; |
| 1010 | } |
| 1011 | |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 1012 | static DEFINE_MUTEX(nvm_mutex); |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 1013 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1014 | /** |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1015 | * e1000_acquire_nvm_ich8lan - Acquire NVM mutex |
| 1016 | * @hw: pointer to the HW structure |
| 1017 | * |
| 1018 | * Acquires the mutex for performing NVM operations. |
| 1019 | **/ |
| 1020 | static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw) |
| 1021 | { |
| 1022 | mutex_lock(&nvm_mutex); |
| 1023 | |
| 1024 | return 0; |
| 1025 | } |
| 1026 | |
| 1027 | /** |
| 1028 | * e1000_release_nvm_ich8lan - Release NVM mutex |
| 1029 | * @hw: pointer to the HW structure |
| 1030 | * |
| 1031 | * Releases the mutex used while performing NVM operations. |
| 1032 | **/ |
| 1033 | static void e1000_release_nvm_ich8lan(struct e1000_hw *hw) |
| 1034 | { |
| 1035 | mutex_unlock(&nvm_mutex); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1036 | } |
| 1037 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1038 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1039 | * e1000_acquire_swflag_ich8lan - Acquire software control flag |
| 1040 | * @hw: pointer to the HW structure |
| 1041 | * |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1042 | * Acquires the software control flag for performing PHY and select |
| 1043 | * MAC CSR accesses. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1044 | **/ |
| 1045 | static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) |
| 1046 | { |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1047 | u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT; |
| 1048 | s32 ret_val = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1049 | |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1050 | if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE, |
| 1051 | &hw->adapter->state)) { |
Bruce Allan | 34c9ef8 | 2011-10-21 04:33:47 +0000 | [diff] [blame] | 1052 | e_dbg("contention for Phy access\n"); |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1053 | return -E1000_ERR_PHY; |
| 1054 | } |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 1055 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1056 | while (timeout) { |
| 1057 | extcnf_ctrl = er32(EXTCNF_CTRL); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1058 | if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)) |
| 1059 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1060 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1061 | mdelay(1); |
| 1062 | timeout--; |
| 1063 | } |
| 1064 | |
| 1065 | if (!timeout) { |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1066 | e_dbg("SW has already locked the resource.\n"); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1067 | ret_val = -E1000_ERR_CONFIG; |
| 1068 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1069 | } |
| 1070 | |
Bruce Allan | 53ac5a8 | 2009-10-26 11:23:06 +0000 | [diff] [blame] | 1071 | timeout = SW_FLAG_TIMEOUT; |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1072 | |
| 1073 | extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; |
| 1074 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 1075 | |
| 1076 | while (timeout) { |
| 1077 | extcnf_ctrl = er32(EXTCNF_CTRL); |
| 1078 | if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) |
| 1079 | break; |
| 1080 | |
| 1081 | mdelay(1); |
| 1082 | timeout--; |
| 1083 | } |
| 1084 | |
| 1085 | if (!timeout) { |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 1086 | e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n", |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1087 | er32(FWSM), extcnf_ctrl); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1088 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; |
| 1089 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 1090 | ret_val = -E1000_ERR_CONFIG; |
| 1091 | goto out; |
| 1092 | } |
| 1093 | |
| 1094 | out: |
| 1095 | if (ret_val) |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1096 | clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 1097 | |
| 1098 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1099 | } |
| 1100 | |
| 1101 | /** |
| 1102 | * e1000_release_swflag_ich8lan - Release software control flag |
| 1103 | * @hw: pointer to the HW structure |
| 1104 | * |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1105 | * Releases the software control flag for performing PHY and select |
| 1106 | * MAC CSR accesses. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1107 | **/ |
| 1108 | static void e1000_release_swflag_ich8lan(struct e1000_hw *hw) |
| 1109 | { |
| 1110 | u32 extcnf_ctrl; |
| 1111 | |
| 1112 | extcnf_ctrl = er32(EXTCNF_CTRL); |
Bruce Allan | c5caf48 | 2011-05-13 07:19:53 +0000 | [diff] [blame] | 1113 | |
| 1114 | if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) { |
| 1115 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; |
| 1116 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 1117 | } else { |
| 1118 | e_dbg("Semaphore unexpectedly released by sw/fw/hw\n"); |
| 1119 | } |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 1120 | |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 1121 | clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
| 1124 | /** |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1125 | * e1000_check_mng_mode_ich8lan - Checks management mode |
| 1126 | * @hw: pointer to the HW structure |
| 1127 | * |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 1128 | * This checks if the adapter has any manageability enabled. |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1129 | * This is a function pointer entry point only called by read/write |
| 1130 | * routines for the PHY and NVM parts. |
| 1131 | **/ |
| 1132 | static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw) |
| 1133 | { |
Bruce Allan | a708dd8 | 2009-11-20 23:28:37 +0000 | [diff] [blame] | 1134 | u32 fwsm; |
| 1135 | |
| 1136 | fwsm = er32(FWSM); |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 1137 | return (fwsm & E1000_ICH_FWSM_FW_VALID) && |
| 1138 | ((fwsm & E1000_FWSM_MODE_MASK) == |
| 1139 | (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT)); |
| 1140 | } |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1141 | |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 1142 | /** |
| 1143 | * e1000_check_mng_mode_pchlan - Checks management mode |
| 1144 | * @hw: pointer to the HW structure |
| 1145 | * |
| 1146 | * This checks if the adapter has iAMT enabled. |
| 1147 | * This is a function pointer entry point only called by read/write |
| 1148 | * routines for the PHY and NVM parts. |
| 1149 | **/ |
| 1150 | static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw) |
| 1151 | { |
| 1152 | u32 fwsm; |
| 1153 | |
| 1154 | fwsm = er32(FWSM); |
| 1155 | return (fwsm & E1000_ICH_FWSM_FW_VALID) && |
| 1156 | (fwsm & (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT)); |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 1157 | } |
| 1158 | |
| 1159 | /** |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 1160 | * e1000_rar_set_pch2lan - Set receive address register |
| 1161 | * @hw: pointer to the HW structure |
| 1162 | * @addr: pointer to the receive address |
| 1163 | * @index: receive address array register |
| 1164 | * |
| 1165 | * Sets the receive address array register at index to the address passed |
| 1166 | * in by addr. For 82579, RAR[0] is the base address register that is to |
| 1167 | * contain the MAC address but RAR[1-6] are reserved for manageability (ME). |
| 1168 | * Use SHRA[0-3] in place of those reserved for ME. |
| 1169 | **/ |
| 1170 | static void e1000_rar_set_pch2lan(struct e1000_hw *hw, u8 *addr, u32 index) |
| 1171 | { |
| 1172 | u32 rar_low, rar_high; |
| 1173 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1174 | /* HW expects these in little endian so we reverse the byte order |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 1175 | * from network order (big endian) to little endian |
| 1176 | */ |
| 1177 | rar_low = ((u32)addr[0] | |
| 1178 | ((u32)addr[1] << 8) | |
| 1179 | ((u32)addr[2] << 16) | ((u32)addr[3] << 24)); |
| 1180 | |
| 1181 | rar_high = ((u32)addr[4] | ((u32)addr[5] << 8)); |
| 1182 | |
| 1183 | /* If MAC address zero, no need to set the AV bit */ |
| 1184 | if (rar_low || rar_high) |
| 1185 | rar_high |= E1000_RAH_AV; |
| 1186 | |
| 1187 | if (index == 0) { |
| 1188 | ew32(RAL(index), rar_low); |
| 1189 | e1e_flush(); |
| 1190 | ew32(RAH(index), rar_high); |
| 1191 | e1e_flush(); |
| 1192 | return; |
| 1193 | } |
| 1194 | |
| 1195 | if (index < hw->mac.rar_entry_count) { |
| 1196 | s32 ret_val; |
| 1197 | |
| 1198 | ret_val = e1000_acquire_swflag_ich8lan(hw); |
| 1199 | if (ret_val) |
| 1200 | goto out; |
| 1201 | |
| 1202 | ew32(SHRAL(index - 1), rar_low); |
| 1203 | e1e_flush(); |
| 1204 | ew32(SHRAH(index - 1), rar_high); |
| 1205 | e1e_flush(); |
| 1206 | |
| 1207 | e1000_release_swflag_ich8lan(hw); |
| 1208 | |
| 1209 | /* verify the register updates */ |
| 1210 | if ((er32(SHRAL(index - 1)) == rar_low) && |
| 1211 | (er32(SHRAH(index - 1)) == rar_high)) |
| 1212 | return; |
| 1213 | |
| 1214 | e_dbg("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n", |
| 1215 | (index - 1), er32(FWSM)); |
| 1216 | } |
| 1217 | |
| 1218 | out: |
| 1219 | e_dbg("Failed to write receive address at index %d\n", index); |
| 1220 | } |
| 1221 | |
| 1222 | /** |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1223 | * e1000_rar_set_pch_lpt - Set receive address registers |
| 1224 | * @hw: pointer to the HW structure |
| 1225 | * @addr: pointer to the receive address |
| 1226 | * @index: receive address array register |
| 1227 | * |
| 1228 | * Sets the receive address register array at index to the address passed |
| 1229 | * in by addr. For LPT, RAR[0] is the base address register that is to |
| 1230 | * contain the MAC address. SHRA[0-10] are the shared receive address |
| 1231 | * registers that are shared between the Host and manageability engine (ME). |
| 1232 | **/ |
| 1233 | static void e1000_rar_set_pch_lpt(struct e1000_hw *hw, u8 *addr, u32 index) |
| 1234 | { |
| 1235 | u32 rar_low, rar_high; |
| 1236 | u32 wlock_mac; |
| 1237 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1238 | /* HW expects these in little endian so we reverse the byte order |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1239 | * from network order (big endian) to little endian |
| 1240 | */ |
| 1241 | rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) | |
| 1242 | ((u32)addr[2] << 16) | ((u32)addr[3] << 24)); |
| 1243 | |
| 1244 | rar_high = ((u32)addr[4] | ((u32)addr[5] << 8)); |
| 1245 | |
| 1246 | /* If MAC address zero, no need to set the AV bit */ |
| 1247 | if (rar_low || rar_high) |
| 1248 | rar_high |= E1000_RAH_AV; |
| 1249 | |
| 1250 | if (index == 0) { |
| 1251 | ew32(RAL(index), rar_low); |
| 1252 | e1e_flush(); |
| 1253 | ew32(RAH(index), rar_high); |
| 1254 | e1e_flush(); |
| 1255 | return; |
| 1256 | } |
| 1257 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1258 | /* The manageability engine (ME) can lock certain SHRAR registers that |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1259 | * it is using - those registers are unavailable for use. |
| 1260 | */ |
| 1261 | if (index < hw->mac.rar_entry_count) { |
| 1262 | wlock_mac = er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK; |
| 1263 | wlock_mac >>= E1000_FWSM_WLOCK_MAC_SHIFT; |
| 1264 | |
| 1265 | /* Check if all SHRAR registers are locked */ |
| 1266 | if (wlock_mac == 1) |
| 1267 | goto out; |
| 1268 | |
| 1269 | if ((wlock_mac == 0) || (index <= wlock_mac)) { |
| 1270 | s32 ret_val; |
| 1271 | |
| 1272 | ret_val = e1000_acquire_swflag_ich8lan(hw); |
| 1273 | |
| 1274 | if (ret_val) |
| 1275 | goto out; |
| 1276 | |
| 1277 | ew32(SHRAL_PCH_LPT(index - 1), rar_low); |
| 1278 | e1e_flush(); |
| 1279 | ew32(SHRAH_PCH_LPT(index - 1), rar_high); |
| 1280 | e1e_flush(); |
| 1281 | |
| 1282 | e1000_release_swflag_ich8lan(hw); |
| 1283 | |
| 1284 | /* verify the register updates */ |
| 1285 | if ((er32(SHRAL_PCH_LPT(index - 1)) == rar_low) && |
| 1286 | (er32(SHRAH_PCH_LPT(index - 1)) == rar_high)) |
| 1287 | return; |
| 1288 | } |
| 1289 | } |
| 1290 | |
| 1291 | out: |
| 1292 | e_dbg("Failed to write receive address at index %d\n", index); |
| 1293 | } |
| 1294 | |
| 1295 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1296 | * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked |
| 1297 | * @hw: pointer to the HW structure |
| 1298 | * |
| 1299 | * Checks if firmware is blocking the reset of the PHY. |
| 1300 | * This is a function pointer entry point only called by |
| 1301 | * reset routines. |
| 1302 | **/ |
| 1303 | static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw) |
| 1304 | { |
| 1305 | u32 fwsm; |
| 1306 | |
| 1307 | fwsm = er32(FWSM); |
| 1308 | |
| 1309 | return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET; |
| 1310 | } |
| 1311 | |
| 1312 | /** |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1313 | * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states |
| 1314 | * @hw: pointer to the HW structure |
| 1315 | * |
| 1316 | * Assumes semaphore already acquired. |
| 1317 | * |
| 1318 | **/ |
| 1319 | static s32 e1000_write_smbus_addr(struct e1000_hw *hw) |
| 1320 | { |
| 1321 | u16 phy_data; |
| 1322 | u32 strap = er32(STRAP); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1323 | u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >> |
| 1324 | E1000_STRAP_SMT_FREQ_SHIFT; |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1325 | s32 ret_val = 0; |
| 1326 | |
| 1327 | strap &= E1000_STRAP_SMBUS_ADDRESS_MASK; |
| 1328 | |
| 1329 | ret_val = e1000_read_phy_reg_hv_locked(hw, HV_SMB_ADDR, &phy_data); |
| 1330 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1331 | return ret_val; |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1332 | |
| 1333 | phy_data &= ~HV_SMB_ADDR_MASK; |
| 1334 | phy_data |= (strap >> E1000_STRAP_SMBUS_ADDRESS_SHIFT); |
| 1335 | phy_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID; |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1336 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1337 | if (hw->phy.type == e1000_phy_i217) { |
| 1338 | /* Restore SMBus frequency */ |
| 1339 | if (freq--) { |
| 1340 | phy_data &= ~HV_SMB_ADDR_FREQ_MASK; |
| 1341 | phy_data |= (freq & (1 << 0)) << |
| 1342 | HV_SMB_ADDR_FREQ_LOW_SHIFT; |
| 1343 | phy_data |= (freq & (1 << 1)) << |
| 1344 | (HV_SMB_ADDR_FREQ_HIGH_SHIFT - 1); |
| 1345 | } else { |
| 1346 | e_dbg("Unsupported SMB frequency in PHY\n"); |
| 1347 | } |
| 1348 | } |
| 1349 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1350 | return e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, phy_data); |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1351 | } |
| 1352 | |
| 1353 | /** |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1354 | * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration |
| 1355 | * @hw: pointer to the HW structure |
| 1356 | * |
| 1357 | * SW should configure the LCD from the NVM extended configuration region |
| 1358 | * as a workaround for certain parts. |
| 1359 | **/ |
| 1360 | static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw) |
| 1361 | { |
| 1362 | struct e1000_phy_info *phy = &hw->phy; |
| 1363 | u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask; |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1364 | s32 ret_val = 0; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1365 | u16 word_addr, reg_data, reg_addr, phy_page = 0; |
| 1366 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1367 | /* Initialize the PHY from the NVM on ICH platforms. This |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1368 | * is needed due to an issue where the NVM configuration is |
| 1369 | * not properly autoloaded after power transitions. |
| 1370 | * Therefore, after each PHY reset, we will load the |
| 1371 | * configuration data out of the NVM manually. |
| 1372 | */ |
Bruce Allan | 3f0c16e | 2010-06-16 13:26:17 +0000 | [diff] [blame] | 1373 | switch (hw->mac.type) { |
| 1374 | case e1000_ich8lan: |
| 1375 | if (phy->type != e1000_phy_igp_3) |
| 1376 | return ret_val; |
| 1377 | |
Bruce Allan | 5f3eed6 | 2010-09-22 17:15:54 +0000 | [diff] [blame] | 1378 | if ((hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_AMT) || |
| 1379 | (hw->adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_C)) { |
Bruce Allan | 3f0c16e | 2010-06-16 13:26:17 +0000 | [diff] [blame] | 1380 | sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG; |
| 1381 | break; |
| 1382 | } |
| 1383 | /* Fall-thru */ |
| 1384 | case e1000_pchlan: |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1385 | case e1000_pch2lan: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1386 | case e1000_pch_lpt: |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1387 | sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M; |
Bruce Allan | 3f0c16e | 2010-06-16 13:26:17 +0000 | [diff] [blame] | 1388 | break; |
| 1389 | default: |
| 1390 | return ret_val; |
| 1391 | } |
| 1392 | |
| 1393 | ret_val = hw->phy.ops.acquire(hw); |
| 1394 | if (ret_val) |
| 1395 | return ret_val; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1396 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1397 | data = er32(FEXTNVM); |
| 1398 | if (!(data & sw_cfg_mask)) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1399 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1400 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1401 | /* Make sure HW does not configure LCD from PHY |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1402 | * extended configuration before SW configuration |
| 1403 | */ |
| 1404 | data = er32(EXTCNF_CTRL); |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1405 | if ((hw->mac.type < e1000_pch2lan) && |
| 1406 | (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE)) |
| 1407 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1408 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1409 | cnf_size = er32(EXTCNF_SIZE); |
| 1410 | cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK; |
| 1411 | cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT; |
| 1412 | if (!cnf_size) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1413 | goto release; |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1414 | |
| 1415 | cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK; |
| 1416 | cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT; |
| 1417 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1418 | if (((hw->mac.type == e1000_pchlan) && |
| 1419 | !(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE)) || |
| 1420 | (hw->mac.type > e1000_pchlan)) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1421 | /* HW configures the SMBus address and LEDs when the |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1422 | * OEM and LCD Write Enable bits are set in the NVM. |
| 1423 | * When both NVM bits are cleared, SW will configure |
| 1424 | * them instead. |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1425 | */ |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 1426 | ret_val = e1000_write_smbus_addr(hw); |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1427 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1428 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1429 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1430 | data = er32(LEDCTL); |
| 1431 | ret_val = e1000_write_phy_reg_hv_locked(hw, HV_LED_CONFIG, |
| 1432 | (u16)data); |
| 1433 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1434 | goto release; |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1435 | } |
| 1436 | |
| 1437 | /* Configure LCD from extended configuration region. */ |
| 1438 | |
| 1439 | /* cnf_base_addr is in DWORD */ |
| 1440 | word_addr = (u16)(cnf_base_addr << 1); |
| 1441 | |
| 1442 | for (i = 0; i < cnf_size; i++) { |
| 1443 | ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1, |
| 1444 | ®_data); |
| 1445 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1446 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1447 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1448 | ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1), |
| 1449 | 1, ®_addr); |
| 1450 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1451 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1452 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1453 | /* Save off the PHY page for future writes. */ |
| 1454 | if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) { |
| 1455 | phy_page = reg_data; |
| 1456 | continue; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1457 | } |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1458 | |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1459 | reg_addr &= PHY_REG_MASK; |
| 1460 | reg_addr |= phy_page; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1461 | |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1462 | ret_val = e1e_wphy_locked(hw, (u32)reg_addr, reg_data); |
Bruce Allan | 8b802a7 | 2010-05-10 15:01:10 +0000 | [diff] [blame] | 1463 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1464 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1465 | } |
| 1466 | |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1467 | release: |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1468 | hw->phy.ops.release(hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1469 | return ret_val; |
| 1470 | } |
| 1471 | |
| 1472 | /** |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1473 | * e1000_k1_gig_workaround_hv - K1 Si workaround |
| 1474 | * @hw: pointer to the HW structure |
| 1475 | * @link: link up bool flag |
| 1476 | * |
| 1477 | * If K1 is enabled for 1Gbps, the MAC might stall when transitioning |
| 1478 | * from a lower speed. This workaround disables K1 whenever link is at 1Gig |
| 1479 | * If link is down, the function will restore the default K1 setting located |
| 1480 | * in the NVM. |
| 1481 | **/ |
| 1482 | static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link) |
| 1483 | { |
| 1484 | s32 ret_val = 0; |
| 1485 | u16 status_reg = 0; |
| 1486 | bool k1_enable = hw->dev_spec.ich8lan.nvm_k1_enabled; |
| 1487 | |
| 1488 | if (hw->mac.type != e1000_pchlan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1489 | return 0; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1490 | |
| 1491 | /* Wrap the whole flow with the sw flag */ |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1492 | ret_val = hw->phy.ops.acquire(hw); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1493 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1494 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1495 | |
| 1496 | /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */ |
| 1497 | if (link) { |
| 1498 | if (hw->phy.type == e1000_phy_82578) { |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1499 | ret_val = e1e_rphy_locked(hw, BM_CS_STATUS, |
| 1500 | &status_reg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1501 | if (ret_val) |
| 1502 | goto release; |
| 1503 | |
| 1504 | status_reg &= BM_CS_STATUS_LINK_UP | |
| 1505 | BM_CS_STATUS_RESOLVED | |
| 1506 | BM_CS_STATUS_SPEED_MASK; |
| 1507 | |
| 1508 | if (status_reg == (BM_CS_STATUS_LINK_UP | |
| 1509 | BM_CS_STATUS_RESOLVED | |
| 1510 | BM_CS_STATUS_SPEED_1000)) |
| 1511 | k1_enable = false; |
| 1512 | } |
| 1513 | |
| 1514 | if (hw->phy.type == e1000_phy_82577) { |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1515 | ret_val = e1e_rphy_locked(hw, HV_M_STATUS, &status_reg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1516 | if (ret_val) |
| 1517 | goto release; |
| 1518 | |
| 1519 | status_reg &= HV_M_STATUS_LINK_UP | |
| 1520 | HV_M_STATUS_AUTONEG_COMPLETE | |
| 1521 | HV_M_STATUS_SPEED_MASK; |
| 1522 | |
| 1523 | if (status_reg == (HV_M_STATUS_LINK_UP | |
| 1524 | HV_M_STATUS_AUTONEG_COMPLETE | |
| 1525 | HV_M_STATUS_SPEED_1000)) |
| 1526 | k1_enable = false; |
| 1527 | } |
| 1528 | |
| 1529 | /* Link stall fix for link up */ |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1530 | ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x0100); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1531 | if (ret_val) |
| 1532 | goto release; |
| 1533 | |
| 1534 | } else { |
| 1535 | /* Link stall fix for link down */ |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1536 | ret_val = e1e_wphy_locked(hw, PHY_REG(770, 19), 0x4100); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1537 | if (ret_val) |
| 1538 | goto release; |
| 1539 | } |
| 1540 | |
| 1541 | ret_val = e1000_configure_k1_ich8lan(hw, k1_enable); |
| 1542 | |
| 1543 | release: |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1544 | hw->phy.ops.release(hw); |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1545 | |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1546 | return ret_val; |
| 1547 | } |
| 1548 | |
| 1549 | /** |
| 1550 | * e1000_configure_k1_ich8lan - Configure K1 power state |
| 1551 | * @hw: pointer to the HW structure |
| 1552 | * @enable: K1 state to configure |
| 1553 | * |
| 1554 | * Configure the K1 power state based on the provided parameter. |
| 1555 | * Assumes semaphore already acquired. |
| 1556 | * |
| 1557 | * Success returns 0, Failure returns -E1000_ERR_PHY (-2) |
| 1558 | **/ |
Bruce Allan | bb436b2 | 2009-11-20 23:24:11 +0000 | [diff] [blame] | 1559 | s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable) |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1560 | { |
| 1561 | s32 ret_val = 0; |
| 1562 | u32 ctrl_reg = 0; |
| 1563 | u32 ctrl_ext = 0; |
| 1564 | u32 reg = 0; |
| 1565 | u16 kmrn_reg = 0; |
| 1566 | |
Bruce Allan | 3d3a167 | 2012-02-23 03:13:18 +0000 | [diff] [blame] | 1567 | ret_val = e1000e_read_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG, |
| 1568 | &kmrn_reg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1569 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1570 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1571 | |
| 1572 | if (k1_enable) |
| 1573 | kmrn_reg |= E1000_KMRNCTRLSTA_K1_ENABLE; |
| 1574 | else |
| 1575 | kmrn_reg &= ~E1000_KMRNCTRLSTA_K1_ENABLE; |
| 1576 | |
Bruce Allan | 3d3a167 | 2012-02-23 03:13:18 +0000 | [diff] [blame] | 1577 | ret_val = e1000e_write_kmrn_reg_locked(hw, E1000_KMRNCTRLSTA_K1_CONFIG, |
| 1578 | kmrn_reg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1579 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1580 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1581 | |
| 1582 | udelay(20); |
| 1583 | ctrl_ext = er32(CTRL_EXT); |
| 1584 | ctrl_reg = er32(CTRL); |
| 1585 | |
| 1586 | reg = ctrl_reg & ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100); |
| 1587 | reg |= E1000_CTRL_FRCSPD; |
| 1588 | ew32(CTRL, reg); |
| 1589 | |
| 1590 | ew32(CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_SPD_BYPS); |
Jesse Brandeburg | 945a515 | 2011-07-20 00:56:21 +0000 | [diff] [blame] | 1591 | e1e_flush(); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1592 | udelay(20); |
| 1593 | ew32(CTRL, ctrl_reg); |
| 1594 | ew32(CTRL_EXT, ctrl_ext); |
Jesse Brandeburg | 945a515 | 2011-07-20 00:56:21 +0000 | [diff] [blame] | 1595 | e1e_flush(); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1596 | udelay(20); |
| 1597 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1598 | return 0; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1599 | } |
| 1600 | |
| 1601 | /** |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1602 | * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration |
| 1603 | * @hw: pointer to the HW structure |
| 1604 | * @d0_state: boolean if entering d0 or d3 device state |
| 1605 | * |
| 1606 | * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are |
| 1607 | * collectively called OEM bits. The OEM Write Enable bit and SW Config bit |
| 1608 | * in NVM determines whether HW should configure LPLU and Gbe Disable. |
| 1609 | **/ |
| 1610 | static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state) |
| 1611 | { |
| 1612 | s32 ret_val = 0; |
| 1613 | u32 mac_reg; |
| 1614 | u16 oem_reg; |
| 1615 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1616 | if (hw->mac.type < e1000_pchlan) |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1617 | return ret_val; |
| 1618 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1619 | ret_val = hw->phy.ops.acquire(hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1620 | if (ret_val) |
| 1621 | return ret_val; |
| 1622 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1623 | if (hw->mac.type == e1000_pchlan) { |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1624 | mac_reg = er32(EXTCNF_CTRL); |
| 1625 | if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1626 | goto release; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1627 | } |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1628 | |
| 1629 | mac_reg = er32(FEXTNVM); |
| 1630 | if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M)) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1631 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1632 | |
| 1633 | mac_reg = er32(PHY_CTRL); |
| 1634 | |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1635 | ret_val = e1e_rphy_locked(hw, HV_OEM_BITS, &oem_reg); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1636 | if (ret_val) |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1637 | goto release; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1638 | |
| 1639 | oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU); |
| 1640 | |
| 1641 | if (d0_state) { |
| 1642 | if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE) |
| 1643 | oem_reg |= HV_OEM_BITS_GBE_DIS; |
| 1644 | |
| 1645 | if (mac_reg & E1000_PHY_CTRL_D0A_LPLU) |
| 1646 | oem_reg |= HV_OEM_BITS_LPLU; |
| 1647 | } else { |
Bruce Allan | 03299e4 | 2011-09-30 08:07:05 +0000 | [diff] [blame] | 1648 | if (mac_reg & (E1000_PHY_CTRL_GBE_DISABLE | |
| 1649 | E1000_PHY_CTRL_NOND0A_GBE_DISABLE)) |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1650 | oem_reg |= HV_OEM_BITS_GBE_DIS; |
| 1651 | |
Bruce Allan | 03299e4 | 2011-09-30 08:07:05 +0000 | [diff] [blame] | 1652 | if (mac_reg & (E1000_PHY_CTRL_D0A_LPLU | |
| 1653 | E1000_PHY_CTRL_NOND0A_LPLU)) |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1654 | oem_reg |= HV_OEM_BITS_LPLU; |
| 1655 | } |
Bruce Allan | 03299e4 | 2011-09-30 08:07:05 +0000 | [diff] [blame] | 1656 | |
Bruce Allan | 92fe173 | 2012-04-12 06:27:03 +0000 | [diff] [blame] | 1657 | /* Set Restart auto-neg to activate the bits */ |
| 1658 | if ((d0_state || (hw->mac.type != e1000_pchlan)) && |
| 1659 | !hw->phy.ops.check_reset_block(hw)) |
| 1660 | oem_reg |= HV_OEM_BITS_RESTART_AN; |
| 1661 | |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1662 | ret_val = e1e_wphy_locked(hw, HV_OEM_BITS, oem_reg); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1663 | |
Bruce Allan | 75ce153 | 2012-02-08 02:54:48 +0000 | [diff] [blame] | 1664 | release: |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1665 | hw->phy.ops.release(hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 1666 | |
| 1667 | return ret_val; |
| 1668 | } |
| 1669 | |
| 1670 | |
| 1671 | /** |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 1672 | * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode |
| 1673 | * @hw: pointer to the HW structure |
| 1674 | **/ |
| 1675 | static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw) |
| 1676 | { |
| 1677 | s32 ret_val; |
| 1678 | u16 data; |
| 1679 | |
| 1680 | ret_val = e1e_rphy(hw, HV_KMRN_MODE_CTRL, &data); |
| 1681 | if (ret_val) |
| 1682 | return ret_val; |
| 1683 | |
| 1684 | data |= HV_KMRN_MDIO_SLOW; |
| 1685 | |
| 1686 | ret_val = e1e_wphy(hw, HV_KMRN_MODE_CTRL, data); |
| 1687 | |
| 1688 | return ret_val; |
| 1689 | } |
| 1690 | |
| 1691 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1692 | * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be |
| 1693 | * done after every PHY reset. |
| 1694 | **/ |
| 1695 | static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw) |
| 1696 | { |
| 1697 | s32 ret_val = 0; |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1698 | u16 phy_data; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1699 | |
| 1700 | if (hw->mac.type != e1000_pchlan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1701 | return 0; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1702 | |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 1703 | /* Set MDIO slow mode before any other MDIO access */ |
| 1704 | if (hw->phy.type == e1000_phy_82577) { |
| 1705 | ret_val = e1000_set_mdio_slow_mode_hv(hw); |
| 1706 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1707 | return ret_val; |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 1708 | } |
| 1709 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1710 | if (((hw->phy.type == e1000_phy_82577) && |
| 1711 | ((hw->phy.revision == 1) || (hw->phy.revision == 2))) || |
| 1712 | ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) { |
| 1713 | /* Disable generation of early preamble */ |
| 1714 | ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431); |
| 1715 | if (ret_val) |
| 1716 | return ret_val; |
| 1717 | |
| 1718 | /* Preamble tuning for SSC */ |
Bruce Allan | 1d2101a7 | 2011-07-22 06:21:56 +0000 | [diff] [blame] | 1719 | ret_val = e1e_wphy(hw, HV_KMRN_FIFO_CTRLSTA, 0xA204); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1720 | if (ret_val) |
| 1721 | return ret_val; |
| 1722 | } |
| 1723 | |
| 1724 | if (hw->phy.type == e1000_phy_82578) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1725 | /* Return registers to default by doing a soft reset then |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1726 | * writing 0x3140 to the control register. |
| 1727 | */ |
| 1728 | if (hw->phy.revision < 2) { |
| 1729 | e1000e_phy_sw_reset(hw); |
| 1730 | ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140); |
| 1731 | } |
| 1732 | } |
| 1733 | |
| 1734 | /* Select page 0 */ |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 1735 | ret_val = hw->phy.ops.acquire(hw); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1736 | if (ret_val) |
| 1737 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1738 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1739 | hw->phy.addr = 1; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1740 | ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0); |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1741 | hw->phy.ops.release(hw); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1742 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1743 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1744 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1745 | /* Configure the K1 Si workaround during phy reset assuming there is |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1746 | * link so that it disables K1 if link is in 1Gbps. |
| 1747 | */ |
| 1748 | ret_val = e1000_k1_gig_workaround_hv(hw, true); |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1749 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1750 | return ret_val; |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 1751 | |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1752 | /* Workaround for link disconnects on a busy hub in half duplex */ |
| 1753 | ret_val = hw->phy.ops.acquire(hw); |
| 1754 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1755 | return ret_val; |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1756 | ret_val = e1e_rphy_locked(hw, BM_PORT_GEN_CFG, &phy_data); |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1757 | if (ret_val) |
| 1758 | goto release; |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1759 | ret_val = e1e_wphy_locked(hw, BM_PORT_GEN_CFG, phy_data & 0x00FF); |
Bruce Allan | baf86c9 | 2010-01-13 01:53:08 +0000 | [diff] [blame] | 1760 | release: |
| 1761 | hw->phy.ops.release(hw); |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1762 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1763 | return ret_val; |
| 1764 | } |
| 1765 | |
| 1766 | /** |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1767 | * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY |
| 1768 | * @hw: pointer to the HW structure |
| 1769 | **/ |
| 1770 | void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw) |
| 1771 | { |
| 1772 | u32 mac_reg; |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 1773 | u16 i, phy_reg = 0; |
| 1774 | s32 ret_val; |
| 1775 | |
| 1776 | ret_val = hw->phy.ops.acquire(hw); |
| 1777 | if (ret_val) |
| 1778 | return; |
| 1779 | ret_val = e1000_enable_phy_wakeup_reg_access_bm(hw, &phy_reg); |
| 1780 | if (ret_val) |
| 1781 | goto release; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1782 | |
| 1783 | /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */ |
| 1784 | for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) { |
| 1785 | mac_reg = er32(RAL(i)); |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 1786 | hw->phy.ops.write_reg_page(hw, BM_RAR_L(i), |
| 1787 | (u16)(mac_reg & 0xFFFF)); |
| 1788 | hw->phy.ops.write_reg_page(hw, BM_RAR_M(i), |
| 1789 | (u16)((mac_reg >> 16) & 0xFFFF)); |
| 1790 | |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1791 | mac_reg = er32(RAH(i)); |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 1792 | hw->phy.ops.write_reg_page(hw, BM_RAR_H(i), |
| 1793 | (u16)(mac_reg & 0xFFFF)); |
| 1794 | hw->phy.ops.write_reg_page(hw, BM_RAR_CTRL(i), |
| 1795 | (u16)((mac_reg & E1000_RAH_AV) |
| 1796 | >> 16)); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1797 | } |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 1798 | |
| 1799 | e1000_disable_phy_wakeup_reg_access_bm(hw, &phy_reg); |
| 1800 | |
| 1801 | release: |
| 1802 | hw->phy.ops.release(hw); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1803 | } |
| 1804 | |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1805 | /** |
| 1806 | * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation |
| 1807 | * with 82579 PHY |
| 1808 | * @hw: pointer to the HW structure |
| 1809 | * @enable: flag to enable/disable workaround when enabling/disabling jumbos |
| 1810 | **/ |
| 1811 | s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable) |
| 1812 | { |
| 1813 | s32 ret_val = 0; |
| 1814 | u16 phy_reg, data; |
| 1815 | u32 mac_reg; |
| 1816 | u16 i; |
| 1817 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 1818 | if (hw->mac.type < e1000_pch2lan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1819 | return 0; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1820 | |
| 1821 | /* disable Rx path while enabling/disabling workaround */ |
| 1822 | e1e_rphy(hw, PHY_REG(769, 20), &phy_reg); |
| 1823 | ret_val = e1e_wphy(hw, PHY_REG(769, 20), phy_reg | (1 << 14)); |
| 1824 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1825 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1826 | |
| 1827 | if (enable) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 1828 | /* Write Rx addresses (rar_entry_count for RAL/H, +4 for |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1829 | * SHRAL/H) and initial CRC values to the MAC |
| 1830 | */ |
| 1831 | for (i = 0; i < (hw->mac.rar_entry_count + 4); i++) { |
| 1832 | u8 mac_addr[ETH_ALEN] = {0}; |
| 1833 | u32 addr_high, addr_low; |
| 1834 | |
| 1835 | addr_high = er32(RAH(i)); |
| 1836 | if (!(addr_high & E1000_RAH_AV)) |
| 1837 | continue; |
| 1838 | addr_low = er32(RAL(i)); |
| 1839 | mac_addr[0] = (addr_low & 0xFF); |
| 1840 | mac_addr[1] = ((addr_low >> 8) & 0xFF); |
| 1841 | mac_addr[2] = ((addr_low >> 16) & 0xFF); |
| 1842 | mac_addr[3] = ((addr_low >> 24) & 0xFF); |
| 1843 | mac_addr[4] = (addr_high & 0xFF); |
| 1844 | mac_addr[5] = ((addr_high >> 8) & 0xFF); |
| 1845 | |
Bruce Allan | fe46f58 | 2011-01-06 14:29:51 +0000 | [diff] [blame] | 1846 | ew32(PCH_RAICC(i), ~ether_crc_le(ETH_ALEN, mac_addr)); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1847 | } |
| 1848 | |
| 1849 | /* Write Rx addresses to the PHY */ |
| 1850 | e1000_copy_rx_addrs_to_phy_ich8lan(hw); |
| 1851 | |
| 1852 | /* Enable jumbo frame workaround in the MAC */ |
| 1853 | mac_reg = er32(FFLT_DBG); |
| 1854 | mac_reg &= ~(1 << 14); |
| 1855 | mac_reg |= (7 << 15); |
| 1856 | ew32(FFLT_DBG, mac_reg); |
| 1857 | |
| 1858 | mac_reg = er32(RCTL); |
| 1859 | mac_reg |= E1000_RCTL_SECRC; |
| 1860 | ew32(RCTL, mac_reg); |
| 1861 | |
| 1862 | ret_val = e1000e_read_kmrn_reg(hw, |
| 1863 | E1000_KMRNCTRLSTA_CTRL_OFFSET, |
| 1864 | &data); |
| 1865 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1866 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1867 | ret_val = e1000e_write_kmrn_reg(hw, |
| 1868 | E1000_KMRNCTRLSTA_CTRL_OFFSET, |
| 1869 | data | (1 << 0)); |
| 1870 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1871 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1872 | ret_val = e1000e_read_kmrn_reg(hw, |
| 1873 | E1000_KMRNCTRLSTA_HD_CTRL, |
| 1874 | &data); |
| 1875 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1876 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1877 | data &= ~(0xF << 8); |
| 1878 | data |= (0xB << 8); |
| 1879 | ret_val = e1000e_write_kmrn_reg(hw, |
| 1880 | E1000_KMRNCTRLSTA_HD_CTRL, |
| 1881 | data); |
| 1882 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1883 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1884 | |
| 1885 | /* Enable jumbo frame workaround in the PHY */ |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1886 | e1e_rphy(hw, PHY_REG(769, 23), &data); |
| 1887 | data &= ~(0x7F << 5); |
| 1888 | data |= (0x37 << 5); |
| 1889 | ret_val = e1e_wphy(hw, PHY_REG(769, 23), data); |
| 1890 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1891 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1892 | e1e_rphy(hw, PHY_REG(769, 16), &data); |
| 1893 | data &= ~(1 << 13); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1894 | ret_val = e1e_wphy(hw, PHY_REG(769, 16), data); |
| 1895 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1896 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1897 | e1e_rphy(hw, PHY_REG(776, 20), &data); |
| 1898 | data &= ~(0x3FF << 2); |
| 1899 | data |= (0x1A << 2); |
| 1900 | ret_val = e1e_wphy(hw, PHY_REG(776, 20), data); |
| 1901 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1902 | return ret_val; |
Bruce Allan | b64e9dd | 2011-09-30 08:07:00 +0000 | [diff] [blame] | 1903 | ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0xF100); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1904 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1905 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1906 | e1e_rphy(hw, HV_PM_CTRL, &data); |
| 1907 | ret_val = e1e_wphy(hw, HV_PM_CTRL, data | (1 << 10)); |
| 1908 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1909 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1910 | } else { |
| 1911 | /* Write MAC register values back to h/w defaults */ |
| 1912 | mac_reg = er32(FFLT_DBG); |
| 1913 | mac_reg &= ~(0xF << 14); |
| 1914 | ew32(FFLT_DBG, mac_reg); |
| 1915 | |
| 1916 | mac_reg = er32(RCTL); |
| 1917 | mac_reg &= ~E1000_RCTL_SECRC; |
Bruce Allan | a1ce647 | 2010-09-22 17:16:40 +0000 | [diff] [blame] | 1918 | ew32(RCTL, mac_reg); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1919 | |
| 1920 | ret_val = e1000e_read_kmrn_reg(hw, |
| 1921 | E1000_KMRNCTRLSTA_CTRL_OFFSET, |
| 1922 | &data); |
| 1923 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1924 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1925 | ret_val = e1000e_write_kmrn_reg(hw, |
| 1926 | E1000_KMRNCTRLSTA_CTRL_OFFSET, |
| 1927 | data & ~(1 << 0)); |
| 1928 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1929 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1930 | ret_val = e1000e_read_kmrn_reg(hw, |
| 1931 | E1000_KMRNCTRLSTA_HD_CTRL, |
| 1932 | &data); |
| 1933 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1934 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1935 | data &= ~(0xF << 8); |
| 1936 | data |= (0xB << 8); |
| 1937 | ret_val = e1000e_write_kmrn_reg(hw, |
| 1938 | E1000_KMRNCTRLSTA_HD_CTRL, |
| 1939 | data); |
| 1940 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1941 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1942 | |
| 1943 | /* Write PHY register values back to h/w defaults */ |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1944 | e1e_rphy(hw, PHY_REG(769, 23), &data); |
| 1945 | data &= ~(0x7F << 5); |
| 1946 | ret_val = e1e_wphy(hw, PHY_REG(769, 23), data); |
| 1947 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1948 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1949 | e1e_rphy(hw, PHY_REG(769, 16), &data); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1950 | data |= (1 << 13); |
| 1951 | ret_val = e1e_wphy(hw, PHY_REG(769, 16), data); |
| 1952 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1953 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1954 | e1e_rphy(hw, PHY_REG(776, 20), &data); |
| 1955 | data &= ~(0x3FF << 2); |
| 1956 | data |= (0x8 << 2); |
| 1957 | ret_val = e1e_wphy(hw, PHY_REG(776, 20), data); |
| 1958 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1959 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1960 | ret_val = e1e_wphy(hw, PHY_REG(776, 23), 0x7E00); |
| 1961 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1962 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1963 | e1e_rphy(hw, HV_PM_CTRL, &data); |
| 1964 | ret_val = e1e_wphy(hw, HV_PM_CTRL, data & ~(1 << 10)); |
| 1965 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1966 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1967 | } |
| 1968 | |
| 1969 | /* re-enable Rx path after enabling/disabling workaround */ |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1970 | return e1e_wphy(hw, PHY_REG(769, 20), phy_reg & ~(1 << 14)); |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1971 | } |
| 1972 | |
| 1973 | /** |
| 1974 | * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be |
| 1975 | * done after every PHY reset. |
| 1976 | **/ |
| 1977 | static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw) |
| 1978 | { |
| 1979 | s32 ret_val = 0; |
| 1980 | |
| 1981 | if (hw->mac.type != e1000_pch2lan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1982 | return 0; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 1983 | |
| 1984 | /* Set MDIO slow mode before any other MDIO access */ |
| 1985 | ret_val = e1000_set_mdio_slow_mode_hv(hw); |
| 1986 | |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 1987 | ret_val = hw->phy.ops.acquire(hw); |
| 1988 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 1989 | return ret_val; |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1990 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, I82579_MSE_THRESHOLD); |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 1991 | if (ret_val) |
| 1992 | goto release; |
| 1993 | /* set MSE higher to enable link to stay up when noise is high */ |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1994 | ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, 0x0034); |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 1995 | if (ret_val) |
| 1996 | goto release; |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 1997 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, I82579_MSE_LINK_DOWN); |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 1998 | if (ret_val) |
| 1999 | goto release; |
| 2000 | /* drop link after 5 times MSE threshold was reached */ |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 2001 | ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, 0x0005); |
Bruce Allan | 4d24136 | 2011-12-16 00:46:06 +0000 | [diff] [blame] | 2002 | release: |
| 2003 | hw->phy.ops.release(hw); |
| 2004 | |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2005 | return ret_val; |
| 2006 | } |
| 2007 | |
| 2008 | /** |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2009 | * e1000_k1_gig_workaround_lv - K1 Si workaround |
| 2010 | * @hw: pointer to the HW structure |
| 2011 | * |
| 2012 | * Workaround to set the K1 beacon duration for 82579 parts |
| 2013 | **/ |
| 2014 | static s32 e1000_k1_workaround_lv(struct e1000_hw *hw) |
| 2015 | { |
| 2016 | s32 ret_val = 0; |
| 2017 | u16 status_reg = 0; |
| 2018 | u32 mac_reg; |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2019 | u16 phy_reg; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2020 | |
| 2021 | if (hw->mac.type != e1000_pch2lan) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2022 | return 0; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2023 | |
| 2024 | /* Set K1 beacon duration based on 1Gbps speed or otherwise */ |
| 2025 | ret_val = e1e_rphy(hw, HV_M_STATUS, &status_reg); |
| 2026 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2027 | return ret_val; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2028 | |
| 2029 | if ((status_reg & (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) |
| 2030 | == (HV_M_STATUS_LINK_UP | HV_M_STATUS_AUTONEG_COMPLETE)) { |
| 2031 | mac_reg = er32(FEXTNVM4); |
| 2032 | mac_reg &= ~E1000_FEXTNVM4_BEACON_DURATION_MASK; |
| 2033 | |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2034 | ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg); |
| 2035 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2036 | return ret_val; |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2037 | |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2038 | if (status_reg & HV_M_STATUS_SPEED_1000) { |
Bruce Allan | 36ceeb4 | 2012-03-20 03:47:47 +0000 | [diff] [blame] | 2039 | u16 pm_phy_reg; |
| 2040 | |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2041 | mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_8USEC; |
| 2042 | phy_reg &= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT; |
Bruce Allan | 36ceeb4 | 2012-03-20 03:47:47 +0000 | [diff] [blame] | 2043 | /* LV 1G Packet drop issue wa */ |
| 2044 | ret_val = e1e_rphy(hw, HV_PM_CTRL, &pm_phy_reg); |
| 2045 | if (ret_val) |
| 2046 | return ret_val; |
| 2047 | pm_phy_reg &= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA; |
| 2048 | ret_val = e1e_wphy(hw, HV_PM_CTRL, pm_phy_reg); |
| 2049 | if (ret_val) |
| 2050 | return ret_val; |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2051 | } else { |
| 2052 | mac_reg |= E1000_FEXTNVM4_BEACON_DURATION_16USEC; |
| 2053 | phy_reg |= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT; |
| 2054 | } |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2055 | ew32(FEXTNVM4, mac_reg); |
Bruce Allan | 0ed013e | 2011-07-29 05:52:56 +0000 | [diff] [blame] | 2056 | ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg); |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2057 | } |
| 2058 | |
Bruce Allan | 831bd2e | 2010-09-22 17:16:18 +0000 | [diff] [blame] | 2059 | return ret_val; |
| 2060 | } |
| 2061 | |
| 2062 | /** |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2063 | * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware |
| 2064 | * @hw: pointer to the HW structure |
| 2065 | * @gate: boolean set to true to gate, false to ungate |
| 2066 | * |
| 2067 | * Gate/ungate the automatic PHY configuration via hardware; perform |
| 2068 | * the configuration via software instead. |
| 2069 | **/ |
| 2070 | static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw *hw, bool gate) |
| 2071 | { |
| 2072 | u32 extcnf_ctrl; |
| 2073 | |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 2074 | if (hw->mac.type < e1000_pch2lan) |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2075 | return; |
| 2076 | |
| 2077 | extcnf_ctrl = er32(EXTCNF_CTRL); |
| 2078 | |
| 2079 | if (gate) |
| 2080 | extcnf_ctrl |= E1000_EXTCNF_CTRL_GATE_PHY_CFG; |
| 2081 | else |
| 2082 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG; |
| 2083 | |
| 2084 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2085 | } |
| 2086 | |
| 2087 | /** |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2088 | * e1000_lan_init_done_ich8lan - Check for PHY config completion |
| 2089 | * @hw: pointer to the HW structure |
| 2090 | * |
| 2091 | * Check the appropriate indication the MAC has finished configuring the |
| 2092 | * PHY after a software reset. |
| 2093 | **/ |
| 2094 | static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw) |
| 2095 | { |
| 2096 | u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT; |
| 2097 | |
| 2098 | /* Wait for basic configuration completes before proceeding */ |
| 2099 | do { |
| 2100 | data = er32(STATUS); |
| 2101 | data &= E1000_STATUS_LAN_INIT_DONE; |
| 2102 | udelay(100); |
| 2103 | } while ((!data) && --loop); |
| 2104 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2105 | /* If basic configuration is incomplete before the above loop |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2106 | * count reaches 0, loading the configuration from NVM will |
| 2107 | * leave the PHY in a bad state possibly resulting in no link. |
| 2108 | */ |
| 2109 | if (loop == 0) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2110 | e_dbg("LAN_INIT_DONE not set, increase timeout\n"); |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2111 | |
| 2112 | /* Clear the Init Done bit for the next init event */ |
| 2113 | data = er32(STATUS); |
| 2114 | data &= ~E1000_STATUS_LAN_INIT_DONE; |
| 2115 | ew32(STATUS, data); |
| 2116 | } |
| 2117 | |
| 2118 | /** |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2119 | * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2120 | * @hw: pointer to the HW structure |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2121 | **/ |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2122 | static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2123 | { |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 2124 | s32 ret_val = 0; |
| 2125 | u16 reg; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2126 | |
Bruce Allan | 44abd5c | 2012-02-22 09:02:37 +0000 | [diff] [blame] | 2127 | if (hw->phy.ops.check_reset_block(hw)) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2128 | return 0; |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2129 | |
Bruce Allan | 5f3eed6 | 2010-09-22 17:15:54 +0000 | [diff] [blame] | 2130 | /* Allow time for h/w to get to quiescent state after reset */ |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 2131 | usleep_range(10000, 20000); |
Bruce Allan | 5f3eed6 | 2010-09-22 17:15:54 +0000 | [diff] [blame] | 2132 | |
Bruce Allan | fddaa1a | 2010-01-13 01:52:49 +0000 | [diff] [blame] | 2133 | /* Perform any necessary post-reset workarounds */ |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2134 | switch (hw->mac.type) { |
| 2135 | case e1000_pchlan: |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2136 | ret_val = e1000_hv_phy_workarounds_ich8lan(hw); |
| 2137 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2138 | return ret_val; |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2139 | break; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2140 | case e1000_pch2lan: |
| 2141 | ret_val = e1000_lv_phy_workarounds_ich8lan(hw); |
| 2142 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2143 | return ret_val; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 2144 | break; |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2145 | default: |
| 2146 | break; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2147 | } |
| 2148 | |
Bruce Allan | 3ebfc7c | 2011-05-13 07:20:14 +0000 | [diff] [blame] | 2149 | /* Clear the host wakeup bit after lcd reset */ |
| 2150 | if (hw->mac.type >= e1000_pchlan) { |
| 2151 | e1e_rphy(hw, BM_PORT_GEN_CFG, ®); |
| 2152 | reg &= ~BM_WUC_HOST_WU_BIT; |
| 2153 | e1e_wphy(hw, BM_PORT_GEN_CFG, reg); |
| 2154 | } |
Bruce Allan | db2932e | 2009-10-26 11:22:47 +0000 | [diff] [blame] | 2155 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 2156 | /* Configure the LCD with the extended configuration region in NVM */ |
| 2157 | ret_val = e1000_sw_lcd_config_ich8lan(hw); |
| 2158 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2159 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2160 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 2161 | /* Configure the LCD with the OEM bits in NVM */ |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2162 | ret_val = e1000_oem_bits_config_ich8lan(hw, true); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2163 | |
Bruce Allan | 1effb45 | 2011-02-25 06:58:03 +0000 | [diff] [blame] | 2164 | if (hw->mac.type == e1000_pch2lan) { |
| 2165 | /* Ungate automatic PHY configuration on non-managed 82579 */ |
| 2166 | if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) { |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 2167 | usleep_range(10000, 20000); |
Bruce Allan | 1effb45 | 2011-02-25 06:58:03 +0000 | [diff] [blame] | 2168 | e1000_gate_hw_phy_config_ich8lan(hw, false); |
| 2169 | } |
| 2170 | |
| 2171 | /* Set EEE LPI Update Timer to 200usec */ |
| 2172 | ret_val = hw->phy.ops.acquire(hw); |
| 2173 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2174 | return ret_val; |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 2175 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, |
| 2176 | I82579_LPI_UPDATE_TIMER); |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2177 | if (!ret_val) |
Bruce Allan | f1430d6 | 2012-04-14 04:21:52 +0000 | [diff] [blame] | 2178 | ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, 0x1387); |
Bruce Allan | 1effb45 | 2011-02-25 06:58:03 +0000 | [diff] [blame] | 2179 | hw->phy.ops.release(hw); |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2180 | } |
| 2181 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2182 | return ret_val; |
| 2183 | } |
| 2184 | |
| 2185 | /** |
| 2186 | * e1000_phy_hw_reset_ich8lan - Performs a PHY reset |
| 2187 | * @hw: pointer to the HW structure |
| 2188 | * |
| 2189 | * Resets the PHY |
| 2190 | * This is a function pointer entry point called by drivers |
| 2191 | * or other shared routines. |
| 2192 | **/ |
| 2193 | static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw) |
| 2194 | { |
| 2195 | s32 ret_val = 0; |
| 2196 | |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 2197 | /* Gate automatic PHY configuration by hardware on non-managed 82579 */ |
| 2198 | if ((hw->mac.type == e1000_pch2lan) && |
| 2199 | !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) |
| 2200 | e1000_gate_hw_phy_config_ich8lan(hw, true); |
| 2201 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2202 | ret_val = e1000e_phy_hw_reset_generic(hw); |
| 2203 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2204 | return ret_val; |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 2205 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2206 | return e1000_post_phy_reset_ich8lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2207 | } |
| 2208 | |
| 2209 | /** |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 2210 | * e1000_set_lplu_state_pchlan - Set Low Power Link Up state |
| 2211 | * @hw: pointer to the HW structure |
| 2212 | * @active: true to enable LPLU, false to disable |
| 2213 | * |
| 2214 | * Sets the LPLU state according to the active flag. For PCH, if OEM write |
| 2215 | * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set |
| 2216 | * the phy speed. This function will manually set the LPLU bit and restart |
| 2217 | * auto-neg as hw would do. D3 and D0 LPLU will call the same function |
| 2218 | * since it configures the same bit. |
| 2219 | **/ |
| 2220 | static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active) |
| 2221 | { |
| 2222 | s32 ret_val = 0; |
| 2223 | u16 oem_reg; |
| 2224 | |
| 2225 | ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg); |
| 2226 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2227 | return ret_val; |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 2228 | |
| 2229 | if (active) |
| 2230 | oem_reg |= HV_OEM_BITS_LPLU; |
| 2231 | else |
| 2232 | oem_reg &= ~HV_OEM_BITS_LPLU; |
| 2233 | |
Bruce Allan | 44abd5c | 2012-02-22 09:02:37 +0000 | [diff] [blame] | 2234 | if (!hw->phy.ops.check_reset_block(hw)) |
Bruce Allan | 464c85e | 2011-12-16 00:46:49 +0000 | [diff] [blame] | 2235 | oem_reg |= HV_OEM_BITS_RESTART_AN; |
| 2236 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 2237 | return e1e_wphy(hw, HV_OEM_BITS, oem_reg); |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 2238 | } |
| 2239 | |
| 2240 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2241 | * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state |
| 2242 | * @hw: pointer to the HW structure |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 2243 | * @active: true to enable LPLU, false to disable |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2244 | * |
| 2245 | * Sets the LPLU D0 state according to the active flag. When |
| 2246 | * activating LPLU this function also disables smart speed |
| 2247 | * and vice versa. LPLU will not be activated unless the |
| 2248 | * device autonegotiation advertisement meets standards of |
| 2249 | * either 10 or 10/100 or 10/100/1000 at all duplexes. |
| 2250 | * This is a function pointer entry point only called by |
| 2251 | * PHY setup routines. |
| 2252 | **/ |
| 2253 | static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active) |
| 2254 | { |
| 2255 | struct e1000_phy_info *phy = &hw->phy; |
| 2256 | u32 phy_ctrl; |
| 2257 | s32 ret_val = 0; |
| 2258 | u16 data; |
| 2259 | |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 2260 | if (phy->type == e1000_phy_ife) |
Bruce Allan | 8260725 | 2012-02-08 02:55:09 +0000 | [diff] [blame] | 2261 | return 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2262 | |
| 2263 | phy_ctrl = er32(PHY_CTRL); |
| 2264 | |
| 2265 | if (active) { |
| 2266 | phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU; |
| 2267 | ew32(PHY_CTRL, phy_ctrl); |
| 2268 | |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2269 | if (phy->type != e1000_phy_igp_3) |
| 2270 | return 0; |
| 2271 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2272 | /* Call gig speed drop workaround on LPLU before accessing |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2273 | * any PHY registers |
| 2274 | */ |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2275 | if (hw->mac.type == e1000_ich8lan) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2276 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 2277 | |
| 2278 | /* When LPLU is enabled, we should disable SmartSpeed */ |
| 2279 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); |
| 2280 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
| 2281 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); |
| 2282 | if (ret_val) |
| 2283 | return ret_val; |
| 2284 | } else { |
| 2285 | phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU; |
| 2286 | ew32(PHY_CTRL, phy_ctrl); |
| 2287 | |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2288 | if (phy->type != e1000_phy_igp_3) |
| 2289 | return 0; |
| 2290 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2291 | /* LPLU and SmartSpeed are mutually exclusive. LPLU is used |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2292 | * during Dx states where the power conservation is most |
| 2293 | * important. During driver activity we should enable |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2294 | * SmartSpeed, so performance is maintained. |
| 2295 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2296 | if (phy->smart_speed == e1000_smart_speed_on) { |
| 2297 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2298 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2299 | if (ret_val) |
| 2300 | return ret_val; |
| 2301 | |
| 2302 | data |= IGP01E1000_PSCFR_SMART_SPEED; |
| 2303 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2304 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2305 | if (ret_val) |
| 2306 | return ret_val; |
| 2307 | } else if (phy->smart_speed == e1000_smart_speed_off) { |
| 2308 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2309 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2310 | if (ret_val) |
| 2311 | return ret_val; |
| 2312 | |
| 2313 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
| 2314 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2315 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2316 | if (ret_val) |
| 2317 | return ret_val; |
| 2318 | } |
| 2319 | } |
| 2320 | |
| 2321 | return 0; |
| 2322 | } |
| 2323 | |
| 2324 | /** |
| 2325 | * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state |
| 2326 | * @hw: pointer to the HW structure |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 2327 | * @active: true to enable LPLU, false to disable |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2328 | * |
| 2329 | * Sets the LPLU D3 state according to the active flag. When |
| 2330 | * activating LPLU this function also disables smart speed |
| 2331 | * and vice versa. LPLU will not be activated unless the |
| 2332 | * device autonegotiation advertisement meets standards of |
| 2333 | * either 10 or 10/100 or 10/100/1000 at all duplexes. |
| 2334 | * This is a function pointer entry point only called by |
| 2335 | * PHY setup routines. |
| 2336 | **/ |
| 2337 | static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active) |
| 2338 | { |
| 2339 | struct e1000_phy_info *phy = &hw->phy; |
| 2340 | u32 phy_ctrl; |
Bruce Allan | d7eb338 | 2012-02-08 02:55:14 +0000 | [diff] [blame] | 2341 | s32 ret_val = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2342 | u16 data; |
| 2343 | |
| 2344 | phy_ctrl = er32(PHY_CTRL); |
| 2345 | |
| 2346 | if (!active) { |
| 2347 | phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU; |
| 2348 | ew32(PHY_CTRL, phy_ctrl); |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2349 | |
| 2350 | if (phy->type != e1000_phy_igp_3) |
| 2351 | return 0; |
| 2352 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2353 | /* LPLU and SmartSpeed are mutually exclusive. LPLU is used |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2354 | * during Dx states where the power conservation is most |
| 2355 | * important. During driver activity we should enable |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2356 | * SmartSpeed, so performance is maintained. |
| 2357 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2358 | if (phy->smart_speed == e1000_smart_speed_on) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2359 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 2360 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2361 | if (ret_val) |
| 2362 | return ret_val; |
| 2363 | |
| 2364 | data |= IGP01E1000_PSCFR_SMART_SPEED; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2365 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 2366 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2367 | if (ret_val) |
| 2368 | return ret_val; |
| 2369 | } else if (phy->smart_speed == e1000_smart_speed_off) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2370 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 2371 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2372 | if (ret_val) |
| 2373 | return ret_val; |
| 2374 | |
| 2375 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2376 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 2377 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2378 | if (ret_val) |
| 2379 | return ret_val; |
| 2380 | } |
| 2381 | } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || |
| 2382 | (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || |
| 2383 | (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { |
| 2384 | phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU; |
| 2385 | ew32(PHY_CTRL, phy_ctrl); |
| 2386 | |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2387 | if (phy->type != e1000_phy_igp_3) |
| 2388 | return 0; |
| 2389 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2390 | /* Call gig speed drop workaround on LPLU before accessing |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2391 | * any PHY registers |
| 2392 | */ |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 2393 | if (hw->mac.type == e1000_ich8lan) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2394 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 2395 | |
| 2396 | /* When LPLU is enabled, we should disable SmartSpeed */ |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2397 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2398 | if (ret_val) |
| 2399 | return ret_val; |
| 2400 | |
| 2401 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2402 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2403 | } |
| 2404 | |
Bruce Allan | d7eb338 | 2012-02-08 02:55:14 +0000 | [diff] [blame] | 2405 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2406 | } |
| 2407 | |
| 2408 | /** |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2409 | * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1 |
| 2410 | * @hw: pointer to the HW structure |
| 2411 | * @bank: pointer to the variable that returns the active bank |
| 2412 | * |
| 2413 | * Reads signature byte from the NVM using the flash access registers. |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2414 | * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank. |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2415 | **/ |
| 2416 | static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank) |
| 2417 | { |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2418 | u32 eecd; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2419 | struct e1000_nvm_info *nvm = &hw->nvm; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2420 | u32 bank1_offset = nvm->flash_bank_size * sizeof(u16); |
| 2421 | u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2422 | u8 sig_byte = 0; |
Bruce Allan | f71dde6 | 2012-02-08 02:55:35 +0000 | [diff] [blame] | 2423 | s32 ret_val; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2424 | |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2425 | switch (hw->mac.type) { |
| 2426 | case e1000_ich8lan: |
| 2427 | case e1000_ich9lan: |
| 2428 | eecd = er32(EECD); |
| 2429 | if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) == |
| 2430 | E1000_EECD_SEC1VAL_VALID_MASK) { |
| 2431 | if (eecd & E1000_EECD_SEC1VAL) |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2432 | *bank = 1; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2433 | else |
| 2434 | *bank = 0; |
| 2435 | |
| 2436 | return 0; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2437 | } |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 2438 | e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n"); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2439 | /* fall-thru */ |
| 2440 | default: |
| 2441 | /* set bank to 0 in case flash read fails */ |
| 2442 | *bank = 0; |
| 2443 | |
| 2444 | /* Check bank 0 */ |
| 2445 | ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset, |
| 2446 | &sig_byte); |
| 2447 | if (ret_val) |
| 2448 | return ret_val; |
| 2449 | if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) == |
| 2450 | E1000_ICH_NVM_SIG_VALUE) { |
| 2451 | *bank = 0; |
| 2452 | return 0; |
| 2453 | } |
| 2454 | |
| 2455 | /* Check bank 1 */ |
| 2456 | ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset + |
| 2457 | bank1_offset, |
| 2458 | &sig_byte); |
| 2459 | if (ret_val) |
| 2460 | return ret_val; |
| 2461 | if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) == |
| 2462 | E1000_ICH_NVM_SIG_VALUE) { |
| 2463 | *bank = 1; |
| 2464 | return 0; |
| 2465 | } |
| 2466 | |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2467 | e_dbg("ERROR: No valid NVM bank present\n"); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2468 | return -E1000_ERR_NVM; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2469 | } |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2470 | } |
| 2471 | |
| 2472 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2473 | * e1000_read_nvm_ich8lan - Read word(s) from the NVM |
| 2474 | * @hw: pointer to the HW structure |
| 2475 | * @offset: The offset (in bytes) of the word(s) to read. |
| 2476 | * @words: Size of data to read in words |
| 2477 | * @data: Pointer to the word(s) to read at offset. |
| 2478 | * |
| 2479 | * Reads a word(s) from the NVM using the flash access registers. |
| 2480 | **/ |
| 2481 | static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, |
| 2482 | u16 *data) |
| 2483 | { |
| 2484 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 2485 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
| 2486 | u32 act_offset; |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2487 | s32 ret_val = 0; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2488 | u32 bank = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2489 | u16 i, word; |
| 2490 | |
| 2491 | if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || |
| 2492 | (words == 0)) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2493 | e_dbg("nvm parameter(s) out of bounds\n"); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 2494 | ret_val = -E1000_ERR_NVM; |
| 2495 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2496 | } |
| 2497 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2498 | nvm->ops.acquire(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2499 | |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2500 | ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2501 | if (ret_val) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2502 | e_dbg("Could not detect valid bank, assuming bank 0\n"); |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2503 | bank = 0; |
| 2504 | } |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2505 | |
| 2506 | act_offset = (bank) ? nvm->flash_bank_size : 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2507 | act_offset += offset; |
| 2508 | |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2509 | ret_val = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2510 | for (i = 0; i < words; i++) { |
Bruce Allan | b9e06f7 | 2011-07-22 06:21:41 +0000 | [diff] [blame] | 2511 | if (dev_spec->shadow_ram[offset+i].modified) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2512 | data[i] = dev_spec->shadow_ram[offset+i].value; |
| 2513 | } else { |
| 2514 | ret_val = e1000_read_flash_word_ich8lan(hw, |
| 2515 | act_offset + i, |
| 2516 | &word); |
| 2517 | if (ret_val) |
| 2518 | break; |
| 2519 | data[i] = word; |
| 2520 | } |
| 2521 | } |
| 2522 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2523 | nvm->ops.release(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2524 | |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2525 | out: |
| 2526 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2527 | e_dbg("NVM read error: %d\n", ret_val); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2528 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2529 | return ret_val; |
| 2530 | } |
| 2531 | |
| 2532 | /** |
| 2533 | * e1000_flash_cycle_init_ich8lan - Initialize flash |
| 2534 | * @hw: pointer to the HW structure |
| 2535 | * |
| 2536 | * This function does initial flash setup so that a new read/write/erase cycle |
| 2537 | * can be started. |
| 2538 | **/ |
| 2539 | static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw) |
| 2540 | { |
| 2541 | union ich8_hws_flash_status hsfsts; |
| 2542 | s32 ret_val = -E1000_ERR_NVM; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2543 | |
| 2544 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 2545 | |
| 2546 | /* Check if the flash descriptor is valid */ |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2547 | if (!hsfsts.hsf_status.fldesvalid) { |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 2548 | e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2549 | return -E1000_ERR_NVM; |
| 2550 | } |
| 2551 | |
| 2552 | /* Clear FCERR and DAEL in hw status by writing 1 */ |
| 2553 | hsfsts.hsf_status.flcerr = 1; |
| 2554 | hsfsts.hsf_status.dael = 1; |
| 2555 | |
| 2556 | ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 2557 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2558 | /* Either we should have a hardware SPI cycle in progress |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2559 | * bit to check against, in order to start a new cycle or |
| 2560 | * FDONE bit should be changed in the hardware so that it |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 2561 | * is 1 after hardware reset, which can then be used as an |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2562 | * indication whether a cycle is in progress or has been |
| 2563 | * completed. |
| 2564 | */ |
| 2565 | |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2566 | if (!hsfsts.hsf_status.flcinprog) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2567 | /* There is no cycle running at present, |
Bruce Allan | 5ff5b66 | 2009-12-01 15:51:11 +0000 | [diff] [blame] | 2568 | * so we can start a cycle. |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2569 | * Begin by setting Flash Cycle Done. |
| 2570 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2571 | hsfsts.hsf_status.flcdone = 1; |
| 2572 | ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 2573 | ret_val = 0; |
| 2574 | } else { |
Bruce Allan | f71dde6 | 2012-02-08 02:55:35 +0000 | [diff] [blame] | 2575 | s32 i; |
Bruce Allan | 90da066 | 2011-01-06 07:02:53 +0000 | [diff] [blame] | 2576 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2577 | /* Otherwise poll for sometime so the current |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2578 | * cycle has a chance to end before giving up. |
| 2579 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2580 | for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) { |
Bruce Allan | c8243ee | 2011-12-17 08:32:57 +0000 | [diff] [blame] | 2581 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2582 | if (!hsfsts.hsf_status.flcinprog) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2583 | ret_val = 0; |
| 2584 | break; |
| 2585 | } |
| 2586 | udelay(1); |
| 2587 | } |
Bruce Allan | 9e2d765 | 2012-01-31 06:37:27 +0000 | [diff] [blame] | 2588 | if (!ret_val) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2589 | /* Successful in waiting for previous cycle to timeout, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2590 | * now set the Flash Cycle Done. |
| 2591 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2592 | hsfsts.hsf_status.flcdone = 1; |
| 2593 | ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 2594 | } else { |
Joe Perches | 2c73e1f | 2010-03-26 20:16:59 +0000 | [diff] [blame] | 2595 | e_dbg("Flash controller busy, cannot get access\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2596 | } |
| 2597 | } |
| 2598 | |
| 2599 | return ret_val; |
| 2600 | } |
| 2601 | |
| 2602 | /** |
| 2603 | * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase) |
| 2604 | * @hw: pointer to the HW structure |
| 2605 | * @timeout: maximum time to wait for completion |
| 2606 | * |
| 2607 | * This function starts a flash cycle and waits for its completion. |
| 2608 | **/ |
| 2609 | static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout) |
| 2610 | { |
| 2611 | union ich8_hws_flash_ctrl hsflctl; |
| 2612 | union ich8_hws_flash_status hsfsts; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2613 | u32 i = 0; |
| 2614 | |
| 2615 | /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */ |
| 2616 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 2617 | hsflctl.hsf_ctrl.flcgo = 1; |
| 2618 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 2619 | |
| 2620 | /* wait till FDONE bit is set to 1 */ |
| 2621 | do { |
| 2622 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2623 | if (hsfsts.hsf_status.flcdone) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2624 | break; |
| 2625 | udelay(1); |
| 2626 | } while (i++ < timeout); |
| 2627 | |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2628 | if (hsfsts.hsf_status.flcdone && !hsfsts.hsf_status.flcerr) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2629 | return 0; |
| 2630 | |
Bruce Allan | 55920b5 | 2012-02-08 02:55:25 +0000 | [diff] [blame] | 2631 | return -E1000_ERR_NVM; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2632 | } |
| 2633 | |
| 2634 | /** |
| 2635 | * e1000_read_flash_word_ich8lan - Read word from flash |
| 2636 | * @hw: pointer to the HW structure |
| 2637 | * @offset: offset to data location |
| 2638 | * @data: pointer to the location for storing the data |
| 2639 | * |
| 2640 | * Reads the flash word at offset into data. Offset is converted |
| 2641 | * to bytes before read. |
| 2642 | **/ |
| 2643 | static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset, |
| 2644 | u16 *data) |
| 2645 | { |
| 2646 | /* Must convert offset into bytes. */ |
| 2647 | offset <<= 1; |
| 2648 | |
| 2649 | return e1000_read_flash_data_ich8lan(hw, offset, 2, data); |
| 2650 | } |
| 2651 | |
| 2652 | /** |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2653 | * e1000_read_flash_byte_ich8lan - Read byte from flash |
| 2654 | * @hw: pointer to the HW structure |
| 2655 | * @offset: The offset of the byte to read. |
| 2656 | * @data: Pointer to a byte to store the value read. |
| 2657 | * |
| 2658 | * Reads a single byte from the NVM using the flash access registers. |
| 2659 | **/ |
| 2660 | static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, |
| 2661 | u8 *data) |
| 2662 | { |
| 2663 | s32 ret_val; |
| 2664 | u16 word = 0; |
| 2665 | |
| 2666 | ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word); |
| 2667 | if (ret_val) |
| 2668 | return ret_val; |
| 2669 | |
| 2670 | *data = (u8)word; |
| 2671 | |
| 2672 | return 0; |
| 2673 | } |
| 2674 | |
| 2675 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2676 | * e1000_read_flash_data_ich8lan - Read byte or word from NVM |
| 2677 | * @hw: pointer to the HW structure |
| 2678 | * @offset: The offset (in bytes) of the byte or word to read. |
| 2679 | * @size: Size of data to read, 1=byte 2=word |
| 2680 | * @data: Pointer to the word to store the value read. |
| 2681 | * |
| 2682 | * Reads a byte or word from the NVM using the flash access registers. |
| 2683 | **/ |
| 2684 | static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, |
| 2685 | u8 size, u16 *data) |
| 2686 | { |
| 2687 | union ich8_hws_flash_status hsfsts; |
| 2688 | union ich8_hws_flash_ctrl hsflctl; |
| 2689 | u32 flash_linear_addr; |
| 2690 | u32 flash_data = 0; |
| 2691 | s32 ret_val = -E1000_ERR_NVM; |
| 2692 | u8 count = 0; |
| 2693 | |
| 2694 | if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK) |
| 2695 | return -E1000_ERR_NVM; |
| 2696 | |
| 2697 | flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) + |
| 2698 | hw->nvm.flash_base_addr; |
| 2699 | |
| 2700 | do { |
| 2701 | udelay(1); |
| 2702 | /* Steps */ |
| 2703 | ret_val = e1000_flash_cycle_init_ich8lan(hw); |
Bruce Allan | 9e2d765 | 2012-01-31 06:37:27 +0000 | [diff] [blame] | 2704 | if (ret_val) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2705 | break; |
| 2706 | |
| 2707 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 2708 | /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ |
| 2709 | hsflctl.hsf_ctrl.fldbcount = size - 1; |
| 2710 | hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ; |
| 2711 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 2712 | |
| 2713 | ew32flash(ICH_FLASH_FADDR, flash_linear_addr); |
| 2714 | |
| 2715 | ret_val = e1000_flash_cycle_ich8lan(hw, |
| 2716 | ICH_FLASH_READ_COMMAND_TIMEOUT); |
| 2717 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2718 | /* Check if FCERR is set to 1, if set to 1, clear it |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2719 | * and try the whole sequence a few more times, else |
| 2720 | * read in (shift in) the Flash Data0, the order is |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2721 | * least significant byte first msb to lsb |
| 2722 | */ |
Bruce Allan | 9e2d765 | 2012-01-31 06:37:27 +0000 | [diff] [blame] | 2723 | if (!ret_val) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2724 | flash_data = er32flash(ICH_FLASH_FDATA0); |
Bruce Allan | b1cdfea | 2010-12-11 05:53:47 +0000 | [diff] [blame] | 2725 | if (size == 1) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2726 | *data = (u8)(flash_data & 0x000000FF); |
Bruce Allan | b1cdfea | 2010-12-11 05:53:47 +0000 | [diff] [blame] | 2727 | else if (size == 2) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2728 | *data = (u16)(flash_data & 0x0000FFFF); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2729 | break; |
| 2730 | } else { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2731 | /* If we've gotten here, then things are probably |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2732 | * completely hosed, but if the error condition is |
| 2733 | * detected, it won't hurt to give it another try... |
| 2734 | * ICH_FLASH_CYCLE_REPEAT_COUNT times. |
| 2735 | */ |
| 2736 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2737 | if (hsfsts.hsf_status.flcerr) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2738 | /* Repeat for some time before giving up. */ |
| 2739 | continue; |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 2740 | } else if (!hsfsts.hsf_status.flcdone) { |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 2741 | e_dbg("Timeout error - flash cycle did not complete.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2742 | break; |
| 2743 | } |
| 2744 | } |
| 2745 | } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); |
| 2746 | |
| 2747 | return ret_val; |
| 2748 | } |
| 2749 | |
| 2750 | /** |
| 2751 | * e1000_write_nvm_ich8lan - Write word(s) to the NVM |
| 2752 | * @hw: pointer to the HW structure |
| 2753 | * @offset: The offset (in bytes) of the word(s) to write. |
| 2754 | * @words: Size of data to write in words |
| 2755 | * @data: Pointer to the word(s) to write at offset. |
| 2756 | * |
| 2757 | * Writes a byte or word to the NVM using the flash access registers. |
| 2758 | **/ |
| 2759 | static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, |
| 2760 | u16 *data) |
| 2761 | { |
| 2762 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 2763 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2764 | u16 i; |
| 2765 | |
| 2766 | if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || |
| 2767 | (words == 0)) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2768 | e_dbg("nvm parameter(s) out of bounds\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2769 | return -E1000_ERR_NVM; |
| 2770 | } |
| 2771 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2772 | nvm->ops.acquire(hw); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 2773 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2774 | for (i = 0; i < words; i++) { |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 2775 | dev_spec->shadow_ram[offset+i].modified = true; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2776 | dev_spec->shadow_ram[offset+i].value = data[i]; |
| 2777 | } |
| 2778 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2779 | nvm->ops.release(hw); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 2780 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2781 | return 0; |
| 2782 | } |
| 2783 | |
| 2784 | /** |
| 2785 | * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM |
| 2786 | * @hw: pointer to the HW structure |
| 2787 | * |
| 2788 | * The NVM checksum is updated by calling the generic update_nvm_checksum, |
| 2789 | * which writes the checksum to the shadow ram. The changes in the shadow |
| 2790 | * ram are then committed to the EEPROM by processing each bank at a time |
| 2791 | * checking for the modified bit and writing only the pending changes. |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 2792 | * After a successful commit, the shadow ram is cleared and is ready for |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2793 | * future writes. |
| 2794 | **/ |
| 2795 | static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) |
| 2796 | { |
| 2797 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 2798 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2799 | u32 i, act_offset, new_bank_offset, old_bank_offset, bank; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2800 | s32 ret_val; |
| 2801 | u16 data; |
| 2802 | |
| 2803 | ret_val = e1000e_update_nvm_checksum_generic(hw); |
| 2804 | if (ret_val) |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2805 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2806 | |
| 2807 | if (nvm->type != e1000_nvm_flash_sw) |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2808 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2809 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2810 | nvm->ops.acquire(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2811 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2812 | /* We're writing to the opposite bank so if we're on bank 1, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2813 | * write to bank 0 etc. We also need to erase the segment that |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2814 | * is going to be written |
| 2815 | */ |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2816 | ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2817 | if (ret_val) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2818 | e_dbg("Could not detect valid bank, assuming bank 0\n"); |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2819 | bank = 0; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2820 | } |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 2821 | |
| 2822 | if (bank == 0) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2823 | new_bank_offset = nvm->flash_bank_size; |
| 2824 | old_bank_offset = 0; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2825 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 1); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2826 | if (ret_val) |
| 2827 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2828 | } else { |
| 2829 | old_bank_offset = nvm->flash_bank_size; |
| 2830 | new_bank_offset = 0; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2831 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 0); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2832 | if (ret_val) |
| 2833 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2834 | } |
| 2835 | |
| 2836 | for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2837 | /* Determine whether to write the value stored |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2838 | * in the other NVM bank or a modified value stored |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2839 | * in the shadow RAM |
| 2840 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2841 | if (dev_spec->shadow_ram[i].modified) { |
| 2842 | data = dev_spec->shadow_ram[i].value; |
| 2843 | } else { |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2844 | ret_val = e1000_read_flash_word_ich8lan(hw, i + |
| 2845 | old_bank_offset, |
| 2846 | &data); |
| 2847 | if (ret_val) |
| 2848 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2849 | } |
| 2850 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2851 | /* If the word is 0x13, then make sure the signature bits |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2852 | * (15:14) are 11b until the commit has completed. |
| 2853 | * This will allow us to write 10b which indicates the |
| 2854 | * signature is valid. We want to do this after the write |
| 2855 | * has completed so that we don't mark the segment valid |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2856 | * while the write is still in progress |
| 2857 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2858 | if (i == E1000_ICH_NVM_SIG_WORD) |
| 2859 | data |= E1000_ICH_NVM_SIG_MASK; |
| 2860 | |
| 2861 | /* Convert offset to bytes. */ |
| 2862 | act_offset = (i + new_bank_offset) << 1; |
| 2863 | |
| 2864 | udelay(100); |
| 2865 | /* Write the bytes to the new bank. */ |
| 2866 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, |
| 2867 | act_offset, |
| 2868 | (u8)data); |
| 2869 | if (ret_val) |
| 2870 | break; |
| 2871 | |
| 2872 | udelay(100); |
| 2873 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, |
| 2874 | act_offset + 1, |
| 2875 | (u8)(data >> 8)); |
| 2876 | if (ret_val) |
| 2877 | break; |
| 2878 | } |
| 2879 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2880 | /* Don't bother writing the segment valid bits if sector |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2881 | * programming failed. |
| 2882 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2883 | if (ret_val) { |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 2884 | /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2885 | e_dbg("Flash commit failed.\n"); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2886 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2887 | } |
| 2888 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2889 | /* Finally validate the new segment by setting bit 15:14 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2890 | * to 10b in word 0x13 , this can be done without an |
| 2891 | * erase as well since these bits are 11 to start with |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2892 | * and we need to change bit 14 to 0b |
| 2893 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2894 | act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2895 | ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2896 | if (ret_val) |
| 2897 | goto release; |
| 2898 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2899 | data &= 0xBFFF; |
| 2900 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, |
| 2901 | act_offset * 2 + 1, |
| 2902 | (u8)(data >> 8)); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2903 | if (ret_val) |
| 2904 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2905 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2906 | /* And invalidate the previously valid segment by setting |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2907 | * its signature word (0x13) high_byte to 0b. This can be |
| 2908 | * done without an erase because flash erase sets all bits |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2909 | * to 1's. We can write 1's to 0's without an erase |
| 2910 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2911 | act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1; |
| 2912 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2913 | if (ret_val) |
| 2914 | goto release; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2915 | |
| 2916 | /* Great! Everything worked, we can now clear the cached entries. */ |
| 2917 | for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) { |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 2918 | dev_spec->shadow_ram[i].modified = false; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2919 | dev_spec->shadow_ram[i].value = 0xFFFF; |
| 2920 | } |
| 2921 | |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2922 | release: |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 2923 | nvm->ops.release(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2924 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 2925 | /* Reload the EEPROM, or else modifications will not appear |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2926 | * until after the next adapter reset. |
| 2927 | */ |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2928 | if (!ret_val) { |
Bruce Allan | e85e363 | 2012-02-22 09:03:14 +0000 | [diff] [blame] | 2929 | nvm->ops.reload(hw); |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 2930 | usleep_range(10000, 20000); |
Bruce Allan | 9c5e209 | 2010-05-10 15:00:31 +0000 | [diff] [blame] | 2931 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2932 | |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2933 | out: |
| 2934 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 2935 | e_dbg("NVM update error: %d\n", ret_val); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 2936 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2937 | return ret_val; |
| 2938 | } |
| 2939 | |
| 2940 | /** |
| 2941 | * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum |
| 2942 | * @hw: pointer to the HW structure |
| 2943 | * |
| 2944 | * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19. |
| 2945 | * If the bit is 0, that the EEPROM had been modified, but the checksum was not |
| 2946 | * calculated, in which case we need to calculate the checksum and set bit 6. |
| 2947 | **/ |
| 2948 | static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw) |
| 2949 | { |
| 2950 | s32 ret_val; |
| 2951 | u16 data; |
Bruce Allan | 1cc7a3a | 2013-01-09 08:15:42 +0000 | [diff] [blame^] | 2952 | u16 word; |
| 2953 | u16 valid_csum_mask; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2954 | |
Bruce Allan | 1cc7a3a | 2013-01-09 08:15:42 +0000 | [diff] [blame^] | 2955 | /* Read NVM and check Invalid Image CSUM bit. If this bit is 0, |
| 2956 | * the checksum needs to be fixed. This bit is an indication that |
| 2957 | * the NVM was prepared by OEM software and did not calculate |
| 2958 | * the checksum...a likely scenario. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2959 | */ |
Bruce Allan | 1cc7a3a | 2013-01-09 08:15:42 +0000 | [diff] [blame^] | 2960 | switch (hw->mac.type) { |
| 2961 | case e1000_pch_lpt: |
| 2962 | word = NVM_COMPAT; |
| 2963 | valid_csum_mask = NVM_COMPAT_VALID_CSUM; |
| 2964 | break; |
| 2965 | default: |
| 2966 | word = NVM_FUTURE_INIT_WORD1; |
| 2967 | valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM; |
| 2968 | break; |
| 2969 | } |
| 2970 | |
| 2971 | ret_val = e1000_read_nvm(hw, word, 1, &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2972 | if (ret_val) |
| 2973 | return ret_val; |
| 2974 | |
Bruce Allan | 1cc7a3a | 2013-01-09 08:15:42 +0000 | [diff] [blame^] | 2975 | if (!(data & valid_csum_mask)) { |
| 2976 | data |= valid_csum_mask; |
| 2977 | ret_val = e1000_write_nvm(hw, word, 1, &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2978 | if (ret_val) |
| 2979 | return ret_val; |
| 2980 | ret_val = e1000e_update_nvm_checksum(hw); |
| 2981 | if (ret_val) |
| 2982 | return ret_val; |
| 2983 | } |
| 2984 | |
| 2985 | return e1000e_validate_nvm_checksum_generic(hw); |
| 2986 | } |
| 2987 | |
| 2988 | /** |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 2989 | * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only |
| 2990 | * @hw: pointer to the HW structure |
| 2991 | * |
| 2992 | * To prevent malicious write/erase of the NVM, set it to be read-only |
| 2993 | * so that the hardware ignores all write/erase cycles of the NVM via |
| 2994 | * the flash control registers. The shadow-ram copy of the NVM will |
| 2995 | * still be updated, however any updates to this copy will not stick |
| 2996 | * across driver reloads. |
| 2997 | **/ |
| 2998 | void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw) |
| 2999 | { |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 3000 | struct e1000_nvm_info *nvm = &hw->nvm; |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3001 | union ich8_flash_protected_range pr0; |
| 3002 | union ich8_hws_flash_status hsfsts; |
| 3003 | u32 gfpreg; |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3004 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 3005 | nvm->ops.acquire(hw); |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3006 | |
| 3007 | gfpreg = er32flash(ICH_FLASH_GFPREG); |
| 3008 | |
| 3009 | /* Write-protect GbE Sector of NVM */ |
| 3010 | pr0.regval = er32flash(ICH_FLASH_PR0); |
| 3011 | pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK; |
| 3012 | pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK); |
| 3013 | pr0.range.wpe = true; |
| 3014 | ew32flash(ICH_FLASH_PR0, pr0.regval); |
| 3015 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3016 | /* Lock down a subset of GbE Flash Control Registers, e.g. |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3017 | * PR0 to prevent the write-protection from being lifted. |
| 3018 | * Once FLOCKDN is set, the registers protected by it cannot |
| 3019 | * be written until FLOCKDN is cleared by a hardware reset. |
| 3020 | */ |
| 3021 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 3022 | hsfsts.hsf_status.flockdn = true; |
| 3023 | ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 3024 | |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 3025 | nvm->ops.release(hw); |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 3026 | } |
| 3027 | |
| 3028 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3029 | * e1000_write_flash_data_ich8lan - Writes bytes to the NVM |
| 3030 | * @hw: pointer to the HW structure |
| 3031 | * @offset: The offset (in bytes) of the byte/word to read. |
| 3032 | * @size: Size of data to read, 1=byte 2=word |
| 3033 | * @data: The byte(s) to write to the NVM. |
| 3034 | * |
| 3035 | * Writes one/two bytes to the NVM using the flash access registers. |
| 3036 | **/ |
| 3037 | static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, |
| 3038 | u8 size, u16 data) |
| 3039 | { |
| 3040 | union ich8_hws_flash_status hsfsts; |
| 3041 | union ich8_hws_flash_ctrl hsflctl; |
| 3042 | u32 flash_linear_addr; |
| 3043 | u32 flash_data = 0; |
| 3044 | s32 ret_val; |
| 3045 | u8 count = 0; |
| 3046 | |
| 3047 | if (size < 1 || size > 2 || data > size * 0xff || |
| 3048 | offset > ICH_FLASH_LINEAR_ADDR_MASK) |
| 3049 | return -E1000_ERR_NVM; |
| 3050 | |
| 3051 | flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) + |
| 3052 | hw->nvm.flash_base_addr; |
| 3053 | |
| 3054 | do { |
| 3055 | udelay(1); |
| 3056 | /* Steps */ |
| 3057 | ret_val = e1000_flash_cycle_init_ich8lan(hw); |
| 3058 | if (ret_val) |
| 3059 | break; |
| 3060 | |
| 3061 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 3062 | /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ |
| 3063 | hsflctl.hsf_ctrl.fldbcount = size -1; |
| 3064 | hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE; |
| 3065 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 3066 | |
| 3067 | ew32flash(ICH_FLASH_FADDR, flash_linear_addr); |
| 3068 | |
| 3069 | if (size == 1) |
| 3070 | flash_data = (u32)data & 0x00FF; |
| 3071 | else |
| 3072 | flash_data = (u32)data; |
| 3073 | |
| 3074 | ew32flash(ICH_FLASH_FDATA0, flash_data); |
| 3075 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3076 | /* check if FCERR is set to 1 , if set to 1, clear it |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3077 | * and try the whole sequence a few more times else done |
| 3078 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3079 | ret_val = e1000_flash_cycle_ich8lan(hw, |
| 3080 | ICH_FLASH_WRITE_COMMAND_TIMEOUT); |
| 3081 | if (!ret_val) |
| 3082 | break; |
| 3083 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3084 | /* If we're here, then things are most likely |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3085 | * completely hosed, but if the error condition |
| 3086 | * is detected, it won't hurt to give it another |
| 3087 | * try...ICH_FLASH_CYCLE_REPEAT_COUNT times. |
| 3088 | */ |
| 3089 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 3090 | if (hsfsts.hsf_status.flcerr) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3091 | /* Repeat for some time before giving up. */ |
| 3092 | continue; |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 3093 | if (!hsfsts.hsf_status.flcdone) { |
Bruce Allan | 434f139 | 2011-12-16 00:46:54 +0000 | [diff] [blame] | 3094 | e_dbg("Timeout error - flash cycle did not complete.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3095 | break; |
| 3096 | } |
| 3097 | } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); |
| 3098 | |
| 3099 | return ret_val; |
| 3100 | } |
| 3101 | |
| 3102 | /** |
| 3103 | * e1000_write_flash_byte_ich8lan - Write a single byte to NVM |
| 3104 | * @hw: pointer to the HW structure |
| 3105 | * @offset: The index of the byte to read. |
| 3106 | * @data: The byte to write to the NVM. |
| 3107 | * |
| 3108 | * Writes a single byte to the NVM using the flash access registers. |
| 3109 | **/ |
| 3110 | static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, |
| 3111 | u8 data) |
| 3112 | { |
| 3113 | u16 word = (u16)data; |
| 3114 | |
| 3115 | return e1000_write_flash_data_ich8lan(hw, offset, 1, word); |
| 3116 | } |
| 3117 | |
| 3118 | /** |
| 3119 | * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM |
| 3120 | * @hw: pointer to the HW structure |
| 3121 | * @offset: The offset of the byte to write. |
| 3122 | * @byte: The byte to write to the NVM. |
| 3123 | * |
| 3124 | * Writes a single byte to the NVM using the flash access registers. |
| 3125 | * Goes through a retry algorithm before giving up. |
| 3126 | **/ |
| 3127 | static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw, |
| 3128 | u32 offset, u8 byte) |
| 3129 | { |
| 3130 | s32 ret_val; |
| 3131 | u16 program_retries; |
| 3132 | |
| 3133 | ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte); |
| 3134 | if (!ret_val) |
| 3135 | return ret_val; |
| 3136 | |
| 3137 | for (program_retries = 0; program_retries < 100; program_retries++) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3138 | e_dbg("Retrying Byte %2.2X at offset %u\n", byte, offset); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3139 | udelay(100); |
| 3140 | ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte); |
| 3141 | if (!ret_val) |
| 3142 | break; |
| 3143 | } |
| 3144 | if (program_retries == 100) |
| 3145 | return -E1000_ERR_NVM; |
| 3146 | |
| 3147 | return 0; |
| 3148 | } |
| 3149 | |
| 3150 | /** |
| 3151 | * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM |
| 3152 | * @hw: pointer to the HW structure |
| 3153 | * @bank: 0 for first bank, 1 for second bank, etc. |
| 3154 | * |
| 3155 | * Erases the bank specified. Each bank is a 4k block. Banks are 0 based. |
| 3156 | * bank N is 4096 * N + flash_reg_addr. |
| 3157 | **/ |
| 3158 | static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank) |
| 3159 | { |
| 3160 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 3161 | union ich8_hws_flash_status hsfsts; |
| 3162 | union ich8_hws_flash_ctrl hsflctl; |
| 3163 | u32 flash_linear_addr; |
| 3164 | /* bank size is in 16bit words - adjust to bytes */ |
| 3165 | u32 flash_bank_size = nvm->flash_bank_size * 2; |
| 3166 | s32 ret_val; |
| 3167 | s32 count = 0; |
Bruce Allan | a708dd8 | 2009-11-20 23:28:37 +0000 | [diff] [blame] | 3168 | s32 j, iteration, sector_size; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3169 | |
| 3170 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 3171 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3172 | /* Determine HW Sector size: Read BERASE bits of hw flash status |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3173 | * register |
| 3174 | * 00: The Hw sector is 256 bytes, hence we need to erase 16 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3175 | * consecutive sectors. The start index for the nth Hw sector |
| 3176 | * can be calculated as = bank * 4096 + n * 256 |
| 3177 | * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector. |
| 3178 | * The start index for the nth Hw sector can be calculated |
| 3179 | * as = bank * 4096 |
| 3180 | * 10: The Hw sector is 8K bytes, nth sector = bank * 8192 |
| 3181 | * (ich9 only, otherwise error condition) |
| 3182 | * 11: The Hw sector is 64K bytes, nth sector = bank * 65536 |
| 3183 | */ |
| 3184 | switch (hsfsts.hsf_status.berasesz) { |
| 3185 | case 0: |
| 3186 | /* Hw sector size 256 */ |
| 3187 | sector_size = ICH_FLASH_SEG_SIZE_256; |
| 3188 | iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256; |
| 3189 | break; |
| 3190 | case 1: |
| 3191 | sector_size = ICH_FLASH_SEG_SIZE_4K; |
Bruce Allan | 28c9195 | 2009-07-01 13:28:32 +0000 | [diff] [blame] | 3192 | iteration = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3193 | break; |
| 3194 | case 2: |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 3195 | sector_size = ICH_FLASH_SEG_SIZE_8K; |
| 3196 | iteration = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3197 | break; |
| 3198 | case 3: |
| 3199 | sector_size = ICH_FLASH_SEG_SIZE_64K; |
Bruce Allan | 28c9195 | 2009-07-01 13:28:32 +0000 | [diff] [blame] | 3200 | iteration = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3201 | break; |
| 3202 | default: |
| 3203 | return -E1000_ERR_NVM; |
| 3204 | } |
| 3205 | |
| 3206 | /* Start with the base address, then add the sector offset. */ |
| 3207 | flash_linear_addr = hw->nvm.flash_base_addr; |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 3208 | flash_linear_addr += (bank) ? flash_bank_size : 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3209 | |
| 3210 | for (j = 0; j < iteration ; j++) { |
| 3211 | do { |
| 3212 | /* Steps */ |
| 3213 | ret_val = e1000_flash_cycle_init_ich8lan(hw); |
| 3214 | if (ret_val) |
| 3215 | return ret_val; |
| 3216 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3217 | /* Write a value 11 (block Erase) in Flash |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3218 | * Cycle field in hw flash control |
| 3219 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3220 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 3221 | hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE; |
| 3222 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 3223 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3224 | /* Write the last 24 bits of an index within the |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3225 | * block into Flash Linear address field in Flash |
| 3226 | * Address. |
| 3227 | */ |
| 3228 | flash_linear_addr += (j * sector_size); |
| 3229 | ew32flash(ICH_FLASH_FADDR, flash_linear_addr); |
| 3230 | |
| 3231 | ret_val = e1000_flash_cycle_ich8lan(hw, |
| 3232 | ICH_FLASH_ERASE_COMMAND_TIMEOUT); |
Bruce Allan | 9e2d765 | 2012-01-31 06:37:27 +0000 | [diff] [blame] | 3233 | if (!ret_val) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3234 | break; |
| 3235 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3236 | /* Check if FCERR is set to 1. If 1, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3237 | * clear it and try the whole sequence |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3238 | * a few more times else Done |
| 3239 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3240 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 3241 | if (hsfsts.hsf_status.flcerr) |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3242 | /* repeat for some time before giving up */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3243 | continue; |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 3244 | else if (!hsfsts.hsf_status.flcdone) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3245 | return ret_val; |
| 3246 | } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT); |
| 3247 | } |
| 3248 | |
| 3249 | return 0; |
| 3250 | } |
| 3251 | |
| 3252 | /** |
| 3253 | * e1000_valid_led_default_ich8lan - Set the default LED settings |
| 3254 | * @hw: pointer to the HW structure |
| 3255 | * @data: Pointer to the LED settings |
| 3256 | * |
| 3257 | * Reads the LED default settings from the NVM to data. If the NVM LED |
| 3258 | * settings is all 0's or F's, set the LED default to a valid LED default |
| 3259 | * setting. |
| 3260 | **/ |
| 3261 | static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data) |
| 3262 | { |
| 3263 | s32 ret_val; |
| 3264 | |
| 3265 | ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data); |
| 3266 | if (ret_val) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3267 | e_dbg("NVM Read Error\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3268 | return ret_val; |
| 3269 | } |
| 3270 | |
| 3271 | if (*data == ID_LED_RESERVED_0000 || |
| 3272 | *data == ID_LED_RESERVED_FFFF) |
| 3273 | *data = ID_LED_DEFAULT_ICH8LAN; |
| 3274 | |
| 3275 | return 0; |
| 3276 | } |
| 3277 | |
| 3278 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3279 | * e1000_id_led_init_pchlan - store LED configurations |
| 3280 | * @hw: pointer to the HW structure |
| 3281 | * |
| 3282 | * PCH does not control LEDs via the LEDCTL register, rather it uses |
| 3283 | * the PHY LED configuration register. |
| 3284 | * |
| 3285 | * PCH also does not have an "always on" or "always off" mode which |
| 3286 | * complicates the ID feature. Instead of using the "on" mode to indicate |
Bruce Allan | d1964eb | 2012-02-22 09:02:21 +0000 | [diff] [blame] | 3287 | * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()), |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3288 | * use "link_up" mode. The LEDs will still ID on request if there is no |
| 3289 | * link based on logic in e1000_led_[on|off]_pchlan(). |
| 3290 | **/ |
| 3291 | static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw) |
| 3292 | { |
| 3293 | struct e1000_mac_info *mac = &hw->mac; |
| 3294 | s32 ret_val; |
| 3295 | const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP; |
| 3296 | const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT; |
| 3297 | u16 data, i, temp, shift; |
| 3298 | |
| 3299 | /* Get default ID LED modes */ |
| 3300 | ret_val = hw->nvm.ops.valid_led_default(hw, &data); |
| 3301 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3302 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3303 | |
| 3304 | mac->ledctl_default = er32(LEDCTL); |
| 3305 | mac->ledctl_mode1 = mac->ledctl_default; |
| 3306 | mac->ledctl_mode2 = mac->ledctl_default; |
| 3307 | |
| 3308 | for (i = 0; i < 4; i++) { |
| 3309 | temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK; |
| 3310 | shift = (i * 5); |
| 3311 | switch (temp) { |
| 3312 | case ID_LED_ON1_DEF2: |
| 3313 | case ID_LED_ON1_ON2: |
| 3314 | case ID_LED_ON1_OFF2: |
| 3315 | mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift); |
| 3316 | mac->ledctl_mode1 |= (ledctl_on << shift); |
| 3317 | break; |
| 3318 | case ID_LED_OFF1_DEF2: |
| 3319 | case ID_LED_OFF1_ON2: |
| 3320 | case ID_LED_OFF1_OFF2: |
| 3321 | mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift); |
| 3322 | mac->ledctl_mode1 |= (ledctl_off << shift); |
| 3323 | break; |
| 3324 | default: |
| 3325 | /* Do nothing */ |
| 3326 | break; |
| 3327 | } |
| 3328 | switch (temp) { |
| 3329 | case ID_LED_DEF1_ON2: |
| 3330 | case ID_LED_ON1_ON2: |
| 3331 | case ID_LED_OFF1_ON2: |
| 3332 | mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift); |
| 3333 | mac->ledctl_mode2 |= (ledctl_on << shift); |
| 3334 | break; |
| 3335 | case ID_LED_DEF1_OFF2: |
| 3336 | case ID_LED_ON1_OFF2: |
| 3337 | case ID_LED_OFF1_OFF2: |
| 3338 | mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift); |
| 3339 | mac->ledctl_mode2 |= (ledctl_off << shift); |
| 3340 | break; |
| 3341 | default: |
| 3342 | /* Do nothing */ |
| 3343 | break; |
| 3344 | } |
| 3345 | } |
| 3346 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3347 | return 0; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3348 | } |
| 3349 | |
| 3350 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3351 | * e1000_get_bus_info_ich8lan - Get/Set the bus type and width |
| 3352 | * @hw: pointer to the HW structure |
| 3353 | * |
| 3354 | * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability |
| 3355 | * register, so the the bus width is hard coded. |
| 3356 | **/ |
| 3357 | static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw) |
| 3358 | { |
| 3359 | struct e1000_bus_info *bus = &hw->bus; |
| 3360 | s32 ret_val; |
| 3361 | |
| 3362 | ret_val = e1000e_get_bus_info_pcie(hw); |
| 3363 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3364 | /* ICH devices are "PCI Express"-ish. They have |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3365 | * a configuration space, but do not contain |
| 3366 | * PCI Express Capability registers, so bus width |
| 3367 | * must be hardcoded. |
| 3368 | */ |
| 3369 | if (bus->width == e1000_bus_width_unknown) |
| 3370 | bus->width = e1000_bus_width_pcie_x1; |
| 3371 | |
| 3372 | return ret_val; |
| 3373 | } |
| 3374 | |
| 3375 | /** |
| 3376 | * e1000_reset_hw_ich8lan - Reset the hardware |
| 3377 | * @hw: pointer to the HW structure |
| 3378 | * |
| 3379 | * Does a full reset of the hardware which includes a reset of the PHY and |
| 3380 | * MAC. |
| 3381 | **/ |
| 3382 | static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) |
| 3383 | { |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 3384 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3385 | u16 kum_cfg; |
| 3386 | u32 ctrl, reg; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3387 | s32 ret_val; |
| 3388 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3389 | /* Prevent the PCI-E bus from sticking if there is no TLP connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3390 | * on the last TLP read/write transaction when MAC is reset. |
| 3391 | */ |
| 3392 | ret_val = e1000e_disable_pcie_master(hw); |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3393 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3394 | e_dbg("PCI-E Master disable polling has failed.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3395 | |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3396 | e_dbg("Masking off all interrupts\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3397 | ew32(IMC, 0xffffffff); |
| 3398 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3399 | /* Disable the Transmit and Receive units. Then delay to allow |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3400 | * any pending transactions to complete before we hit the MAC |
| 3401 | * with the global reset. |
| 3402 | */ |
| 3403 | ew32(RCTL, 0); |
| 3404 | ew32(TCTL, E1000_TCTL_PSP); |
| 3405 | e1e_flush(); |
| 3406 | |
Bruce Allan | 1bba438 | 2011-03-19 00:27:20 +0000 | [diff] [blame] | 3407 | usleep_range(10000, 20000); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3408 | |
| 3409 | /* Workaround for ICH8 bit corruption issue in FIFO memory */ |
| 3410 | if (hw->mac.type == e1000_ich8lan) { |
| 3411 | /* Set Tx and Rx buffer allocation to 8k apiece. */ |
| 3412 | ew32(PBA, E1000_PBA_8K); |
| 3413 | /* Set Packet Buffer Size to 16k. */ |
| 3414 | ew32(PBS, E1000_PBS_16K); |
| 3415 | } |
| 3416 | |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 3417 | if (hw->mac.type == e1000_pchlan) { |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3418 | /* Save the NVM K1 bit setting */ |
| 3419 | ret_val = e1000_read_nvm(hw, E1000_NVM_K1_CONFIG, 1, &kum_cfg); |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 3420 | if (ret_val) |
| 3421 | return ret_val; |
| 3422 | |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3423 | if (kum_cfg & E1000_NVM_K1_ENABLE) |
Bruce Allan | 1d5846b | 2009-10-29 13:46:05 +0000 | [diff] [blame] | 3424 | dev_spec->nvm_k1_enabled = true; |
| 3425 | else |
| 3426 | dev_spec->nvm_k1_enabled = false; |
| 3427 | } |
| 3428 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3429 | ctrl = er32(CTRL); |
| 3430 | |
Bruce Allan | 44abd5c | 2012-02-22 09:02:37 +0000 | [diff] [blame] | 3431 | if (!hw->phy.ops.check_reset_block(hw)) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3432 | /* Full-chip reset requires MAC and PHY reset at the same |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3433 | * time to make sure the interface between MAC and the |
| 3434 | * external PHY is reset. |
| 3435 | */ |
| 3436 | ctrl |= E1000_CTRL_PHY_RST; |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 3437 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3438 | /* Gate automatic PHY configuration by hardware on |
Bruce Allan | 605c82b | 2010-09-22 17:17:01 +0000 | [diff] [blame] | 3439 | * non-managed 82579 |
| 3440 | */ |
| 3441 | if ((hw->mac.type == e1000_pch2lan) && |
| 3442 | !(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) |
| 3443 | e1000_gate_hw_phy_config_ich8lan(hw, true); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3444 | } |
| 3445 | ret_val = e1000_acquire_swflag_ich8lan(hw); |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3446 | e_dbg("Issuing a global reset to ich8lan\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3447 | ew32(CTRL, (ctrl | E1000_CTRL_RST)); |
Jesse Brandeburg | 945a515 | 2011-07-20 00:56:21 +0000 | [diff] [blame] | 3448 | /* cannot issue a flush here because it hangs the hardware */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3449 | msleep(20); |
| 3450 | |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3451 | /* Set Phy Config Counter to 50msec */ |
| 3452 | if (hw->mac.type == e1000_pch2lan) { |
| 3453 | reg = er32(FEXTNVM3); |
| 3454 | reg &= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK; |
| 3455 | reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC; |
| 3456 | ew32(FEXTNVM3, reg); |
| 3457 | } |
| 3458 | |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3459 | if (!ret_val) |
Bruce Allan | a90b412 | 2011-10-07 03:50:38 +0000 | [diff] [blame] | 3460 | clear_bit(__E1000_ACCESS_SHARED_RESOURCE, &hw->adapter->state); |
Jesse Brandeburg | 37f4023 | 2008-10-02 16:33:20 -0700 | [diff] [blame] | 3461 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3462 | if (ctrl & E1000_CTRL_PHY_RST) { |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3463 | ret_val = hw->phy.ops.get_cfg_done(hw); |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3464 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3465 | return ret_val; |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3466 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3467 | ret_val = e1000_post_phy_reset_ich8lan(hw); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 3468 | if (ret_val) |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3469 | return ret_val; |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame] | 3470 | } |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 3471 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3472 | /* For PCH, this write will make sure that any noise |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 3473 | * will be detected as a CRC error and be dropped rather than show up |
| 3474 | * as a bad packet to the DMA engine. |
| 3475 | */ |
| 3476 | if (hw->mac.type == e1000_pchlan) |
| 3477 | ew32(CRC_OFFSET, 0x65656565); |
| 3478 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3479 | ew32(IMC, 0xffffffff); |
Bruce Allan | dd93f95 | 2011-01-06 14:29:48 +0000 | [diff] [blame] | 3480 | er32(ICR); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3481 | |
Bruce Allan | 62bc813 | 2012-03-20 03:47:57 +0000 | [diff] [blame] | 3482 | reg = er32(KABGTXD); |
| 3483 | reg |= E1000_KABGTXD_BGSQLBIAS; |
| 3484 | ew32(KABGTXD, reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3485 | |
Bruce Allan | 5015e53 | 2012-02-08 02:55:56 +0000 | [diff] [blame] | 3486 | return 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3487 | } |
| 3488 | |
| 3489 | /** |
| 3490 | * e1000_init_hw_ich8lan - Initialize the hardware |
| 3491 | * @hw: pointer to the HW structure |
| 3492 | * |
| 3493 | * Prepares the hardware for transmit and receive by doing the following: |
| 3494 | * - initialize hardware bits |
| 3495 | * - initialize LED identification |
| 3496 | * - setup receive address registers |
| 3497 | * - setup flow control |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 3498 | * - setup transmit descriptors |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3499 | * - clear statistics |
| 3500 | **/ |
| 3501 | static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw) |
| 3502 | { |
| 3503 | struct e1000_mac_info *mac = &hw->mac; |
| 3504 | u32 ctrl_ext, txdctl, snoop; |
| 3505 | s32 ret_val; |
| 3506 | u16 i; |
| 3507 | |
| 3508 | e1000_initialize_hw_bits_ich8lan(hw); |
| 3509 | |
| 3510 | /* Initialize identification LED */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3511 | ret_val = mac->ops.id_led_init(hw); |
Bruce Allan | de39b75 | 2009-11-20 23:27:59 +0000 | [diff] [blame] | 3512 | if (ret_val) |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3513 | e_dbg("Error initializing identification LED\n"); |
Bruce Allan | de39b75 | 2009-11-20 23:27:59 +0000 | [diff] [blame] | 3514 | /* This is not fatal and we should not stop init due to this */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3515 | |
| 3516 | /* Setup the receive address. */ |
| 3517 | e1000e_init_rx_addrs(hw, mac->rar_entry_count); |
| 3518 | |
| 3519 | /* Zero out the Multicast HASH table */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3520 | e_dbg("Zeroing the MTA\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3521 | for (i = 0; i < mac->mta_reg_count; i++) |
| 3522 | E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); |
| 3523 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3524 | /* The 82578 Rx buffer will stall if wakeup is enabled in host and |
Bruce Allan | 3ebfc7c | 2011-05-13 07:20:14 +0000 | [diff] [blame] | 3525 | * the ME. Disable wakeup by clearing the host wakeup bit. |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3526 | * Reset the phy after disabling host wakeup to reset the Rx buffer. |
| 3527 | */ |
| 3528 | if (hw->phy.type == e1000_phy_82578) { |
Bruce Allan | 3ebfc7c | 2011-05-13 07:20:14 +0000 | [diff] [blame] | 3529 | e1e_rphy(hw, BM_PORT_GEN_CFG, &i); |
| 3530 | i &= ~BM_WUC_HOST_WU_BIT; |
| 3531 | e1e_wphy(hw, BM_PORT_GEN_CFG, i); |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3532 | ret_val = e1000_phy_hw_reset_ich8lan(hw); |
| 3533 | if (ret_val) |
| 3534 | return ret_val; |
| 3535 | } |
| 3536 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3537 | /* Setup link and flow control */ |
Bruce Allan | 1a46b40 | 2012-02-22 09:02:26 +0000 | [diff] [blame] | 3538 | ret_val = mac->ops.setup_link(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3539 | |
| 3540 | /* Set the transmit descriptor write-back policy for both queues */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3541 | txdctl = er32(TXDCTL(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3542 | txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) | |
| 3543 | E1000_TXDCTL_FULL_TX_DESC_WB; |
| 3544 | txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) | |
| 3545 | E1000_TXDCTL_MAX_TX_DESC_PREFETCH; |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3546 | ew32(TXDCTL(0), txdctl); |
| 3547 | txdctl = er32(TXDCTL(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3548 | txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) | |
| 3549 | E1000_TXDCTL_FULL_TX_DESC_WB; |
| 3550 | txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) | |
| 3551 | E1000_TXDCTL_MAX_TX_DESC_PREFETCH; |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3552 | ew32(TXDCTL(1), txdctl); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3553 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3554 | /* ICH8 has opposite polarity of no_snoop bits. |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3555 | * By default, we should use snoop behavior. |
| 3556 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3557 | if (mac->type == e1000_ich8lan) |
| 3558 | snoop = PCIE_ICH8_SNOOP_ALL; |
| 3559 | else |
| 3560 | snoop = (u32) ~(PCIE_NO_SNOOP_ALL); |
| 3561 | e1000e_set_pcie_no_snoop(hw, snoop); |
| 3562 | |
| 3563 | ctrl_ext = er32(CTRL_EXT); |
| 3564 | ctrl_ext |= E1000_CTRL_EXT_RO_DIS; |
| 3565 | ew32(CTRL_EXT, ctrl_ext); |
| 3566 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3567 | /* Clear all of the statistics registers (clear on read). It is |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3568 | * important that we do this after we have tried to establish link |
| 3569 | * because the symbol error count will increment wildly if there |
| 3570 | * is no link. |
| 3571 | */ |
| 3572 | e1000_clear_hw_cntrs_ich8lan(hw); |
| 3573 | |
Bruce Allan | e561a70 | 2012-02-08 02:55:46 +0000 | [diff] [blame] | 3574 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3575 | } |
| 3576 | /** |
| 3577 | * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits |
| 3578 | * @hw: pointer to the HW structure |
| 3579 | * |
| 3580 | * Sets/Clears required hardware bits necessary for correctly setting up the |
| 3581 | * hardware for transmit and receive. |
| 3582 | **/ |
| 3583 | static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw) |
| 3584 | { |
| 3585 | u32 reg; |
| 3586 | |
| 3587 | /* Extended Device Control */ |
| 3588 | reg = er32(CTRL_EXT); |
| 3589 | reg |= (1 << 22); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3590 | /* Enable PHY low-power state when MAC is at D3 w/o WoL */ |
| 3591 | if (hw->mac.type >= e1000_pchlan) |
| 3592 | reg |= E1000_CTRL_EXT_PHYPDEN; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3593 | ew32(CTRL_EXT, reg); |
| 3594 | |
| 3595 | /* Transmit Descriptor Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3596 | reg = er32(TXDCTL(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3597 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3598 | ew32(TXDCTL(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3599 | |
| 3600 | /* Transmit Descriptor Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3601 | reg = er32(TXDCTL(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3602 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3603 | ew32(TXDCTL(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3604 | |
| 3605 | /* Transmit Arbitration Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3606 | reg = er32(TARC(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3607 | if (hw->mac.type == e1000_ich8lan) |
| 3608 | reg |= (1 << 28) | (1 << 29); |
| 3609 | reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3610 | ew32(TARC(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3611 | |
| 3612 | /* Transmit Arbitration Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3613 | reg = er32(TARC(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3614 | if (er32(TCTL) & E1000_TCTL_MULR) |
| 3615 | reg &= ~(1 << 28); |
| 3616 | else |
| 3617 | reg |= (1 << 28); |
| 3618 | reg |= (1 << 24) | (1 << 26) | (1 << 30); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 3619 | ew32(TARC(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3620 | |
| 3621 | /* Device Status */ |
| 3622 | if (hw->mac.type == e1000_ich8lan) { |
| 3623 | reg = er32(STATUS); |
| 3624 | reg &= ~(1 << 31); |
| 3625 | ew32(STATUS, reg); |
| 3626 | } |
Jesse Brandeburg | a80483d | 2010-03-05 02:21:44 +0000 | [diff] [blame] | 3627 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3628 | /* work-around descriptor data corruption issue during nfs v2 udp |
Jesse Brandeburg | a80483d | 2010-03-05 02:21:44 +0000 | [diff] [blame] | 3629 | * traffic, just disable the nfs filtering capability |
| 3630 | */ |
| 3631 | reg = er32(RFCTL); |
| 3632 | reg |= (E1000_RFCTL_NFSW_DIS | E1000_RFCTL_NFSR_DIS); |
Matthew Vick | f6bd557 | 2012-04-25 08:01:05 +0000 | [diff] [blame] | 3633 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3634 | /* Disable IPv6 extension header parsing because some malformed |
Matthew Vick | f6bd557 | 2012-04-25 08:01:05 +0000 | [diff] [blame] | 3635 | * IPv6 headers can hang the Rx. |
| 3636 | */ |
| 3637 | if (hw->mac.type == e1000_ich8lan) |
| 3638 | reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS); |
Jesse Brandeburg | a80483d | 2010-03-05 02:21:44 +0000 | [diff] [blame] | 3639 | ew32(RFCTL, reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3640 | } |
| 3641 | |
| 3642 | /** |
| 3643 | * e1000_setup_link_ich8lan - Setup flow control and link settings |
| 3644 | * @hw: pointer to the HW structure |
| 3645 | * |
| 3646 | * Determines which flow control settings to use, then configures flow |
| 3647 | * control. Calls the appropriate media-specific link configuration |
| 3648 | * function. Assuming the adapter has a valid link partner, a valid link |
| 3649 | * should be established. Assumes the hardware has previously been reset |
| 3650 | * and the transmitter and receiver are not enabled. |
| 3651 | **/ |
| 3652 | static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) |
| 3653 | { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3654 | s32 ret_val; |
| 3655 | |
Bruce Allan | 44abd5c | 2012-02-22 09:02:37 +0000 | [diff] [blame] | 3656 | if (hw->phy.ops.check_reset_block(hw)) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3657 | return 0; |
| 3658 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3659 | /* ICH parts do not have a word in the NVM to determine |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3660 | * the default flow control setting, so we explicitly |
| 3661 | * set it to full. |
| 3662 | */ |
Bruce Allan | 37289d9 | 2009-06-02 11:29:37 +0000 | [diff] [blame] | 3663 | if (hw->fc.requested_mode == e1000_fc_default) { |
| 3664 | /* Workaround h/w hang when Tx flow control enabled */ |
| 3665 | if (hw->mac.type == e1000_pchlan) |
| 3666 | hw->fc.requested_mode = e1000_fc_rx_pause; |
| 3667 | else |
| 3668 | hw->fc.requested_mode = e1000_fc_full; |
| 3669 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3670 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3671 | /* Save off the requested flow control mode for use later. Depending |
Bruce Allan | 5c48ef3e2 | 2008-11-21 16:57:36 -0800 | [diff] [blame] | 3672 | * on the link partner's capabilities, we may or may not use this mode. |
| 3673 | */ |
| 3674 | hw->fc.current_mode = hw->fc.requested_mode; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3675 | |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3676 | e_dbg("After fix-ups FlowControl is now = %x\n", |
Bruce Allan | 5c48ef3e2 | 2008-11-21 16:57:36 -0800 | [diff] [blame] | 3677 | hw->fc.current_mode); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3678 | |
| 3679 | /* Continue to configure the copper link. */ |
Bruce Allan | 944ce01 | 2012-02-22 09:02:42 +0000 | [diff] [blame] | 3680 | ret_val = hw->mac.ops.setup_physical_interface(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3681 | if (ret_val) |
| 3682 | return ret_val; |
| 3683 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 3684 | ew32(FCTTV, hw->fc.pause_time); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3685 | if ((hw->phy.type == e1000_phy_82578) || |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 3686 | (hw->phy.type == e1000_phy_82579) || |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 3687 | (hw->phy.type == e1000_phy_i217) || |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3688 | (hw->phy.type == e1000_phy_82577)) { |
Bruce Allan | a305595 | 2010-05-10 15:02:12 +0000 | [diff] [blame] | 3689 | ew32(FCRTV_PCH, hw->fc.refresh_time); |
| 3690 | |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 3691 | ret_val = e1e_wphy(hw, PHY_REG(BM_PORT_CTRL_PAGE, 27), |
| 3692 | hw->fc.pause_time); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3693 | if (ret_val) |
| 3694 | return ret_val; |
| 3695 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3696 | |
| 3697 | return e1000e_set_fc_watermarks(hw); |
| 3698 | } |
| 3699 | |
| 3700 | /** |
| 3701 | * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface |
| 3702 | * @hw: pointer to the HW structure |
| 3703 | * |
| 3704 | * Configures the kumeran interface to the PHY to wait the appropriate time |
| 3705 | * when polling the PHY, then call the generic setup_copper_link to finish |
| 3706 | * configuring the copper link. |
| 3707 | **/ |
| 3708 | static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw) |
| 3709 | { |
| 3710 | u32 ctrl; |
| 3711 | s32 ret_val; |
| 3712 | u16 reg_data; |
| 3713 | |
| 3714 | ctrl = er32(CTRL); |
| 3715 | ctrl |= E1000_CTRL_SLU; |
| 3716 | ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); |
| 3717 | ew32(CTRL, ctrl); |
| 3718 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3719 | /* Set the mac to wait the maximum time between each iteration |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3720 | * and increase the max iterations when polling the phy; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3721 | * this fixes erroneous timeouts at 10Mbps. |
| 3722 | */ |
Bruce Allan | 0781895 | 2009-12-08 07:28:01 +0000 | [diff] [blame] | 3723 | ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_TIMEOUTS, 0xFFFF); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3724 | if (ret_val) |
| 3725 | return ret_val; |
Bruce Allan | 0781895 | 2009-12-08 07:28:01 +0000 | [diff] [blame] | 3726 | ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM, |
| 3727 | ®_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3728 | if (ret_val) |
| 3729 | return ret_val; |
| 3730 | reg_data |= 0x3F; |
Bruce Allan | 0781895 | 2009-12-08 07:28:01 +0000 | [diff] [blame] | 3731 | ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_INBAND_PARAM, |
| 3732 | reg_data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3733 | if (ret_val) |
| 3734 | return ret_val; |
| 3735 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3736 | switch (hw->phy.type) { |
| 3737 | case e1000_phy_igp_3: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3738 | ret_val = e1000e_copper_link_setup_igp(hw); |
| 3739 | if (ret_val) |
| 3740 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3741 | break; |
| 3742 | case e1000_phy_bm: |
| 3743 | case e1000_phy_82578: |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3744 | ret_val = e1000e_copper_link_setup_m88(hw); |
| 3745 | if (ret_val) |
| 3746 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3747 | break; |
| 3748 | case e1000_phy_82577: |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 3749 | case e1000_phy_82579: |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 3750 | case e1000_phy_i217: |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3751 | ret_val = e1000_copper_link_setup_82577(hw); |
| 3752 | if (ret_val) |
| 3753 | return ret_val; |
| 3754 | break; |
| 3755 | case e1000_phy_ife: |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 3756 | ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, ®_data); |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3757 | if (ret_val) |
| 3758 | return ret_val; |
| 3759 | |
| 3760 | reg_data &= ~IFE_PMC_AUTO_MDIX; |
| 3761 | |
| 3762 | switch (hw->phy.mdix) { |
| 3763 | case 1: |
| 3764 | reg_data &= ~IFE_PMC_FORCE_MDIX; |
| 3765 | break; |
| 3766 | case 2: |
| 3767 | reg_data |= IFE_PMC_FORCE_MDIX; |
| 3768 | break; |
| 3769 | case 0: |
| 3770 | default: |
| 3771 | reg_data |= IFE_PMC_AUTO_MDIX; |
| 3772 | break; |
| 3773 | } |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 3774 | ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data); |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3775 | if (ret_val) |
| 3776 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3777 | break; |
| 3778 | default: |
| 3779 | break; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3780 | } |
Bruce Allan | 3fa829363 | 2012-02-08 02:55:40 +0000 | [diff] [blame] | 3781 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3782 | return e1000e_setup_copper_link(hw); |
| 3783 | } |
| 3784 | |
| 3785 | /** |
| 3786 | * e1000_get_link_up_info_ich8lan - Get current link speed and duplex |
| 3787 | * @hw: pointer to the HW structure |
| 3788 | * @speed: pointer to store current link speed |
| 3789 | * @duplex: pointer to store the current link duplex |
| 3790 | * |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3791 | * Calls the generic get_speed_and_duplex to retrieve the current link |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3792 | * information and then calls the Kumeran lock loss workaround for links at |
| 3793 | * gigabit speeds. |
| 3794 | **/ |
| 3795 | static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed, |
| 3796 | u16 *duplex) |
| 3797 | { |
| 3798 | s32 ret_val; |
| 3799 | |
| 3800 | ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex); |
| 3801 | if (ret_val) |
| 3802 | return ret_val; |
| 3803 | |
| 3804 | if ((hw->mac.type == e1000_ich8lan) && |
| 3805 | (hw->phy.type == e1000_phy_igp_3) && |
| 3806 | (*speed == SPEED_1000)) { |
| 3807 | ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw); |
| 3808 | } |
| 3809 | |
| 3810 | return ret_val; |
| 3811 | } |
| 3812 | |
| 3813 | /** |
| 3814 | * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround |
| 3815 | * @hw: pointer to the HW structure |
| 3816 | * |
| 3817 | * Work-around for 82566 Kumeran PCS lock loss: |
| 3818 | * On link status change (i.e. PCI reset, speed change) and link is up and |
| 3819 | * speed is gigabit- |
| 3820 | * 0) if workaround is optionally disabled do nothing |
| 3821 | * 1) wait 1ms for Kumeran link to come up |
| 3822 | * 2) check Kumeran Diagnostic register PCS lock loss bit |
| 3823 | * 3) if not set the link is locked (all is good), otherwise... |
| 3824 | * 4) reset the PHY |
| 3825 | * 5) repeat up to 10 times |
| 3826 | * Note: this is only called for IGP3 copper when speed is 1gb. |
| 3827 | **/ |
| 3828 | static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw) |
| 3829 | { |
| 3830 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
| 3831 | u32 phy_ctrl; |
| 3832 | s32 ret_val; |
| 3833 | u16 i, data; |
| 3834 | bool link; |
| 3835 | |
| 3836 | if (!dev_spec->kmrn_lock_loss_workaround_enabled) |
| 3837 | return 0; |
| 3838 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3839 | /* Make sure link is up before proceeding. If not just return. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3840 | * Attempting this while link is negotiating fouled up link |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3841 | * stability |
| 3842 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3843 | ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); |
| 3844 | if (!link) |
| 3845 | return 0; |
| 3846 | |
| 3847 | for (i = 0; i < 10; i++) { |
| 3848 | /* read once to clear */ |
| 3849 | ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data); |
| 3850 | if (ret_val) |
| 3851 | return ret_val; |
| 3852 | /* and again to get new status */ |
| 3853 | ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data); |
| 3854 | if (ret_val) |
| 3855 | return ret_val; |
| 3856 | |
| 3857 | /* check for PCS lock */ |
| 3858 | if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS)) |
| 3859 | return 0; |
| 3860 | |
| 3861 | /* Issue PHY reset */ |
| 3862 | e1000_phy_hw_reset(hw); |
| 3863 | mdelay(5); |
| 3864 | } |
| 3865 | /* Disable GigE link negotiation */ |
| 3866 | phy_ctrl = er32(PHY_CTRL); |
| 3867 | phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE | |
| 3868 | E1000_PHY_CTRL_NOND0A_GBE_DISABLE); |
| 3869 | ew32(PHY_CTRL, phy_ctrl); |
| 3870 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3871 | /* Call gig speed drop workaround on Gig disable before accessing |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3872 | * any PHY registers |
| 3873 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3874 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 3875 | |
| 3876 | /* unable to acquire PCS lock */ |
| 3877 | return -E1000_ERR_PHY; |
| 3878 | } |
| 3879 | |
| 3880 | /** |
Bruce Allan | 6e3c807 | 2012-02-22 09:02:47 +0000 | [diff] [blame] | 3881 | * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3882 | * @hw: pointer to the HW structure |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 3883 | * @state: boolean value used to set the current Kumeran workaround state |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3884 | * |
Bruce Allan | 564ea9b | 2009-11-20 23:26:44 +0000 | [diff] [blame] | 3885 | * If ICH8, set the current Kumeran workaround state (enabled - true |
| 3886 | * /disabled - false). |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3887 | **/ |
| 3888 | void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, |
| 3889 | bool state) |
| 3890 | { |
| 3891 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
| 3892 | |
| 3893 | if (hw->mac.type != e1000_ich8lan) { |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 3894 | e_dbg("Workaround applies to ICH8 only.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3895 | return; |
| 3896 | } |
| 3897 | |
| 3898 | dev_spec->kmrn_lock_loss_workaround_enabled = state; |
| 3899 | } |
| 3900 | |
| 3901 | /** |
| 3902 | * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3 |
| 3903 | * @hw: pointer to the HW structure |
| 3904 | * |
| 3905 | * Workaround for 82566 power-down on D3 entry: |
| 3906 | * 1) disable gigabit link |
| 3907 | * 2) write VR power-down enable |
| 3908 | * 3) read it back |
| 3909 | * Continue if successful, else issue LCD reset and repeat |
| 3910 | **/ |
| 3911 | void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw) |
| 3912 | { |
| 3913 | u32 reg; |
| 3914 | u16 data; |
| 3915 | u8 retry = 0; |
| 3916 | |
| 3917 | if (hw->phy.type != e1000_phy_igp_3) |
| 3918 | return; |
| 3919 | |
| 3920 | /* Try the workaround twice (if needed) */ |
| 3921 | do { |
| 3922 | /* Disable link */ |
| 3923 | reg = er32(PHY_CTRL); |
| 3924 | reg |= (E1000_PHY_CTRL_GBE_DISABLE | |
| 3925 | E1000_PHY_CTRL_NOND0A_GBE_DISABLE); |
| 3926 | ew32(PHY_CTRL, reg); |
| 3927 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 3928 | /* Call gig speed drop workaround on Gig disable before |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 3929 | * accessing any PHY registers |
| 3930 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3931 | if (hw->mac.type == e1000_ich8lan) |
| 3932 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 3933 | |
| 3934 | /* Write VR power-down enable */ |
| 3935 | e1e_rphy(hw, IGP3_VR_CTRL, &data); |
| 3936 | data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK; |
| 3937 | e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN); |
| 3938 | |
| 3939 | /* Read it back and test */ |
| 3940 | e1e_rphy(hw, IGP3_VR_CTRL, &data); |
| 3941 | data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK; |
| 3942 | if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry) |
| 3943 | break; |
| 3944 | |
| 3945 | /* Issue PHY reset and repeat at most one more time */ |
| 3946 | reg = er32(CTRL); |
| 3947 | ew32(CTRL, reg | E1000_CTRL_PHY_RST); |
| 3948 | retry++; |
| 3949 | } while (retry); |
| 3950 | } |
| 3951 | |
| 3952 | /** |
| 3953 | * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working |
| 3954 | * @hw: pointer to the HW structure |
| 3955 | * |
| 3956 | * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC), |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 3957 | * LPLU, Gig disable, MDIC PHY reset): |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3958 | * 1) Set Kumeran Near-end loopback |
| 3959 | * 2) Clear Kumeran Near-end loopback |
Bruce Allan | 462d599 | 2011-09-30 08:07:11 +0000 | [diff] [blame] | 3960 | * Should only be called for ICH8[m] devices with any 1G Phy. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3961 | **/ |
| 3962 | void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw) |
| 3963 | { |
| 3964 | s32 ret_val; |
| 3965 | u16 reg_data; |
| 3966 | |
Bruce Allan | 462d599 | 2011-09-30 08:07:11 +0000 | [diff] [blame] | 3967 | if ((hw->mac.type != e1000_ich8lan) || (hw->phy.type == e1000_phy_ife)) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3968 | return; |
| 3969 | |
| 3970 | ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, |
| 3971 | ®_data); |
| 3972 | if (ret_val) |
| 3973 | return; |
| 3974 | reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK; |
| 3975 | ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, |
| 3976 | reg_data); |
| 3977 | if (ret_val) |
| 3978 | return; |
| 3979 | reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK; |
| 3980 | ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, |
| 3981 | reg_data); |
| 3982 | } |
| 3983 | |
| 3984 | /** |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 3985 | * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3986 | * @hw: pointer to the HW structure |
| 3987 | * |
| 3988 | * During S0 to Sx transition, it is possible the link remains at gig |
| 3989 | * instead of negotiating to a lower speed. Before going to Sx, set |
Bruce Allan | c077a90 | 2011-12-16 00:46:38 +0000 | [diff] [blame] | 3990 | * 'Gig Disable' to force link speed negotiation to a lower speed based on |
| 3991 | * the LPLU setting in the NVM or custom setting. For PCH and newer parts, |
| 3992 | * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also |
| 3993 | * needs to be written. |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 3994 | * Parts that support (and are linked to a partner which support) EEE in |
| 3995 | * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power |
| 3996 | * than 10Mbps w/o EEE. |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3997 | **/ |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 3998 | void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw) |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3999 | { |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4000 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4001 | u32 phy_ctrl; |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 4002 | s32 ret_val; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4003 | |
Bruce Allan | 17f085d | 2010-06-17 18:59:48 +0000 | [diff] [blame] | 4004 | phy_ctrl = er32(PHY_CTRL); |
Bruce Allan | c077a90 | 2011-12-16 00:46:38 +0000 | [diff] [blame] | 4005 | phy_ctrl |= E1000_PHY_CTRL_GBE_DISABLE; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4006 | if (hw->phy.type == e1000_phy_i217) { |
| 4007 | u16 phy_reg; |
| 4008 | |
| 4009 | ret_val = hw->phy.ops.acquire(hw); |
| 4010 | if (ret_val) |
| 4011 | goto out; |
| 4012 | |
| 4013 | if (!dev_spec->eee_disable) { |
| 4014 | u16 eee_advert; |
| 4015 | |
| 4016 | ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, |
| 4017 | I217_EEE_ADVERTISEMENT); |
| 4018 | if (ret_val) |
| 4019 | goto release; |
| 4020 | e1e_rphy_locked(hw, I82579_EMI_DATA, &eee_advert); |
| 4021 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4022 | /* Disable LPLU if both link partners support 100BaseT |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4023 | * EEE and 100Full is advertised on both ends of the |
| 4024 | * link. |
| 4025 | */ |
| 4026 | if ((eee_advert & I217_EEE_100_SUPPORTED) && |
| 4027 | (dev_spec->eee_lp_ability & |
| 4028 | I217_EEE_100_SUPPORTED) && |
| 4029 | (hw->phy.autoneg_advertised & ADVERTISE_100_FULL)) |
| 4030 | phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU | |
| 4031 | E1000_PHY_CTRL_NOND0A_LPLU); |
| 4032 | } |
| 4033 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4034 | /* For i217 Intel Rapid Start Technology support, |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4035 | * when the system is going into Sx and no manageability engine |
| 4036 | * is present, the driver must configure proxy to reset only on |
| 4037 | * power good. LPI (Low Power Idle) state must also reset only |
| 4038 | * on power good, as well as the MTA (Multicast table array). |
| 4039 | * The SMBus release must also be disabled on LCD reset. |
| 4040 | */ |
| 4041 | if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) { |
| 4042 | |
| 4043 | /* Enable proxy to reset only on power good. */ |
| 4044 | e1e_rphy_locked(hw, I217_PROXY_CTRL, &phy_reg); |
| 4045 | phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE; |
| 4046 | e1e_wphy_locked(hw, I217_PROXY_CTRL, phy_reg); |
| 4047 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4048 | /* Set bit enable LPI (EEE) to reset only on |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4049 | * power good. |
| 4050 | */ |
| 4051 | e1e_rphy_locked(hw, I217_SxCTRL, &phy_reg); |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4052 | phy_reg |= I217_SxCTRL_ENABLE_LPI_RESET; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4053 | e1e_wphy_locked(hw, I217_SxCTRL, phy_reg); |
| 4054 | |
| 4055 | /* Disable the SMB release on LCD reset. */ |
| 4056 | e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg); |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4057 | phy_reg &= ~I217_MEMPWR_DISABLE_SMB_RELEASE; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4058 | e1e_wphy_locked(hw, I217_MEMPWR, phy_reg); |
| 4059 | } |
| 4060 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4061 | /* Enable MTA to reset for Intel Rapid Start Technology |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4062 | * Support |
| 4063 | */ |
| 4064 | e1e_rphy_locked(hw, I217_CGFREG, &phy_reg); |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4065 | phy_reg |= I217_CGFREG_ENABLE_MTA_RESET; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4066 | e1e_wphy_locked(hw, I217_CGFREG, phy_reg); |
| 4067 | |
| 4068 | release: |
| 4069 | hw->phy.ops.release(hw); |
| 4070 | } |
| 4071 | out: |
Bruce Allan | 17f085d | 2010-06-17 18:59:48 +0000 | [diff] [blame] | 4072 | ew32(PHY_CTRL, phy_ctrl); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4073 | |
Bruce Allan | 462d599 | 2011-09-30 08:07:11 +0000 | [diff] [blame] | 4074 | if (hw->mac.type == e1000_ich8lan) |
| 4075 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 4076 | |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 4077 | if (hw->mac.type >= e1000_pchlan) { |
Bruce Allan | ce54afd | 2010-11-24 06:01:41 +0000 | [diff] [blame] | 4078 | e1000_oem_bits_config_ich8lan(hw, false); |
Bruce Allan | 92fe173 | 2012-04-12 06:27:03 +0000 | [diff] [blame] | 4079 | |
| 4080 | /* Reset PHY to activate OEM bits on 82577/8 */ |
| 4081 | if (hw->mac.type == e1000_pchlan) |
| 4082 | e1000e_phy_hw_reset_generic(hw); |
| 4083 | |
Bruce Allan | 8395ae8 | 2010-09-22 17:15:08 +0000 | [diff] [blame] | 4084 | ret_val = hw->phy.ops.acquire(hw); |
| 4085 | if (ret_val) |
| 4086 | return; |
| 4087 | e1000_write_smbus_addr(hw); |
| 4088 | hw->phy.ops.release(hw); |
| 4089 | } |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4090 | } |
| 4091 | |
| 4092 | /** |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4093 | * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0 |
| 4094 | * @hw: pointer to the HW structure |
| 4095 | * |
| 4096 | * During Sx to S0 transitions on non-managed devices or managed devices |
| 4097 | * on which PHY resets are not blocked, if the PHY registers cannot be |
| 4098 | * accessed properly by the s/w toggle the LANPHYPC value to power cycle |
| 4099 | * the PHY. |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4100 | * On i217, setup Intel Rapid Start Technology. |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4101 | **/ |
| 4102 | void e1000_resume_workarounds_pchlan(struct e1000_hw *hw) |
| 4103 | { |
Bruce Allan | 90b8298 | 2011-12-16 00:46:33 +0000 | [diff] [blame] | 4104 | s32 ret_val; |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4105 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 4106 | if (hw->mac.type < e1000_pch2lan) |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4107 | return; |
| 4108 | |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 4109 | ret_val = e1000_init_phy_workarounds_pchlan(hw); |
Bruce Allan | 90b8298 | 2011-12-16 00:46:33 +0000 | [diff] [blame] | 4110 | if (ret_val) { |
Bruce Allan | cb17aab | 2012-04-13 03:16:22 +0000 | [diff] [blame] | 4111 | e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val); |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4112 | return; |
| 4113 | } |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4114 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4115 | /* For i217 Intel Rapid Start Technology support when the system |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4116 | * is transitioning from Sx and no manageability engine is present |
| 4117 | * configure SMBus to restore on reset, disable proxy, and enable |
| 4118 | * the reset on MTA (Multicast table array). |
| 4119 | */ |
| 4120 | if (hw->phy.type == e1000_phy_i217) { |
| 4121 | u16 phy_reg; |
| 4122 | |
| 4123 | ret_val = hw->phy.ops.acquire(hw); |
| 4124 | if (ret_val) { |
| 4125 | e_dbg("Failed to setup iRST\n"); |
| 4126 | return; |
| 4127 | } |
| 4128 | |
| 4129 | if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4130 | /* Restore clear on SMB if no manageability engine |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4131 | * is present |
| 4132 | */ |
| 4133 | ret_val = e1e_rphy_locked(hw, I217_MEMPWR, &phy_reg); |
| 4134 | if (ret_val) |
| 4135 | goto release; |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4136 | phy_reg |= I217_MEMPWR_DISABLE_SMB_RELEASE; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4137 | e1e_wphy_locked(hw, I217_MEMPWR, phy_reg); |
| 4138 | |
| 4139 | /* Disable Proxy */ |
| 4140 | e1e_wphy_locked(hw, I217_PROXY_CTRL, 0); |
| 4141 | } |
| 4142 | /* Enable reset on MTA */ |
| 4143 | ret_val = e1e_rphy_locked(hw, I217_CGFREG, &phy_reg); |
| 4144 | if (ret_val) |
| 4145 | goto release; |
Bruce Allan | 6d7407b | 2012-05-10 02:51:17 +0000 | [diff] [blame] | 4146 | phy_reg &= ~I217_CGFREG_ENABLE_MTA_RESET; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4147 | e1e_wphy_locked(hw, I217_CGFREG, phy_reg); |
| 4148 | release: |
| 4149 | if (ret_val) |
| 4150 | e_dbg("Error %d in resume workarounds\n", ret_val); |
| 4151 | hw->phy.ops.release(hw); |
| 4152 | } |
Bruce Allan | 99730e4 | 2011-05-13 07:19:48 +0000 | [diff] [blame] | 4153 | } |
| 4154 | |
| 4155 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4156 | * e1000_cleanup_led_ich8lan - Restore the default LED operation |
| 4157 | * @hw: pointer to the HW structure |
| 4158 | * |
| 4159 | * Return the LED back to the default configuration. |
| 4160 | **/ |
| 4161 | static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw) |
| 4162 | { |
| 4163 | if (hw->phy.type == e1000_phy_ife) |
| 4164 | return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0); |
| 4165 | |
| 4166 | ew32(LEDCTL, hw->mac.ledctl_default); |
| 4167 | return 0; |
| 4168 | } |
| 4169 | |
| 4170 | /** |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 4171 | * e1000_led_on_ich8lan - Turn LEDs on |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4172 | * @hw: pointer to the HW structure |
| 4173 | * |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 4174 | * Turn on the LEDs. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4175 | **/ |
| 4176 | static s32 e1000_led_on_ich8lan(struct e1000_hw *hw) |
| 4177 | { |
| 4178 | if (hw->phy.type == e1000_phy_ife) |
| 4179 | return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, |
| 4180 | (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON)); |
| 4181 | |
| 4182 | ew32(LEDCTL, hw->mac.ledctl_mode2); |
| 4183 | return 0; |
| 4184 | } |
| 4185 | |
| 4186 | /** |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 4187 | * e1000_led_off_ich8lan - Turn LEDs off |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4188 | * @hw: pointer to the HW structure |
| 4189 | * |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 4190 | * Turn off the LEDs. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4191 | **/ |
| 4192 | static s32 e1000_led_off_ich8lan(struct e1000_hw *hw) |
| 4193 | { |
| 4194 | if (hw->phy.type == e1000_phy_ife) |
| 4195 | return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4196 | (IFE_PSCL_PROBE_MODE | |
| 4197 | IFE_PSCL_PROBE_LEDS_OFF)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4198 | |
| 4199 | ew32(LEDCTL, hw->mac.ledctl_mode1); |
| 4200 | return 0; |
| 4201 | } |
| 4202 | |
| 4203 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4204 | * e1000_setup_led_pchlan - Configures SW controllable LED |
| 4205 | * @hw: pointer to the HW structure |
| 4206 | * |
| 4207 | * This prepares the SW controllable LED for use. |
| 4208 | **/ |
| 4209 | static s32 e1000_setup_led_pchlan(struct e1000_hw *hw) |
| 4210 | { |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4211 | return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_mode1); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4212 | } |
| 4213 | |
| 4214 | /** |
| 4215 | * e1000_cleanup_led_pchlan - Restore the default LED operation |
| 4216 | * @hw: pointer to the HW structure |
| 4217 | * |
| 4218 | * Return the LED back to the default configuration. |
| 4219 | **/ |
| 4220 | static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw) |
| 4221 | { |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4222 | return e1e_wphy(hw, HV_LED_CONFIG, (u16)hw->mac.ledctl_default); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4223 | } |
| 4224 | |
| 4225 | /** |
| 4226 | * e1000_led_on_pchlan - Turn LEDs on |
| 4227 | * @hw: pointer to the HW structure |
| 4228 | * |
| 4229 | * Turn on the LEDs. |
| 4230 | **/ |
| 4231 | static s32 e1000_led_on_pchlan(struct e1000_hw *hw) |
| 4232 | { |
| 4233 | u16 data = (u16)hw->mac.ledctl_mode2; |
| 4234 | u32 i, led; |
| 4235 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4236 | /* If no link, then turn LED on by setting the invert bit |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4237 | * for each LED that's mode is "link_up" in ledctl_mode2. |
| 4238 | */ |
| 4239 | if (!(er32(STATUS) & E1000_STATUS_LU)) { |
| 4240 | for (i = 0; i < 3; i++) { |
| 4241 | led = (data >> (i * 5)) & E1000_PHY_LED0_MASK; |
| 4242 | if ((led & E1000_PHY_LED0_MODE_MASK) != |
| 4243 | E1000_LEDCTL_MODE_LINK_UP) |
| 4244 | continue; |
| 4245 | if (led & E1000_PHY_LED0_IVRT) |
| 4246 | data &= ~(E1000_PHY_LED0_IVRT << (i * 5)); |
| 4247 | else |
| 4248 | data |= (E1000_PHY_LED0_IVRT << (i * 5)); |
| 4249 | } |
| 4250 | } |
| 4251 | |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4252 | return e1e_wphy(hw, HV_LED_CONFIG, data); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4253 | } |
| 4254 | |
| 4255 | /** |
| 4256 | * e1000_led_off_pchlan - Turn LEDs off |
| 4257 | * @hw: pointer to the HW structure |
| 4258 | * |
| 4259 | * Turn off the LEDs. |
| 4260 | **/ |
| 4261 | static s32 e1000_led_off_pchlan(struct e1000_hw *hw) |
| 4262 | { |
| 4263 | u16 data = (u16)hw->mac.ledctl_mode1; |
| 4264 | u32 i, led; |
| 4265 | |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4266 | /* If no link, then turn LED off by clearing the invert bit |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4267 | * for each LED that's mode is "link_up" in ledctl_mode1. |
| 4268 | */ |
| 4269 | if (!(er32(STATUS) & E1000_STATUS_LU)) { |
| 4270 | for (i = 0; i < 3; i++) { |
| 4271 | led = (data >> (i * 5)) & E1000_PHY_LED0_MASK; |
| 4272 | if ((led & E1000_PHY_LED0_MODE_MASK) != |
| 4273 | E1000_LEDCTL_MODE_LINK_UP) |
| 4274 | continue; |
| 4275 | if (led & E1000_PHY_LED0_IVRT) |
| 4276 | data &= ~(E1000_PHY_LED0_IVRT << (i * 5)); |
| 4277 | else |
| 4278 | data |= (E1000_PHY_LED0_IVRT << (i * 5)); |
| 4279 | } |
| 4280 | } |
| 4281 | |
Bruce Allan | 482fed8 | 2011-01-06 14:29:49 +0000 | [diff] [blame] | 4282 | return e1e_wphy(hw, HV_LED_CONFIG, data); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4283 | } |
| 4284 | |
| 4285 | /** |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4286 | * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4287 | * @hw: pointer to the HW structure |
| 4288 | * |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4289 | * Read appropriate register for the config done bit for completion status |
| 4290 | * and configure the PHY through s/w for EEPROM-less parts. |
| 4291 | * |
| 4292 | * NOTE: some silicon which is EEPROM-less will fail trying to read the |
| 4293 | * config done bit, so only an error is logged and continues. If we were |
| 4294 | * to return with error, EEPROM-less silicon would not be able to be reset |
| 4295 | * or change link. |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4296 | **/ |
| 4297 | static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw) |
| 4298 | { |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4299 | s32 ret_val = 0; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4300 | u32 bank = 0; |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4301 | u32 status; |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 4302 | |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4303 | e1000e_get_cfg_done(hw); |
| 4304 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4305 | /* Wait for indication from h/w that it has completed basic config */ |
| 4306 | if (hw->mac.type >= e1000_ich10lan) { |
| 4307 | e1000_lan_init_done_ich8lan(hw); |
| 4308 | } else { |
| 4309 | ret_val = e1000e_get_auto_rd_done(hw); |
| 4310 | if (ret_val) { |
Bruce Allan | e921eb1 | 2012-11-28 09:28:37 +0000 | [diff] [blame] | 4311 | /* When auto config read does not complete, do not |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4312 | * return with an error. This can happen in situations |
| 4313 | * where there is no eeprom and prevents getting link. |
| 4314 | */ |
| 4315 | e_dbg("Auto Read Done did not complete\n"); |
| 4316 | ret_val = 0; |
| 4317 | } |
| 4318 | } |
| 4319 | |
| 4320 | /* Clear PHY Reset Asserted bit */ |
| 4321 | status = er32(STATUS); |
| 4322 | if (status & E1000_STATUS_PHYRA) |
| 4323 | ew32(STATUS, status & ~E1000_STATUS_PHYRA); |
| 4324 | else |
| 4325 | e_dbg("PHY Reset Asserted not set - needs delay\n"); |
| 4326 | |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4327 | /* If EEPROM is not marked present, init the IGP 3 PHY manually */ |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4328 | if (hw->mac.type <= e1000_ich9lan) { |
Bruce Allan | 04499ec | 2012-04-13 00:08:31 +0000 | [diff] [blame] | 4329 | if (!(er32(EECD) & E1000_EECD_PRES) && |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4330 | (hw->phy.type == e1000_phy_igp_3)) { |
| 4331 | e1000e_phy_init_script_igp3(hw); |
| 4332 | } |
| 4333 | } else { |
| 4334 | if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) { |
| 4335 | /* Maybe we should do a basic PHY config */ |
Bruce Allan | 3bb99fe | 2009-11-20 23:25:07 +0000 | [diff] [blame] | 4336 | e_dbg("EEPROM not present\n"); |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4337 | ret_val = -E1000_ERR_CONFIG; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4338 | } |
| 4339 | } |
| 4340 | |
Bruce Allan | e98cac4 | 2010-05-10 15:02:32 +0000 | [diff] [blame] | 4341 | return ret_val; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4342 | } |
| 4343 | |
| 4344 | /** |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 4345 | * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down |
| 4346 | * @hw: pointer to the HW structure |
| 4347 | * |
| 4348 | * In the case of a PHY power down to save power, or to turn off link during a |
| 4349 | * driver unload, or wake on lan is not enabled, remove the link. |
| 4350 | **/ |
| 4351 | static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw) |
| 4352 | { |
| 4353 | /* If the management interface is not enabled, then power down */ |
| 4354 | if (!(hw->mac.ops.check_mng_mode(hw) || |
| 4355 | hw->phy.ops.check_reset_block(hw))) |
| 4356 | e1000_power_down_phy_copper(hw); |
Bruce Allan | 17f208d | 2009-12-01 15:47:22 +0000 | [diff] [blame] | 4357 | } |
| 4358 | |
| 4359 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4360 | * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters |
| 4361 | * @hw: pointer to the HW structure |
| 4362 | * |
| 4363 | * Clears hardware counters specific to the silicon family and calls |
| 4364 | * clear_hw_cntrs_generic to clear all general purpose counters. |
| 4365 | **/ |
| 4366 | static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw) |
| 4367 | { |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4368 | u16 phy_data; |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 4369 | s32 ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4370 | |
| 4371 | e1000e_clear_hw_cntrs_base(hw); |
| 4372 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 4373 | er32(ALGNERRC); |
| 4374 | er32(RXERRC); |
| 4375 | er32(TNCRS); |
| 4376 | er32(CEXTERR); |
| 4377 | er32(TSCTC); |
| 4378 | er32(TSCTFC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4379 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 4380 | er32(MGTPRC); |
| 4381 | er32(MGTPDC); |
| 4382 | er32(MGTPTC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4383 | |
Bruce Allan | 99673d9 | 2009-11-20 23:27:21 +0000 | [diff] [blame] | 4384 | er32(IAC); |
| 4385 | er32(ICRXOC); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4386 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4387 | /* Clear PHY statistics registers */ |
| 4388 | if ((hw->phy.type == e1000_phy_82578) || |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4389 | (hw->phy.type == e1000_phy_82579) || |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4390 | (hw->phy.type == e1000_phy_i217) || |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4391 | (hw->phy.type == e1000_phy_82577)) { |
Bruce Allan | 2b6b168 | 2011-05-13 07:20:09 +0000 | [diff] [blame] | 4392 | ret_val = hw->phy.ops.acquire(hw); |
| 4393 | if (ret_val) |
| 4394 | return; |
| 4395 | ret_val = hw->phy.ops.set_page(hw, |
| 4396 | HV_STATS_PAGE << IGP_PAGE_SHIFT); |
| 4397 | if (ret_val) |
| 4398 | goto release; |
| 4399 | hw->phy.ops.read_reg_page(hw, HV_SCC_UPPER, &phy_data); |
| 4400 | hw->phy.ops.read_reg_page(hw, HV_SCC_LOWER, &phy_data); |
| 4401 | hw->phy.ops.read_reg_page(hw, HV_ECOL_UPPER, &phy_data); |
| 4402 | hw->phy.ops.read_reg_page(hw, HV_ECOL_LOWER, &phy_data); |
| 4403 | hw->phy.ops.read_reg_page(hw, HV_MCC_UPPER, &phy_data); |
| 4404 | hw->phy.ops.read_reg_page(hw, HV_MCC_LOWER, &phy_data); |
| 4405 | hw->phy.ops.read_reg_page(hw, HV_LATECOL_UPPER, &phy_data); |
| 4406 | hw->phy.ops.read_reg_page(hw, HV_LATECOL_LOWER, &phy_data); |
| 4407 | hw->phy.ops.read_reg_page(hw, HV_COLC_UPPER, &phy_data); |
| 4408 | hw->phy.ops.read_reg_page(hw, HV_COLC_LOWER, &phy_data); |
| 4409 | hw->phy.ops.read_reg_page(hw, HV_DC_UPPER, &phy_data); |
| 4410 | hw->phy.ops.read_reg_page(hw, HV_DC_LOWER, &phy_data); |
| 4411 | hw->phy.ops.read_reg_page(hw, HV_TNCRS_UPPER, &phy_data); |
| 4412 | hw->phy.ops.read_reg_page(hw, HV_TNCRS_LOWER, &phy_data); |
| 4413 | release: |
| 4414 | hw->phy.ops.release(hw); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4415 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4416 | } |
| 4417 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4418 | static const struct e1000_mac_operations ich8_mac_ops = { |
Bruce Allan | eb7700d | 2010-06-16 13:27:05 +0000 | [diff] [blame] | 4419 | /* check_mng_mode dependent on mac type */ |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 4420 | .check_for_link = e1000_check_for_copper_link_ich8lan, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4421 | /* cleanup_led dependent on mac type */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4422 | .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, |
| 4423 | .get_bus_info = e1000_get_bus_info_ich8lan, |
Bruce Allan | f4d2dd4 | 2010-01-13 02:05:18 +0000 | [diff] [blame] | 4424 | .set_lan_id = e1000_set_lan_id_single_port, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4425 | .get_link_up_info = e1000_get_link_up_info_ich8lan, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4426 | /* led_on dependent on mac type */ |
| 4427 | /* led_off dependent on mac type */ |
Jeff Kirsher | e2de3eb | 2008-03-28 09:15:11 -0700 | [diff] [blame] | 4428 | .update_mc_addr_list = e1000e_update_mc_addr_list_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4429 | .reset_hw = e1000_reset_hw_ich8lan, |
| 4430 | .init_hw = e1000_init_hw_ich8lan, |
| 4431 | .setup_link = e1000_setup_link_ich8lan, |
| 4432 | .setup_physical_interface= e1000_setup_copper_link_ich8lan, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4433 | /* id_led_init dependent on mac type */ |
Bruce Allan | 57cde76 | 2012-02-22 09:02:58 +0000 | [diff] [blame] | 4434 | .config_collision_dist = e1000e_config_collision_dist_generic, |
Bruce Allan | 69e1e01 | 2012-04-14 03:28:50 +0000 | [diff] [blame] | 4435 | .rar_set = e1000e_rar_set_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4436 | }; |
| 4437 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4438 | static const struct e1000_phy_operations ich8_phy_ops = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4439 | .acquire = e1000_acquire_swflag_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4440 | .check_reset_block = e1000_check_reset_block_ich8lan, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4441 | .commit = NULL, |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4442 | .get_cfg_done = e1000_get_cfg_done_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4443 | .get_cable_length = e1000e_get_cable_length_igp_2, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4444 | .read_reg = e1000e_read_phy_reg_igp, |
| 4445 | .release = e1000_release_swflag_ich8lan, |
| 4446 | .reset = e1000_phy_hw_reset_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4447 | .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan, |
| 4448 | .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4449 | .write_reg = e1000e_write_phy_reg_igp, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4450 | }; |
| 4451 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4452 | static const struct e1000_nvm_operations ich8_nvm_ops = { |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4453 | .acquire = e1000_acquire_nvm_ich8lan, |
| 4454 | .read = e1000_read_nvm_ich8lan, |
| 4455 | .release = e1000_release_nvm_ich8lan, |
Bruce Allan | e85e363 | 2012-02-22 09:03:14 +0000 | [diff] [blame] | 4456 | .reload = e1000e_reload_nvm_generic, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4457 | .update = e1000_update_nvm_checksum_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4458 | .valid_led_default = e1000_valid_led_default_ich8lan, |
Bruce Allan | 94d8186 | 2009-11-20 23:25:26 +0000 | [diff] [blame] | 4459 | .validate = e1000_validate_nvm_checksum_ich8lan, |
| 4460 | .write = e1000_write_nvm_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4461 | }; |
| 4462 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4463 | const struct e1000_info e1000_ich8_info = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4464 | .mac = e1000_ich8lan, |
| 4465 | .flags = FLAG_HAS_WOL |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4466 | | FLAG_IS_ICH |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4467 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4468 | | FLAG_HAS_AMT |
| 4469 | | FLAG_HAS_FLASH |
| 4470 | | FLAG_APME_IN_WUC, |
| 4471 | .pba = 8, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 4472 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 4473 | .get_variants = e1000_get_variants_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4474 | .mac_ops = &ich8_mac_ops, |
| 4475 | .phy_ops = &ich8_phy_ops, |
| 4476 | .nvm_ops = &ich8_nvm_ops, |
| 4477 | }; |
| 4478 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4479 | const struct e1000_info e1000_ich9_info = { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4480 | .mac = e1000_ich9lan, |
| 4481 | .flags = FLAG_HAS_JUMBO_FRAMES |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 4482 | | FLAG_IS_ICH |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4483 | | FLAG_HAS_WOL |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4484 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4485 | | FLAG_HAS_AMT |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4486 | | FLAG_HAS_FLASH |
| 4487 | | FLAG_APME_IN_WUC, |
Bruce Allan | 7f1557e | 2011-12-16 00:46:43 +0000 | [diff] [blame] | 4488 | .pba = 18, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 4489 | .max_hw_frame_size = DEFAULT_JUMBO, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 4490 | .get_variants = e1000_get_variants_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 4491 | .mac_ops = &ich8_mac_ops, |
| 4492 | .phy_ops = &ich8_phy_ops, |
| 4493 | .nvm_ops = &ich8_nvm_ops, |
| 4494 | }; |
| 4495 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4496 | const struct e1000_info e1000_ich10_info = { |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4497 | .mac = e1000_ich10lan, |
| 4498 | .flags = FLAG_HAS_JUMBO_FRAMES |
| 4499 | | FLAG_IS_ICH |
| 4500 | | FLAG_HAS_WOL |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4501 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4502 | | FLAG_HAS_AMT |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4503 | | FLAG_HAS_FLASH |
| 4504 | | FLAG_APME_IN_WUC, |
Bruce Allan | 7f1557e | 2011-12-16 00:46:43 +0000 | [diff] [blame] | 4505 | .pba = 18, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 4506 | .max_hw_frame_size = DEFAULT_JUMBO, |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 4507 | .get_variants = e1000_get_variants_ich8lan, |
| 4508 | .mac_ops = &ich8_mac_ops, |
| 4509 | .phy_ops = &ich8_phy_ops, |
| 4510 | .nvm_ops = &ich8_nvm_ops, |
| 4511 | }; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4512 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4513 | const struct e1000_info e1000_pch_info = { |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4514 | .mac = e1000_pchlan, |
| 4515 | .flags = FLAG_IS_ICH |
| 4516 | | FLAG_HAS_WOL |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4517 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4518 | | FLAG_HAS_AMT |
| 4519 | | FLAG_HAS_FLASH |
| 4520 | | FLAG_HAS_JUMBO_FRAMES |
Bruce Allan | 38eb394 | 2009-11-19 12:34:20 +0000 | [diff] [blame] | 4521 | | FLAG_DISABLE_FC_PAUSE_TIME /* errata */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4522 | | FLAG_APME_IN_WUC, |
Bruce Allan | 8c7bbb9 | 2010-06-16 13:26:41 +0000 | [diff] [blame] | 4523 | .flags2 = FLAG2_HAS_PHY_STATS, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 4524 | .pba = 26, |
| 4525 | .max_hw_frame_size = 4096, |
| 4526 | .get_variants = e1000_get_variants_ich8lan, |
| 4527 | .mac_ops = &ich8_mac_ops, |
| 4528 | .phy_ops = &ich8_phy_ops, |
| 4529 | .nvm_ops = &ich8_nvm_ops, |
| 4530 | }; |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4531 | |
Jeff Kirsher | 8ce9d6c | 2011-09-24 13:23:52 +0000 | [diff] [blame] | 4532 | const struct e1000_info e1000_pch2_info = { |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4533 | .mac = e1000_pch2lan, |
| 4534 | .flags = FLAG_IS_ICH |
| 4535 | | FLAG_HAS_WOL |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4536 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4537 | | FLAG_HAS_AMT |
| 4538 | | FLAG_HAS_FLASH |
| 4539 | | FLAG_HAS_JUMBO_FRAMES |
| 4540 | | FLAG_APME_IN_WUC, |
Bruce Allan | e52997f | 2010-06-16 13:27:49 +0000 | [diff] [blame] | 4541 | .flags2 = FLAG2_HAS_PHY_STATS |
| 4542 | | FLAG2_HAS_EEE, |
Bruce Allan | 828bac8 | 2010-09-29 21:39:37 +0000 | [diff] [blame] | 4543 | .pba = 26, |
Bruce Allan | d3738bb | 2010-06-16 13:27:28 +0000 | [diff] [blame] | 4544 | .max_hw_frame_size = DEFAULT_JUMBO, |
| 4545 | .get_variants = e1000_get_variants_ich8lan, |
| 4546 | .mac_ops = &ich8_mac_ops, |
| 4547 | .phy_ops = &ich8_phy_ops, |
| 4548 | .nvm_ops = &ich8_nvm_ops, |
| 4549 | }; |
Bruce Allan | 2fbe452 | 2012-04-19 03:21:47 +0000 | [diff] [blame] | 4550 | |
| 4551 | const struct e1000_info e1000_pch_lpt_info = { |
| 4552 | .mac = e1000_pch_lpt, |
| 4553 | .flags = FLAG_IS_ICH |
| 4554 | | FLAG_HAS_WOL |
| 4555 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 4556 | | FLAG_HAS_AMT |
| 4557 | | FLAG_HAS_FLASH |
| 4558 | | FLAG_HAS_JUMBO_FRAMES |
| 4559 | | FLAG_APME_IN_WUC, |
| 4560 | .flags2 = FLAG2_HAS_PHY_STATS |
| 4561 | | FLAG2_HAS_EEE, |
| 4562 | .pba = 26, |
| 4563 | .max_hw_frame_size = DEFAULT_JUMBO, |
| 4564 | .get_variants = e1000_get_variants_ich8lan, |
| 4565 | .mac_ops = &ich8_mac_ops, |
| 4566 | .phy_ops = &ich8_phy_ops, |
| 4567 | .nvm_ops = &ich8_nvm_ops, |
| 4568 | }; |