1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2012 Intel Corporation.
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.
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
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
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
27 *******************************************************************************/
29 /* 82562G 10/100 Network Connection
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
41 * 82567LM Gigabit Network Connection
42 * 82567LF Gigabit Network Connection
43 * 82567V Gigabit Network Connection
44 * 82567LM-2 Gigabit Network Connection
45 * 82567LF-2 Gigabit Network Connection
46 * 82567V-2 Gigabit Network Connection
47 * 82567LF-3 Gigabit Network Connection
48 * 82567LM-3 Gigabit Network Connection
49 * 82567LM-4 Gigabit Network Connection
50 * 82577LM Gigabit Network Connection
51 * 82577LC Gigabit Network Connection
52 * 82578DM Gigabit Network Connection
53 * 82578DC Gigabit Network Connection
54 * 82579LM Gigabit Network Connection
55 * 82579V Gigabit Network Connection
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
65 #define ICH_FLASH_PR0 0x0074
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
73 #define ICH_CYCLE_READ 0
74 #define ICH_CYCLE_WRITE 2
75 #define ICH_CYCLE_ERASE 3
77 #define FLASH_GFPREG_BASE_MASK 0x1FFF
78 #define FLASH_SECTOR_ADDR_SHIFT 12
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
86 #define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */
87 /* FW established a valid mode */
88 #define E1000_ICH_FWSM_FW_VALID 0x00008000
90 #define E1000_ICH_MNG_IAMT_MODE 0x2
92 #define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
93 (ID_LED_DEF1_OFF2 << 8) | \
94 (ID_LED_DEF1_ON2 << 4) | \
97 #define E1000_ICH_NVM_SIG_WORD 0x13
98 #define E1000_ICH_NVM_SIG_MASK 0xC000
99 #define E1000_ICH_NVM_VALID_SIG_MASK 0xC0
100 #define E1000_ICH_NVM_SIG_VALUE 0x80
102 #define E1000_ICH8_LAN_INIT_TIMEOUT 1500
104 #define E1000_FEXTNVM_SW_CONFIG 1
105 #define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
107 #define E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK 0x0C000000
108 #define E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC 0x08000000
110 #define E1000_FEXTNVM4_BEACON_DURATION_MASK 0x7
111 #define E1000_FEXTNVM4_BEACON_DURATION_8USEC 0x7
112 #define E1000_FEXTNVM4_BEACON_DURATION_16USEC 0x3
114 #define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
116 #define E1000_ICH_RAR_ENTRIES 7
117 #define E1000_PCH2_RAR_ENTRIES 5 /* RAR[0], SHRA[0-3] */
118 #define E1000_PCH_LPT_RAR_ENTRIES 12 /* RAR[0], SHRA[0-10] */
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 */
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
130 #define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */
132 #define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */
134 /* SMBus Control Phy Register */
135 #define CV_SMB_CTRL PHY_REG(769, 23)
136 #define CV_SMB_CTRL_FORCE_SMBUS 0x0001
138 /* SMBus Address Phy Register */
139 #define HV_SMB_ADDR PHY_REG(768, 26)
140 #define HV_SMB_ADDR_MASK 0x007F
141 #define HV_SMB_ADDR_PEC_EN 0x0200
142 #define HV_SMB_ADDR_VALID 0x0080
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
147 /* PHY Power Management Control */
148 #define HV_PM_CTRL PHY_REG(770, 17)
149 #define HV_PM_CTRL_PLL_STOP_IN_K1_GIGA 0x100
151 /* PHY Low Power Idle Control */
152 #define I82579_LPI_CTRL PHY_REG(772, 20)
153 #define I82579_LPI_CTRL_100_ENABLE 0x2000
154 #define I82579_LPI_CTRL_1000_ENABLE 0x4000
155 #define I82579_LPI_CTRL_ENABLE_MASK 0x6000
156 #define I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT 0x80
158 /* Extended Management Interface (EMI) Registers */
159 #define I82579_EMI_ADDR 0x10
160 #define I82579_EMI_DATA 0x11
161 #define I82579_LPI_UPDATE_TIMER 0x4805 /* in 40ns units + 40 ns base value */
162 #define I82579_MSE_THRESHOLD 0x084F /* 82579 Mean Square Error Threshold */
163 #define I82577_MSE_THRESHOLD 0x0887 /* 82577 Mean Square Error Threshold */
164 #define I82579_MSE_LINK_DOWN 0x2411 /* MSE count before dropping link */
165 #define I82579_EEE_PCS_STATUS 0x182D /* IEEE MMD Register 3.1 >> 8 */
166 #define I82579_EEE_LP_ABILITY 0x040F /* IEEE MMD Register 7.61 */
167 #define I82579_EEE_100_SUPPORTED (1 << 1) /* 100BaseTx EEE supported */
168 #define I82579_EEE_1000_SUPPORTED (1 << 2) /* 1000BaseTx EEE supported */
169 #define I217_EEE_PCS_STATUS 0x9401 /* IEEE MMD Register 3.1 */
170 #define I217_EEE_ADVERTISEMENT 0x8001 /* IEEE MMD Register 7.60 */
171 #define I217_EEE_LP_ABILITY 0x8002 /* IEEE MMD Register 7.61 */
173 /* Intel Rapid Start Technology Support */
174 #define I217_PROXY_CTRL BM_PHY_REG(BM_WUC_PAGE, 70)
175 #define I217_PROXY_CTRL_AUTO_DISABLE 0x0080
176 #define I217_SxCTRL PHY_REG(BM_PORT_CTRL_PAGE, 28)
177 #define I217_SxCTRL_ENABLE_LPI_RESET 0x1000
178 #define I217_CGFREG PHY_REG(772, 29)
179 #define I217_CGFREG_ENABLE_MTA_RESET 0x0002
180 #define I217_MEMPWR PHY_REG(772, 26)
181 #define I217_MEMPWR_DISABLE_SMB_RELEASE 0x0010
183 /* Strapping Option Register - RO */
184 #define E1000_STRAP 0x0000C
185 #define E1000_STRAP_SMBUS_ADDRESS_MASK 0x00FE0000
186 #define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17
187 #define E1000_STRAP_SMT_FREQ_MASK 0x00003000
188 #define E1000_STRAP_SMT_FREQ_SHIFT 12
190 /* OEM Bits Phy Register */
191 #define HV_OEM_BITS PHY_REG(768, 25)
192 #define HV_OEM_BITS_LPLU 0x0004 /* Low Power Link Up */
193 #define HV_OEM_BITS_GBE_DIS 0x0040 /* Gigabit Disable */
194 #define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */
196 #define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */
197 #define E1000_NVM_K1_ENABLE 0x1 /* NVM Enable K1 bit */
199 /* KMRN Mode Control */
200 #define HV_KMRN_MODE_CTRL PHY_REG(769, 16)
201 #define HV_KMRN_MDIO_SLOW 0x0400
203 /* KMRN FIFO Control and Status */
204 #define HV_KMRN_FIFO_CTRLSTA PHY_REG(770, 16)
205 #define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK 0x7000
206 #define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT 12
208 /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
209 /* Offset 04h HSFSTS */
210 union ich8_hws_flash_status
{
212 u16 flcdone
:1; /* bit 0 Flash Cycle Done */
213 u16 flcerr
:1; /* bit 1 Flash Cycle Error */
214 u16 dael
:1; /* bit 2 Direct Access error Log */
215 u16 berasesz
:2; /* bit 4:3 Sector Erase Size */
216 u16 flcinprog
:1; /* bit 5 flash cycle in Progress */
217 u16 reserved1
:2; /* bit 13:6 Reserved */
218 u16 reserved2
:6; /* bit 13:6 Reserved */
219 u16 fldesvalid
:1; /* bit 14 Flash Descriptor Valid */
220 u16 flockdn
:1; /* bit 15 Flash Config Lock-Down */
225 /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
226 /* Offset 06h FLCTL */
227 union ich8_hws_flash_ctrl
{
228 struct ich8_hsflctl
{
229 u16 flcgo
:1; /* 0 Flash Cycle Go */
230 u16 flcycle
:2; /* 2:1 Flash Cycle */
231 u16 reserved
:5; /* 7:3 Reserved */
232 u16 fldbcount
:2; /* 9:8 Flash Data Byte Count */
233 u16 flockdn
:6; /* 15:10 Reserved */
238 /* ICH Flash Region Access Permissions */
239 union ich8_hws_flash_regacc
{
241 u32 grra
:8; /* 0:7 GbE region Read Access */
242 u32 grwa
:8; /* 8:15 GbE region Write Access */
243 u32 gmrag
:8; /* 23:16 GbE Master Read Access Grant */
244 u32 gmwag
:8; /* 31:24 GbE Master Write Access Grant */
249 /* ICH Flash Protected Region */
250 union ich8_flash_protected_range
{
252 u32 base
:13; /* 0:12 Protected Range Base */
253 u32 reserved1
:2; /* 13:14 Reserved */
254 u32 rpe
:1; /* 15 Read Protection Enable */
255 u32 limit
:13; /* 16:28 Protected Range Limit */
256 u32 reserved2
:2; /* 29:30 Reserved */
257 u32 wpe
:1; /* 31 Write Protection Enable */
262 static s32
e1000_setup_link_ich8lan(struct e1000_hw
*hw
);
263 static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw
*hw
);
264 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw
*hw
);
265 static s32
e1000_erase_flash_bank_ich8lan(struct e1000_hw
*hw
, u32 bank
);
266 static s32
e1000_retry_write_flash_byte_ich8lan(struct e1000_hw
*hw
,
267 u32 offset
, u8 byte
);
268 static s32
e1000_read_flash_byte_ich8lan(struct e1000_hw
*hw
, u32 offset
,
270 static s32
e1000_read_flash_word_ich8lan(struct e1000_hw
*hw
, u32 offset
,
272 static s32
e1000_read_flash_data_ich8lan(struct e1000_hw
*hw
, u32 offset
,
274 static s32
e1000_setup_copper_link_ich8lan(struct e1000_hw
*hw
);
275 static s32
e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw
*hw
);
276 static s32
e1000_get_cfg_done_ich8lan(struct e1000_hw
*hw
);
277 static s32
e1000_cleanup_led_ich8lan(struct e1000_hw
*hw
);
278 static s32
e1000_led_on_ich8lan(struct e1000_hw
*hw
);
279 static s32
e1000_led_off_ich8lan(struct e1000_hw
*hw
);
280 static s32
e1000_id_led_init_pchlan(struct e1000_hw
*hw
);
281 static s32
e1000_setup_led_pchlan(struct e1000_hw
*hw
);
282 static s32
e1000_cleanup_led_pchlan(struct e1000_hw
*hw
);
283 static s32
e1000_led_on_pchlan(struct e1000_hw
*hw
);
284 static s32
e1000_led_off_pchlan(struct e1000_hw
*hw
);
285 static s32
e1000_set_lplu_state_pchlan(struct e1000_hw
*hw
, bool active
);
286 static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw
*hw
);
287 static void e1000_lan_init_done_ich8lan(struct e1000_hw
*hw
);
288 static s32
e1000_k1_gig_workaround_hv(struct e1000_hw
*hw
, bool link
);
289 static s32
e1000_set_mdio_slow_mode_hv(struct e1000_hw
*hw
);
290 static bool e1000_check_mng_mode_ich8lan(struct e1000_hw
*hw
);
291 static bool e1000_check_mng_mode_pchlan(struct e1000_hw
*hw
);
292 static void e1000_rar_set_pch2lan(struct e1000_hw
*hw
, u8
*addr
, u32 index
);
293 static void e1000_rar_set_pch_lpt(struct e1000_hw
*hw
, u8
*addr
, u32 index
);
294 static s32
e1000_k1_workaround_lv(struct e1000_hw
*hw
);
295 static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw
*hw
, bool gate
);
297 static inline u16
__er16flash(struct e1000_hw
*hw
, unsigned long reg
)
299 return readw(hw
->flash_address
+ reg
);
302 static inline u32
__er32flash(struct e1000_hw
*hw
, unsigned long reg
)
304 return readl(hw
->flash_address
+ reg
);
307 static inline void __ew16flash(struct e1000_hw
*hw
, unsigned long reg
, u16 val
)
309 writew(val
, hw
->flash_address
+ reg
);
312 static inline void __ew32flash(struct e1000_hw
*hw
, unsigned long reg
, u32 val
)
314 writel(val
, hw
->flash_address
+ reg
);
317 #define er16flash(reg) __er16flash(hw, (reg))
318 #define er32flash(reg) __er32flash(hw, (reg))
319 #define ew16flash(reg, val) __ew16flash(hw, (reg), (val))
320 #define ew32flash(reg, val) __ew32flash(hw, (reg), (val))
323 * e1000_phy_is_accessible_pchlan - Check if able to access PHY registers
324 * @hw: pointer to the HW structure
326 * Test access to the PHY registers by reading the PHY ID registers. If
327 * the PHY ID is already known (e.g. resume path) compare it with known ID,
328 * otherwise assume the read PHY ID is correct if it is valid.
330 * Assumes the sw/fw/hw semaphore is already acquired.
332 static bool e1000_phy_is_accessible_pchlan(struct e1000_hw
*hw
)
339 for (retry_count
= 0; retry_count
< 2; retry_count
++) {
340 ret_val
= e1e_rphy_locked(hw
, PHY_ID1
, &phy_reg
);
341 if (ret_val
|| (phy_reg
== 0xFFFF))
343 phy_id
= (u32
)(phy_reg
<< 16);
345 ret_val
= e1e_rphy_locked(hw
, PHY_ID2
, &phy_reg
);
346 if (ret_val
|| (phy_reg
== 0xFFFF)) {
350 phy_id
|= (u32
)(phy_reg
& PHY_REVISION_MASK
);
355 if (hw
->phy
.id
== phy_id
)
359 hw
->phy
.revision
= (u32
)(phy_reg
& ~PHY_REVISION_MASK
);
363 /* In case the PHY needs to be in mdio slow mode,
364 * set slow mode and try to get the PHY id again.
366 hw
->phy
.ops
.release(hw
);
367 ret_val
= e1000_set_mdio_slow_mode_hv(hw
);
369 ret_val
= e1000e_get_phy_id(hw
);
370 hw
->phy
.ops
.acquire(hw
);
376 * e1000_init_phy_workarounds_pchlan - PHY initialization workarounds
377 * @hw: pointer to the HW structure
379 * Workarounds/flow necessary for PHY initialization during driver load
382 static s32
e1000_init_phy_workarounds_pchlan(struct e1000_hw
*hw
)
384 u32 mac_reg
, fwsm
= er32(FWSM
);
388 ret_val
= hw
->phy
.ops
.acquire(hw
);
390 e_dbg("Failed to initialize PHY flow\n");
394 /* The MAC-PHY interconnect may be in SMBus mode. If the PHY is
395 * inaccessible and resetting the PHY is not blocked, toggle the
396 * LANPHYPC Value bit to force the interconnect to PCIe mode.
398 switch (hw
->mac
.type
) {
400 if (e1000_phy_is_accessible_pchlan(hw
))
403 /* Before toggling LANPHYPC, see if PHY is accessible by
404 * forcing MAC to SMBus mode first.
406 mac_reg
= er32(CTRL_EXT
);
407 mac_reg
|= E1000_CTRL_EXT_FORCE_SMBUS
;
408 ew32(CTRL_EXT
, mac_reg
);
412 /* Gate automatic PHY configuration by hardware on
415 if ((hw
->mac
.type
== e1000_pch2lan
) &&
416 !(fwsm
& E1000_ICH_FWSM_FW_VALID
))
417 e1000_gate_hw_phy_config_ich8lan(hw
, true);
419 if (e1000_phy_is_accessible_pchlan(hw
)) {
420 if (hw
->mac
.type
== e1000_pch_lpt
) {
421 /* Unforce SMBus mode in PHY */
422 e1e_rphy_locked(hw
, CV_SMB_CTRL
, &phy_reg
);
423 phy_reg
&= ~CV_SMB_CTRL_FORCE_SMBUS
;
424 e1e_wphy_locked(hw
, CV_SMB_CTRL
, phy_reg
);
426 /* Unforce SMBus mode in MAC */
427 mac_reg
= er32(CTRL_EXT
);
428 mac_reg
&= ~E1000_CTRL_EXT_FORCE_SMBUS
;
429 ew32(CTRL_EXT
, mac_reg
);
436 if ((hw
->mac
.type
== e1000_pchlan
) &&
437 (fwsm
& E1000_ICH_FWSM_FW_VALID
))
440 if (hw
->phy
.ops
.check_reset_block(hw
)) {
441 e_dbg("Required LANPHYPC toggle blocked by ME\n");
445 e_dbg("Toggling LANPHYPC\n");
447 /* Set Phy Config Counter to 50msec */
448 mac_reg
= er32(FEXTNVM3
);
449 mac_reg
&= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK
;
450 mac_reg
|= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC
;
451 ew32(FEXTNVM3
, mac_reg
);
453 /* Toggle LANPHYPC Value bit */
454 mac_reg
= er32(CTRL
);
455 mac_reg
|= E1000_CTRL_LANPHYPC_OVERRIDE
;
456 mac_reg
&= ~E1000_CTRL_LANPHYPC_VALUE
;
460 mac_reg
&= ~E1000_CTRL_LANPHYPC_OVERRIDE
;
463 if (hw
->mac
.type
< e1000_pch_lpt
) {
468 usleep_range(5000, 10000);
469 } while (!(er32(CTRL_EXT
) &
470 E1000_CTRL_EXT_LPCD
) && count
--);
477 hw
->phy
.ops
.release(hw
);
479 /* Reset the PHY before any access to it. Doing so, ensures
480 * that the PHY is in a known good state before we read/write
481 * PHY registers. The generic reset is sufficient here,
482 * because we haven't determined the PHY type yet.
484 ret_val
= e1000e_phy_hw_reset_generic(hw
);
486 /* Ungate automatic PHY configuration on non-managed 82579 */
487 if ((hw
->mac
.type
== e1000_pch2lan
) &&
488 !(fwsm
& E1000_ICH_FWSM_FW_VALID
)) {
489 usleep_range(10000, 20000);
490 e1000_gate_hw_phy_config_ich8lan(hw
, false);
497 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
498 * @hw: pointer to the HW structure
500 * Initialize family-specific PHY parameters and function pointers.
502 static s32
e1000_init_phy_params_pchlan(struct e1000_hw
*hw
)
504 struct e1000_phy_info
*phy
= &hw
->phy
;
508 phy
->reset_delay_us
= 100;
510 phy
->ops
.set_page
= e1000_set_page_igp
;
511 phy
->ops
.read_reg
= e1000_read_phy_reg_hv
;
512 phy
->ops
.read_reg_locked
= e1000_read_phy_reg_hv_locked
;
513 phy
->ops
.read_reg_page
= e1000_read_phy_reg_page_hv
;
514 phy
->ops
.set_d0_lplu_state
= e1000_set_lplu_state_pchlan
;
515 phy
->ops
.set_d3_lplu_state
= e1000_set_lplu_state_pchlan
;
516 phy
->ops
.write_reg
= e1000_write_phy_reg_hv
;
517 phy
->ops
.write_reg_locked
= e1000_write_phy_reg_hv_locked
;
518 phy
->ops
.write_reg_page
= e1000_write_phy_reg_page_hv
;
519 phy
->ops
.power_up
= e1000_power_up_phy_copper
;
520 phy
->ops
.power_down
= e1000_power_down_phy_copper_ich8lan
;
521 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
523 phy
->id
= e1000_phy_unknown
;
525 ret_val
= e1000_init_phy_workarounds_pchlan(hw
);
529 if (phy
->id
== e1000_phy_unknown
)
530 switch (hw
->mac
.type
) {
532 ret_val
= e1000e_get_phy_id(hw
);
535 if ((phy
->id
!= 0) && (phy
->id
!= PHY_REVISION_MASK
))
540 /* In case the PHY needs to be in mdio slow mode,
541 * set slow mode and try to get the PHY id again.
543 ret_val
= e1000_set_mdio_slow_mode_hv(hw
);
546 ret_val
= e1000e_get_phy_id(hw
);
551 phy
->type
= e1000e_get_phy_type_from_id(phy
->id
);
554 case e1000_phy_82577
:
555 case e1000_phy_82579
:
557 phy
->ops
.check_polarity
= e1000_check_polarity_82577
;
558 phy
->ops
.force_speed_duplex
=
559 e1000_phy_force_speed_duplex_82577
;
560 phy
->ops
.get_cable_length
= e1000_get_cable_length_82577
;
561 phy
->ops
.get_info
= e1000_get_phy_info_82577
;
562 phy
->ops
.commit
= e1000e_phy_sw_reset
;
564 case e1000_phy_82578
:
565 phy
->ops
.check_polarity
= e1000_check_polarity_m88
;
566 phy
->ops
.force_speed_duplex
= e1000e_phy_force_speed_duplex_m88
;
567 phy
->ops
.get_cable_length
= e1000e_get_cable_length_m88
;
568 phy
->ops
.get_info
= e1000e_get_phy_info_m88
;
571 ret_val
= -E1000_ERR_PHY
;
579 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
580 * @hw: pointer to the HW structure
582 * Initialize family-specific PHY parameters and function pointers.
584 static s32
e1000_init_phy_params_ich8lan(struct e1000_hw
*hw
)
586 struct e1000_phy_info
*phy
= &hw
->phy
;
591 phy
->reset_delay_us
= 100;
593 phy
->ops
.power_up
= e1000_power_up_phy_copper
;
594 phy
->ops
.power_down
= e1000_power_down_phy_copper_ich8lan
;
596 /* We may need to do this twice - once for IGP and if that fails,
597 * we'll set BM func pointers and try again
599 ret_val
= e1000e_determine_phy_address(hw
);
601 phy
->ops
.write_reg
= e1000e_write_phy_reg_bm
;
602 phy
->ops
.read_reg
= e1000e_read_phy_reg_bm
;
603 ret_val
= e1000e_determine_phy_address(hw
);
605 e_dbg("Cannot determine PHY addr. Erroring out\n");
611 while ((e1000_phy_unknown
== e1000e_get_phy_type_from_id(phy
->id
)) &&
613 usleep_range(1000, 2000);
614 ret_val
= e1000e_get_phy_id(hw
);
621 case IGP03E1000_E_PHY_ID
:
622 phy
->type
= e1000_phy_igp_3
;
623 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
624 phy
->ops
.read_reg_locked
= e1000e_read_phy_reg_igp_locked
;
625 phy
->ops
.write_reg_locked
= e1000e_write_phy_reg_igp_locked
;
626 phy
->ops
.get_info
= e1000e_get_phy_info_igp
;
627 phy
->ops
.check_polarity
= e1000_check_polarity_igp
;
628 phy
->ops
.force_speed_duplex
= e1000e_phy_force_speed_duplex_igp
;
631 case IFE_PLUS_E_PHY_ID
:
633 phy
->type
= e1000_phy_ife
;
634 phy
->autoneg_mask
= E1000_ALL_NOT_GIG
;
635 phy
->ops
.get_info
= e1000_get_phy_info_ife
;
636 phy
->ops
.check_polarity
= e1000_check_polarity_ife
;
637 phy
->ops
.force_speed_duplex
= e1000_phy_force_speed_duplex_ife
;
639 case BME1000_E_PHY_ID
:
640 phy
->type
= e1000_phy_bm
;
641 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
642 phy
->ops
.read_reg
= e1000e_read_phy_reg_bm
;
643 phy
->ops
.write_reg
= e1000e_write_phy_reg_bm
;
644 phy
->ops
.commit
= e1000e_phy_sw_reset
;
645 phy
->ops
.get_info
= e1000e_get_phy_info_m88
;
646 phy
->ops
.check_polarity
= e1000_check_polarity_m88
;
647 phy
->ops
.force_speed_duplex
= e1000e_phy_force_speed_duplex_m88
;
650 return -E1000_ERR_PHY
;
658 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
659 * @hw: pointer to the HW structure
661 * Initialize family-specific NVM parameters and function
664 static s32
e1000_init_nvm_params_ich8lan(struct e1000_hw
*hw
)
666 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
667 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
668 u32 gfpreg
, sector_base_addr
, sector_end_addr
;
671 /* Can't read flash registers if the register set isn't mapped. */
672 if (!hw
->flash_address
) {
673 e_dbg("ERROR: Flash registers not mapped\n");
674 return -E1000_ERR_CONFIG
;
677 nvm
->type
= e1000_nvm_flash_sw
;
679 gfpreg
= er32flash(ICH_FLASH_GFPREG
);
681 /* sector_X_addr is a "sector"-aligned address (4096 bytes)
682 * Add 1 to sector_end_addr since this sector is included in
685 sector_base_addr
= gfpreg
& FLASH_GFPREG_BASE_MASK
;
686 sector_end_addr
= ((gfpreg
>> 16) & FLASH_GFPREG_BASE_MASK
) + 1;
688 /* flash_base_addr is byte-aligned */
689 nvm
->flash_base_addr
= sector_base_addr
<< FLASH_SECTOR_ADDR_SHIFT
;
691 /* find total size of the NVM, then cut in half since the total
692 * size represents two separate NVM banks.
694 nvm
->flash_bank_size
= (sector_end_addr
- sector_base_addr
)
695 << FLASH_SECTOR_ADDR_SHIFT
;
696 nvm
->flash_bank_size
/= 2;
697 /* Adjust to word count */
698 nvm
->flash_bank_size
/= sizeof(u16
);
700 nvm
->word_size
= E1000_ICH8_SHADOW_RAM_WORDS
;
702 /* Clear shadow ram */
703 for (i
= 0; i
< nvm
->word_size
; i
++) {
704 dev_spec
->shadow_ram
[i
].modified
= false;
705 dev_spec
->shadow_ram
[i
].value
= 0xFFFF;
712 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
713 * @hw: pointer to the HW structure
715 * Initialize family-specific MAC parameters and function
718 static s32
e1000_init_mac_params_ich8lan(struct e1000_hw
*hw
)
720 struct e1000_mac_info
*mac
= &hw
->mac
;
722 /* Set media type function pointer */
723 hw
->phy
.media_type
= e1000_media_type_copper
;
725 /* Set mta register count */
726 mac
->mta_reg_count
= 32;
727 /* Set rar entry count */
728 mac
->rar_entry_count
= E1000_ICH_RAR_ENTRIES
;
729 if (mac
->type
== e1000_ich8lan
)
730 mac
->rar_entry_count
--;
732 mac
->has_fwsm
= true;
733 /* ARC subsystem not supported */
734 mac
->arc_subsystem_valid
= false;
735 /* Adaptive IFS supported */
736 mac
->adaptive_ifs
= true;
738 /* LED and other operations */
743 /* check management mode */
744 mac
->ops
.check_mng_mode
= e1000_check_mng_mode_ich8lan
;
746 mac
->ops
.id_led_init
= e1000e_id_led_init_generic
;
748 mac
->ops
.blink_led
= e1000e_blink_led_generic
;
750 mac
->ops
.setup_led
= e1000e_setup_led_generic
;
752 mac
->ops
.cleanup_led
= e1000_cleanup_led_ich8lan
;
753 /* turn on/off LED */
754 mac
->ops
.led_on
= e1000_led_on_ich8lan
;
755 mac
->ops
.led_off
= e1000_led_off_ich8lan
;
758 mac
->rar_entry_count
= E1000_PCH2_RAR_ENTRIES
;
759 mac
->ops
.rar_set
= e1000_rar_set_pch2lan
;
763 /* check management mode */
764 mac
->ops
.check_mng_mode
= e1000_check_mng_mode_pchlan
;
766 mac
->ops
.id_led_init
= e1000_id_led_init_pchlan
;
768 mac
->ops
.setup_led
= e1000_setup_led_pchlan
;
770 mac
->ops
.cleanup_led
= e1000_cleanup_led_pchlan
;
771 /* turn on/off LED */
772 mac
->ops
.led_on
= e1000_led_on_pchlan
;
773 mac
->ops
.led_off
= e1000_led_off_pchlan
;
779 if (mac
->type
== e1000_pch_lpt
) {
780 mac
->rar_entry_count
= E1000_PCH_LPT_RAR_ENTRIES
;
781 mac
->ops
.rar_set
= e1000_rar_set_pch_lpt
;
784 /* Enable PCS Lock-loss workaround for ICH8 */
785 if (mac
->type
== e1000_ich8lan
)
786 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw
, true);
788 /* Gate automatic PHY configuration by hardware on managed
791 if ((mac
->type
== e1000_pch2lan
|| mac
->type
== e1000_pch_lpt
) &&
792 (er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
))
793 e1000_gate_hw_phy_config_ich8lan(hw
, true);
799 * __e1000_access_emi_reg_locked - Read/write EMI register
800 * @hw: pointer to the HW structure
801 * @addr: EMI address to program
802 * @data: pointer to value to read/write from/to the EMI address
803 * @read: boolean flag to indicate read or write
805 * This helper function assumes the SW/FW/HW Semaphore is already acquired.
807 static s32
__e1000_access_emi_reg_locked(struct e1000_hw
*hw
, u16 address
,
808 u16
*data
, bool read
)
812 ret_val
= e1e_wphy_locked(hw
, I82579_EMI_ADDR
, address
);
817 ret_val
= e1e_rphy_locked(hw
, I82579_EMI_DATA
, data
);
819 ret_val
= e1e_wphy_locked(hw
, I82579_EMI_DATA
, *data
);
825 * e1000_read_emi_reg_locked - Read Extended Management Interface register
826 * @hw: pointer to the HW structure
827 * @addr: EMI address to program
828 * @data: value to be read from the EMI address
830 * Assumes the SW/FW/HW Semaphore is already acquired.
832 static s32
e1000_read_emi_reg_locked(struct e1000_hw
*hw
, u16 addr
, u16
*data
)
834 return __e1000_access_emi_reg_locked(hw
, addr
, data
, true);
838 * e1000_write_emi_reg_locked - Write Extended Management Interface register
839 * @hw: pointer to the HW structure
840 * @addr: EMI address to program
841 * @data: value to be written to the EMI address
843 * Assumes the SW/FW/HW Semaphore is already acquired.
845 static s32
e1000_write_emi_reg_locked(struct e1000_hw
*hw
, u16 addr
, u16 data
)
847 return __e1000_access_emi_reg_locked(hw
, addr
, &data
, false);
851 * e1000_set_eee_pchlan - Enable/disable EEE support
852 * @hw: pointer to the HW structure
854 * Enable/disable EEE based on setting in dev_spec structure, the duplex of
855 * the link and the EEE capabilities of the link partner. The LPI Control
856 * register bits will remain set only if/when link is up.
858 static s32
e1000_set_eee_pchlan(struct e1000_hw
*hw
)
860 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
864 if ((hw
->phy
.type
!= e1000_phy_82579
) &&
865 (hw
->phy
.type
!= e1000_phy_i217
))
868 ret_val
= hw
->phy
.ops
.acquire(hw
);
872 ret_val
= e1e_rphy_locked(hw
, I82579_LPI_CTRL
, &lpi_ctrl
);
876 /* Clear bits that enable EEE in various speeds */
877 lpi_ctrl
&= ~I82579_LPI_CTRL_ENABLE_MASK
;
879 /* Enable EEE if not disabled by user */
880 if (!dev_spec
->eee_disable
) {
881 u16 lpa
, pcs_status
, data
;
883 /* Save off link partner's EEE ability */
884 switch (hw
->phy
.type
) {
885 case e1000_phy_82579
:
886 lpa
= I82579_EEE_LP_ABILITY
;
887 pcs_status
= I82579_EEE_PCS_STATUS
;
890 lpa
= I217_EEE_LP_ABILITY
;
891 pcs_status
= I217_EEE_PCS_STATUS
;
894 ret_val
= -E1000_ERR_PHY
;
897 ret_val
= e1000_read_emi_reg_locked(hw
, lpa
,
898 &dev_spec
->eee_lp_ability
);
902 /* Enable EEE only for speeds in which the link partner is
905 if (dev_spec
->eee_lp_ability
& I82579_EEE_1000_SUPPORTED
)
906 lpi_ctrl
|= I82579_LPI_CTRL_1000_ENABLE
;
908 if (dev_spec
->eee_lp_ability
& I82579_EEE_100_SUPPORTED
) {
909 e1e_rphy_locked(hw
, PHY_LP_ABILITY
, &data
);
910 if (data
& NWAY_LPAR_100TX_FD_CAPS
)
911 lpi_ctrl
|= I82579_LPI_CTRL_100_ENABLE
;
913 /* EEE is not supported in 100Half, so ignore
914 * partner's EEE in 100 ability if full-duplex
917 dev_spec
->eee_lp_ability
&=
918 ~I82579_EEE_100_SUPPORTED
;
921 /* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */
922 ret_val
= e1000_read_emi_reg_locked(hw
, pcs_status
, &data
);
927 ret_val
= e1e_wphy_locked(hw
, I82579_LPI_CTRL
, lpi_ctrl
);
929 hw
->phy
.ops
.release(hw
);
935 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
936 * @hw: pointer to the HW structure
938 * Checks to see of the link status of the hardware has changed. If a
939 * change in link status has been detected, then we read the PHY registers
940 * to get the current speed/duplex if link exists.
942 static s32
e1000_check_for_copper_link_ich8lan(struct e1000_hw
*hw
)
944 struct e1000_mac_info
*mac
= &hw
->mac
;
949 /* We only want to go out to the PHY registers to see if Auto-Neg
950 * has completed and/or if our link status has changed. The
951 * get_link_status flag is set upon receiving a Link Status
952 * Change or Rx Sequence Error interrupt.
954 if (!mac
->get_link_status
)
957 /* First we want to see if the MII Status Register reports
958 * link. If so, then we want to get the current speed/duplex
961 ret_val
= e1000e_phy_has_link_generic(hw
, 1, 0, &link
);
965 if (hw
->mac
.type
== e1000_pchlan
) {
966 ret_val
= e1000_k1_gig_workaround_hv(hw
, link
);
971 /* Clear link partner's EEE ability */
972 hw
->dev_spec
.ich8lan
.eee_lp_ability
= 0;
975 return 0; /* No link detected */
977 mac
->get_link_status
= false;
979 switch (hw
->mac
.type
) {
981 ret_val
= e1000_k1_workaround_lv(hw
);
986 if (hw
->phy
.type
== e1000_phy_82578
) {
987 ret_val
= e1000_link_stall_workaround_hv(hw
);
992 /* Workaround for PCHx parts in half-duplex:
993 * Set the number of preambles removed from the packet
994 * when it is passed from the PHY to the MAC to prevent
995 * the MAC from misinterpreting the packet type.
997 e1e_rphy(hw
, HV_KMRN_FIFO_CTRLSTA
, &phy_reg
);
998 phy_reg
&= ~HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK
;
1000 if ((er32(STATUS
) & E1000_STATUS_FD
) != E1000_STATUS_FD
)
1001 phy_reg
|= (1 << HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT
);
1003 e1e_wphy(hw
, HV_KMRN_FIFO_CTRLSTA
, phy_reg
);
1009 /* Check if there was DownShift, must be checked
1010 * immediately after link-up
1012 e1000e_check_downshift(hw
);
1014 /* Enable/Disable EEE after link up */
1015 ret_val
= e1000_set_eee_pchlan(hw
);
1019 /* If we are forcing speed/duplex, then we simply return since
1020 * we have already determined whether we have link or not.
1023 return -E1000_ERR_CONFIG
;
1025 /* Auto-Neg is enabled. Auto Speed Detection takes care
1026 * of MAC speed/duplex configuration. So we only need to
1027 * configure Collision Distance in the MAC.
1029 mac
->ops
.config_collision_dist(hw
);
1031 /* Configure Flow Control now that Auto-Neg has completed.
1032 * First, we need to restore the desired flow control
1033 * settings because we may have had to re-autoneg with a
1034 * different link partner.
1036 ret_val
= e1000e_config_fc_after_link_up(hw
);
1038 e_dbg("Error configuring flow control\n");
1043 static s32
e1000_get_variants_ich8lan(struct e1000_adapter
*adapter
)
1045 struct e1000_hw
*hw
= &adapter
->hw
;
1048 rc
= e1000_init_mac_params_ich8lan(hw
);
1052 rc
= e1000_init_nvm_params_ich8lan(hw
);
1056 switch (hw
->mac
.type
) {
1059 case e1000_ich10lan
:
1060 rc
= e1000_init_phy_params_ich8lan(hw
);
1065 rc
= e1000_init_phy_params_pchlan(hw
);
1073 /* Disable Jumbo Frame support on parts with Intel 10/100 PHY or
1074 * on parts with MACsec enabled in NVM (reflected in CTRL_EXT).
1076 if ((adapter
->hw
.phy
.type
== e1000_phy_ife
) ||
1077 ((adapter
->hw
.mac
.type
>= e1000_pch2lan
) &&
1078 (!(er32(CTRL_EXT
) & E1000_CTRL_EXT_LSECCK
)))) {
1079 adapter
->flags
&= ~FLAG_HAS_JUMBO_FRAMES
;
1080 adapter
->max_hw_frame_size
= ETH_FRAME_LEN
+ ETH_FCS_LEN
;
1082 hw
->mac
.ops
.blink_led
= NULL
;
1085 if ((adapter
->hw
.mac
.type
== e1000_ich8lan
) &&
1086 (adapter
->hw
.phy
.type
!= e1000_phy_ife
))
1087 adapter
->flags
|= FLAG_LSC_GIG_SPEED_DROP
;
1089 /* Enable workaround for 82579 w/ ME enabled */
1090 if ((adapter
->hw
.mac
.type
== e1000_pch2lan
) &&
1091 (er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
))
1092 adapter
->flags2
|= FLAG2_PCIM2PCI_ARBITER_WA
;
1094 /* Disable EEE by default until IEEE802.3az spec is finalized */
1095 if (adapter
->flags2
& FLAG2_HAS_EEE
)
1096 adapter
->hw
.dev_spec
.ich8lan
.eee_disable
= true;
1101 static DEFINE_MUTEX(nvm_mutex
);
1104 * e1000_acquire_nvm_ich8lan - Acquire NVM mutex
1105 * @hw: pointer to the HW structure
1107 * Acquires the mutex for performing NVM operations.
1109 static s32
e1000_acquire_nvm_ich8lan(struct e1000_hw
*hw
)
1111 mutex_lock(&nvm_mutex
);
1117 * e1000_release_nvm_ich8lan - Release NVM mutex
1118 * @hw: pointer to the HW structure
1120 * Releases the mutex used while performing NVM operations.
1122 static void e1000_release_nvm_ich8lan(struct e1000_hw
*hw
)
1124 mutex_unlock(&nvm_mutex
);
1128 * e1000_acquire_swflag_ich8lan - Acquire software control flag
1129 * @hw: pointer to the HW structure
1131 * Acquires the software control flag for performing PHY and select
1134 static s32
e1000_acquire_swflag_ich8lan(struct e1000_hw
*hw
)
1136 u32 extcnf_ctrl
, timeout
= PHY_CFG_TIMEOUT
;
1139 if (test_and_set_bit(__E1000_ACCESS_SHARED_RESOURCE
,
1140 &hw
->adapter
->state
)) {
1141 e_dbg("contention for Phy access\n");
1142 return -E1000_ERR_PHY
;
1146 extcnf_ctrl
= er32(EXTCNF_CTRL
);
1147 if (!(extcnf_ctrl
& E1000_EXTCNF_CTRL_SWFLAG
))
1155 e_dbg("SW has already locked the resource.\n");
1156 ret_val
= -E1000_ERR_CONFIG
;
1160 timeout
= SW_FLAG_TIMEOUT
;
1162 extcnf_ctrl
|= E1000_EXTCNF_CTRL_SWFLAG
;
1163 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
1166 extcnf_ctrl
= er32(EXTCNF_CTRL
);
1167 if (extcnf_ctrl
& E1000_EXTCNF_CTRL_SWFLAG
)
1175 e_dbg("Failed to acquire the semaphore, FW or HW has it: FWSM=0x%8.8x EXTCNF_CTRL=0x%8.8x)\n",
1176 er32(FWSM
), extcnf_ctrl
);
1177 extcnf_ctrl
&= ~E1000_EXTCNF_CTRL_SWFLAG
;
1178 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
1179 ret_val
= -E1000_ERR_CONFIG
;
1185 clear_bit(__E1000_ACCESS_SHARED_RESOURCE
, &hw
->adapter
->state
);
1191 * e1000_release_swflag_ich8lan - Release software control flag
1192 * @hw: pointer to the HW structure
1194 * Releases the software control flag for performing PHY and select
1197 static void e1000_release_swflag_ich8lan(struct e1000_hw
*hw
)
1201 extcnf_ctrl
= er32(EXTCNF_CTRL
);
1203 if (extcnf_ctrl
& E1000_EXTCNF_CTRL_SWFLAG
) {
1204 extcnf_ctrl
&= ~E1000_EXTCNF_CTRL_SWFLAG
;
1205 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
1207 e_dbg("Semaphore unexpectedly released by sw/fw/hw\n");
1210 clear_bit(__E1000_ACCESS_SHARED_RESOURCE
, &hw
->adapter
->state
);
1214 * e1000_check_mng_mode_ich8lan - Checks management mode
1215 * @hw: pointer to the HW structure
1217 * This checks if the adapter has any manageability enabled.
1218 * This is a function pointer entry point only called by read/write
1219 * routines for the PHY and NVM parts.
1221 static bool e1000_check_mng_mode_ich8lan(struct e1000_hw
*hw
)
1226 return (fwsm
& E1000_ICH_FWSM_FW_VALID
) &&
1227 ((fwsm
& E1000_FWSM_MODE_MASK
) ==
1228 (E1000_ICH_MNG_IAMT_MODE
<< E1000_FWSM_MODE_SHIFT
));
1232 * e1000_check_mng_mode_pchlan - Checks management mode
1233 * @hw: pointer to the HW structure
1235 * This checks if the adapter has iAMT enabled.
1236 * This is a function pointer entry point only called by read/write
1237 * routines for the PHY and NVM parts.
1239 static bool e1000_check_mng_mode_pchlan(struct e1000_hw
*hw
)
1244 return (fwsm
& E1000_ICH_FWSM_FW_VALID
) &&
1245 (fwsm
& (E1000_ICH_MNG_IAMT_MODE
<< E1000_FWSM_MODE_SHIFT
));
1249 * e1000_rar_set_pch2lan - Set receive address register
1250 * @hw: pointer to the HW structure
1251 * @addr: pointer to the receive address
1252 * @index: receive address array register
1254 * Sets the receive address array register at index to the address passed
1255 * in by addr. For 82579, RAR[0] is the base address register that is to
1256 * contain the MAC address but RAR[1-6] are reserved for manageability (ME).
1257 * Use SHRA[0-3] in place of those reserved for ME.
1259 static void e1000_rar_set_pch2lan(struct e1000_hw
*hw
, u8
*addr
, u32 index
)
1261 u32 rar_low
, rar_high
;
1263 /* HW expects these in little endian so we reverse the byte order
1264 * from network order (big endian) to little endian
1266 rar_low
= ((u32
)addr
[0] |
1267 ((u32
)addr
[1] << 8) |
1268 ((u32
)addr
[2] << 16) | ((u32
)addr
[3] << 24));
1270 rar_high
= ((u32
)addr
[4] | ((u32
)addr
[5] << 8));
1272 /* If MAC address zero, no need to set the AV bit */
1273 if (rar_low
|| rar_high
)
1274 rar_high
|= E1000_RAH_AV
;
1277 ew32(RAL(index
), rar_low
);
1279 ew32(RAH(index
), rar_high
);
1284 if (index
< hw
->mac
.rar_entry_count
) {
1287 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
1291 ew32(SHRAL(index
- 1), rar_low
);
1293 ew32(SHRAH(index
- 1), rar_high
);
1296 e1000_release_swflag_ich8lan(hw
);
1298 /* verify the register updates */
1299 if ((er32(SHRAL(index
- 1)) == rar_low
) &&
1300 (er32(SHRAH(index
- 1)) == rar_high
))
1303 e_dbg("SHRA[%d] might be locked by ME - FWSM=0x%8.8x\n",
1304 (index
- 1), er32(FWSM
));
1308 e_dbg("Failed to write receive address at index %d\n", index
);
1312 * e1000_rar_set_pch_lpt - Set receive address registers
1313 * @hw: pointer to the HW structure
1314 * @addr: pointer to the receive address
1315 * @index: receive address array register
1317 * Sets the receive address register array at index to the address passed
1318 * in by addr. For LPT, RAR[0] is the base address register that is to
1319 * contain the MAC address. SHRA[0-10] are the shared receive address
1320 * registers that are shared between the Host and manageability engine (ME).
1322 static void e1000_rar_set_pch_lpt(struct e1000_hw
*hw
, u8
*addr
, u32 index
)
1324 u32 rar_low
, rar_high
;
1327 /* HW expects these in little endian so we reverse the byte order
1328 * from network order (big endian) to little endian
1330 rar_low
= ((u32
)addr
[0] | ((u32
)addr
[1] << 8) |
1331 ((u32
)addr
[2] << 16) | ((u32
)addr
[3] << 24));
1333 rar_high
= ((u32
)addr
[4] | ((u32
)addr
[5] << 8));
1335 /* If MAC address zero, no need to set the AV bit */
1336 if (rar_low
|| rar_high
)
1337 rar_high
|= E1000_RAH_AV
;
1340 ew32(RAL(index
), rar_low
);
1342 ew32(RAH(index
), rar_high
);
1347 /* The manageability engine (ME) can lock certain SHRAR registers that
1348 * it is using - those registers are unavailable for use.
1350 if (index
< hw
->mac
.rar_entry_count
) {
1351 wlock_mac
= er32(FWSM
) & E1000_FWSM_WLOCK_MAC_MASK
;
1352 wlock_mac
>>= E1000_FWSM_WLOCK_MAC_SHIFT
;
1354 /* Check if all SHRAR registers are locked */
1358 if ((wlock_mac
== 0) || (index
<= wlock_mac
)) {
1361 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
1366 ew32(SHRAL_PCH_LPT(index
- 1), rar_low
);
1368 ew32(SHRAH_PCH_LPT(index
- 1), rar_high
);
1371 e1000_release_swflag_ich8lan(hw
);
1373 /* verify the register updates */
1374 if ((er32(SHRAL_PCH_LPT(index
- 1)) == rar_low
) &&
1375 (er32(SHRAH_PCH_LPT(index
- 1)) == rar_high
))
1381 e_dbg("Failed to write receive address at index %d\n", index
);
1385 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
1386 * @hw: pointer to the HW structure
1388 * Checks if firmware is blocking the reset of the PHY.
1389 * This is a function pointer entry point only called by
1392 static s32
e1000_check_reset_block_ich8lan(struct e1000_hw
*hw
)
1398 return (fwsm
& E1000_ICH_FWSM_RSPCIPHY
) ? 0 : E1000_BLK_PHY_RESET
;
1402 * e1000_write_smbus_addr - Write SMBus address to PHY needed during Sx states
1403 * @hw: pointer to the HW structure
1405 * Assumes semaphore already acquired.
1408 static s32
e1000_write_smbus_addr(struct e1000_hw
*hw
)
1411 u32 strap
= er32(STRAP
);
1412 u32 freq
= (strap
& E1000_STRAP_SMT_FREQ_MASK
) >>
1413 E1000_STRAP_SMT_FREQ_SHIFT
;
1416 strap
&= E1000_STRAP_SMBUS_ADDRESS_MASK
;
1418 ret_val
= e1000_read_phy_reg_hv_locked(hw
, HV_SMB_ADDR
, &phy_data
);
1422 phy_data
&= ~HV_SMB_ADDR_MASK
;
1423 phy_data
|= (strap
>> E1000_STRAP_SMBUS_ADDRESS_SHIFT
);
1424 phy_data
|= HV_SMB_ADDR_PEC_EN
| HV_SMB_ADDR_VALID
;
1426 if (hw
->phy
.type
== e1000_phy_i217
) {
1427 /* Restore SMBus frequency */
1429 phy_data
&= ~HV_SMB_ADDR_FREQ_MASK
;
1430 phy_data
|= (freq
& (1 << 0)) <<
1431 HV_SMB_ADDR_FREQ_LOW_SHIFT
;
1432 phy_data
|= (freq
& (1 << 1)) <<
1433 (HV_SMB_ADDR_FREQ_HIGH_SHIFT
- 1);
1435 e_dbg("Unsupported SMB frequency in PHY\n");
1439 return e1000_write_phy_reg_hv_locked(hw
, HV_SMB_ADDR
, phy_data
);
1443 * e1000_sw_lcd_config_ich8lan - SW-based LCD Configuration
1444 * @hw: pointer to the HW structure
1446 * SW should configure the LCD from the NVM extended configuration region
1447 * as a workaround for certain parts.
1449 static s32
e1000_sw_lcd_config_ich8lan(struct e1000_hw
*hw
)
1451 struct e1000_phy_info
*phy
= &hw
->phy
;
1452 u32 i
, data
, cnf_size
, cnf_base_addr
, sw_cfg_mask
;
1454 u16 word_addr
, reg_data
, reg_addr
, phy_page
= 0;
1456 /* Initialize the PHY from the NVM on ICH platforms. This
1457 * is needed due to an issue where the NVM configuration is
1458 * not properly autoloaded after power transitions.
1459 * Therefore, after each PHY reset, we will load the
1460 * configuration data out of the NVM manually.
1462 switch (hw
->mac
.type
) {
1464 if (phy
->type
!= e1000_phy_igp_3
)
1467 if ((hw
->adapter
->pdev
->device
== E1000_DEV_ID_ICH8_IGP_AMT
) ||
1468 (hw
->adapter
->pdev
->device
== E1000_DEV_ID_ICH8_IGP_C
)) {
1469 sw_cfg_mask
= E1000_FEXTNVM_SW_CONFIG
;
1476 sw_cfg_mask
= E1000_FEXTNVM_SW_CONFIG_ICH8M
;
1482 ret_val
= hw
->phy
.ops
.acquire(hw
);
1486 data
= er32(FEXTNVM
);
1487 if (!(data
& sw_cfg_mask
))
1490 /* Make sure HW does not configure LCD from PHY
1491 * extended configuration before SW configuration
1493 data
= er32(EXTCNF_CTRL
);
1494 if ((hw
->mac
.type
< e1000_pch2lan
) &&
1495 (data
& E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE
))
1498 cnf_size
= er32(EXTCNF_SIZE
);
1499 cnf_size
&= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK
;
1500 cnf_size
>>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT
;
1504 cnf_base_addr
= data
& E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK
;
1505 cnf_base_addr
>>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT
;
1507 if (((hw
->mac
.type
== e1000_pchlan
) &&
1508 !(data
& E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE
)) ||
1509 (hw
->mac
.type
> e1000_pchlan
)) {
1510 /* HW configures the SMBus address and LEDs when the
1511 * OEM and LCD Write Enable bits are set in the NVM.
1512 * When both NVM bits are cleared, SW will configure
1515 ret_val
= e1000_write_smbus_addr(hw
);
1519 data
= er32(LEDCTL
);
1520 ret_val
= e1000_write_phy_reg_hv_locked(hw
, HV_LED_CONFIG
,
1526 /* Configure LCD from extended configuration region. */
1528 /* cnf_base_addr is in DWORD */
1529 word_addr
= (u16
)(cnf_base_addr
<< 1);
1531 for (i
= 0; i
< cnf_size
; i
++) {
1532 ret_val
= e1000_read_nvm(hw
, (word_addr
+ i
* 2), 1,
1537 ret_val
= e1000_read_nvm(hw
, (word_addr
+ i
* 2 + 1),
1542 /* Save off the PHY page for future writes. */
1543 if (reg_addr
== IGP01E1000_PHY_PAGE_SELECT
) {
1544 phy_page
= reg_data
;
1548 reg_addr
&= PHY_REG_MASK
;
1549 reg_addr
|= phy_page
;
1551 ret_val
= e1e_wphy_locked(hw
, (u32
)reg_addr
, reg_data
);
1557 hw
->phy
.ops
.release(hw
);
1562 * e1000_k1_gig_workaround_hv - K1 Si workaround
1563 * @hw: pointer to the HW structure
1564 * @link: link up bool flag
1566 * If K1 is enabled for 1Gbps, the MAC might stall when transitioning
1567 * from a lower speed. This workaround disables K1 whenever link is at 1Gig
1568 * If link is down, the function will restore the default K1 setting located
1571 static s32
e1000_k1_gig_workaround_hv(struct e1000_hw
*hw
, bool link
)
1575 bool k1_enable
= hw
->dev_spec
.ich8lan
.nvm_k1_enabled
;
1577 if (hw
->mac
.type
!= e1000_pchlan
)
1580 /* Wrap the whole flow with the sw flag */
1581 ret_val
= hw
->phy
.ops
.acquire(hw
);
1585 /* Disable K1 when link is 1Gbps, otherwise use the NVM setting */
1587 if (hw
->phy
.type
== e1000_phy_82578
) {
1588 ret_val
= e1e_rphy_locked(hw
, BM_CS_STATUS
,
1593 status_reg
&= BM_CS_STATUS_LINK_UP
|
1594 BM_CS_STATUS_RESOLVED
|
1595 BM_CS_STATUS_SPEED_MASK
;
1597 if (status_reg
== (BM_CS_STATUS_LINK_UP
|
1598 BM_CS_STATUS_RESOLVED
|
1599 BM_CS_STATUS_SPEED_1000
))
1603 if (hw
->phy
.type
== e1000_phy_82577
) {
1604 ret_val
= e1e_rphy_locked(hw
, HV_M_STATUS
, &status_reg
);
1608 status_reg
&= HV_M_STATUS_LINK_UP
|
1609 HV_M_STATUS_AUTONEG_COMPLETE
|
1610 HV_M_STATUS_SPEED_MASK
;
1612 if (status_reg
== (HV_M_STATUS_LINK_UP
|
1613 HV_M_STATUS_AUTONEG_COMPLETE
|
1614 HV_M_STATUS_SPEED_1000
))
1618 /* Link stall fix for link up */
1619 ret_val
= e1e_wphy_locked(hw
, PHY_REG(770, 19), 0x0100);
1624 /* Link stall fix for link down */
1625 ret_val
= e1e_wphy_locked(hw
, PHY_REG(770, 19), 0x4100);
1630 ret_val
= e1000_configure_k1_ich8lan(hw
, k1_enable
);
1633 hw
->phy
.ops
.release(hw
);
1639 * e1000_configure_k1_ich8lan - Configure K1 power state
1640 * @hw: pointer to the HW structure
1641 * @enable: K1 state to configure
1643 * Configure the K1 power state based on the provided parameter.
1644 * Assumes semaphore already acquired.
1646 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1648 s32
e1000_configure_k1_ich8lan(struct e1000_hw
*hw
, bool k1_enable
)
1656 ret_val
= e1000e_read_kmrn_reg_locked(hw
, E1000_KMRNCTRLSTA_K1_CONFIG
,
1662 kmrn_reg
|= E1000_KMRNCTRLSTA_K1_ENABLE
;
1664 kmrn_reg
&= ~E1000_KMRNCTRLSTA_K1_ENABLE
;
1666 ret_val
= e1000e_write_kmrn_reg_locked(hw
, E1000_KMRNCTRLSTA_K1_CONFIG
,
1672 ctrl_ext
= er32(CTRL_EXT
);
1673 ctrl_reg
= er32(CTRL
);
1675 reg
= ctrl_reg
& ~(E1000_CTRL_SPD_1000
| E1000_CTRL_SPD_100
);
1676 reg
|= E1000_CTRL_FRCSPD
;
1679 ew32(CTRL_EXT
, ctrl_ext
| E1000_CTRL_EXT_SPD_BYPS
);
1682 ew32(CTRL
, ctrl_reg
);
1683 ew32(CTRL_EXT
, ctrl_ext
);
1691 * e1000_oem_bits_config_ich8lan - SW-based LCD Configuration
1692 * @hw: pointer to the HW structure
1693 * @d0_state: boolean if entering d0 or d3 device state
1695 * SW will configure Gbe Disable and LPLU based on the NVM. The four bits are
1696 * collectively called OEM bits. The OEM Write Enable bit and SW Config bit
1697 * in NVM determines whether HW should configure LPLU and Gbe Disable.
1699 static s32
e1000_oem_bits_config_ich8lan(struct e1000_hw
*hw
, bool d0_state
)
1705 if (hw
->mac
.type
< e1000_pchlan
)
1708 ret_val
= hw
->phy
.ops
.acquire(hw
);
1712 if (hw
->mac
.type
== e1000_pchlan
) {
1713 mac_reg
= er32(EXTCNF_CTRL
);
1714 if (mac_reg
& E1000_EXTCNF_CTRL_OEM_WRITE_ENABLE
)
1718 mac_reg
= er32(FEXTNVM
);
1719 if (!(mac_reg
& E1000_FEXTNVM_SW_CONFIG_ICH8M
))
1722 mac_reg
= er32(PHY_CTRL
);
1724 ret_val
= e1e_rphy_locked(hw
, HV_OEM_BITS
, &oem_reg
);
1728 oem_reg
&= ~(HV_OEM_BITS_GBE_DIS
| HV_OEM_BITS_LPLU
);
1731 if (mac_reg
& E1000_PHY_CTRL_GBE_DISABLE
)
1732 oem_reg
|= HV_OEM_BITS_GBE_DIS
;
1734 if (mac_reg
& E1000_PHY_CTRL_D0A_LPLU
)
1735 oem_reg
|= HV_OEM_BITS_LPLU
;
1737 if (mac_reg
& (E1000_PHY_CTRL_GBE_DISABLE
|
1738 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
))
1739 oem_reg
|= HV_OEM_BITS_GBE_DIS
;
1741 if (mac_reg
& (E1000_PHY_CTRL_D0A_LPLU
|
1742 E1000_PHY_CTRL_NOND0A_LPLU
))
1743 oem_reg
|= HV_OEM_BITS_LPLU
;
1746 /* Set Restart auto-neg to activate the bits */
1747 if ((d0_state
|| (hw
->mac
.type
!= e1000_pchlan
)) &&
1748 !hw
->phy
.ops
.check_reset_block(hw
))
1749 oem_reg
|= HV_OEM_BITS_RESTART_AN
;
1751 ret_val
= e1e_wphy_locked(hw
, HV_OEM_BITS
, oem_reg
);
1754 hw
->phy
.ops
.release(hw
);
1761 * e1000_set_mdio_slow_mode_hv - Set slow MDIO access mode
1762 * @hw: pointer to the HW structure
1764 static s32
e1000_set_mdio_slow_mode_hv(struct e1000_hw
*hw
)
1769 ret_val
= e1e_rphy(hw
, HV_KMRN_MODE_CTRL
, &data
);
1773 data
|= HV_KMRN_MDIO_SLOW
;
1775 ret_val
= e1e_wphy(hw
, HV_KMRN_MODE_CTRL
, data
);
1781 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
1782 * done after every PHY reset.
1784 static s32
e1000_hv_phy_workarounds_ich8lan(struct e1000_hw
*hw
)
1789 if (hw
->mac
.type
!= e1000_pchlan
)
1792 /* Set MDIO slow mode before any other MDIO access */
1793 if (hw
->phy
.type
== e1000_phy_82577
) {
1794 ret_val
= e1000_set_mdio_slow_mode_hv(hw
);
1799 if (((hw
->phy
.type
== e1000_phy_82577
) &&
1800 ((hw
->phy
.revision
== 1) || (hw
->phy
.revision
== 2))) ||
1801 ((hw
->phy
.type
== e1000_phy_82578
) && (hw
->phy
.revision
== 1))) {
1802 /* Disable generation of early preamble */
1803 ret_val
= e1e_wphy(hw
, PHY_REG(769, 25), 0x4431);
1807 /* Preamble tuning for SSC */
1808 ret_val
= e1e_wphy(hw
, HV_KMRN_FIFO_CTRLSTA
, 0xA204);
1813 if (hw
->phy
.type
== e1000_phy_82578
) {
1814 /* Return registers to default by doing a soft reset then
1815 * writing 0x3140 to the control register.
1817 if (hw
->phy
.revision
< 2) {
1818 e1000e_phy_sw_reset(hw
);
1819 ret_val
= e1e_wphy(hw
, PHY_CONTROL
, 0x3140);
1824 ret_val
= hw
->phy
.ops
.acquire(hw
);
1829 ret_val
= e1000e_write_phy_reg_mdic(hw
, IGP01E1000_PHY_PAGE_SELECT
, 0);
1830 hw
->phy
.ops
.release(hw
);
1834 /* Configure the K1 Si workaround during phy reset assuming there is
1835 * link so that it disables K1 if link is in 1Gbps.
1837 ret_val
= e1000_k1_gig_workaround_hv(hw
, true);
1841 /* Workaround for link disconnects on a busy hub in half duplex */
1842 ret_val
= hw
->phy
.ops
.acquire(hw
);
1845 ret_val
= e1e_rphy_locked(hw
, BM_PORT_GEN_CFG
, &phy_data
);
1848 ret_val
= e1e_wphy_locked(hw
, BM_PORT_GEN_CFG
, phy_data
& 0x00FF);
1852 /* set MSE higher to enable link to stay up when noise is high */
1853 ret_val
= e1000_write_emi_reg_locked(hw
, I82577_MSE_THRESHOLD
, 0x0034);
1855 hw
->phy
.ops
.release(hw
);
1861 * e1000_copy_rx_addrs_to_phy_ich8lan - Copy Rx addresses from MAC to PHY
1862 * @hw: pointer to the HW structure
1864 void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw
*hw
)
1870 ret_val
= hw
->phy
.ops
.acquire(hw
);
1873 ret_val
= e1000_enable_phy_wakeup_reg_access_bm(hw
, &phy_reg
);
1877 /* Copy both RAL/H (rar_entry_count) and SHRAL/H (+4) to PHY */
1878 for (i
= 0; i
< (hw
->mac
.rar_entry_count
+ 4); i
++) {
1879 mac_reg
= er32(RAL(i
));
1880 hw
->phy
.ops
.write_reg_page(hw
, BM_RAR_L(i
),
1881 (u16
)(mac_reg
& 0xFFFF));
1882 hw
->phy
.ops
.write_reg_page(hw
, BM_RAR_M(i
),
1883 (u16
)((mac_reg
>> 16) & 0xFFFF));
1885 mac_reg
= er32(RAH(i
));
1886 hw
->phy
.ops
.write_reg_page(hw
, BM_RAR_H(i
),
1887 (u16
)(mac_reg
& 0xFFFF));
1888 hw
->phy
.ops
.write_reg_page(hw
, BM_RAR_CTRL(i
),
1889 (u16
)((mac_reg
& E1000_RAH_AV
)
1893 e1000_disable_phy_wakeup_reg_access_bm(hw
, &phy_reg
);
1896 hw
->phy
.ops
.release(hw
);
1900 * e1000_lv_jumbo_workaround_ich8lan - required for jumbo frame operation
1902 * @hw: pointer to the HW structure
1903 * @enable: flag to enable/disable workaround when enabling/disabling jumbos
1905 s32
e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw
*hw
, bool enable
)
1912 if (hw
->mac
.type
< e1000_pch2lan
)
1915 /* disable Rx path while enabling/disabling workaround */
1916 e1e_rphy(hw
, PHY_REG(769, 20), &phy_reg
);
1917 ret_val
= e1e_wphy(hw
, PHY_REG(769, 20), phy_reg
| (1 << 14));
1922 /* Write Rx addresses (rar_entry_count for RAL/H, +4 for
1923 * SHRAL/H) and initial CRC values to the MAC
1925 for (i
= 0; i
< (hw
->mac
.rar_entry_count
+ 4); i
++) {
1926 u8 mac_addr
[ETH_ALEN
] = {0};
1927 u32 addr_high
, addr_low
;
1929 addr_high
= er32(RAH(i
));
1930 if (!(addr_high
& E1000_RAH_AV
))
1932 addr_low
= er32(RAL(i
));
1933 mac_addr
[0] = (addr_low
& 0xFF);
1934 mac_addr
[1] = ((addr_low
>> 8) & 0xFF);
1935 mac_addr
[2] = ((addr_low
>> 16) & 0xFF);
1936 mac_addr
[3] = ((addr_low
>> 24) & 0xFF);
1937 mac_addr
[4] = (addr_high
& 0xFF);
1938 mac_addr
[5] = ((addr_high
>> 8) & 0xFF);
1940 ew32(PCH_RAICC(i
), ~ether_crc_le(ETH_ALEN
, mac_addr
));
1943 /* Write Rx addresses to the PHY */
1944 e1000_copy_rx_addrs_to_phy_ich8lan(hw
);
1946 /* Enable jumbo frame workaround in the MAC */
1947 mac_reg
= er32(FFLT_DBG
);
1948 mac_reg
&= ~(1 << 14);
1949 mac_reg
|= (7 << 15);
1950 ew32(FFLT_DBG
, mac_reg
);
1952 mac_reg
= er32(RCTL
);
1953 mac_reg
|= E1000_RCTL_SECRC
;
1954 ew32(RCTL
, mac_reg
);
1956 ret_val
= e1000e_read_kmrn_reg(hw
,
1957 E1000_KMRNCTRLSTA_CTRL_OFFSET
,
1961 ret_val
= e1000e_write_kmrn_reg(hw
,
1962 E1000_KMRNCTRLSTA_CTRL_OFFSET
,
1966 ret_val
= e1000e_read_kmrn_reg(hw
,
1967 E1000_KMRNCTRLSTA_HD_CTRL
,
1971 data
&= ~(0xF << 8);
1973 ret_val
= e1000e_write_kmrn_reg(hw
,
1974 E1000_KMRNCTRLSTA_HD_CTRL
,
1979 /* Enable jumbo frame workaround in the PHY */
1980 e1e_rphy(hw
, PHY_REG(769, 23), &data
);
1981 data
&= ~(0x7F << 5);
1982 data
|= (0x37 << 5);
1983 ret_val
= e1e_wphy(hw
, PHY_REG(769, 23), data
);
1986 e1e_rphy(hw
, PHY_REG(769, 16), &data
);
1988 ret_val
= e1e_wphy(hw
, PHY_REG(769, 16), data
);
1991 e1e_rphy(hw
, PHY_REG(776, 20), &data
);
1992 data
&= ~(0x3FF << 2);
1993 data
|= (0x1A << 2);
1994 ret_val
= e1e_wphy(hw
, PHY_REG(776, 20), data
);
1997 ret_val
= e1e_wphy(hw
, PHY_REG(776, 23), 0xF100);
2000 e1e_rphy(hw
, HV_PM_CTRL
, &data
);
2001 ret_val
= e1e_wphy(hw
, HV_PM_CTRL
, data
| (1 << 10));
2005 /* Write MAC register values back to h/w defaults */
2006 mac_reg
= er32(FFLT_DBG
);
2007 mac_reg
&= ~(0xF << 14);
2008 ew32(FFLT_DBG
, mac_reg
);
2010 mac_reg
= er32(RCTL
);
2011 mac_reg
&= ~E1000_RCTL_SECRC
;
2012 ew32(RCTL
, mac_reg
);
2014 ret_val
= e1000e_read_kmrn_reg(hw
,
2015 E1000_KMRNCTRLSTA_CTRL_OFFSET
,
2019 ret_val
= e1000e_write_kmrn_reg(hw
,
2020 E1000_KMRNCTRLSTA_CTRL_OFFSET
,
2024 ret_val
= e1000e_read_kmrn_reg(hw
,
2025 E1000_KMRNCTRLSTA_HD_CTRL
,
2029 data
&= ~(0xF << 8);
2031 ret_val
= e1000e_write_kmrn_reg(hw
,
2032 E1000_KMRNCTRLSTA_HD_CTRL
,
2037 /* Write PHY register values back to h/w defaults */
2038 e1e_rphy(hw
, PHY_REG(769, 23), &data
);
2039 data
&= ~(0x7F << 5);
2040 ret_val
= e1e_wphy(hw
, PHY_REG(769, 23), data
);
2043 e1e_rphy(hw
, PHY_REG(769, 16), &data
);
2045 ret_val
= e1e_wphy(hw
, PHY_REG(769, 16), data
);
2048 e1e_rphy(hw
, PHY_REG(776, 20), &data
);
2049 data
&= ~(0x3FF << 2);
2051 ret_val
= e1e_wphy(hw
, PHY_REG(776, 20), data
);
2054 ret_val
= e1e_wphy(hw
, PHY_REG(776, 23), 0x7E00);
2057 e1e_rphy(hw
, HV_PM_CTRL
, &data
);
2058 ret_val
= e1e_wphy(hw
, HV_PM_CTRL
, data
& ~(1 << 10));
2063 /* re-enable Rx path after enabling/disabling workaround */
2064 return e1e_wphy(hw
, PHY_REG(769, 20), phy_reg
& ~(1 << 14));
2068 * e1000_lv_phy_workarounds_ich8lan - A series of Phy workarounds to be
2069 * done after every PHY reset.
2071 static s32
e1000_lv_phy_workarounds_ich8lan(struct e1000_hw
*hw
)
2075 if (hw
->mac
.type
!= e1000_pch2lan
)
2078 /* Set MDIO slow mode before any other MDIO access */
2079 ret_val
= e1000_set_mdio_slow_mode_hv(hw
);
2081 ret_val
= hw
->phy
.ops
.acquire(hw
);
2084 /* set MSE higher to enable link to stay up when noise is high */
2085 ret_val
= e1000_write_emi_reg_locked(hw
, I82579_MSE_THRESHOLD
, 0x0034);
2088 /* drop link after 5 times MSE threshold was reached */
2089 ret_val
= e1000_write_emi_reg_locked(hw
, I82579_MSE_LINK_DOWN
, 0x0005);
2091 hw
->phy
.ops
.release(hw
);
2097 * e1000_k1_gig_workaround_lv - K1 Si workaround
2098 * @hw: pointer to the HW structure
2100 * Workaround to set the K1 beacon duration for 82579 parts
2102 static s32
e1000_k1_workaround_lv(struct e1000_hw
*hw
)
2109 if (hw
->mac
.type
!= e1000_pch2lan
)
2112 /* Set K1 beacon duration based on 1Gbps speed or otherwise */
2113 ret_val
= e1e_rphy(hw
, HV_M_STATUS
, &status_reg
);
2117 if ((status_reg
& (HV_M_STATUS_LINK_UP
| HV_M_STATUS_AUTONEG_COMPLETE
))
2118 == (HV_M_STATUS_LINK_UP
| HV_M_STATUS_AUTONEG_COMPLETE
)) {
2119 mac_reg
= er32(FEXTNVM4
);
2120 mac_reg
&= ~E1000_FEXTNVM4_BEACON_DURATION_MASK
;
2122 ret_val
= e1e_rphy(hw
, I82579_LPI_CTRL
, &phy_reg
);
2126 if (status_reg
& HV_M_STATUS_SPEED_1000
) {
2129 mac_reg
|= E1000_FEXTNVM4_BEACON_DURATION_8USEC
;
2130 phy_reg
&= ~I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT
;
2131 /* LV 1G Packet drop issue wa */
2132 ret_val
= e1e_rphy(hw
, HV_PM_CTRL
, &pm_phy_reg
);
2135 pm_phy_reg
&= ~HV_PM_CTRL_PLL_STOP_IN_K1_GIGA
;
2136 ret_val
= e1e_wphy(hw
, HV_PM_CTRL
, pm_phy_reg
);
2140 mac_reg
|= E1000_FEXTNVM4_BEACON_DURATION_16USEC
;
2141 phy_reg
|= I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT
;
2143 ew32(FEXTNVM4
, mac_reg
);
2144 ret_val
= e1e_wphy(hw
, I82579_LPI_CTRL
, phy_reg
);
2151 * e1000_gate_hw_phy_config_ich8lan - disable PHY config via hardware
2152 * @hw: pointer to the HW structure
2153 * @gate: boolean set to true to gate, false to ungate
2155 * Gate/ungate the automatic PHY configuration via hardware; perform
2156 * the configuration via software instead.
2158 static void e1000_gate_hw_phy_config_ich8lan(struct e1000_hw
*hw
, bool gate
)
2162 if (hw
->mac
.type
< e1000_pch2lan
)
2165 extcnf_ctrl
= er32(EXTCNF_CTRL
);
2168 extcnf_ctrl
|= E1000_EXTCNF_CTRL_GATE_PHY_CFG
;
2170 extcnf_ctrl
&= ~E1000_EXTCNF_CTRL_GATE_PHY_CFG
;
2172 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
2176 * e1000_lan_init_done_ich8lan - Check for PHY config completion
2177 * @hw: pointer to the HW structure
2179 * Check the appropriate indication the MAC has finished configuring the
2180 * PHY after a software reset.
2182 static void e1000_lan_init_done_ich8lan(struct e1000_hw
*hw
)
2184 u32 data
, loop
= E1000_ICH8_LAN_INIT_TIMEOUT
;
2186 /* Wait for basic configuration completes before proceeding */
2188 data
= er32(STATUS
);
2189 data
&= E1000_STATUS_LAN_INIT_DONE
;
2191 } while ((!data
) && --loop
);
2193 /* If basic configuration is incomplete before the above loop
2194 * count reaches 0, loading the configuration from NVM will
2195 * leave the PHY in a bad state possibly resulting in no link.
2198 e_dbg("LAN_INIT_DONE not set, increase timeout\n");
2200 /* Clear the Init Done bit for the next init event */
2201 data
= er32(STATUS
);
2202 data
&= ~E1000_STATUS_LAN_INIT_DONE
;
2207 * e1000_post_phy_reset_ich8lan - Perform steps required after a PHY reset
2208 * @hw: pointer to the HW structure
2210 static s32
e1000_post_phy_reset_ich8lan(struct e1000_hw
*hw
)
2215 if (hw
->phy
.ops
.check_reset_block(hw
))
2218 /* Allow time for h/w to get to quiescent state after reset */
2219 usleep_range(10000, 20000);
2221 /* Perform any necessary post-reset workarounds */
2222 switch (hw
->mac
.type
) {
2224 ret_val
= e1000_hv_phy_workarounds_ich8lan(hw
);
2229 ret_val
= e1000_lv_phy_workarounds_ich8lan(hw
);
2237 /* Clear the host wakeup bit after lcd reset */
2238 if (hw
->mac
.type
>= e1000_pchlan
) {
2239 e1e_rphy(hw
, BM_PORT_GEN_CFG
, ®
);
2240 reg
&= ~BM_WUC_HOST_WU_BIT
;
2241 e1e_wphy(hw
, BM_PORT_GEN_CFG
, reg
);
2244 /* Configure the LCD with the extended configuration region in NVM */
2245 ret_val
= e1000_sw_lcd_config_ich8lan(hw
);
2249 /* Configure the LCD with the OEM bits in NVM */
2250 ret_val
= e1000_oem_bits_config_ich8lan(hw
, true);
2252 if (hw
->mac
.type
== e1000_pch2lan
) {
2253 /* Ungate automatic PHY configuration on non-managed 82579 */
2254 if (!(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
)) {
2255 usleep_range(10000, 20000);
2256 e1000_gate_hw_phy_config_ich8lan(hw
, false);
2259 /* Set EEE LPI Update Timer to 200usec */
2260 ret_val
= hw
->phy
.ops
.acquire(hw
);
2263 ret_val
= e1000_write_emi_reg_locked(hw
,
2264 I82579_LPI_UPDATE_TIMER
,
2266 hw
->phy
.ops
.release(hw
);
2273 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
2274 * @hw: pointer to the HW structure
2277 * This is a function pointer entry point called by drivers
2278 * or other shared routines.
2280 static s32
e1000_phy_hw_reset_ich8lan(struct e1000_hw
*hw
)
2284 /* Gate automatic PHY configuration by hardware on non-managed 82579 */
2285 if ((hw
->mac
.type
== e1000_pch2lan
) &&
2286 !(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
))
2287 e1000_gate_hw_phy_config_ich8lan(hw
, true);
2289 ret_val
= e1000e_phy_hw_reset_generic(hw
);
2293 return e1000_post_phy_reset_ich8lan(hw
);
2297 * e1000_set_lplu_state_pchlan - Set Low Power Link Up state
2298 * @hw: pointer to the HW structure
2299 * @active: true to enable LPLU, false to disable
2301 * Sets the LPLU state according to the active flag. For PCH, if OEM write
2302 * bit are disabled in the NVM, writing the LPLU bits in the MAC will not set
2303 * the phy speed. This function will manually set the LPLU bit and restart
2304 * auto-neg as hw would do. D3 and D0 LPLU will call the same function
2305 * since it configures the same bit.
2307 static s32
e1000_set_lplu_state_pchlan(struct e1000_hw
*hw
, bool active
)
2312 ret_val
= e1e_rphy(hw
, HV_OEM_BITS
, &oem_reg
);
2317 oem_reg
|= HV_OEM_BITS_LPLU
;
2319 oem_reg
&= ~HV_OEM_BITS_LPLU
;
2321 if (!hw
->phy
.ops
.check_reset_block(hw
))
2322 oem_reg
|= HV_OEM_BITS_RESTART_AN
;
2324 return e1e_wphy(hw
, HV_OEM_BITS
, oem_reg
);
2328 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
2329 * @hw: pointer to the HW structure
2330 * @active: true to enable LPLU, false to disable
2332 * Sets the LPLU D0 state according to the active flag. When
2333 * activating LPLU this function also disables smart speed
2334 * and vice versa. LPLU will not be activated unless the
2335 * device autonegotiation advertisement meets standards of
2336 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2337 * This is a function pointer entry point only called by
2338 * PHY setup routines.
2340 static s32
e1000_set_d0_lplu_state_ich8lan(struct e1000_hw
*hw
, bool active
)
2342 struct e1000_phy_info
*phy
= &hw
->phy
;
2347 if (phy
->type
== e1000_phy_ife
)
2350 phy_ctrl
= er32(PHY_CTRL
);
2353 phy_ctrl
|= E1000_PHY_CTRL_D0A_LPLU
;
2354 ew32(PHY_CTRL
, phy_ctrl
);
2356 if (phy
->type
!= e1000_phy_igp_3
)
2359 /* Call gig speed drop workaround on LPLU before accessing
2362 if (hw
->mac
.type
== e1000_ich8lan
)
2363 e1000e_gig_downshift_workaround_ich8lan(hw
);
2365 /* When LPLU is enabled, we should disable SmartSpeed */
2366 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, &data
);
2367 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
2368 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, data
);
2372 phy_ctrl
&= ~E1000_PHY_CTRL_D0A_LPLU
;
2373 ew32(PHY_CTRL
, phy_ctrl
);
2375 if (phy
->type
!= e1000_phy_igp_3
)
2378 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
2379 * during Dx states where the power conservation is most
2380 * important. During driver activity we should enable
2381 * SmartSpeed, so performance is maintained.
2383 if (phy
->smart_speed
== e1000_smart_speed_on
) {
2384 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2389 data
|= IGP01E1000_PSCFR_SMART_SPEED
;
2390 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2394 } else if (phy
->smart_speed
== e1000_smart_speed_off
) {
2395 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2400 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
2401 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2412 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
2413 * @hw: pointer to the HW structure
2414 * @active: true to enable LPLU, false to disable
2416 * Sets the LPLU D3 state according to the active flag. When
2417 * activating LPLU this function also disables smart speed
2418 * and vice versa. LPLU will not be activated unless the
2419 * device autonegotiation advertisement meets standards of
2420 * either 10 or 10/100 or 10/100/1000 at all duplexes.
2421 * This is a function pointer entry point only called by
2422 * PHY setup routines.
2424 static s32
e1000_set_d3_lplu_state_ich8lan(struct e1000_hw
*hw
, bool active
)
2426 struct e1000_phy_info
*phy
= &hw
->phy
;
2431 phy_ctrl
= er32(PHY_CTRL
);
2434 phy_ctrl
&= ~E1000_PHY_CTRL_NOND0A_LPLU
;
2435 ew32(PHY_CTRL
, phy_ctrl
);
2437 if (phy
->type
!= e1000_phy_igp_3
)
2440 /* LPLU and SmartSpeed are mutually exclusive. LPLU is used
2441 * during Dx states where the power conservation is most
2442 * important. During driver activity we should enable
2443 * SmartSpeed, so performance is maintained.
2445 if (phy
->smart_speed
== e1000_smart_speed_on
) {
2446 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2451 data
|= IGP01E1000_PSCFR_SMART_SPEED
;
2452 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2456 } else if (phy
->smart_speed
== e1000_smart_speed_off
) {
2457 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2462 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
2463 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
2468 } else if ((phy
->autoneg_advertised
== E1000_ALL_SPEED_DUPLEX
) ||
2469 (phy
->autoneg_advertised
== E1000_ALL_NOT_GIG
) ||
2470 (phy
->autoneg_advertised
== E1000_ALL_10_SPEED
)) {
2471 phy_ctrl
|= E1000_PHY_CTRL_NOND0A_LPLU
;
2472 ew32(PHY_CTRL
, phy_ctrl
);
2474 if (phy
->type
!= e1000_phy_igp_3
)
2477 /* Call gig speed drop workaround on LPLU before accessing
2480 if (hw
->mac
.type
== e1000_ich8lan
)
2481 e1000e_gig_downshift_workaround_ich8lan(hw
);
2483 /* When LPLU is enabled, we should disable SmartSpeed */
2484 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, &data
);
2488 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
2489 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, data
);
2496 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
2497 * @hw: pointer to the HW structure
2498 * @bank: pointer to the variable that returns the active bank
2500 * Reads signature byte from the NVM using the flash access registers.
2501 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
2503 static s32
e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw
*hw
, u32
*bank
)
2506 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2507 u32 bank1_offset
= nvm
->flash_bank_size
* sizeof(u16
);
2508 u32 act_offset
= E1000_ICH_NVM_SIG_WORD
* 2 + 1;
2512 switch (hw
->mac
.type
) {
2516 if ((eecd
& E1000_EECD_SEC1VAL_VALID_MASK
) ==
2517 E1000_EECD_SEC1VAL_VALID_MASK
) {
2518 if (eecd
& E1000_EECD_SEC1VAL
)
2525 e_dbg("Unable to determine valid NVM bank via EEC - reading flash signature\n");
2528 /* set bank to 0 in case flash read fails */
2532 ret_val
= e1000_read_flash_byte_ich8lan(hw
, act_offset
,
2536 if ((sig_byte
& E1000_ICH_NVM_VALID_SIG_MASK
) ==
2537 E1000_ICH_NVM_SIG_VALUE
) {
2543 ret_val
= e1000_read_flash_byte_ich8lan(hw
, act_offset
+
2548 if ((sig_byte
& E1000_ICH_NVM_VALID_SIG_MASK
) ==
2549 E1000_ICH_NVM_SIG_VALUE
) {
2554 e_dbg("ERROR: No valid NVM bank present\n");
2555 return -E1000_ERR_NVM
;
2560 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
2561 * @hw: pointer to the HW structure
2562 * @offset: The offset (in bytes) of the word(s) to read.
2563 * @words: Size of data to read in words
2564 * @data: Pointer to the word(s) to read at offset.
2566 * Reads a word(s) from the NVM using the flash access registers.
2568 static s32
e1000_read_nvm_ich8lan(struct e1000_hw
*hw
, u16 offset
, u16 words
,
2571 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2572 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
2578 if ((offset
>= nvm
->word_size
) || (words
> nvm
->word_size
- offset
) ||
2580 e_dbg("nvm parameter(s) out of bounds\n");
2581 ret_val
= -E1000_ERR_NVM
;
2585 nvm
->ops
.acquire(hw
);
2587 ret_val
= e1000_valid_nvm_bank_detect_ich8lan(hw
, &bank
);
2589 e_dbg("Could not detect valid bank, assuming bank 0\n");
2593 act_offset
= (bank
) ? nvm
->flash_bank_size
: 0;
2594 act_offset
+= offset
;
2597 for (i
= 0; i
< words
; i
++) {
2598 if (dev_spec
->shadow_ram
[offset
+i
].modified
) {
2599 data
[i
] = dev_spec
->shadow_ram
[offset
+i
].value
;
2601 ret_val
= e1000_read_flash_word_ich8lan(hw
,
2610 nvm
->ops
.release(hw
);
2614 e_dbg("NVM read error: %d\n", ret_val
);
2620 * e1000_flash_cycle_init_ich8lan - Initialize flash
2621 * @hw: pointer to the HW structure
2623 * This function does initial flash setup so that a new read/write/erase cycle
2626 static s32
e1000_flash_cycle_init_ich8lan(struct e1000_hw
*hw
)
2628 union ich8_hws_flash_status hsfsts
;
2629 s32 ret_val
= -E1000_ERR_NVM
;
2631 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2633 /* Check if the flash descriptor is valid */
2634 if (!hsfsts
.hsf_status
.fldesvalid
) {
2635 e_dbg("Flash descriptor invalid. SW Sequencing must be used.\n");
2636 return -E1000_ERR_NVM
;
2639 /* Clear FCERR and DAEL in hw status by writing 1 */
2640 hsfsts
.hsf_status
.flcerr
= 1;
2641 hsfsts
.hsf_status
.dael
= 1;
2643 ew16flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
2645 /* Either we should have a hardware SPI cycle in progress
2646 * bit to check against, in order to start a new cycle or
2647 * FDONE bit should be changed in the hardware so that it
2648 * is 1 after hardware reset, which can then be used as an
2649 * indication whether a cycle is in progress or has been
2653 if (!hsfsts
.hsf_status
.flcinprog
) {
2654 /* There is no cycle running at present,
2655 * so we can start a cycle.
2656 * Begin by setting Flash Cycle Done.
2658 hsfsts
.hsf_status
.flcdone
= 1;
2659 ew16flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
2664 /* Otherwise poll for sometime so the current
2665 * cycle has a chance to end before giving up.
2667 for (i
= 0; i
< ICH_FLASH_READ_COMMAND_TIMEOUT
; i
++) {
2668 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2669 if (!hsfsts
.hsf_status
.flcinprog
) {
2676 /* Successful in waiting for previous cycle to timeout,
2677 * now set the Flash Cycle Done.
2679 hsfsts
.hsf_status
.flcdone
= 1;
2680 ew16flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
2682 e_dbg("Flash controller busy, cannot get access\n");
2690 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
2691 * @hw: pointer to the HW structure
2692 * @timeout: maximum time to wait for completion
2694 * This function starts a flash cycle and waits for its completion.
2696 static s32
e1000_flash_cycle_ich8lan(struct e1000_hw
*hw
, u32 timeout
)
2698 union ich8_hws_flash_ctrl hsflctl
;
2699 union ich8_hws_flash_status hsfsts
;
2702 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
2703 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
2704 hsflctl
.hsf_ctrl
.flcgo
= 1;
2705 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
2707 /* wait till FDONE bit is set to 1 */
2709 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2710 if (hsfsts
.hsf_status
.flcdone
)
2713 } while (i
++ < timeout
);
2715 if (hsfsts
.hsf_status
.flcdone
&& !hsfsts
.hsf_status
.flcerr
)
2718 return -E1000_ERR_NVM
;
2722 * e1000_read_flash_word_ich8lan - Read word from flash
2723 * @hw: pointer to the HW structure
2724 * @offset: offset to data location
2725 * @data: pointer to the location for storing the data
2727 * Reads the flash word at offset into data. Offset is converted
2728 * to bytes before read.
2730 static s32
e1000_read_flash_word_ich8lan(struct e1000_hw
*hw
, u32 offset
,
2733 /* Must convert offset into bytes. */
2736 return e1000_read_flash_data_ich8lan(hw
, offset
, 2, data
);
2740 * e1000_read_flash_byte_ich8lan - Read byte from flash
2741 * @hw: pointer to the HW structure
2742 * @offset: The offset of the byte to read.
2743 * @data: Pointer to a byte to store the value read.
2745 * Reads a single byte from the NVM using the flash access registers.
2747 static s32
e1000_read_flash_byte_ich8lan(struct e1000_hw
*hw
, u32 offset
,
2753 ret_val
= e1000_read_flash_data_ich8lan(hw
, offset
, 1, &word
);
2763 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
2764 * @hw: pointer to the HW structure
2765 * @offset: The offset (in bytes) of the byte or word to read.
2766 * @size: Size of data to read, 1=byte 2=word
2767 * @data: Pointer to the word to store the value read.
2769 * Reads a byte or word from the NVM using the flash access registers.
2771 static s32
e1000_read_flash_data_ich8lan(struct e1000_hw
*hw
, u32 offset
,
2774 union ich8_hws_flash_status hsfsts
;
2775 union ich8_hws_flash_ctrl hsflctl
;
2776 u32 flash_linear_addr
;
2778 s32 ret_val
= -E1000_ERR_NVM
;
2781 if (size
< 1 || size
> 2 || offset
> ICH_FLASH_LINEAR_ADDR_MASK
)
2782 return -E1000_ERR_NVM
;
2784 flash_linear_addr
= (ICH_FLASH_LINEAR_ADDR_MASK
& offset
) +
2785 hw
->nvm
.flash_base_addr
;
2790 ret_val
= e1000_flash_cycle_init_ich8lan(hw
);
2794 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
2795 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
2796 hsflctl
.hsf_ctrl
.fldbcount
= size
- 1;
2797 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_READ
;
2798 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
2800 ew32flash(ICH_FLASH_FADDR
, flash_linear_addr
);
2802 ret_val
= e1000_flash_cycle_ich8lan(hw
,
2803 ICH_FLASH_READ_COMMAND_TIMEOUT
);
2805 /* Check if FCERR is set to 1, if set to 1, clear it
2806 * and try the whole sequence a few more times, else
2807 * read in (shift in) the Flash Data0, the order is
2808 * least significant byte first msb to lsb
2811 flash_data
= er32flash(ICH_FLASH_FDATA0
);
2813 *data
= (u8
)(flash_data
& 0x000000FF);
2815 *data
= (u16
)(flash_data
& 0x0000FFFF);
2818 /* If we've gotten here, then things are probably
2819 * completely hosed, but if the error condition is
2820 * detected, it won't hurt to give it another try...
2821 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
2823 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2824 if (hsfsts
.hsf_status
.flcerr
) {
2825 /* Repeat for some time before giving up. */
2827 } else if (!hsfsts
.hsf_status
.flcdone
) {
2828 e_dbg("Timeout error - flash cycle did not complete.\n");
2832 } while (count
++ < ICH_FLASH_CYCLE_REPEAT_COUNT
);
2838 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
2839 * @hw: pointer to the HW structure
2840 * @offset: The offset (in bytes) of the word(s) to write.
2841 * @words: Size of data to write in words
2842 * @data: Pointer to the word(s) to write at offset.
2844 * Writes a byte or word to the NVM using the flash access registers.
2846 static s32
e1000_write_nvm_ich8lan(struct e1000_hw
*hw
, u16 offset
, u16 words
,
2849 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2850 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
2853 if ((offset
>= nvm
->word_size
) || (words
> nvm
->word_size
- offset
) ||
2855 e_dbg("nvm parameter(s) out of bounds\n");
2856 return -E1000_ERR_NVM
;
2859 nvm
->ops
.acquire(hw
);
2861 for (i
= 0; i
< words
; i
++) {
2862 dev_spec
->shadow_ram
[offset
+i
].modified
= true;
2863 dev_spec
->shadow_ram
[offset
+i
].value
= data
[i
];
2866 nvm
->ops
.release(hw
);
2872 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
2873 * @hw: pointer to the HW structure
2875 * The NVM checksum is updated by calling the generic update_nvm_checksum,
2876 * which writes the checksum to the shadow ram. The changes in the shadow
2877 * ram are then committed to the EEPROM by processing each bank at a time
2878 * checking for the modified bit and writing only the pending changes.
2879 * After a successful commit, the shadow ram is cleared and is ready for
2882 static s32
e1000_update_nvm_checksum_ich8lan(struct e1000_hw
*hw
)
2884 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2885 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
2886 u32 i
, act_offset
, new_bank_offset
, old_bank_offset
, bank
;
2890 ret_val
= e1000e_update_nvm_checksum_generic(hw
);
2894 if (nvm
->type
!= e1000_nvm_flash_sw
)
2897 nvm
->ops
.acquire(hw
);
2899 /* We're writing to the opposite bank so if we're on bank 1,
2900 * write to bank 0 etc. We also need to erase the segment that
2901 * is going to be written
2903 ret_val
= e1000_valid_nvm_bank_detect_ich8lan(hw
, &bank
);
2905 e_dbg("Could not detect valid bank, assuming bank 0\n");
2910 new_bank_offset
= nvm
->flash_bank_size
;
2911 old_bank_offset
= 0;
2912 ret_val
= e1000_erase_flash_bank_ich8lan(hw
, 1);
2916 old_bank_offset
= nvm
->flash_bank_size
;
2917 new_bank_offset
= 0;
2918 ret_val
= e1000_erase_flash_bank_ich8lan(hw
, 0);
2923 for (i
= 0; i
< E1000_ICH8_SHADOW_RAM_WORDS
; i
++) {
2924 /* Determine whether to write the value stored
2925 * in the other NVM bank or a modified value stored
2928 if (dev_spec
->shadow_ram
[i
].modified
) {
2929 data
= dev_spec
->shadow_ram
[i
].value
;
2931 ret_val
= e1000_read_flash_word_ich8lan(hw
, i
+
2938 /* If the word is 0x13, then make sure the signature bits
2939 * (15:14) are 11b until the commit has completed.
2940 * This will allow us to write 10b which indicates the
2941 * signature is valid. We want to do this after the write
2942 * has completed so that we don't mark the segment valid
2943 * while the write is still in progress
2945 if (i
== E1000_ICH_NVM_SIG_WORD
)
2946 data
|= E1000_ICH_NVM_SIG_MASK
;
2948 /* Convert offset to bytes. */
2949 act_offset
= (i
+ new_bank_offset
) << 1;
2952 /* Write the bytes to the new bank. */
2953 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
,
2960 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
,
2967 /* Don't bother writing the segment valid bits if sector
2968 * programming failed.
2971 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
2972 e_dbg("Flash commit failed.\n");
2976 /* Finally validate the new segment by setting bit 15:14
2977 * to 10b in word 0x13 , this can be done without an
2978 * erase as well since these bits are 11 to start with
2979 * and we need to change bit 14 to 0b
2981 act_offset
= new_bank_offset
+ E1000_ICH_NVM_SIG_WORD
;
2982 ret_val
= e1000_read_flash_word_ich8lan(hw
, act_offset
, &data
);
2987 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
,
2993 /* And invalidate the previously valid segment by setting
2994 * its signature word (0x13) high_byte to 0b. This can be
2995 * done without an erase because flash erase sets all bits
2996 * to 1's. We can write 1's to 0's without an erase
2998 act_offset
= (old_bank_offset
+ E1000_ICH_NVM_SIG_WORD
) * 2 + 1;
2999 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
, act_offset
, 0);
3003 /* Great! Everything worked, we can now clear the cached entries. */
3004 for (i
= 0; i
< E1000_ICH8_SHADOW_RAM_WORDS
; i
++) {
3005 dev_spec
->shadow_ram
[i
].modified
= false;
3006 dev_spec
->shadow_ram
[i
].value
= 0xFFFF;
3010 nvm
->ops
.release(hw
);
3012 /* Reload the EEPROM, or else modifications will not appear
3013 * until after the next adapter reset.
3016 nvm
->ops
.reload(hw
);
3017 usleep_range(10000, 20000);
3022 e_dbg("NVM update error: %d\n", ret_val
);
3028 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
3029 * @hw: pointer to the HW structure
3031 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
3032 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
3033 * calculated, in which case we need to calculate the checksum and set bit 6.
3035 static s32
e1000_validate_nvm_checksum_ich8lan(struct e1000_hw
*hw
)
3040 u16 valid_csum_mask
;
3042 /* Read NVM and check Invalid Image CSUM bit. If this bit is 0,
3043 * the checksum needs to be fixed. This bit is an indication that
3044 * the NVM was prepared by OEM software and did not calculate
3045 * the checksum...a likely scenario.
3047 switch (hw
->mac
.type
) {
3050 valid_csum_mask
= NVM_COMPAT_VALID_CSUM
;
3053 word
= NVM_FUTURE_INIT_WORD1
;
3054 valid_csum_mask
= NVM_FUTURE_INIT_WORD1_VALID_CSUM
;
3058 ret_val
= e1000_read_nvm(hw
, word
, 1, &data
);
3062 if (!(data
& valid_csum_mask
)) {
3063 data
|= valid_csum_mask
;
3064 ret_val
= e1000_write_nvm(hw
, word
, 1, &data
);
3067 ret_val
= e1000e_update_nvm_checksum(hw
);
3072 return e1000e_validate_nvm_checksum_generic(hw
);
3076 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
3077 * @hw: pointer to the HW structure
3079 * To prevent malicious write/erase of the NVM, set it to be read-only
3080 * so that the hardware ignores all write/erase cycles of the NVM via
3081 * the flash control registers. The shadow-ram copy of the NVM will
3082 * still be updated, however any updates to this copy will not stick
3083 * across driver reloads.
3085 void e1000e_write_protect_nvm_ich8lan(struct e1000_hw
*hw
)
3087 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
3088 union ich8_flash_protected_range pr0
;
3089 union ich8_hws_flash_status hsfsts
;
3092 nvm
->ops
.acquire(hw
);
3094 gfpreg
= er32flash(ICH_FLASH_GFPREG
);
3096 /* Write-protect GbE Sector of NVM */
3097 pr0
.regval
= er32flash(ICH_FLASH_PR0
);
3098 pr0
.range
.base
= gfpreg
& FLASH_GFPREG_BASE_MASK
;
3099 pr0
.range
.limit
= ((gfpreg
>> 16) & FLASH_GFPREG_BASE_MASK
);
3100 pr0
.range
.wpe
= true;
3101 ew32flash(ICH_FLASH_PR0
, pr0
.regval
);
3103 /* Lock down a subset of GbE Flash Control Registers, e.g.
3104 * PR0 to prevent the write-protection from being lifted.
3105 * Once FLOCKDN is set, the registers protected by it cannot
3106 * be written until FLOCKDN is cleared by a hardware reset.
3108 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
3109 hsfsts
.hsf_status
.flockdn
= true;
3110 ew32flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
3112 nvm
->ops
.release(hw
);
3116 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
3117 * @hw: pointer to the HW structure
3118 * @offset: The offset (in bytes) of the byte/word to read.
3119 * @size: Size of data to read, 1=byte 2=word
3120 * @data: The byte(s) to write to the NVM.
3122 * Writes one/two bytes to the NVM using the flash access registers.
3124 static s32
e1000_write_flash_data_ich8lan(struct e1000_hw
*hw
, u32 offset
,
3127 union ich8_hws_flash_status hsfsts
;
3128 union ich8_hws_flash_ctrl hsflctl
;
3129 u32 flash_linear_addr
;
3134 if (size
< 1 || size
> 2 || data
> size
* 0xff ||
3135 offset
> ICH_FLASH_LINEAR_ADDR_MASK
)
3136 return -E1000_ERR_NVM
;
3138 flash_linear_addr
= (ICH_FLASH_LINEAR_ADDR_MASK
& offset
) +
3139 hw
->nvm
.flash_base_addr
;
3144 ret_val
= e1000_flash_cycle_init_ich8lan(hw
);
3148 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
3149 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
3150 hsflctl
.hsf_ctrl
.fldbcount
= size
-1;
3151 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_WRITE
;
3152 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
3154 ew32flash(ICH_FLASH_FADDR
, flash_linear_addr
);
3157 flash_data
= (u32
)data
& 0x00FF;
3159 flash_data
= (u32
)data
;
3161 ew32flash(ICH_FLASH_FDATA0
, flash_data
);
3163 /* check if FCERR is set to 1 , if set to 1, clear it
3164 * and try the whole sequence a few more times else done
3166 ret_val
= e1000_flash_cycle_ich8lan(hw
,
3167 ICH_FLASH_WRITE_COMMAND_TIMEOUT
);
3171 /* If we're here, then things are most likely
3172 * completely hosed, but if the error condition
3173 * is detected, it won't hurt to give it another
3174 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
3176 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
3177 if (hsfsts
.hsf_status
.flcerr
)
3178 /* Repeat for some time before giving up. */
3180 if (!hsfsts
.hsf_status
.flcdone
) {
3181 e_dbg("Timeout error - flash cycle did not complete.\n");
3184 } while (count
++ < ICH_FLASH_CYCLE_REPEAT_COUNT
);
3190 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
3191 * @hw: pointer to the HW structure
3192 * @offset: The index of the byte to read.
3193 * @data: The byte to write to the NVM.
3195 * Writes a single byte to the NVM using the flash access registers.
3197 static s32
e1000_write_flash_byte_ich8lan(struct e1000_hw
*hw
, u32 offset
,
3200 u16 word
= (u16
)data
;
3202 return e1000_write_flash_data_ich8lan(hw
, offset
, 1, word
);
3206 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
3207 * @hw: pointer to the HW structure
3208 * @offset: The offset of the byte to write.
3209 * @byte: The byte to write to the NVM.
3211 * Writes a single byte to the NVM using the flash access registers.
3212 * Goes through a retry algorithm before giving up.
3214 static s32
e1000_retry_write_flash_byte_ich8lan(struct e1000_hw
*hw
,
3215 u32 offset
, u8 byte
)
3218 u16 program_retries
;
3220 ret_val
= e1000_write_flash_byte_ich8lan(hw
, offset
, byte
);
3224 for (program_retries
= 0; program_retries
< 100; program_retries
++) {
3225 e_dbg("Retrying Byte %2.2X at offset %u\n", byte
, offset
);
3227 ret_val
= e1000_write_flash_byte_ich8lan(hw
, offset
, byte
);
3231 if (program_retries
== 100)
3232 return -E1000_ERR_NVM
;
3238 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
3239 * @hw: pointer to the HW structure
3240 * @bank: 0 for first bank, 1 for second bank, etc.
3242 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
3243 * bank N is 4096 * N + flash_reg_addr.
3245 static s32
e1000_erase_flash_bank_ich8lan(struct e1000_hw
*hw
, u32 bank
)
3247 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
3248 union ich8_hws_flash_status hsfsts
;
3249 union ich8_hws_flash_ctrl hsflctl
;
3250 u32 flash_linear_addr
;
3251 /* bank size is in 16bit words - adjust to bytes */
3252 u32 flash_bank_size
= nvm
->flash_bank_size
* 2;
3255 s32 j
, iteration
, sector_size
;
3257 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
3259 /* Determine HW Sector size: Read BERASE bits of hw flash status
3261 * 00: The Hw sector is 256 bytes, hence we need to erase 16
3262 * consecutive sectors. The start index for the nth Hw sector
3263 * can be calculated as = bank * 4096 + n * 256
3264 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
3265 * The start index for the nth Hw sector can be calculated
3267 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
3268 * (ich9 only, otherwise error condition)
3269 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
3271 switch (hsfsts
.hsf_status
.berasesz
) {
3273 /* Hw sector size 256 */
3274 sector_size
= ICH_FLASH_SEG_SIZE_256
;
3275 iteration
= flash_bank_size
/ ICH_FLASH_SEG_SIZE_256
;
3278 sector_size
= ICH_FLASH_SEG_SIZE_4K
;
3282 sector_size
= ICH_FLASH_SEG_SIZE_8K
;
3286 sector_size
= ICH_FLASH_SEG_SIZE_64K
;
3290 return -E1000_ERR_NVM
;
3293 /* Start with the base address, then add the sector offset. */
3294 flash_linear_addr
= hw
->nvm
.flash_base_addr
;
3295 flash_linear_addr
+= (bank
) ? flash_bank_size
: 0;
3297 for (j
= 0; j
< iteration
; j
++) {
3300 ret_val
= e1000_flash_cycle_init_ich8lan(hw
);
3304 /* Write a value 11 (block Erase) in Flash
3305 * Cycle field in hw flash control
3307 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
3308 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_ERASE
;
3309 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
3311 /* Write the last 24 bits of an index within the
3312 * block into Flash Linear address field in Flash
3315 flash_linear_addr
+= (j
* sector_size
);
3316 ew32flash(ICH_FLASH_FADDR
, flash_linear_addr
);
3318 ret_val
= e1000_flash_cycle_ich8lan(hw
,
3319 ICH_FLASH_ERASE_COMMAND_TIMEOUT
);
3323 /* Check if FCERR is set to 1. If 1,
3324 * clear it and try the whole sequence
3325 * a few more times else Done
3327 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
3328 if (hsfsts
.hsf_status
.flcerr
)
3329 /* repeat for some time before giving up */
3331 else if (!hsfsts
.hsf_status
.flcdone
)
3333 } while (++count
< ICH_FLASH_CYCLE_REPEAT_COUNT
);
3340 * e1000_valid_led_default_ich8lan - Set the default LED settings
3341 * @hw: pointer to the HW structure
3342 * @data: Pointer to the LED settings
3344 * Reads the LED default settings from the NVM to data. If the NVM LED
3345 * settings is all 0's or F's, set the LED default to a valid LED default
3348 static s32
e1000_valid_led_default_ich8lan(struct e1000_hw
*hw
, u16
*data
)
3352 ret_val
= e1000_read_nvm(hw
, NVM_ID_LED_SETTINGS
, 1, data
);
3354 e_dbg("NVM Read Error\n");
3358 if (*data
== ID_LED_RESERVED_0000
||
3359 *data
== ID_LED_RESERVED_FFFF
)
3360 *data
= ID_LED_DEFAULT_ICH8LAN
;
3366 * e1000_id_led_init_pchlan - store LED configurations
3367 * @hw: pointer to the HW structure
3369 * PCH does not control LEDs via the LEDCTL register, rather it uses
3370 * the PHY LED configuration register.
3372 * PCH also does not have an "always on" or "always off" mode which
3373 * complicates the ID feature. Instead of using the "on" mode to indicate
3374 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init_generic()),
3375 * use "link_up" mode. The LEDs will still ID on request if there is no
3376 * link based on logic in e1000_led_[on|off]_pchlan().
3378 static s32
e1000_id_led_init_pchlan(struct e1000_hw
*hw
)
3380 struct e1000_mac_info
*mac
= &hw
->mac
;
3382 const u32 ledctl_on
= E1000_LEDCTL_MODE_LINK_UP
;
3383 const u32 ledctl_off
= E1000_LEDCTL_MODE_LINK_UP
| E1000_PHY_LED0_IVRT
;
3384 u16 data
, i
, temp
, shift
;
3386 /* Get default ID LED modes */
3387 ret_val
= hw
->nvm
.ops
.valid_led_default(hw
, &data
);
3391 mac
->ledctl_default
= er32(LEDCTL
);
3392 mac
->ledctl_mode1
= mac
->ledctl_default
;
3393 mac
->ledctl_mode2
= mac
->ledctl_default
;
3395 for (i
= 0; i
< 4; i
++) {
3396 temp
= (data
>> (i
<< 2)) & E1000_LEDCTL_LED0_MODE_MASK
;
3399 case ID_LED_ON1_DEF2
:
3400 case ID_LED_ON1_ON2
:
3401 case ID_LED_ON1_OFF2
:
3402 mac
->ledctl_mode1
&= ~(E1000_PHY_LED0_MASK
<< shift
);
3403 mac
->ledctl_mode1
|= (ledctl_on
<< shift
);
3405 case ID_LED_OFF1_DEF2
:
3406 case ID_LED_OFF1_ON2
:
3407 case ID_LED_OFF1_OFF2
:
3408 mac
->ledctl_mode1
&= ~(E1000_PHY_LED0_MASK
<< shift
);
3409 mac
->ledctl_mode1
|= (ledctl_off
<< shift
);
3416 case ID_LED_DEF1_ON2
:
3417 case ID_LED_ON1_ON2
:
3418 case ID_LED_OFF1_ON2
:
3419 mac
->ledctl_mode2
&= ~(E1000_PHY_LED0_MASK
<< shift
);
3420 mac
->ledctl_mode2
|= (ledctl_on
<< shift
);
3422 case ID_LED_DEF1_OFF2
:
3423 case ID_LED_ON1_OFF2
:
3424 case ID_LED_OFF1_OFF2
:
3425 mac
->ledctl_mode2
&= ~(E1000_PHY_LED0_MASK
<< shift
);
3426 mac
->ledctl_mode2
|= (ledctl_off
<< shift
);
3438 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
3439 * @hw: pointer to the HW structure
3441 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
3442 * register, so the the bus width is hard coded.
3444 static s32
e1000_get_bus_info_ich8lan(struct e1000_hw
*hw
)
3446 struct e1000_bus_info
*bus
= &hw
->bus
;
3449 ret_val
= e1000e_get_bus_info_pcie(hw
);
3451 /* ICH devices are "PCI Express"-ish. They have
3452 * a configuration space, but do not contain
3453 * PCI Express Capability registers, so bus width
3454 * must be hardcoded.
3456 if (bus
->width
== e1000_bus_width_unknown
)
3457 bus
->width
= e1000_bus_width_pcie_x1
;
3463 * e1000_reset_hw_ich8lan - Reset the hardware
3464 * @hw: pointer to the HW structure
3466 * Does a full reset of the hardware which includes a reset of the PHY and
3469 static s32
e1000_reset_hw_ich8lan(struct e1000_hw
*hw
)
3471 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
3476 /* Prevent the PCI-E bus from sticking if there is no TLP connection
3477 * on the last TLP read/write transaction when MAC is reset.
3479 ret_val
= e1000e_disable_pcie_master(hw
);
3481 e_dbg("PCI-E Master disable polling has failed.\n");
3483 e_dbg("Masking off all interrupts\n");
3484 ew32(IMC
, 0xffffffff);
3486 /* Disable the Transmit and Receive units. Then delay to allow
3487 * any pending transactions to complete before we hit the MAC
3488 * with the global reset.
3491 ew32(TCTL
, E1000_TCTL_PSP
);
3494 usleep_range(10000, 20000);
3496 /* Workaround for ICH8 bit corruption issue in FIFO memory */
3497 if (hw
->mac
.type
== e1000_ich8lan
) {
3498 /* Set Tx and Rx buffer allocation to 8k apiece. */
3499 ew32(PBA
, E1000_PBA_8K
);
3500 /* Set Packet Buffer Size to 16k. */
3501 ew32(PBS
, E1000_PBS_16K
);
3504 if (hw
->mac
.type
== e1000_pchlan
) {
3505 /* Save the NVM K1 bit setting */
3506 ret_val
= e1000_read_nvm(hw
, E1000_NVM_K1_CONFIG
, 1, &kum_cfg
);
3510 if (kum_cfg
& E1000_NVM_K1_ENABLE
)
3511 dev_spec
->nvm_k1_enabled
= true;
3513 dev_spec
->nvm_k1_enabled
= false;
3518 if (!hw
->phy
.ops
.check_reset_block(hw
)) {
3519 /* Full-chip reset requires MAC and PHY reset at the same
3520 * time to make sure the interface between MAC and the
3521 * external PHY is reset.
3523 ctrl
|= E1000_CTRL_PHY_RST
;
3525 /* Gate automatic PHY configuration by hardware on
3528 if ((hw
->mac
.type
== e1000_pch2lan
) &&
3529 !(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
))
3530 e1000_gate_hw_phy_config_ich8lan(hw
, true);
3532 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
3533 e_dbg("Issuing a global reset to ich8lan\n");
3534 ew32(CTRL
, (ctrl
| E1000_CTRL_RST
));
3535 /* cannot issue a flush here because it hangs the hardware */
3538 /* Set Phy Config Counter to 50msec */
3539 if (hw
->mac
.type
== e1000_pch2lan
) {
3540 reg
= er32(FEXTNVM3
);
3541 reg
&= ~E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK
;
3542 reg
|= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC
;
3543 ew32(FEXTNVM3
, reg
);
3547 clear_bit(__E1000_ACCESS_SHARED_RESOURCE
, &hw
->adapter
->state
);
3549 if (ctrl
& E1000_CTRL_PHY_RST
) {
3550 ret_val
= hw
->phy
.ops
.get_cfg_done(hw
);
3554 ret_val
= e1000_post_phy_reset_ich8lan(hw
);
3559 /* For PCH, this write will make sure that any noise
3560 * will be detected as a CRC error and be dropped rather than show up
3561 * as a bad packet to the DMA engine.
3563 if (hw
->mac
.type
== e1000_pchlan
)
3564 ew32(CRC_OFFSET
, 0x65656565);
3566 ew32(IMC
, 0xffffffff);
3569 reg
= er32(KABGTXD
);
3570 reg
|= E1000_KABGTXD_BGSQLBIAS
;
3577 * e1000_init_hw_ich8lan - Initialize the hardware
3578 * @hw: pointer to the HW structure
3580 * Prepares the hardware for transmit and receive by doing the following:
3581 * - initialize hardware bits
3582 * - initialize LED identification
3583 * - setup receive address registers
3584 * - setup flow control
3585 * - setup transmit descriptors
3586 * - clear statistics
3588 static s32
e1000_init_hw_ich8lan(struct e1000_hw
*hw
)
3590 struct e1000_mac_info
*mac
= &hw
->mac
;
3591 u32 ctrl_ext
, txdctl
, snoop
;
3595 e1000_initialize_hw_bits_ich8lan(hw
);
3597 /* Initialize identification LED */
3598 ret_val
= mac
->ops
.id_led_init(hw
);
3600 e_dbg("Error initializing identification LED\n");
3601 /* This is not fatal and we should not stop init due to this */
3603 /* Setup the receive address. */
3604 e1000e_init_rx_addrs(hw
, mac
->rar_entry_count
);
3606 /* Zero out the Multicast HASH table */
3607 e_dbg("Zeroing the MTA\n");
3608 for (i
= 0; i
< mac
->mta_reg_count
; i
++)
3609 E1000_WRITE_REG_ARRAY(hw
, E1000_MTA
, i
, 0);
3611 /* The 82578 Rx buffer will stall if wakeup is enabled in host and
3612 * the ME. Disable wakeup by clearing the host wakeup bit.
3613 * Reset the phy after disabling host wakeup to reset the Rx buffer.
3615 if (hw
->phy
.type
== e1000_phy_82578
) {
3616 e1e_rphy(hw
, BM_PORT_GEN_CFG
, &i
);
3617 i
&= ~BM_WUC_HOST_WU_BIT
;
3618 e1e_wphy(hw
, BM_PORT_GEN_CFG
, i
);
3619 ret_val
= e1000_phy_hw_reset_ich8lan(hw
);
3624 /* Setup link and flow control */
3625 ret_val
= mac
->ops
.setup_link(hw
);
3627 /* Set the transmit descriptor write-back policy for both queues */
3628 txdctl
= er32(TXDCTL(0));
3629 txdctl
= (txdctl
& ~E1000_TXDCTL_WTHRESH
) |
3630 E1000_TXDCTL_FULL_TX_DESC_WB
;
3631 txdctl
= (txdctl
& ~E1000_TXDCTL_PTHRESH
) |
3632 E1000_TXDCTL_MAX_TX_DESC_PREFETCH
;
3633 ew32(TXDCTL(0), txdctl
);
3634 txdctl
= er32(TXDCTL(1));
3635 txdctl
= (txdctl
& ~E1000_TXDCTL_WTHRESH
) |
3636 E1000_TXDCTL_FULL_TX_DESC_WB
;
3637 txdctl
= (txdctl
& ~E1000_TXDCTL_PTHRESH
) |
3638 E1000_TXDCTL_MAX_TX_DESC_PREFETCH
;
3639 ew32(TXDCTL(1), txdctl
);
3641 /* ICH8 has opposite polarity of no_snoop bits.
3642 * By default, we should use snoop behavior.
3644 if (mac
->type
== e1000_ich8lan
)
3645 snoop
= PCIE_ICH8_SNOOP_ALL
;
3647 snoop
= (u32
) ~(PCIE_NO_SNOOP_ALL
);
3648 e1000e_set_pcie_no_snoop(hw
, snoop
);
3650 ctrl_ext
= er32(CTRL_EXT
);
3651 ctrl_ext
|= E1000_CTRL_EXT_RO_DIS
;
3652 ew32(CTRL_EXT
, ctrl_ext
);
3654 /* Clear all of the statistics registers (clear on read). It is
3655 * important that we do this after we have tried to establish link
3656 * because the symbol error count will increment wildly if there
3659 e1000_clear_hw_cntrs_ich8lan(hw
);
3664 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
3665 * @hw: pointer to the HW structure
3667 * Sets/Clears required hardware bits necessary for correctly setting up the
3668 * hardware for transmit and receive.
3670 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw
*hw
)
3674 /* Extended Device Control */
3675 reg
= er32(CTRL_EXT
);
3677 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
3678 if (hw
->mac
.type
>= e1000_pchlan
)
3679 reg
|= E1000_CTRL_EXT_PHYPDEN
;
3680 ew32(CTRL_EXT
, reg
);
3682 /* Transmit Descriptor Control 0 */
3683 reg
= er32(TXDCTL(0));
3685 ew32(TXDCTL(0), reg
);
3687 /* Transmit Descriptor Control 1 */
3688 reg
= er32(TXDCTL(1));
3690 ew32(TXDCTL(1), reg
);
3692 /* Transmit Arbitration Control 0 */
3693 reg
= er32(TARC(0));
3694 if (hw
->mac
.type
== e1000_ich8lan
)
3695 reg
|= (1 << 28) | (1 << 29);
3696 reg
|= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
3699 /* Transmit Arbitration Control 1 */
3700 reg
= er32(TARC(1));
3701 if (er32(TCTL
) & E1000_TCTL_MULR
)
3705 reg
|= (1 << 24) | (1 << 26) | (1 << 30);
3709 if (hw
->mac
.type
== e1000_ich8lan
) {
3715 /* work-around descriptor data corruption issue during nfs v2 udp
3716 * traffic, just disable the nfs filtering capability
3719 reg
|= (E1000_RFCTL_NFSW_DIS
| E1000_RFCTL_NFSR_DIS
);
3721 /* Disable IPv6 extension header parsing because some malformed
3722 * IPv6 headers can hang the Rx.
3724 if (hw
->mac
.type
== e1000_ich8lan
)
3725 reg
|= (E1000_RFCTL_IPV6_EX_DIS
| E1000_RFCTL_NEW_IPV6_EXT_DIS
);
3730 * e1000_setup_link_ich8lan - Setup flow control and link settings
3731 * @hw: pointer to the HW structure
3733 * Determines which flow control settings to use, then configures flow
3734 * control. Calls the appropriate media-specific link configuration
3735 * function. Assuming the adapter has a valid link partner, a valid link
3736 * should be established. Assumes the hardware has previously been reset
3737 * and the transmitter and receiver are not enabled.
3739 static s32
e1000_setup_link_ich8lan(struct e1000_hw
*hw
)
3743 if (hw
->phy
.ops
.check_reset_block(hw
))
3746 /* ICH parts do not have a word in the NVM to determine
3747 * the default flow control setting, so we explicitly
3750 if (hw
->fc
.requested_mode
== e1000_fc_default
) {
3751 /* Workaround h/w hang when Tx flow control enabled */
3752 if (hw
->mac
.type
== e1000_pchlan
)
3753 hw
->fc
.requested_mode
= e1000_fc_rx_pause
;
3755 hw
->fc
.requested_mode
= e1000_fc_full
;
3758 /* Save off the requested flow control mode for use later. Depending
3759 * on the link partner's capabilities, we may or may not use this mode.
3761 hw
->fc
.current_mode
= hw
->fc
.requested_mode
;
3763 e_dbg("After fix-ups FlowControl is now = %x\n",
3764 hw
->fc
.current_mode
);
3766 /* Continue to configure the copper link. */
3767 ret_val
= hw
->mac
.ops
.setup_physical_interface(hw
);
3771 ew32(FCTTV
, hw
->fc
.pause_time
);
3772 if ((hw
->phy
.type
== e1000_phy_82578
) ||
3773 (hw
->phy
.type
== e1000_phy_82579
) ||
3774 (hw
->phy
.type
== e1000_phy_i217
) ||
3775 (hw
->phy
.type
== e1000_phy_82577
)) {
3776 ew32(FCRTV_PCH
, hw
->fc
.refresh_time
);
3778 ret_val
= e1e_wphy(hw
, PHY_REG(BM_PORT_CTRL_PAGE
, 27),
3784 return e1000e_set_fc_watermarks(hw
);
3788 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
3789 * @hw: pointer to the HW structure
3791 * Configures the kumeran interface to the PHY to wait the appropriate time
3792 * when polling the PHY, then call the generic setup_copper_link to finish
3793 * configuring the copper link.
3795 static s32
e1000_setup_copper_link_ich8lan(struct e1000_hw
*hw
)
3802 ctrl
|= E1000_CTRL_SLU
;
3803 ctrl
&= ~(E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
3806 /* Set the mac to wait the maximum time between each iteration
3807 * and increase the max iterations when polling the phy;
3808 * this fixes erroneous timeouts at 10Mbps.
3810 ret_val
= e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_TIMEOUTS
, 0xFFFF);
3813 ret_val
= e1000e_read_kmrn_reg(hw
, E1000_KMRNCTRLSTA_INBAND_PARAM
,
3818 ret_val
= e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_INBAND_PARAM
,
3823 switch (hw
->phy
.type
) {
3824 case e1000_phy_igp_3
:
3825 ret_val
= e1000e_copper_link_setup_igp(hw
);
3830 case e1000_phy_82578
:
3831 ret_val
= e1000e_copper_link_setup_m88(hw
);
3835 case e1000_phy_82577
:
3836 case e1000_phy_82579
:
3837 case e1000_phy_i217
:
3838 ret_val
= e1000_copper_link_setup_82577(hw
);
3843 ret_val
= e1e_rphy(hw
, IFE_PHY_MDIX_CONTROL
, ®_data
);
3847 reg_data
&= ~IFE_PMC_AUTO_MDIX
;
3849 switch (hw
->phy
.mdix
) {
3851 reg_data
&= ~IFE_PMC_FORCE_MDIX
;
3854 reg_data
|= IFE_PMC_FORCE_MDIX
;
3858 reg_data
|= IFE_PMC_AUTO_MDIX
;
3861 ret_val
= e1e_wphy(hw
, IFE_PHY_MDIX_CONTROL
, reg_data
);
3869 return e1000e_setup_copper_link(hw
);
3873 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
3874 * @hw: pointer to the HW structure
3875 * @speed: pointer to store current link speed
3876 * @duplex: pointer to store the current link duplex
3878 * Calls the generic get_speed_and_duplex to retrieve the current link
3879 * information and then calls the Kumeran lock loss workaround for links at
3882 static s32
e1000_get_link_up_info_ich8lan(struct e1000_hw
*hw
, u16
*speed
,
3887 ret_val
= e1000e_get_speed_and_duplex_copper(hw
, speed
, duplex
);
3891 if ((hw
->mac
.type
== e1000_ich8lan
) &&
3892 (hw
->phy
.type
== e1000_phy_igp_3
) &&
3893 (*speed
== SPEED_1000
)) {
3894 ret_val
= e1000_kmrn_lock_loss_workaround_ich8lan(hw
);
3901 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
3902 * @hw: pointer to the HW structure
3904 * Work-around for 82566 Kumeran PCS lock loss:
3905 * On link status change (i.e. PCI reset, speed change) and link is up and
3907 * 0) if workaround is optionally disabled do nothing
3908 * 1) wait 1ms for Kumeran link to come up
3909 * 2) check Kumeran Diagnostic register PCS lock loss bit
3910 * 3) if not set the link is locked (all is good), otherwise...
3912 * 5) repeat up to 10 times
3913 * Note: this is only called for IGP3 copper when speed is 1gb.
3915 static s32
e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw
*hw
)
3917 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
3923 if (!dev_spec
->kmrn_lock_loss_workaround_enabled
)
3926 /* Make sure link is up before proceeding. If not just return.
3927 * Attempting this while link is negotiating fouled up link
3930 ret_val
= e1000e_phy_has_link_generic(hw
, 1, 0, &link
);
3934 for (i
= 0; i
< 10; i
++) {
3935 /* read once to clear */
3936 ret_val
= e1e_rphy(hw
, IGP3_KMRN_DIAG
, &data
);
3939 /* and again to get new status */
3940 ret_val
= e1e_rphy(hw
, IGP3_KMRN_DIAG
, &data
);
3944 /* check for PCS lock */
3945 if (!(data
& IGP3_KMRN_DIAG_PCS_LOCK_LOSS
))
3948 /* Issue PHY reset */
3949 e1000_phy_hw_reset(hw
);
3952 /* Disable GigE link negotiation */
3953 phy_ctrl
= er32(PHY_CTRL
);
3954 phy_ctrl
|= (E1000_PHY_CTRL_GBE_DISABLE
|
3955 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
);
3956 ew32(PHY_CTRL
, phy_ctrl
);
3958 /* Call gig speed drop workaround on Gig disable before accessing
3961 e1000e_gig_downshift_workaround_ich8lan(hw
);
3963 /* unable to acquire PCS lock */
3964 return -E1000_ERR_PHY
;
3968 * e1000e_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
3969 * @hw: pointer to the HW structure
3970 * @state: boolean value used to set the current Kumeran workaround state
3972 * If ICH8, set the current Kumeran workaround state (enabled - true
3973 * /disabled - false).
3975 void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw
*hw
,
3978 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
3980 if (hw
->mac
.type
!= e1000_ich8lan
) {
3981 e_dbg("Workaround applies to ICH8 only.\n");
3985 dev_spec
->kmrn_lock_loss_workaround_enabled
= state
;
3989 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
3990 * @hw: pointer to the HW structure
3992 * Workaround for 82566 power-down on D3 entry:
3993 * 1) disable gigabit link
3994 * 2) write VR power-down enable
3996 * Continue if successful, else issue LCD reset and repeat
3998 void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw
*hw
)
4004 if (hw
->phy
.type
!= e1000_phy_igp_3
)
4007 /* Try the workaround twice (if needed) */
4010 reg
= er32(PHY_CTRL
);
4011 reg
|= (E1000_PHY_CTRL_GBE_DISABLE
|
4012 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
);
4013 ew32(PHY_CTRL
, reg
);
4015 /* Call gig speed drop workaround on Gig disable before
4016 * accessing any PHY registers
4018 if (hw
->mac
.type
== e1000_ich8lan
)
4019 e1000e_gig_downshift_workaround_ich8lan(hw
);
4021 /* Write VR power-down enable */
4022 e1e_rphy(hw
, IGP3_VR_CTRL
, &data
);
4023 data
&= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK
;
4024 e1e_wphy(hw
, IGP3_VR_CTRL
, data
| IGP3_VR_CTRL_MODE_SHUTDOWN
);
4026 /* Read it back and test */
4027 e1e_rphy(hw
, IGP3_VR_CTRL
, &data
);
4028 data
&= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK
;
4029 if ((data
== IGP3_VR_CTRL_MODE_SHUTDOWN
) || retry
)
4032 /* Issue PHY reset and repeat at most one more time */
4034 ew32(CTRL
, reg
| E1000_CTRL_PHY_RST
);
4040 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
4041 * @hw: pointer to the HW structure
4043 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
4044 * LPLU, Gig disable, MDIC PHY reset):
4045 * 1) Set Kumeran Near-end loopback
4046 * 2) Clear Kumeran Near-end loopback
4047 * Should only be called for ICH8[m] devices with any 1G Phy.
4049 void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw
*hw
)
4054 if ((hw
->mac
.type
!= e1000_ich8lan
) || (hw
->phy
.type
== e1000_phy_ife
))
4057 ret_val
= e1000e_read_kmrn_reg(hw
, E1000_KMRNCTRLSTA_DIAG_OFFSET
,
4061 reg_data
|= E1000_KMRNCTRLSTA_DIAG_NELPBK
;
4062 ret_val
= e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_DIAG_OFFSET
,
4066 reg_data
&= ~E1000_KMRNCTRLSTA_DIAG_NELPBK
;
4067 ret_val
= e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_DIAG_OFFSET
,
4072 * e1000_suspend_workarounds_ich8lan - workarounds needed during S0->Sx
4073 * @hw: pointer to the HW structure
4075 * During S0 to Sx transition, it is possible the link remains at gig
4076 * instead of negotiating to a lower speed. Before going to Sx, set
4077 * 'Gig Disable' to force link speed negotiation to a lower speed based on
4078 * the LPLU setting in the NVM or custom setting. For PCH and newer parts,
4079 * the OEM bits PHY register (LED, GbE disable and LPLU configurations) also
4080 * needs to be written.
4081 * Parts that support (and are linked to a partner which support) EEE in
4082 * 100Mbps should disable LPLU since 100Mbps w/ EEE requires less power
4083 * than 10Mbps w/o EEE.
4085 void e1000_suspend_workarounds_ich8lan(struct e1000_hw
*hw
)
4087 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
4091 phy_ctrl
= er32(PHY_CTRL
);
4092 phy_ctrl
|= E1000_PHY_CTRL_GBE_DISABLE
;
4093 if (hw
->phy
.type
== e1000_phy_i217
) {
4096 ret_val
= hw
->phy
.ops
.acquire(hw
);
4100 if (!dev_spec
->eee_disable
) {
4104 e1000_read_emi_reg_locked(hw
,
4105 I217_EEE_ADVERTISEMENT
,
4110 /* Disable LPLU if both link partners support 100BaseT
4111 * EEE and 100Full is advertised on both ends of the
4114 if ((eee_advert
& I82579_EEE_100_SUPPORTED
) &&
4115 (dev_spec
->eee_lp_ability
&
4116 I82579_EEE_100_SUPPORTED
) &&
4117 (hw
->phy
.autoneg_advertised
& ADVERTISE_100_FULL
))
4118 phy_ctrl
&= ~(E1000_PHY_CTRL_D0A_LPLU
|
4119 E1000_PHY_CTRL_NOND0A_LPLU
);
4122 /* For i217 Intel Rapid Start Technology support,
4123 * when the system is going into Sx and no manageability engine
4124 * is present, the driver must configure proxy to reset only on
4125 * power good. LPI (Low Power Idle) state must also reset only
4126 * on power good, as well as the MTA (Multicast table array).
4127 * The SMBus release must also be disabled on LCD reset.
4129 if (!(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
)) {
4131 /* Enable proxy to reset only on power good. */
4132 e1e_rphy_locked(hw
, I217_PROXY_CTRL
, &phy_reg
);
4133 phy_reg
|= I217_PROXY_CTRL_AUTO_DISABLE
;
4134 e1e_wphy_locked(hw
, I217_PROXY_CTRL
, phy_reg
);
4136 /* Set bit enable LPI (EEE) to reset only on
4139 e1e_rphy_locked(hw
, I217_SxCTRL
, &phy_reg
);
4140 phy_reg
|= I217_SxCTRL_ENABLE_LPI_RESET
;
4141 e1e_wphy_locked(hw
, I217_SxCTRL
, phy_reg
);
4143 /* Disable the SMB release on LCD reset. */
4144 e1e_rphy_locked(hw
, I217_MEMPWR
, &phy_reg
);
4145 phy_reg
&= ~I217_MEMPWR_DISABLE_SMB_RELEASE
;
4146 e1e_wphy_locked(hw
, I217_MEMPWR
, phy_reg
);
4149 /* Enable MTA to reset for Intel Rapid Start Technology
4152 e1e_rphy_locked(hw
, I217_CGFREG
, &phy_reg
);
4153 phy_reg
|= I217_CGFREG_ENABLE_MTA_RESET
;
4154 e1e_wphy_locked(hw
, I217_CGFREG
, phy_reg
);
4157 hw
->phy
.ops
.release(hw
);
4160 ew32(PHY_CTRL
, phy_ctrl
);
4162 if (hw
->mac
.type
== e1000_ich8lan
)
4163 e1000e_gig_downshift_workaround_ich8lan(hw
);
4165 if (hw
->mac
.type
>= e1000_pchlan
) {
4166 e1000_oem_bits_config_ich8lan(hw
, false);
4168 /* Reset PHY to activate OEM bits on 82577/8 */
4169 if (hw
->mac
.type
== e1000_pchlan
)
4170 e1000e_phy_hw_reset_generic(hw
);
4172 ret_val
= hw
->phy
.ops
.acquire(hw
);
4175 e1000_write_smbus_addr(hw
);
4176 hw
->phy
.ops
.release(hw
);
4181 * e1000_resume_workarounds_pchlan - workarounds needed during Sx->S0
4182 * @hw: pointer to the HW structure
4184 * During Sx to S0 transitions on non-managed devices or managed devices
4185 * on which PHY resets are not blocked, if the PHY registers cannot be
4186 * accessed properly by the s/w toggle the LANPHYPC value to power cycle
4188 * On i217, setup Intel Rapid Start Technology.
4190 void e1000_resume_workarounds_pchlan(struct e1000_hw
*hw
)
4194 if (hw
->mac
.type
< e1000_pch2lan
)
4197 ret_val
= e1000_init_phy_workarounds_pchlan(hw
);
4199 e_dbg("Failed to init PHY flow ret_val=%d\n", ret_val
);
4203 /* For i217 Intel Rapid Start Technology support when the system
4204 * is transitioning from Sx and no manageability engine is present
4205 * configure SMBus to restore on reset, disable proxy, and enable
4206 * the reset on MTA (Multicast table array).
4208 if (hw
->phy
.type
== e1000_phy_i217
) {
4211 ret_val
= hw
->phy
.ops
.acquire(hw
);
4213 e_dbg("Failed to setup iRST\n");
4217 if (!(er32(FWSM
) & E1000_ICH_FWSM_FW_VALID
)) {
4218 /* Restore clear on SMB if no manageability engine
4221 ret_val
= e1e_rphy_locked(hw
, I217_MEMPWR
, &phy_reg
);
4224 phy_reg
|= I217_MEMPWR_DISABLE_SMB_RELEASE
;
4225 e1e_wphy_locked(hw
, I217_MEMPWR
, phy_reg
);
4228 e1e_wphy_locked(hw
, I217_PROXY_CTRL
, 0);
4230 /* Enable reset on MTA */
4231 ret_val
= e1e_rphy_locked(hw
, I217_CGFREG
, &phy_reg
);
4234 phy_reg
&= ~I217_CGFREG_ENABLE_MTA_RESET
;
4235 e1e_wphy_locked(hw
, I217_CGFREG
, phy_reg
);
4238 e_dbg("Error %d in resume workarounds\n", ret_val
);
4239 hw
->phy
.ops
.release(hw
);
4244 * e1000_cleanup_led_ich8lan - Restore the default LED operation
4245 * @hw: pointer to the HW structure
4247 * Return the LED back to the default configuration.
4249 static s32
e1000_cleanup_led_ich8lan(struct e1000_hw
*hw
)
4251 if (hw
->phy
.type
== e1000_phy_ife
)
4252 return e1e_wphy(hw
, IFE_PHY_SPECIAL_CONTROL_LED
, 0);
4254 ew32(LEDCTL
, hw
->mac
.ledctl_default
);
4259 * e1000_led_on_ich8lan - Turn LEDs on
4260 * @hw: pointer to the HW structure
4264 static s32
e1000_led_on_ich8lan(struct e1000_hw
*hw
)
4266 if (hw
->phy
.type
== e1000_phy_ife
)
4267 return e1e_wphy(hw
, IFE_PHY_SPECIAL_CONTROL_LED
,
4268 (IFE_PSCL_PROBE_MODE
| IFE_PSCL_PROBE_LEDS_ON
));
4270 ew32(LEDCTL
, hw
->mac
.ledctl_mode2
);
4275 * e1000_led_off_ich8lan - Turn LEDs off
4276 * @hw: pointer to the HW structure
4278 * Turn off the LEDs.
4280 static s32
e1000_led_off_ich8lan(struct e1000_hw
*hw
)
4282 if (hw
->phy
.type
== e1000_phy_ife
)
4283 return e1e_wphy(hw
, IFE_PHY_SPECIAL_CONTROL_LED
,
4284 (IFE_PSCL_PROBE_MODE
|
4285 IFE_PSCL_PROBE_LEDS_OFF
));
4287 ew32(LEDCTL
, hw
->mac
.ledctl_mode1
);
4292 * e1000_setup_led_pchlan - Configures SW controllable LED
4293 * @hw: pointer to the HW structure
4295 * This prepares the SW controllable LED for use.
4297 static s32
e1000_setup_led_pchlan(struct e1000_hw
*hw
)
4299 return e1e_wphy(hw
, HV_LED_CONFIG
, (u16
)hw
->mac
.ledctl_mode1
);
4303 * e1000_cleanup_led_pchlan - Restore the default LED operation
4304 * @hw: pointer to the HW structure
4306 * Return the LED back to the default configuration.
4308 static s32
e1000_cleanup_led_pchlan(struct e1000_hw
*hw
)
4310 return e1e_wphy(hw
, HV_LED_CONFIG
, (u16
)hw
->mac
.ledctl_default
);
4314 * e1000_led_on_pchlan - Turn LEDs on
4315 * @hw: pointer to the HW structure
4319 static s32
e1000_led_on_pchlan(struct e1000_hw
*hw
)
4321 u16 data
= (u16
)hw
->mac
.ledctl_mode2
;
4324 /* If no link, then turn LED on by setting the invert bit
4325 * for each LED that's mode is "link_up" in ledctl_mode2.
4327 if (!(er32(STATUS
) & E1000_STATUS_LU
)) {
4328 for (i
= 0; i
< 3; i
++) {
4329 led
= (data
>> (i
* 5)) & E1000_PHY_LED0_MASK
;
4330 if ((led
& E1000_PHY_LED0_MODE_MASK
) !=
4331 E1000_LEDCTL_MODE_LINK_UP
)
4333 if (led
& E1000_PHY_LED0_IVRT
)
4334 data
&= ~(E1000_PHY_LED0_IVRT
<< (i
* 5));
4336 data
|= (E1000_PHY_LED0_IVRT
<< (i
* 5));
4340 return e1e_wphy(hw
, HV_LED_CONFIG
, data
);
4344 * e1000_led_off_pchlan - Turn LEDs off
4345 * @hw: pointer to the HW structure
4347 * Turn off the LEDs.
4349 static s32
e1000_led_off_pchlan(struct e1000_hw
*hw
)
4351 u16 data
= (u16
)hw
->mac
.ledctl_mode1
;
4354 /* If no link, then turn LED off by clearing the invert bit
4355 * for each LED that's mode is "link_up" in ledctl_mode1.
4357 if (!(er32(STATUS
) & E1000_STATUS_LU
)) {
4358 for (i
= 0; i
< 3; i
++) {
4359 led
= (data
>> (i
* 5)) & E1000_PHY_LED0_MASK
;
4360 if ((led
& E1000_PHY_LED0_MODE_MASK
) !=
4361 E1000_LEDCTL_MODE_LINK_UP
)
4363 if (led
& E1000_PHY_LED0_IVRT
)
4364 data
&= ~(E1000_PHY_LED0_IVRT
<< (i
* 5));
4366 data
|= (E1000_PHY_LED0_IVRT
<< (i
* 5));
4370 return e1e_wphy(hw
, HV_LED_CONFIG
, data
);
4374 * e1000_get_cfg_done_ich8lan - Read config done bit after Full or PHY reset
4375 * @hw: pointer to the HW structure
4377 * Read appropriate register for the config done bit for completion status
4378 * and configure the PHY through s/w for EEPROM-less parts.
4380 * NOTE: some silicon which is EEPROM-less will fail trying to read the
4381 * config done bit, so only an error is logged and continues. If we were
4382 * to return with error, EEPROM-less silicon would not be able to be reset
4385 static s32
e1000_get_cfg_done_ich8lan(struct e1000_hw
*hw
)
4391 e1000e_get_cfg_done(hw
);
4393 /* Wait for indication from h/w that it has completed basic config */
4394 if (hw
->mac
.type
>= e1000_ich10lan
) {
4395 e1000_lan_init_done_ich8lan(hw
);
4397 ret_val
= e1000e_get_auto_rd_done(hw
);
4399 /* When auto config read does not complete, do not
4400 * return with an error. This can happen in situations
4401 * where there is no eeprom and prevents getting link.
4403 e_dbg("Auto Read Done did not complete\n");
4408 /* Clear PHY Reset Asserted bit */
4409 status
= er32(STATUS
);
4410 if (status
& E1000_STATUS_PHYRA
)
4411 ew32(STATUS
, status
& ~E1000_STATUS_PHYRA
);
4413 e_dbg("PHY Reset Asserted not set - needs delay\n");
4415 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
4416 if (hw
->mac
.type
<= e1000_ich9lan
) {
4417 if (!(er32(EECD
) & E1000_EECD_PRES
) &&
4418 (hw
->phy
.type
== e1000_phy_igp_3
)) {
4419 e1000e_phy_init_script_igp3(hw
);
4422 if (e1000_valid_nvm_bank_detect_ich8lan(hw
, &bank
)) {
4423 /* Maybe we should do a basic PHY config */
4424 e_dbg("EEPROM not present\n");
4425 ret_val
= -E1000_ERR_CONFIG
;
4433 * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down
4434 * @hw: pointer to the HW structure
4436 * In the case of a PHY power down to save power, or to turn off link during a
4437 * driver unload, or wake on lan is not enabled, remove the link.
4439 static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw
*hw
)
4441 /* If the management interface is not enabled, then power down */
4442 if (!(hw
->mac
.ops
.check_mng_mode(hw
) ||
4443 hw
->phy
.ops
.check_reset_block(hw
)))
4444 e1000_power_down_phy_copper(hw
);
4448 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
4449 * @hw: pointer to the HW structure
4451 * Clears hardware counters specific to the silicon family and calls
4452 * clear_hw_cntrs_generic to clear all general purpose counters.
4454 static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw
*hw
)
4459 e1000e_clear_hw_cntrs_base(hw
);
4475 /* Clear PHY statistics registers */
4476 if ((hw
->phy
.type
== e1000_phy_82578
) ||
4477 (hw
->phy
.type
== e1000_phy_82579
) ||
4478 (hw
->phy
.type
== e1000_phy_i217
) ||
4479 (hw
->phy
.type
== e1000_phy_82577
)) {
4480 ret_val
= hw
->phy
.ops
.acquire(hw
);
4483 ret_val
= hw
->phy
.ops
.set_page(hw
,
4484 HV_STATS_PAGE
<< IGP_PAGE_SHIFT
);
4487 hw
->phy
.ops
.read_reg_page(hw
, HV_SCC_UPPER
, &phy_data
);
4488 hw
->phy
.ops
.read_reg_page(hw
, HV_SCC_LOWER
, &phy_data
);
4489 hw
->phy
.ops
.read_reg_page(hw
, HV_ECOL_UPPER
, &phy_data
);
4490 hw
->phy
.ops
.read_reg_page(hw
, HV_ECOL_LOWER
, &phy_data
);
4491 hw
->phy
.ops
.read_reg_page(hw
, HV_MCC_UPPER
, &phy_data
);
4492 hw
->phy
.ops
.read_reg_page(hw
, HV_MCC_LOWER
, &phy_data
);
4493 hw
->phy
.ops
.read_reg_page(hw
, HV_LATECOL_UPPER
, &phy_data
);
4494 hw
->phy
.ops
.read_reg_page(hw
, HV_LATECOL_LOWER
, &phy_data
);
4495 hw
->phy
.ops
.read_reg_page(hw
, HV_COLC_UPPER
, &phy_data
);
4496 hw
->phy
.ops
.read_reg_page(hw
, HV_COLC_LOWER
, &phy_data
);
4497 hw
->phy
.ops
.read_reg_page(hw
, HV_DC_UPPER
, &phy_data
);
4498 hw
->phy
.ops
.read_reg_page(hw
, HV_DC_LOWER
, &phy_data
);
4499 hw
->phy
.ops
.read_reg_page(hw
, HV_TNCRS_UPPER
, &phy_data
);
4500 hw
->phy
.ops
.read_reg_page(hw
, HV_TNCRS_LOWER
, &phy_data
);
4502 hw
->phy
.ops
.release(hw
);
4506 static const struct e1000_mac_operations ich8_mac_ops
= {
4507 /* check_mng_mode dependent on mac type */
4508 .check_for_link
= e1000_check_for_copper_link_ich8lan
,
4509 /* cleanup_led dependent on mac type */
4510 .clear_hw_cntrs
= e1000_clear_hw_cntrs_ich8lan
,
4511 .get_bus_info
= e1000_get_bus_info_ich8lan
,
4512 .set_lan_id
= e1000_set_lan_id_single_port
,
4513 .get_link_up_info
= e1000_get_link_up_info_ich8lan
,
4514 /* led_on dependent on mac type */
4515 /* led_off dependent on mac type */
4516 .update_mc_addr_list
= e1000e_update_mc_addr_list_generic
,
4517 .reset_hw
= e1000_reset_hw_ich8lan
,
4518 .init_hw
= e1000_init_hw_ich8lan
,
4519 .setup_link
= e1000_setup_link_ich8lan
,
4520 .setup_physical_interface
= e1000_setup_copper_link_ich8lan
,
4521 /* id_led_init dependent on mac type */
4522 .config_collision_dist
= e1000e_config_collision_dist_generic
,
4523 .rar_set
= e1000e_rar_set_generic
,
4526 static const struct e1000_phy_operations ich8_phy_ops
= {
4527 .acquire
= e1000_acquire_swflag_ich8lan
,
4528 .check_reset_block
= e1000_check_reset_block_ich8lan
,
4530 .get_cfg_done
= e1000_get_cfg_done_ich8lan
,
4531 .get_cable_length
= e1000e_get_cable_length_igp_2
,
4532 .read_reg
= e1000e_read_phy_reg_igp
,
4533 .release
= e1000_release_swflag_ich8lan
,
4534 .reset
= e1000_phy_hw_reset_ich8lan
,
4535 .set_d0_lplu_state
= e1000_set_d0_lplu_state_ich8lan
,
4536 .set_d3_lplu_state
= e1000_set_d3_lplu_state_ich8lan
,
4537 .write_reg
= e1000e_write_phy_reg_igp
,
4540 static const struct e1000_nvm_operations ich8_nvm_ops
= {
4541 .acquire
= e1000_acquire_nvm_ich8lan
,
4542 .read
= e1000_read_nvm_ich8lan
,
4543 .release
= e1000_release_nvm_ich8lan
,
4544 .reload
= e1000e_reload_nvm_generic
,
4545 .update
= e1000_update_nvm_checksum_ich8lan
,
4546 .valid_led_default
= e1000_valid_led_default_ich8lan
,
4547 .validate
= e1000_validate_nvm_checksum_ich8lan
,
4548 .write
= e1000_write_nvm_ich8lan
,
4551 const struct e1000_info e1000_ich8_info
= {
4552 .mac
= e1000_ich8lan
,
4553 .flags
= FLAG_HAS_WOL
4555 | FLAG_HAS_CTRLEXT_ON_LOAD
4560 .max_hw_frame_size
= ETH_FRAME_LEN
+ ETH_FCS_LEN
,
4561 .get_variants
= e1000_get_variants_ich8lan
,
4562 .mac_ops
= &ich8_mac_ops
,
4563 .phy_ops
= &ich8_phy_ops
,
4564 .nvm_ops
= &ich8_nvm_ops
,
4567 const struct e1000_info e1000_ich9_info
= {
4568 .mac
= e1000_ich9lan
,
4569 .flags
= FLAG_HAS_JUMBO_FRAMES
4572 | FLAG_HAS_CTRLEXT_ON_LOAD
4577 .max_hw_frame_size
= DEFAULT_JUMBO
,
4578 .get_variants
= e1000_get_variants_ich8lan
,
4579 .mac_ops
= &ich8_mac_ops
,
4580 .phy_ops
= &ich8_phy_ops
,
4581 .nvm_ops
= &ich8_nvm_ops
,
4584 const struct e1000_info e1000_ich10_info
= {
4585 .mac
= e1000_ich10lan
,
4586 .flags
= FLAG_HAS_JUMBO_FRAMES
4589 | FLAG_HAS_CTRLEXT_ON_LOAD
4594 .max_hw_frame_size
= DEFAULT_JUMBO
,
4595 .get_variants
= e1000_get_variants_ich8lan
,
4596 .mac_ops
= &ich8_mac_ops
,
4597 .phy_ops
= &ich8_phy_ops
,
4598 .nvm_ops
= &ich8_nvm_ops
,
4601 const struct e1000_info e1000_pch_info
= {
4602 .mac
= e1000_pchlan
,
4603 .flags
= FLAG_IS_ICH
4605 | FLAG_HAS_CTRLEXT_ON_LOAD
4608 | FLAG_HAS_JUMBO_FRAMES
4609 | FLAG_DISABLE_FC_PAUSE_TIME
/* errata */
4611 .flags2
= FLAG2_HAS_PHY_STATS
,
4613 .max_hw_frame_size
= 4096,
4614 .get_variants
= e1000_get_variants_ich8lan
,
4615 .mac_ops
= &ich8_mac_ops
,
4616 .phy_ops
= &ich8_phy_ops
,
4617 .nvm_ops
= &ich8_nvm_ops
,
4620 const struct e1000_info e1000_pch2_info
= {
4621 .mac
= e1000_pch2lan
,
4622 .flags
= FLAG_IS_ICH
4624 | FLAG_HAS_CTRLEXT_ON_LOAD
4627 | FLAG_HAS_JUMBO_FRAMES
4629 .flags2
= FLAG2_HAS_PHY_STATS
4632 .max_hw_frame_size
= DEFAULT_JUMBO
,
4633 .get_variants
= e1000_get_variants_ich8lan
,
4634 .mac_ops
= &ich8_mac_ops
,
4635 .phy_ops
= &ich8_phy_ops
,
4636 .nvm_ops
= &ich8_nvm_ops
,
4639 const struct e1000_info e1000_pch_lpt_info
= {
4640 .mac
= e1000_pch_lpt
,
4641 .flags
= FLAG_IS_ICH
4643 | FLAG_HAS_CTRLEXT_ON_LOAD
4646 | FLAG_HAS_JUMBO_FRAMES
4648 .flags2
= FLAG2_HAS_PHY_STATS
4651 .max_hw_frame_size
= DEFAULT_JUMBO
,
4652 .get_variants
= e1000_get_variants_ich8lan
,
4653 .mac_ops
= &ich8_mac_ops
,
4654 .phy_ops
= &ich8_phy_ops
,
4655 .nvm_ops
= &ich8_nvm_ops
,