Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel PRO/1000 Linux driver |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 4 | Copyright(c) 1999 - 2008 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 | |
| 29 | /* |
Bruce Allan | 1605927 | 2008-11-21 16:51:06 -0800 | [diff] [blame] | 30 | * 82562G 10/100 Network Connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 31 | * 82562G-2 10/100 Network Connection |
| 32 | * 82562GT 10/100 Network Connection |
| 33 | * 82562GT-2 10/100 Network Connection |
| 34 | * 82562V 10/100 Network Connection |
| 35 | * 82562V-2 10/100 Network Connection |
| 36 | * 82566DC-2 Gigabit Network Connection |
| 37 | * 82566DC Gigabit Network Connection |
| 38 | * 82566DM-2 Gigabit Network Connection |
| 39 | * 82566DM Gigabit Network Connection |
| 40 | * 82566MC Gigabit Network Connection |
| 41 | * 82566MM Gigabit Network Connection |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 42 | * 82567LM Gigabit Network Connection |
| 43 | * 82567LF Gigabit Network Connection |
Bruce Allan | 1605927 | 2008-11-21 16:51:06 -0800 | [diff] [blame] | 44 | * 82567V Gigabit Network Connection |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 45 | * 82567LM-2 Gigabit Network Connection |
| 46 | * 82567LF-2 Gigabit Network Connection |
| 47 | * 82567V-2 Gigabit Network Connection |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 48 | * 82567LF-3 Gigabit Network Connection |
| 49 | * 82567LM-3 Gigabit Network Connection |
Bruce Allan | 2f15f9d | 2008-08-26 18:36:36 -0700 | [diff] [blame] | 50 | * 82567LM-4 Gigabit Network Connection |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 51 | * 82577LM Gigabit Network Connection |
| 52 | * 82577LC Gigabit Network Connection |
| 53 | * 82578DM Gigabit Network Connection |
| 54 | * 82578DC Gigabit Network Connection |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 55 | */ |
| 56 | |
| 57 | #include <linux/netdevice.h> |
| 58 | #include <linux/ethtool.h> |
| 59 | #include <linux/delay.h> |
| 60 | #include <linux/pci.h> |
| 61 | |
| 62 | #include "e1000.h" |
| 63 | |
| 64 | #define ICH_FLASH_GFPREG 0x0000 |
| 65 | #define ICH_FLASH_HSFSTS 0x0004 |
| 66 | #define ICH_FLASH_HSFCTL 0x0006 |
| 67 | #define ICH_FLASH_FADDR 0x0008 |
| 68 | #define ICH_FLASH_FDATA0 0x0010 |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 69 | #define ICH_FLASH_PR0 0x0074 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 70 | |
| 71 | #define ICH_FLASH_READ_COMMAND_TIMEOUT 500 |
| 72 | #define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500 |
| 73 | #define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000 |
| 74 | #define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF |
| 75 | #define ICH_FLASH_CYCLE_REPEAT_COUNT 10 |
| 76 | |
| 77 | #define ICH_CYCLE_READ 0 |
| 78 | #define ICH_CYCLE_WRITE 2 |
| 79 | #define ICH_CYCLE_ERASE 3 |
| 80 | |
| 81 | #define FLASH_GFPREG_BASE_MASK 0x1FFF |
| 82 | #define FLASH_SECTOR_ADDR_SHIFT 12 |
| 83 | |
| 84 | #define ICH_FLASH_SEG_SIZE_256 256 |
| 85 | #define ICH_FLASH_SEG_SIZE_4K 4096 |
| 86 | #define ICH_FLASH_SEG_SIZE_8K 8192 |
| 87 | #define ICH_FLASH_SEG_SIZE_64K 65536 |
| 88 | |
| 89 | |
| 90 | #define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */ |
| 91 | |
| 92 | #define E1000_ICH_MNG_IAMT_MODE 0x2 |
| 93 | |
| 94 | #define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \ |
| 95 | (ID_LED_DEF1_OFF2 << 8) | \ |
| 96 | (ID_LED_DEF1_ON2 << 4) | \ |
| 97 | (ID_LED_DEF1_DEF2)) |
| 98 | |
| 99 | #define E1000_ICH_NVM_SIG_WORD 0x13 |
| 100 | #define E1000_ICH_NVM_SIG_MASK 0xC000 |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 101 | #define E1000_ICH_NVM_VALID_SIG_MASK 0xC0 |
| 102 | #define E1000_ICH_NVM_SIG_VALUE 0x80 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 103 | |
| 104 | #define E1000_ICH8_LAN_INIT_TIMEOUT 1500 |
| 105 | |
| 106 | #define E1000_FEXTNVM_SW_CONFIG 1 |
| 107 | #define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */ |
| 108 | |
| 109 | #define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL |
| 110 | |
| 111 | #define E1000_ICH_RAR_ENTRIES 7 |
| 112 | |
| 113 | #define PHY_PAGE_SHIFT 5 |
| 114 | #define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \ |
| 115 | ((reg) & MAX_PHY_REG_ADDRESS)) |
| 116 | #define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */ |
| 117 | #define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */ |
| 118 | |
| 119 | #define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002 |
| 120 | #define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300 |
| 121 | #define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200 |
| 122 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 123 | #define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */ |
| 124 | |
Bruce Allan | 53ac5a8 | 2009-10-26 11:23:06 +0000 | [diff] [blame] | 125 | #define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */ |
| 126 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 127 | /* SMBus Address Phy Register */ |
| 128 | #define HV_SMB_ADDR PHY_REG(768, 26) |
| 129 | #define HV_SMB_ADDR_PEC_EN 0x0200 |
| 130 | #define HV_SMB_ADDR_VALID 0x0080 |
| 131 | |
| 132 | /* Strapping Option Register - RO */ |
| 133 | #define E1000_STRAP 0x0000C |
| 134 | #define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000 |
| 135 | #define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17 |
| 136 | |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 137 | /* OEM Bits Phy Register */ |
| 138 | #define HV_OEM_BITS PHY_REG(768, 25) |
| 139 | #define HV_OEM_BITS_LPLU 0x0004 /* Low Power Link Up */ |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 140 | #define HV_OEM_BITS_GBE_DIS 0x0040 /* Gigabit Disable */ |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 141 | #define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */ |
| 142 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 143 | /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ |
| 144 | /* Offset 04h HSFSTS */ |
| 145 | union ich8_hws_flash_status { |
| 146 | struct ich8_hsfsts { |
| 147 | u16 flcdone :1; /* bit 0 Flash Cycle Done */ |
| 148 | u16 flcerr :1; /* bit 1 Flash Cycle Error */ |
| 149 | u16 dael :1; /* bit 2 Direct Access error Log */ |
| 150 | u16 berasesz :2; /* bit 4:3 Sector Erase Size */ |
| 151 | u16 flcinprog :1; /* bit 5 flash cycle in Progress */ |
| 152 | u16 reserved1 :2; /* bit 13:6 Reserved */ |
| 153 | u16 reserved2 :6; /* bit 13:6 Reserved */ |
| 154 | u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */ |
| 155 | u16 flockdn :1; /* bit 15 Flash Config Lock-Down */ |
| 156 | } hsf_status; |
| 157 | u16 regval; |
| 158 | }; |
| 159 | |
| 160 | /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */ |
| 161 | /* Offset 06h FLCTL */ |
| 162 | union ich8_hws_flash_ctrl { |
| 163 | struct ich8_hsflctl { |
| 164 | u16 flcgo :1; /* 0 Flash Cycle Go */ |
| 165 | u16 flcycle :2; /* 2:1 Flash Cycle */ |
| 166 | u16 reserved :5; /* 7:3 Reserved */ |
| 167 | u16 fldbcount :2; /* 9:8 Flash Data Byte Count */ |
| 168 | u16 flockdn :6; /* 15:10 Reserved */ |
| 169 | } hsf_ctrl; |
| 170 | u16 regval; |
| 171 | }; |
| 172 | |
| 173 | /* ICH Flash Region Access Permissions */ |
| 174 | union ich8_hws_flash_regacc { |
| 175 | struct ich8_flracc { |
| 176 | u32 grra :8; /* 0:7 GbE region Read Access */ |
| 177 | u32 grwa :8; /* 8:15 GbE region Write Access */ |
| 178 | u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */ |
| 179 | u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */ |
| 180 | } hsf_flregacc; |
| 181 | u16 regval; |
| 182 | }; |
| 183 | |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 184 | /* ICH Flash Protected Region */ |
| 185 | union ich8_flash_protected_range { |
| 186 | struct ich8_pr { |
| 187 | u32 base:13; /* 0:12 Protected Range Base */ |
| 188 | u32 reserved1:2; /* 13:14 Reserved */ |
| 189 | u32 rpe:1; /* 15 Read Protection Enable */ |
| 190 | u32 limit:13; /* 16:28 Protected Range Limit */ |
| 191 | u32 reserved2:2; /* 29:30 Reserved */ |
| 192 | u32 wpe:1; /* 31 Write Protection Enable */ |
| 193 | } range; |
| 194 | u32 regval; |
| 195 | }; |
| 196 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 197 | static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw); |
| 198 | static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw); |
| 199 | static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw); |
| 200 | static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw); |
| 201 | static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank); |
| 202 | static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw, |
| 203 | u32 offset, u8 byte); |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 204 | static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, |
| 205 | u8 *data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 206 | static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset, |
| 207 | u16 *data); |
| 208 | static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, |
| 209 | u8 size, u16 *data); |
| 210 | static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw); |
| 211 | static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw); |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 212 | static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 213 | static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw); |
| 214 | static s32 e1000_led_on_ich8lan(struct e1000_hw *hw); |
| 215 | static s32 e1000_led_off_ich8lan(struct e1000_hw *hw); |
| 216 | static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw); |
| 217 | static s32 e1000_setup_led_pchlan(struct e1000_hw *hw); |
| 218 | static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw); |
| 219 | static s32 e1000_led_on_pchlan(struct e1000_hw *hw); |
| 220 | static s32 e1000_led_off_pchlan(struct e1000_hw *hw); |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 221 | static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active); |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 222 | static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 223 | |
| 224 | static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg) |
| 225 | { |
| 226 | return readw(hw->flash_address + reg); |
| 227 | } |
| 228 | |
| 229 | static inline u32 __er32flash(struct e1000_hw *hw, unsigned long reg) |
| 230 | { |
| 231 | return readl(hw->flash_address + reg); |
| 232 | } |
| 233 | |
| 234 | static inline void __ew16flash(struct e1000_hw *hw, unsigned long reg, u16 val) |
| 235 | { |
| 236 | writew(val, hw->flash_address + reg); |
| 237 | } |
| 238 | |
| 239 | static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val) |
| 240 | { |
| 241 | writel(val, hw->flash_address + reg); |
| 242 | } |
| 243 | |
| 244 | #define er16flash(reg) __er16flash(hw, (reg)) |
| 245 | #define er32flash(reg) __er32flash(hw, (reg)) |
| 246 | #define ew16flash(reg,val) __ew16flash(hw, (reg), (val)) |
| 247 | #define ew32flash(reg,val) __ew32flash(hw, (reg), (val)) |
| 248 | |
| 249 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 250 | * e1000_init_phy_params_pchlan - Initialize PHY function pointers |
| 251 | * @hw: pointer to the HW structure |
| 252 | * |
| 253 | * Initialize family-specific PHY parameters and function pointers. |
| 254 | **/ |
| 255 | static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw) |
| 256 | { |
| 257 | struct e1000_phy_info *phy = &hw->phy; |
| 258 | s32 ret_val = 0; |
| 259 | |
| 260 | phy->addr = 1; |
| 261 | phy->reset_delay_us = 100; |
| 262 | |
| 263 | phy->ops.check_polarity = e1000_check_polarity_ife_ich8lan; |
| 264 | phy->ops.read_phy_reg = e1000_read_phy_reg_hv; |
Bruce Allan | 5ccdcec | 2009-10-26 11:24:02 +0000 | [diff] [blame] | 265 | phy->ops.read_phy_reg_locked = e1000_read_phy_reg_hv_locked; |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 266 | phy->ops.set_d0_lplu_state = e1000_set_lplu_state_pchlan; |
| 267 | phy->ops.set_d3_lplu_state = e1000_set_lplu_state_pchlan; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 268 | phy->ops.write_phy_reg = e1000_write_phy_reg_hv; |
Bruce Allan | 5ccdcec | 2009-10-26 11:24:02 +0000 | [diff] [blame] | 269 | phy->ops.write_phy_reg_locked = e1000_write_phy_reg_hv_locked; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 270 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
| 271 | |
| 272 | phy->id = e1000_phy_unknown; |
| 273 | e1000e_get_phy_id(hw); |
| 274 | phy->type = e1000e_get_phy_type_from_id(phy->id); |
| 275 | |
| 276 | if (phy->type == e1000_phy_82577) { |
| 277 | phy->ops.check_polarity = e1000_check_polarity_82577; |
| 278 | phy->ops.force_speed_duplex = |
| 279 | e1000_phy_force_speed_duplex_82577; |
| 280 | phy->ops.get_cable_length = e1000_get_cable_length_82577; |
| 281 | phy->ops.get_phy_info = e1000_get_phy_info_82577; |
| 282 | phy->ops.commit_phy = e1000e_phy_sw_reset; |
| 283 | } |
| 284 | |
| 285 | return ret_val; |
| 286 | } |
| 287 | |
| 288 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 289 | * e1000_init_phy_params_ich8lan - Initialize PHY function pointers |
| 290 | * @hw: pointer to the HW structure |
| 291 | * |
| 292 | * Initialize family-specific PHY parameters and function pointers. |
| 293 | **/ |
| 294 | static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw) |
| 295 | { |
| 296 | struct e1000_phy_info *phy = &hw->phy; |
| 297 | s32 ret_val; |
| 298 | u16 i = 0; |
| 299 | |
| 300 | phy->addr = 1; |
| 301 | phy->reset_delay_us = 100; |
| 302 | |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 303 | /* |
| 304 | * We may need to do this twice - once for IGP and if that fails, |
| 305 | * we'll set BM func pointers and try again |
| 306 | */ |
| 307 | ret_val = e1000e_determine_phy_address(hw); |
| 308 | if (ret_val) { |
| 309 | hw->phy.ops.write_phy_reg = e1000e_write_phy_reg_bm; |
| 310 | hw->phy.ops.read_phy_reg = e1000e_read_phy_reg_bm; |
| 311 | ret_val = e1000e_determine_phy_address(hw); |
| 312 | if (ret_val) |
| 313 | return ret_val; |
| 314 | } |
| 315 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 316 | phy->id = 0; |
| 317 | while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) && |
| 318 | (i++ < 100)) { |
| 319 | msleep(1); |
| 320 | ret_val = e1000e_get_phy_id(hw); |
| 321 | if (ret_val) |
| 322 | return ret_val; |
| 323 | } |
| 324 | |
| 325 | /* Verify phy id */ |
| 326 | switch (phy->id) { |
| 327 | case IGP03E1000_E_PHY_ID: |
| 328 | phy->type = e1000_phy_igp_3; |
| 329 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
Bruce Allan | 5ccdcec | 2009-10-26 11:24:02 +0000 | [diff] [blame] | 330 | phy->ops.read_phy_reg_locked = e1000e_read_phy_reg_igp_locked; |
| 331 | phy->ops.write_phy_reg_locked = e1000e_write_phy_reg_igp_locked; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 332 | break; |
| 333 | case IFE_E_PHY_ID: |
| 334 | case IFE_PLUS_E_PHY_ID: |
| 335 | case IFE_C_E_PHY_ID: |
| 336 | phy->type = e1000_phy_ife; |
| 337 | phy->autoneg_mask = E1000_ALL_NOT_GIG; |
| 338 | break; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 339 | case BME1000_E_PHY_ID: |
| 340 | phy->type = e1000_phy_bm; |
| 341 | phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; |
| 342 | hw->phy.ops.read_phy_reg = e1000e_read_phy_reg_bm; |
| 343 | hw->phy.ops.write_phy_reg = e1000e_write_phy_reg_bm; |
| 344 | hw->phy.ops.commit_phy = e1000e_phy_sw_reset; |
| 345 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 346 | default: |
| 347 | return -E1000_ERR_PHY; |
| 348 | break; |
| 349 | } |
| 350 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 351 | phy->ops.check_polarity = e1000_check_polarity_ife_ich8lan; |
| 352 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 353 | return 0; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers |
| 358 | * @hw: pointer to the HW structure |
| 359 | * |
| 360 | * Initialize family-specific NVM parameters and function |
| 361 | * pointers. |
| 362 | **/ |
| 363 | static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw) |
| 364 | { |
| 365 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 366 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 367 | u32 gfpreg, sector_base_addr, sector_end_addr; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 368 | u16 i; |
| 369 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 370 | /* Can't read flash registers if the register set isn't mapped. */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 371 | if (!hw->flash_address) { |
| 372 | hw_dbg(hw, "ERROR: Flash registers not mapped\n"); |
| 373 | return -E1000_ERR_CONFIG; |
| 374 | } |
| 375 | |
| 376 | nvm->type = e1000_nvm_flash_sw; |
| 377 | |
| 378 | gfpreg = er32flash(ICH_FLASH_GFPREG); |
| 379 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 380 | /* |
| 381 | * sector_X_addr is a "sector"-aligned address (4096 bytes) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 382 | * Add 1 to sector_end_addr since this sector is included in |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 383 | * the overall size. |
| 384 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 385 | sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK; |
| 386 | sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1; |
| 387 | |
| 388 | /* flash_base_addr is byte-aligned */ |
| 389 | nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT; |
| 390 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 391 | /* |
| 392 | * find total size of the NVM, then cut in half since the total |
| 393 | * size represents two separate NVM banks. |
| 394 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 395 | nvm->flash_bank_size = (sector_end_addr - sector_base_addr) |
| 396 | << FLASH_SECTOR_ADDR_SHIFT; |
| 397 | nvm->flash_bank_size /= 2; |
| 398 | /* Adjust to word count */ |
| 399 | nvm->flash_bank_size /= sizeof(u16); |
| 400 | |
| 401 | nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS; |
| 402 | |
| 403 | /* Clear shadow ram */ |
| 404 | for (i = 0; i < nvm->word_size; i++) { |
| 405 | dev_spec->shadow_ram[i].modified = 0; |
| 406 | dev_spec->shadow_ram[i].value = 0xFFFF; |
| 407 | } |
| 408 | |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * e1000_init_mac_params_ich8lan - Initialize MAC function pointers |
| 414 | * @hw: pointer to the HW structure |
| 415 | * |
| 416 | * Initialize family-specific MAC parameters and function |
| 417 | * pointers. |
| 418 | **/ |
| 419 | static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter) |
| 420 | { |
| 421 | struct e1000_hw *hw = &adapter->hw; |
| 422 | struct e1000_mac_info *mac = &hw->mac; |
| 423 | |
| 424 | /* Set media type function pointer */ |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 425 | hw->phy.media_type = e1000_media_type_copper; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 426 | |
| 427 | /* Set mta register count */ |
| 428 | mac->mta_reg_count = 32; |
| 429 | /* Set rar entry count */ |
| 430 | mac->rar_entry_count = E1000_ICH_RAR_ENTRIES; |
| 431 | if (mac->type == e1000_ich8lan) |
| 432 | mac->rar_entry_count--; |
| 433 | /* Set if manageability features are enabled. */ |
| 434 | mac->arc_subsystem_valid = 1; |
| 435 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 436 | /* LED operations */ |
| 437 | switch (mac->type) { |
| 438 | case e1000_ich8lan: |
| 439 | case e1000_ich9lan: |
| 440 | case e1000_ich10lan: |
| 441 | /* ID LED init */ |
| 442 | mac->ops.id_led_init = e1000e_id_led_init; |
| 443 | /* setup LED */ |
| 444 | mac->ops.setup_led = e1000e_setup_led_generic; |
| 445 | /* cleanup LED */ |
| 446 | mac->ops.cleanup_led = e1000_cleanup_led_ich8lan; |
| 447 | /* turn on/off LED */ |
| 448 | mac->ops.led_on = e1000_led_on_ich8lan; |
| 449 | mac->ops.led_off = e1000_led_off_ich8lan; |
| 450 | break; |
| 451 | case e1000_pchlan: |
| 452 | /* ID LED init */ |
| 453 | mac->ops.id_led_init = e1000_id_led_init_pchlan; |
| 454 | /* setup LED */ |
| 455 | mac->ops.setup_led = e1000_setup_led_pchlan; |
| 456 | /* cleanup LED */ |
| 457 | mac->ops.cleanup_led = e1000_cleanup_led_pchlan; |
| 458 | /* turn on/off LED */ |
| 459 | mac->ops.led_on = e1000_led_on_pchlan; |
| 460 | mac->ops.led_off = e1000_led_off_pchlan; |
| 461 | break; |
| 462 | default: |
| 463 | break; |
| 464 | } |
| 465 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 466 | /* Enable PCS Lock-loss workaround for ICH8 */ |
| 467 | if (mac->type == e1000_ich8lan) |
| 468 | e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, 1); |
| 469 | |
| 470 | return 0; |
| 471 | } |
| 472 | |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 473 | /** |
| 474 | * e1000_check_for_copper_link_ich8lan - Check for link (Copper) |
| 475 | * @hw: pointer to the HW structure |
| 476 | * |
| 477 | * Checks to see of the link status of the hardware has changed. If a |
| 478 | * change in link status has been detected, then we read the PHY registers |
| 479 | * to get the current speed/duplex if link exists. |
| 480 | **/ |
| 481 | static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) |
| 482 | { |
| 483 | struct e1000_mac_info *mac = &hw->mac; |
| 484 | s32 ret_val; |
| 485 | bool link; |
| 486 | |
| 487 | /* |
| 488 | * We only want to go out to the PHY registers to see if Auto-Neg |
| 489 | * has completed and/or if our link status has changed. The |
| 490 | * get_link_status flag is set upon receiving a Link Status |
| 491 | * Change or Rx Sequence Error interrupt. |
| 492 | */ |
| 493 | if (!mac->get_link_status) { |
| 494 | ret_val = 0; |
| 495 | goto out; |
| 496 | } |
| 497 | |
| 498 | if (hw->mac.type == e1000_pchlan) { |
| 499 | ret_val = e1000e_write_kmrn_reg(hw, |
| 500 | E1000_KMRNCTRLSTA_K1_CONFIG, |
| 501 | E1000_KMRNCTRLSTA_K1_ENABLE); |
| 502 | if (ret_val) |
| 503 | goto out; |
| 504 | } |
| 505 | |
| 506 | /* |
| 507 | * First we want to see if the MII Status Register reports |
| 508 | * link. If so, then we want to get the current speed/duplex |
| 509 | * of the PHY. |
| 510 | */ |
| 511 | ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); |
| 512 | if (ret_val) |
| 513 | goto out; |
| 514 | |
| 515 | if (!link) |
| 516 | goto out; /* No link detected */ |
| 517 | |
| 518 | mac->get_link_status = false; |
| 519 | |
| 520 | if (hw->phy.type == e1000_phy_82578) { |
| 521 | ret_val = e1000_link_stall_workaround_hv(hw); |
| 522 | if (ret_val) |
| 523 | goto out; |
| 524 | } |
| 525 | |
| 526 | /* |
| 527 | * Check if there was DownShift, must be checked |
| 528 | * immediately after link-up |
| 529 | */ |
| 530 | e1000e_check_downshift(hw); |
| 531 | |
| 532 | /* |
| 533 | * If we are forcing speed/duplex, then we simply return since |
| 534 | * we have already determined whether we have link or not. |
| 535 | */ |
| 536 | if (!mac->autoneg) { |
| 537 | ret_val = -E1000_ERR_CONFIG; |
| 538 | goto out; |
| 539 | } |
| 540 | |
| 541 | /* |
| 542 | * Auto-Neg is enabled. Auto Speed Detection takes care |
| 543 | * of MAC speed/duplex configuration. So we only need to |
| 544 | * configure Collision Distance in the MAC. |
| 545 | */ |
| 546 | e1000e_config_collision_dist(hw); |
| 547 | |
| 548 | /* |
| 549 | * Configure Flow Control now that Auto-Neg has completed. |
| 550 | * First, we need to restore the desired flow control |
| 551 | * settings because we may have had to re-autoneg with a |
| 552 | * different link partner. |
| 553 | */ |
| 554 | ret_val = e1000e_config_fc_after_link_up(hw); |
| 555 | if (ret_val) |
| 556 | hw_dbg(hw, "Error configuring flow control\n"); |
| 557 | |
| 558 | out: |
| 559 | return ret_val; |
| 560 | } |
| 561 | |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 562 | static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 563 | { |
| 564 | struct e1000_hw *hw = &adapter->hw; |
| 565 | s32 rc; |
| 566 | |
| 567 | rc = e1000_init_mac_params_ich8lan(adapter); |
| 568 | if (rc) |
| 569 | return rc; |
| 570 | |
| 571 | rc = e1000_init_nvm_params_ich8lan(hw); |
| 572 | if (rc) |
| 573 | return rc; |
| 574 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 575 | if (hw->mac.type == e1000_pchlan) |
| 576 | rc = e1000_init_phy_params_pchlan(hw); |
| 577 | else |
| 578 | rc = e1000_init_phy_params_ich8lan(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 579 | if (rc) |
| 580 | return rc; |
| 581 | |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 582 | if (adapter->hw.phy.type == e1000_phy_ife) { |
| 583 | adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES; |
| 584 | adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN; |
| 585 | } |
| 586 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 587 | if ((adapter->hw.mac.type == e1000_ich8lan) && |
| 588 | (adapter->hw.phy.type == e1000_phy_igp_3)) |
| 589 | adapter->flags |= FLAG_LSC_GIG_SPEED_DROP; |
| 590 | |
| 591 | return 0; |
| 592 | } |
| 593 | |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 594 | static DEFINE_MUTEX(nvm_mutex); |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 595 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 596 | /** |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 597 | * e1000_acquire_nvm_ich8lan - Acquire NVM mutex |
| 598 | * @hw: pointer to the HW structure |
| 599 | * |
| 600 | * Acquires the mutex for performing NVM operations. |
| 601 | **/ |
| 602 | static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw) |
| 603 | { |
| 604 | mutex_lock(&nvm_mutex); |
| 605 | |
| 606 | return 0; |
| 607 | } |
| 608 | |
| 609 | /** |
| 610 | * e1000_release_nvm_ich8lan - Release NVM mutex |
| 611 | * @hw: pointer to the HW structure |
| 612 | * |
| 613 | * Releases the mutex used while performing NVM operations. |
| 614 | **/ |
| 615 | static void e1000_release_nvm_ich8lan(struct e1000_hw *hw) |
| 616 | { |
| 617 | mutex_unlock(&nvm_mutex); |
| 618 | |
| 619 | return; |
| 620 | } |
| 621 | |
| 622 | static DEFINE_MUTEX(swflag_mutex); |
| 623 | |
| 624 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 625 | * e1000_acquire_swflag_ich8lan - Acquire software control flag |
| 626 | * @hw: pointer to the HW structure |
| 627 | * |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 628 | * Acquires the software control flag for performing PHY and select |
| 629 | * MAC CSR accesses. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 630 | **/ |
| 631 | static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) |
| 632 | { |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 633 | u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT; |
| 634 | s32 ret_val = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 635 | |
Linus Torvalds | 95b866d | 2008-10-03 09:18:17 -0700 | [diff] [blame] | 636 | might_sleep(); |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 637 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 638 | mutex_lock(&swflag_mutex); |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 639 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 640 | while (timeout) { |
| 641 | extcnf_ctrl = er32(EXTCNF_CTRL); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 642 | if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)) |
| 643 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 644 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 645 | mdelay(1); |
| 646 | timeout--; |
| 647 | } |
| 648 | |
| 649 | if (!timeout) { |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 650 | hw_dbg(hw, "SW/FW/HW has locked the resource for too long.\n"); |
| 651 | ret_val = -E1000_ERR_CONFIG; |
| 652 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 653 | } |
| 654 | |
Bruce Allan | 53ac5a8 | 2009-10-26 11:23:06 +0000 | [diff] [blame] | 655 | timeout = SW_FLAG_TIMEOUT; |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 656 | |
| 657 | extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; |
| 658 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 659 | |
| 660 | while (timeout) { |
| 661 | extcnf_ctrl = er32(EXTCNF_CTRL); |
| 662 | if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) |
| 663 | break; |
| 664 | |
| 665 | mdelay(1); |
| 666 | timeout--; |
| 667 | } |
| 668 | |
| 669 | if (!timeout) { |
| 670 | hw_dbg(hw, "Failed to acquire the semaphore.\n"); |
| 671 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; |
| 672 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
| 673 | ret_val = -E1000_ERR_CONFIG; |
| 674 | goto out; |
| 675 | } |
| 676 | |
| 677 | out: |
| 678 | if (ret_val) |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 679 | mutex_unlock(&swflag_mutex); |
Bruce Allan | 373a88d | 2009-08-07 07:41:37 +0000 | [diff] [blame] | 680 | |
| 681 | return ret_val; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | /** |
| 685 | * e1000_release_swflag_ich8lan - Release software control flag |
| 686 | * @hw: pointer to the HW structure |
| 687 | * |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 688 | * Releases the software control flag for performing PHY and select |
| 689 | * MAC CSR accesses. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 690 | **/ |
| 691 | static void e1000_release_swflag_ich8lan(struct e1000_hw *hw) |
| 692 | { |
| 693 | u32 extcnf_ctrl; |
| 694 | |
| 695 | extcnf_ctrl = er32(EXTCNF_CTRL); |
| 696 | extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; |
| 697 | ew32(EXTCNF_CTRL, extcnf_ctrl); |
Thomas Gleixner | 717d438 | 2008-10-02 16:33:40 -0700 | [diff] [blame] | 698 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 699 | mutex_unlock(&swflag_mutex); |
| 700 | |
| 701 | return; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 702 | } |
| 703 | |
| 704 | /** |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 705 | * e1000_check_mng_mode_ich8lan - Checks management mode |
| 706 | * @hw: pointer to the HW structure |
| 707 | * |
| 708 | * This checks if the adapter has manageability enabled. |
| 709 | * This is a function pointer entry point only called by read/write |
| 710 | * routines for the PHY and NVM parts. |
| 711 | **/ |
| 712 | static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw) |
| 713 | { |
| 714 | u32 fwsm = er32(FWSM); |
| 715 | |
| 716 | return (fwsm & E1000_FWSM_MODE_MASK) == |
| 717 | (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT); |
| 718 | } |
| 719 | |
| 720 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 721 | * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked |
| 722 | * @hw: pointer to the HW structure |
| 723 | * |
| 724 | * Checks if firmware is blocking the reset of the PHY. |
| 725 | * This is a function pointer entry point only called by |
| 726 | * reset routines. |
| 727 | **/ |
| 728 | static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw) |
| 729 | { |
| 730 | u32 fwsm; |
| 731 | |
| 732 | fwsm = er32(FWSM); |
| 733 | |
| 734 | return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? 0 : E1000_BLK_PHY_RESET; |
| 735 | } |
| 736 | |
| 737 | /** |
| 738 | * e1000_phy_force_speed_duplex_ich8lan - Force PHY speed & duplex |
| 739 | * @hw: pointer to the HW structure |
| 740 | * |
| 741 | * Forces the speed and duplex settings of the PHY. |
| 742 | * This is a function pointer entry point only called by |
| 743 | * PHY setup routines. |
| 744 | **/ |
| 745 | static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw) |
| 746 | { |
| 747 | struct e1000_phy_info *phy = &hw->phy; |
| 748 | s32 ret_val; |
| 749 | u16 data; |
| 750 | bool link; |
| 751 | |
| 752 | if (phy->type != e1000_phy_ife) { |
| 753 | ret_val = e1000e_phy_force_speed_duplex_igp(hw); |
| 754 | return ret_val; |
| 755 | } |
| 756 | |
| 757 | ret_val = e1e_rphy(hw, PHY_CONTROL, &data); |
| 758 | if (ret_val) |
| 759 | return ret_val; |
| 760 | |
| 761 | e1000e_phy_force_speed_duplex_setup(hw, &data); |
| 762 | |
| 763 | ret_val = e1e_wphy(hw, PHY_CONTROL, data); |
| 764 | if (ret_val) |
| 765 | return ret_val; |
| 766 | |
| 767 | /* Disable MDI-X support for 10/100 */ |
| 768 | ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &data); |
| 769 | if (ret_val) |
| 770 | return ret_val; |
| 771 | |
| 772 | data &= ~IFE_PMC_AUTO_MDIX; |
| 773 | data &= ~IFE_PMC_FORCE_MDIX; |
| 774 | |
| 775 | ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, data); |
| 776 | if (ret_val) |
| 777 | return ret_val; |
| 778 | |
| 779 | hw_dbg(hw, "IFE PMC: %X\n", data); |
| 780 | |
| 781 | udelay(1); |
| 782 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 783 | if (phy->autoneg_wait_to_complete) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 784 | hw_dbg(hw, "Waiting for forced speed/duplex link on IFE phy.\n"); |
| 785 | |
| 786 | ret_val = e1000e_phy_has_link_generic(hw, |
| 787 | PHY_FORCE_LIMIT, |
| 788 | 100000, |
| 789 | &link); |
| 790 | if (ret_val) |
| 791 | return ret_val; |
| 792 | |
| 793 | if (!link) |
| 794 | hw_dbg(hw, "Link taking longer than expected.\n"); |
| 795 | |
| 796 | /* Try once more */ |
| 797 | ret_val = e1000e_phy_has_link_generic(hw, |
| 798 | PHY_FORCE_LIMIT, |
| 799 | 100000, |
| 800 | &link); |
| 801 | if (ret_val) |
| 802 | return ret_val; |
| 803 | } |
| 804 | |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | /** |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 809 | * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration |
| 810 | * @hw: pointer to the HW structure |
| 811 | * |
| 812 | * SW should configure the LCD from the NVM extended configuration region |
| 813 | * as a workaround for certain parts. |
| 814 | **/ |
| 815 | static s32 e1000_sw_lcd_config_ich8lan(struct e1000_hw *hw) |
| 816 | { |
| 817 | struct e1000_phy_info *phy = &hw->phy; |
| 818 | u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask; |
| 819 | s32 ret_val; |
| 820 | u16 word_addr, reg_data, reg_addr, phy_page = 0; |
| 821 | |
| 822 | ret_val = hw->phy.ops.acquire_phy(hw); |
| 823 | if (ret_val) |
| 824 | return ret_val; |
| 825 | |
| 826 | /* |
| 827 | * Initialize the PHY from the NVM on ICH platforms. This |
| 828 | * is needed due to an issue where the NVM configuration is |
| 829 | * not properly autoloaded after power transitions. |
| 830 | * Therefore, after each PHY reset, we will load the |
| 831 | * configuration data out of the NVM manually. |
| 832 | */ |
| 833 | if ((hw->mac.type == e1000_ich8lan && phy->type == e1000_phy_igp_3) || |
| 834 | (hw->mac.type == e1000_pchlan)) { |
| 835 | struct e1000_adapter *adapter = hw->adapter; |
| 836 | |
| 837 | /* Check if SW needs to configure the PHY */ |
| 838 | if ((adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_M_AMT) || |
| 839 | (adapter->pdev->device == E1000_DEV_ID_ICH8_IGP_M) || |
| 840 | (hw->mac.type == e1000_pchlan)) |
| 841 | sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M; |
| 842 | else |
| 843 | sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG; |
| 844 | |
| 845 | data = er32(FEXTNVM); |
| 846 | if (!(data & sw_cfg_mask)) |
| 847 | goto out; |
| 848 | |
| 849 | /* Wait for basic configuration completes before proceeding */ |
| 850 | e1000_lan_init_done_ich8lan(hw); |
| 851 | |
| 852 | /* |
| 853 | * Make sure HW does not configure LCD from PHY |
| 854 | * extended configuration before SW configuration |
| 855 | */ |
| 856 | data = er32(EXTCNF_CTRL); |
| 857 | if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE) |
| 858 | goto out; |
| 859 | |
| 860 | cnf_size = er32(EXTCNF_SIZE); |
| 861 | cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK; |
| 862 | cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT; |
| 863 | if (!cnf_size) |
| 864 | goto out; |
| 865 | |
| 866 | cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK; |
| 867 | cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT; |
| 868 | |
| 869 | if (!(data & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) && |
| 870 | (hw->mac.type == e1000_pchlan)) { |
| 871 | /* |
| 872 | * HW configures the SMBus address and LEDs when the |
| 873 | * OEM and LCD Write Enable bits are set in the NVM. |
| 874 | * When both NVM bits are cleared, SW will configure |
| 875 | * them instead. |
| 876 | */ |
| 877 | data = er32(STRAP); |
| 878 | data &= E1000_STRAP_SMBUS_ADDRESS_MASK; |
| 879 | reg_data = data >> E1000_STRAP_SMBUS_ADDRESS_SHIFT; |
| 880 | reg_data |= HV_SMB_ADDR_PEC_EN | HV_SMB_ADDR_VALID; |
| 881 | ret_val = e1000_write_phy_reg_hv_locked(hw, HV_SMB_ADDR, |
| 882 | reg_data); |
| 883 | if (ret_val) |
| 884 | goto out; |
| 885 | |
| 886 | data = er32(LEDCTL); |
| 887 | ret_val = e1000_write_phy_reg_hv_locked(hw, |
| 888 | HV_LED_CONFIG, |
| 889 | (u16)data); |
| 890 | if (ret_val) |
| 891 | goto out; |
| 892 | } |
| 893 | /* Configure LCD from extended configuration region. */ |
| 894 | |
| 895 | /* cnf_base_addr is in DWORD */ |
| 896 | word_addr = (u16)(cnf_base_addr << 1); |
| 897 | |
| 898 | for (i = 0; i < cnf_size; i++) { |
| 899 | ret_val = e1000_read_nvm(hw, (word_addr + i * 2), 1, |
| 900 | ®_data); |
| 901 | if (ret_val) |
| 902 | goto out; |
| 903 | |
| 904 | ret_val = e1000_read_nvm(hw, (word_addr + i * 2 + 1), |
| 905 | 1, ®_addr); |
| 906 | if (ret_val) |
| 907 | goto out; |
| 908 | |
| 909 | /* Save off the PHY page for future writes. */ |
| 910 | if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) { |
| 911 | phy_page = reg_data; |
| 912 | continue; |
| 913 | } |
| 914 | |
| 915 | reg_addr &= PHY_REG_MASK; |
| 916 | reg_addr |= phy_page; |
| 917 | |
| 918 | ret_val = phy->ops.write_phy_reg_locked(hw, |
| 919 | (u32)reg_addr, |
| 920 | reg_data); |
| 921 | if (ret_val) |
| 922 | goto out; |
| 923 | } |
| 924 | } |
| 925 | |
| 926 | out: |
| 927 | hw->phy.ops.release_phy(hw); |
| 928 | return ret_val; |
| 929 | } |
| 930 | |
| 931 | /** |
| 932 | * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration |
| 933 | * @hw: pointer to the HW structure |
| 934 | * @d0_state: boolean if entering d0 or d3 device state |
| 935 | * |
| 936 | * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are |
| 937 | * collectively called OEM bits. The OEM Write Enable bit and SW Config bit |
| 938 | * in NVM determines whether HW should configure LPLU and Gbe Disable. |
| 939 | **/ |
| 940 | static s32 e1000_oem_bits_config_ich8lan(struct e1000_hw *hw, bool d0_state) |
| 941 | { |
| 942 | s32 ret_val = 0; |
| 943 | u32 mac_reg; |
| 944 | u16 oem_reg; |
| 945 | |
| 946 | if (hw->mac.type != e1000_pchlan) |
| 947 | return ret_val; |
| 948 | |
| 949 | ret_val = hw->phy.ops.acquire_phy(hw); |
| 950 | if (ret_val) |
| 951 | return ret_val; |
| 952 | |
| 953 | mac_reg = er32(EXTCNF_CTRL); |
| 954 | if (mac_reg & E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE) |
| 955 | goto out; |
| 956 | |
| 957 | mac_reg = er32(FEXTNVM); |
| 958 | if (!(mac_reg & E1000_FEXTNVM_SW_CONFIG_ICH8M)) |
| 959 | goto out; |
| 960 | |
| 961 | mac_reg = er32(PHY_CTRL); |
| 962 | |
| 963 | ret_val = hw->phy.ops.read_phy_reg_locked(hw, HV_OEM_BITS, &oem_reg); |
| 964 | if (ret_val) |
| 965 | goto out; |
| 966 | |
| 967 | oem_reg &= ~(HV_OEM_BITS_GBE_DIS | HV_OEM_BITS_LPLU); |
| 968 | |
| 969 | if (d0_state) { |
| 970 | if (mac_reg & E1000_PHY_CTRL_GBE_DISABLE) |
| 971 | oem_reg |= HV_OEM_BITS_GBE_DIS; |
| 972 | |
| 973 | if (mac_reg & E1000_PHY_CTRL_D0A_LPLU) |
| 974 | oem_reg |= HV_OEM_BITS_LPLU; |
| 975 | } else { |
| 976 | if (mac_reg & E1000_PHY_CTRL_NOND0A_GBE_DISABLE) |
| 977 | oem_reg |= HV_OEM_BITS_GBE_DIS; |
| 978 | |
| 979 | if (mac_reg & E1000_PHY_CTRL_NOND0A_LPLU) |
| 980 | oem_reg |= HV_OEM_BITS_LPLU; |
| 981 | } |
| 982 | /* Restart auto-neg to activate the bits */ |
| 983 | oem_reg |= HV_OEM_BITS_RESTART_AN; |
| 984 | ret_val = hw->phy.ops.write_phy_reg_locked(hw, HV_OEM_BITS, oem_reg); |
| 985 | |
| 986 | out: |
| 987 | hw->phy.ops.release_phy(hw); |
| 988 | |
| 989 | return ret_val; |
| 990 | } |
| 991 | |
| 992 | |
| 993 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 994 | * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be |
| 995 | * done after every PHY reset. |
| 996 | **/ |
| 997 | static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw) |
| 998 | { |
| 999 | s32 ret_val = 0; |
| 1000 | |
| 1001 | if (hw->mac.type != e1000_pchlan) |
| 1002 | return ret_val; |
| 1003 | |
| 1004 | if (((hw->phy.type == e1000_phy_82577) && |
| 1005 | ((hw->phy.revision == 1) || (hw->phy.revision == 2))) || |
| 1006 | ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) { |
| 1007 | /* Disable generation of early preamble */ |
| 1008 | ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431); |
| 1009 | if (ret_val) |
| 1010 | return ret_val; |
| 1011 | |
| 1012 | /* Preamble tuning for SSC */ |
| 1013 | ret_val = e1e_wphy(hw, PHY_REG(770, 16), 0xA204); |
| 1014 | if (ret_val) |
| 1015 | return ret_val; |
| 1016 | } |
| 1017 | |
| 1018 | if (hw->phy.type == e1000_phy_82578) { |
| 1019 | /* |
| 1020 | * Return registers to default by doing a soft reset then |
| 1021 | * writing 0x3140 to the control register. |
| 1022 | */ |
| 1023 | if (hw->phy.revision < 2) { |
| 1024 | e1000e_phy_sw_reset(hw); |
| 1025 | ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140); |
| 1026 | } |
| 1027 | } |
| 1028 | |
| 1029 | /* Select page 0 */ |
| 1030 | ret_val = hw->phy.ops.acquire_phy(hw); |
| 1031 | if (ret_val) |
| 1032 | return ret_val; |
| 1033 | hw->phy.addr = 1; |
| 1034 | e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0); |
| 1035 | hw->phy.ops.release_phy(hw); |
| 1036 | |
| 1037 | return ret_val; |
| 1038 | } |
| 1039 | |
| 1040 | /** |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 1041 | * e1000_lan_init_done_ich8lan - Check for PHY config completion |
| 1042 | * @hw: pointer to the HW structure |
| 1043 | * |
| 1044 | * Check the appropriate indication the MAC has finished configuring the |
| 1045 | * PHY after a software reset. |
| 1046 | **/ |
| 1047 | static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw) |
| 1048 | { |
| 1049 | u32 data, loop = E1000_ICH8_LAN_INIT_TIMEOUT; |
| 1050 | |
| 1051 | /* Wait for basic configuration completes before proceeding */ |
| 1052 | do { |
| 1053 | data = er32(STATUS); |
| 1054 | data &= E1000_STATUS_LAN_INIT_DONE; |
| 1055 | udelay(100); |
| 1056 | } while ((!data) && --loop); |
| 1057 | |
| 1058 | /* |
| 1059 | * If basic configuration is incomplete before the above loop |
| 1060 | * count reaches 0, loading the configuration from NVM will |
| 1061 | * leave the PHY in a bad state possibly resulting in no link. |
| 1062 | */ |
| 1063 | if (loop == 0) |
| 1064 | hw_dbg(hw, "LAN_INIT_DONE not set, increase timeout\n"); |
| 1065 | |
| 1066 | /* Clear the Init Done bit for the next init event */ |
| 1067 | data = er32(STATUS); |
| 1068 | data &= ~E1000_STATUS_LAN_INIT_DONE; |
| 1069 | ew32(STATUS, data); |
| 1070 | } |
| 1071 | |
| 1072 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1073 | * e1000_phy_hw_reset_ich8lan - Performs a PHY reset |
| 1074 | * @hw: pointer to the HW structure |
| 1075 | * |
| 1076 | * Resets the PHY |
| 1077 | * This is a function pointer entry point called by drivers |
| 1078 | * or other shared routines. |
| 1079 | **/ |
| 1080 | static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw) |
| 1081 | { |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 1082 | s32 ret_val = 0; |
| 1083 | u16 reg; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1084 | |
| 1085 | ret_val = e1000e_phy_hw_reset_generic(hw); |
| 1086 | if (ret_val) |
| 1087 | return ret_val; |
| 1088 | |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 1089 | /* Allow time for h/w to get to a quiescent state after reset */ |
| 1090 | mdelay(10); |
| 1091 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1092 | if (hw->mac.type == e1000_pchlan) { |
| 1093 | ret_val = e1000_hv_phy_workarounds_ich8lan(hw); |
| 1094 | if (ret_val) |
| 1095 | return ret_val; |
| 1096 | } |
| 1097 | |
Bruce Allan | db2932e | 2009-10-26 11:22:47 +0000 | [diff] [blame] | 1098 | /* Dummy read to clear the phy wakeup bit after lcd reset */ |
| 1099 | if (hw->mac.type == e1000_pchlan) |
| 1100 | e1e_rphy(hw, BM_WUC, ®); |
| 1101 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 1102 | /* Configure the LCD with the extended configuration region in NVM */ |
| 1103 | ret_val = e1000_sw_lcd_config_ich8lan(hw); |
| 1104 | if (ret_val) |
| 1105 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1106 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 1107 | /* Configure the LCD with the OEM bits in NVM */ |
| 1108 | if (hw->mac.type == e1000_pchlan) |
| 1109 | ret_val = e1000_oem_bits_config_ich8lan(hw, true); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1110 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 1111 | out: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1112 | return 0; |
| 1113 | } |
| 1114 | |
| 1115 | /** |
| 1116 | * e1000_get_phy_info_ife_ich8lan - Retrieves various IFE PHY states |
| 1117 | * @hw: pointer to the HW structure |
| 1118 | * |
| 1119 | * Populates "phy" structure with various feature states. |
| 1120 | * This function is only called by other family-specific |
| 1121 | * routines. |
| 1122 | **/ |
| 1123 | static s32 e1000_get_phy_info_ife_ich8lan(struct e1000_hw *hw) |
| 1124 | { |
| 1125 | struct e1000_phy_info *phy = &hw->phy; |
| 1126 | s32 ret_val; |
| 1127 | u16 data; |
| 1128 | bool link; |
| 1129 | |
| 1130 | ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); |
| 1131 | if (ret_val) |
| 1132 | return ret_val; |
| 1133 | |
| 1134 | if (!link) { |
| 1135 | hw_dbg(hw, "Phy info is only valid if link is up\n"); |
| 1136 | return -E1000_ERR_CONFIG; |
| 1137 | } |
| 1138 | |
| 1139 | ret_val = e1e_rphy(hw, IFE_PHY_SPECIAL_CONTROL, &data); |
| 1140 | if (ret_val) |
| 1141 | return ret_val; |
| 1142 | phy->polarity_correction = (!(data & IFE_PSC_AUTO_POLARITY_DISABLE)); |
| 1143 | |
| 1144 | if (phy->polarity_correction) { |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1145 | ret_val = phy->ops.check_polarity(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1146 | if (ret_val) |
| 1147 | return ret_val; |
| 1148 | } else { |
| 1149 | /* Polarity is forced */ |
| 1150 | phy->cable_polarity = (data & IFE_PSC_FORCE_POLARITY) |
| 1151 | ? e1000_rev_polarity_reversed |
| 1152 | : e1000_rev_polarity_normal; |
| 1153 | } |
| 1154 | |
| 1155 | ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &data); |
| 1156 | if (ret_val) |
| 1157 | return ret_val; |
| 1158 | |
| 1159 | phy->is_mdix = (data & IFE_PMC_MDIX_STATUS); |
| 1160 | |
| 1161 | /* The following parameters are undefined for 10/100 operation. */ |
| 1162 | phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; |
| 1163 | phy->local_rx = e1000_1000t_rx_status_undefined; |
| 1164 | phy->remote_rx = e1000_1000t_rx_status_undefined; |
| 1165 | |
| 1166 | return 0; |
| 1167 | } |
| 1168 | |
| 1169 | /** |
| 1170 | * e1000_get_phy_info_ich8lan - Calls appropriate PHY type get_phy_info |
| 1171 | * @hw: pointer to the HW structure |
| 1172 | * |
| 1173 | * Wrapper for calling the get_phy_info routines for the appropriate phy type. |
| 1174 | * This is a function pointer entry point called by drivers |
| 1175 | * or other shared routines. |
| 1176 | **/ |
| 1177 | static s32 e1000_get_phy_info_ich8lan(struct e1000_hw *hw) |
| 1178 | { |
| 1179 | switch (hw->phy.type) { |
| 1180 | case e1000_phy_ife: |
| 1181 | return e1000_get_phy_info_ife_ich8lan(hw); |
| 1182 | break; |
| 1183 | case e1000_phy_igp_3: |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 1184 | case e1000_phy_bm: |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 1185 | case e1000_phy_82578: |
| 1186 | case e1000_phy_82577: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1187 | return e1000e_get_phy_info_igp(hw); |
| 1188 | break; |
| 1189 | default: |
| 1190 | break; |
| 1191 | } |
| 1192 | |
| 1193 | return -E1000_ERR_PHY_TYPE; |
| 1194 | } |
| 1195 | |
| 1196 | /** |
| 1197 | * e1000_check_polarity_ife_ich8lan - Check cable polarity for IFE PHY |
| 1198 | * @hw: pointer to the HW structure |
| 1199 | * |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 1200 | * Polarity is determined on the polarity reversal feature being enabled. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1201 | * This function is only called by other family-specific |
| 1202 | * routines. |
| 1203 | **/ |
| 1204 | static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw) |
| 1205 | { |
| 1206 | struct e1000_phy_info *phy = &hw->phy; |
| 1207 | s32 ret_val; |
| 1208 | u16 phy_data, offset, mask; |
| 1209 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1210 | /* |
| 1211 | * Polarity is determined based on the reversal feature being enabled. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1212 | */ |
| 1213 | if (phy->polarity_correction) { |
| 1214 | offset = IFE_PHY_EXTENDED_STATUS_CONTROL; |
| 1215 | mask = IFE_PESC_POLARITY_REVERSED; |
| 1216 | } else { |
| 1217 | offset = IFE_PHY_SPECIAL_CONTROL; |
| 1218 | mask = IFE_PSC_FORCE_POLARITY; |
| 1219 | } |
| 1220 | |
| 1221 | ret_val = e1e_rphy(hw, offset, &phy_data); |
| 1222 | |
| 1223 | if (!ret_val) |
| 1224 | phy->cable_polarity = (phy_data & mask) |
| 1225 | ? e1000_rev_polarity_reversed |
| 1226 | : e1000_rev_polarity_normal; |
| 1227 | |
| 1228 | return ret_val; |
| 1229 | } |
| 1230 | |
| 1231 | /** |
Bruce Allan | fa2ce13 | 2009-10-26 11:23:25 +0000 | [diff] [blame] | 1232 | * e1000_set_lplu_state_pchlan - Set Low Power Link Up state |
| 1233 | * @hw: pointer to the HW structure |
| 1234 | * @active: true to enable LPLU, false to disable |
| 1235 | * |
| 1236 | * Sets the LPLU state according to the active flag. For PCH, if OEM write |
| 1237 | * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set |
| 1238 | * the phy speed. This function will manually set the LPLU bit and restart |
| 1239 | * auto-neg as hw would do. D3 and D0 LPLU will call the same function |
| 1240 | * since it configures the same bit. |
| 1241 | **/ |
| 1242 | static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active) |
| 1243 | { |
| 1244 | s32 ret_val = 0; |
| 1245 | u16 oem_reg; |
| 1246 | |
| 1247 | ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg); |
| 1248 | if (ret_val) |
| 1249 | goto out; |
| 1250 | |
| 1251 | if (active) |
| 1252 | oem_reg |= HV_OEM_BITS_LPLU; |
| 1253 | else |
| 1254 | oem_reg &= ~HV_OEM_BITS_LPLU; |
| 1255 | |
| 1256 | oem_reg |= HV_OEM_BITS_RESTART_AN; |
| 1257 | ret_val = e1e_wphy(hw, HV_OEM_BITS, oem_reg); |
| 1258 | |
| 1259 | out: |
| 1260 | return ret_val; |
| 1261 | } |
| 1262 | |
| 1263 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1264 | * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state |
| 1265 | * @hw: pointer to the HW structure |
| 1266 | * @active: TRUE to enable LPLU, FALSE to disable |
| 1267 | * |
| 1268 | * Sets the LPLU D0 state according to the active flag. When |
| 1269 | * activating LPLU this function also disables smart speed |
| 1270 | * and vice versa. LPLU will not be activated unless the |
| 1271 | * device autonegotiation advertisement meets standards of |
| 1272 | * either 10 or 10/100 or 10/100/1000 at all duplexes. |
| 1273 | * This is a function pointer entry point only called by |
| 1274 | * PHY setup routines. |
| 1275 | **/ |
| 1276 | static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active) |
| 1277 | { |
| 1278 | struct e1000_phy_info *phy = &hw->phy; |
| 1279 | u32 phy_ctrl; |
| 1280 | s32 ret_val = 0; |
| 1281 | u16 data; |
| 1282 | |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 1283 | if (phy->type == e1000_phy_ife) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1284 | return ret_val; |
| 1285 | |
| 1286 | phy_ctrl = er32(PHY_CTRL); |
| 1287 | |
| 1288 | if (active) { |
| 1289 | phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU; |
| 1290 | ew32(PHY_CTRL, phy_ctrl); |
| 1291 | |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 1292 | if (phy->type != e1000_phy_igp_3) |
| 1293 | return 0; |
| 1294 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1295 | /* |
| 1296 | * Call gig speed drop workaround on LPLU before accessing |
| 1297 | * any PHY registers |
| 1298 | */ |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 1299 | if (hw->mac.type == e1000_ich8lan) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1300 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 1301 | |
| 1302 | /* When LPLU is enabled, we should disable SmartSpeed */ |
| 1303 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); |
| 1304 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
| 1305 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); |
| 1306 | if (ret_val) |
| 1307 | return ret_val; |
| 1308 | } else { |
| 1309 | phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU; |
| 1310 | ew32(PHY_CTRL, phy_ctrl); |
| 1311 | |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 1312 | if (phy->type != e1000_phy_igp_3) |
| 1313 | return 0; |
| 1314 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1315 | /* |
| 1316 | * LPLU and SmartSpeed are mutually exclusive. LPLU is used |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1317 | * during Dx states where the power conservation is most |
| 1318 | * important. During driver activity we should enable |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1319 | * SmartSpeed, so performance is maintained. |
| 1320 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1321 | if (phy->smart_speed == e1000_smart_speed_on) { |
| 1322 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1323 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1324 | if (ret_val) |
| 1325 | return ret_val; |
| 1326 | |
| 1327 | data |= IGP01E1000_PSCFR_SMART_SPEED; |
| 1328 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1329 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1330 | if (ret_val) |
| 1331 | return ret_val; |
| 1332 | } else if (phy->smart_speed == e1000_smart_speed_off) { |
| 1333 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1334 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1335 | if (ret_val) |
| 1336 | return ret_val; |
| 1337 | |
| 1338 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
| 1339 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1340 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1341 | if (ret_val) |
| 1342 | return ret_val; |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | return 0; |
| 1347 | } |
| 1348 | |
| 1349 | /** |
| 1350 | * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state |
| 1351 | * @hw: pointer to the HW structure |
| 1352 | * @active: TRUE to enable LPLU, FALSE to disable |
| 1353 | * |
| 1354 | * Sets the LPLU D3 state according to the active flag. When |
| 1355 | * activating LPLU this function also disables smart speed |
| 1356 | * and vice versa. LPLU will not be activated unless the |
| 1357 | * device autonegotiation advertisement meets standards of |
| 1358 | * either 10 or 10/100 or 10/100/1000 at all duplexes. |
| 1359 | * This is a function pointer entry point only called by |
| 1360 | * PHY setup routines. |
| 1361 | **/ |
| 1362 | static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active) |
| 1363 | { |
| 1364 | struct e1000_phy_info *phy = &hw->phy; |
| 1365 | u32 phy_ctrl; |
| 1366 | s32 ret_val; |
| 1367 | u16 data; |
| 1368 | |
| 1369 | phy_ctrl = er32(PHY_CTRL); |
| 1370 | |
| 1371 | if (!active) { |
| 1372 | phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU; |
| 1373 | ew32(PHY_CTRL, phy_ctrl); |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 1374 | |
| 1375 | if (phy->type != e1000_phy_igp_3) |
| 1376 | return 0; |
| 1377 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1378 | /* |
| 1379 | * LPLU and SmartSpeed are mutually exclusive. LPLU is used |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1380 | * during Dx states where the power conservation is most |
| 1381 | * important. During driver activity we should enable |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1382 | * SmartSpeed, so performance is maintained. |
| 1383 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1384 | if (phy->smart_speed == e1000_smart_speed_on) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1385 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 1386 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1387 | if (ret_val) |
| 1388 | return ret_val; |
| 1389 | |
| 1390 | data |= IGP01E1000_PSCFR_SMART_SPEED; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1391 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 1392 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1393 | if (ret_val) |
| 1394 | return ret_val; |
| 1395 | } else if (phy->smart_speed == e1000_smart_speed_off) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1396 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 1397 | &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1398 | if (ret_val) |
| 1399 | return ret_val; |
| 1400 | |
| 1401 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1402 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, |
| 1403 | data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1404 | if (ret_val) |
| 1405 | return ret_val; |
| 1406 | } |
| 1407 | } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || |
| 1408 | (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || |
| 1409 | (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { |
| 1410 | phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU; |
| 1411 | ew32(PHY_CTRL, phy_ctrl); |
| 1412 | |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 1413 | if (phy->type != e1000_phy_igp_3) |
| 1414 | return 0; |
| 1415 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1416 | /* |
| 1417 | * Call gig speed drop workaround on LPLU before accessing |
| 1418 | * any PHY registers |
| 1419 | */ |
Bruce Allan | 60f1292 | 2009-07-01 13:28:14 +0000 | [diff] [blame] | 1420 | if (hw->mac.type == e1000_ich8lan) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1421 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 1422 | |
| 1423 | /* When LPLU is enabled, we should disable SmartSpeed */ |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1424 | ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1425 | if (ret_val) |
| 1426 | return ret_val; |
| 1427 | |
| 1428 | data &= ~IGP01E1000_PSCFR_SMART_SPEED; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1429 | ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1430 | } |
| 1431 | |
| 1432 | return 0; |
| 1433 | } |
| 1434 | |
| 1435 | /** |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1436 | * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1 |
| 1437 | * @hw: pointer to the HW structure |
| 1438 | * @bank: pointer to the variable that returns the active bank |
| 1439 | * |
| 1440 | * Reads signature byte from the NVM using the flash access registers. |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1441 | * 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] | 1442 | **/ |
| 1443 | static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank) |
| 1444 | { |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1445 | u32 eecd; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1446 | struct e1000_nvm_info *nvm = &hw->nvm; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1447 | u32 bank1_offset = nvm->flash_bank_size * sizeof(u16); |
| 1448 | u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1449 | u8 sig_byte = 0; |
| 1450 | s32 ret_val = 0; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1451 | |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1452 | switch (hw->mac.type) { |
| 1453 | case e1000_ich8lan: |
| 1454 | case e1000_ich9lan: |
| 1455 | eecd = er32(EECD); |
| 1456 | if ((eecd & E1000_EECD_SEC1VAL_VALID_MASK) == |
| 1457 | E1000_EECD_SEC1VAL_VALID_MASK) { |
| 1458 | if (eecd & E1000_EECD_SEC1VAL) |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1459 | *bank = 1; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1460 | else |
| 1461 | *bank = 0; |
| 1462 | |
| 1463 | return 0; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1464 | } |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1465 | hw_dbg(hw, "Unable to determine valid NVM bank via EEC - " |
| 1466 | "reading flash signature\n"); |
| 1467 | /* fall-thru */ |
| 1468 | default: |
| 1469 | /* set bank to 0 in case flash read fails */ |
| 1470 | *bank = 0; |
| 1471 | |
| 1472 | /* Check bank 0 */ |
| 1473 | ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset, |
| 1474 | &sig_byte); |
| 1475 | if (ret_val) |
| 1476 | return ret_val; |
| 1477 | if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) == |
| 1478 | E1000_ICH_NVM_SIG_VALUE) { |
| 1479 | *bank = 0; |
| 1480 | return 0; |
| 1481 | } |
| 1482 | |
| 1483 | /* Check bank 1 */ |
| 1484 | ret_val = e1000_read_flash_byte_ich8lan(hw, act_offset + |
| 1485 | bank1_offset, |
| 1486 | &sig_byte); |
| 1487 | if (ret_val) |
| 1488 | return ret_val; |
| 1489 | if ((sig_byte & E1000_ICH_NVM_VALID_SIG_MASK) == |
| 1490 | E1000_ICH_NVM_SIG_VALUE) { |
| 1491 | *bank = 1; |
| 1492 | return 0; |
| 1493 | } |
| 1494 | |
| 1495 | hw_dbg(hw, "ERROR: No valid NVM bank present\n"); |
| 1496 | return -E1000_ERR_NVM; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1497 | } |
| 1498 | |
| 1499 | return 0; |
| 1500 | } |
| 1501 | |
| 1502 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1503 | * e1000_read_nvm_ich8lan - Read word(s) from the NVM |
| 1504 | * @hw: pointer to the HW structure |
| 1505 | * @offset: The offset (in bytes) of the word(s) to read. |
| 1506 | * @words: Size of data to read in words |
| 1507 | * @data: Pointer to the word(s) to read at offset. |
| 1508 | * |
| 1509 | * Reads a word(s) from the NVM using the flash access registers. |
| 1510 | **/ |
| 1511 | static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, |
| 1512 | u16 *data) |
| 1513 | { |
| 1514 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 1515 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
| 1516 | u32 act_offset; |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 1517 | s32 ret_val = 0; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1518 | u32 bank = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1519 | u16 i, word; |
| 1520 | |
| 1521 | if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || |
| 1522 | (words == 0)) { |
| 1523 | hw_dbg(hw, "nvm parameter(s) out of bounds\n"); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1524 | ret_val = -E1000_ERR_NVM; |
| 1525 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1526 | } |
| 1527 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1528 | nvm->ops.acquire_nvm(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1529 | |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1530 | ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 1531 | if (ret_val) { |
| 1532 | hw_dbg(hw, "Could not detect valid bank, assuming bank 0\n"); |
| 1533 | bank = 0; |
| 1534 | } |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1535 | |
| 1536 | act_offset = (bank) ? nvm->flash_bank_size : 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1537 | act_offset += offset; |
| 1538 | |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 1539 | ret_val = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1540 | for (i = 0; i < words; i++) { |
| 1541 | if ((dev_spec->shadow_ram) && |
| 1542 | (dev_spec->shadow_ram[offset+i].modified)) { |
| 1543 | data[i] = dev_spec->shadow_ram[offset+i].value; |
| 1544 | } else { |
| 1545 | ret_val = e1000_read_flash_word_ich8lan(hw, |
| 1546 | act_offset + i, |
| 1547 | &word); |
| 1548 | if (ret_val) |
| 1549 | break; |
| 1550 | data[i] = word; |
| 1551 | } |
| 1552 | } |
| 1553 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1554 | nvm->ops.release_nvm(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1555 | |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1556 | out: |
| 1557 | if (ret_val) |
| 1558 | hw_dbg(hw, "NVM read error: %d\n", ret_val); |
| 1559 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1560 | return ret_val; |
| 1561 | } |
| 1562 | |
| 1563 | /** |
| 1564 | * e1000_flash_cycle_init_ich8lan - Initialize flash |
| 1565 | * @hw: pointer to the HW structure |
| 1566 | * |
| 1567 | * This function does initial flash setup so that a new read/write/erase cycle |
| 1568 | * can be started. |
| 1569 | **/ |
| 1570 | static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw) |
| 1571 | { |
| 1572 | union ich8_hws_flash_status hsfsts; |
| 1573 | s32 ret_val = -E1000_ERR_NVM; |
| 1574 | s32 i = 0; |
| 1575 | |
| 1576 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 1577 | |
| 1578 | /* Check if the flash descriptor is valid */ |
| 1579 | if (hsfsts.hsf_status.fldesvalid == 0) { |
| 1580 | hw_dbg(hw, "Flash descriptor invalid. " |
| 1581 | "SW Sequencing must be used."); |
| 1582 | return -E1000_ERR_NVM; |
| 1583 | } |
| 1584 | |
| 1585 | /* Clear FCERR and DAEL in hw status by writing 1 */ |
| 1586 | hsfsts.hsf_status.flcerr = 1; |
| 1587 | hsfsts.hsf_status.dael = 1; |
| 1588 | |
| 1589 | ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 1590 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1591 | /* |
| 1592 | * Either we should have a hardware SPI cycle in progress |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1593 | * bit to check against, in order to start a new cycle or |
| 1594 | * FDONE bit should be changed in the hardware so that it |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 1595 | * is 1 after hardware reset, which can then be used as an |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1596 | * indication whether a cycle is in progress or has been |
| 1597 | * completed. |
| 1598 | */ |
| 1599 | |
| 1600 | if (hsfsts.hsf_status.flcinprog == 0) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1601 | /* |
| 1602 | * There is no cycle running at present, |
| 1603 | * so we can start a cycle |
| 1604 | * Begin by setting Flash Cycle Done. |
| 1605 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1606 | hsfsts.hsf_status.flcdone = 1; |
| 1607 | ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 1608 | ret_val = 0; |
| 1609 | } else { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1610 | /* |
| 1611 | * otherwise poll for sometime so the current |
| 1612 | * cycle has a chance to end before giving up. |
| 1613 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1614 | for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) { |
| 1615 | hsfsts.regval = __er16flash(hw, ICH_FLASH_HSFSTS); |
| 1616 | if (hsfsts.hsf_status.flcinprog == 0) { |
| 1617 | ret_val = 0; |
| 1618 | break; |
| 1619 | } |
| 1620 | udelay(1); |
| 1621 | } |
| 1622 | if (ret_val == 0) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1623 | /* |
| 1624 | * Successful in waiting for previous cycle to timeout, |
| 1625 | * now set the Flash Cycle Done. |
| 1626 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1627 | hsfsts.hsf_status.flcdone = 1; |
| 1628 | ew16flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 1629 | } else { |
| 1630 | hw_dbg(hw, "Flash controller busy, cannot get access"); |
| 1631 | } |
| 1632 | } |
| 1633 | |
| 1634 | return ret_val; |
| 1635 | } |
| 1636 | |
| 1637 | /** |
| 1638 | * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase) |
| 1639 | * @hw: pointer to the HW structure |
| 1640 | * @timeout: maximum time to wait for completion |
| 1641 | * |
| 1642 | * This function starts a flash cycle and waits for its completion. |
| 1643 | **/ |
| 1644 | static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout) |
| 1645 | { |
| 1646 | union ich8_hws_flash_ctrl hsflctl; |
| 1647 | union ich8_hws_flash_status hsfsts; |
| 1648 | s32 ret_val = -E1000_ERR_NVM; |
| 1649 | u32 i = 0; |
| 1650 | |
| 1651 | /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */ |
| 1652 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 1653 | hsflctl.hsf_ctrl.flcgo = 1; |
| 1654 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 1655 | |
| 1656 | /* wait till FDONE bit is set to 1 */ |
| 1657 | do { |
| 1658 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 1659 | if (hsfsts.hsf_status.flcdone == 1) |
| 1660 | break; |
| 1661 | udelay(1); |
| 1662 | } while (i++ < timeout); |
| 1663 | |
| 1664 | if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0) |
| 1665 | return 0; |
| 1666 | |
| 1667 | return ret_val; |
| 1668 | } |
| 1669 | |
| 1670 | /** |
| 1671 | * e1000_read_flash_word_ich8lan - Read word from flash |
| 1672 | * @hw: pointer to the HW structure |
| 1673 | * @offset: offset to data location |
| 1674 | * @data: pointer to the location for storing the data |
| 1675 | * |
| 1676 | * Reads the flash word at offset into data. Offset is converted |
| 1677 | * to bytes before read. |
| 1678 | **/ |
| 1679 | static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset, |
| 1680 | u16 *data) |
| 1681 | { |
| 1682 | /* Must convert offset into bytes. */ |
| 1683 | offset <<= 1; |
| 1684 | |
| 1685 | return e1000_read_flash_data_ich8lan(hw, offset, 2, data); |
| 1686 | } |
| 1687 | |
| 1688 | /** |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1689 | * e1000_read_flash_byte_ich8lan - Read byte from flash |
| 1690 | * @hw: pointer to the HW structure |
| 1691 | * @offset: The offset of the byte to read. |
| 1692 | * @data: Pointer to a byte to store the value read. |
| 1693 | * |
| 1694 | * Reads a single byte from the NVM using the flash access registers. |
| 1695 | **/ |
| 1696 | static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, |
| 1697 | u8 *data) |
| 1698 | { |
| 1699 | s32 ret_val; |
| 1700 | u16 word = 0; |
| 1701 | |
| 1702 | ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word); |
| 1703 | if (ret_val) |
| 1704 | return ret_val; |
| 1705 | |
| 1706 | *data = (u8)word; |
| 1707 | |
| 1708 | return 0; |
| 1709 | } |
| 1710 | |
| 1711 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1712 | * e1000_read_flash_data_ich8lan - Read byte or word from NVM |
| 1713 | * @hw: pointer to the HW structure |
| 1714 | * @offset: The offset (in bytes) of the byte or word to read. |
| 1715 | * @size: Size of data to read, 1=byte 2=word |
| 1716 | * @data: Pointer to the word to store the value read. |
| 1717 | * |
| 1718 | * Reads a byte or word from the NVM using the flash access registers. |
| 1719 | **/ |
| 1720 | static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, |
| 1721 | u8 size, u16 *data) |
| 1722 | { |
| 1723 | union ich8_hws_flash_status hsfsts; |
| 1724 | union ich8_hws_flash_ctrl hsflctl; |
| 1725 | u32 flash_linear_addr; |
| 1726 | u32 flash_data = 0; |
| 1727 | s32 ret_val = -E1000_ERR_NVM; |
| 1728 | u8 count = 0; |
| 1729 | |
| 1730 | if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK) |
| 1731 | return -E1000_ERR_NVM; |
| 1732 | |
| 1733 | flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) + |
| 1734 | hw->nvm.flash_base_addr; |
| 1735 | |
| 1736 | do { |
| 1737 | udelay(1); |
| 1738 | /* Steps */ |
| 1739 | ret_val = e1000_flash_cycle_init_ich8lan(hw); |
| 1740 | if (ret_val != 0) |
| 1741 | break; |
| 1742 | |
| 1743 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 1744 | /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ |
| 1745 | hsflctl.hsf_ctrl.fldbcount = size - 1; |
| 1746 | hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ; |
| 1747 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 1748 | |
| 1749 | ew32flash(ICH_FLASH_FADDR, flash_linear_addr); |
| 1750 | |
| 1751 | ret_val = e1000_flash_cycle_ich8lan(hw, |
| 1752 | ICH_FLASH_READ_COMMAND_TIMEOUT); |
| 1753 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1754 | /* |
| 1755 | * 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] | 1756 | * and try the whole sequence a few more times, else |
| 1757 | * read in (shift in) the Flash Data0, the order is |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1758 | * least significant byte first msb to lsb |
| 1759 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1760 | if (ret_val == 0) { |
| 1761 | flash_data = er32flash(ICH_FLASH_FDATA0); |
| 1762 | if (size == 1) { |
| 1763 | *data = (u8)(flash_data & 0x000000FF); |
| 1764 | } else if (size == 2) { |
| 1765 | *data = (u16)(flash_data & 0x0000FFFF); |
| 1766 | } |
| 1767 | break; |
| 1768 | } else { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1769 | /* |
| 1770 | * If we've gotten here, then things are probably |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1771 | * completely hosed, but if the error condition is |
| 1772 | * detected, it won't hurt to give it another try... |
| 1773 | * ICH_FLASH_CYCLE_REPEAT_COUNT times. |
| 1774 | */ |
| 1775 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 1776 | if (hsfsts.hsf_status.flcerr == 1) { |
| 1777 | /* Repeat for some time before giving up. */ |
| 1778 | continue; |
| 1779 | } else if (hsfsts.hsf_status.flcdone == 0) { |
| 1780 | hw_dbg(hw, "Timeout error - flash cycle " |
| 1781 | "did not complete."); |
| 1782 | break; |
| 1783 | } |
| 1784 | } |
| 1785 | } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); |
| 1786 | |
| 1787 | return ret_val; |
| 1788 | } |
| 1789 | |
| 1790 | /** |
| 1791 | * e1000_write_nvm_ich8lan - Write word(s) to the NVM |
| 1792 | * @hw: pointer to the HW structure |
| 1793 | * @offset: The offset (in bytes) of the word(s) to write. |
| 1794 | * @words: Size of data to write in words |
| 1795 | * @data: Pointer to the word(s) to write at offset. |
| 1796 | * |
| 1797 | * Writes a byte or word to the NVM using the flash access registers. |
| 1798 | **/ |
| 1799 | static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, |
| 1800 | u16 *data) |
| 1801 | { |
| 1802 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 1803 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1804 | u16 i; |
| 1805 | |
| 1806 | if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || |
| 1807 | (words == 0)) { |
| 1808 | hw_dbg(hw, "nvm parameter(s) out of bounds\n"); |
| 1809 | return -E1000_ERR_NVM; |
| 1810 | } |
| 1811 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1812 | nvm->ops.acquire_nvm(hw); |
| 1813 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1814 | for (i = 0; i < words; i++) { |
| 1815 | dev_spec->shadow_ram[offset+i].modified = 1; |
| 1816 | dev_spec->shadow_ram[offset+i].value = data[i]; |
| 1817 | } |
| 1818 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1819 | nvm->ops.release_nvm(hw); |
| 1820 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1821 | return 0; |
| 1822 | } |
| 1823 | |
| 1824 | /** |
| 1825 | * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM |
| 1826 | * @hw: pointer to the HW structure |
| 1827 | * |
| 1828 | * The NVM checksum is updated by calling the generic update_nvm_checksum, |
| 1829 | * which writes the checksum to the shadow ram. The changes in the shadow |
| 1830 | * ram are then committed to the EEPROM by processing each bank at a time |
| 1831 | * checking for the modified bit and writing only the pending changes. |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 1832 | * 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] | 1833 | * future writes. |
| 1834 | **/ |
| 1835 | static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) |
| 1836 | { |
| 1837 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 1838 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1839 | u32 i, act_offset, new_bank_offset, old_bank_offset, bank; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1840 | s32 ret_val; |
| 1841 | u16 data; |
| 1842 | |
| 1843 | ret_val = e1000e_update_nvm_checksum_generic(hw); |
| 1844 | if (ret_val) |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1845 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1846 | |
| 1847 | if (nvm->type != e1000_nvm_flash_sw) |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1848 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1849 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1850 | nvm->ops.acquire_nvm(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1851 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1852 | /* |
| 1853 | * 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] | 1854 | * 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] | 1855 | * is going to be written |
| 1856 | */ |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1857 | ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1858 | if (ret_val) { |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 1859 | hw_dbg(hw, "Could not detect valid bank, assuming bank 0\n"); |
| 1860 | bank = 0; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1861 | } |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 1862 | |
| 1863 | if (bank == 0) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1864 | new_bank_offset = nvm->flash_bank_size; |
| 1865 | old_bank_offset = 0; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1866 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 1); |
| 1867 | if (ret_val) { |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1868 | nvm->ops.release_nvm(hw); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1869 | goto out; |
| 1870 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1871 | } else { |
| 1872 | old_bank_offset = nvm->flash_bank_size; |
| 1873 | new_bank_offset = 0; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1874 | ret_val = e1000_erase_flash_bank_ich8lan(hw, 0); |
| 1875 | if (ret_val) { |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1876 | nvm->ops.release_nvm(hw); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1877 | goto out; |
| 1878 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1879 | } |
| 1880 | |
| 1881 | for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1882 | /* |
| 1883 | * Determine whether to write the value stored |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1884 | * in the other NVM bank or a modified value stored |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1885 | * in the shadow RAM |
| 1886 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1887 | if (dev_spec->shadow_ram[i].modified) { |
| 1888 | data = dev_spec->shadow_ram[i].value; |
| 1889 | } else { |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1890 | ret_val = e1000_read_flash_word_ich8lan(hw, i + |
| 1891 | old_bank_offset, |
| 1892 | &data); |
| 1893 | if (ret_val) |
| 1894 | break; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1895 | } |
| 1896 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1897 | /* |
| 1898 | * If the word is 0x13, then make sure the signature bits |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1899 | * (15:14) are 11b until the commit has completed. |
| 1900 | * This will allow us to write 10b which indicates the |
| 1901 | * signature is valid. We want to do this after the write |
| 1902 | * has completed so that we don't mark the segment valid |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1903 | * while the write is still in progress |
| 1904 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1905 | if (i == E1000_ICH_NVM_SIG_WORD) |
| 1906 | data |= E1000_ICH_NVM_SIG_MASK; |
| 1907 | |
| 1908 | /* Convert offset to bytes. */ |
| 1909 | act_offset = (i + new_bank_offset) << 1; |
| 1910 | |
| 1911 | udelay(100); |
| 1912 | /* Write the bytes to the new bank. */ |
| 1913 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, |
| 1914 | act_offset, |
| 1915 | (u8)data); |
| 1916 | if (ret_val) |
| 1917 | break; |
| 1918 | |
| 1919 | udelay(100); |
| 1920 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, |
| 1921 | act_offset + 1, |
| 1922 | (u8)(data >> 8)); |
| 1923 | if (ret_val) |
| 1924 | break; |
| 1925 | } |
| 1926 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1927 | /* |
| 1928 | * Don't bother writing the segment valid bits if sector |
| 1929 | * programming failed. |
| 1930 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1931 | if (ret_val) { |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 1932 | /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1933 | hw_dbg(hw, "Flash commit failed.\n"); |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1934 | nvm->ops.release_nvm(hw); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1935 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1936 | } |
| 1937 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1938 | /* |
| 1939 | * Finally validate the new segment by setting bit 15:14 |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1940 | * to 10b in word 0x13 , this can be done without an |
| 1941 | * erase as well since these bits are 11 to start with |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1942 | * and we need to change bit 14 to 0b |
| 1943 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1944 | act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD; |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1945 | ret_val = e1000_read_flash_word_ich8lan(hw, act_offset, &data); |
| 1946 | if (ret_val) { |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1947 | nvm->ops.release_nvm(hw); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1948 | goto out; |
| 1949 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1950 | data &= 0xBFFF; |
| 1951 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, |
| 1952 | act_offset * 2 + 1, |
| 1953 | (u8)(data >> 8)); |
| 1954 | if (ret_val) { |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1955 | nvm->ops.release_nvm(hw); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1956 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1957 | } |
| 1958 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1959 | /* |
| 1960 | * And invalidate the previously valid segment by setting |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1961 | * its signature word (0x13) high_byte to 0b. This can be |
| 1962 | * done without an erase because flash erase sets all bits |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1963 | * to 1's. We can write 1's to 0's without an erase |
| 1964 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1965 | act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1; |
| 1966 | ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0); |
| 1967 | if (ret_val) { |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1968 | nvm->ops.release_nvm(hw); |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1969 | goto out; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1970 | } |
| 1971 | |
| 1972 | /* Great! Everything worked, we can now clear the cached entries. */ |
| 1973 | for (i = 0; i < E1000_ICH8_SHADOW_RAM_WORDS; i++) { |
| 1974 | dev_spec->shadow_ram[i].modified = 0; |
| 1975 | dev_spec->shadow_ram[i].value = 0xFFFF; |
| 1976 | } |
| 1977 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 1978 | nvm->ops.release_nvm(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1979 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1980 | /* |
| 1981 | * Reload the EEPROM, or else modifications will not appear |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1982 | * until after the next adapter reset. |
| 1983 | */ |
| 1984 | e1000e_reload_nvm(hw); |
| 1985 | msleep(10); |
| 1986 | |
Bruce Allan | e243455 | 2008-11-21 17:02:41 -0800 | [diff] [blame] | 1987 | out: |
| 1988 | if (ret_val) |
| 1989 | hw_dbg(hw, "NVM update error: %d\n", ret_val); |
| 1990 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1991 | return ret_val; |
| 1992 | } |
| 1993 | |
| 1994 | /** |
| 1995 | * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum |
| 1996 | * @hw: pointer to the HW structure |
| 1997 | * |
| 1998 | * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19. |
| 1999 | * If the bit is 0, that the EEPROM had been modified, but the checksum was not |
| 2000 | * calculated, in which case we need to calculate the checksum and set bit 6. |
| 2001 | **/ |
| 2002 | static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw) |
| 2003 | { |
| 2004 | s32 ret_val; |
| 2005 | u16 data; |
| 2006 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2007 | /* |
| 2008 | * Read 0x19 and check bit 6. If this bit is 0, the checksum |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2009 | * needs to be fixed. This bit is an indication that the NVM |
| 2010 | * was prepared by OEM software and did not calculate the |
| 2011 | * checksum...a likely scenario. |
| 2012 | */ |
| 2013 | ret_val = e1000_read_nvm(hw, 0x19, 1, &data); |
| 2014 | if (ret_val) |
| 2015 | return ret_val; |
| 2016 | |
| 2017 | if ((data & 0x40) == 0) { |
| 2018 | data |= 0x40; |
| 2019 | ret_val = e1000_write_nvm(hw, 0x19, 1, &data); |
| 2020 | if (ret_val) |
| 2021 | return ret_val; |
| 2022 | ret_val = e1000e_update_nvm_checksum(hw); |
| 2023 | if (ret_val) |
| 2024 | return ret_val; |
| 2025 | } |
| 2026 | |
| 2027 | return e1000e_validate_nvm_checksum_generic(hw); |
| 2028 | } |
| 2029 | |
| 2030 | /** |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 2031 | * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only |
| 2032 | * @hw: pointer to the HW structure |
| 2033 | * |
| 2034 | * To prevent malicious write/erase of the NVM, set it to be read-only |
| 2035 | * so that the hardware ignores all write/erase cycles of the NVM via |
| 2036 | * the flash control registers. The shadow-ram copy of the NVM will |
| 2037 | * still be updated, however any updates to this copy will not stick |
| 2038 | * across driver reloads. |
| 2039 | **/ |
| 2040 | void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw) |
| 2041 | { |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 2042 | struct e1000_nvm_info *nvm = &hw->nvm; |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 2043 | union ich8_flash_protected_range pr0; |
| 2044 | union ich8_hws_flash_status hsfsts; |
| 2045 | u32 gfpreg; |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 2046 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 2047 | nvm->ops.acquire_nvm(hw); |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 2048 | |
| 2049 | gfpreg = er32flash(ICH_FLASH_GFPREG); |
| 2050 | |
| 2051 | /* Write-protect GbE Sector of NVM */ |
| 2052 | pr0.regval = er32flash(ICH_FLASH_PR0); |
| 2053 | pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK; |
| 2054 | pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK); |
| 2055 | pr0.range.wpe = true; |
| 2056 | ew32flash(ICH_FLASH_PR0, pr0.regval); |
| 2057 | |
| 2058 | /* |
| 2059 | * Lock down a subset of GbE Flash Control Registers, e.g. |
| 2060 | * PR0 to prevent the write-protection from being lifted. |
| 2061 | * Once FLOCKDN is set, the registers protected by it cannot |
| 2062 | * be written until FLOCKDN is cleared by a hardware reset. |
| 2063 | */ |
| 2064 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 2065 | hsfsts.hsf_status.flockdn = true; |
| 2066 | ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval); |
| 2067 | |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 2068 | nvm->ops.release_nvm(hw); |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 2069 | } |
| 2070 | |
| 2071 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2072 | * e1000_write_flash_data_ich8lan - Writes bytes to the NVM |
| 2073 | * @hw: pointer to the HW structure |
| 2074 | * @offset: The offset (in bytes) of the byte/word to read. |
| 2075 | * @size: Size of data to read, 1=byte 2=word |
| 2076 | * @data: The byte(s) to write to the NVM. |
| 2077 | * |
| 2078 | * Writes one/two bytes to the NVM using the flash access registers. |
| 2079 | **/ |
| 2080 | static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, |
| 2081 | u8 size, u16 data) |
| 2082 | { |
| 2083 | union ich8_hws_flash_status hsfsts; |
| 2084 | union ich8_hws_flash_ctrl hsflctl; |
| 2085 | u32 flash_linear_addr; |
| 2086 | u32 flash_data = 0; |
| 2087 | s32 ret_val; |
| 2088 | u8 count = 0; |
| 2089 | |
| 2090 | if (size < 1 || size > 2 || data > size * 0xff || |
| 2091 | offset > ICH_FLASH_LINEAR_ADDR_MASK) |
| 2092 | return -E1000_ERR_NVM; |
| 2093 | |
| 2094 | flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) + |
| 2095 | hw->nvm.flash_base_addr; |
| 2096 | |
| 2097 | do { |
| 2098 | udelay(1); |
| 2099 | /* Steps */ |
| 2100 | ret_val = e1000_flash_cycle_init_ich8lan(hw); |
| 2101 | if (ret_val) |
| 2102 | break; |
| 2103 | |
| 2104 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 2105 | /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ |
| 2106 | hsflctl.hsf_ctrl.fldbcount = size -1; |
| 2107 | hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE; |
| 2108 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 2109 | |
| 2110 | ew32flash(ICH_FLASH_FADDR, flash_linear_addr); |
| 2111 | |
| 2112 | if (size == 1) |
| 2113 | flash_data = (u32)data & 0x00FF; |
| 2114 | else |
| 2115 | flash_data = (u32)data; |
| 2116 | |
| 2117 | ew32flash(ICH_FLASH_FDATA0, flash_data); |
| 2118 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2119 | /* |
| 2120 | * check if FCERR is set to 1 , if set to 1, clear it |
| 2121 | * and try the whole sequence a few more times else done |
| 2122 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2123 | ret_val = e1000_flash_cycle_ich8lan(hw, |
| 2124 | ICH_FLASH_WRITE_COMMAND_TIMEOUT); |
| 2125 | if (!ret_val) |
| 2126 | break; |
| 2127 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2128 | /* |
| 2129 | * If we're here, then things are most likely |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2130 | * completely hosed, but if the error condition |
| 2131 | * is detected, it won't hurt to give it another |
| 2132 | * try...ICH_FLASH_CYCLE_REPEAT_COUNT times. |
| 2133 | */ |
| 2134 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 2135 | if (hsfsts.hsf_status.flcerr == 1) |
| 2136 | /* Repeat for some time before giving up. */ |
| 2137 | continue; |
| 2138 | if (hsfsts.hsf_status.flcdone == 0) { |
| 2139 | hw_dbg(hw, "Timeout error - flash cycle " |
| 2140 | "did not complete."); |
| 2141 | break; |
| 2142 | } |
| 2143 | } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); |
| 2144 | |
| 2145 | return ret_val; |
| 2146 | } |
| 2147 | |
| 2148 | /** |
| 2149 | * e1000_write_flash_byte_ich8lan - Write a single byte to NVM |
| 2150 | * @hw: pointer to the HW structure |
| 2151 | * @offset: The index of the byte to read. |
| 2152 | * @data: The byte to write to the NVM. |
| 2153 | * |
| 2154 | * Writes a single byte to the NVM using the flash access registers. |
| 2155 | **/ |
| 2156 | static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, |
| 2157 | u8 data) |
| 2158 | { |
| 2159 | u16 word = (u16)data; |
| 2160 | |
| 2161 | return e1000_write_flash_data_ich8lan(hw, offset, 1, word); |
| 2162 | } |
| 2163 | |
| 2164 | /** |
| 2165 | * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM |
| 2166 | * @hw: pointer to the HW structure |
| 2167 | * @offset: The offset of the byte to write. |
| 2168 | * @byte: The byte to write to the NVM. |
| 2169 | * |
| 2170 | * Writes a single byte to the NVM using the flash access registers. |
| 2171 | * Goes through a retry algorithm before giving up. |
| 2172 | **/ |
| 2173 | static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw, |
| 2174 | u32 offset, u8 byte) |
| 2175 | { |
| 2176 | s32 ret_val; |
| 2177 | u16 program_retries; |
| 2178 | |
| 2179 | ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte); |
| 2180 | if (!ret_val) |
| 2181 | return ret_val; |
| 2182 | |
| 2183 | for (program_retries = 0; program_retries < 100; program_retries++) { |
| 2184 | hw_dbg(hw, "Retrying Byte %2.2X at offset %u\n", byte, offset); |
| 2185 | udelay(100); |
| 2186 | ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte); |
| 2187 | if (!ret_val) |
| 2188 | break; |
| 2189 | } |
| 2190 | if (program_retries == 100) |
| 2191 | return -E1000_ERR_NVM; |
| 2192 | |
| 2193 | return 0; |
| 2194 | } |
| 2195 | |
| 2196 | /** |
| 2197 | * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM |
| 2198 | * @hw: pointer to the HW structure |
| 2199 | * @bank: 0 for first bank, 1 for second bank, etc. |
| 2200 | * |
| 2201 | * Erases the bank specified. Each bank is a 4k block. Banks are 0 based. |
| 2202 | * bank N is 4096 * N + flash_reg_addr. |
| 2203 | **/ |
| 2204 | static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank) |
| 2205 | { |
| 2206 | struct e1000_nvm_info *nvm = &hw->nvm; |
| 2207 | union ich8_hws_flash_status hsfsts; |
| 2208 | union ich8_hws_flash_ctrl hsflctl; |
| 2209 | u32 flash_linear_addr; |
| 2210 | /* bank size is in 16bit words - adjust to bytes */ |
| 2211 | u32 flash_bank_size = nvm->flash_bank_size * 2; |
| 2212 | s32 ret_val; |
| 2213 | s32 count = 0; |
| 2214 | s32 iteration; |
| 2215 | s32 sector_size; |
| 2216 | s32 j; |
| 2217 | |
| 2218 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 2219 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2220 | /* |
| 2221 | * Determine HW Sector size: Read BERASE bits of hw flash status |
| 2222 | * register |
| 2223 | * 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] | 2224 | * consecutive sectors. The start index for the nth Hw sector |
| 2225 | * can be calculated as = bank * 4096 + n * 256 |
| 2226 | * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector. |
| 2227 | * The start index for the nth Hw sector can be calculated |
| 2228 | * as = bank * 4096 |
| 2229 | * 10: The Hw sector is 8K bytes, nth sector = bank * 8192 |
| 2230 | * (ich9 only, otherwise error condition) |
| 2231 | * 11: The Hw sector is 64K bytes, nth sector = bank * 65536 |
| 2232 | */ |
| 2233 | switch (hsfsts.hsf_status.berasesz) { |
| 2234 | case 0: |
| 2235 | /* Hw sector size 256 */ |
| 2236 | sector_size = ICH_FLASH_SEG_SIZE_256; |
| 2237 | iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256; |
| 2238 | break; |
| 2239 | case 1: |
| 2240 | sector_size = ICH_FLASH_SEG_SIZE_4K; |
Bruce Allan | 28c9195 | 2009-07-01 13:28:32 +0000 | [diff] [blame] | 2241 | iteration = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2242 | break; |
| 2243 | case 2: |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2244 | sector_size = ICH_FLASH_SEG_SIZE_8K; |
| 2245 | iteration = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2246 | break; |
| 2247 | case 3: |
| 2248 | sector_size = ICH_FLASH_SEG_SIZE_64K; |
Bruce Allan | 28c9195 | 2009-07-01 13:28:32 +0000 | [diff] [blame] | 2249 | iteration = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2250 | break; |
| 2251 | default: |
| 2252 | return -E1000_ERR_NVM; |
| 2253 | } |
| 2254 | |
| 2255 | /* Start with the base address, then add the sector offset. */ |
| 2256 | flash_linear_addr = hw->nvm.flash_base_addr; |
Bruce Allan | 148675a | 2009-08-07 07:41:56 +0000 | [diff] [blame] | 2257 | flash_linear_addr += (bank) ? flash_bank_size : 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2258 | |
| 2259 | for (j = 0; j < iteration ; j++) { |
| 2260 | do { |
| 2261 | /* Steps */ |
| 2262 | ret_val = e1000_flash_cycle_init_ich8lan(hw); |
| 2263 | if (ret_val) |
| 2264 | return ret_val; |
| 2265 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2266 | /* |
| 2267 | * Write a value 11 (block Erase) in Flash |
| 2268 | * Cycle field in hw flash control |
| 2269 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2270 | hsflctl.regval = er16flash(ICH_FLASH_HSFCTL); |
| 2271 | hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE; |
| 2272 | ew16flash(ICH_FLASH_HSFCTL, hsflctl.regval); |
| 2273 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2274 | /* |
| 2275 | * Write the last 24 bits of an index within the |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2276 | * block into Flash Linear address field in Flash |
| 2277 | * Address. |
| 2278 | */ |
| 2279 | flash_linear_addr += (j * sector_size); |
| 2280 | ew32flash(ICH_FLASH_FADDR, flash_linear_addr); |
| 2281 | |
| 2282 | ret_val = e1000_flash_cycle_ich8lan(hw, |
| 2283 | ICH_FLASH_ERASE_COMMAND_TIMEOUT); |
| 2284 | if (ret_val == 0) |
| 2285 | break; |
| 2286 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2287 | /* |
| 2288 | * Check if FCERR is set to 1. If 1, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2289 | * clear it and try the whole sequence |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2290 | * a few more times else Done |
| 2291 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2292 | hsfsts.regval = er16flash(ICH_FLASH_HSFSTS); |
| 2293 | if (hsfsts.hsf_status.flcerr == 1) |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2294 | /* repeat for some time before giving up */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2295 | continue; |
| 2296 | else if (hsfsts.hsf_status.flcdone == 0) |
| 2297 | return ret_val; |
| 2298 | } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT); |
| 2299 | } |
| 2300 | |
| 2301 | return 0; |
| 2302 | } |
| 2303 | |
| 2304 | /** |
| 2305 | * e1000_valid_led_default_ich8lan - Set the default LED settings |
| 2306 | * @hw: pointer to the HW structure |
| 2307 | * @data: Pointer to the LED settings |
| 2308 | * |
| 2309 | * Reads the LED default settings from the NVM to data. If the NVM LED |
| 2310 | * settings is all 0's or F's, set the LED default to a valid LED default |
| 2311 | * setting. |
| 2312 | **/ |
| 2313 | static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data) |
| 2314 | { |
| 2315 | s32 ret_val; |
| 2316 | |
| 2317 | ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data); |
| 2318 | if (ret_val) { |
| 2319 | hw_dbg(hw, "NVM Read Error\n"); |
| 2320 | return ret_val; |
| 2321 | } |
| 2322 | |
| 2323 | if (*data == ID_LED_RESERVED_0000 || |
| 2324 | *data == ID_LED_RESERVED_FFFF) |
| 2325 | *data = ID_LED_DEFAULT_ICH8LAN; |
| 2326 | |
| 2327 | return 0; |
| 2328 | } |
| 2329 | |
| 2330 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2331 | * e1000_id_led_init_pchlan - store LED configurations |
| 2332 | * @hw: pointer to the HW structure |
| 2333 | * |
| 2334 | * PCH does not control LEDs via the LEDCTL register, rather it uses |
| 2335 | * the PHY LED configuration register. |
| 2336 | * |
| 2337 | * PCH also does not have an "always on" or "always off" mode which |
| 2338 | * complicates the ID feature. Instead of using the "on" mode to indicate |
| 2339 | * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init()), |
| 2340 | * use "link_up" mode. The LEDs will still ID on request if there is no |
| 2341 | * link based on logic in e1000_led_[on|off]_pchlan(). |
| 2342 | **/ |
| 2343 | static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw) |
| 2344 | { |
| 2345 | struct e1000_mac_info *mac = &hw->mac; |
| 2346 | s32 ret_val; |
| 2347 | const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP; |
| 2348 | const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT; |
| 2349 | u16 data, i, temp, shift; |
| 2350 | |
| 2351 | /* Get default ID LED modes */ |
| 2352 | ret_val = hw->nvm.ops.valid_led_default(hw, &data); |
| 2353 | if (ret_val) |
| 2354 | goto out; |
| 2355 | |
| 2356 | mac->ledctl_default = er32(LEDCTL); |
| 2357 | mac->ledctl_mode1 = mac->ledctl_default; |
| 2358 | mac->ledctl_mode2 = mac->ledctl_default; |
| 2359 | |
| 2360 | for (i = 0; i < 4; i++) { |
| 2361 | temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK; |
| 2362 | shift = (i * 5); |
| 2363 | switch (temp) { |
| 2364 | case ID_LED_ON1_DEF2: |
| 2365 | case ID_LED_ON1_ON2: |
| 2366 | case ID_LED_ON1_OFF2: |
| 2367 | mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift); |
| 2368 | mac->ledctl_mode1 |= (ledctl_on << shift); |
| 2369 | break; |
| 2370 | case ID_LED_OFF1_DEF2: |
| 2371 | case ID_LED_OFF1_ON2: |
| 2372 | case ID_LED_OFF1_OFF2: |
| 2373 | mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift); |
| 2374 | mac->ledctl_mode1 |= (ledctl_off << shift); |
| 2375 | break; |
| 2376 | default: |
| 2377 | /* Do nothing */ |
| 2378 | break; |
| 2379 | } |
| 2380 | switch (temp) { |
| 2381 | case ID_LED_DEF1_ON2: |
| 2382 | case ID_LED_ON1_ON2: |
| 2383 | case ID_LED_OFF1_ON2: |
| 2384 | mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift); |
| 2385 | mac->ledctl_mode2 |= (ledctl_on << shift); |
| 2386 | break; |
| 2387 | case ID_LED_DEF1_OFF2: |
| 2388 | case ID_LED_ON1_OFF2: |
| 2389 | case ID_LED_OFF1_OFF2: |
| 2390 | mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift); |
| 2391 | mac->ledctl_mode2 |= (ledctl_off << shift); |
| 2392 | break; |
| 2393 | default: |
| 2394 | /* Do nothing */ |
| 2395 | break; |
| 2396 | } |
| 2397 | } |
| 2398 | |
| 2399 | out: |
| 2400 | return ret_val; |
| 2401 | } |
| 2402 | |
| 2403 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2404 | * e1000_get_bus_info_ich8lan - Get/Set the bus type and width |
| 2405 | * @hw: pointer to the HW structure |
| 2406 | * |
| 2407 | * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability |
| 2408 | * register, so the the bus width is hard coded. |
| 2409 | **/ |
| 2410 | static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw) |
| 2411 | { |
| 2412 | struct e1000_bus_info *bus = &hw->bus; |
| 2413 | s32 ret_val; |
| 2414 | |
| 2415 | ret_val = e1000e_get_bus_info_pcie(hw); |
| 2416 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2417 | /* |
| 2418 | * ICH devices are "PCI Express"-ish. They have |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2419 | * a configuration space, but do not contain |
| 2420 | * PCI Express Capability registers, so bus width |
| 2421 | * must be hardcoded. |
| 2422 | */ |
| 2423 | if (bus->width == e1000_bus_width_unknown) |
| 2424 | bus->width = e1000_bus_width_pcie_x1; |
| 2425 | |
| 2426 | return ret_val; |
| 2427 | } |
| 2428 | |
| 2429 | /** |
| 2430 | * e1000_reset_hw_ich8lan - Reset the hardware |
| 2431 | * @hw: pointer to the HW structure |
| 2432 | * |
| 2433 | * Does a full reset of the hardware which includes a reset of the PHY and |
| 2434 | * MAC. |
| 2435 | **/ |
| 2436 | static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) |
| 2437 | { |
Bruce Allan | db2932e | 2009-10-26 11:22:47 +0000 | [diff] [blame] | 2438 | u16 reg; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2439 | u32 ctrl, icr, kab; |
| 2440 | s32 ret_val; |
| 2441 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2442 | /* |
| 2443 | * 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] | 2444 | * on the last TLP read/write transaction when MAC is reset. |
| 2445 | */ |
| 2446 | ret_val = e1000e_disable_pcie_master(hw); |
| 2447 | if (ret_val) { |
| 2448 | hw_dbg(hw, "PCI-E Master disable polling has failed.\n"); |
| 2449 | } |
| 2450 | |
| 2451 | hw_dbg(hw, "Masking off all interrupts\n"); |
| 2452 | ew32(IMC, 0xffffffff); |
| 2453 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2454 | /* |
| 2455 | * Disable the Transmit and Receive units. Then delay to allow |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2456 | * any pending transactions to complete before we hit the MAC |
| 2457 | * with the global reset. |
| 2458 | */ |
| 2459 | ew32(RCTL, 0); |
| 2460 | ew32(TCTL, E1000_TCTL_PSP); |
| 2461 | e1e_flush(); |
| 2462 | |
| 2463 | msleep(10); |
| 2464 | |
| 2465 | /* Workaround for ICH8 bit corruption issue in FIFO memory */ |
| 2466 | if (hw->mac.type == e1000_ich8lan) { |
| 2467 | /* Set Tx and Rx buffer allocation to 8k apiece. */ |
| 2468 | ew32(PBA, E1000_PBA_8K); |
| 2469 | /* Set Packet Buffer Size to 16k. */ |
| 2470 | ew32(PBS, E1000_PBS_16K); |
| 2471 | } |
| 2472 | |
| 2473 | ctrl = er32(CTRL); |
| 2474 | |
| 2475 | if (!e1000_check_reset_block(hw)) { |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2476 | /* Clear PHY Reset Asserted bit */ |
| 2477 | if (hw->mac.type >= e1000_pchlan) { |
| 2478 | u32 status = er32(STATUS); |
| 2479 | ew32(STATUS, status & ~E1000_STATUS_PHYRA); |
| 2480 | } |
| 2481 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2482 | /* |
| 2483 | * PHY HW reset requires MAC CORE reset at the same |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2484 | * time to make sure the interface between MAC and the |
| 2485 | * external PHY is reset. |
| 2486 | */ |
| 2487 | ctrl |= E1000_CTRL_PHY_RST; |
| 2488 | } |
| 2489 | ret_val = e1000_acquire_swflag_ich8lan(hw); |
Jeff Kirsher | 30bb0e0 | 2008-12-11 21:28:11 -0800 | [diff] [blame] | 2490 | /* Whether or not the swflag was acquired, we need to reset the part */ |
Bruce Allan | 0285c8d | 2008-11-21 16:59:54 -0800 | [diff] [blame] | 2491 | hw_dbg(hw, "Issuing a global reset to ich8lan\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2492 | ew32(CTRL, (ctrl | E1000_CTRL_RST)); |
| 2493 | msleep(20); |
| 2494 | |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2495 | if (!ret_val) |
Jeff Kirsher | 30bb0e0 | 2008-12-11 21:28:11 -0800 | [diff] [blame] | 2496 | e1000_release_swflag_ich8lan(hw); |
Jesse Brandeburg | 37f4023 | 2008-10-02 16:33:20 -0700 | [diff] [blame] | 2497 | |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2498 | if (ctrl & E1000_CTRL_PHY_RST) |
| 2499 | ret_val = hw->phy.ops.get_cfg_done(hw); |
| 2500 | |
| 2501 | if (hw->mac.type >= e1000_ich10lan) { |
| 2502 | e1000_lan_init_done_ich8lan(hw); |
| 2503 | } else { |
| 2504 | ret_val = e1000e_get_auto_rd_done(hw); |
| 2505 | if (ret_val) { |
| 2506 | /* |
| 2507 | * When auto config read does not complete, do not |
| 2508 | * return with an error. This can happen in situations |
| 2509 | * where there is no eeprom and prevents getting link. |
| 2510 | */ |
| 2511 | hw_dbg(hw, "Auto Read Done did not complete\n"); |
| 2512 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2513 | } |
Bruce Allan | db2932e | 2009-10-26 11:22:47 +0000 | [diff] [blame] | 2514 | /* Dummy read to clear the phy wakeup bit after lcd reset */ |
| 2515 | if (hw->mac.type == e1000_pchlan) |
| 2516 | e1e_rphy(hw, BM_WUC, ®); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2517 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 2518 | ret_val = e1000_sw_lcd_config_ich8lan(hw); |
| 2519 | if (ret_val) |
| 2520 | goto out; |
| 2521 | |
| 2522 | if (hw->mac.type == e1000_pchlan) { |
| 2523 | ret_val = e1000_oem_bits_config_ich8lan(hw, true); |
| 2524 | if (ret_val) |
| 2525 | goto out; |
| 2526 | } |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 2527 | /* |
| 2528 | * For PCH, this write will make sure that any noise |
| 2529 | * will be detected as a CRC error and be dropped rather than show up |
| 2530 | * as a bad packet to the DMA engine. |
| 2531 | */ |
| 2532 | if (hw->mac.type == e1000_pchlan) |
| 2533 | ew32(CRC_OFFSET, 0x65656565); |
| 2534 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2535 | ew32(IMC, 0xffffffff); |
| 2536 | icr = er32(ICR); |
| 2537 | |
| 2538 | kab = er32(KABGTXD); |
| 2539 | kab |= E1000_KABGTXD_BGSQLBIAS; |
| 2540 | ew32(KABGTXD, kab); |
| 2541 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2542 | if (hw->mac.type == e1000_pchlan) |
| 2543 | ret_val = e1000_hv_phy_workarounds_ich8lan(hw); |
| 2544 | |
Bruce Allan | f523d21 | 2009-10-29 13:45:45 +0000 | [diff] [blame^] | 2545 | out: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2546 | return ret_val; |
| 2547 | } |
| 2548 | |
| 2549 | /** |
| 2550 | * e1000_init_hw_ich8lan - Initialize the hardware |
| 2551 | * @hw: pointer to the HW structure |
| 2552 | * |
| 2553 | * Prepares the hardware for transmit and receive by doing the following: |
| 2554 | * - initialize hardware bits |
| 2555 | * - initialize LED identification |
| 2556 | * - setup receive address registers |
| 2557 | * - setup flow control |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 2558 | * - setup transmit descriptors |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2559 | * - clear statistics |
| 2560 | **/ |
| 2561 | static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw) |
| 2562 | { |
| 2563 | struct e1000_mac_info *mac = &hw->mac; |
| 2564 | u32 ctrl_ext, txdctl, snoop; |
| 2565 | s32 ret_val; |
| 2566 | u16 i; |
| 2567 | |
| 2568 | e1000_initialize_hw_bits_ich8lan(hw); |
| 2569 | |
| 2570 | /* Initialize identification LED */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2571 | ret_val = mac->ops.id_led_init(hw); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2572 | if (ret_val) { |
| 2573 | hw_dbg(hw, "Error initializing identification LED\n"); |
| 2574 | return ret_val; |
| 2575 | } |
| 2576 | |
| 2577 | /* Setup the receive address. */ |
| 2578 | e1000e_init_rx_addrs(hw, mac->rar_entry_count); |
| 2579 | |
| 2580 | /* Zero out the Multicast HASH table */ |
| 2581 | hw_dbg(hw, "Zeroing the MTA\n"); |
| 2582 | for (i = 0; i < mac->mta_reg_count; i++) |
| 2583 | E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); |
| 2584 | |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 2585 | /* |
| 2586 | * The 82578 Rx buffer will stall if wakeup is enabled in host and |
| 2587 | * the ME. Reading the BM_WUC register will clear the host wakeup bit. |
| 2588 | * Reset the phy after disabling host wakeup to reset the Rx buffer. |
| 2589 | */ |
| 2590 | if (hw->phy.type == e1000_phy_82578) { |
| 2591 | hw->phy.ops.read_phy_reg(hw, BM_WUC, &i); |
| 2592 | ret_val = e1000_phy_hw_reset_ich8lan(hw); |
| 2593 | if (ret_val) |
| 2594 | return ret_val; |
| 2595 | } |
| 2596 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2597 | /* Setup link and flow control */ |
| 2598 | ret_val = e1000_setup_link_ich8lan(hw); |
| 2599 | |
| 2600 | /* Set the transmit descriptor write-back policy for both queues */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2601 | txdctl = er32(TXDCTL(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2602 | txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) | |
| 2603 | E1000_TXDCTL_FULL_TX_DESC_WB; |
| 2604 | txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) | |
| 2605 | E1000_TXDCTL_MAX_TX_DESC_PREFETCH; |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2606 | ew32(TXDCTL(0), txdctl); |
| 2607 | txdctl = er32(TXDCTL(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2608 | txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) | |
| 2609 | E1000_TXDCTL_FULL_TX_DESC_WB; |
| 2610 | txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) | |
| 2611 | E1000_TXDCTL_MAX_TX_DESC_PREFETCH; |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2612 | ew32(TXDCTL(1), txdctl); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2613 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2614 | /* |
| 2615 | * ICH8 has opposite polarity of no_snoop bits. |
| 2616 | * By default, we should use snoop behavior. |
| 2617 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2618 | if (mac->type == e1000_ich8lan) |
| 2619 | snoop = PCIE_ICH8_SNOOP_ALL; |
| 2620 | else |
| 2621 | snoop = (u32) ~(PCIE_NO_SNOOP_ALL); |
| 2622 | e1000e_set_pcie_no_snoop(hw, snoop); |
| 2623 | |
| 2624 | ctrl_ext = er32(CTRL_EXT); |
| 2625 | ctrl_ext |= E1000_CTRL_EXT_RO_DIS; |
| 2626 | ew32(CTRL_EXT, ctrl_ext); |
| 2627 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2628 | /* |
| 2629 | * Clear all of the statistics registers (clear on read). It is |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2630 | * important that we do this after we have tried to establish link |
| 2631 | * because the symbol error count will increment wildly if there |
| 2632 | * is no link. |
| 2633 | */ |
| 2634 | e1000_clear_hw_cntrs_ich8lan(hw); |
| 2635 | |
| 2636 | return 0; |
| 2637 | } |
| 2638 | /** |
| 2639 | * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits |
| 2640 | * @hw: pointer to the HW structure |
| 2641 | * |
| 2642 | * Sets/Clears required hardware bits necessary for correctly setting up the |
| 2643 | * hardware for transmit and receive. |
| 2644 | **/ |
| 2645 | static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw) |
| 2646 | { |
| 2647 | u32 reg; |
| 2648 | |
| 2649 | /* Extended Device Control */ |
| 2650 | reg = er32(CTRL_EXT); |
| 2651 | reg |= (1 << 22); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2652 | /* Enable PHY low-power state when MAC is at D3 w/o WoL */ |
| 2653 | if (hw->mac.type >= e1000_pchlan) |
| 2654 | reg |= E1000_CTRL_EXT_PHYPDEN; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2655 | ew32(CTRL_EXT, reg); |
| 2656 | |
| 2657 | /* Transmit Descriptor Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2658 | reg = er32(TXDCTL(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2659 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2660 | ew32(TXDCTL(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2661 | |
| 2662 | /* Transmit Descriptor Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2663 | reg = er32(TXDCTL(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2664 | reg |= (1 << 22); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2665 | ew32(TXDCTL(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2666 | |
| 2667 | /* Transmit Arbitration Control 0 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2668 | reg = er32(TARC(0)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2669 | if (hw->mac.type == e1000_ich8lan) |
| 2670 | reg |= (1 << 28) | (1 << 29); |
| 2671 | reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2672 | ew32(TARC(0), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2673 | |
| 2674 | /* Transmit Arbitration Control 1 */ |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2675 | reg = er32(TARC(1)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2676 | if (er32(TCTL) & E1000_TCTL_MULR) |
| 2677 | reg &= ~(1 << 28); |
| 2678 | else |
| 2679 | reg |= (1 << 28); |
| 2680 | reg |= (1 << 24) | (1 << 26) | (1 << 30); |
Jeff Kirsher | e9ec2c0 | 2008-04-02 13:48:13 -0700 | [diff] [blame] | 2681 | ew32(TARC(1), reg); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2682 | |
| 2683 | /* Device Status */ |
| 2684 | if (hw->mac.type == e1000_ich8lan) { |
| 2685 | reg = er32(STATUS); |
| 2686 | reg &= ~(1 << 31); |
| 2687 | ew32(STATUS, reg); |
| 2688 | } |
| 2689 | } |
| 2690 | |
| 2691 | /** |
| 2692 | * e1000_setup_link_ich8lan - Setup flow control and link settings |
| 2693 | * @hw: pointer to the HW structure |
| 2694 | * |
| 2695 | * Determines which flow control settings to use, then configures flow |
| 2696 | * control. Calls the appropriate media-specific link configuration |
| 2697 | * function. Assuming the adapter has a valid link partner, a valid link |
| 2698 | * should be established. Assumes the hardware has previously been reset |
| 2699 | * and the transmitter and receiver are not enabled. |
| 2700 | **/ |
| 2701 | static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) |
| 2702 | { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2703 | s32 ret_val; |
| 2704 | |
| 2705 | if (e1000_check_reset_block(hw)) |
| 2706 | return 0; |
| 2707 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2708 | /* |
| 2709 | * ICH parts do not have a word in the NVM to determine |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2710 | * the default flow control setting, so we explicitly |
| 2711 | * set it to full. |
| 2712 | */ |
Bruce Allan | 37289d9 | 2009-06-02 11:29:37 +0000 | [diff] [blame] | 2713 | if (hw->fc.requested_mode == e1000_fc_default) { |
| 2714 | /* Workaround h/w hang when Tx flow control enabled */ |
| 2715 | if (hw->mac.type == e1000_pchlan) |
| 2716 | hw->fc.requested_mode = e1000_fc_rx_pause; |
| 2717 | else |
| 2718 | hw->fc.requested_mode = e1000_fc_full; |
| 2719 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2720 | |
Bruce Allan | 5c48ef3e2 | 2008-11-21 16:57:36 -0800 | [diff] [blame] | 2721 | /* |
| 2722 | * Save off the requested flow control mode for use later. Depending |
| 2723 | * on the link partner's capabilities, we may or may not use this mode. |
| 2724 | */ |
| 2725 | hw->fc.current_mode = hw->fc.requested_mode; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2726 | |
Bruce Allan | 5c48ef3e2 | 2008-11-21 16:57:36 -0800 | [diff] [blame] | 2727 | hw_dbg(hw, "After fix-ups FlowControl is now = %x\n", |
| 2728 | hw->fc.current_mode); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2729 | |
| 2730 | /* Continue to configure the copper link. */ |
| 2731 | ret_val = e1000_setup_copper_link_ich8lan(hw); |
| 2732 | if (ret_val) |
| 2733 | return ret_val; |
| 2734 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 2735 | ew32(FCTTV, hw->fc.pause_time); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2736 | if ((hw->phy.type == e1000_phy_82578) || |
| 2737 | (hw->phy.type == e1000_phy_82577)) { |
| 2738 | ret_val = hw->phy.ops.write_phy_reg(hw, |
| 2739 | PHY_REG(BM_PORT_CTRL_PAGE, 27), |
| 2740 | hw->fc.pause_time); |
| 2741 | if (ret_val) |
| 2742 | return ret_val; |
| 2743 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2744 | |
| 2745 | return e1000e_set_fc_watermarks(hw); |
| 2746 | } |
| 2747 | |
| 2748 | /** |
| 2749 | * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface |
| 2750 | * @hw: pointer to the HW structure |
| 2751 | * |
| 2752 | * Configures the kumeran interface to the PHY to wait the appropriate time |
| 2753 | * when polling the PHY, then call the generic setup_copper_link to finish |
| 2754 | * configuring the copper link. |
| 2755 | **/ |
| 2756 | static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw) |
| 2757 | { |
| 2758 | u32 ctrl; |
| 2759 | s32 ret_val; |
| 2760 | u16 reg_data; |
| 2761 | |
| 2762 | ctrl = er32(CTRL); |
| 2763 | ctrl |= E1000_CTRL_SLU; |
| 2764 | ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); |
| 2765 | ew32(CTRL, ctrl); |
| 2766 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2767 | /* |
| 2768 | * Set the mac to wait the maximum time between each iteration |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2769 | * and increase the max iterations when polling the phy; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2770 | * this fixes erroneous timeouts at 10Mbps. |
| 2771 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2772 | ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 4), 0xFFFF); |
| 2773 | if (ret_val) |
| 2774 | return ret_val; |
| 2775 | ret_val = e1000e_read_kmrn_reg(hw, GG82563_REG(0x34, 9), ®_data); |
| 2776 | if (ret_val) |
| 2777 | return ret_val; |
| 2778 | reg_data |= 0x3F; |
| 2779 | ret_val = e1000e_write_kmrn_reg(hw, GG82563_REG(0x34, 9), reg_data); |
| 2780 | if (ret_val) |
| 2781 | return ret_val; |
| 2782 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2783 | switch (hw->phy.type) { |
| 2784 | case e1000_phy_igp_3: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2785 | ret_val = e1000e_copper_link_setup_igp(hw); |
| 2786 | if (ret_val) |
| 2787 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2788 | break; |
| 2789 | case e1000_phy_bm: |
| 2790 | case e1000_phy_82578: |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 2791 | ret_val = e1000e_copper_link_setup_m88(hw); |
| 2792 | if (ret_val) |
| 2793 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2794 | break; |
| 2795 | case e1000_phy_82577: |
| 2796 | ret_val = e1000_copper_link_setup_82577(hw); |
| 2797 | if (ret_val) |
| 2798 | return ret_val; |
| 2799 | break; |
| 2800 | case e1000_phy_ife: |
| 2801 | ret_val = hw->phy.ops.read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, |
| 2802 | ®_data); |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 2803 | if (ret_val) |
| 2804 | return ret_val; |
| 2805 | |
| 2806 | reg_data &= ~IFE_PMC_AUTO_MDIX; |
| 2807 | |
| 2808 | switch (hw->phy.mdix) { |
| 2809 | case 1: |
| 2810 | reg_data &= ~IFE_PMC_FORCE_MDIX; |
| 2811 | break; |
| 2812 | case 2: |
| 2813 | reg_data |= IFE_PMC_FORCE_MDIX; |
| 2814 | break; |
| 2815 | case 0: |
| 2816 | default: |
| 2817 | reg_data |= IFE_PMC_AUTO_MDIX; |
| 2818 | break; |
| 2819 | } |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2820 | ret_val = hw->phy.ops.write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, |
| 2821 | reg_data); |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 2822 | if (ret_val) |
| 2823 | return ret_val; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 2824 | break; |
| 2825 | default: |
| 2826 | break; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 2827 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2828 | return e1000e_setup_copper_link(hw); |
| 2829 | } |
| 2830 | |
| 2831 | /** |
| 2832 | * e1000_get_link_up_info_ich8lan - Get current link speed and duplex |
| 2833 | * @hw: pointer to the HW structure |
| 2834 | * @speed: pointer to store current link speed |
| 2835 | * @duplex: pointer to store the current link duplex |
| 2836 | * |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2837 | * Calls the generic get_speed_and_duplex to retrieve the current link |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2838 | * information and then calls the Kumeran lock loss workaround for links at |
| 2839 | * gigabit speeds. |
| 2840 | **/ |
| 2841 | static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed, |
| 2842 | u16 *duplex) |
| 2843 | { |
| 2844 | s32 ret_val; |
| 2845 | |
| 2846 | ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex); |
| 2847 | if (ret_val) |
| 2848 | return ret_val; |
| 2849 | |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 2850 | if ((hw->mac.type == e1000_pchlan) && (*speed == SPEED_1000)) { |
| 2851 | ret_val = e1000e_write_kmrn_reg(hw, |
| 2852 | E1000_KMRNCTRLSTA_K1_CONFIG, |
| 2853 | E1000_KMRNCTRLSTA_K1_DISABLE); |
| 2854 | if (ret_val) |
| 2855 | return ret_val; |
| 2856 | } |
| 2857 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2858 | if ((hw->mac.type == e1000_ich8lan) && |
| 2859 | (hw->phy.type == e1000_phy_igp_3) && |
| 2860 | (*speed == SPEED_1000)) { |
| 2861 | ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw); |
| 2862 | } |
| 2863 | |
| 2864 | return ret_val; |
| 2865 | } |
| 2866 | |
| 2867 | /** |
| 2868 | * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround |
| 2869 | * @hw: pointer to the HW structure |
| 2870 | * |
| 2871 | * Work-around for 82566 Kumeran PCS lock loss: |
| 2872 | * On link status change (i.e. PCI reset, speed change) and link is up and |
| 2873 | * speed is gigabit- |
| 2874 | * 0) if workaround is optionally disabled do nothing |
| 2875 | * 1) wait 1ms for Kumeran link to come up |
| 2876 | * 2) check Kumeran Diagnostic register PCS lock loss bit |
| 2877 | * 3) if not set the link is locked (all is good), otherwise... |
| 2878 | * 4) reset the PHY |
| 2879 | * 5) repeat up to 10 times |
| 2880 | * Note: this is only called for IGP3 copper when speed is 1gb. |
| 2881 | **/ |
| 2882 | static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw) |
| 2883 | { |
| 2884 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
| 2885 | u32 phy_ctrl; |
| 2886 | s32 ret_val; |
| 2887 | u16 i, data; |
| 2888 | bool link; |
| 2889 | |
| 2890 | if (!dev_spec->kmrn_lock_loss_workaround_enabled) |
| 2891 | return 0; |
| 2892 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2893 | /* |
| 2894 | * Make sure link is up before proceeding. If not just return. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2895 | * Attempting this while link is negotiating fouled up link |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2896 | * stability |
| 2897 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2898 | ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); |
| 2899 | if (!link) |
| 2900 | return 0; |
| 2901 | |
| 2902 | for (i = 0; i < 10; i++) { |
| 2903 | /* read once to clear */ |
| 2904 | ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data); |
| 2905 | if (ret_val) |
| 2906 | return ret_val; |
| 2907 | /* and again to get new status */ |
| 2908 | ret_val = e1e_rphy(hw, IGP3_KMRN_DIAG, &data); |
| 2909 | if (ret_val) |
| 2910 | return ret_val; |
| 2911 | |
| 2912 | /* check for PCS lock */ |
| 2913 | if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS)) |
| 2914 | return 0; |
| 2915 | |
| 2916 | /* Issue PHY reset */ |
| 2917 | e1000_phy_hw_reset(hw); |
| 2918 | mdelay(5); |
| 2919 | } |
| 2920 | /* Disable GigE link negotiation */ |
| 2921 | phy_ctrl = er32(PHY_CTRL); |
| 2922 | phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE | |
| 2923 | E1000_PHY_CTRL_NOND0A_GBE_DISABLE); |
| 2924 | ew32(PHY_CTRL, phy_ctrl); |
| 2925 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2926 | /* |
| 2927 | * Call gig speed drop workaround on Gig disable before accessing |
| 2928 | * any PHY registers |
| 2929 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2930 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 2931 | |
| 2932 | /* unable to acquire PCS lock */ |
| 2933 | return -E1000_ERR_PHY; |
| 2934 | } |
| 2935 | |
| 2936 | /** |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2937 | * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2938 | * @hw: pointer to the HW structure |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 2939 | * @state: boolean value used to set the current Kumeran workaround state |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2940 | * |
| 2941 | * If ICH8, set the current Kumeran workaround state (enabled - TRUE |
| 2942 | * /disabled - FALSE). |
| 2943 | **/ |
| 2944 | void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, |
| 2945 | bool state) |
| 2946 | { |
| 2947 | struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; |
| 2948 | |
| 2949 | if (hw->mac.type != e1000_ich8lan) { |
| 2950 | hw_dbg(hw, "Workaround applies to ICH8 only.\n"); |
| 2951 | return; |
| 2952 | } |
| 2953 | |
| 2954 | dev_spec->kmrn_lock_loss_workaround_enabled = state; |
| 2955 | } |
| 2956 | |
| 2957 | /** |
| 2958 | * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3 |
| 2959 | * @hw: pointer to the HW structure |
| 2960 | * |
| 2961 | * Workaround for 82566 power-down on D3 entry: |
| 2962 | * 1) disable gigabit link |
| 2963 | * 2) write VR power-down enable |
| 2964 | * 3) read it back |
| 2965 | * Continue if successful, else issue LCD reset and repeat |
| 2966 | **/ |
| 2967 | void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw) |
| 2968 | { |
| 2969 | u32 reg; |
| 2970 | u16 data; |
| 2971 | u8 retry = 0; |
| 2972 | |
| 2973 | if (hw->phy.type != e1000_phy_igp_3) |
| 2974 | return; |
| 2975 | |
| 2976 | /* Try the workaround twice (if needed) */ |
| 2977 | do { |
| 2978 | /* Disable link */ |
| 2979 | reg = er32(PHY_CTRL); |
| 2980 | reg |= (E1000_PHY_CTRL_GBE_DISABLE | |
| 2981 | E1000_PHY_CTRL_NOND0A_GBE_DISABLE); |
| 2982 | ew32(PHY_CTRL, reg); |
| 2983 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 2984 | /* |
| 2985 | * Call gig speed drop workaround on Gig disable before |
| 2986 | * accessing any PHY registers |
| 2987 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 2988 | if (hw->mac.type == e1000_ich8lan) |
| 2989 | e1000e_gig_downshift_workaround_ich8lan(hw); |
| 2990 | |
| 2991 | /* Write VR power-down enable */ |
| 2992 | e1e_rphy(hw, IGP3_VR_CTRL, &data); |
| 2993 | data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK; |
| 2994 | e1e_wphy(hw, IGP3_VR_CTRL, data | IGP3_VR_CTRL_MODE_SHUTDOWN); |
| 2995 | |
| 2996 | /* Read it back and test */ |
| 2997 | e1e_rphy(hw, IGP3_VR_CTRL, &data); |
| 2998 | data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK; |
| 2999 | if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry) |
| 3000 | break; |
| 3001 | |
| 3002 | /* Issue PHY reset and repeat at most one more time */ |
| 3003 | reg = er32(CTRL); |
| 3004 | ew32(CTRL, reg | E1000_CTRL_PHY_RST); |
| 3005 | retry++; |
| 3006 | } while (retry); |
| 3007 | } |
| 3008 | |
| 3009 | /** |
| 3010 | * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working |
| 3011 | * @hw: pointer to the HW structure |
| 3012 | * |
| 3013 | * 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] | 3014 | * LPLU, Gig disable, MDIC PHY reset): |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3015 | * 1) Set Kumeran Near-end loopback |
| 3016 | * 2) Clear Kumeran Near-end loopback |
| 3017 | * Should only be called for ICH8[m] devices with IGP_3 Phy. |
| 3018 | **/ |
| 3019 | void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw) |
| 3020 | { |
| 3021 | s32 ret_val; |
| 3022 | u16 reg_data; |
| 3023 | |
| 3024 | if ((hw->mac.type != e1000_ich8lan) || |
| 3025 | (hw->phy.type != e1000_phy_igp_3)) |
| 3026 | return; |
| 3027 | |
| 3028 | ret_val = e1000e_read_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, |
| 3029 | ®_data); |
| 3030 | if (ret_val) |
| 3031 | return; |
| 3032 | reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK; |
| 3033 | ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, |
| 3034 | reg_data); |
| 3035 | if (ret_val) |
| 3036 | return; |
| 3037 | reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK; |
| 3038 | ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, |
| 3039 | reg_data); |
| 3040 | } |
| 3041 | |
| 3042 | /** |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3043 | * e1000e_disable_gig_wol_ich8lan - disable gig during WoL |
| 3044 | * @hw: pointer to the HW structure |
| 3045 | * |
| 3046 | * During S0 to Sx transition, it is possible the link remains at gig |
| 3047 | * instead of negotiating to a lower speed. Before going to Sx, set |
| 3048 | * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation |
| 3049 | * to a lower speed. |
| 3050 | * |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3051 | * Should only be called for applicable parts. |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3052 | **/ |
| 3053 | void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw) |
| 3054 | { |
| 3055 | u32 phy_ctrl; |
| 3056 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3057 | switch (hw->mac.type) { |
| 3058 | case e1000_ich9lan: |
| 3059 | case e1000_ich10lan: |
| 3060 | case e1000_pchlan: |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3061 | phy_ctrl = er32(PHY_CTRL); |
| 3062 | phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU | |
| 3063 | E1000_PHY_CTRL_GBE_DISABLE; |
| 3064 | ew32(PHY_CTRL, phy_ctrl); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3065 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3066 | if (hw->mac.type == e1000_pchlan) |
Bruce Allan | 74eee2e | 2009-10-22 21:22:18 -0700 | [diff] [blame] | 3067 | e1000_phy_hw_reset_ich8lan(hw); |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3068 | default: |
| 3069 | break; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3070 | } |
| 3071 | |
| 3072 | return; |
| 3073 | } |
| 3074 | |
| 3075 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3076 | * e1000_cleanup_led_ich8lan - Restore the default LED operation |
| 3077 | * @hw: pointer to the HW structure |
| 3078 | * |
| 3079 | * Return the LED back to the default configuration. |
| 3080 | **/ |
| 3081 | static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw) |
| 3082 | { |
| 3083 | if (hw->phy.type == e1000_phy_ife) |
| 3084 | return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0); |
| 3085 | |
| 3086 | ew32(LEDCTL, hw->mac.ledctl_default); |
| 3087 | return 0; |
| 3088 | } |
| 3089 | |
| 3090 | /** |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 3091 | * e1000_led_on_ich8lan - Turn LEDs on |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3092 | * @hw: pointer to the HW structure |
| 3093 | * |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 3094 | * Turn on the LEDs. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3095 | **/ |
| 3096 | static s32 e1000_led_on_ich8lan(struct e1000_hw *hw) |
| 3097 | { |
| 3098 | if (hw->phy.type == e1000_phy_ife) |
| 3099 | return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, |
| 3100 | (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON)); |
| 3101 | |
| 3102 | ew32(LEDCTL, hw->mac.ledctl_mode2); |
| 3103 | return 0; |
| 3104 | } |
| 3105 | |
| 3106 | /** |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 3107 | * e1000_led_off_ich8lan - Turn LEDs off |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3108 | * @hw: pointer to the HW structure |
| 3109 | * |
Auke Kok | 489815c | 2008-02-21 15:11:07 -0800 | [diff] [blame] | 3110 | * Turn off the LEDs. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3111 | **/ |
| 3112 | static s32 e1000_led_off_ich8lan(struct e1000_hw *hw) |
| 3113 | { |
| 3114 | if (hw->phy.type == e1000_phy_ife) |
| 3115 | return e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, |
| 3116 | (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF)); |
| 3117 | |
| 3118 | ew32(LEDCTL, hw->mac.ledctl_mode1); |
| 3119 | return 0; |
| 3120 | } |
| 3121 | |
| 3122 | /** |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3123 | * e1000_setup_led_pchlan - Configures SW controllable LED |
| 3124 | * @hw: pointer to the HW structure |
| 3125 | * |
| 3126 | * This prepares the SW controllable LED for use. |
| 3127 | **/ |
| 3128 | static s32 e1000_setup_led_pchlan(struct e1000_hw *hw) |
| 3129 | { |
| 3130 | return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG, |
| 3131 | (u16)hw->mac.ledctl_mode1); |
| 3132 | } |
| 3133 | |
| 3134 | /** |
| 3135 | * e1000_cleanup_led_pchlan - Restore the default LED operation |
| 3136 | * @hw: pointer to the HW structure |
| 3137 | * |
| 3138 | * Return the LED back to the default configuration. |
| 3139 | **/ |
| 3140 | static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw) |
| 3141 | { |
| 3142 | return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG, |
| 3143 | (u16)hw->mac.ledctl_default); |
| 3144 | } |
| 3145 | |
| 3146 | /** |
| 3147 | * e1000_led_on_pchlan - Turn LEDs on |
| 3148 | * @hw: pointer to the HW structure |
| 3149 | * |
| 3150 | * Turn on the LEDs. |
| 3151 | **/ |
| 3152 | static s32 e1000_led_on_pchlan(struct e1000_hw *hw) |
| 3153 | { |
| 3154 | u16 data = (u16)hw->mac.ledctl_mode2; |
| 3155 | u32 i, led; |
| 3156 | |
| 3157 | /* |
| 3158 | * If no link, then turn LED on by setting the invert bit |
| 3159 | * for each LED that's mode is "link_up" in ledctl_mode2. |
| 3160 | */ |
| 3161 | if (!(er32(STATUS) & E1000_STATUS_LU)) { |
| 3162 | for (i = 0; i < 3; i++) { |
| 3163 | led = (data >> (i * 5)) & E1000_PHY_LED0_MASK; |
| 3164 | if ((led & E1000_PHY_LED0_MODE_MASK) != |
| 3165 | E1000_LEDCTL_MODE_LINK_UP) |
| 3166 | continue; |
| 3167 | if (led & E1000_PHY_LED0_IVRT) |
| 3168 | data &= ~(E1000_PHY_LED0_IVRT << (i * 5)); |
| 3169 | else |
| 3170 | data |= (E1000_PHY_LED0_IVRT << (i * 5)); |
| 3171 | } |
| 3172 | } |
| 3173 | |
| 3174 | return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG, data); |
| 3175 | } |
| 3176 | |
| 3177 | /** |
| 3178 | * e1000_led_off_pchlan - Turn LEDs off |
| 3179 | * @hw: pointer to the HW structure |
| 3180 | * |
| 3181 | * Turn off the LEDs. |
| 3182 | **/ |
| 3183 | static s32 e1000_led_off_pchlan(struct e1000_hw *hw) |
| 3184 | { |
| 3185 | u16 data = (u16)hw->mac.ledctl_mode1; |
| 3186 | u32 i, led; |
| 3187 | |
| 3188 | /* |
| 3189 | * If no link, then turn LED off by clearing the invert bit |
| 3190 | * for each LED that's mode is "link_up" in ledctl_mode1. |
| 3191 | */ |
| 3192 | if (!(er32(STATUS) & E1000_STATUS_LU)) { |
| 3193 | for (i = 0; i < 3; i++) { |
| 3194 | led = (data >> (i * 5)) & E1000_PHY_LED0_MASK; |
| 3195 | if ((led & E1000_PHY_LED0_MODE_MASK) != |
| 3196 | E1000_LEDCTL_MODE_LINK_UP) |
| 3197 | continue; |
| 3198 | if (led & E1000_PHY_LED0_IVRT) |
| 3199 | data &= ~(E1000_PHY_LED0_IVRT << (i * 5)); |
| 3200 | else |
| 3201 | data |= (E1000_PHY_LED0_IVRT << (i * 5)); |
| 3202 | } |
| 3203 | } |
| 3204 | |
| 3205 | return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG, data); |
| 3206 | } |
| 3207 | |
| 3208 | /** |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 3209 | * e1000_get_cfg_done_ich8lan - Read config done bit |
| 3210 | * @hw: pointer to the HW structure |
| 3211 | * |
| 3212 | * Read the management control register for the config done bit for |
| 3213 | * completion status. NOTE: silicon which is EEPROM-less will fail trying |
| 3214 | * to read the config done bit, so an error is *ONLY* logged and returns |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3215 | * 0. If we were to return with error, EEPROM-less silicon |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 3216 | * would not be able to be reset or change link. |
| 3217 | **/ |
| 3218 | static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw) |
| 3219 | { |
| 3220 | u32 bank = 0; |
| 3221 | |
Bruce Allan | fc0c776 | 2009-07-01 13:27:55 +0000 | [diff] [blame] | 3222 | if (hw->mac.type >= e1000_pchlan) { |
| 3223 | u32 status = er32(STATUS); |
| 3224 | |
| 3225 | if (status & E1000_STATUS_PHYRA) |
| 3226 | ew32(STATUS, status & ~E1000_STATUS_PHYRA); |
| 3227 | else |
| 3228 | hw_dbg(hw, |
| 3229 | "PHY Reset Asserted not set - needs delay\n"); |
| 3230 | } |
| 3231 | |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 3232 | e1000e_get_cfg_done(hw); |
| 3233 | |
| 3234 | /* If EEPROM is not marked present, init the IGP 3 PHY manually */ |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3235 | if ((hw->mac.type != e1000_ich10lan) && |
| 3236 | (hw->mac.type != e1000_pchlan)) { |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 3237 | if (((er32(EECD) & E1000_EECD_PRES) == 0) && |
| 3238 | (hw->phy.type == e1000_phy_igp_3)) { |
| 3239 | e1000e_phy_init_script_igp3(hw); |
| 3240 | } |
| 3241 | } else { |
| 3242 | if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) { |
| 3243 | /* Maybe we should do a basic PHY config */ |
| 3244 | hw_dbg(hw, "EEPROM not present\n"); |
| 3245 | return -E1000_ERR_CONFIG; |
| 3246 | } |
| 3247 | } |
| 3248 | |
| 3249 | return 0; |
| 3250 | } |
| 3251 | |
| 3252 | /** |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3253 | * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters |
| 3254 | * @hw: pointer to the HW structure |
| 3255 | * |
| 3256 | * Clears hardware counters specific to the silicon family and calls |
| 3257 | * clear_hw_cntrs_generic to clear all general purpose counters. |
| 3258 | **/ |
| 3259 | static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw) |
| 3260 | { |
| 3261 | u32 temp; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3262 | u16 phy_data; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3263 | |
| 3264 | e1000e_clear_hw_cntrs_base(hw); |
| 3265 | |
| 3266 | temp = er32(ALGNERRC); |
| 3267 | temp = er32(RXERRC); |
| 3268 | temp = er32(TNCRS); |
| 3269 | temp = er32(CEXTERR); |
| 3270 | temp = er32(TSCTC); |
| 3271 | temp = er32(TSCTFC); |
| 3272 | |
| 3273 | temp = er32(MGTPRC); |
| 3274 | temp = er32(MGTPDC); |
| 3275 | temp = er32(MGTPTC); |
| 3276 | |
| 3277 | temp = er32(IAC); |
| 3278 | temp = er32(ICRXOC); |
| 3279 | |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3280 | /* Clear PHY statistics registers */ |
| 3281 | if ((hw->phy.type == e1000_phy_82578) || |
| 3282 | (hw->phy.type == e1000_phy_82577)) { |
| 3283 | hw->phy.ops.read_phy_reg(hw, HV_SCC_UPPER, &phy_data); |
| 3284 | hw->phy.ops.read_phy_reg(hw, HV_SCC_LOWER, &phy_data); |
| 3285 | hw->phy.ops.read_phy_reg(hw, HV_ECOL_UPPER, &phy_data); |
| 3286 | hw->phy.ops.read_phy_reg(hw, HV_ECOL_LOWER, &phy_data); |
| 3287 | hw->phy.ops.read_phy_reg(hw, HV_MCC_UPPER, &phy_data); |
| 3288 | hw->phy.ops.read_phy_reg(hw, HV_MCC_LOWER, &phy_data); |
| 3289 | hw->phy.ops.read_phy_reg(hw, HV_LATECOL_UPPER, &phy_data); |
| 3290 | hw->phy.ops.read_phy_reg(hw, HV_LATECOL_LOWER, &phy_data); |
| 3291 | hw->phy.ops.read_phy_reg(hw, HV_COLC_UPPER, &phy_data); |
| 3292 | hw->phy.ops.read_phy_reg(hw, HV_COLC_LOWER, &phy_data); |
| 3293 | hw->phy.ops.read_phy_reg(hw, HV_DC_UPPER, &phy_data); |
| 3294 | hw->phy.ops.read_phy_reg(hw, HV_DC_LOWER, &phy_data); |
| 3295 | hw->phy.ops.read_phy_reg(hw, HV_TNCRS_UPPER, &phy_data); |
| 3296 | hw->phy.ops.read_phy_reg(hw, HV_TNCRS_LOWER, &phy_data); |
| 3297 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3298 | } |
| 3299 | |
| 3300 | static struct e1000_mac_operations ich8_mac_ops = { |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3301 | .id_led_init = e1000e_id_led_init, |
Bruce Allan | 4662e82 | 2008-08-26 18:37:06 -0700 | [diff] [blame] | 3302 | .check_mng_mode = e1000_check_mng_mode_ich8lan, |
Bruce Allan | 7d3cabb | 2009-07-01 13:29:08 +0000 | [diff] [blame] | 3303 | .check_for_link = e1000_check_for_copper_link_ich8lan, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3304 | /* cleanup_led dependent on mac type */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3305 | .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, |
| 3306 | .get_bus_info = e1000_get_bus_info_ich8lan, |
| 3307 | .get_link_up_info = e1000_get_link_up_info_ich8lan, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3308 | /* led_on dependent on mac type */ |
| 3309 | /* led_off dependent on mac type */ |
Jeff Kirsher | e2de3eb | 2008-03-28 09:15:11 -0700 | [diff] [blame] | 3310 | .update_mc_addr_list = e1000e_update_mc_addr_list_generic, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3311 | .reset_hw = e1000_reset_hw_ich8lan, |
| 3312 | .init_hw = e1000_init_hw_ich8lan, |
| 3313 | .setup_link = e1000_setup_link_ich8lan, |
| 3314 | .setup_physical_interface= e1000_setup_copper_link_ich8lan, |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3315 | /* id_led_init dependent on mac type */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3316 | }; |
| 3317 | |
| 3318 | static struct e1000_phy_operations ich8_phy_ops = { |
| 3319 | .acquire_phy = e1000_acquire_swflag_ich8lan, |
| 3320 | .check_reset_block = e1000_check_reset_block_ich8lan, |
| 3321 | .commit_phy = NULL, |
| 3322 | .force_speed_duplex = e1000_phy_force_speed_duplex_ich8lan, |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 3323 | .get_cfg_done = e1000_get_cfg_done_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3324 | .get_cable_length = e1000e_get_cable_length_igp_2, |
| 3325 | .get_phy_info = e1000_get_phy_info_ich8lan, |
| 3326 | .read_phy_reg = e1000e_read_phy_reg_igp, |
| 3327 | .release_phy = e1000_release_swflag_ich8lan, |
| 3328 | .reset_phy = e1000_phy_hw_reset_ich8lan, |
| 3329 | .set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan, |
| 3330 | .set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan, |
| 3331 | .write_phy_reg = e1000e_write_phy_reg_igp, |
| 3332 | }; |
| 3333 | |
| 3334 | static struct e1000_nvm_operations ich8_nvm_ops = { |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 3335 | .acquire_nvm = e1000_acquire_nvm_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3336 | .read_nvm = e1000_read_nvm_ich8lan, |
Bruce Allan | ca15df5 | 2009-10-26 11:23:43 +0000 | [diff] [blame] | 3337 | .release_nvm = e1000_release_nvm_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3338 | .update_nvm = e1000_update_nvm_checksum_ich8lan, |
| 3339 | .valid_led_default = e1000_valid_led_default_ich8lan, |
| 3340 | .validate_nvm = e1000_validate_nvm_checksum_ich8lan, |
| 3341 | .write_nvm = e1000_write_nvm_ich8lan, |
| 3342 | }; |
| 3343 | |
| 3344 | struct e1000_info e1000_ich8_info = { |
| 3345 | .mac = e1000_ich8lan, |
| 3346 | .flags = FLAG_HAS_WOL |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3347 | | FLAG_IS_ICH |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3348 | | FLAG_RX_CSUM_ENABLED |
| 3349 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 3350 | | FLAG_HAS_AMT |
| 3351 | | FLAG_HAS_FLASH |
| 3352 | | FLAG_APME_IN_WUC, |
| 3353 | .pba = 8, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 3354 | .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 3355 | .get_variants = e1000_get_variants_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3356 | .mac_ops = &ich8_mac_ops, |
| 3357 | .phy_ops = &ich8_phy_ops, |
| 3358 | .nvm_ops = &ich8_nvm_ops, |
| 3359 | }; |
| 3360 | |
| 3361 | struct e1000_info e1000_ich9_info = { |
| 3362 | .mac = e1000_ich9lan, |
| 3363 | .flags = FLAG_HAS_JUMBO_FRAMES |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 3364 | | FLAG_IS_ICH |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3365 | | FLAG_HAS_WOL |
| 3366 | | FLAG_RX_CSUM_ENABLED |
| 3367 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 3368 | | FLAG_HAS_AMT |
| 3369 | | FLAG_HAS_ERT |
| 3370 | | FLAG_HAS_FLASH |
| 3371 | | FLAG_APME_IN_WUC, |
| 3372 | .pba = 10, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 3373 | .max_hw_frame_size = DEFAULT_JUMBO, |
Jeff Kirsher | 69e3fd8 | 2008-04-02 13:48:18 -0700 | [diff] [blame] | 3374 | .get_variants = e1000_get_variants_ich8lan, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 3375 | .mac_ops = &ich8_mac_ops, |
| 3376 | .phy_ops = &ich8_phy_ops, |
| 3377 | .nvm_ops = &ich8_nvm_ops, |
| 3378 | }; |
| 3379 | |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 3380 | struct e1000_info e1000_ich10_info = { |
| 3381 | .mac = e1000_ich10lan, |
| 3382 | .flags = FLAG_HAS_JUMBO_FRAMES |
| 3383 | | FLAG_IS_ICH |
| 3384 | | FLAG_HAS_WOL |
| 3385 | | FLAG_RX_CSUM_ENABLED |
| 3386 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 3387 | | FLAG_HAS_AMT |
| 3388 | | FLAG_HAS_ERT |
| 3389 | | FLAG_HAS_FLASH |
| 3390 | | FLAG_APME_IN_WUC, |
| 3391 | .pba = 10, |
Bruce Allan | 2adc55c | 2009-06-02 11:28:58 +0000 | [diff] [blame] | 3392 | .max_hw_frame_size = DEFAULT_JUMBO, |
Bruce Allan | f4187b5 | 2008-08-26 18:36:50 -0700 | [diff] [blame] | 3393 | .get_variants = e1000_get_variants_ich8lan, |
| 3394 | .mac_ops = &ich8_mac_ops, |
| 3395 | .phy_ops = &ich8_phy_ops, |
| 3396 | .nvm_ops = &ich8_nvm_ops, |
| 3397 | }; |
Bruce Allan | a4f58f5 | 2009-06-02 11:29:18 +0000 | [diff] [blame] | 3398 | |
| 3399 | struct e1000_info e1000_pch_info = { |
| 3400 | .mac = e1000_pchlan, |
| 3401 | .flags = FLAG_IS_ICH |
| 3402 | | FLAG_HAS_WOL |
| 3403 | | FLAG_RX_CSUM_ENABLED |
| 3404 | | FLAG_HAS_CTRLEXT_ON_LOAD |
| 3405 | | FLAG_HAS_AMT |
| 3406 | | FLAG_HAS_FLASH |
| 3407 | | FLAG_HAS_JUMBO_FRAMES |
| 3408 | | FLAG_APME_IN_WUC, |
| 3409 | .pba = 26, |
| 3410 | .max_hw_frame_size = 4096, |
| 3411 | .get_variants = e1000_get_variants_ich8lan, |
| 3412 | .mac_ops = &ich8_mac_ops, |
| 3413 | .phy_ops = &ich8_phy_ops, |
| 3414 | .nvm_ops = &ich8_nvm_ops, |
| 3415 | }; |