blob: 9b969615b72a44ddee7e8487712541b544de1271 [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allanf5e261e2012-01-01 16:00:03 +00004 Copyright(c) 1999 - 2012 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
29/*
30 * 80003ES2LAN Gigabit Ethernet Controller (Copper)
31 * 80003ES2LAN Gigabit Ethernet Controller (Serdes)
32 */
33
Auke Kokbc7f75f2007-09-17 12:30:59 -070034#include "e1000.h"
35
36#define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL 0x00
37#define E1000_KMRNCTRLSTA_OFFSET_INB_CTRL 0x02
38#define E1000_KMRNCTRLSTA_OFFSET_HD_CTRL 0x10
David Graham2d9498f2008-04-23 11:09:14 -070039#define E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE 0x1F
Auke Kokbc7f75f2007-09-17 12:30:59 -070040
41#define E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS 0x0008
42#define E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS 0x0800
43#define E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING 0x0010
44
45#define E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT 0x0004
46#define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT 0x0000
David Graham2d9498f2008-04-23 11:09:14 -070047#define E1000_KMRNCTRLSTA_OPMODE_E_IDLE 0x2000
Auke Kokbc7f75f2007-09-17 12:30:59 -070048
Bruce Allan3421eec2009-12-08 07:28:20 +000049#define E1000_KMRNCTRLSTA_OPMODE_MASK 0x000C
50#define E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO 0x0004
51
Auke Kokbc7f75f2007-09-17 12:30:59 -070052#define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00 /* Gigabit Carry Extend Padding */
53#define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN 0x00010000
54
55#define DEFAULT_TIPG_IPGT_1000_80003ES2LAN 0x8
56#define DEFAULT_TIPG_IPGT_10_100_80003ES2LAN 0x9
57
58/* GG82563 PHY Specific Status Register (Page 0, Register 16 */
59#define GG82563_PSCR_POLARITY_REVERSAL_DISABLE 0x0002 /* 1=Reversal Disab. */
60#define GG82563_PSCR_CROSSOVER_MODE_MASK 0x0060
61#define GG82563_PSCR_CROSSOVER_MODE_MDI 0x0000 /* 00=Manual MDI */
62#define GG82563_PSCR_CROSSOVER_MODE_MDIX 0x0020 /* 01=Manual MDIX */
63#define GG82563_PSCR_CROSSOVER_MODE_AUTO 0x0060 /* 11=Auto crossover */
64
65/* PHY Specific Control Register 2 (Page 0, Register 26) */
66#define GG82563_PSCR2_REVERSE_AUTO_NEG 0x2000
67 /* 1=Reverse Auto-Negotiation */
68
69/* MAC Specific Control Register (Page 2, Register 21) */
70/* Tx clock speed for Link Down and 1000BASE-T for the following speeds */
71#define GG82563_MSCR_TX_CLK_MASK 0x0007
72#define GG82563_MSCR_TX_CLK_10MBPS_2_5 0x0004
73#define GG82563_MSCR_TX_CLK_100MBPS_25 0x0005
74#define GG82563_MSCR_TX_CLK_1000MBPS_25 0x0007
75
76#define GG82563_MSCR_ASSERT_CRS_ON_TX 0x0010 /* 1=Assert */
77
78/* DSP Distance Register (Page 5, Register 26) */
79#define GG82563_DSPD_CABLE_LENGTH 0x0007 /* 0 = <50M
80 1 = 50-80M
81 2 = 80-110M
82 3 = 110-140M
83 4 = >140M */
84
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 Allanad680762008-03-28 09:15:03 -070098/*
99 * A table for the GG82563 cable length where the range is defined
Auke Kokbc7f75f2007-09-17 12:30:59 -0700100 * with a lower bound at "index" and the upper bound at
101 * "index + 5".
102 */
Bruce Allan64806412010-12-11 05:53:42 +0000103static const u16 e1000_gg82563_cable_length_table[] = {
104 0, 60, 115, 150, 150, 60, 115, 150, 180, 180, 0xFF };
Bruce Allaneb656d42009-12-01 15:47:02 +0000105#define GG82563_CABLE_LENGTH_TABLE_SIZE \
106 ARRAY_SIZE(e1000_gg82563_cable_length_table)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700107
108static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw);
109static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
110static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask);
111static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);
112static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);
113static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);
114static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800115static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw);
116static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
117 u16 *data);
118static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
119 u16 data);
Bruce Allan17f208d2009-12-01 15:47:22 +0000120static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700121
122/**
123 * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs.
124 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700125 **/
126static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw)
127{
128 struct e1000_phy_info *phy = &hw->phy;
129 s32 ret_val;
130
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700131 if (hw->phy.media_type != e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700132 phy->type = e1000_phy_none;
133 return 0;
Bruce Allan17f208d2009-12-01 15:47:22 +0000134 } else {
135 phy->ops.power_up = e1000_power_up_phy_copper;
136 phy->ops.power_down = e1000_power_down_phy_copper_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700137 }
138
139 phy->addr = 1;
140 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
141 phy->reset_delay_us = 100;
142 phy->type = e1000_phy_gg82563;
143
144 /* This can only be done after all function pointers are setup. */
145 ret_val = e1000e_get_phy_id(hw);
146
147 /* Verify phy id */
148 if (phy->id != GG82563_E_PHY_ID)
149 return -E1000_ERR_PHY;
150
151 return ret_val;
152}
153
154/**
155 * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs.
156 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700157 **/
158static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
159{
160 struct e1000_nvm_info *nvm = &hw->nvm;
161 u32 eecd = er32(EECD);
162 u16 size;
163
164 nvm->opcode_bits = 8;
165 nvm->delay_usec = 1;
166 switch (nvm->override) {
167 case e1000_nvm_override_spi_large:
168 nvm->page_size = 32;
169 nvm->address_bits = 16;
170 break;
171 case e1000_nvm_override_spi_small:
172 nvm->page_size = 8;
173 nvm->address_bits = 8;
174 break;
175 default:
176 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
177 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
178 break;
179 }
180
Bruce Allanad680762008-03-28 09:15:03 -0700181 nvm->type = e1000_nvm_eeprom_spi;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700182
183 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
184 E1000_EECD_SIZE_EX_SHIFT);
185
Bruce Allanad680762008-03-28 09:15:03 -0700186 /*
187 * Added to a constant, "size" becomes the left-shift value
Auke Kokbc7f75f2007-09-17 12:30:59 -0700188 * for setting word_size.
189 */
190 size += NVM_WORD_SIZE_BASE_SHIFT;
Jeff Kirsher8d7c2942008-04-02 13:48:07 -0700191
192 /* EEPROM access above 16k is unsupported */
193 if (size > 14)
194 size = 14;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700195 nvm->word_size = 1 << size;
196
197 return 0;
198}
199
200/**
201 * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs.
202 * @hw: pointer to the HW structure
Auke Kokbc7f75f2007-09-17 12:30:59 -0700203 **/
204static s32 e1000_init_mac_params_80003es2lan(struct e1000_adapter *adapter)
205{
206 struct e1000_hw *hw = &adapter->hw;
207 struct e1000_mac_info *mac = &hw->mac;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700208
Bruce Allane68782e2012-01-31 06:37:43 +0000209 /* Set media type and media-dependent function pointers */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700210 switch (adapter->pdev->device) {
211 case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700212 hw->phy.media_type = e1000_media_type_internal_serdes;
Bruce Allane68782e2012-01-31 06:37:43 +0000213 mac->ops.check_for_link = e1000e_check_for_serdes_link;
214 mac->ops.setup_physical_interface =
215 e1000e_setup_fiber_serdes_link;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700216 break;
217 default:
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700218 hw->phy.media_type = e1000_media_type_copper;
Bruce Allane68782e2012-01-31 06:37:43 +0000219 mac->ops.check_for_link = e1000e_check_for_copper_link;
220 mac->ops.setup_physical_interface =
221 e1000_setup_copper_link_80003es2lan;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700222 break;
223 }
224
225 /* Set mta register count */
226 mac->mta_reg_count = 128;
227 /* Set rar entry count */
228 mac->rar_entry_count = E1000_RAR_ENTRIES;
Bruce Allana65a4a02010-05-10 15:01:51 +0000229 /* FWSM register */
230 mac->has_fwsm = true;
231 /* ARC supported; valid only if manageability features are enabled. */
232 mac->arc_subsystem_valid =
233 (er32(FWSM) & E1000_FWSM_MODE_MASK)
234 ? true : false;
Bruce Allanf464ba82010-01-07 16:31:35 +0000235 /* Adaptive IFS not supported */
236 mac->adaptive_ifs = false;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700237
Bruce Allanf4d2dd42010-01-13 02:05:18 +0000238 /* set lan id for port to determine which phy lock to use */
239 hw->mac.ops.set_lan_id(hw);
240
Auke Kokbc7f75f2007-09-17 12:30:59 -0700241 return 0;
242}
243
Jeff Kirsher69e3fd82008-04-02 13:48:18 -0700244static s32 e1000_get_variants_80003es2lan(struct e1000_adapter *adapter)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700245{
246 struct e1000_hw *hw = &adapter->hw;
247 s32 rc;
248
249 rc = e1000_init_mac_params_80003es2lan(adapter);
250 if (rc)
251 return rc;
252
253 rc = e1000_init_nvm_params_80003es2lan(hw);
254 if (rc)
255 return rc;
256
257 rc = e1000_init_phy_params_80003es2lan(hw);
258 if (rc)
259 return rc;
260
261 return 0;
262}
263
264/**
265 * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY
266 * @hw: pointer to the HW structure
267 *
Bruce Allanfe401672009-11-20 23:26:05 +0000268 * A wrapper to acquire access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700269 **/
270static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw)
271{
272 u16 mask;
273
274 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700275 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
276}
277
278/**
279 * e1000_release_phy_80003es2lan - Release rights to access PHY
280 * @hw: pointer to the HW structure
281 *
Bruce Allanfe401672009-11-20 23:26:05 +0000282 * A wrapper to release access rights to the correct PHY.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700283 **/
284static void e1000_release_phy_80003es2lan(struct e1000_hw *hw)
285{
286 u16 mask;
287
288 mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800289 e1000_release_swfw_sync_80003es2lan(hw, mask);
290}
291
292/**
293 * e1000_acquire_mac_csr_80003es2lan - Acquire rights to access Kumeran register
294 * @hw: pointer to the HW structure
295 *
296 * Acquire the semaphore to access the Kumeran interface.
297 *
298 **/
299static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw)
300{
301 u16 mask;
302
303 mask = E1000_SWFW_CSR_SM;
304
305 return e1000_acquire_swfw_sync_80003es2lan(hw, mask);
306}
307
308/**
309 * e1000_release_mac_csr_80003es2lan - Release rights to access Kumeran Register
310 * @hw: pointer to the HW structure
311 *
312 * Release the semaphore used to access the Kumeran interface
313 **/
314static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw)
315{
316 u16 mask;
317
318 mask = E1000_SWFW_CSR_SM;
David Graham2d9498f2008-04-23 11:09:14 -0700319
Auke Kokbc7f75f2007-09-17 12:30:59 -0700320 e1000_release_swfw_sync_80003es2lan(hw, mask);
321}
322
323/**
324 * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM
325 * @hw: pointer to the HW structure
326 *
Bruce Allanfe401672009-11-20 23:26:05 +0000327 * Acquire the semaphore to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700328 **/
329static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw)
330{
331 s32 ret_val;
332
333 ret_val = e1000_acquire_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
334 if (ret_val)
335 return ret_val;
336
337 ret_val = e1000e_acquire_nvm(hw);
338
339 if (ret_val)
340 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
341
342 return ret_val;
343}
344
345/**
346 * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM
347 * @hw: pointer to the HW structure
348 *
Bruce Allanfe401672009-11-20 23:26:05 +0000349 * Release the semaphore used to access the EEPROM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700350 **/
351static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw)
352{
353 e1000e_release_nvm(hw);
354 e1000_release_swfw_sync_80003es2lan(hw, E1000_SWFW_EEP_SM);
355}
356
357/**
358 * e1000_acquire_swfw_sync_80003es2lan - Acquire SW/FW semaphore
359 * @hw: pointer to the HW structure
360 * @mask: specifies which semaphore to acquire
361 *
362 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
363 * will also specify which port we're acquiring the lock for.
364 **/
365static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
366{
367 u32 swfw_sync;
368 u32 swmask = mask;
369 u32 fwmask = mask << 16;
370 s32 i = 0;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800371 s32 timeout = 50;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700372
373 while (i < timeout) {
374 if (e1000e_get_hw_semaphore(hw))
375 return -E1000_ERR_SWFW_SYNC;
376
377 swfw_sync = er32(SW_FW_SYNC);
378 if (!(swfw_sync & (fwmask | swmask)))
379 break;
380
Bruce Allanad680762008-03-28 09:15:03 -0700381 /*
382 * Firmware currently using resource (fwmask)
383 * or other software thread using resource (swmask)
384 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700385 e1000e_put_hw_semaphore(hw);
386 mdelay(5);
387 i++;
388 }
389
390 if (i == timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000391 e_dbg("Driver can't access resource, SW_FW_SYNC timeout.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700392 return -E1000_ERR_SWFW_SYNC;
393 }
394
395 swfw_sync |= swmask;
396 ew32(SW_FW_SYNC, swfw_sync);
397
398 e1000e_put_hw_semaphore(hw);
399
400 return 0;
401}
402
403/**
404 * e1000_release_swfw_sync_80003es2lan - Release SW/FW semaphore
405 * @hw: pointer to the HW structure
406 * @mask: specifies which semaphore to acquire
407 *
408 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
409 * will also specify which port we're releasing the lock for.
410 **/
411static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask)
412{
413 u32 swfw_sync;
414
Bruce Allan184125a2010-12-11 05:53:37 +0000415 while (e1000e_get_hw_semaphore(hw) != 0)
416 ; /* Empty */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700417
418 swfw_sync = er32(SW_FW_SYNC);
419 swfw_sync &= ~mask;
420 ew32(SW_FW_SYNC, swfw_sync);
421
422 e1000e_put_hw_semaphore(hw);
423}
424
425/**
426 * e1000_read_phy_reg_gg82563_80003es2lan - Read GG82563 PHY register
427 * @hw: pointer to the HW structure
428 * @offset: offset of the register to read
429 * @data: pointer to the data returned from the operation
430 *
Bruce Allanfe401672009-11-20 23:26:05 +0000431 * Read the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700432 **/
433static s32 e1000_read_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 Allanad680762008-03-28 09:15:03 -0700448 /*
449 * Use Alternative Page Select register to access
Auke Kokbc7f75f2007-09-17 12:30:59 -0700450 * registers 30 and 31
451 */
452 page_select = GG82563_PHY_PAGE_SELECT_ALT;
David Graham2d9498f2008-04-23 11:09:14 -0700453 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700454
455 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
David Graham2d9498f2008-04-23 11:09:14 -0700456 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
457 if (ret_val) {
458 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700459 return ret_val;
David Graham2d9498f2008-04-23 11:09:14 -0700460 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700461
Bruce Allan3421eec2009-12-08 07:28:20 +0000462 if (hw->dev_spec.e80003es2lan.mdic_wa_enable == true) {
463 /*
464 * The "ready" bit in the MDIC register may be incorrectly set
465 * before the device has completed the "Page Select" MDI
466 * transaction. So we wait 200us after each MDI command...
467 */
468 udelay(200);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700469
Bruce Allan3421eec2009-12-08 07:28:20 +0000470 /* ...and verify the command was successful. */
471 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700472
Bruce Allan3421eec2009-12-08 07:28:20 +0000473 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
474 ret_val = -E1000_ERR_PHY;
475 e1000_release_phy_80003es2lan(hw);
476 return ret_val;
477 }
478
479 udelay(200);
480
481 ret_val = e1000e_read_phy_reg_mdic(hw,
482 MAX_PHY_REG_ADDRESS & offset,
483 data);
484
485 udelay(200);
486 } else {
487 ret_val = e1000e_read_phy_reg_mdic(hw,
488 MAX_PHY_REG_ADDRESS & offset,
489 data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700490 }
491
David Graham2d9498f2008-04-23 11:09:14 -0700492 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700493
494 return ret_val;
495}
496
497/**
498 * e1000_write_phy_reg_gg82563_80003es2lan - Write GG82563 PHY register
499 * @hw: pointer to the HW structure
500 * @offset: offset of the register to read
501 * @data: value to write to the register
502 *
Bruce Allanfe401672009-11-20 23:26:05 +0000503 * Write to the GG82563 PHY register.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700504 **/
505static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw,
506 u32 offset, u16 data)
507{
508 s32 ret_val;
509 u32 page_select;
510 u16 temp;
511
David Graham2d9498f2008-04-23 11:09:14 -0700512 ret_val = e1000_acquire_phy_80003es2lan(hw);
513 if (ret_val)
514 return ret_val;
515
Auke Kokbc7f75f2007-09-17 12:30:59 -0700516 /* Select Configuration Page */
David Graham2d9498f2008-04-23 11:09:14 -0700517 if ((offset & MAX_PHY_REG_ADDRESS) < GG82563_MIN_ALT_REG) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700518 page_select = GG82563_PHY_PAGE_SELECT;
David Graham2d9498f2008-04-23 11:09:14 -0700519 } else {
Bruce Allanad680762008-03-28 09:15:03 -0700520 /*
521 * Use Alternative Page Select register to access
Auke Kokbc7f75f2007-09-17 12:30:59 -0700522 * registers 30 and 31
523 */
524 page_select = GG82563_PHY_PAGE_SELECT_ALT;
David Graham2d9498f2008-04-23 11:09:14 -0700525 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700526
527 temp = (u16)((u16)offset >> GG82563_PAGE_SHIFT);
David Graham2d9498f2008-04-23 11:09:14 -0700528 ret_val = e1000e_write_phy_reg_mdic(hw, page_select, temp);
529 if (ret_val) {
530 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700531 return ret_val;
David Graham2d9498f2008-04-23 11:09:14 -0700532 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700533
Bruce Allan3421eec2009-12-08 07:28:20 +0000534 if (hw->dev_spec.e80003es2lan.mdic_wa_enable == true) {
535 /*
536 * The "ready" bit in the MDIC register may be incorrectly set
537 * before the device has completed the "Page Select" MDI
538 * transaction. So we wait 200us after each MDI command...
539 */
540 udelay(200);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700541
Bruce Allan3421eec2009-12-08 07:28:20 +0000542 /* ...and verify the command was successful. */
543 ret_val = e1000e_read_phy_reg_mdic(hw, page_select, &temp);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700544
Bruce Allan3421eec2009-12-08 07:28:20 +0000545 if (((u16)offset >> GG82563_PAGE_SHIFT) != temp) {
546 e1000_release_phy_80003es2lan(hw);
547 return -E1000_ERR_PHY;
548 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700549
Bruce Allan3421eec2009-12-08 07:28:20 +0000550 udelay(200);
551
552 ret_val = e1000e_write_phy_reg_mdic(hw,
553 MAX_PHY_REG_ADDRESS & offset,
554 data);
555
556 udelay(200);
557 } else {
558 ret_val = e1000e_write_phy_reg_mdic(hw,
559 MAX_PHY_REG_ADDRESS & offset,
560 data);
David Graham2d9498f2008-04-23 11:09:14 -0700561 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700562
David Graham2d9498f2008-04-23 11:09:14 -0700563 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700564
565 return ret_val;
566}
567
568/**
569 * e1000_write_nvm_80003es2lan - Write to ESB2 NVM
570 * @hw: pointer to the HW structure
571 * @offset: offset of the register to read
572 * @words: number of words to write
573 * @data: buffer of data to write to the NVM
574 *
Bruce Allanfe401672009-11-20 23:26:05 +0000575 * Write "words" of data to the ESB2 NVM.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700576 **/
577static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset,
578 u16 words, u16 *data)
579{
580 return e1000e_write_nvm_spi(hw, offset, words, data);
581}
582
583/**
584 * e1000_get_cfg_done_80003es2lan - Wait for configuration to complete
585 * @hw: pointer to the HW structure
586 *
587 * Wait a specific amount of time for manageability processes to complete.
588 * This is a function pointer entry point called by the phy module.
589 **/
590static s32 e1000_get_cfg_done_80003es2lan(struct e1000_hw *hw)
591{
592 s32 timeout = PHY_CFG_TIMEOUT;
593 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
594
595 if (hw->bus.func == 1)
596 mask = E1000_NVM_CFG_DONE_PORT_1;
597
598 while (timeout) {
599 if (er32(EEMNGCTL) & mask)
600 break;
Bruce Allan1bba4382011-03-19 00:27:20 +0000601 usleep_range(1000, 2000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700602 timeout--;
603 }
604 if (!timeout) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000605 e_dbg("MNG configuration cycle has not completed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700606 return -E1000_ERR_RESET;
607 }
608
609 return 0;
610}
611
612/**
613 * e1000_phy_force_speed_duplex_80003es2lan - Force PHY speed and duplex
614 * @hw: pointer to the HW structure
615 *
616 * Force the speed and duplex settings onto the PHY. This is a
617 * function pointer entry point called by the phy module.
618 **/
619static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)
620{
621 s32 ret_val;
622 u16 phy_data;
623 bool link;
624
Bruce Allanad680762008-03-28 09:15:03 -0700625 /*
626 * Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI
Auke Kokbc7f75f2007-09-17 12:30:59 -0700627 * forced whenever speed and duplex are forced.
628 */
629 ret_val = e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
630 if (ret_val)
631 return ret_val;
632
633 phy_data &= ~GG82563_PSCR_CROSSOVER_MODE_AUTO;
634 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, phy_data);
635 if (ret_val)
636 return ret_val;
637
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000638 e_dbg("GG82563 PSCR: %X\n", phy_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700639
640 ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data);
641 if (ret_val)
642 return ret_val;
643
644 e1000e_phy_force_speed_duplex_setup(hw, &phy_data);
645
646 /* Reset the phy to commit changes. */
647 phy_data |= MII_CR_RESET;
648
649 ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data);
650 if (ret_val)
651 return ret_val;
652
653 udelay(1);
654
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700655 if (hw->phy.autoneg_wait_to_complete) {
Bruce Allan434f1392011-12-16 00:46:54 +0000656 e_dbg("Waiting for forced speed/duplex link on GG82563 phy.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700657
658 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
659 100000, &link);
660 if (ret_val)
661 return ret_val;
662
663 if (!link) {
Bruce Allanad680762008-03-28 09:15:03 -0700664 /*
665 * We didn't get link.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700666 * Reset the DSP and cross our fingers.
667 */
668 ret_val = e1000e_phy_reset_dsp(hw);
669 if (ret_val)
670 return ret_val;
671 }
672
673 /* Try once more */
674 ret_val = e1000e_phy_has_link_generic(hw, PHY_FORCE_LIMIT,
675 100000, &link);
676 if (ret_val)
677 return ret_val;
678 }
679
680 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &phy_data);
681 if (ret_val)
682 return ret_val;
683
Bruce Allanad680762008-03-28 09:15:03 -0700684 /*
685 * Resetting the phy means we need to verify the TX_CLK corresponds
Auke Kokbc7f75f2007-09-17 12:30:59 -0700686 * to the link speed. 10Mbps -> 2.5MHz, else 25MHz.
687 */
688 phy_data &= ~GG82563_MSCR_TX_CLK_MASK;
689 if (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED)
690 phy_data |= GG82563_MSCR_TX_CLK_10MBPS_2_5;
691 else
692 phy_data |= GG82563_MSCR_TX_CLK_100MBPS_25;
693
Bruce Allanad680762008-03-28 09:15:03 -0700694 /*
695 * In addition, we must re-enable CRS on Tx for both half and full
Auke Kokbc7f75f2007-09-17 12:30:59 -0700696 * duplex.
697 */
698 phy_data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
699 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, phy_data);
700
701 return ret_val;
702}
703
704/**
705 * e1000_get_cable_length_80003es2lan - Set approximate cable length
706 * @hw: pointer to the HW structure
707 *
708 * Find the approximate cable length as measured by the GG82563 PHY.
709 * This is a function pointer entry point called by the phy module.
710 **/
711static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)
712{
713 struct e1000_phy_info *phy = &hw->phy;
Bruce Allaneb656d42009-12-01 15:47:02 +0000714 s32 ret_val = 0;
Bruce Allana708dd82009-11-20 23:28:37 +0000715 u16 phy_data, index;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700716
717 ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data);
718 if (ret_val)
Bruce Allaneb656d42009-12-01 15:47:02 +0000719 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700720
721 index = phy_data & GG82563_DSPD_CABLE_LENGTH;
Bruce Allaneb656d42009-12-01 15:47:02 +0000722
723 if (index >= GG82563_CABLE_LENGTH_TABLE_SIZE - 5) {
724 ret_val = -E1000_ERR_PHY;
725 goto out;
726 }
727
Auke Kokbc7f75f2007-09-17 12:30:59 -0700728 phy->min_cable_length = e1000_gg82563_cable_length_table[index];
Bruce Allaneb656d42009-12-01 15:47:02 +0000729 phy->max_cable_length = e1000_gg82563_cable_length_table[index + 5];
Auke Kokbc7f75f2007-09-17 12:30:59 -0700730
731 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
732
Bruce Allaneb656d42009-12-01 15:47:02 +0000733out:
734 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700735}
736
737/**
738 * e1000_get_link_up_info_80003es2lan - Report speed and duplex
739 * @hw: pointer to the HW structure
740 * @speed: pointer to speed buffer
741 * @duplex: pointer to duplex buffer
742 *
743 * Retrieve the current speed and duplex configuration.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700744 **/
745static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed,
746 u16 *duplex)
747{
748 s32 ret_val;
749
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700750 if (hw->phy.media_type == e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700751 ret_val = e1000e_get_speed_and_duplex_copper(hw,
752 speed,
753 duplex);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800754 hw->phy.ops.cfg_on_link_up(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700755 } else {
756 ret_val = e1000e_get_speed_and_duplex_fiber_serdes(hw,
757 speed,
758 duplex);
759 }
760
761 return ret_val;
762}
763
764/**
765 * e1000_reset_hw_80003es2lan - Reset the ESB2 controller
766 * @hw: pointer to the HW structure
767 *
768 * Perform a global reset to the ESB2 controller.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700769 **/
770static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)
771{
Bruce Allandd93f952011-01-06 14:29:48 +0000772 u32 ctrl;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700773 s32 ret_val;
774
Bruce Allanad680762008-03-28 09:15:03 -0700775 /*
776 * Prevent the PCI-E bus from sticking if there is no TLP connection
Auke Kokbc7f75f2007-09-17 12:30:59 -0700777 * on the last TLP read/write transaction when MAC is reset.
778 */
779 ret_val = e1000e_disable_pcie_master(hw);
780 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000781 e_dbg("PCI-E Master disable polling has failed.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700782
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000783 e_dbg("Masking off all interrupts\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700784 ew32(IMC, 0xffffffff);
785
786 ew32(RCTL, 0);
787 ew32(TCTL, E1000_TCTL_PSP);
788 e1e_flush();
789
Bruce Allan1bba4382011-03-19 00:27:20 +0000790 usleep_range(10000, 20000);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700791
792 ctrl = er32(CTRL);
793
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800794 ret_val = e1000_acquire_phy_80003es2lan(hw);
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000795 e_dbg("Issuing a global reset to MAC\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700796 ew32(CTRL, ctrl | E1000_CTRL_RST);
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800797 e1000_release_phy_80003es2lan(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700798
799 ret_val = e1000e_get_auto_rd_done(hw);
800 if (ret_val)
801 /* We don't want to continue accessing MAC registers. */
802 return ret_val;
803
804 /* Clear any pending interrupt events. */
805 ew32(IMC, 0xffffffff);
Bruce Allandd93f952011-01-06 14:29:48 +0000806 er32(ICR);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700807
Bruce Allan608f8a02010-01-13 02:04:58 +0000808 ret_val = e1000_check_alt_mac_addr_generic(hw);
809
810 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700811}
812
813/**
814 * e1000_init_hw_80003es2lan - Initialize the ESB2 controller
815 * @hw: pointer to the HW structure
816 *
817 * Initialize the hw bits, LED, VFTA, MTA, link and hw counters.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700818 **/
819static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)
820{
821 struct e1000_mac_info *mac = &hw->mac;
822 u32 reg_data;
823 s32 ret_val;
Bruce Alland9b24132011-05-13 07:19:42 +0000824 u16 kum_reg_data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700825 u16 i;
826
827 e1000_initialize_hw_bits_80003es2lan(hw);
828
829 /* Initialize identification LED */
830 ret_val = e1000e_id_led_init(hw);
Bruce Allande39b752009-11-20 23:27:59 +0000831 if (ret_val)
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000832 e_dbg("Error initializing identification LED\n");
Bruce Allande39b752009-11-20 23:27:59 +0000833 /* This is not fatal and we should not stop init due to this */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700834
835 /* Disabling VLAN filtering */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000836 e_dbg("Initializing the IEEE VLAN\n");
Bruce Allancaaddaf2009-12-01 15:46:43 +0000837 mac->ops.clear_vfta(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700838
839 /* Setup the receive address. */
840 e1000e_init_rx_addrs(hw, mac->rar_entry_count);
841
842 /* Zero out the Multicast HASH table */
Bruce Allan3bb99fe2009-11-20 23:25:07 +0000843 e_dbg("Zeroing the MTA\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700844 for (i = 0; i < mac->mta_reg_count; i++)
845 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
846
847 /* Setup link and flow control */
848 ret_val = e1000e_setup_link(hw);
849
Bruce Alland9b24132011-05-13 07:19:42 +0000850 /* Disable IBIST slave mode (far-end loopback) */
851 e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
852 &kum_reg_data);
853 kum_reg_data |= E1000_KMRNCTRLSTA_IBIST_DISABLE;
854 e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM,
855 kum_reg_data);
856
Auke Kokbc7f75f2007-09-17 12:30:59 -0700857 /* Set the transmit descriptor write-back policy */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700858 reg_data = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700859 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
860 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700861 ew32(TXDCTL(0), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700862
863 /* ...for both queues. */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700864 reg_data = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700865 reg_data = (reg_data & ~E1000_TXDCTL_WTHRESH) |
866 E1000_TXDCTL_FULL_TX_DESC_WB | E1000_TXDCTL_COUNT_DESC;
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700867 ew32(TXDCTL(1), reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700868
869 /* Enable retransmit on late collisions */
870 reg_data = er32(TCTL);
871 reg_data |= E1000_TCTL_RTLC;
872 ew32(TCTL, reg_data);
873
874 /* Configure Gigabit Carry Extend Padding */
875 reg_data = er32(TCTL_EXT);
876 reg_data &= ~E1000_TCTL_EXT_GCEX_MASK;
877 reg_data |= DEFAULT_TCTL_EXT_GCEX_80003ES2LAN;
878 ew32(TCTL_EXT, reg_data);
879
880 /* Configure Transmit Inter-Packet Gap */
881 reg_data = er32(TIPG);
882 reg_data &= ~E1000_TIPG_IPGT_MASK;
883 reg_data |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
884 ew32(TIPG, reg_data);
885
886 reg_data = E1000_READ_REG_ARRAY(hw, E1000_FFLT, 0x0001);
887 reg_data &= ~0x00100000;
888 E1000_WRITE_REG_ARRAY(hw, E1000_FFLT, 0x0001, reg_data);
889
Bruce Allan3421eec2009-12-08 07:28:20 +0000890 /* default to true to enable the MDIC W/A */
891 hw->dev_spec.e80003es2lan.mdic_wa_enable = true;
892
893 ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
894 E1000_KMRNCTRLSTA_OFFSET >>
895 E1000_KMRNCTRLSTA_OFFSET_SHIFT,
896 &i);
897 if (!ret_val) {
898 if ((i & E1000_KMRNCTRLSTA_OPMODE_MASK) ==
899 E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO)
900 hw->dev_spec.e80003es2lan.mdic_wa_enable = false;
901 }
902
Bruce Allanad680762008-03-28 09:15:03 -0700903 /*
904 * Clear all of the statistics registers (clear on read). It is
Auke Kokbc7f75f2007-09-17 12:30:59 -0700905 * important that we do this after we have tried to establish link
906 * because the symbol error count will increment wildly if there
907 * is no link.
908 */
909 e1000_clear_hw_cntrs_80003es2lan(hw);
910
911 return ret_val;
912}
913
914/**
915 * e1000_initialize_hw_bits_80003es2lan - Init hw bits of ESB2
916 * @hw: pointer to the HW structure
917 *
918 * Initializes required hardware-dependent bits needed for normal operation.
919 **/
920static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw)
921{
922 u32 reg;
923
924 /* Transmit Descriptor Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700925 reg = er32(TXDCTL(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700926 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700927 ew32(TXDCTL(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700928
929 /* Transmit Descriptor Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700930 reg = er32(TXDCTL(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700931 reg |= (1 << 22);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700932 ew32(TXDCTL(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700933
934 /* Transmit Arbitration Control 0 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700935 reg = er32(TARC(0));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700936 reg &= ~(0xF << 27); /* 30:27 */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700937 if (hw->phy.media_type != e1000_media_type_copper)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700938 reg &= ~(1 << 20);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700939 ew32(TARC(0), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700940
941 /* Transmit Arbitration Control 1 */
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700942 reg = er32(TARC(1));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700943 if (er32(TCTL) & E1000_TCTL_MULR)
944 reg &= ~(1 << 28);
945 else
946 reg |= (1 << 28);
Jeff Kirshere9ec2c02008-04-02 13:48:13 -0700947 ew32(TARC(1), reg);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700948}
949
950/**
951 * e1000_copper_link_setup_gg82563_80003es2lan - Configure GG82563 Link
952 * @hw: pointer to the HW structure
953 *
954 * Setup some GG82563 PHY registers for obtaining link
955 **/
956static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)
957{
958 struct e1000_phy_info *phy = &hw->phy;
959 s32 ret_val;
960 u32 ctrl_ext;
Bruce Allan75eb0fa2008-11-21 16:53:51 -0800961 u16 data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700962
David Graham2d9498f2008-04-23 11:09:14 -0700963 ret_val = e1e_rphy(hw, GG82563_PHY_MAC_SPEC_CTRL, &data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700964 if (ret_val)
965 return ret_val;
966
967 data |= GG82563_MSCR_ASSERT_CRS_ON_TX;
968 /* Use 25MHz for both link down and 1000Base-T for Tx clock. */
969 data |= GG82563_MSCR_TX_CLK_1000MBPS_25;
970
David Graham2d9498f2008-04-23 11:09:14 -0700971 ret_val = e1e_wphy(hw, GG82563_PHY_MAC_SPEC_CTRL, data);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700972 if (ret_val)
973 return ret_val;
974
Bruce Allanad680762008-03-28 09:15:03 -0700975 /*
976 * Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700977 * MDI/MDI-X = 0 (default)
978 * 0 - Auto for all speeds
979 * 1 - MDI mode
980 * 2 - MDI-X mode
981 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
982 */
983 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL, &data);
984 if (ret_val)
985 return ret_val;
986
987 data &= ~GG82563_PSCR_CROSSOVER_MODE_MASK;
988
989 switch (phy->mdix) {
990 case 1:
991 data |= GG82563_PSCR_CROSSOVER_MODE_MDI;
992 break;
993 case 2:
994 data |= GG82563_PSCR_CROSSOVER_MODE_MDIX;
995 break;
996 case 0:
997 default:
998 data |= GG82563_PSCR_CROSSOVER_MODE_AUTO;
999 break;
1000 }
1001
Bruce Allanad680762008-03-28 09:15:03 -07001002 /*
1003 * Options:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001004 * disable_polarity_correction = 0 (default)
1005 * Automatic Correction for Reversed Cable Polarity
1006 * 0 - Disabled
1007 * 1 - Enabled
1008 */
1009 data &= ~GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
1010 if (phy->disable_polarity_correction)
1011 data |= GG82563_PSCR_POLARITY_REVERSAL_DISABLE;
1012
1013 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL, data);
1014 if (ret_val)
1015 return ret_val;
1016
1017 /* SW Reset the PHY so all changes take effect */
1018 ret_val = e1000e_commit_phy(hw);
1019 if (ret_val) {
Bruce Allan3bb99fe2009-11-20 23:25:07 +00001020 e_dbg("Error Resetting the PHY\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001021 return ret_val;
1022 }
1023
Bruce Allanad680762008-03-28 09:15:03 -07001024 /* Bypass Rx and Tx FIFO's */
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001025 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1026 E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL,
Bruce Allanad680762008-03-28 09:15:03 -07001027 E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS |
Auke Kokbc7f75f2007-09-17 12:30:59 -07001028 E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS);
1029 if (ret_val)
1030 return ret_val;
1031
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001032 ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
David Graham2d9498f2008-04-23 11:09:14 -07001033 E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
1034 &data);
1035 if (ret_val)
1036 return ret_val;
1037 data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001038 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
David Graham2d9498f2008-04-23 11:09:14 -07001039 E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE,
1040 data);
1041 if (ret_val)
1042 return ret_val;
1043
Auke Kokbc7f75f2007-09-17 12:30:59 -07001044 ret_val = e1e_rphy(hw, GG82563_PHY_SPEC_CTRL_2, &data);
1045 if (ret_val)
1046 return ret_val;
1047
1048 data &= ~GG82563_PSCR2_REVERSE_AUTO_NEG;
1049 ret_val = e1e_wphy(hw, GG82563_PHY_SPEC_CTRL_2, data);
1050 if (ret_val)
1051 return ret_val;
1052
1053 ctrl_ext = er32(CTRL_EXT);
1054 ctrl_ext &= ~(E1000_CTRL_EXT_LINK_MODE_MASK);
1055 ew32(CTRL_EXT, ctrl_ext);
1056
1057 ret_val = e1e_rphy(hw, GG82563_PHY_PWR_MGMT_CTRL, &data);
1058 if (ret_val)
1059 return ret_val;
1060
Bruce Allanad680762008-03-28 09:15:03 -07001061 /*
1062 * Do not init these registers when the HW is in IAMT mode, since the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001063 * firmware will have already initialized them. We only initialize
1064 * them if the HW is not in IAMT mode.
1065 */
1066 if (!e1000e_check_mng_mode(hw)) {
1067 /* Enable Electrical Idle on the PHY */
1068 data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE;
1069 ret_val = e1e_wphy(hw, GG82563_PHY_PWR_MGMT_CTRL, data);
1070 if (ret_val)
1071 return ret_val;
1072
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001073 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &data);
1074 if (ret_val)
1075 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001076
1077 data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1078 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, data);
1079 if (ret_val)
1080 return ret_val;
1081 }
1082
Bruce Allanad680762008-03-28 09:15:03 -07001083 /*
1084 * Workaround: Disable padding in Kumeran interface in the MAC
Auke Kokbc7f75f2007-09-17 12:30:59 -07001085 * and in the PHY to avoid CRC errors.
1086 */
1087 ret_val = e1e_rphy(hw, GG82563_PHY_INBAND_CTRL, &data);
1088 if (ret_val)
1089 return ret_val;
1090
1091 data |= GG82563_ICR_DIS_PADDING;
1092 ret_val = e1e_wphy(hw, GG82563_PHY_INBAND_CTRL, data);
1093 if (ret_val)
1094 return ret_val;
1095
1096 return 0;
1097}
1098
1099/**
1100 * e1000_setup_copper_link_80003es2lan - Setup Copper Link for ESB2
1101 * @hw: pointer to the HW structure
1102 *
1103 * Essentially a wrapper for setting up all things "copper" related.
1104 * This is a function pointer entry point called by the mac module.
1105 **/
1106static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)
1107{
1108 u32 ctrl;
1109 s32 ret_val;
1110 u16 reg_data;
1111
1112 ctrl = er32(CTRL);
1113 ctrl |= E1000_CTRL_SLU;
1114 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1115 ew32(CTRL, ctrl);
1116
Bruce Allanad680762008-03-28 09:15:03 -07001117 /*
1118 * Set the mac to wait the maximum time between each
Auke Kokbc7f75f2007-09-17 12:30:59 -07001119 * iteration and increase the max iterations when
Bruce Allanad680762008-03-28 09:15:03 -07001120 * polling the phy; this fixes erroneous timeouts at 10Mbps.
1121 */
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001122 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),
1123 0xFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001124 if (ret_val)
1125 return ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001126 ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1127 &reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001128 if (ret_val)
1129 return ret_val;
1130 reg_data |= 0x3F;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001131 ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),
1132 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001133 if (ret_val)
1134 return ret_val;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001135 ret_val = e1000_read_kmrn_reg_80003es2lan(hw,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001136 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
1137 &reg_data);
1138 if (ret_val)
1139 return ret_val;
1140 reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001141 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1142 E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,
Bruce Allanad680762008-03-28 09:15:03 -07001143 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001144 if (ret_val)
1145 return ret_val;
1146
1147 ret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);
1148 if (ret_val)
1149 return ret_val;
1150
1151 ret_val = e1000e_setup_copper_link(hw);
1152
1153 return 0;
1154}
1155
1156/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001157 * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up
1158 * @hw: pointer to the HW structure
1159 * @duplex: current duplex setting
1160 *
1161 * Configure the KMRN interface by applying last minute quirks for
1162 * 10/100 operation.
1163 **/
1164static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw)
1165{
1166 s32 ret_val = 0;
1167 u16 speed;
1168 u16 duplex;
1169
1170 if (hw->phy.media_type == e1000_media_type_copper) {
1171 ret_val = e1000e_get_speed_and_duplex_copper(hw, &speed,
1172 &duplex);
1173 if (ret_val)
1174 return ret_val;
1175
1176 if (speed == SPEED_1000)
1177 ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw);
1178 else
1179 ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex);
1180 }
1181
1182 return ret_val;
1183}
1184
1185/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001186 * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation
1187 * @hw: pointer to the HW structure
1188 * @duplex: current duplex setting
1189 *
1190 * Configure the KMRN interface by applying last minute quirks for
1191 * 10/100 operation.
1192 **/
1193static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex)
1194{
1195 s32 ret_val;
1196 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001197 u32 i = 0;
1198 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001199
1200 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001201 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1202 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1203 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001204 if (ret_val)
1205 return ret_val;
1206
1207 /* Configure Transmit Inter-Packet Gap */
1208 tipg = er32(TIPG);
1209 tipg &= ~E1000_TIPG_IPGT_MASK;
1210 tipg |= DEFAULT_TIPG_IPGT_10_100_80003ES2LAN;
1211 ew32(TIPG, tipg);
1212
David Graham2d9498f2008-04-23 11:09:14 -07001213 do {
1214 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1215 if (ret_val)
1216 return ret_val;
1217
1218 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1219 if (ret_val)
1220 return ret_val;
1221 i++;
1222 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001223
1224 if (duplex == HALF_DUPLEX)
1225 reg_data |= GG82563_KMCR_PASS_FALSE_CARRIER;
1226 else
1227 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1228
1229 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
1230
1231 return 0;
1232}
1233
1234/**
1235 * e1000_cfg_kmrn_1000_80003es2lan - Apply "quirks" for gigabit operation
1236 * @hw: pointer to the HW structure
1237 *
1238 * Configure the KMRN interface by applying last minute quirks for
1239 * gigabit operation.
1240 **/
1241static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
1242{
1243 s32 ret_val;
David Graham2d9498f2008-04-23 11:09:14 -07001244 u16 reg_data, reg_data2;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001245 u32 tipg;
David Graham2d9498f2008-04-23 11:09:14 -07001246 u32 i = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001247
1248 reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT;
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001249 ret_val = e1000_write_kmrn_reg_80003es2lan(hw,
1250 E1000_KMRNCTRLSTA_OFFSET_HD_CTRL,
1251 reg_data);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001252 if (ret_val)
1253 return ret_val;
1254
1255 /* Configure Transmit Inter-Packet Gap */
1256 tipg = er32(TIPG);
1257 tipg &= ~E1000_TIPG_IPGT_MASK;
1258 tipg |= DEFAULT_TIPG_IPGT_1000_80003ES2LAN;
1259 ew32(TIPG, tipg);
1260
David Graham2d9498f2008-04-23 11:09:14 -07001261 do {
1262 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data);
1263 if (ret_val)
1264 return ret_val;
1265
1266 ret_val = e1e_rphy(hw, GG82563_PHY_KMRN_MODE_CTRL, &reg_data2);
1267 if (ret_val)
1268 return ret_val;
1269 i++;
1270 } while ((reg_data != reg_data2) && (i < GG82563_MAX_KMRN_RETRY));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001271
1272 reg_data &= ~GG82563_KMCR_PASS_FALSE_CARRIER;
1273 ret_val = e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, reg_data);
1274
1275 return ret_val;
1276}
1277
1278/**
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001279 * e1000_read_kmrn_reg_80003es2lan - Read kumeran register
1280 * @hw: pointer to the HW structure
1281 * @offset: register offset to be read
1282 * @data: pointer to the read data
1283 *
1284 * Acquire semaphore, then read the PHY register at offset
1285 * using the kumeran interface. The information retrieved is stored in data.
1286 * Release the semaphore before exiting.
1287 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001288static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1289 u16 *data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001290{
1291 u32 kmrnctrlsta;
1292 s32 ret_val = 0;
1293
1294 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1295 if (ret_val)
1296 return ret_val;
1297
1298 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1299 E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN;
1300 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001301 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001302
1303 udelay(2);
1304
1305 kmrnctrlsta = er32(KMRNCTRLSTA);
1306 *data = (u16)kmrnctrlsta;
1307
1308 e1000_release_mac_csr_80003es2lan(hw);
1309
1310 return ret_val;
1311}
1312
1313/**
1314 * e1000_write_kmrn_reg_80003es2lan - Write kumeran register
1315 * @hw: pointer to the HW structure
1316 * @offset: register offset to write to
1317 * @data: data to write at register offset
1318 *
1319 * Acquire semaphore, then write the data to PHY register
1320 * at the offset using the kumeran interface. Release semaphore
1321 * before exiting.
1322 **/
Hannes Ederfa4c16d2008-12-22 09:16:13 +00001323static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
1324 u16 data)
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001325{
1326 u32 kmrnctrlsta;
1327 s32 ret_val = 0;
1328
1329 ret_val = e1000_acquire_mac_csr_80003es2lan(hw);
1330 if (ret_val)
1331 return ret_val;
1332
1333 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) &
1334 E1000_KMRNCTRLSTA_OFFSET) | data;
1335 ew32(KMRNCTRLSTA, kmrnctrlsta);
Jesse Brandeburg945a5152011-07-20 00:56:21 +00001336 e1e_flush();
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001337
1338 udelay(2);
1339
1340 e1000_release_mac_csr_80003es2lan(hw);
1341
1342 return ret_val;
1343}
1344
1345/**
Bruce Allan608f8a02010-01-13 02:04:58 +00001346 * e1000_read_mac_addr_80003es2lan - Read device MAC address
1347 * @hw: pointer to the HW structure
1348 **/
1349static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)
1350{
1351 s32 ret_val = 0;
1352
1353 /*
1354 * If there's an alternate MAC address place it in RAR0
1355 * so that it will override the Si installed default perm
1356 * address.
1357 */
1358 ret_val = e1000_check_alt_mac_addr_generic(hw);
1359 if (ret_val)
1360 goto out;
1361
1362 ret_val = e1000_read_mac_addr_generic(hw);
1363
1364out:
1365 return ret_val;
1366}
1367
1368/**
Bruce Allan17f208d2009-12-01 15:47:22 +00001369 * e1000_power_down_phy_copper_80003es2lan - Remove link during PHY power down
1370 * @hw: pointer to the HW structure
1371 *
1372 * In the case of a PHY power down to save power, or to turn off link during a
1373 * driver unload, or wake on lan is not enabled, remove the link.
1374 **/
1375static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw)
1376{
1377 /* If the management interface is not enabled, then power down */
1378 if (!(hw->mac.ops.check_mng_mode(hw) ||
1379 hw->phy.ops.check_reset_block(hw)))
1380 e1000_power_down_phy_copper(hw);
Bruce Allan17f208d2009-12-01 15:47:22 +00001381}
1382
1383/**
Auke Kokbc7f75f2007-09-17 12:30:59 -07001384 * e1000_clear_hw_cntrs_80003es2lan - Clear device specific hardware counters
1385 * @hw: pointer to the HW structure
1386 *
1387 * Clears the hardware counters by reading the counter registers.
1388 **/
1389static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw)
1390{
Auke Kokbc7f75f2007-09-17 12:30:59 -07001391 e1000e_clear_hw_cntrs_base(hw);
1392
Bruce Allan99673d92009-11-20 23:27:21 +00001393 er32(PRC64);
1394 er32(PRC127);
1395 er32(PRC255);
1396 er32(PRC511);
1397 er32(PRC1023);
1398 er32(PRC1522);
1399 er32(PTC64);
1400 er32(PTC127);
1401 er32(PTC255);
1402 er32(PTC511);
1403 er32(PTC1023);
1404 er32(PTC1522);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001405
Bruce Allan99673d92009-11-20 23:27:21 +00001406 er32(ALGNERRC);
1407 er32(RXERRC);
1408 er32(TNCRS);
1409 er32(CEXTERR);
1410 er32(TSCTC);
1411 er32(TSCTFC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001412
Bruce Allan99673d92009-11-20 23:27:21 +00001413 er32(MGTPRC);
1414 er32(MGTPDC);
1415 er32(MGTPTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001416
Bruce Allan99673d92009-11-20 23:27:21 +00001417 er32(IAC);
1418 er32(ICRXOC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001419
Bruce Allan99673d92009-11-20 23:27:21 +00001420 er32(ICRXPTC);
1421 er32(ICRXATC);
1422 er32(ICTXPTC);
1423 er32(ICTXATC);
1424 er32(ICTXQEC);
1425 er32(ICTXQMTC);
1426 er32(ICRXDMTC);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001427}
1428
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001429static const struct e1000_mac_operations es2_mac_ops = {
Bruce Allan608f8a02010-01-13 02:04:58 +00001430 .read_mac_addr = e1000_read_mac_addr_80003es2lan,
Bruce Allana4f58f52009-06-02 11:29:18 +00001431 .id_led_init = e1000e_id_led_init,
Bruce Allandbf80dc2011-04-16 00:34:40 +00001432 .blink_led = e1000e_blink_led_generic,
Bruce Allan4662e822008-08-26 18:37:06 -07001433 .check_mng_mode = e1000e_check_mng_mode_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001434 /* check_for_link dependent on media type */
1435 .cleanup_led = e1000e_cleanup_led_generic,
1436 .clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan,
1437 .get_bus_info = e1000e_get_bus_info_pcie,
Bruce Allanf4d2dd42010-01-13 02:05:18 +00001438 .set_lan_id = e1000_set_lan_id_multi_port_pcie,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001439 .get_link_up_info = e1000_get_link_up_info_80003es2lan,
1440 .led_on = e1000e_led_on_generic,
1441 .led_off = e1000e_led_off_generic,
Jeff Kirshere2de3eb2008-03-28 09:15:11 -07001442 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
Bruce Allancaaddaf2009-12-01 15:46:43 +00001443 .write_vfta = e1000_write_vfta_generic,
1444 .clear_vfta = e1000_clear_vfta_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001445 .reset_hw = e1000_reset_hw_80003es2lan,
1446 .init_hw = e1000_init_hw_80003es2lan,
1447 .setup_link = e1000e_setup_link,
1448 /* setup_physical_interface dependent on media type */
Bruce Allana4f58f52009-06-02 11:29:18 +00001449 .setup_led = e1000e_setup_led_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001450};
1451
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001452static const struct e1000_phy_operations es2_phy_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001453 .acquire = e1000_acquire_phy_80003es2lan,
Bruce Allan94e5b652009-12-02 17:02:14 +00001454 .check_polarity = e1000_check_polarity_m88,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001455 .check_reset_block = e1000e_check_reset_block_generic,
Bruce Allan94d81862009-11-20 23:25:26 +00001456 .commit = e1000e_phy_sw_reset,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001457 .force_speed_duplex = e1000_phy_force_speed_duplex_80003es2lan,
1458 .get_cfg_done = e1000_get_cfg_done_80003es2lan,
1459 .get_cable_length = e1000_get_cable_length_80003es2lan,
Bruce Allan94d81862009-11-20 23:25:26 +00001460 .get_info = e1000e_get_phy_info_m88,
1461 .read_reg = e1000_read_phy_reg_gg82563_80003es2lan,
1462 .release = e1000_release_phy_80003es2lan,
1463 .reset = e1000e_phy_hw_reset_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001464 .set_d0_lplu_state = NULL,
1465 .set_d3_lplu_state = e1000e_set_d3_lplu_state,
Bruce Allan94d81862009-11-20 23:25:26 +00001466 .write_reg = e1000_write_phy_reg_gg82563_80003es2lan,
Bruce Allan75eb0fa2008-11-21 16:53:51 -08001467 .cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001468};
1469
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001470static const struct e1000_nvm_operations es2_nvm_ops = {
Bruce Allan94d81862009-11-20 23:25:26 +00001471 .acquire = e1000_acquire_nvm_80003es2lan,
1472 .read = e1000e_read_nvm_eerd,
1473 .release = e1000_release_nvm_80003es2lan,
1474 .update = e1000e_update_nvm_checksum_generic,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001475 .valid_led_default = e1000e_valid_led_default,
Bruce Allan94d81862009-11-20 23:25:26 +00001476 .validate = e1000e_validate_nvm_checksum_generic,
1477 .write = e1000_write_nvm_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001478};
1479
Jeff Kirsher8ce9d6c2011-09-24 13:23:52 +00001480const struct e1000_info e1000_es2_info = {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001481 .mac = e1000_80003es2lan,
1482 .flags = FLAG_HAS_HW_VLAN_FILTER
1483 | FLAG_HAS_JUMBO_FRAMES
Auke Kokbc7f75f2007-09-17 12:30:59 -07001484 | FLAG_HAS_WOL
1485 | FLAG_APME_IN_CTRL3
Auke Kokbc7f75f2007-09-17 12:30:59 -07001486 | FLAG_HAS_CTRLEXT_ON_LOAD
Auke Kokbc7f75f2007-09-17 12:30:59 -07001487 | FLAG_RX_NEEDS_RESTART /* errata */
1488 | FLAG_TARC_SET_BIT_ZERO /* errata */
1489 | FLAG_APME_CHECK_PORT_B
Bruce Allan6a92f732011-12-16 00:46:12 +00001490 | FLAG_DISABLE_FC_PAUSE_TIME, /* errata */
Jesse Brandeburg3a3b7582010-09-29 21:38:49 +00001491 .flags2 = FLAG2_DMA_BURST,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001492 .pba = 38,
Bruce Allan2adc55c2009-06-02 11:28:58 +00001493 .max_hw_frame_size = DEFAULT_JUMBO,
Jeff Kirsher69e3fd82008-04-02 13:48:18 -07001494 .get_variants = e1000_get_variants_80003es2lan,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001495 .mac_ops = &es2_mac_ops,
1496 .phy_ops = &es2_phy_ops,
1497 .nvm_ops = &es2_nvm_ops,
1498};
1499