blob: 303aa8a73d8003b0bde8539a701c1a31d944ddd1 [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 Allanfc830b72013-02-20 04:06:11 +000041
Bruce Allaneb656d42009-12-01 15:47:02 +000042#define GG82563_CABLE_LENGTH_TABLE_SIZE \
43 ARRAY_SIZE(e1000_gg82563_cable_length_table)
Auke Kokbc7f75f2007-09-17 12:30:59 -070044
45static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
46static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
47static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
48static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
49static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
50static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
51static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
Bruce Allan1f96012d2013-01-05 03:06:54 +000052static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
53 u16 *data);
54static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
55 u16 data);
Bruce Allan17f208d2009-12-01 15:47:22 +000056static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -070057
58/**
59 * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
60 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -070061 **/
62static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw)
63{
64 struct e1000_phy_info *phy = &hw->phy;
65 s32 ret_val;
66
Jeff Kirsher318a94d2008-03-28 09:15:16 -070067 if (hw->phy.media_type != e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -070068 phy->type = e1000_phy_none;
69 return 0;
Bruce Allan17f208d2009-12-01 15:47:22 +000070 } else {
71 phy->ops.power_up = e1000_power_up_phy_copper;
72 phy->ops.power_down = e1000_power_down_phy_copper_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -070073 }
74
75 phy->addr = 1;
76 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
77 phy->reset_delay_us = 100;
78 phy->type = e1000_phy_gg82563;
79
80 /* This can only be done after all function pointers are setup. */
81 ret_val = e1000e_get_phy_id(hw);
82
83 /* Verify phy id */
84 if (phy->id != GG82563_E_PHY_ID)
85 return -E1000_ERR_PHY;
86
87 return ret_val;
88}
89
90/**
91 * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
92 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -070093 **/
94static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
95{
96 struct e1000_nvm_info *nvm = &hw->nvm;
97 u32 eecd = er32(EECD);
98 u16 size;
99
100 nvm->opcode_bits = 8;
101 nvm->delay_usec = 1;
102 switch (nvm->override) {
103 case e1000_nvm_override_spi_large:
104 nvm->page_size = 32;
105 nvm->address_bits = 16;
106 break;
107 case e1000_nvm_override_spi_small:
108 nvm->page_size = 8;
109 nvm->address_bits = 8;
110 break;
111 default:
112 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
113 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
114 break;
115 }
116
Bruce Allanad680762008-03-28 09:15:03 -0700117 nvm->type = e1000_nvm_eeprom_spi;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700118
119 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
Bruce Allanf0ff4392013-02-20 04:05:39 +0000120 E1000_EECD_SIZE_EX_SHIFT);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700121
Bruce Allane921eb12012-11-28 09:28:37 +0000122 /* Added to a constant, "size" becomes the left-shift value
Auke Kokbc7f75f2007-09-17 12:30:59 -0700123 * for setting word_size.
124 */
125 size += NVM_WORD_SIZE_BASE_SHIFT;
Jeff Kirsher8d7c2942008-04-02 13:48:07 -0700126
127 /* EEPROM access above 16k is unsupported */
128 if (size > 14)
129 size = 14;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700130 nvm->word_size = 1 << size;
131
132 return 0;
133}
134
135/**
136 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
137 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700138 **/
Bruce Allanec34c172012-02-01 10:53:05 +0000139static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700140{
Auke Kokbc7f75f2007-09-17 12:30:59 -0700141 struct e1000_mac_info *mac = &hw->mac;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700142
Bruce Allane68782e2012-01-31 06:37:43 +0000143 /* Set media type and media-dependent function pointers */
Bruce Allanec34c172012-02-01 10:53:05 +0000144 switch (hw->adapter->pdev->device) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700145 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700146 hw->phy.media_type = e1000_media_type_internal_serdes;
Bruce Allane68782e2012-01-31 06:37:43 +0000147 mac->ops.check_for_link = e1000e_check_for_serdes_link;
148 mac->ops.setup_physical_interface =
149 e1000e_setup_fiber_serdes_link;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700150 break;
151 default:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700152 hw->phy.media_type = e1000_media_type_copper;
Bruce Allane68782e2012-01-31 06:37:43 +0000153 mac->ops.check_for_link = e1000e_check_for_copper_link;
154 mac->ops.setup_physical_interface =
155 e1000_setup_copper_link_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700156 break;
157 }
158
159 /* Set mta register count */
160 mac->mta_reg_count = 128;
161 /* Set rar entry count */
162 mac->rar_entry_count = E1000_RAR_ENTRIES;
Bruce Allana65a4a02010-05-10 15:01:51 +0000163 /* FWSM register */
164 mac->has_fwsm = true;
165 /* ARC supported; valid only if manageability features are enabled. */
Bruce Allan04499ec2012-04-13 00:08:31 +0000166 mac->arc_subsystem_valid = !!(er32(FWSM) & E1000_FWSM_MODE_MASK);
Bruce Allanf464ba82010-01-07 16:31:35 +0000167 /* Adaptive IFS not supported */
168 mac->adaptive_ifs = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700169
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000170 /* set lan id for port to determine which phy lock to use */
171 hw->mac.ops.set_lan_id(hw);
172
Auke Kokbc7f75f2007-09-17 12:30:59 -0700173 return 0;
174}
175
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700176static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700177{
178 struct e1000_hw *hw = &adapter->hw;
179 s32 rc;
180
Bruce Allanec34c172012-02-01 10:53:05 +0000181 rc = e1000_init_mac_params_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700182 if (rc)
183 return rc;
184
185 rc = e1000_init_nvm_params_80003es2lan(hw);
186 if (rc)
187 return rc;
188
189 rc = e1000_init_phy_params_80003es2lan(hw);
190 if (rc)
191 return rc;
192
193 return 0;
194}
195
196/**
197 * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
198 * @hw: pointer to the HW structure
199 *
Bruce Allanfe401672009-11-20 23:26:05 +0000200 * A wrapper to acquire access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700201 **/
202static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw)
203{
204 u16 mask;
205
206 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700207 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
208}
209
210/**
211 * e1000_release_phy_80003es2lan - Release rights to access PHY
212 * @hw: pointer to the HW structure
213 *
Bruce Allanfe401672009-11-20 23:26:05 +0000214 * A wrapper to release access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700215 **/
216static void e1000_release_phy_80003es2lan(struct e1000_hw *hw)
217{
218 u16 mask;
219
220 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800221 e1000_release_swfw_sync_80003es2lan(hw, mask);
222}
223
224/**
Bruce Allandffcdde2012-02-17 09:35:33 +0000225 * e1000_acquire_mac_csr_80003es2lan - Acquire right to access Kumeran register
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800226 * @hw: pointer to the HW structure
227 *
228 * Acquire the semaphore to access the Kumeran interface.
229 *
230 **/
231static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
232{
233 u16 mask;
234
235 mask = E1000_SWFW_CSR_SM;
236
237 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
238}
239
240/**
Bruce Allandffcdde2012-02-17 09:35:33 +0000241 * e1000_release_mac_csr_80003es2lan - Release right to access Kumeran Register
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800242 * @hw: pointer to the HW structure
243 *
244 * Release the semaphore used to access the Kumeran interface
245 **/
246static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw)
247{
248 u16 mask;
249
250 mask = E1000_SWFW_CSR_SM;
David Graham2d9498f2008-04-23 11:09:14 -0700251
Auke Kokbc7f75f2007-09-17 12:30:59 -0700252 e1000_release_swfw_sync_80003es2lan(hw, mask);
253}
254
255/**
256 * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
257 * @hw: pointer to the HW structure
258 *
Bruce Allanfe401672009-11-20 23:26:05 +0000259 * Acquire the semaphore to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700260 **/
261static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw)
262{
263 s32 ret_val;
264
265 ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
266 if (ret_val)
267 return ret_val;
268
269 ret_val = e1000e_acquire_nvm(hw);
270
271 if (ret_val)
272 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
273
274 return ret_val;
275}
276
277/**
278 * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
279 * @hw: pointer to the HW structure
280 *
Bruce Allanfe401672009-11-20 23:26:05 +0000281 * Release the semaphore used to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700282 **/
283static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
284{
285 e1000e_release_nvm(hw);
286 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
287}
288
289/**
290 * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
291 * @hw: pointer to the HW structure
292 * @mask: specifies which semaphore to acquire
293 *
294 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
295 * will also specify which port we're acquiring the lock for.
296 **/
297static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
298{
299 u32 swfw_sync;
300 u32 swmask = mask;
301 u32 fwmask = mask << 16;
302 s32 i = 0;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800303 s32 timeout = 50;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700304
305 while (i < timeout) {
306 if (e1000e_get_hw_semaphore(hw))
307 return -E1000_ERR_SWFW_SYNC;
308
309 swfw_sync = er32(SW_FW_SYNC);
310 if (!(swfw_sync & (fwmask | swmask)))
311 break;
312
Bruce Allane921eb12012-11-28 09:28:37 +0000313 /* Firmware currently using resource (fwmask)
Bruce Allanad680762008-03-28 09:15:03 -0700314 * or other software thread using resource (swmask)
315 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700316 e1000e_put_hw_semaphore(hw);
317 mdelay(5);
318 i++;
319 }
320
321 if (i == timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000322 e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700323 return -E1000_ERR_SWFW_SYNC;
324 }
325
326 swfw_sync |= swmask;
327 ew32(SW_FW_SYNC, swfw_sync);
328
329 e1000e_put_hw_semaphore(hw);
330
331 return 0;
332}
333
334/**
335 * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
336 * @hw: pointer to the HW structure
337 * @mask: specifies which semaphore to acquire
338 *
339 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
340 * will also specify which port we're releasing the lock for.
341 **/
342static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
343{
344 u32 swfw_sync;
345
Bruce Allan184125a2010-12-11 05:53:37 +0000346 while (e1000e_get_hw_semaphore(hw) != 0)
347 ; /* Empty */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700348
349 swfw_sync = er32(SW_FW_SYNC);
350 swfw_sync &= ~mask;
351 ew32(SW_FW_SYNC, swfw_sync);
352
353 e1000e_put_hw_semaphore(hw);
354}
355
356/**
357 * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
358 * @hw: pointer to the HW structure
359 * @offset: offset of the register to read
360 * @data: pointer to the data returned from the operation
361 *
Bruce Allanfe401672009-11-20 23:26:05 +0000362 * Read the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700363 **/
364static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
365 u32 offset, u16 *data)
366{
367 s32 ret_val;
368 u32 page_select;
369 u16 temp;
370
David Graham2d9498f2008-04-23 11:09:14 -0700371 ret_val = e1000_acquire_phy_80003es2lan(hw);
372 if (ret_val)
373 return ret_val;
374
Auke Kokbc7f75f2007-09-17 12:30:59 -0700375 /* Select Configuration Page */
David Graham2d9498f2008-04-23 11:09:14 -0700376 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700377 page_select = GG82563_PHY_PAGE_SELECT;
David Graham2d9498f2008-04-23 11:09:14 -0700378 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000379 /* Use Alternative Page Select register to access
Auke Kokbc7f75f2007-09-17 12:30:59 -0700380 * registers 30 and 31
381 */
382 page_select = GG82563_PHY_PAGE_SELECT_ALT;
David Graham2d9498f2008-04-23 11:09:14 -0700383 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700384
385 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
David Graham2d9498f2008-04-23 11:09:14 -0700386 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
387 if (ret_val) {
388 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700389 return ret_val;
David Graham2d9498f2008-04-23 11:09:14 -0700390 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700391
Bruce Allanb4d8e212012-02-17 03:17:55 +0000392 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
Bruce Allane921eb12012-11-28 09:28:37 +0000393 /* The "ready" bit in the MDIC register may be incorrectly set
Bruce Allan3421eec2009-12-08 07:28:20 +0000394 * before the device has completed the "Page Select" MDI
395 * transaction. So we wait 200us after each MDI command...
396 */
397 udelay(200);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700398
Bruce Allan3421eec2009-12-08 07:28:20 +0000399 /* ...and verify the command was successful. */
400 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700401
Bruce Allan3421eec2009-12-08 07:28:20 +0000402 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
Bruce Allan3421eec2009-12-08 07:28:20 +0000403 e1000_release_phy_80003es2lan(hw);
Bruce Allan7eb61d82012-02-08 02:55:03 +0000404 return -E1000_ERR_PHY;
Bruce Allan3421eec2009-12-08 07:28:20 +0000405 }
406
407 udelay(200);
408
409 ret_val = e1000e_read_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000410 MAX_PHY_REG_ADDRESS & offset,
411 data);
Bruce Allan3421eec2009-12-08 07:28:20 +0000412
413 udelay(200);
414 } else {
415 ret_val = e1000e_read_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000416 MAX_PHY_REG_ADDRESS & offset,
417 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700418 }
419
David Graham2d9498f2008-04-23 11:09:14 -0700420 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700421
422 return ret_val;
423}
424
425/**
426 * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
427 * @hw: pointer to the HW structure
428 * @offset: offset of the register to read
429 * @data: value to write to the register
430 *
Bruce Allanfe401672009-11-20 23:26:05 +0000431 * Write to the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700432 **/
433static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
434 u32 offset, u16 data)
435{
436 s32 ret_val;
437 u32 page_select;
438 u16 temp;
439
David Graham2d9498f2008-04-23 11:09:14 -0700440 ret_val = e1000_acquire_phy_80003es2lan(hw);
441 if (ret_val)
442 return ret_val;
443
Auke Kokbc7f75f2007-09-17 12:30:59 -0700444 /* Select Configuration Page */
David Graham2d9498f2008-04-23 11:09:14 -0700445 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700446 page_select = GG82563_PHY_PAGE_SELECT;
David Graham2d9498f2008-04-23 11:09:14 -0700447 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000448 /* Use Alternative Page Select register to access
Auke Kokbc7f75f2007-09-17 12:30:59 -0700449 * registers 30 and 31
450 */
451 page_select = GG82563_PHY_PAGE_SELECT_ALT;
David Graham2d9498f2008-04-23 11:09:14 -0700452 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700453
454 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
David Graham2d9498f2008-04-23 11:09:14 -0700455 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
456 if (ret_val) {
457 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700458 return ret_val;
David Graham2d9498f2008-04-23 11:09:14 -0700459 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700460
Bruce Allanb4d8e212012-02-17 03:17:55 +0000461 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
Bruce Allane921eb12012-11-28 09:28:37 +0000462 /* The "ready" bit in the MDIC register may be incorrectly set
Bruce Allan3421eec2009-12-08 07:28:20 +0000463 * before the device has completed the "Page Select" MDI
464 * transaction. So we wait 200us after each MDI command...
465 */
466 udelay(200);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700467
Bruce Allan3421eec2009-12-08 07:28:20 +0000468 /* ...and verify the command was successful. */
469 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700470
Bruce Allan3421eec2009-12-08 07:28:20 +0000471 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
472 e1000_release_phy_80003es2lan(hw);
473 return -E1000_ERR_PHY;
474 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700475
Bruce Allan3421eec2009-12-08 07:28:20 +0000476 udelay(200);
477
478 ret_val = e1000e_write_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000479 MAX_PHY_REG_ADDRESS &
480 offset, data);
Bruce Allan3421eec2009-12-08 07:28:20 +0000481
482 udelay(200);
483 } else {
484 ret_val = e1000e_write_phy_reg_mdic(hw,
Bruce Allanf0ff4392013-02-20 04:05:39 +0000485 MAX_PHY_REG_ADDRESS &
486 offset, data);
David Graham2d9498f2008-04-23 11:09:14 -0700487 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700488
David Graham2d9498f2008-04-23 11:09:14 -0700489 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700490
491 return ret_val;
492}
493
494/**
495 * e1000_write_nvm_80003es2lan - Write to ESB2 NVM
496 * @hw: pointer to the HW structure
497 * @offset: offset of the register to read
498 * @words: number of words to write
499 * @data: buffer of data to write to the NVM
500 *
Bruce Allanfe401672009-11-20 23:26:05 +0000501 * Write "words" of data to the ESB2 NVM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700502 **/
503static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
504 u16 words, u16 *data)
505{
506 return e1000e_write_nvm_spi(hw, offset, words, data);
507}
508
509/**
510 * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
511 * @hw: pointer to the HW structure
512 *
513 * Wait a specific amount of time for manageability processes to complete.
514 * This is a function pointer entry point called by the phy module.
515 **/
516static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
517{
518 s32 timeout = PHY_CFG_TIMEOUT;
519 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
520
521 if (hw->bus.func == 1)
522 mask = E1000_NVM_CFG_DONE_PORT_1;
523
524 while (timeout) {
525 if (er32(EEMNGCTL) & mask)
526 break;
Bruce Allan1bba4382011-03-19 00:27:20 +0000527 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700528 timeout--;
529 }
530 if (!timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000531 e_dbg("MNG configuration cycle has not completed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700532 return -E1000_ERR_RESET;
533 }
534
535 return 0;
536}
537
538/**
539 * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
540 * @hw: pointer to the HW structure
541 *
542 * Force the speed and duplex settings onto the PHY. This is a
543 * function pointer entry point called by the phy module.
544 **/
545static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
546{
547 s32 ret_val;
548 u16 phy_data;
549 bool link;
550
Bruce Allane921eb12012-11-28 09:28:37 +0000551 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
Auke Kokbc7f75f2007-09-17 12:30:59 -0700552 * forced whenever speed and duplex are forced.
553 */
554 ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
555 if (ret_val)
556 return ret_val;
557
558 phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
559 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
560 if (ret_val)
561 return ret_val;
562
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000563 e_dbg("GG82563 PSCR: %X\n", phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700564
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000565 ret_val = e1e_rphy(hw, MII_BMCR, &phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700566 if (ret_val)
567 return ret_val;
568
569 e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
570
571 /* Reset the phy to commit changes. */
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000572 phy_data |= BMCR_RESET;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700573
Bruce Allanc2ade1a2013-01-16 08:54:35 +0000574 ret_val = e1e_wphy(hw, MII_BMCR, phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700575 if (ret_val)
576 return ret_val;
577
578 udelay(1);
579
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700580 if (hw->phy.autoneg_wait_to_complete) {
Bruce Allan434f1392011-12-16 00:46:54 +0000581 e_dbg("Waiting for forced speed/duplex link on GG82563 phy.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700582
583 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
Bruce Allan17e813e2013-02-20 04:06:01 +0000584 100000, &link);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700585 if (ret_val)
586 return ret_val;
587
588 if (!link) {
Bruce Allane921eb12012-11-28 09:28:37 +0000589 /* We didn't get link.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700590 * Reset the DSP and cross our fingers.
591 */
592 ret_val = e1000e_phy_reset_dsp(hw);
593 if (ret_val)
594 return ret_val;
595 }
596
597 /* Try once more */
598 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
Bruce Allan17e813e2013-02-20 04:06:01 +0000599 100000, &link);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700600 if (ret_val)
601 return ret_val;
602 }
603
604 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
605 if (ret_val)
606 return ret_val;
607
Bruce Allane921eb12012-11-28 09:28:37 +0000608 /* Resetting the phy means we need to verify the TX_CLK corresponds
Auke Kokbc7f75f2007-09-17 12:30:59 -0700609 * to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
610 */
611 phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
612 if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
613 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
614 else
615 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
616
Bruce Allane921eb12012-11-28 09:28:37 +0000617 /* In addition, we must re-enable CRS on Tx for both half and full
Auke Kokbc7f75f2007-09-17 12:30:59 -0700618 * duplex.
619 */
620 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
621 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
622
623 return ret_val;
624}
625
626/**
627 * e1000_get_cable_length_80003es2lan - Set approximate cable length
628 * @hw: pointer to the HW structure
629 *
630 * Find the approximate cable length as measured by the GG82563 PHY.
631 * This is a function pointer entry point called by the phy module.
632 **/
633static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
634{
635 struct e1000_phy_info *phy = &hw->phy;
Bruce Allan70806a72013-01-05 05:08:37 +0000636 s32 ret_val;
Bruce Allana708dd82009-11-20 23:28:37 +0000637 u16 phy_data, index;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700638
639 ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
640 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000641 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700642
643 index = phy_data & GG82563_DSPD_CABLE_LENGTH;
Bruce Allaneb656d42009-12-01 15:47:02 +0000644
Bruce Allan5015e532012-02-08 02:55:56 +0000645 if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5)
646 return -E1000_ERR_PHY;
Bruce Allaneb656d42009-12-01 15:47:02 +0000647
Auke Kokbc7f75f2007-09-17 12:30:59 -0700648 phy->min_cable_length = e1000_gg82563_cable_length_table[index];
Bruce Allaneb656d42009-12-01 15:47:02 +0000649 phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
Auke Kokbc7f75f2007-09-17 12:30:59 -0700650
651 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
652
Bruce Allan5015e532012-02-08 02:55:56 +0000653 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700654}
655
656/**
657 * e1000_get_link_up_info_80003es2lan - Report speed and duplex
658 * @hw: pointer to the HW structure
659 * @speed: pointer to speed buffer
660 * @duplex: pointer to duplex buffer
661 *
662 * Retrieve the current speed and duplex configuration.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700663 **/
664static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
665 u16 *duplex)
666{
667 s32 ret_val;
668
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700669 if (hw->phy.media_type == e1000_media_type_copper) {
Bruce Allan17e813e2013-02-20 04:06:01 +0000670 ret_val = e1000e_get_speed_and_duplex_copper(hw, speed, duplex);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800671 hw->phy.ops.cfg_on_link_up(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700672 } else {
673 ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
Bruce Allan17e813e2013-02-20 04:06:01 +0000674 speed,
675 duplex);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700676 }
677
678 return ret_val;
679}
680
681/**
682 * e1000_reset_hw_80003es2lan - Reset the ESB2 controller
683 * @hw: pointer to the HW structure
684 *
685 * Perform a global reset to the ESB2 controller.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700686 **/
687static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
688{
Bruce Allandd93f952011-01-06 14:29:48 +0000689 u32 ctrl;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700690 s32 ret_val;
Matthew Vick1c1093a2012-03-16 09:02:58 +0000691 u16 kum_reg_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700692
Bruce Allane921eb12012-11-28 09:28:37 +0000693 /* Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -0700694 * on the last TLP read/write transaction when MAC is reset.
695 */
696 ret_val = e1000e_disable_pcie_master(hw);
697 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000698 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700699
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000700 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700701 ew32(IMC, 0xffffffff);
702
703 ew32(RCTL, 0);
704 ew32(TCTL, E1000_TCTL_PSP);
705 e1e_flush();
706
Bruce Allan1bba4382011-03-19 00:27:20 +0000707 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700708
709 ctrl = er32(CTRL);
710
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800711 ret_val = e1000_acquire_phy_80003es2lan(hw);
Bruce Allan7dbbe5d2013-01-05 05:08:31 +0000712 if (ret_val)
713 return ret_val;
714
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000715 e_dbg("Issuing a global reset to MAC\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700716 ew32(CTRL, ctrl | E1000_CTRL_RST);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800717 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700718
Matthew Vick1c1093a2012-03-16 09:02:58 +0000719 /* Disable IBIST slave mode (far-end loopback) */
720 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
721 &kum_reg_data);
722 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
723 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
724 kum_reg_data);
725
Auke Kokbc7f75f2007-09-17 12:30:59 -0700726 ret_val = e1000e_get_auto_rd_done(hw);
727 if (ret_val)
728 /* We don't want to continue accessing MAC registers. */
729 return ret_val;
730
731 /* Clear any pending interrupt events. */
732 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +0000733 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700734
Bruce Allan7eb61d82012-02-08 02:55:03 +0000735 return e1000_check_alt_mac_addr_generic(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700736}
737
738/**
739 * e1000_init_hw_80003es2lan - Initialize the ESB2 controller
740 * @hw: pointer to the HW structure
741 *
742 * Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700743 **/
744static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
745{
746 struct e1000_mac_info *mac = &hw->mac;
747 u32 reg_data;
748 s32 ret_val;
Bruce Alland9b24132011-05-13 07:19:42 +0000749 u16 kum_reg_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700750 u16 i;
751
752 e1000_initialize_hw_bits_80003es2lan(hw);
753
754 /* Initialize identification LED */
Bruce Alland1964eb2012-02-22 09:02:21 +0000755 ret_val = mac->ops.id_led_init(hw);
Bruce Allan33550ce2013-02-20 04:06:16 +0000756 /* An error is not fatal and we should not stop init due to this */
Bruce Allande39b752009-11-20 23:27:59 +0000757 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000758 e_dbg("Error initializing identification LED\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700759
760 /* Disabling VLAN filtering */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000761 e_dbg("Initializing the IEEE VLAN\n");
Bruce Allancaaddaf2009-12-01 15:46:43 +0000762 mac->ops.clear_vfta(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700763
764 /* Setup the receive address. */
765 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
766
767 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000768 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700769 for (i = 0; i < mac->mta_reg_count; i++)
770 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
771
772 /* Setup link and flow control */
Bruce Allan1a46b402012-02-22 09:02:26 +0000773 ret_val = mac->ops.setup_link(hw);
Bruce Allan7dbbe5d2013-01-05 05:08:31 +0000774 if (ret_val)
775 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700776
Bruce Alland9b24132011-05-13 07:19:42 +0000777 /* Disable IBIST slave mode (far-end loopback) */
778 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
779 &kum_reg_data);
780 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
781 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
782 kum_reg_data);
783
Auke Kokbc7f75f2007-09-17 12:30:59 -0700784 /* Set the transmit descriptor write-back policy */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700785 reg_data = er32(TXDCTL(0));
Bruce Allanf0ff4392013-02-20 04:05:39 +0000786 reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
787 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700788 ew32(TXDCTL(0), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700789
790 /* ...for both queues. */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700791 reg_data = er32(TXDCTL(1));
Bruce Allanf0ff4392013-02-20 04:05:39 +0000792 reg_data = ((reg_data & ~E1000_TXDCTL_WTHRESH) |
793 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700794 ew32(TXDCTL(1), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700795
796 /* Enable retransmit on late collisions */
797 reg_data = er32(TCTL);
798 reg_data |= E1000_TCTL_RTLC;
799 ew32(TCTL, reg_data);
800
801 /* Configure Gigabit Carry Extend Padding */
802 reg_data = er32(TCTL_EXT);
803 reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
804 reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
805 ew32(TCTL_EXT, reg_data);
806
807 /* Configure Transmit Inter-Packet Gap */
808 reg_data = er32(TIPG);
809 reg_data &= ~E1000_TIPG_IPGT_MASK;
810 reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
811 ew32(TIPG, reg_data);
812
813 reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
814 reg_data &= ~0x00100000;
815 E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
816
Bruce Allan3421eec2009-12-08 07:28:20 +0000817 /* default to true to enable the MDIC W/A */
818 hw->dev_spec.e80003es2lan.mdic_wa_enable = true;
819
Bruce Allanf0ff4392013-02-20 04:05:39 +0000820 ret_val =
821 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET >>
822 E1000_KMRNCTRLSTA_OFFSET_SHIFT, &i);
Bruce Allan3421eec2009-12-08 07:28:20 +0000823 if (!ret_val) {
824 if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
Bruce Allan17e813e2013-02-20 04:06:01 +0000825 E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
Bruce Allan3421eec2009-12-08 07:28:20 +0000826 hw->dev_spec.e80003es2lan.mdic_wa_enable = false;
827 }
828
Bruce Allane921eb12012-11-28 09:28:37 +0000829 /* Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -0700830 * important that we do this after we have tried to establish link
831 * because the symbol error count will increment wildly if there
832 * is no link.
833 */
834 e1000_clear_hw_cntrs_80003es2lan(hw);
835
836 return ret_val;
837}
838
839/**
840 * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
841 * @hw: pointer to the HW structure
842 *
843 * Initializes required hardware-dependent bits needed for normal operation.
844 **/
845static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
846{
847 u32 reg;
848
849 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700850 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700851 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700852 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700853
854 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700855 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700856 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700857 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700858
859 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700860 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700861 reg &= ~(0xF << 27); /* 30:27 */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700862 if (hw->phy.media_type != e1000_media_type_copper)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700863 reg &= ~(1 << 20);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700864 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700865
866 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700867 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700868 if (er32(TCTL) & E1000_TCTL_MULR)
869 reg &= ~(1 << 28);
870 else
871 reg |= (1 << 28);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700872 ew32(TARC(1), reg);
Matthew Vickf6bd5572012-04-25 08:01:05 +0000873
Bruce Allane921eb12012-11-28 09:28:37 +0000874 /* Disable IPv6 extension header parsing because some malformed
Matthew Vickf6bd5572012-04-25 08:01:05 +0000875 * IPv6 headers can hang the Rx.
876 */
877 reg = er32(RFCTL);
878 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
879 ew32(RFCTL, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700880}
881
882/**
883 * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
884 * @hw: pointer to the HW structure
885 *
886 * Setup some GG82563 PHY registers for obtaining link
887 **/
888static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
889{
890 struct e1000_phy_info *phy = &hw->phy;
891 s32 ret_val;
Bruce Allan17e813e2013-02-20 04:06:01 +0000892 u32 reg;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800893 u16 data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700894
David Graham2d9498f2008-04-23 11:09:14 -0700895 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700896 if (ret_val)
897 return ret_val;
898
899 data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
900 /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
901 data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
902
David Graham2d9498f2008-04-23 11:09:14 -0700903 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700904 if (ret_val)
905 return ret_val;
906
Bruce Allane921eb12012-11-28 09:28:37 +0000907 /* Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700908 * MDI/MDI-X = 0 (default)
909 * 0 - Auto for all speeds
910 * 1 - MDI mode
911 * 2 - MDI-X mode
912 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
913 */
914 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
915 if (ret_val)
916 return ret_val;
917
918 data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
919
920 switch (phy->mdix) {
921 case 1:
922 data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
923 break;
924 case 2:
925 data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
926 break;
927 case 0:
928 default:
929 data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
930 break;
931 }
932
Bruce Allane921eb12012-11-28 09:28:37 +0000933 /* Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700934 * disable_polarity_correction = 0 (default)
935 * Automatic Correction for Reversed Cable Polarity
936 * 0 - Disabled
937 * 1 - Enabled
938 */
939 data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
940 if (phy->disable_polarity_correction)
941 data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
942
943 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
944 if (ret_val)
945 return ret_val;
946
947 /* SW Reset the PHY so all changes take effect */
Bruce Allan6b598e12013-01-23 06:50:05 +0000948 ret_val = hw->phy.ops.commit(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700949 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000950 e_dbg("Error Resetting the PHY\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700951 return ret_val;
952 }
953
Bruce Allanad680762008-03-28 09:15:03 -0700954 /* Bypass Rx and Tx FIFO's */
Bruce Allan17e813e2013-02-20 04:06:01 +0000955 reg = E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL;
956 data = (E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
957 E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
958 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700959 if (ret_val)
960 return ret_val;
961
Bruce Allan17e813e2013-02-20 04:06:01 +0000962 reg = E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE;
963 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, reg, &data);
David Graham2d9498f2008-04-23 11:09:14 -0700964 if (ret_val)
965 return ret_val;
966 data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
Bruce Allan17e813e2013-02-20 04:06:01 +0000967 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, reg, data);
David Graham2d9498f2008-04-23 11:09:14 -0700968 if (ret_val)
969 return ret_val;
970
Auke Kokbc7f75f2007-09-17 12:30:59 -0700971 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
972 if (ret_val)
973 return ret_val;
974
975 data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
976 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
977 if (ret_val)
978 return ret_val;
979
Bruce Allan17e813e2013-02-20 04:06:01 +0000980 reg = er32(CTRL_EXT);
981 reg &= ~E1000_CTRL_EXT_LINK_MODE_MASK;
982 ew32(CTRL_EXT, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700983
984 ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
985 if (ret_val)
986 return ret_val;
987
Bruce Allane921eb12012-11-28 09:28:37 +0000988 /* Do not init these registers when the HW is in IAMT mode, since the
Auke Kokbc7f75f2007-09-17 12:30:59 -0700989 * firmware will have already initialized them. We only initialize
990 * them if the HW is not in IAMT mode.
991 */
Bruce Allan48768322012-02-22 09:02:32 +0000992 if (!hw->mac.ops.check_mng_mode(hw)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700993 /* Enable Electrical Idle on the PHY */
994 data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
995 ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data);
996 if (ret_val)
997 return ret_val;
998
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800999 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data);
1000 if (ret_val)
1001 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001002
1003 data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1004 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data);
1005 if (ret_val)
1006 return ret_val;
1007 }
1008
Bruce Allane921eb12012-11-28 09:28:37 +00001009 /* Workaround: Disable padding in Kumeran interface in the MAC
Auke Kokbc7f75f2007-09-17 12:30:59 -07001010 * and in the PHY to avoid CRC errors.
1011 */
1012 ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
1013 if (ret_val)
1014 return ret_val;
1015
1016 data |= GG82563_ICR_DIS_PADDING;
1017 ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
1018 if (ret_val)
1019 return ret_val;
1020
1021 return 0;
1022}
1023
1024/**
1025 * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
1026 * @hw: pointer to the HW structure
1027 *
1028 * Essentially a wrapper for setting up all things "copper" related.
1029 * This is a function pointer entry point called by the mac module.
1030 **/
1031static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
1032{
1033 u32 ctrl;
1034 s32 ret_val;
1035 u16 reg_data;
1036
1037 ctrl = er32(CTRL);
1038 ctrl |= E1000_CTRL_SLU;
1039 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1040 ew32(CTRL, ctrl);
1041
Bruce Allane921eb12012-11-28 09:28:37 +00001042 /* Set the mac to wait the maximum time between each
Auke Kokbc7f75f2007-09-17 12:30:59 -07001043 * iteration and increase the max iterations when
Bruce Allanad680762008-03-28 09:15:03 -07001044 * polling the phy; this fixes erroneous timeouts at 10Mbps.
1045 */
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001046 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
Bruce Allanf0ff4392013-02-20 04:05:39 +00001047 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001048 if (ret_val)
1049 return ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001050 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
Bruce Allanf0ff4392013-02-20 04:05:39 +00001051 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001052 if (ret_val)
1053 return ret_val;
1054 reg_data |= 0x3F;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001055 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
Bruce Allanf0ff4392013-02-20 04:05:39 +00001056 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001057 if (ret_val)
1058 return ret_val;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001059 ret_val =
1060 e1000_read_kmrn_reg_80003es2lan(hw,
1061 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1062 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001063 if (ret_val)
1064 return ret_val;
1065 reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001066 ret_val =
1067 e1000_write_kmrn_reg_80003es2lan(hw,
1068 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1069 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001070 if (ret_val)
1071 return ret_val;
1072
1073 ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);
1074 if (ret_val)
1075 return ret_val;
1076
Bruce Allan8649f432012-02-08 02:54:58 +00001077 return e1000e_setup_copper_link(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001078}
1079
1080/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001081 * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
1082 * @hw: pointer to the HW structure
1083 * @duplex: current duplex setting
1084 *
1085 * Configure the KMRN interface by applying last minute quirks for
1086 * 10/100 operation.
1087 **/
1088static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
1089{
1090 s32 ret_val = 0;
1091 u16 speed;
1092 u16 duplex;
1093
1094 if (hw->phy.media_type == e1000_media_type_copper) {
1095 ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed,
Bruce Allanf0ff4392013-02-20 04:05:39 +00001096 &duplex);
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001097 if (ret_val)
1098 return ret_val;
1099
1100 if (speed == SPEED_1000)
1101 ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw);
1102 else
1103 ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex);
1104 }
1105
1106 return ret_val;
1107}
1108
1109/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001110 * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
1111 * @hw: pointer to the HW structure
1112 * @duplex: current duplex setting
1113 *
1114 * Configure the KMRN interface by applying last minute quirks for
1115 * 10/100 operation.
1116 **/
1117static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
1118{
1119 s32 ret_val;
1120 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001121 u32 i = 0;
1122 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001123
1124 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001125 ret_val =
1126 e1000_write_kmrn_reg_80003es2lan(hw,
1127 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1128 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001129 if (ret_val)
1130 return ret_val;
1131
1132 /* Configure Transmit Inter-Packet Gap */
1133 tipg = er32(TIPG);
1134 tipg &= ~E1000_TIPG_IPGT_MASK;
1135 tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
1136 ew32(TIPG, tipg);
1137
David Graham2d9498f2008-04-23 11:09:14 -07001138 do {
1139 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1140 if (ret_val)
1141 return ret_val;
1142
1143 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1144 if (ret_val)
1145 return ret_val;
1146 i++;
1147 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001148
1149 if (duplex == HALF_DUPLEX)
1150 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
1151 else
1152 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1153
Bruce Allan520d6f22012-02-08 02:54:53 +00001154 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001155}
1156
1157/**
1158 * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
1159 * @hw: pointer to the HW structure
1160 *
1161 * Configure the KMRN interface by applying last minute quirks for
1162 * gigabit operation.
1163 **/
1164static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
1165{
1166 s32 ret_val;
David Graham2d9498f2008-04-23 11:09:14 -07001167 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001168 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001169 u32 i = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001170
1171 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
Bruce Allanf0ff4392013-02-20 04:05:39 +00001172 ret_val =
1173 e1000_write_kmrn_reg_80003es2lan(hw,
1174 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1175 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001176 if (ret_val)
1177 return ret_val;
1178
1179 /* Configure Transmit Inter-Packet Gap */
1180 tipg = er32(TIPG);
1181 tipg &= ~E1000_TIPG_IPGT_MASK;
1182 tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
1183 ew32(TIPG, tipg);
1184
David Graham2d9498f2008-04-23 11:09:14 -07001185 do {
1186 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1187 if (ret_val)
1188 return ret_val;
1189
1190 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1191 if (ret_val)
1192 return ret_val;
1193 i++;
1194 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001195
1196 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001197
Bruce Allan7eb61d82012-02-08 02:55:03 +00001198 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001199}
1200
1201/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001202 * e1000_read_kmrn_reg_80003es2lan - Read kumeran register
1203 * @hw: pointer to the HW structure
1204 * @offset: register offset to be read
1205 * @data: pointer to the read data
1206 *
1207 * Acquire semaphore, then read the PHY register at offset
1208 * using the kumeran interface. The information retrieved is stored in data.
1209 * Release the semaphore before exiting.
1210 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001211static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1212 u16 *data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001213{
1214 u32 kmrnctrlsta;
Bruce Allan70806a72013-01-05 05:08:37 +00001215 s32 ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001216
1217 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1218 if (ret_val)
1219 return ret_val;
1220
1221 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
Bruce Allanf0ff4392013-02-20 04:05:39 +00001222 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001223 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001224 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001225
1226 udelay(2);
1227
1228 kmrnctrlsta = er32(KMRNCTRLSTA);
1229 *data = (u16)kmrnctrlsta;
1230
1231 e1000_release_mac_csr_80003es2lan(hw);
1232
1233 return ret_val;
1234}
1235
1236/**
1237 * e1000_write_kmrn_reg_80003es2lan - Write kumeran register
1238 * @hw: pointer to the HW structure
1239 * @offset: register offset to write to
1240 * @data: data to write at register offset
1241 *
1242 * Acquire semaphore, then write the data to PHY register
1243 * at the offset using the kumeran interface. Release semaphore
1244 * before exiting.
1245 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001246static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1247 u16 data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001248{
1249 u32 kmrnctrlsta;
Bruce Allan70806a72013-01-05 05:08:37 +00001250 s32 ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001251
1252 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1253 if (ret_val)
1254 return ret_val;
1255
1256 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
Bruce Allanf0ff4392013-02-20 04:05:39 +00001257 E1000_KMRNCTRLSTA_OFFSET) | data;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001258 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001259 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001260
1261 udelay(2);
1262
1263 e1000_release_mac_csr_80003es2lan(hw);
1264
1265 return ret_val;
1266}
1267
1268/**
Bruce Allan608f8a02010-01-13 02:04:58 +00001269 * e1000_read_mac_addr_80003es2lan - Read device MAC address
1270 * @hw: pointer to the HW structure
1271 **/
1272static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
1273{
Bruce Allan70806a72013-01-05 05:08:37 +00001274 s32 ret_val;
Bruce Allan608f8a02010-01-13 02:04:58 +00001275
Bruce Allane921eb12012-11-28 09:28:37 +00001276 /* If there's an alternate MAC address place it in RAR0
Bruce Allan608f8a02010-01-13 02:04:58 +00001277 * so that it will override the Si installed default perm
1278 * address.
1279 */
1280 ret_val = e1000_check_alt_mac_addr_generic(hw);
1281 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001282 return ret_val;
Bruce Allan608f8a02010-01-13 02:04:58 +00001283
Bruce Allan5015e532012-02-08 02:55:56 +00001284 return e1000_read_mac_addr_generic(hw);
Bruce Allan608f8a02010-01-13 02:04:58 +00001285}
1286
1287/**
Bruce Allan17f208d2009-12-01 15:47:22 +00001288 * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down
1289 * @hw: pointer to the HW structure
1290 *
1291 * In the case of a PHY power down to save power, or to turn off link during a
1292 * driver unload, or wake on lan is not enabled, remove the link.
1293 **/
1294static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw)
1295{
1296 /* If the management interface is not enabled, then power down */
1297 if (!(hw->mac.ops.check_mng_mode(hw) ||
1298 hw->phy.ops.check_reset_block(hw)))
1299 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00001300}
1301
1302/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001303 * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
1304 * @hw: pointer to the HW structure
1305 *
1306 * Clears the hardware counters by reading the counter registers.
1307 **/
1308static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
1309{
Auke Kokbc7f75f2007-09-17 12:30:59 -07001310 e1000e_clear_hw_cntrs_base(hw);
1311
Bruce Allan99673d92009-11-20 23:27:21 +00001312 er32(PRC64);
1313 er32(PRC127);
1314 er32(PRC255);
1315 er32(PRC511);
1316 er32(PRC1023);
1317 er32(PRC1522);
1318 er32(PTC64);
1319 er32(PTC127);
1320 er32(PTC255);
1321 er32(PTC511);
1322 er32(PTC1023);
1323 er32(PTC1522);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001324
Bruce Allan99673d92009-11-20 23:27:21 +00001325 er32(ALGNERRC);
1326 er32(RXERRC);
1327 er32(TNCRS);
1328 er32(CEXTERR);
1329 er32(TSCTC);
1330 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001331
Bruce Allan99673d92009-11-20 23:27:21 +00001332 er32(MGTPRC);
1333 er32(MGTPDC);
1334 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001335
Bruce Allan99673d92009-11-20 23:27:21 +00001336 er32(IAC);
1337 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001338
Bruce Allan99673d92009-11-20 23:27:21 +00001339 er32(ICRXPTC);
1340 er32(ICRXATC);
1341 er32(ICTXPTC);
1342 er32(ICTXATC);
1343 er32(ICTXQEC);
1344 er32(ICTXQMTC);
1345 er32(ICRXDMTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001346}
1347
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001348static const struct e1000_mac_operations es2_mac_ops = {
Bruce Allan608f8a02010-01-13 02:04:58 +00001349 .read_mac_addr = e1000_read_mac_addr_80003es2lan,
Bruce Alland1964eb2012-02-22 09:02:21 +00001350 .id_led_init = e1000e_id_led_init_generic,
Bruce Allandbf80dc2011-04-16 00:34:40 +00001351 .blink_led = e1000e_blink_led_generic,
Bruce Allan4662e822008-08-26 18:37:06 -07001352 .check_mng_mode = e1000e_check_mng_mode_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001353 /* check_for_link dependent on media type */
1354 .cleanup_led = e1000e_cleanup_led_generic,
1355 .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan,
1356 .get_bus_info = e1000e_get_bus_info_pcie,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00001357 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001358 .get_link_up_info = e1000_get_link_up_info_80003es2lan,
1359 .led_on = e1000e_led_on_generic,
1360 .led_off = e1000e_led_off_generic,
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07001361 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Bruce Allancaaddaf2009-12-01 15:46:43 +00001362 .write_vfta = e1000_write_vfta_generic,
1363 .clear_vfta = e1000_clear_vfta_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001364 .reset_hw = e1000_reset_hw_80003es2lan,
1365 .init_hw = e1000_init_hw_80003es2lan,
Bruce Allan1a46b402012-02-22 09:02:26 +00001366 .setup_link = e1000e_setup_link_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001367 /* setup_physical_interface dependent on media type */
Bruce Allana4f58f52009-06-02 11:29:18 +00001368 .setup_led = e1000e_setup_led_generic,
Bruce Allan57cde762012-02-22 09:02:58 +00001369 .config_collision_dist = e1000e_config_collision_dist_generic,
Bruce Allan69e1e012012-04-14 03:28:50 +00001370 .rar_set = e1000e_rar_set_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001371};
1372
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001373static const struct e1000_phy_operations es2_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001374 .acquire = e1000_acquire_phy_80003es2lan,
Bruce Allan94e5b652009-12-02 17:02:14 +00001375 .check_polarity = e1000_check_polarity_m88,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001376 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan55c5f552013-01-12 07:28:24 +00001377 .commit = e1000e_phy_sw_reset,
1378 .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan,
1379 .get_cfg_done = e1000_get_cfg_done_80003es2lan,
1380 .get_cable_length = e1000_get_cable_length_80003es2lan,
1381 .get_info = e1000e_get_phy_info_m88,
1382 .read_reg = e1000_read_phy_reg_gg82563_80003es2lan,
Bruce Allan94d81862009-11-20 23:25:26 +00001383 .release = e1000_release_phy_80003es2lan,
Bruce Allan55c5f552013-01-12 07:28:24 +00001384 .reset = e1000e_phy_hw_reset_generic,
1385 .set_d0_lplu_state = NULL,
1386 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
1387 .write_reg = e1000_write_phy_reg_gg82563_80003es2lan,
1388 .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001389};
1390
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001391static const struct e1000_nvm_operations es2_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001392 .acquire = e1000_acquire_nvm_80003es2lan,
1393 .read = e1000e_read_nvm_eerd,
1394 .release = e1000_release_nvm_80003es2lan,
Bruce Allane85e3632012-02-22 09:03:14 +00001395 .reload = e1000e_reload_nvm_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001396 .update = e1000e_update_nvm_checksum_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001397 .valid_led_default = e1000e_valid_led_default,
Bruce Allan94d81862009-11-20 23:25:26 +00001398 .validate = e1000e_validate_nvm_checksum_generic,
1399 .write = e1000_write_nvm_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001400};
1401
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001402const struct e1000_info e1000_es2_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001403 .mac = e1000_80003es2lan,
1404 .flags = FLAG_HAS_HW_VLAN_FILTER
1405 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07001406 | FLAG_HAS_WOL
1407 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07001408 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07001409 | FLAG_RX_NEEDS_RESTART /* errata */
1410 | FLAG_TARC_SET_BIT_ZERO /* errata */
1411 | FLAG_APME_CHECK_PORT_B
Bruce Allan6a92f732011-12-16 00:46:12 +00001412 | FLAG_DISABLE_FC_PAUSE_TIME, /* errata */
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00001413 .flags2 = FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001414 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00001415 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07001416 .get_variants = e1000_get_variants_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001417 .mac_ops = &es2_mac_ops,
1418 .phy_ops = &es2_phy_ops,
1419 .nvm_ops = &es2_nvm_ops,
1420};