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