blob: 6c0d96b9889d0c809cd116ebb7a6f1ceb653330e [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allanbf670442013-01-01 16:00:01 +00004 Copyright(c) 1999 - 2013 Intel Corporation.
Auke Kokbc7f75f2007-09-17 12:30:59 -07005
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28
Bruce Allane921eb12012-11-28 09:28:37 +000029/* 80003ES2LAN Gigabit Ethernet Controller (Copper)
Auke Kokbc7f75f2007-09-17 12:30:59 -070030 * 80003ES2LAN Gigabit Ethernet Controller (Serdes)
31 */
32
Auke Kokbc7f75f2007-09-17 12:30:59 -070033#include "e1000.h"
34
Bruce Allane921eb12012-11-28 09:28:37 +000035/* A table for the GG82563 cable length where the range is defined
Auke Kokbc7f75f2007-09-17 12:30:59 -070036 * with a lower bound at "index" and the upper bound at
37 * "index + 5".
38 */
Bruce Allan64806412010-12-11 05:53:42 +000039static const u16 e1000_gg82563_cable_length_table[] = {
40 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
Bruce Allaneb656d42009-12-01 15:47:02 +000041#define GG82563_CABLE_LENGTH_TABLE_SIZE \
42 ARRAY_SIZE(e1000_gg82563_cable_length_table)
Auke Kokbc7f75f2007-09-17 12:30:59 -070043
44static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
45static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
46static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
47static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
48static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
49static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
50static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
Bruce Allan1f96012d2013-01-05 03:06:54 +000051static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
52 u16 *data);
53static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
54 u16 data);
Bruce Allan17f208d2009-12-01 15:47:22 +000055static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -070056
57/**
58 * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
59 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -070060 **/
61static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw)
62{
63 struct e1000_phy_info *phy = &hw->phy;
64 s32 ret_val;
65
Jeff Kirsher318a94d2008-03-28 09:15:16 -070066 if (hw->phy.media_type != e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -070067 phy->type = e1000_phy_none;
68 return 0;
Bruce Allan17f208d2009-12-01 15:47:22 +000069 } else {
70 phy->ops.power_up = e1000_power_up_phy_copper;
71 phy->ops.power_down = e1000_power_down_phy_copper_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -070072 }
73
74 phy->addr = 1;
75 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
76 phy->reset_delay_us = 100;
77 phy->type = e1000_phy_gg82563;
78
79 /* This can only be done after all function pointers are setup. */
80 ret_val = e1000e_get_phy_id(hw);
81
82 /* Verify phy id */
83 if (phy->id != GG82563_E_PHY_ID)
84 return -E1000_ERR_PHY;
85
86 return ret_val;
87}
88
89/**
90 * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
91 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -070092 **/
93static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
94{
95 struct e1000_nvm_info *nvm = &hw->nvm;
96 u32 eecd = er32(EECD);
97 u16 size;
98
99 nvm->opcode_bits = 8;
100 nvm->delay_usec = 1;
101 switch (nvm->override) {
102 case e1000_nvm_override_spi_large:
103 nvm->page_size = 32;
104 nvm->address_bits = 16;
105 break;
106 case e1000_nvm_override_spi_small:
107 nvm->page_size = 8;
108 nvm->address_bits = 8;
109 break;
110 default:
111 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
112 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
113 break;
114 }
115
Bruce Allanad680762008-03-28 09:15:03 -0700116 nvm->type = e1000_nvm_eeprom_spi;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700117
118 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
Bruce Allanf0ff4392013-02-20 04:05:39 +0000119 E1000_EECD_SIZE_EX_SHIFT);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700120
Bruce Allane921eb12012-11-28 09:28:37 +0000121 /* Added to a constant, "size" becomes the left-shift value
Auke Kokbc7f75f2007-09-17 12:30:59 -0700122 * for setting word_size.
123 */
124 size += NVM_WORD_SIZE_BASE_SHIFT;
Jeff Kirsher8d7c2942008-04-02 13:48:07 -0700125
126 /* EEPROM access above 16k is unsupported */
127 if (size > 14)
128 size = 14;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700129 nvm->word_size = 1 << size;
130
131 return 0;
132}
133
134/**
135 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
136 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700137 **/
Bruce Allanec34c172012-02-01 10:53:05 +0000138static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700139{
Auke Kokbc7f75f2007-09-17 12:30:59 -0700140 struct e1000_mac_info *mac = &hw->mac;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700141
Bruce Allane68782e2012-01-31 06:37:43 +0000142 /* Set media type and media-dependent function pointers */
Bruce Allanec34c172012-02-01 10:53:05 +0000143 switch (hw->adapter->pdev->device) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700144 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700145 hw->phy.media_type = e1000_media_type_internal_serdes;
Bruce Allane68782e2012-01-31 06:37:43 +0000146 mac->ops.check_for_link = e1000e_check_for_serdes_link;
147 mac->ops.setup_physical_interface =
148 e1000e_setup_fiber_serdes_link;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700149 break;
150 default:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700151 hw->phy.media_type = e1000_media_type_copper;
Bruce Allane68782e2012-01-31 06:37:43 +0000152 mac->ops.check_for_link = e1000e_check_for_copper_link;
153 mac->ops.setup_physical_interface =
154 e1000_setup_copper_link_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700155 break;
156 }
157
158 /* Set mta register count */
159 mac->mta_reg_count = 128;
160 /* Set rar entry count */
161 mac->rar_entry_count = E1000_RAR_ENTRIES;
Bruce Allana65a4a02010-05-10 15:01:51 +0000162 /* FWSM register */
163 mac->has_fwsm = true;
164 /* ARC supported; valid only if manageability features are enabled. */
Bruce Allan04499ec2012-04-13 00:08:31 +0000165 mac->arc_subsystem_valid = !!(er32(FWSM) & E1000_FWSM_MODE_MASK);
Bruce Allanf464ba82010-01-07 16:31:35 +0000166 /* Adaptive IFS not supported */
167 mac->adaptive_ifs = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700168
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000169 /* set lan id for port to determine which phy lock to use */
170 hw->mac.ops.set_lan_id(hw);
171
Auke Kokbc7f75f2007-09-17 12:30:59 -0700172 return 0;
173}
174
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700175static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700176{
177 struct e1000_hw *hw = &adapter->hw;
178 s32 rc;
179
Bruce Allanec34c172012-02-01 10:53:05 +0000180 rc = e1000_init_mac_params_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700181 if (rc)
182 return rc;
183
184 rc = e1000_init_nvm_params_80003es2lan(hw);
185 if (rc)
186 return rc;
187
188 rc = e1000_init_phy_params_80003es2lan(hw);
189 if (rc)
190 return rc;
191
192 return 0;
193}
194
195/**
196 * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
197 * @hw: pointer to the HW structure
198 *
Bruce Allanfe401672009-11-20 23:26:05 +0000199 * A wrapper to acquire access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700200 **/
201static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw)
202{
203 u16 mask;
204
205 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700206 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
207}
208
209/**
210 * e1000_release_phy_80003es2lan - Release rights to access PHY
211 * @hw: pointer to the HW structure
212 *
Bruce Allanfe401672009-11-20 23:26:05 +0000213 * A wrapper to release access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700214 **/
215static void e1000_release_phy_80003es2lan(struct e1000_hw *hw)
216{
217 u16 mask;
218
219 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800220 e1000_release_swfw_sync_80003es2lan(hw, mask);
221}
222
223/**
Bruce Allandffcdde2012-02-17 09:35:33 +0000224 * e1000_acquire_mac_csr_80003es2lan - Acquire right to access Kumeran register
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800225 * @hw: pointer to the HW structure
226 *
227 * Acquire the semaphore to access the Kumeran interface.
228 *
229 **/
230static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
231{
232 u16 mask;
233
234 mask = E1000_SWFW_CSR_SM;
235
236 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
237}
238
239/**
Bruce Allandffcdde2012-02-17 09:35:33 +0000240 * e1000_release_mac_csr_80003es2lan - Release right to access Kumeran Register
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800241 * @hw: pointer to the HW structure
242 *
243 * Release the semaphore used to access the Kumeran interface
244 **/
245static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw)
246{
247 u16 mask;
248
249 mask = E1000_SWFW_CSR_SM;
David Graham2d9498f2008-04-23 11:09:14 -0700250
Auke Kokbc7f75f2007-09-17 12:30:59 -0700251 e1000_release_swfw_sync_80003es2lan(hw, mask);
252}
253
254/**
255 * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
256 * @hw: pointer to the HW structure
257 *
Bruce Allanfe401672009-11-20 23:26:05 +0000258 * Acquire the semaphore to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700259 **/
260static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw)
261{
262 s32 ret_val;
263
264 ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
265 if (ret_val)
266 return ret_val;
267
268 ret_val = e1000e_acquire_nvm(hw);
269
270 if (ret_val)
271 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
272
273 return ret_val;
274}
275
276/**
277 * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
278 * @hw: pointer to the HW structure
279 *
Bruce Allanfe401672009-11-20 23:26:05 +0000280 * Release the semaphore used to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700281 **/
282static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
283{
284 e1000e_release_nvm(hw);
285 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
286}
287
288/**
289 * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
290 * @hw: pointer to the HW structure
291 * @mask: specifies which semaphore to acquire
292 *
293 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
294 * will also specify which port we're acquiring the lock for.
295 **/
296static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
297{
298 u32 swfw_sync;
299 u32 swmask = mask;
300 u32 fwmask = mask << 16;
301 s32 i = 0;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800302 s32 timeout = 50;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700303
304 while (i < timeout) {
305 if (e1000e_get_hw_semaphore(hw))
306 return -E1000_ERR_SWFW_SYNC;
307
308 swfw_sync = er32(SW_FW_SYNC);
309 if (!(swfw_sync & (fwmask | swmask)))
310 break;
311
Bruce Allane921eb12012-11-28 09:28:37 +0000312 /* Firmware currently using resource (fwmask)
Bruce Allanad680762008-03-28 09:15:03 -0700313 * or other software thread using resource (swmask)
314 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700315 e1000e_put_hw_semaphore(hw);
316 mdelay(5);
317 i++;
318 }
319
320 if (i == timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000321 e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700322 return -E1000_ERR_SWFW_SYNC;
323 }
324
325 swfw_sync |= swmask;
326 ew32(SW_FW_SYNC, swfw_sync);
327
328 e1000e_put_hw_semaphore(hw);
329
330 return 0;
331}
332
333/**
334 * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
335 * @hw: pointer to the HW structure
336 * @mask: specifies which semaphore to acquire
337 *
338 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
339 * will also specify which port we're releasing the lock for.
340 **/
341static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
342{
343 u32 swfw_sync;
344
Bruce Allan184125a2010-12-11 05:53:37 +0000345 while (e1000e_get_hw_semaphore(hw) != 0)
346 ; /* Empty */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700347
348 swfw_sync = er32(SW_FW_SYNC);
349 swfw_sync &= ~mask;
350 ew32(SW_FW_SYNC, swfw_sync);
351
352 e1000e_put_hw_semaphore(hw);
353}
354
355/**
356 * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
357 * @hw: pointer to the HW structure
358 * @offset: offset of the register to read
359 * @data: pointer to the data returned from the operation
360 *
Bruce Allanfe401672009-11-20 23:26:05 +0000361 * Read the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700362 **/
363static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
364 u32 offset, u16 *data)
365{
366 s32 ret_val;
367 u32 page_select;
368 u16 temp;
369
David Graham2d9498f2008-04-23 11:09:14 -0700370 ret_val = e1000_acquire_phy_80003es2lan(hw);
371 if (ret_val)
372 return ret_val;
373
Auke Kokbc7f75f2007-09-17 12:30:59 -0700374 /* Select Configuration Page */
David Graham2d9498f2008-04-23 11:09:14 -0700375 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700376 page_select = GG82563_PHY_PAGE_SELECT;
David Graham2d9498f2008-04-23 11:09:14 -0700377 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000378 /* Use Alternative Page Select register to access
Auke Kokbc7f75f2007-09-17 12:30:59 -0700379 * registers 30 and 31
380 */
381 page_select = GG82563_PHY_PAGE_SELECT_ALT;
David Graham2d9498f2008-04-23 11:09:14 -0700382 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700383
384 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
David Graham2d9498f2008-04-23 11:09:14 -0700385 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
386 if (ret_val) {
387 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700388 return ret_val;
David Graham2d9498f2008-04-23 11:09:14 -0700389 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700390
Bruce Allanb4d8e212012-02-17 03:17:55 +0000391 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
Bruce Allane921eb12012-11-28 09:28:37 +0000392 /* The "ready" bit in the MDIC register may be incorrectly set
Bruce Allan3421eec2009-12-08 07:28:20 +0000393 * before the device has completed the "Page Select" MDI
394 * transaction. So we wait 200us after each MDI command...
395 */
396 udelay(200);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700397
Bruce Allan3421eec2009-12-08 07:28:20 +0000398 /* ...and verify the command was successful. */
399 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700400
Bruce Allan3421eec2009-12-08 07:28:20 +0000401 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
Bruce Allan3421eec2009-12-08 07:28:20 +0000402 e1000_release_phy_80003es2lan(hw);
Bruce Allan7eb61d82012-02-08 02:55:03 +0000403 return -E1000_ERR_PHY;
Bruce Allan3421eec2009-12-08 07:28:20 +0000404 }
405
406 udelay(200);
407
408 ret_val = e1000e_read_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000409 MAX_PHY_REG_ADDRESS & offset,
410 data);
Bruce Allan3421eec2009-12-08 07:28:20 +0000411
412 udelay(200);
413 } else {
414 ret_val = e1000e_read_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000415 MAX_PHY_REG_ADDRESS & offset,
416 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700417 }
418
David Graham2d9498f2008-04-23 11:09:14 -0700419 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700420
421 return ret_val;
422}
423
424/**
425 * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
426 * @hw: pointer to the HW structure
427 * @offset: offset of the register to read
428 * @data: value to write to the register
429 *
Bruce Allanfe401672009-11-20 23:26:05 +0000430 * Write to the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700431 **/
432static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
433 u32 offset, u16 data)
434{
435 s32 ret_val;
436 u32 page_select;
437 u16 temp;
438
David Graham2d9498f2008-04-23 11:09:14 -0700439 ret_val = e1000_acquire_phy_80003es2lan(hw);
440 if (ret_val)
441 return ret_val;
442
Auke Kokbc7f75f2007-09-17 12:30:59 -0700443 /* Select Configuration Page */
David Graham2d9498f2008-04-23 11:09:14 -0700444 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700445 page_select = GG82563_PHY_PAGE_SELECT;
David Graham2d9498f2008-04-23 11:09:14 -0700446 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000447 /* Use Alternative Page Select register to access
Auke Kokbc7f75f2007-09-17 12:30:59 -0700448 * registers 30 and 31
449 */
450 page_select = GG82563_PHY_PAGE_SELECT_ALT;
David Graham2d9498f2008-04-23 11:09:14 -0700451 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700452
453 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
David Graham2d9498f2008-04-23 11:09:14 -0700454 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
455 if (ret_val) {
456 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700457 return ret_val;
David Graham2d9498f2008-04-23 11:09:14 -0700458 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700459
Bruce Allanb4d8e212012-02-17 03:17:55 +0000460 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
Bruce Allane921eb12012-11-28 09:28:37 +0000461 /* The "ready" bit in the MDIC register may be incorrectly set
Bruce Allan3421eec2009-12-08 07:28:20 +0000462 * before the device has completed the "Page Select" MDI
463 * transaction. So we wait 200us after each MDI command...
464 */
465 udelay(200);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700466
Bruce Allan3421eec2009-12-08 07:28:20 +0000467 /* ...and verify the command was successful. */
468 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700469
Bruce Allan3421eec2009-12-08 07:28:20 +0000470 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
471 e1000_release_phy_80003es2lan(hw);
472 return -E1000_ERR_PHY;
473 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700474
Bruce Allan3421eec2009-12-08 07:28:20 +0000475 udelay(200);
476
477 ret_val = e1000e_write_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000478 MAX_PHY_REG_ADDRESS &
479 offset, data);
Bruce Allan3421eec2009-12-08 07:28:20 +0000480
481 udelay(200);
482 } else {
483 ret_val = e1000e_write_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000484 MAX_PHY_REG_ADDRESS &
485 offset, data);
David Graham2d9498f2008-04-23 11:09:14 -0700486 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700487
David Graham2d9498f2008-04-23 11:09:14 -0700488 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700489
490 return ret_val;
491}
492
493/**
494 * e1000_write_nvm_80003es2lan - Write to ESB2 NVM
495 * @hw: pointer to the HW structure
496 * @offset: offset of the register to read
497 * @words: number of words to write
498 * @data: buffer of data to write to the NVM
499 *
Bruce Allanfe401672009-11-20 23:26:05 +0000500 * Write "words" of data to the ESB2 NVM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700501 **/
502static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
503 u16 words, u16 *data)
504{
505 return e1000e_write_nvm_spi(hw, offset, words, data);
506}
507
508/**
509 * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
510 * @hw: pointer to the HW structure
511 *
512 * Wait a specific amount of time for manageability processes to complete.
513 * This is a function pointer entry point called by the phy module.
514 **/
515static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
516{
517 s32 timeout = PHY_CFG_TIMEOUT;
518 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
519
520 if (hw->bus.func == 1)
521 mask = E1000_NVM_CFG_DONE_PORT_1;
522
523 while (timeout) {
524 if (er32(EEMNGCTL) & mask)
525 break;
Bruce Allan1bba4382011-03-19 00:27:20 +0000526 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700527 timeout--;
528 }
529 if (!timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000530 e_dbg("MNG configuration cycle has not completed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700531 return -E1000_ERR_RESET;
532 }
533
534 return 0;
535}
536
537/**
538 * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
539 * @hw: pointer to the HW structure
540 *
541 * Force the speed and duplex settings onto the PHY. This is a
542 * function pointer entry point called by the phy module.
543 **/
544static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
545{
546 s32 ret_val;
547 u16 phy_data;
548 bool link;
549
Bruce Allane921eb12012-11-28 09:28:37 +0000550 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
Auke Kokbc7f75f2007-09-17 12:30:59 -0700551 * forced whenever speed and duplex are forced.
552 */
553 ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
554 if (ret_val)
555 return ret_val;
556
557 phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
558 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
559 if (ret_val)
560 return ret_val;
561
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000562 e_dbg("GG82563 PSCR: %X\n", phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700563
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000564 ret_val = e1e_rphy(hw, MII_BMCR, &phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700565 if (ret_val)
566 return ret_val;
567
568 e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
569
570 /* Reset the phy to commit changes. */
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000571 phy_data |= BMCR_RESET;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700572
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000573 ret_val = e1e_wphy(hw, MII_BMCR, phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700574 if (ret_val)
575 return ret_val;
576
577 udelay(1);
578
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700579 if (hw->phy.autoneg_wait_to_complete) {
Bruce Allan434f1392011-12-16 00:46:54 +0000580 e_dbg("Waiting for forced speed/duplex link on GG82563 phy.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700581
582 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
Bruce Allan17e813e2013-02-20 04:06:01 +0000583 100000, &link);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700584 if (ret_val)
585 return ret_val;
586
587 if (!link) {
Bruce Allane921eb12012-11-28 09:28:37 +0000588 /* We didn't get link.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700589 * Reset the DSP and cross our fingers.
590 */
591 ret_val = e1000e_phy_reset_dsp(hw);
592 if (ret_val)
593 return ret_val;
594 }
595
596 /* Try once more */
597 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
Bruce Allan17e813e2013-02-20 04:06:01 +0000598 100000, &link);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700599 if (ret_val)
600 return ret_val;
601 }
602
603 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
604 if (ret_val)
605 return ret_val;
606
Bruce Allane921eb12012-11-28 09:28:37 +0000607 /* Resetting the phy means we need to verify the TX_CLK corresponds
Auke Kokbc7f75f2007-09-17 12:30:59 -0700608 * to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
609 */
610 phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
611 if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
612 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
613 else
614 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
615
Bruce Allane921eb12012-11-28 09:28:37 +0000616 /* In addition, we must re-enable CRS on Tx for both half and full
Auke Kokbc7f75f2007-09-17 12:30:59 -0700617 * duplex.
618 */
619 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
620 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
621
622 return ret_val;
623}
624
625/**
626 * e1000_get_cable_length_80003es2lan - Set approximate cable length
627 * @hw: pointer to the HW structure
628 *
629 * Find the approximate cable length as measured by the GG82563 PHY.
630 * This is a function pointer entry point called by the phy module.
631 **/
632static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
633{
634 struct e1000_phy_info *phy = &hw->phy;
Bruce Allan70806a72013-01-05 05:08:37 +0000635 s32 ret_val;
Bruce Allana708dd82009-11-20 23:28:37 +0000636 u16 phy_data, index;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700637
638 ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
639 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000640 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700641
642 index = phy_data & GG82563_DSPD_CABLE_LENGTH;
Bruce Allaneb656d42009-12-01 15:47:02 +0000643
Bruce Allan5015e532012-02-08 02:55:56 +0000644 if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5)
645 return -E1000_ERR_PHY;
Bruce Allaneb656d42009-12-01 15:47:02 +0000646
Auke Kokbc7f75f2007-09-17 12:30:59 -0700647 phy->min_cable_length = e1000_gg82563_cable_length_table[index];
Bruce Allaneb656d42009-12-01 15:47:02 +0000648 phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
Auke Kokbc7f75f2007-09-17 12:30:59 -0700649
650 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
651
Bruce Allan5015e532012-02-08 02:55:56 +0000652 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700653}
654
655/**
656 * e1000_get_link_up_info_80003es2lan - Report speed and duplex
657 * @hw: pointer to the HW structure
658 * @speed: pointer to speed buffer
659 * @duplex: pointer to duplex buffer
660 *
661 * Retrieve the current speed and duplex configuration.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700662 **/
663static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
664 u16 *duplex)
665{
666 s32 ret_val;
667
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700668 if (hw->phy.media_type == e1000_media_type_copper) {
Bruce Allan17e813e2013-02-20 04:06:01 +0000669 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800670 hw->phy.ops.cfg_on_link_up(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700671 } else {
672 ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
Bruce Allan17e813e2013-02-20 04:06:01 +0000673 speed,
674 duplex);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700675 }
676
677 return ret_val;
678}
679
680/**
681 * e1000_reset_hw_80003es2lan - Reset the ESB2 controller
682 * @hw: pointer to the HW structure
683 *
684 * Perform a global reset to the ESB2 controller.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700685 **/
686static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
687{
Bruce Allandd93f952011-01-06 14:29:48 +0000688 u32 ctrl;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700689 s32 ret_val;
Matthew Vick1c1093a2012-03-16 09:02:58 +0000690 u16 kum_reg_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700691
Bruce Allane921eb12012-11-28 09:28:37 +0000692 /* Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -0700693 * on the last TLP read/write transaction when MAC is reset.
694 */
695 ret_val = e1000e_disable_pcie_master(hw);
696 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000697 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700698
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000699 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700700 ew32(IMC, 0xffffffff);
701
702 ew32(RCTL, 0);
703 ew32(TCTL, E1000_TCTL_PSP);
704 e1e_flush();
705
Bruce Allan1bba4382011-03-19 00:27:20 +0000706 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700707
708 ctrl = er32(CTRL);
709
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800710 ret_val = e1000_acquire_phy_80003es2lan(hw);
Bruce Allan7dbbe5d2013-01-05 05:08:31 +0000711 if (ret_val)
712 return ret_val;
713
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000714 e_dbg("Issuing a global reset to MAC\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700715 ew32(CTRL, ctrl | E1000_CTRL_RST);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800716 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700717
Matthew Vick1c1093a2012-03-16 09:02:58 +0000718 /* Disable IBIST slave mode (far-end loopback) */
719 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
720 &kum_reg_data);
721 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
722 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
723 kum_reg_data);
724
Auke Kokbc7f75f2007-09-17 12:30:59 -0700725 ret_val = e1000e_get_auto_rd_done(hw);
726 if (ret_val)
727 /* We don't want to continue accessing MAC registers. */
728 return ret_val;
729
730 /* Clear any pending interrupt events. */
731 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +0000732 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700733
Bruce Allan7eb61d82012-02-08 02:55:03 +0000734 return e1000_check_alt_mac_addr_generic(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700735}
736
737/**
738 * e1000_init_hw_80003es2lan - Initialize the ESB2 controller
739 * @hw: pointer to the HW structure
740 *
741 * Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700742 **/
743static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
744{
745 struct e1000_mac_info *mac = &hw->mac;
746 u32 reg_data;
747 s32 ret_val;
Bruce Alland9b24132011-05-13 07:19:42 +0000748 u16 kum_reg_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700749 u16 i;
750
751 e1000_initialize_hw_bits_80003es2lan(hw);
752
753 /* Initialize identification LED */
Bruce Alland1964eb2012-02-22 09:02:21 +0000754 ret_val = mac->ops.id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +0000755 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000756 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +0000757 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700758
759 /* Disabling VLAN filtering */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000760 e_dbg("Initializing the IEEE VLAN\n");
Bruce Allancaaddaf2009-12-01 15:46:43 +0000761 mac->ops.clear_vfta(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700762
763 /* Setup the receive address. */
764 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
765
766 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000767 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700768 for (i = 0; i < mac->mta_reg_count; i++)
769 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
770
771 /* Setup link and flow control */
Bruce Allan1a46b402012-02-22 09:02:26 +0000772 ret_val = mac->ops.setup_link(hw);
Bruce Allan7dbbe5d2013-01-05 05:08:31 +0000773 if (ret_val)
774 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700775
Bruce Alland9b24132011-05-13 07:19:42 +0000776 /* Disable IBIST slave mode (far-end loopback) */
777 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
778 &kum_reg_data);
779 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
780 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
781 kum_reg_data);
782
Auke Kokbc7f75f2007-09-17 12:30:59 -0700783 /* Set the transmit descriptor write-back policy */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700784 reg_data = er32(TXDCTL(0));
Bruce Allanf0ff4392013-02-20 04:05:39 +0000785 reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
786 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700787 ew32(TXDCTL(0), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700788
789 /* ...for both queues. */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700790 reg_data = er32(TXDCTL(1));
Bruce Allanf0ff4392013-02-20 04:05:39 +0000791 reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
792 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700793 ew32(TXDCTL(1), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700794
795 /* Enable retransmit on late collisions */
796 reg_data = er32(TCTL);
797 reg_data |= E1000_TCTL_RTLC;
798 ew32(TCTL, reg_data);
799
800 /* Configure Gigabit Carry Extend Padding */
801 reg_data = er32(TCTL_EXT);
802 reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
803 reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
804 ew32(TCTL_EXT, reg_data);
805
806 /* Configure Transmit Inter-Packet Gap */
807 reg_data = er32(TIPG);
808 reg_data &= ~E1000_TIPG_IPGT_MASK;
809 reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
810 ew32(TIPG, reg_data);
811
812 reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
813 reg_data &= ~0x00100000;
814 E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
815
Bruce Allan3421eec2009-12-08 07:28:20 +0000816 /* default to true to enable the MDIC W/A */
817 hw->dev_spec.e80003es2lan.mdic_wa_enable = true;
818
Bruce Allanf0ff4392013-02-20 04:05:39 +0000819 ret_val =
820 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET >>
821 E1000_KMRNCTRLSTA_OFFSET_SHIFT, &i);
Bruce Allan3421eec2009-12-08 07:28:20 +0000822 if (!ret_val) {
823 if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
Bruce Allan17e813e2013-02-20 04:06:01 +0000824 E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
Bruce Allan3421eec2009-12-08 07:28:20 +0000825 hw->dev_spec.e80003es2lan.mdic_wa_enable = false;
826 }
827
Bruce Allane921eb12012-11-28 09:28:37 +0000828 /* Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -0700829 * important that we do this after we have tried to establish link
830 * because the symbol error count will increment wildly if there
831 * is no link.
832 */
833 e1000_clear_hw_cntrs_80003es2lan(hw);
834
835 return ret_val;
836}
837
838/**
839 * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
840 * @hw: pointer to the HW structure
841 *
842 * Initializes required hardware-dependent bits needed for normal operation.
843 **/
844static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
845{
846 u32 reg;
847
848 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700849 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700850 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700851 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700852
853 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700854 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700855 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700856 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700857
858 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700859 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700860 reg &= ~(0xF << 27); /* 30:27 */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700861 if (hw->phy.media_type != e1000_media_type_copper)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700862 reg &= ~(1 << 20);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700863 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700864
865 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700866 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700867 if (er32(TCTL) & E1000_TCTL_MULR)
868 reg &= ~(1 << 28);
869 else
870 reg |= (1 << 28);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700871 ew32(TARC(1), reg);
Matthew Vickf6bd5572012-04-25 08:01:05 +0000872
Bruce Allane921eb12012-11-28 09:28:37 +0000873 /* Disable IPv6 extension header parsing because some malformed
Matthew Vickf6bd5572012-04-25 08:01:05 +0000874 * IPv6 headers can hang the Rx.
875 */
876 reg = er32(RFCTL);
877 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
878 ew32(RFCTL, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700879}
880
881/**
882 * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
883 * @hw: pointer to the HW structure
884 *
885 * Setup some GG82563 PHY registers for obtaining link
886 **/
887static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
888{
889 struct e1000_phy_info *phy = &hw->phy;
890 s32 ret_val;
Bruce Allan17e813e2013-02-20 04:06:01 +0000891 u32 reg;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800892 u16 data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700893
David Graham2d9498f2008-04-23 11:09:14 -0700894 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700895 if (ret_val)
896 return ret_val;
897
898 data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
899 /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
900 data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
901
David Graham2d9498f2008-04-23 11:09:14 -0700902 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700903 if (ret_val)
904 return ret_val;
905
Bruce Allane921eb12012-11-28 09:28:37 +0000906 /* Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700907 * MDI/MDI-X = 0 (default)
908 * 0 - Auto for all speeds
909 * 1 - MDI mode
910 * 2 - MDI-X mode
911 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
912 */
913 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
914 if (ret_val)
915 return ret_val;
916
917 data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
918
919 switch (phy->mdix) {
920 case 1:
921 data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
922 break;
923 case 2:
924 data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
925 break;
926 case 0:
927 default:
928 data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
929 break;
930 }
931
Bruce Allane921eb12012-11-28 09:28:37 +0000932 /* Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700933 * disable_polarity_correction = 0 (default)
934 * Automatic Correction for Reversed Cable Polarity
935 * 0 - Disabled
936 * 1 - Enabled
937 */
938 data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
939 if (phy->disable_polarity_correction)
940 data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
941
942 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
943 if (ret_val)
944 return ret_val;
945
946 /* SW Reset the PHY so all changes take effect */
Bruce Allan6b598e12013-01-23 06:50:05 +0000947 ret_val = hw->phy.ops.commit(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700948 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000949 e_dbg("Error Resetting the PHY\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700950 return ret_val;
951 }
952
Bruce Allanad680762008-03-28 09:15:03 -0700953 /* Bypass Rx and Tx FIFO's */
Bruce Allan17e813e2013-02-20 04:06:01 +0000954 reg = E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL;
955 data = (E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
956 E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
957 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700958 if (ret_val)
959 return ret_val;
960
Bruce Allan17e813e2013-02-20 04:06:01 +0000961 reg = E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE;
962 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, reg, &data);
David Graham2d9498f2008-04-23 11:09:14 -0700963 if (ret_val)
964 return ret_val;
965 data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
Bruce Allan17e813e2013-02-20 04:06:01 +0000966 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
David Graham2d9498f2008-04-23 11:09:14 -0700967 if (ret_val)
968 return ret_val;
969
Auke Kokbc7f75f2007-09-17 12:30:59 -0700970 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
971 if (ret_val)
972 return ret_val;
973
974 data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
975 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
976 if (ret_val)
977 return ret_val;
978
Bruce Allan17e813e2013-02-20 04:06:01 +0000979 reg = er32(CTRL_EXT);
980 reg &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
981 ew32(CTRL_EXT, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700982
983 ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
984 if (ret_val)
985 return ret_val;
986
Bruce Allane921eb12012-11-28 09:28:37 +0000987 /* Do not init these registers when the HW is in IAMT mode, since the
Auke Kokbc7f75f2007-09-17 12:30:59 -0700988 * firmware will have already initialized them. We only initialize
989 * them if the HW is not in IAMT mode.
990 */
Bruce Allan48768322012-02-22 09:02:32 +0000991 if (!hw->mac.ops.check_mng_mode(hw)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700992 /* Enable Electrical Idle on the PHY */
993 data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
994 ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data);
995 if (ret_val)
996 return ret_val;
997
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800998 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data);
999 if (ret_val)
1000 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001001
1002 data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1003 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data);
1004 if (ret_val)
1005 return ret_val;
1006 }
1007
Bruce Allane921eb12012-11-28 09:28:37 +00001008 /* Workaround: Disable padding in Kumeran interface in the MAC
Auke Kokbc7f75f2007-09-17 12:30:59 -07001009 * and in the PHY to avoid CRC errors.
1010 */
1011 ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
1012 if (ret_val)
1013 return ret_val;
1014
1015 data |= GG82563_ICR_DIS_PADDING;
1016 ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
1017 if (ret_val)
1018 return ret_val;
1019
1020 return 0;
1021}
1022
1023/**
1024 * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
1025 * @hw: pointer to the HW structure
1026 *
1027 * Essentially a wrapper for setting up all things "copper" related.
1028 * This is a function pointer entry point called by the mac module.
1029 **/
1030static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
1031{
1032 u32 ctrl;
1033 s32 ret_val;
1034 u16 reg_data;
1035
1036 ctrl = er32(CTRL);
1037 ctrl |= E1000_CTRL_SLU;
1038 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1039 ew32(CTRL, ctrl);
1040
Bruce Allane921eb12012-11-28 09:28:37 +00001041 /* Set the mac to wait the maximum time between each
Auke Kokbc7f75f2007-09-17 12:30:59 -07001042 * iteration and increase the max iterations when
Bruce Allanad680762008-03-28 09:15:03 -07001043 * polling the phy; this fixes erroneous timeouts at 10Mbps.
1044 */
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001045 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
Bruce Allanf0ff4392013-02-20 04:05:39 +00001046 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001047 if (ret_val)
1048 return ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001049 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
Bruce Allanf0ff4392013-02-20 04:05:39 +00001050 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001051 if (ret_val)
1052 return ret_val;
1053 reg_data |= 0x3F;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001054 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
Bruce Allanf0ff4392013-02-20 04:05:39 +00001055 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001056 if (ret_val)
1057 return ret_val;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001058 ret_val =
1059 e1000_read_kmrn_reg_80003es2lan(hw,
1060 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1061 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001062 if (ret_val)
1063 return ret_val;
1064 reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001065 ret_val =
1066 e1000_write_kmrn_reg_80003es2lan(hw,
1067 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1068 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001069 if (ret_val)
1070 return ret_val;
1071
1072 ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);
1073 if (ret_val)
1074 return ret_val;
1075
Bruce Allan8649f432012-02-08 02:54:58 +00001076 return e1000e_setup_copper_link(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001077}
1078
1079/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001080 * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
1081 * @hw: pointer to the HW structure
1082 * @duplex: current duplex setting
1083 *
1084 * Configure the KMRN interface by applying last minute quirks for
1085 * 10/100 operation.
1086 **/
1087static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
1088{
1089 s32 ret_val = 0;
1090 u16 speed;
1091 u16 duplex;
1092
1093 if (hw->phy.media_type == e1000_media_type_copper) {
1094 ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed,
Bruce Allanf0ff4392013-02-20 04:05:39 +00001095 &duplex);
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001096 if (ret_val)
1097 return ret_val;
1098
1099 if (speed == SPEED_1000)
1100 ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw);
1101 else
1102 ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex);
1103 }
1104
1105 return ret_val;
1106}
1107
1108/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001109 * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
1110 * @hw: pointer to the HW structure
1111 * @duplex: current duplex setting
1112 *
1113 * Configure the KMRN interface by applying last minute quirks for
1114 * 10/100 operation.
1115 **/
1116static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
1117{
1118 s32 ret_val;
1119 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001120 u32 i = 0;
1121 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001122
1123 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001124 ret_val =
1125 e1000_write_kmrn_reg_80003es2lan(hw,
1126 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1127 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001128 if (ret_val)
1129 return ret_val;
1130
1131 /* Configure Transmit Inter-Packet Gap */
1132 tipg = er32(TIPG);
1133 tipg &= ~E1000_TIPG_IPGT_MASK;
1134 tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
1135 ew32(TIPG, tipg);
1136
David Graham2d9498f2008-04-23 11:09:14 -07001137 do {
1138 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1139 if (ret_val)
1140 return ret_val;
1141
1142 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1143 if (ret_val)
1144 return ret_val;
1145 i++;
1146 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001147
1148 if (duplex == HALF_DUPLEX)
1149 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
1150 else
1151 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1152
Bruce Allan520d6f22012-02-08 02:54:53 +00001153 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001154}
1155
1156/**
1157 * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
1158 * @hw: pointer to the HW structure
1159 *
1160 * Configure the KMRN interface by applying last minute quirks for
1161 * gigabit operation.
1162 **/
1163static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
1164{
1165 s32 ret_val;
David Graham2d9498f2008-04-23 11:09:14 -07001166 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001167 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001168 u32 i = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001169
1170 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001171 ret_val =
1172 e1000_write_kmrn_reg_80003es2lan(hw,
1173 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1174 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001175 if (ret_val)
1176 return ret_val;
1177
1178 /* Configure Transmit Inter-Packet Gap */
1179 tipg = er32(TIPG);
1180 tipg &= ~E1000_TIPG_IPGT_MASK;
1181 tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
1182 ew32(TIPG, tipg);
1183
David Graham2d9498f2008-04-23 11:09:14 -07001184 do {
1185 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1186 if (ret_val)
1187 return ret_val;
1188
1189 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1190 if (ret_val)
1191 return ret_val;
1192 i++;
1193 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001194
1195 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001196
Bruce Allan7eb61d82012-02-08 02:55:03 +00001197 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001198}
1199
1200/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001201 * e1000_read_kmrn_reg_80003es2lan - Read kumeran register
1202 * @hw: pointer to the HW structure
1203 * @offset: register offset to be read
1204 * @data: pointer to the read data
1205 *
1206 * Acquire semaphore, then read the PHY register at offset
1207 * using the kumeran interface. The information retrieved is stored in data.
1208 * Release the semaphore before exiting.
1209 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001210static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1211 u16 *data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001212{
1213 u32 kmrnctrlsta;
Bruce Allan70806a72013-01-05 05:08:37 +00001214 s32 ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001215
1216 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1217 if (ret_val)
1218 return ret_val;
1219
1220 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
Bruce Allanf0ff4392013-02-20 04:05:39 +00001221 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001222 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001223 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001224
1225 udelay(2);
1226
1227 kmrnctrlsta = er32(KMRNCTRLSTA);
1228 *data = (u16)kmrnctrlsta;
1229
1230 e1000_release_mac_csr_80003es2lan(hw);
1231
1232 return ret_val;
1233}
1234
1235/**
1236 * e1000_write_kmrn_reg_80003es2lan - Write kumeran register
1237 * @hw: pointer to the HW structure
1238 * @offset: register offset to write to
1239 * @data: data to write at register offset
1240 *
1241 * Acquire semaphore, then write the data to PHY register
1242 * at the offset using the kumeran interface. Release semaphore
1243 * before exiting.
1244 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001245static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1246 u16 data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001247{
1248 u32 kmrnctrlsta;
Bruce Allan70806a72013-01-05 05:08:37 +00001249 s32 ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001250
1251 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1252 if (ret_val)
1253 return ret_val;
1254
1255 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
Bruce Allanf0ff4392013-02-20 04:05:39 +00001256 E1000_KMRNCTRLSTA_OFFSET) | data;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001257 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001258 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001259
1260 udelay(2);
1261
1262 e1000_release_mac_csr_80003es2lan(hw);
1263
1264 return ret_val;
1265}
1266
1267/**
Bruce Allan608f8a02010-01-13 02:04:58 +00001268 * e1000_read_mac_addr_80003es2lan - Read device MAC address
1269 * @hw: pointer to the HW structure
1270 **/
1271static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
1272{
Bruce Allan70806a72013-01-05 05:08:37 +00001273 s32 ret_val;
Bruce Allan608f8a02010-01-13 02:04:58 +00001274
Bruce Allane921eb12012-11-28 09:28:37 +00001275 /* If there's an alternate MAC address place it in RAR0
Bruce Allan608f8a02010-01-13 02:04:58 +00001276 * so that it will override the Si installed default perm
1277 * address.
1278 */
1279 ret_val = e1000_check_alt_mac_addr_generic(hw);
1280 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001281 return ret_val;
Bruce Allan608f8a02010-01-13 02:04:58 +00001282
Bruce Allan5015e532012-02-08 02:55:56 +00001283 return e1000_read_mac_addr_generic(hw);
Bruce Allan608f8a02010-01-13 02:04:58 +00001284}
1285
1286/**
Bruce Allan17f208d2009-12-01 15:47:22 +00001287 * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down
1288 * @hw: pointer to the HW structure
1289 *
1290 * In the case of a PHY power down to save power, or to turn off link during a
1291 * driver unload, or wake on lan is not enabled, remove the link.
1292 **/
1293static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw)
1294{
1295 /* If the management interface is not enabled, then power down */
1296 if (!(hw->mac.ops.check_mng_mode(hw) ||
1297 hw->phy.ops.check_reset_block(hw)))
1298 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00001299}
1300
1301/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001302 * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
1303 * @hw: pointer to the HW structure
1304 *
1305 * Clears the hardware counters by reading the counter registers.
1306 **/
1307static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
1308{
Auke Kokbc7f75f2007-09-17 12:30:59 -07001309 e1000e_clear_hw_cntrs_base(hw);
1310
Bruce Allan99673d92009-11-20 23:27:21 +00001311 er32(PRC64);
1312 er32(PRC127);
1313 er32(PRC255);
1314 er32(PRC511);
1315 er32(PRC1023);
1316 er32(PRC1522);
1317 er32(PTC64);
1318 er32(PTC127);
1319 er32(PTC255);
1320 er32(PTC511);
1321 er32(PTC1023);
1322 er32(PTC1522);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001323
Bruce Allan99673d92009-11-20 23:27:21 +00001324 er32(ALGNERRC);
1325 er32(RXERRC);
1326 er32(TNCRS);
1327 er32(CEXTERR);
1328 er32(TSCTC);
1329 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001330
Bruce Allan99673d92009-11-20 23:27:21 +00001331 er32(MGTPRC);
1332 er32(MGTPDC);
1333 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001334
Bruce Allan99673d92009-11-20 23:27:21 +00001335 er32(IAC);
1336 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001337
Bruce Allan99673d92009-11-20 23:27:21 +00001338 er32(ICRXPTC);
1339 er32(ICRXATC);
1340 er32(ICTXPTC);
1341 er32(ICTXATC);
1342 er32(ICTXQEC);
1343 er32(ICTXQMTC);
1344 er32(ICRXDMTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001345}
1346
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001347static const struct e1000_mac_operations es2_mac_ops = {
Bruce Allan608f8a02010-01-13 02:04:58 +00001348 .read_mac_addr = e1000_read_mac_addr_80003es2lan,
Bruce Alland1964eb2012-02-22 09:02:21 +00001349 .id_led_init = e1000e_id_led_init_generic,
Bruce Allandbf80dc2011-04-16 00:34:40 +00001350 .blink_led = e1000e_blink_led_generic,
Bruce Allan4662e822008-08-26 18:37:06 -07001351 .check_mng_mode = e1000e_check_mng_mode_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001352 /* check_for_link dependent on media type */
1353 .cleanup_led = e1000e_cleanup_led_generic,
1354 .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan,
1355 .get_bus_info = e1000e_get_bus_info_pcie,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00001356 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001357 .get_link_up_info = e1000_get_link_up_info_80003es2lan,
1358 .led_on = e1000e_led_on_generic,
1359 .led_off = e1000e_led_off_generic,
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07001360 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Bruce Allancaaddaf2009-12-01 15:46:43 +00001361 .write_vfta = e1000_write_vfta_generic,
1362 .clear_vfta = e1000_clear_vfta_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001363 .reset_hw = e1000_reset_hw_80003es2lan,
1364 .init_hw = e1000_init_hw_80003es2lan,
Bruce Allan1a46b402012-02-22 09:02:26 +00001365 .setup_link = e1000e_setup_link_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001366 /* setup_physical_interface dependent on media type */
Bruce Allana4f58f52009-06-02 11:29:18 +00001367 .setup_led = e1000e_setup_led_generic,
Bruce Allan57cde762012-02-22 09:02:58 +00001368 .config_collision_dist = e1000e_config_collision_dist_generic,
Bruce Allan69e1e012012-04-14 03:28:50 +00001369 .rar_set = e1000e_rar_set_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001370};
1371
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001372static const struct e1000_phy_operations es2_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001373 .acquire = e1000_acquire_phy_80003es2lan,
Bruce Allan94e5b652009-12-02 17:02:14 +00001374 .check_polarity = e1000_check_polarity_m88,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001375 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan55c5f552013-01-12 07:28:24 +00001376 .commit = e1000e_phy_sw_reset,
1377 .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan,
1378 .get_cfg_done = e1000_get_cfg_done_80003es2lan,
1379 .get_cable_length = e1000_get_cable_length_80003es2lan,
1380 .get_info = e1000e_get_phy_info_m88,
1381 .read_reg = e1000_read_phy_reg_gg82563_80003es2lan,
Bruce Allan94d81862009-11-20 23:25:26 +00001382 .release = e1000_release_phy_80003es2lan,
Bruce Allan55c5f552013-01-12 07:28:24 +00001383 .reset = e1000e_phy_hw_reset_generic,
1384 .set_d0_lplu_state = NULL,
1385 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
1386 .write_reg = e1000_write_phy_reg_gg82563_80003es2lan,
1387 .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001388};
1389
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001390static const struct e1000_nvm_operations es2_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001391 .acquire = e1000_acquire_nvm_80003es2lan,
1392 .read = e1000e_read_nvm_eerd,
1393 .release = e1000_release_nvm_80003es2lan,
Bruce Allane85e3632012-02-22 09:03:14 +00001394 .reload = e1000e_reload_nvm_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001395 .update = e1000e_update_nvm_checksum_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001396 .valid_led_default = e1000e_valid_led_default,
Bruce Allan94d81862009-11-20 23:25:26 +00001397 .validate = e1000e_validate_nvm_checksum_generic,
1398 .write = e1000_write_nvm_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001399};
1400
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001401const struct e1000_info e1000_es2_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001402 .mac = e1000_80003es2lan,
1403 .flags = FLAG_HAS_HW_VLAN_FILTER
1404 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07001405 | FLAG_HAS_WOL
1406 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07001407 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07001408 | FLAG_RX_NEEDS_RESTART /* errata */
1409 | FLAG_TARC_SET_BIT_ZERO /* errata */
1410 | FLAG_APME_CHECK_PORT_B
Bruce Allan6a92f732011-12-16 00:46:12 +00001411 | FLAG_DISABLE_FC_PAUSE_TIME, /* errata */
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00001412 .flags2 = FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001413 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00001414 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07001415 .get_variants = e1000_get_variants_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001416 .mac_ops = &es2_mac_ops,
1417 .phy_ops = &es2_phy_ops,
1418 .nvm_ops = &es2_nvm_ops,
1419};
1420