blob: a2b5b44cfe2b114de23e968abb886c528761b8bb [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
35#define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL 0x00
36#define E1000_KMRNCTRLSTA_OFFSET_INB_CTRL 0x02
37#define E1000_KMRNCTRLSTA_OFFSET_HD_CTRL 0x10
David Graham2d9498f2008-04-23 11:09:14 -070038#define E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE 0x1F
Auke Kokbc7f75f2007-09-17 12:30:59 -070039
40#define E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS 0x0008
41#define E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS 0x0800
42#define E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING 0x0010
43
44#define E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT 0x0004
45#define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT 0x0000
David Graham2d9498f2008-04-23 11:09:14 -070046#define E1000_KMRNCTRLSTA_OPMODE_E_IDLE 0x2000
Auke Kokbc7f75f2007-09-17 12:30:59 -070047
Bruce Allan3421eec2009-12-08 07:28:20 +000048#define E1000_KMRNCTRLSTA_OPMODE_MASK 0x000C
49#define E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO 0x0004
50
Auke Kokbc7f75f2007-09-17 12:30:59 -070051#define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00 /* Gigabit Carry Extend Padding */
52#define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN 0x00010000
53
54#define DEFAULT_TIPG_IPGT_1000_80003ES2LAN 0x8
55#define DEFAULT_TIPG_IPGT_10_100_80003ES2LAN 0x9
56
57/* GG82563 PHY Specific Status Register (Page 0, Register 16 */
58#define GG82563_PSCR_POLARITY_REVERSAL_DISABLE 0x0002 /* 1=Reversal Disab. */
59#define GG82563_PSCR_CROSSOVER_MODE_MASK 0x0060
60#define GG82563_PSCR_CROSSOVER_MODE_MDI 0x0000 /* 00=Manual MDI */
61#define GG82563_PSCR_CROSSOVER_MODE_MDIX 0x0020 /* 01=Manual MDIX */
62#define GG82563_PSCR_CROSSOVER_MODE_AUTO 0x0060 /* 11=Auto crossover */
63
64/* PHY Specific Control Register 2 (Page 0, Register 26) */
65#define GG82563_PSCR2_REVERSE_AUTO_NEG 0x2000
66 /* 1=Reverse Auto-Negotiation */
67
68/* MAC Specific Control Register (Page 2, Register 21) */
69/* Tx clock speed for Link Down and 1000BASE-T for the following speeds */
70#define GG82563_MSCR_TX_CLK_MASK 0x0007
71#define GG82563_MSCR_TX_CLK_10MBPS_2_5 0x0004
72#define GG82563_MSCR_TX_CLK_100MBPS_25 0x0005
73#define GG82563_MSCR_TX_CLK_1000MBPS_25 0x0007
74
75#define GG82563_MSCR_ASSERT_CRS_ON_TX 0x0010 /* 1=Assert */
76
77/* DSP Distance Register (Page 5, Register 26) */
78#define GG82563_DSPD_CABLE_LENGTH 0x0007 /* 0 = <50M
79 1 = 50-80M
80 2 = 80-110M
81 3 = 110-140M
Bruce Allane921eb12012-11-28 09:28:37 +000082 4 = >140M
83 */
Auke Kokbc7f75f2007-09-17 12:30:59 -070084
85/* Kumeran Mode Control Register (Page 193, Register 16) */
86#define GG82563_KMCR_PASS_FALSE_CARRIER 0x0800
87
David Graham2d9498f2008-04-23 11:09:14 -070088/* Max number of times Kumeran read/write should be validated */
89#define GG82563_MAX_KMRN_RETRY 0x5
90
Auke Kokbc7f75f2007-09-17 12:30:59 -070091/* Power Management Control Register (Page 193, Register 20) */
92#define GG82563_PMCR_ENABLE_ELECTRICAL_IDLE 0x0001
93 /* 1=Enable SERDES Electrical Idle */
94
95/* In-Band Control Register (Page 194, Register 18) */
96#define GG82563_ICR_DIS_PADDING 0x0010 /* Disable Padding */
97
Bruce Allane921eb12012-11-28 09:28:37 +000098/* A table for the GG82563 cable length where the range is defined
Auke Kokbc7f75f2007-09-17 12:30:59 -070099 * with a lower bound at "index" and the upper bound at
100 * "index + 5".
101 */
Bruce Allan64806412010-12-11 05:53:42 +0000102static const u16 e1000_gg82563_cable_length_table[] = {
103 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
Bruce Allaneb656d42009-12-01 15:47:02 +0000104#define GG82563_CABLE_LENGTH_TABLE_SIZE \
105 ARRAY_SIZE(e1000_gg82563_cable_length_table)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700106
107static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
108static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
109static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
110static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
111static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
112static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
113static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
Bruce Allan1f96012d2013-01-05 03:06:54 +0000114static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
115 u16 *data);
116static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
117 u16 data);
Bruce Allan17f208d2009-12-01 15:47:22 +0000118static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700119
120/**
121 * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
122 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700123 **/
124static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw)
125{
126 struct e1000_phy_info *phy = &hw->phy;
127 s32 ret_val;
128
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700129 if (hw->phy.media_type != e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700130 phy->type = e1000_phy_none;
131 return 0;
Bruce Allan17f208d2009-12-01 15:47:22 +0000132 } else {
133 phy->ops.power_up = e1000_power_up_phy_copper;
134 phy->ops.power_down = e1000_power_down_phy_copper_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700135 }
136
137 phy->addr = 1;
138 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
139 phy->reset_delay_us = 100;
140 phy->type = e1000_phy_gg82563;
141
142 /* This can only be done after all function pointers are setup. */
143 ret_val = e1000e_get_phy_id(hw);
144
145 /* Verify phy id */
146 if (phy->id != GG82563_E_PHY_ID)
147 return -E1000_ERR_PHY;
148
149 return ret_val;
150}
151
152/**
153 * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
154 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700155 **/
156static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
157{
158 struct e1000_nvm_info *nvm = &hw->nvm;
159 u32 eecd = er32(EECD);
160 u16 size;
161
162 nvm->opcode_bits = 8;
163 nvm->delay_usec = 1;
164 switch (nvm->override) {
165 case e1000_nvm_override_spi_large:
166 nvm->page_size = 32;
167 nvm->address_bits = 16;
168 break;
169 case e1000_nvm_override_spi_small:
170 nvm->page_size = 8;
171 nvm->address_bits = 8;
172 break;
173 default:
174 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
175 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
176 break;
177 }
178
Bruce Allanad680762008-03-28 09:15:03 -0700179 nvm->type = e1000_nvm_eeprom_spi;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700180
181 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
182 E1000_EECD_SIZE_EX_SHIFT);
183
Bruce Allane921eb12012-11-28 09:28:37 +0000184 /* Added to a constant, "size" becomes the left-shift value
Auke Kokbc7f75f2007-09-17 12:30:59 -0700185 * for setting word_size.
186 */
187 size += NVM_WORD_SIZE_BASE_SHIFT;
Jeff Kirsher8d7c2942008-04-02 13:48:07 -0700188
189 /* EEPROM access above 16k is unsupported */
190 if (size > 14)
191 size = 14;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700192 nvm->word_size = 1 << size;
193
194 return 0;
195}
196
197/**
198 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
199 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700200 **/
Bruce Allanec34c172012-02-01 10:53:05 +0000201static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700202{
Auke Kokbc7f75f2007-09-17 12:30:59 -0700203 struct e1000_mac_info *mac = &hw->mac;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700204
Bruce Allane68782e2012-01-31 06:37:43 +0000205 /* Set media type and media-dependent function pointers */
Bruce Allanec34c172012-02-01 10:53:05 +0000206 switch (hw->adapter->pdev->device) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700207 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700208 hw->phy.media_type = e1000_media_type_internal_serdes;
Bruce Allane68782e2012-01-31 06:37:43 +0000209 mac->ops.check_for_link = e1000e_check_for_serdes_link;
210 mac->ops.setup_physical_interface =
211 e1000e_setup_fiber_serdes_link;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700212 break;
213 default:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700214 hw->phy.media_type = e1000_media_type_copper;
Bruce Allane68782e2012-01-31 06:37:43 +0000215 mac->ops.check_for_link = e1000e_check_for_copper_link;
216 mac->ops.setup_physical_interface =
217 e1000_setup_copper_link_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700218 break;
219 }
220
221 /* Set mta register count */
222 mac->mta_reg_count = 128;
223 /* Set rar entry count */
224 mac->rar_entry_count = E1000_RAR_ENTRIES;
Bruce Allana65a4a02010-05-10 15:01:51 +0000225 /* FWSM register */
226 mac->has_fwsm = true;
227 /* ARC supported; valid only if manageability features are enabled. */
Bruce Allan04499ec2012-04-13 00:08:31 +0000228 mac->arc_subsystem_valid = !!(er32(FWSM) & E1000_FWSM_MODE_MASK);
Bruce Allanf464ba82010-01-07 16:31:35 +0000229 /* Adaptive IFS not supported */
230 mac->adaptive_ifs = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700231
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000232 /* set lan id for port to determine which phy lock to use */
233 hw->mac.ops.set_lan_id(hw);
234
Auke Kokbc7f75f2007-09-17 12:30:59 -0700235 return 0;
236}
237
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700238static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700239{
240 struct e1000_hw *hw = &adapter->hw;
241 s32 rc;
242
Bruce Allanec34c172012-02-01 10:53:05 +0000243 rc = e1000_init_mac_params_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700244 if (rc)
245 return rc;
246
247 rc = e1000_init_nvm_params_80003es2lan(hw);
248 if (rc)
249 return rc;
250
251 rc = e1000_init_phy_params_80003es2lan(hw);
252 if (rc)
253 return rc;
254
255 return 0;
256}
257
258/**
259 * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
260 * @hw: pointer to the HW structure
261 *
Bruce Allanfe401672009-11-20 23:26:05 +0000262 * A wrapper to acquire access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700263 **/
264static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw)
265{
266 u16 mask;
267
268 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700269 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
270}
271
272/**
273 * e1000_release_phy_80003es2lan - Release rights to access PHY
274 * @hw: pointer to the HW structure
275 *
Bruce Allanfe401672009-11-20 23:26:05 +0000276 * A wrapper to release access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700277 **/
278static void e1000_release_phy_80003es2lan(struct e1000_hw *hw)
279{
280 u16 mask;
281
282 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800283 e1000_release_swfw_sync_80003es2lan(hw, mask);
284}
285
286/**
Bruce Allandffcdde2012-02-17 09:35:33 +0000287 * e1000_acquire_mac_csr_80003es2lan - Acquire right to access Kumeran register
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800288 * @hw: pointer to the HW structure
289 *
290 * Acquire the semaphore to access the Kumeran interface.
291 *
292 **/
293static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
294{
295 u16 mask;
296
297 mask = E1000_SWFW_CSR_SM;
298
299 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
300}
301
302/**
Bruce Allandffcdde2012-02-17 09:35:33 +0000303 * e1000_release_mac_csr_80003es2lan - Release right to access Kumeran Register
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800304 * @hw: pointer to the HW structure
305 *
306 * Release the semaphore used to access the Kumeran interface
307 **/
308static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw)
309{
310 u16 mask;
311
312 mask = E1000_SWFW_CSR_SM;
David Graham2d9498f2008-04-23 11:09:14 -0700313
Auke Kokbc7f75f2007-09-17 12:30:59 -0700314 e1000_release_swfw_sync_80003es2lan(hw, mask);
315}
316
317/**
318 * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
319 * @hw: pointer to the HW structure
320 *
Bruce Allanfe401672009-11-20 23:26:05 +0000321 * Acquire the semaphore to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700322 **/
323static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw)
324{
325 s32 ret_val;
326
327 ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
328 if (ret_val)
329 return ret_val;
330
331 ret_val = e1000e_acquire_nvm(hw);
332
333 if (ret_val)
334 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
335
336 return ret_val;
337}
338
339/**
340 * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
341 * @hw: pointer to the HW structure
342 *
Bruce Allanfe401672009-11-20 23:26:05 +0000343 * Release the semaphore used to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700344 **/
345static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
346{
347 e1000e_release_nvm(hw);
348 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
349}
350
351/**
352 * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
353 * @hw: pointer to the HW structure
354 * @mask: specifies which semaphore to acquire
355 *
356 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
357 * will also specify which port we're acquiring the lock for.
358 **/
359static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
360{
361 u32 swfw_sync;
362 u32 swmask = mask;
363 u32 fwmask = mask << 16;
364 s32 i = 0;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800365 s32 timeout = 50;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700366
367 while (i < timeout) {
368 if (e1000e_get_hw_semaphore(hw))
369 return -E1000_ERR_SWFW_SYNC;
370
371 swfw_sync = er32(SW_FW_SYNC);
372 if (!(swfw_sync & (fwmask | swmask)))
373 break;
374
Bruce Allane921eb12012-11-28 09:28:37 +0000375 /* Firmware currently using resource (fwmask)
Bruce Allanad680762008-03-28 09:15:03 -0700376 * or other software thread using resource (swmask)
377 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700378 e1000e_put_hw_semaphore(hw);
379 mdelay(5);
380 i++;
381 }
382
383 if (i == timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000384 e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700385 return -E1000_ERR_SWFW_SYNC;
386 }
387
388 swfw_sync |= swmask;
389 ew32(SW_FW_SYNC, swfw_sync);
390
391 e1000e_put_hw_semaphore(hw);
392
393 return 0;
394}
395
396/**
397 * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
398 * @hw: pointer to the HW structure
399 * @mask: specifies which semaphore to acquire
400 *
401 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
402 * will also specify which port we're releasing the lock for.
403 **/
404static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
405{
406 u32 swfw_sync;
407
Bruce Allan184125a2010-12-11 05:53:37 +0000408 while (e1000e_get_hw_semaphore(hw) != 0)
409 ; /* Empty */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700410
411 swfw_sync = er32(SW_FW_SYNC);
412 swfw_sync &= ~mask;
413 ew32(SW_FW_SYNC, swfw_sync);
414
415 e1000e_put_hw_semaphore(hw);
416}
417
418/**
419 * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
420 * @hw: pointer to the HW structure
421 * @offset: offset of the register to read
422 * @data: pointer to the data returned from the operation
423 *
Bruce Allanfe401672009-11-20 23:26:05 +0000424 * Read the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700425 **/
426static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
427 u32 offset, u16 *data)
428{
429 s32 ret_val;
430 u32 page_select;
431 u16 temp;
432
David Graham2d9498f2008-04-23 11:09:14 -0700433 ret_val = e1000_acquire_phy_80003es2lan(hw);
434 if (ret_val)
435 return ret_val;
436
Auke Kokbc7f75f2007-09-17 12:30:59 -0700437 /* Select Configuration Page */
David Graham2d9498f2008-04-23 11:09:14 -0700438 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700439 page_select = GG82563_PHY_PAGE_SELECT;
David Graham2d9498f2008-04-23 11:09:14 -0700440 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000441 /* Use Alternative Page Select register to access
Auke Kokbc7f75f2007-09-17 12:30:59 -0700442 * registers 30 and 31
443 */
444 page_select = GG82563_PHY_PAGE_SELECT_ALT;
David Graham2d9498f2008-04-23 11:09:14 -0700445 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700446
447 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
David Graham2d9498f2008-04-23 11:09:14 -0700448 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
449 if (ret_val) {
450 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700451 return ret_val;
David Graham2d9498f2008-04-23 11:09:14 -0700452 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700453
Bruce Allanb4d8e212012-02-17 03:17:55 +0000454 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
Bruce Allane921eb12012-11-28 09:28:37 +0000455 /* The "ready" bit in the MDIC register may be incorrectly set
Bruce Allan3421eec2009-12-08 07:28:20 +0000456 * before the device has completed the "Page Select" MDI
457 * transaction. So we wait 200us after each MDI command...
458 */
459 udelay(200);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700460
Bruce Allan3421eec2009-12-08 07:28:20 +0000461 /* ...and verify the command was successful. */
462 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700463
Bruce Allan3421eec2009-12-08 07:28:20 +0000464 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
Bruce Allan3421eec2009-12-08 07:28:20 +0000465 e1000_release_phy_80003es2lan(hw);
Bruce Allan7eb61d82012-02-08 02:55:03 +0000466 return -E1000_ERR_PHY;
Bruce Allan3421eec2009-12-08 07:28:20 +0000467 }
468
469 udelay(200);
470
471 ret_val = e1000e_read_phy_reg_mdic(hw,
472 MAX_PHY_REG_ADDRESS & offset,
473 data);
474
475 udelay(200);
476 } else {
477 ret_val = e1000e_read_phy_reg_mdic(hw,
478 MAX_PHY_REG_ADDRESS & offset,
479 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700480 }
481
David Graham2d9498f2008-04-23 11:09:14 -0700482 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700483
484 return ret_val;
485}
486
487/**
488 * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
489 * @hw: pointer to the HW structure
490 * @offset: offset of the register to read
491 * @data: value to write to the register
492 *
Bruce Allanfe401672009-11-20 23:26:05 +0000493 * Write to the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700494 **/
495static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
496 u32 offset, u16 data)
497{
498 s32 ret_val;
499 u32 page_select;
500 u16 temp;
501
David Graham2d9498f2008-04-23 11:09:14 -0700502 ret_val = e1000_acquire_phy_80003es2lan(hw);
503 if (ret_val)
504 return ret_val;
505
Auke Kokbc7f75f2007-09-17 12:30:59 -0700506 /* Select Configuration Page */
David Graham2d9498f2008-04-23 11:09:14 -0700507 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700508 page_select = GG82563_PHY_PAGE_SELECT;
David Graham2d9498f2008-04-23 11:09:14 -0700509 } else {
Bruce Allane921eb12012-11-28 09:28:37 +0000510 /* Use Alternative Page Select register to access
Auke Kokbc7f75f2007-09-17 12:30:59 -0700511 * registers 30 and 31
512 */
513 page_select = GG82563_PHY_PAGE_SELECT_ALT;
David Graham2d9498f2008-04-23 11:09:14 -0700514 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700515
516 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
David Graham2d9498f2008-04-23 11:09:14 -0700517 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
518 if (ret_val) {
519 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700520 return ret_val;
David Graham2d9498f2008-04-23 11:09:14 -0700521 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700522
Bruce Allanb4d8e212012-02-17 03:17:55 +0000523 if (hw->dev_spec.e80003es2lan.mdic_wa_enable) {
Bruce Allane921eb12012-11-28 09:28:37 +0000524 /* The "ready" bit in the MDIC register may be incorrectly set
Bruce Allan3421eec2009-12-08 07:28:20 +0000525 * before the device has completed the "Page Select" MDI
526 * transaction. So we wait 200us after each MDI command...
527 */
528 udelay(200);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700529
Bruce Allan3421eec2009-12-08 07:28:20 +0000530 /* ...and verify the command was successful. */
531 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700532
Bruce Allan3421eec2009-12-08 07:28:20 +0000533 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
534 e1000_release_phy_80003es2lan(hw);
535 return -E1000_ERR_PHY;
536 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700537
Bruce Allan3421eec2009-12-08 07:28:20 +0000538 udelay(200);
539
540 ret_val = e1000e_write_phy_reg_mdic(hw,
541 MAX_PHY_REG_ADDRESS & offset,
542 data);
543
544 udelay(200);
545 } else {
546 ret_val = e1000e_write_phy_reg_mdic(hw,
547 MAX_PHY_REG_ADDRESS & offset,
548 data);
David Graham2d9498f2008-04-23 11:09:14 -0700549 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700550
David Graham2d9498f2008-04-23 11:09:14 -0700551 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700552
553 return ret_val;
554}
555
556/**
557 * e1000_write_nvm_80003es2lan - Write to ESB2 NVM
558 * @hw: pointer to the HW structure
559 * @offset: offset of the register to read
560 * @words: number of words to write
561 * @data: buffer of data to write to the NVM
562 *
Bruce Allanfe401672009-11-20 23:26:05 +0000563 * Write "words" of data to the ESB2 NVM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700564 **/
565static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
566 u16 words, u16 *data)
567{
568 return e1000e_write_nvm_spi(hw, offset, words, data);
569}
570
571/**
572 * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
573 * @hw: pointer to the HW structure
574 *
575 * Wait a specific amount of time for manageability processes to complete.
576 * This is a function pointer entry point called by the phy module.
577 **/
578static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
579{
580 s32 timeout = PHY_CFG_TIMEOUT;
581 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
582
583 if (hw->bus.func == 1)
584 mask = E1000_NVM_CFG_DONE_PORT_1;
585
586 while (timeout) {
587 if (er32(EEMNGCTL) & mask)
588 break;
Bruce Allan1bba4382011-03-19 00:27:20 +0000589 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700590 timeout--;
591 }
592 if (!timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000593 e_dbg("MNG configuration cycle has not completed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700594 return -E1000_ERR_RESET;
595 }
596
597 return 0;
598}
599
600/**
601 * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
602 * @hw: pointer to the HW structure
603 *
604 * Force the speed and duplex settings onto the PHY. This is a
605 * function pointer entry point called by the phy module.
606 **/
607static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
608{
609 s32 ret_val;
610 u16 phy_data;
611 bool link;
612
Bruce Allane921eb12012-11-28 09:28:37 +0000613 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
Auke Kokbc7f75f2007-09-17 12:30:59 -0700614 * forced whenever speed and duplex are forced.
615 */
616 ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
617 if (ret_val)
618 return ret_val;
619
620 phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
621 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
622 if (ret_val)
623 return ret_val;
624
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000625 e_dbg("GG82563 PSCR: %X\n", phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700626
627 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
628 if (ret_val)
629 return ret_val;
630
631 e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
632
633 /* Reset the phy to commit changes. */
634 phy_data |= MII_CR_RESET;
635
636 ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
637 if (ret_val)
638 return ret_val;
639
640 udelay(1);
641
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700642 if (hw->phy.autoneg_wait_to_complete) {
Bruce Allan434f1392011-12-16 00:46:54 +0000643 e_dbg("Waiting for forced speed/duplex link on GG82563 phy.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700644
645 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
646 100000, &link);
647 if (ret_val)
648 return ret_val;
649
650 if (!link) {
Bruce Allane921eb12012-11-28 09:28:37 +0000651 /* We didn't get link.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700652 * Reset the DSP and cross our fingers.
653 */
654 ret_val = e1000e_phy_reset_dsp(hw);
655 if (ret_val)
656 return ret_val;
657 }
658
659 /* Try once more */
660 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
661 100000, &link);
662 if (ret_val)
663 return ret_val;
664 }
665
666 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
667 if (ret_val)
668 return ret_val;
669
Bruce Allane921eb12012-11-28 09:28:37 +0000670 /* Resetting the phy means we need to verify the TX_CLK corresponds
Auke Kokbc7f75f2007-09-17 12:30:59 -0700671 * to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
672 */
673 phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
674 if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
675 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
676 else
677 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
678
Bruce Allane921eb12012-11-28 09:28:37 +0000679 /* In addition, we must re-enable CRS on Tx for both half and full
Auke Kokbc7f75f2007-09-17 12:30:59 -0700680 * duplex.
681 */
682 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
683 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
684
685 return ret_val;
686}
687
688/**
689 * e1000_get_cable_length_80003es2lan - Set approximate cable length
690 * @hw: pointer to the HW structure
691 *
692 * Find the approximate cable length as measured by the GG82563 PHY.
693 * This is a function pointer entry point called by the phy module.
694 **/
695static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
696{
697 struct e1000_phy_info *phy = &hw->phy;
Bruce Allaneb656d42009-12-01 15:47:02 +0000698 s32 ret_val = 0;
Bruce Allana708dd82009-11-20 23:28:37 +0000699 u16 phy_data, index;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700700
701 ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
702 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +0000703 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700704
705 index = phy_data & GG82563_DSPD_CABLE_LENGTH;
Bruce Allaneb656d42009-12-01 15:47:02 +0000706
Bruce Allan5015e532012-02-08 02:55:56 +0000707 if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5)
708 return -E1000_ERR_PHY;
Bruce Allaneb656d42009-12-01 15:47:02 +0000709
Auke Kokbc7f75f2007-09-17 12:30:59 -0700710 phy->min_cable_length = e1000_gg82563_cable_length_table[index];
Bruce Allaneb656d42009-12-01 15:47:02 +0000711 phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
Auke Kokbc7f75f2007-09-17 12:30:59 -0700712
713 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
714
Bruce Allan5015e532012-02-08 02:55:56 +0000715 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700716}
717
718/**
719 * e1000_get_link_up_info_80003es2lan - Report speed and duplex
720 * @hw: pointer to the HW structure
721 * @speed: pointer to speed buffer
722 * @duplex: pointer to duplex buffer
723 *
724 * Retrieve the current speed and duplex configuration.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700725 **/
726static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
727 u16 *duplex)
728{
729 s32 ret_val;
730
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700731 if (hw->phy.media_type == e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700732 ret_val = e1000e_get_speed_and_duplex_copper(hw,
733 speed,
734 duplex);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800735 hw->phy.ops.cfg_on_link_up(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700736 } else {
737 ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
738 speed,
739 duplex);
740 }
741
742 return ret_val;
743}
744
745/**
746 * e1000_reset_hw_80003es2lan - Reset the ESB2 controller
747 * @hw: pointer to the HW structure
748 *
749 * Perform a global reset to the ESB2 controller.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700750 **/
751static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
752{
Bruce Allandd93f952011-01-06 14:29:48 +0000753 u32 ctrl;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700754 s32 ret_val;
Matthew Vick1c1093a2012-03-16 09:02:58 +0000755 u16 kum_reg_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700756
Bruce Allane921eb12012-11-28 09:28:37 +0000757 /* Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -0700758 * on the last TLP read/write transaction when MAC is reset.
759 */
760 ret_val = e1000e_disable_pcie_master(hw);
761 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000762 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700763
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000764 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700765 ew32(IMC, 0xffffffff);
766
767 ew32(RCTL, 0);
768 ew32(TCTL, E1000_TCTL_PSP);
769 e1e_flush();
770
Bruce Allan1bba4382011-03-19 00:27:20 +0000771 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700772
773 ctrl = er32(CTRL);
774
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800775 ret_val = e1000_acquire_phy_80003es2lan(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000776 e_dbg("Issuing a global reset to MAC\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700777 ew32(CTRL, ctrl | E1000_CTRL_RST);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800778 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700779
Matthew Vick1c1093a2012-03-16 09:02:58 +0000780 /* Disable IBIST slave mode (far-end loopback) */
781 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
782 &kum_reg_data);
783 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
784 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
785 kum_reg_data);
786
Auke Kokbc7f75f2007-09-17 12:30:59 -0700787 ret_val = e1000e_get_auto_rd_done(hw);
788 if (ret_val)
789 /* We don't want to continue accessing MAC registers. */
790 return ret_val;
791
792 /* Clear any pending interrupt events. */
793 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +0000794 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700795
Bruce Allan7eb61d82012-02-08 02:55:03 +0000796 return e1000_check_alt_mac_addr_generic(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700797}
798
799/**
800 * e1000_init_hw_80003es2lan - Initialize the ESB2 controller
801 * @hw: pointer to the HW structure
802 *
803 * Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700804 **/
805static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
806{
807 struct e1000_mac_info *mac = &hw->mac;
808 u32 reg_data;
809 s32 ret_val;
Bruce Alland9b24132011-05-13 07:19:42 +0000810 u16 kum_reg_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700811 u16 i;
812
813 e1000_initialize_hw_bits_80003es2lan(hw);
814
815 /* Initialize identification LED */
Bruce Alland1964eb2012-02-22 09:02:21 +0000816 ret_val = mac->ops.id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +0000817 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000818 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +0000819 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700820
821 /* Disabling VLAN filtering */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000822 e_dbg("Initializing the IEEE VLAN\n");
Bruce Allancaaddaf2009-12-01 15:46:43 +0000823 mac->ops.clear_vfta(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700824
825 /* Setup the receive address. */
826 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
827
828 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000829 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700830 for (i = 0; i < mac->mta_reg_count; i++)
831 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
832
833 /* Setup link and flow control */
Bruce Allan1a46b402012-02-22 09:02:26 +0000834 ret_val = mac->ops.setup_link(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700835
Bruce Alland9b24132011-05-13 07:19:42 +0000836 /* Disable IBIST slave mode (far-end loopback) */
837 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
838 &kum_reg_data);
839 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
840 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
841 kum_reg_data);
842
Auke Kokbc7f75f2007-09-17 12:30:59 -0700843 /* Set the transmit descriptor write-back policy */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700844 reg_data = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700845 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
846 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700847 ew32(TXDCTL(0), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700848
849 /* ...for both queues. */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700850 reg_data = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700851 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
852 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700853 ew32(TXDCTL(1), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700854
855 /* Enable retransmit on late collisions */
856 reg_data = er32(TCTL);
857 reg_data |= E1000_TCTL_RTLC;
858 ew32(TCTL, reg_data);
859
860 /* Configure Gigabit Carry Extend Padding */
861 reg_data = er32(TCTL_EXT);
862 reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
863 reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
864 ew32(TCTL_EXT, reg_data);
865
866 /* Configure Transmit Inter-Packet Gap */
867 reg_data = er32(TIPG);
868 reg_data &= ~E1000_TIPG_IPGT_MASK;
869 reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
870 ew32(TIPG, reg_data);
871
872 reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
873 reg_data &= ~0x00100000;
874 E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
875
Bruce Allan3421eec2009-12-08 07:28:20 +0000876 /* default to true to enable the MDIC W/A */
877 hw->dev_spec.e80003es2lan.mdic_wa_enable = true;
878
879 ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
880 E1000_KMRNCTRLSTA_OFFSET >>
881 E1000_KMRNCTRLSTA_OFFSET_SHIFT,
882 &i);
883 if (!ret_val) {
884 if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
885 E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
886 hw->dev_spec.e80003es2lan.mdic_wa_enable = false;
887 }
888
Bruce Allane921eb12012-11-28 09:28:37 +0000889 /* Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -0700890 * important that we do this after we have tried to establish link
891 * because the symbol error count will increment wildly if there
892 * is no link.
893 */
894 e1000_clear_hw_cntrs_80003es2lan(hw);
895
896 return ret_val;
897}
898
899/**
900 * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
901 * @hw: pointer to the HW structure
902 *
903 * Initializes required hardware-dependent bits needed for normal operation.
904 **/
905static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
906{
907 u32 reg;
908
909 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700910 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700911 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700912 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700913
914 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700915 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700916 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700917 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700918
919 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700920 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700921 reg &= ~(0xF << 27); /* 30:27 */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700922 if (hw->phy.media_type != e1000_media_type_copper)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700923 reg &= ~(1 << 20);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700924 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700925
926 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700927 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700928 if (er32(TCTL) & E1000_TCTL_MULR)
929 reg &= ~(1 << 28);
930 else
931 reg |= (1 << 28);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700932 ew32(TARC(1), reg);
Matthew Vickf6bd5572012-04-25 08:01:05 +0000933
Bruce Allane921eb12012-11-28 09:28:37 +0000934 /* Disable IPv6 extension header parsing because some malformed
Matthew Vickf6bd5572012-04-25 08:01:05 +0000935 * IPv6 headers can hang the Rx.
936 */
937 reg = er32(RFCTL);
938 reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);
939 ew32(RFCTL, reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700940}
941
942/**
943 * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
944 * @hw: pointer to the HW structure
945 *
946 * Setup some GG82563 PHY registers for obtaining link
947 **/
948static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
949{
950 struct e1000_phy_info *phy = &hw->phy;
951 s32 ret_val;
952 u32 ctrl_ext;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800953 u16 data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700954
David Graham2d9498f2008-04-23 11:09:14 -0700955 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700956 if (ret_val)
957 return ret_val;
958
959 data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
960 /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
961 data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
962
David Graham2d9498f2008-04-23 11:09:14 -0700963 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700964 if (ret_val)
965 return ret_val;
966
Bruce Allane921eb12012-11-28 09:28:37 +0000967 /* Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700968 * MDI/MDI-X = 0 (default)
969 * 0 - Auto for all speeds
970 * 1 - MDI mode
971 * 2 - MDI-X mode
972 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
973 */
974 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
975 if (ret_val)
976 return ret_val;
977
978 data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
979
980 switch (phy->mdix) {
981 case 1:
982 data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
983 break;
984 case 2:
985 data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
986 break;
987 case 0:
988 default:
989 data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
990 break;
991 }
992
Bruce Allane921eb12012-11-28 09:28:37 +0000993 /* Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700994 * disable_polarity_correction = 0 (default)
995 * Automatic Correction for Reversed Cable Polarity
996 * 0 - Disabled
997 * 1 - Enabled
998 */
999 data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
1000 if (phy->disable_polarity_correction)
1001 data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
1002
1003 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
1004 if (ret_val)
1005 return ret_val;
1006
1007 /* SW Reset the PHY so all changes take effect */
1008 ret_val = e1000e_commit_phy(hw);
1009 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001010 e_dbg("Error Resetting the PHY\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001011 return ret_val;
1012 }
1013
Bruce Allanad680762008-03-28 09:15:03 -07001014 /* Bypass Rx and Tx FIFO's */
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001015 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1016 E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL,
Bruce Allanad680762008-03-28 09:15:03 -07001017 E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
Auke Kokbc7f75f2007-09-17 12:30:59 -07001018 E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
1019 if (ret_val)
1020 return ret_val;
1021
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001022 ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
David Graham2d9498f2008-04-23 11:09:14 -07001023 E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
1024 &data);
1025 if (ret_val)
1026 return ret_val;
1027 data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001028 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
David Graham2d9498f2008-04-23 11:09:14 -07001029 E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
1030 data);
1031 if (ret_val)
1032 return ret_val;
1033
Auke Kokbc7f75f2007-09-17 12:30:59 -07001034 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
1035 if (ret_val)
1036 return ret_val;
1037
1038 data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
1039 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
1040 if (ret_val)
1041 return ret_val;
1042
1043 ctrl_ext = er32(CTRL_EXT);
1044 ctrl_ext &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
1045 ew32(CTRL_EXT, ctrl_ext);
1046
1047 ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
1048 if (ret_val)
1049 return ret_val;
1050
Bruce Allane921eb12012-11-28 09:28:37 +00001051 /* Do not init these registers when the HW is in IAMT mode, since the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001052 * firmware will have already initialized them. We only initialize
1053 * them if the HW is not in IAMT mode.
1054 */
Bruce Allan48768322012-02-22 09:02:32 +00001055 if (!hw->mac.ops.check_mng_mode(hw)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001056 /* Enable Electrical Idle on the PHY */
1057 data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
1058 ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data);
1059 if (ret_val)
1060 return ret_val;
1061
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001062 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data);
1063 if (ret_val)
1064 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001065
1066 data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1067 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data);
1068 if (ret_val)
1069 return ret_val;
1070 }
1071
Bruce Allane921eb12012-11-28 09:28:37 +00001072 /* Workaround: Disable padding in Kumeran interface in the MAC
Auke Kokbc7f75f2007-09-17 12:30:59 -07001073 * and in the PHY to avoid CRC errors.
1074 */
1075 ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
1076 if (ret_val)
1077 return ret_val;
1078
1079 data |= GG82563_ICR_DIS_PADDING;
1080 ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
1081 if (ret_val)
1082 return ret_val;
1083
1084 return 0;
1085}
1086
1087/**
1088 * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
1089 * @hw: pointer to the HW structure
1090 *
1091 * Essentially a wrapper for setting up all things "copper" related.
1092 * This is a function pointer entry point called by the mac module.
1093 **/
1094static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
1095{
1096 u32 ctrl;
1097 s32 ret_val;
1098 u16 reg_data;
1099
1100 ctrl = er32(CTRL);
1101 ctrl |= E1000_CTRL_SLU;
1102 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1103 ew32(CTRL, ctrl);
1104
Bruce Allane921eb12012-11-28 09:28:37 +00001105 /* Set the mac to wait the maximum time between each
Auke Kokbc7f75f2007-09-17 12:30:59 -07001106 * iteration and increase the max iterations when
Bruce Allanad680762008-03-28 09:15:03 -07001107 * polling the phy; this fixes erroneous timeouts at 10Mbps.
1108 */
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001109 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
1110 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001111 if (ret_val)
1112 return ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001113 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1114 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001115 if (ret_val)
1116 return ret_val;
1117 reg_data |= 0x3F;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001118 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1119 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001120 if (ret_val)
1121 return ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001122 ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001123 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1124 &reg_data);
1125 if (ret_val)
1126 return ret_val;
1127 reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001128 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1129 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
Bruce Allanad680762008-03-28 09:15:03 -07001130 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001131 if (ret_val)
1132 return ret_val;
1133
1134 ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);
1135 if (ret_val)
1136 return ret_val;
1137
Bruce Allan8649f432012-02-08 02:54:58 +00001138 return e1000e_setup_copper_link(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001139}
1140
1141/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001142 * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
1143 * @hw: pointer to the HW structure
1144 * @duplex: current duplex setting
1145 *
1146 * Configure the KMRN interface by applying last minute quirks for
1147 * 10/100 operation.
1148 **/
1149static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
1150{
1151 s32 ret_val = 0;
1152 u16 speed;
1153 u16 duplex;
1154
1155 if (hw->phy.media_type == e1000_media_type_copper) {
1156 ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed,
1157 &duplex);
1158 if (ret_val)
1159 return ret_val;
1160
1161 if (speed == SPEED_1000)
1162 ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw);
1163 else
1164 ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex);
1165 }
1166
1167 return ret_val;
1168}
1169
1170/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001171 * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
1172 * @hw: pointer to the HW structure
1173 * @duplex: current duplex setting
1174 *
1175 * Configure the KMRN interface by applying last minute quirks for
1176 * 10/100 operation.
1177 **/
1178static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
1179{
1180 s32 ret_val;
1181 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001182 u32 i = 0;
1183 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001184
1185 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001186 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1187 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1188 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001189 if (ret_val)
1190 return ret_val;
1191
1192 /* Configure Transmit Inter-Packet Gap */
1193 tipg = er32(TIPG);
1194 tipg &= ~E1000_TIPG_IPGT_MASK;
1195 tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
1196 ew32(TIPG, tipg);
1197
David Graham2d9498f2008-04-23 11:09:14 -07001198 do {
1199 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1200 if (ret_val)
1201 return ret_val;
1202
1203 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1204 if (ret_val)
1205 return ret_val;
1206 i++;
1207 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001208
1209 if (duplex == HALF_DUPLEX)
1210 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
1211 else
1212 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1213
Bruce Allan520d6f22012-02-08 02:54:53 +00001214 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001215}
1216
1217/**
1218 * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
1219 * @hw: pointer to the HW structure
1220 *
1221 * Configure the KMRN interface by applying last minute quirks for
1222 * gigabit operation.
1223 **/
1224static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
1225{
1226 s32 ret_val;
David Graham2d9498f2008-04-23 11:09:14 -07001227 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001228 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001229 u32 i = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001230
1231 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001232 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1233 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1234 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001235 if (ret_val)
1236 return ret_val;
1237
1238 /* Configure Transmit Inter-Packet Gap */
1239 tipg = er32(TIPG);
1240 tipg &= ~E1000_TIPG_IPGT_MASK;
1241 tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
1242 ew32(TIPG, tipg);
1243
David Graham2d9498f2008-04-23 11:09:14 -07001244 do {
1245 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1246 if (ret_val)
1247 return ret_val;
1248
1249 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1250 if (ret_val)
1251 return ret_val;
1252 i++;
1253 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001254
1255 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001256
Bruce Allan7eb61d82012-02-08 02:55:03 +00001257 return e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001258}
1259
1260/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001261 * e1000_read_kmrn_reg_80003es2lan - Read kumeran register
1262 * @hw: pointer to the HW structure
1263 * @offset: register offset to be read
1264 * @data: pointer to the read data
1265 *
1266 * Acquire semaphore, then read the PHY register at offset
1267 * using the kumeran interface. The information retrieved is stored in data.
1268 * Release the semaphore before exiting.
1269 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001270static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1271 u16 *data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001272{
1273 u32 kmrnctrlsta;
1274 s32 ret_val = 0;
1275
1276 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1277 if (ret_val)
1278 return ret_val;
1279
1280 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1281 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
1282 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001283 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001284
1285 udelay(2);
1286
1287 kmrnctrlsta = er32(KMRNCTRLSTA);
1288 *data = (u16)kmrnctrlsta;
1289
1290 e1000_release_mac_csr_80003es2lan(hw);
1291
1292 return ret_val;
1293}
1294
1295/**
1296 * e1000_write_kmrn_reg_80003es2lan - Write kumeran register
1297 * @hw: pointer to the HW structure
1298 * @offset: register offset to write to
1299 * @data: data to write at register offset
1300 *
1301 * Acquire semaphore, then write the data to PHY register
1302 * at the offset using the kumeran interface. Release semaphore
1303 * before exiting.
1304 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001305static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1306 u16 data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001307{
1308 u32 kmrnctrlsta;
1309 s32 ret_val = 0;
1310
1311 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1312 if (ret_val)
1313 return ret_val;
1314
1315 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1316 E1000_KMRNCTRLSTA_OFFSET) | data;
1317 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001318 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001319
1320 udelay(2);
1321
1322 e1000_release_mac_csr_80003es2lan(hw);
1323
1324 return ret_val;
1325}
1326
1327/**
Bruce Allan608f8a02010-01-13 02:04:58 +00001328 * e1000_read_mac_addr_80003es2lan - Read device MAC address
1329 * @hw: pointer to the HW structure
1330 **/
1331static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
1332{
1333 s32 ret_val = 0;
1334
Bruce Allane921eb12012-11-28 09:28:37 +00001335 /* If there's an alternate MAC address place it in RAR0
Bruce Allan608f8a02010-01-13 02:04:58 +00001336 * so that it will override the Si installed default perm
1337 * address.
1338 */
1339 ret_val = e1000_check_alt_mac_addr_generic(hw);
1340 if (ret_val)
Bruce Allan5015e532012-02-08 02:55:56 +00001341 return ret_val;
Bruce Allan608f8a02010-01-13 02:04:58 +00001342
Bruce Allan5015e532012-02-08 02:55:56 +00001343 return e1000_read_mac_addr_generic(hw);
Bruce Allan608f8a02010-01-13 02:04:58 +00001344}
1345
1346/**
Bruce Allan17f208d2009-12-01 15:47:22 +00001347 * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down
1348 * @hw: pointer to the HW structure
1349 *
1350 * In the case of a PHY power down to save power, or to turn off link during a
1351 * driver unload, or wake on lan is not enabled, remove the link.
1352 **/
1353static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw)
1354{
1355 /* If the management interface is not enabled, then power down */
1356 if (!(hw->mac.ops.check_mng_mode(hw) ||
1357 hw->phy.ops.check_reset_block(hw)))
1358 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00001359}
1360
1361/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001362 * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
1363 * @hw: pointer to the HW structure
1364 *
1365 * Clears the hardware counters by reading the counter registers.
1366 **/
1367static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
1368{
Auke Kokbc7f75f2007-09-17 12:30:59 -07001369 e1000e_clear_hw_cntrs_base(hw);
1370
Bruce Allan99673d92009-11-20 23:27:21 +00001371 er32(PRC64);
1372 er32(PRC127);
1373 er32(PRC255);
1374 er32(PRC511);
1375 er32(PRC1023);
1376 er32(PRC1522);
1377 er32(PTC64);
1378 er32(PTC127);
1379 er32(PTC255);
1380 er32(PTC511);
1381 er32(PTC1023);
1382 er32(PTC1522);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001383
Bruce Allan99673d92009-11-20 23:27:21 +00001384 er32(ALGNERRC);
1385 er32(RXERRC);
1386 er32(TNCRS);
1387 er32(CEXTERR);
1388 er32(TSCTC);
1389 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001390
Bruce Allan99673d92009-11-20 23:27:21 +00001391 er32(MGTPRC);
1392 er32(MGTPDC);
1393 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001394
Bruce Allan99673d92009-11-20 23:27:21 +00001395 er32(IAC);
1396 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001397
Bruce Allan99673d92009-11-20 23:27:21 +00001398 er32(ICRXPTC);
1399 er32(ICRXATC);
1400 er32(ICTXPTC);
1401 er32(ICTXATC);
1402 er32(ICTXQEC);
1403 er32(ICTXQMTC);
1404 er32(ICRXDMTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001405}
1406
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001407static const struct e1000_mac_operations es2_mac_ops = {
Bruce Allan608f8a02010-01-13 02:04:58 +00001408 .read_mac_addr = e1000_read_mac_addr_80003es2lan,
Bruce Alland1964eb2012-02-22 09:02:21 +00001409 .id_led_init = e1000e_id_led_init_generic,
Bruce Allandbf80dc2011-04-16 00:34:40 +00001410 .blink_led = e1000e_blink_led_generic,
Bruce Allan4662e822008-08-26 18:37:06 -07001411 .check_mng_mode = e1000e_check_mng_mode_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001412 /* check_for_link dependent on media type */
1413 .cleanup_led = e1000e_cleanup_led_generic,
1414 .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan,
1415 .get_bus_info = e1000e_get_bus_info_pcie,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00001416 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001417 .get_link_up_info = e1000_get_link_up_info_80003es2lan,
1418 .led_on = e1000e_led_on_generic,
1419 .led_off = e1000e_led_off_generic,
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07001420 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Bruce Allancaaddaf2009-12-01 15:46:43 +00001421 .write_vfta = e1000_write_vfta_generic,
1422 .clear_vfta = e1000_clear_vfta_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001423 .reset_hw = e1000_reset_hw_80003es2lan,
1424 .init_hw = e1000_init_hw_80003es2lan,
Bruce Allan1a46b402012-02-22 09:02:26 +00001425 .setup_link = e1000e_setup_link_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001426 /* setup_physical_interface dependent on media type */
Bruce Allana4f58f52009-06-02 11:29:18 +00001427 .setup_led = e1000e_setup_led_generic,
Bruce Allan57cde762012-02-22 09:02:58 +00001428 .config_collision_dist = e1000e_config_collision_dist_generic,
Bruce Allan69e1e012012-04-14 03:28:50 +00001429 .rar_set = e1000e_rar_set_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001430};
1431
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001432static const struct e1000_phy_operations es2_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001433 .acquire = e1000_acquire_phy_80003es2lan,
Bruce Allan94e5b652009-12-02 17:02:14 +00001434 .check_polarity = e1000_check_polarity_m88,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001435 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001436 .commit = e1000e_phy_sw_reset,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001437 .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan,
1438 .get_cfg_done = e1000_get_cfg_done_80003es2lan,
1439 .get_cable_length = e1000_get_cable_length_80003es2lan,
Bruce Allan94d81862009-11-20 23:25:26 +00001440 .get_info = e1000e_get_phy_info_m88,
1441 .read_reg = e1000_read_phy_reg_gg82563_80003es2lan,
1442 .release = e1000_release_phy_80003es2lan,
1443 .reset = e1000e_phy_hw_reset_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001444 .set_d0_lplu_state = NULL,
1445 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001446 .write_reg = e1000_write_phy_reg_gg82563_80003es2lan,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001447 .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001448};
1449
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001450static const struct e1000_nvm_operations es2_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001451 .acquire = e1000_acquire_nvm_80003es2lan,
1452 .read = e1000e_read_nvm_eerd,
1453 .release = e1000_release_nvm_80003es2lan,
Bruce Allane85e3632012-02-22 09:03:14 +00001454 .reload = e1000e_reload_nvm_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001455 .update = e1000e_update_nvm_checksum_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001456 .valid_led_default = e1000e_valid_led_default,
Bruce Allan94d81862009-11-20 23:25:26 +00001457 .validate = e1000e_validate_nvm_checksum_generic,
1458 .write = e1000_write_nvm_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001459};
1460
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001461const struct e1000_info e1000_es2_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001462 .mac = e1000_80003es2lan,
1463 .flags = FLAG_HAS_HW_VLAN_FILTER
1464 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07001465 | FLAG_HAS_WOL
1466 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07001467 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07001468 | FLAG_RX_NEEDS_RESTART /* errata */
1469 | FLAG_TARC_SET_BIT_ZERO /* errata */
1470 | FLAG_APME_CHECK_PORT_B
Bruce Allan6a92f732011-12-16 00:46:12 +00001471 | FLAG_DISABLE_FC_PAUSE_TIME, /* errata */
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00001472 .flags2 = FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001473 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00001474 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07001475 .get_variants = e1000_get_variants_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001476 .mac_ops = &es2_mac_ops,
1477 .phy_ops = &es2_phy_ops,
1478 .nvm_ops = &es2_nvm_ops,
1479};
1480