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