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