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